Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to latest mongosh, driver, and segment analytics VSCODE-366 #494

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,674 changes: 1,564 additions & 2,110 deletions package-lock.json

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"reformat": "prettier --write ."
},
"engines": {
"vscode": "^1.75.1",
"vscode": "^1.76.2",
"node": "^16.16.0",
"npm": "^8.15.1"
},
Expand Down Expand Up @@ -964,52 +964,52 @@
}
},
"dependencies": {
"@babel/parser": "^7.19.1",
"@babel/traverse": "^7.19.1",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@babel/parser": "^7.21.3",
"@babel/traverse": "^7.21.3",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@iconify-icons/codicon": "^1.2.16",
"@iconify-icons/codicon": "^1.2.23",
"@iconify/react": "^1.1.4",
"@leafygreen-ui/logo": "^6.1.3",
"@leafygreen-ui/logo": "^6.3.0",
"@leafygreen-ui/toggle": "^7.0.5",
"@mongodb-js/mongodb-constants": "^0.2.1",
"@mongosh/browser-runtime-electron": "^1.6.2",
"@mongosh/i18n": "^1.6.2",
"@mongosh/service-provider-server": "^1.6.2",
"@mongosh/shell-api": "^1.6.2",
"analytics-node": "^5.1.2",
"bson": "^4.7.0",
"bson-transpilers": "^2.0.0",
"@mongodb-js/mongodb-constants": "^0.2.2",
"@mongosh/browser-runtime-electron": "^1.8.0",
"@mongosh/i18n": "^1.8.0",
"@mongosh/service-provider-server": "^1.8.0",
"@mongosh/shell-api": "^1.8.0",
"analytics-node": "^6.2.0",
"bson": "^5.0.1",
"bson-transpilers": "^2.0.3",
"classnames": "^2.3.2",
"debug": "^4.3.4",
"dotenv": "^16.0.2",
"dotenv": "^16.0.3",
"micromatch": "^4.0.5",
"mongodb": "^4.13.0",
"mongodb": "^5.1.0",
"mongodb-build-info": "^1.5.0",
"mongodb-cloud-info": "^1.1.3",
"mongodb-connection-string-url": "^2.5.3",
"mongodb-data-service": "^22.4.1",
"mongodb-query-parser": "^2.4.6",
"mongodb-schema": "^10.0.0",
"mongodb-connection-string-url": "^2.6.0",
"mongodb-data-service": "^22.5.1",
"mongodb-query-parser": "^2.4.11",
"mongodb-schema": "^10.0.1",
"numeral": "^2.0.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^8.0.5",
"redux": "^4.2.0",
"redux": "^4.2.1",
"ts-log": "^2.2.5",
"uuid": "^8.3.2",
"vscode-languageclient": "^8.0.2",
"vscode-languageserver": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.7"
"vscode-languageclient": "^8.1.0",
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.9"
},
"devDependencies": {
"@mongodb-js/prettier-config-compass": "^1.0.0",
"@mongosh/service-provider-core": "^1.8.0",
"@types/analytics-node": "^3.1.9",
"@types/babel__core": "^7.1.19",
"@types/babel__traverse": "^7.18.1",
"@types/chai": "^4.3.3",
"@types/analytics-node": "^3.1.11",
"@types/babel__core": "^7.20.0",
"@types/babel__traverse": "^7.18.3",
"@types/chai": "^4.3.4",
"@types/chai-fs": "^2.0.2",
"@types/chai-json-schema": "^1.4.6",
"@types/debug": "^4.1.7",
Expand All @@ -1019,20 +1019,20 @@
"@types/micromatch": "^4.0.2",
"@types/mkdirp": "^2.0.0",
"@types/mocha": "^8.2.3",
"@types/node": "^14.18.29",
"@types/react": "^17.0.50",
"@types/react-dom": "^17.0.17",
"@types/node": "^14.18.38",
"@types/react": "^17.0.53",
"@types/react-dom": "^17.0.19",
"@types/sinon": "^9.0.11",
"@types/uuid": "^8.3.4",
"@types/vscode": "^1.74.0",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"@vscode/test-electron": "^2.1.5",
"@vscode/vsce": "^2.16.0",
"@types/vscode": "^1.76.0",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@vscode/test-electron": "^2.3.0",
"@vscode/vsce": "^2.18.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"autoprefixer": "^9.8.8",
"buffer": "^6.0.3",
"chai": "^4.3.6",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-fs": "^2.0.0",
"chai-json-schema": "^1.5.1",
Expand All @@ -1045,7 +1045,7 @@
"download": "^8.0.0",
"electron": "^23.0.0",
"enzyme": "^3.11.0",
"eslint": "^8.23.1",
"eslint": "^8.36.0",
"eslint-config-mongodb-js": "^5.0.3",
"eslint-plugin-mocha": "^10.1.0",
"execa": "^1.0.0",
Expand All @@ -1057,26 +1057,26 @@
"less-loader": "^5.0.0",
"mkdirp": "^1.0.4",
"mocha": "^8.4.0",
"mocha-junit-reporter": "^2.0.2",
"mocha-multi": "^1.1.6",
"mongodb-client-encryption": "^2.4.0",
"mongodb-runner": "^4.9.0",
"mocha-junit-reporter": "^2.2.0",
"mocha-multi": "^1.1.7",
"mongodb-client-encryption": "^2.6.0",
"mongodb-runner": "^4.10.0",
"node-loader": "^0.6.0",
"npm-run-all": "^4.1.5",
"ora": "^5.4.1",
"postcss-loader": "^3.0.0",
"pre-commit": "^1.2.2",
"prettier": "^2.7.1",
"prettier": "^2.8.5",
"process": "^0.11.10",
"semver": "^7.3.7",
"semver": "^7.3.8",
"sinon": "^9.2.4",
"sinon-chai": "^3.7.0",
"stream-browserify": "^3.0.0",
"style-loader": "^1.3.0",
"ts-jest": "^26.5.6",
"ts-loader": "^9.4.1",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^4.8.3",
"typescript": "^4.9.5",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"xvfb-maybe": "^0.2.1",
Expand Down
10 changes: 5 additions & 5 deletions src/editors/documentIdStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EJSON } from 'bson';
import { v4 as uuidv4 } from 'uuid';
import type { EJSONSerializableTypes } from './../types/editDocumentInfoType';

// In order to provide opening documents with various _id types we need
// to pass the documentId and create associated documentIdReference.
Expand All @@ -8,10 +8,10 @@ import { v4 as uuidv4 } from 'uuid';
export default class DocumentIdStore {
_documents: {
documentIdReference: string;
documentId: EJSON.SerializableTypes;
documentId: EJSONSerializableTypes;
}[] = [];

add(documentId: EJSON.SerializableTypes): string {
add(documentId: EJSONSerializableTypes): string {
const existingDocument = this._documents.find(
(item) => item.documentId === documentId
);
Expand All @@ -22,7 +22,7 @@ export default class DocumentIdStore {

const newDocument: {
documentIdReference: string;
documentId: EJSON.SerializableTypes;
documentId: EJSONSerializableTypes;
} = {
documentIdReference: uuidv4(),
documentId,
Expand All @@ -33,7 +33,7 @@ export default class DocumentIdStore {
return newDocument.documentIdReference;
}

get(documentIdReference: string): EJSON.SerializableTypes | undefined {
get(documentIdReference: string): EJSONSerializableTypes | undefined {
const existingDocument = this._documents.find(
(item) => item.documentIdReference === documentIdReference
);
Expand Down
3 changes: 2 additions & 1 deletion src/editors/editDocumentCodeLensProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';

import ConnectionController from '../connectionController';
import { DocumentSource } from '../documentSource';
Expand Down Expand Up @@ -29,7 +30,7 @@ export default class EditDocumentCodeLensProvider
}

updateCodeLensesForCollection(data: {
content: EJSON.SerializableTypes;
content: Document;
namespace: string | null;
uri: vscode.Uri;
}) {
Expand Down
16 changes: 10 additions & 6 deletions src/editors/editorsController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import { EJSON } from 'bson';
import type { Document } from 'bson';

import ActiveConnectionCodeLensProvider from './activeConnectionCodeLensProvider';
import ExportToLanguageCodeLensProvider from './exportToLanguageCodeLensProvider';
Expand All @@ -18,7 +19,10 @@ import { createLogger } from '../logging';
import DocumentIdStore from './documentIdStore';
import { DocumentSource } from '../documentSource';
import EditDocumentCodeLensProvider from './editDocumentCodeLensProvider';
import type { EditDocumentInfo } from '../types/editDocumentInfoType';
import type {
EditDocumentInfo,
EJSONSerializableTypes,
} from '../types/editDocumentInfoType';
import formatError from '../utils/formatError';
import { MemoryFileSystemProvider } from './memoryFileSystemProvider';
import MongoDBDocumentService, {
Expand All @@ -36,7 +40,7 @@ import TelemetryService from '../telemetry/telemetryService';
const log = createLogger('editors controller');

export function getFileDisplayNameForDocument(
documentId: EJSON.SerializableTypes,
documentId: EJSONSerializableTypes,
namespace: string
) {
let displayName = `${namespace}:${EJSON.stringify(documentId)}`;
Expand Down Expand Up @@ -160,11 +164,11 @@ export default class EditorsController {

async openMongoDBDocument(data: EditDocumentInfo): Promise<boolean> {
try {
const mdbDocument = (await this._mongoDBDocumentService.fetchDocument(
const mdbDocument = await this._mongoDBDocumentService.fetchDocument(
data
)) as EJSON.SerializableTypes;
);

if (mdbDocument === null) {
if (!mdbDocument) {
void vscode.window.showErrorMessage(`
Unable to open mongodb document: document ${JSON.stringify(
data.documentId
Expand Down Expand Up @@ -346,7 +350,7 @@ export default class EditorsController {

_saveDocumentToMemoryFileSystem(
fileUri: vscode.Uri,
document: EJSON.SerializableTypes
document: Document
): void {
this._memoryFileSystemProvider.writeFile(
fileUri,
Expand Down
28 changes: 14 additions & 14 deletions src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as util from 'util';
import * as vscode from 'vscode';
import { EJSON, Document } from 'bson';
import { EJSON } from 'bson';
import type { Document, ObjectId } from 'bson';

import ConnectionController from '../connectionController';
import { createLogger } from '../logging';
import { DocumentSource } from '../documentSource';
import type { EditDocumentInfo } from '../types/editDocumentInfoType';
import type {
EditDocumentInfo,
EJSONSerializableTypes,
} from '../types/editDocumentInfoType';
import formatError from '../utils/formatError';
import { StatusView } from '../views';
import TelemetryService from '../telemetry/telemetryService';
Expand Down Expand Up @@ -54,10 +58,10 @@ export default class MongoDBDocumentService {
}

async replaceDocument(data: {
documentId: EJSON.SerializableTypes;
documentId: EJSONSerializableTypes;
namespace: string;
connectionId: string;
newDocument: EJSON.SerializableTypes;
newDocument: Document;
source: DocumentSource;
}): Promise<void> {
log.info('Replace document in MongoDB', data);
Expand Down Expand Up @@ -90,8 +94,8 @@ export default class MongoDBDocumentService {
);
await findOneAndReplace(
namespace,
{ _id: documentId },
newDocument as Document,
{ _id: documentId as ObjectId },
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
newDocument,
{ returnDocument: 'after' }
);

Expand All @@ -104,9 +108,7 @@ export default class MongoDBDocumentService {
}
}

async fetchDocument(
data: EditDocumentInfo
): Promise<EJSON.SerializableTypes | void> {
async fetchDocument(data: EditDocumentInfo): Promise<Document | void> {
log.info('Fetch document from MongoDB', data);

const { documentId, namespace, connectionId } = data;
Expand Down Expand Up @@ -135,19 +137,17 @@ export default class MongoDBDocumentService {
try {
const documents = await dataservice.find(
namespace,
{ _id: documentId },
{ _id: documentId as ObjectId },
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
{ limit: 1 }
);

this._statusView.hideMessage();

if (!documents || documents.length === 0) {
return null;
return;
}

return JSON.parse(
EJSON.stringify(documents[0])
) as EJSON.SerializableTypes;
return JSON.parse(EJSON.stringify(documents[0]));
} catch (error) {
this._statusView.hideMessage();

Expand Down
11 changes: 6 additions & 5 deletions src/explorer/documentTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { EJSON } from 'bson';
import * as vscode from 'vscode';
import type { Document } from 'mongodb';
import { EJSON } from 'bson';
import type { Document, ObjectId } from 'bson';
import type { DataService } from 'mongodb-data-service';
import { promisify } from 'util';
import { toJSString } from 'mongodb-query-parser';
import type { EJSONSerializableTypes } from './../types/editDocumentInfoType';

import formatError from '../utils/formatError';

Expand All @@ -18,7 +19,7 @@ export default class DocumentTreeItem
namespace: string;
dataService: DataService;
document: Document;
documentId: EJSON.SerializableTypes;
documentId: EJSONSerializableTypes;
resetDocumentListCache: () => Promise<void>;

constructor(
Expand Down Expand Up @@ -61,7 +62,7 @@ export default class DocumentTreeItem
async getDocumentContents(): Promise<Document> {
const documents = await this.dataService.find(
this.namespace,
{ _id: this.documentId },
{ _id: this.documentId as ObjectId },
alenakhineika marked this conversation as resolved.
Show resolved Hide resolved
{ limit: 1 }
);

Expand Down Expand Up @@ -109,7 +110,7 @@ export default class DocumentTreeItem
);
const deleteResult = await deleteOne(
this.namespace,
{ _id: this.documentId },
{ _id: this.documentId as ObjectId },
{}
);

Expand Down
Loading