vscode-cosmosdb/main.ts

46 строки
2.1 KiB
TypeScript
Исходник Обычный вид История

Query Editor (NoSQL + Mongo) (#2318) * Dev/sda/cosmosdb nosql query editor (#2295) * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * Dev/sda/cosmosdb nosql query editor (#2296) * feat(webview): Adds new command to show QueryEditor - New Webview panels: QueryEditor, Result - Adds webpack config for React components - Adds new transport between VSCode and Webview - Adds index.tsx as a base for all webview panels * Added support for Fluent UI 9 with VSCode theming (first iteration) (#2298) * added Fluent UI 9 + a demo webview * package.json sorted its commands. * hotfixes to recover a failing build after a package.json upgrade somewhere down the line * Cleaner token override for a Fluent UI adaptive theme * Added scripts, tasks, and launch cofigurations * feat(webview): Dynamically changed theme provider (#2299) * feat(webview): Adds dynamic theme provider * fix(fluent-ui): Minor fixes (#2300) - Bumps floating-ui package - Adds css loader - Fixes task runner * Maintenance: Run a prettier process on the entire codebase. * feat(webview): Adds monaco editor (#2302) * Preview of mongoClusters support (#2306) - Migrated codebase from another repository. - Enabled MongoDB cluster support in Azure Resources. - Implemented work-in-progress updates for: - Slickgrid integration and styling. - Table, tree, and JSON views with auto-resizing. - Improved table and treeview stability. - Basic error handling and query editing. - Upgraded dependencies and fixed various bugs: - Slickgrid-react upgraded to version 5.5.1. - Resolved webview activation issues for MongoDB clusters. - Language service loading error fixed. - Introduced 'jest' testing framework, maintaining legacy 'mocha' tests. - Ran Prettier across the entire codebase. - Refactored and relocated slickgrid utilities. - Final updates to package.json and dependencies. * Dev/sda/query editor context (#2307) * feat(webview): Adds context * feat(webview): Implements Connect/Disconnect buttons * feat(eslint): Fixes eslint errors * feat(audit): Fixes audit errors * feat(audit): Fixes audit errors * feat(audit): Fixes audit errors * chore: Adds webpack analyzer + Adaptive theme * Reviewing vCore merge into development (#2308) - Refactor CollectionView to use useContext for state management - add 'loading' state support, and disable toolbar buttons. - Fixed issues with clusters lacking multi-user support, - unique ID generation in slickgrid utils, and page number formatting. - Enhanced cluster configuration discovery and improved UX. - Added queryResults message handling to the webview panel and fixed import typo. * Remove unused DataViewPanelJSON, DataViewPanelTable, and DataViewPanelTree components in duplicated files * vCore: added monaco with JSON support to the collection view webview (#2309) * chore: Query Editor Result Panel * fix: Update paths for DataViewPanelTable and DataViewPanelTree imports in ResultTab * chore: Query Editor Result Panel * refactor: Remove unused Fluent UI Demo * update launch.json, tasks.json, package.json configs used during mongoClusters development - Update launch.json and tasks.json to include a new configuration for watching and running the extension, webview, and host without extensions profile - Remove unnecessary scripts from package.json * bugfix: launching/watching extension restored Fixed the following error: Error: failed to handle: base_dir(`./`) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly. This cannot be deduced by SWC itself because SWC is a transpiler and it does not try to resolve project details. In other words, SWC does not know which directory should be used as a base directory. It can be deduced if `.swcrc` is used, but if not, there are many candidates. e.g. the directory containing `package.json`, or the current working directory. Because of that, the caller (typically the developer of the JavaScript package) should specify it. If you see this error, please report an issue to the package author. * simplify launch.json and tasks.json for mongoClusters development * [mongoClusters] Update file paths and imports for mongoClusters development ('vCore' --> 'mongoClusters') (#2310) * chore: Updates linter - Eslint has been updated - Prettier has been updated - Code has been updated using new rules * chore: Updates linter - Eslint has been updated - Prettier has been updated - Code has been updated using new rules * feat: Query Editor Tab might be open multiple times (#2312) * chore: Removed unused dev packages * refactor: Rename CredentialsStore to CredentialCache This commit renames the class CredentialsStore to CredentialCache in the mongoClusters module. The purpose of this change is to provide a more accurate and descriptive name for the class that stores and retrieves credentials for connecting to MongoDB clusters. The renaming is done to improve code readability and maintain consistency within the module. The following changes were made: - Renamed src/mongoClusters/CredentialsStore.ts to src/mongoClusters/CredentialCache.ts - Updated import statements and references to the renamed class in other files No functional changes were made in this commit. * Dev/sda/new package (#2315) * chore: Adds new package script * chore: Removes old build * chore: Extension loads json and css plugins in production mode (#2317) - Fixes production webpack config - Fixes package script - State changes correctly in SQL editor - Refactoring: moving functions that transform query result data to the utils directory * chore: Fix extension version in package-lock.json * chore: Fix prettier issues * JSON Schema analyzer for MongoDB BSON documents first iteration, with some stats, but some requried fields still missing. * Refactor test file paths for better organization * JSON Schema Analyzer: Moved queue implementation from an array to a de-queue * Refactor import statements to use default imports (as a consequence of a previous tsconfig update of "esModuleInterop": true) * Refactor import statements and update value display in slickgrid table and tree. Using unified toString functions * Refactor, simplify function names, add comments. * chore: Adaptive theme supports VSCode dark themes (#2320) * fix: Fixes adaptive light theme colors * mongoClusters: Document Schema (#2319) * JSON Schema analyzer for MongoDB BSON documents * Refactor test file paths for better organization * Refactor import statements to use default imports (as a consequence of a previous tsconfig update of "esModuleInterop": true) * Refactor import statements and update value display in slickgrid table and tree. Using unified toString functions * Refactor, simplify function names, add comments. * added data type labels to the table view * chore: Adaptive theme supports VSCode dark themes (#2320) * fix: Fixes adaptive light theme colors * mongoClusters: Document Schema (#2319) * JSON Schema analyzer for MongoDB BSON documents * Refactor test file paths for better organization * Refactor import statements to use default imports (as a consequence of a previous tsconfig update of "esModuleInterop": true) * Refactor import statements and update value display in slickgrid table and tree. Using unified toString functions * Refactor, simplify function names, add comments. * mongoClusters: added index support (display only) * fix: mongoClusters: grid cell rendering * refactor: Remove obsolete console.log statement in MongoClustersClient.ts * Dev/sda/paginator (#2321) feat: Implementing paginator * wip: adding document editing, handling document selection and objectid discovery. * wip: deleting documents from the table view * wip: view document skeleton * wip: moved from json docs to json docs [] for the JSON view * chore: Bumps Node.js version * chore: Revert problemMatcher changes * chore: Fixes development build - Fixes prettier issues - Uses own build steps * chore: Fixes development build - Fixes prettier issues - Uses own build steps * chore: Fixes development build - Fixes prettier issues - Uses own build steps * wip: mongoClusters: adding/updating and deleting documents * bugfix: view self-switching back to prev view * Preventing mongClusters/vCore commands from being shown when disabled. * Improve: Preventing mongClusters/vCore commands from being shown when disabled. * Dev/sda/unit tests (#2323) * chore: Fixes unit test runner - jest: mocking vscode - mocha: fix extension.bundle.js path * chore: Fixes eslint * chore: Fixes prettier issue * wip: enable debugging on Windows+WSL * Remove unused extension recommendation "ms-vscode.azure-account" is no longer in use. * enable debugging on Windows+WSL * enable debugging on Windows+WSL * chore: Adaptive theme supports VSCode dark themes (#2320) * fix: Fixes adaptive light theme colors * mongoClusters: Document Schema (#2319) * JSON Schema analyzer for MongoDB BSON documents * Refactor test file paths for better organization * Refactor import statements to use default imports (as a consequence of a previous tsconfig update of "esModuleInterop": true) * Refactor import statements and update value display in slickgrid table and tree. Using unified toString functions * Refactor, simplify function names, add comments. * Dev/sda/paginator (#2321) feat: Implementing paginator * chore: Bumps Node.js version * chore: Revert problemMatcher changes * chore: Fixes development build - Fixes prettier issues - Uses own build steps * chore: Fixes development build - Fixes prettier issues - Uses own build steps * chore: Fixes development build - Fixes prettier issues - Uses own build steps * Preventing mongClusters/vCore commands from being shown when disabled. * Improve: Preventing mongClusters/vCore commands from being shown when disabled. * Dev/sda/unit tests (#2323) * chore: Fixes unit test runner - jest: mocking vscode - mocha: fix extension.bundle.js path * chore: Fixes eslint * chore: Fixes prettier issue * wip: enable debugging on Windows+WSL * Remove unused extension recommendation "ms-vscode.azure-account" is no longer in use. * enable debugging on Windows+WSL * enable debugging on Windows+WSL * merge-bug-fix: Remove duplicate code. * chore: Monaco adaptive theme (#2324) * chore: Monaco adaptive theme * chore: Add mandatory OSS comment * Refactor authentication titles for MongoDB cluster connection * chore: Adaptive theme supports VSCode dark themes (#2320) * mongoClusters: Document Schema (#2319) * JSON Schema analyzer for MongoDB BSON documents * Refactor test file paths for better organization * Refactor import statements to use default imports (as a consequence of a previous tsconfig update of "esModuleInterop": true) * Refactor import statements and update value display in slickgrid table and tree. Using unified toString functions * Refactor, simplify function names, add comments. * Dev/sda/paginator (#2321) feat: Implementing paginator * chore: Revert problemMatcher changes * chore: Fixes development build - Fixes prettier issues - Uses own build steps * chore: Fixes development build - Fixes prettier issues - Uses own build steps * Preventing mongClusters/vCore commands from being shown when disabled. * Improve: Preventing mongClusters/vCore commands from being shown when disabled. * Dev/sda/unit tests (#2323) * chore: Fixes unit test runner - jest: mocking vscode - mocha: fix extension.bundle.js path * chore: Monaco adaptive theme (#2324) * chore: Monaco adaptive theme * chore: Add mandatory OSS comment * chore: Monaco editor moved to share component (#2325) * merge-bug-fix: mongoclusters, re-enabling document editing * fix: Fixes slickgrid resize container * Fix Cosmos DB user facing terminology (#2326) * Fix legacy Cosmos DB NoSQL terminology: "Core (SQL)" to "NoSQL", "collection" to "container" (NoSQL only). * Rename "Core (SQL)" to "NoSQL" * Renaming collection to container for nosql * Fix lint issue * fix-merge: restoring lost changes * introducing .gitattribuntes to help with WSL+Windows support * chore: Items in submenu were rearrange (#2328) * Add ErrorBoundary connected to telemetry (#2329) * Initial implementation of ErrorBoundary with reporting error to QueryTab * Connect ErrorBoundary to telemetry * Revert unneded change * Revert unneded change * Fix build issue. Make sure reportError exist before calling it * Fix comments * Finalize telemetry callback id * Fix telemetry id and rename reporting function and message name * Wire "azureDatabases.reportIssue" to ErrorBoundary error mesage * Rename event id * vCore: cleaned-up JSON doc view for vCore * Dev/sda/telemetry (#2330) chore: Adds telemetry to all important functions * temporarily removed husky pre-commit * vCore: added database and collection management, improved resource info caching (#2331) * vCore: added create drop db collection * vCore: improved connection/session caching * vCore: feature: not waiting for vCore details before displaying vCore resources * chore: New theme for Slickgrid (#2327) * chore: New theme for Slickgrid * chore: Small fixes - Revert some changes after merging Tomasz PR - Remove Husky * chore: Introduces eslint license header plugin (#2332) - eslint checks copyright header in each ts(x) file - eslint --fix was ran. Fixed all files without copyright header * vCore: added JSON editing support, unified webview implementation for mongoClusters (tRPC prototype) (#2335) - Introduced new webview and messaging system based on tRPC (prototyping with vCore) - Migrated documentView and collectionView to tRPC. - Added JSON editing support to vCore and reorganized BSON/JSON/EJSON handling. - Refactored and rearranged core files, removed unused dependencies, and added missing copyright comments. * chore: Fixes prettier issue * Document viewer (#2334) * feat: New tab for viewing/editing/creating document * feat: Implementing BaseTab as parent class for QueryEditorTab and DocumentTab (#2336) * fix: Fixes indent in main.yaml * vCore: prettier -w * chore: Bump upload-artifact version * chore: Bump actions/checkout and actions/setup-node versions * chore: Bump dependencies versions * fix: Fetch All shows records (#2339) - Records counter shows the number of records or All while query is executing - Return to first page works properly - Table view shows all records * chore: Adds info about next release (#2338) * chore: Adds info about next release - New release info - Fixes README typos --------- Co-authored-by: Vsevolod Kukol <sevoku@microsoft.com> * feat: Timer shows instead of record counter while query is executing (#2341) * vCore: adding table view data navigation into objects (#2342) **vCore Enhancements:** - Extract properties from JSON schema at a given path. - Resolved SlickGrid rendering issues for step-in/step-out functionality. - Ensured _id remains as the first column in table views. - Disabled text selection on elements in the collection view - UI and Session Management: * vCore: add import + export support for vCore collections (EJSON) (#2344) vCore: Add document import/export functionality with streaming and BSON support * feat: The edit mode was removed. View | Edit | Delete buttons are available if there are selected rows (#2343) * vCore: mongosh support (at the mongoCluster and the database level) (#2348) vCore: added mongosh support for mongo clusters * fix: Adds indicator that document is opened in read only mode (#2345) * fix: Slickgrid message "No data to display" has fixed placed while query is re-executing (#2346) * fix: QueryEditor and Document toolbars has the same size and positions (#2347) * vCore: Unified UX for the collection view (#2349) vCore: Unified UI/UX of the collection view to match a common style. * vCore: auto-completion for find filter queries (#2352) Implemented basic query auto-completion functionality for find filter queries in vCore * fix: All records have unique Id for table view. (#2353) - Fixes issue with non-unique id - Fixes issue that document is not found when it opens in view tab. Edit buttons are displayed only if query is `SELECT * ...` * vCore: removed the @fluentui/react import that was enforcing an obsolete font downloads (#2354) * Fix an issue where an internal error is not meaningful (#2351) There are several scenarios where loading database resources might fail. This change adds an optional message to a commonly used nonNullValue check function and improves database resource resolution error handling. Additioally the resource ID and Name gets now masked when reporting errors to telemetry and GitHub issues. * Fix formatting * Update Readme.md (#2350) * Some minor Readme improvements * Update Overview picture in Readme * Add Query Editor to Readme * vCore: breadcrumb support for table level navigation (#2356) * feat: The use can open document for editing if document was open as read-only (#2357) * fix: Removing top-level ellipsis in Tree View (#2358) * fix: Disconnect button has the same icon as the connect button. The difference in colors (#2360) * fix: Document error messages are shown in VS Code (#2361) * vCore: Updated Layout, Resolved ResizeObserver issues, changes to cred management (#2362) - Moved breadcrumbs to bottom of the screen. - Fixed password re-entry bug on refresh. - Added import/export buttons to collection view. - Set query to initialize as `{ }`. - Resolved resize errors in document view. - Refactored toolbar and improved Monaco editor integration: - Removed unused class from `ToolbarTableNavigation`. - Added `MonacoAdaptive` component for layout improvements. - Renamed editor mount handler for clarity. - Cleaned up unused styles and adjusted editor options. * feat(table-view): Double click on record opens document view in read-only mode (#2364) * vCore: clear invalid credentials and allow password re-entry (#2363) * Query editor title represent current connection (#2365) * fix: Query Editor Tab changes title if connection is active * feat: New duplicate button which opens new query editor tab with the same query * vCore: bugfix: collection view remains open when opening documents (#2367) * vCore: an attempt to handle an aborted password entry (#2369) * fix: Stats table shows scrollbars if table does not fit to container (#2370) * fix: Only selected rows are copied/downloaded (#2371) * Dev/sda/copy or download only selected rows (#2372) * fix: Only selected rows are copied/downloaded * SlickGrid Table and Tree layout fix (bottom padding/margin) (#2373) * vCore: UI tweaks and improvements (#2374) * vCore: add an extended confirmation dialog for "risky" operations (#2355) * vCore: handle empty clusters and empty databases (#2380) added placeholder nodes for empty clusters and empty databases * Fix an issue where Mongo nodes did not have a local parent assigned (#2378) Flag all AzExtTreeItem.parent overrides as type-only declarations most AzExtTreeItem implementation override the AzExtTreeItem.parent field with a more specific type. This was not an issue before, but with swc or more recent tsc these fields get initialized after the parent AzExtTreeItem completes and overwrite whatever it has assigned already. This results in .parent being undefined after all constructors finish, and many parent operations fail at runtime. The right way to address this it to indicate to TS that the declaration is for type safety only and should not have any runtime effects. Documentation: https://www.typescriptlang.org/docs/handbook/2/classes.html#type-only-field-declarations * Prevent duplicate headers (#2376) * Fix an issue where a MongoDB connection error might be hidden by a missing null check. (#2384) * Improve Capacity Mode selection wording (#2386) * Fix an issue where a Document shows as "undefined" if _id is not set (#2383) This is likely to happen if "id" has been removed from the cosmosDB.documentLabelFields setting. * feat: Index Metrics in Stats (#2366) * feat: New Tab with Index Metrics * feat: Index Metrics moved to Stats tab * Dispatch Query errors to VS Code (#2388) and show a native message with reporting to Output window. Additionally handle unexpected error reporting. * feat: Use webview tab for new Cosmos DB document (#2390) * Fix formatting issue * fix: Dispatch Query errors to VS Code (#2393) and show a native message with reporting to Output window. Additionally handle unexpected error reporting. * Run npm ci as an additional setup step at the end (#2391) * Run npm ci as an additional setup step at the end * Move vsix to root folder after packaging since this is where the shared build pipeline extects to find it. * Reword RBAC setting description (#2389) * fix: Allow to go back during connect flow (#2392) * Improve server names when creating a new resource (#2385) * Revert resource tag change when creating NoSQL account * Improve server names when creating a new resource * fix: Allow to go back during connect flow * fix: Decrease toolbar paddings (#2394) * extended confirmation dialog for "risky" operations (#2377) * improved deletion challenge options * transition to DialogResponses and ensuring that the 'random number' is never the default one. * Add vCore to Mongo Capacity Mode selection (#2387) * Improve Capacity Mode selection wording * Add vCore to Mongo Capacity Mode selection * fix formatting * Adds support for connecting to MongoDB Clusters with a connection string and for attaching more than one database account (#2395) - Implemented SharedWorkspaceStorage for unified storage structure - Enabled adding/removing MongoDB cluster connections - Improved error handling, comments, and refactored code - Updated workspace item handling for RU and vCore accounts --------- Co-authored-by: Tomasz Naumowicz <tnaum-ms@naumowicz.de> Co-authored-by: Tomasz Naumowicz <tnaumowicz@microsoft.com> Co-authored-by: Laurent Nguyen <laurent.nguyen@microsoft.com> Co-authored-by: Vsevolod Kukol <sevoku@microsoft.com>
2024-11-12 16:19:27 +03:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// This file is copy of main.js. It was created to not brake the old build process, but provides the same functionality as main.js.
// The old webpack config changes the source code of the main.js file to replace the import statements with require statements.
// The new webpack config does not do this anymore, uses swc for transpiling and does not change the source code.
// This is the extension entrypoint module, which imports extension.bundle.js, the actual extension code.
// This is in a separate file so we can properly measure extension.bundle.js load time.
import { type apiUtils } from '@microsoft/vscode-azext-utils';
import type * as vscode from 'vscode';
import * as extension from './src/extension';
const perfStats = {
loadStartTime: Date.now(),
loadEndTime: -1,
};
export async function activate(ctx: vscode.ExtensionContext): Promise<apiUtils.AzureExtensionApiProvider> {
if (process.env['STOP_ON_ENTRY'] === "true") {
/**
* It's useful to have a debugger statement here to stop the extension at the very beginning.
* Otherwise, it's hard to attach the debugger to the extension host process before the extension starts.
* In some environments (for example Windows+WSL), the extension host process starts quickly,
* before the debugger can attach.
*/
// eslint-disable-next-line no-debugger
debugger;
}
return extension.activateInternal(ctx, perfStats);
}
export async function deactivate(ctx: vscode.ExtensionContext): Promise<void> {
return extension.deactivateInternal(ctx);
}
perfStats.loadEndTime = Date.now();
// Since not all unit/integration tests right now might be moved to jest, we need to export some classes/functions.
export * from './src/utils/getIp';