From bac97c1ed3414d1c5922774e319e2f398f940000 Mon Sep 17 00:00:00 2001 From: Paula Stachova Date: Mon, 18 Mar 2024 10:48:10 +0100 Subject: [PATCH 1/6] chore(e2e): disable range test for 8.0+ (#5581) --------- Co-authored-by: Anna Henningsen --- packages/compass-e2e-tests/tests/in-use-encryption.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts index ee6c01ea260..9ab47fe5d72 100644 --- a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts +++ b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts @@ -447,6 +447,10 @@ describe('CSFLE / QE', function () { ['range', collectionNameRange], ] as const) { it(`can edit and query the ${mode} encrypted field in the CRUD view`, async function () { + // TODO(COMPASS-7760): re-enable after 7.3/8.0 support is ready + if (mode === 'range' && serverSatisfies('>= 8.0.0-alpha')) { + return this.skip(); + } const [field, oldValue, newValue] = mode !== 'range' ? ['phoneNumber', '"30303030"', '"10101010"'] From 97303245b2d4d603ab5a2011e90120b80e135887 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:56:01 +0000 Subject: [PATCH 2/6] chore: update AUTHORS and THIRD-PARTY-NOTICES (#5587) Update report Co-authored-by: paula-stacho --- THIRD-PARTY-NOTICES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index d6254a5b12f..b73f8eca374 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -1,5 +1,5 @@ The following third-party software is used by and included in **Mongodb Compass**. -This document was automatically generated on Sun Mar 17 2024. +This document was automatically generated on Mon Mar 18 2024. ## List of dependencies From 46e636c024b12956b0410d125d1267e4ba8f7cbd Mon Sep 17 00:00:00 2001 From: Himanshu Singh Date: Mon, 18 Mar 2024 11:18:25 +0100 Subject: [PATCH 3/6] feat(ConnectionsManager): introduce ConnectionsManager as a way to inject DataService into Compass app COMPASS-7650 (#5558) --- configs/eslint-config-compass/plugin.js | 1 - package-lock.json | 131 ++-- packages/compass-aggregations/package.json | 7 +- packages/compass-aggregations/src/index.ts | 2 +- packages/compass-app-stores/package.json | 4 +- packages/compass-app-stores/src/plugin.tsx | 6 +- .../src/stores/instance-store.ts | 2 +- packages/compass-collection/package.json | 6 +- packages/compass-collection/src/index.ts | 8 +- .../src/modules/collection-tab.ts | 2 +- .../src/stores/collection-tab.ts | 2 +- .../src/components/connections.spec.tsx | 599 ++++++++++-------- .../src/components/connections.tsx | 22 +- .../src/connections-manager.spec.ts | 502 +++++++++++++++ .../src/connections-manager.ts | 277 ++++++++ packages/compass-connections/src/provider.ts | 61 ++ .../src/stores/connections-store.spec.ts | 95 +-- .../src/stores/connections-store.ts | 236 ++++--- packages/compass-crud/package.json | 7 +- packages/compass-crud/src/index.ts | 2 +- packages/compass-explain-plan/package.json | 6 +- packages/compass-explain-plan/src/index.ts | 6 +- .../compass-explain-plan/src/stores/index.ts | 2 +- .../compass-export-to-language/package.json | 6 +- .../compass-export-to-language/src/index.ts | 6 +- .../src/stores/index.ts | 2 +- packages/compass-home/src/components/home.tsx | 132 ++-- .../compass-home/src/modules/telemetry.ts | 10 +- packages/compass-import-export/package.json | 7 +- packages/compass-import-export/src/index.ts | 2 +- packages/compass-indexes/package.json | 7 +- packages/compass-indexes/src/index.ts | 6 +- .../compass-indexes/src/stores/drop-index.tsx | 2 +- packages/compass-query-bar/package.json | 4 +- packages/compass-query-bar/src/index.tsx | 6 +- .../src/stores/query-bar-store.ts | 2 +- .../package.json | 6 +- .../src/index.ts | 4 +- .../src/stores/index.ts | 2 +- .../compass-schema-validation/package.json | 6 +- .../compass-schema-validation/src/index.ts | 6 +- .../src/modules/index.ts | 2 +- .../src/modules/sample-documents.ts | 2 +- .../src/stores/store.ts | 2 +- packages/compass-schema/package.json | 4 +- packages/compass-schema/src/index.ts | 6 +- packages/compass-schema/src/stores/store.ts | 2 +- packages/compass-serverstats/package.json | 6 +- packages/compass-serverstats/src/index.ts | 4 +- packages/compass-shell/package.json | 7 +- packages/compass-shell/src/index.ts | 6 +- packages/compass-shell/src/modules/runtime.ts | 2 +- packages/compass-shell/src/plugin.spec.tsx | 39 +- packages/compass-shell/src/plugin.tsx | 2 +- packages/compass-shell/src/stores/store.ts | 2 +- packages/compass-sidebar/package.json | 5 +- .../multiple-connections/sidebar.tsx | 2 - packages/compass-sidebar/src/index.ts | 6 +- .../src/modules/data-service.ts | 2 +- packages/compass-sidebar/src/stores/store.ts | 2 +- packages/compass-web/package.json | 1 + packages/compass-web/src/index.spec.tsx | 1 + packages/compass-web/src/index.tsx | 43 +- packages/compass-workspaces/package.json | 6 +- packages/compass-workspaces/src/index.ts | 8 +- packages/data-service/package.json | 11 +- packages/data-service/provider.d.ts | 1 - packages/data-service/provider.js | 1 - .../data-service/src/connection-attempt.ts | 2 +- packages/data-service/src/provider.ts | 33 - packages/databases-collections/package.json | 7 +- .../src/collections-plugin.tsx | 8 +- .../src/databases-plugin.tsx | 8 +- packages/databases-collections/src/index.ts | 2 +- .../src/modules/create-namespace.ts | 2 +- .../src/stores/collections-store.ts | 2 +- .../src/stores/create-namespace.ts | 2 +- .../src/stores/databases-store.ts | 2 +- .../src/stores/drop-namespace.tsx | 2 +- .../src/stores/rename-collection.ts | 2 +- 80 files changed, 1677 insertions(+), 772 deletions(-) create mode 100644 packages/compass-connections/src/connections-manager.spec.ts create mode 100644 packages/compass-connections/src/connections-manager.ts delete mode 100644 packages/data-service/provider.d.ts delete mode 100644 packages/data-service/provider.js delete mode 100644 packages/data-service/src/provider.ts diff --git a/configs/eslint-config-compass/plugin.js b/configs/eslint-config-compass/plugin.js index a1d3a37a9e1..070032b8c82 100644 --- a/configs/eslint-config-compass/plugin.js +++ b/configs/eslint-config-compass/plugin.js @@ -17,7 +17,6 @@ module.exports = { 'no-restricted-imports': 'off', '@typescript-eslint/no-restricted-imports': [ 'error', - restrictedProviderImport('mongodb-data-service'), restrictedProviderImport('@mongodb-js/compass-logging'), restrictedProviderImport('@mongodb-js/compass-app-stores'), restrictedProviderImport('@mongodb-js/my-queries-storage'), diff --git a/package-lock.json b/package-lock.json index 756acb3ee69..e7643b90f3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45688,6 +45688,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -45702,8 +45703,7 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1" + "hadron-type-checker": "^7.1.2" }, "devDependencies": { "@babel/generator": "^7.19.5", @@ -45732,6 +45732,7 @@ "mocha": "^10.2.0", "mongodb": "^6.5.0", "mongodb-collection-model": "^5.18.1", + "mongodb-data-service": "^22.18.1", "mongodb-database-model": "^2.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", @@ -45754,6 +45755,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -45769,7 +45771,6 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -45827,9 +45828,9 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1" }, "devDependencies": { @@ -45854,9 +45855,9 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "react": "^17.0.2" } @@ -45895,11 +45896,11 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -45938,11 +45939,11 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -46292,6 +46293,7 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -46303,8 +46305,7 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1" + "hadron-type-checker": "^7.1.2" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", @@ -46331,6 +46332,7 @@ "jsondiffpatch": "^0.5.0", "lodash": "^4.17.21", "mocha": "^10.2.0", + "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", @@ -46346,6 +46348,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -46358,7 +46361,6 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -46818,12 +46820,12 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/explain-plan-helper": "^1.1.10", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", @@ -46858,12 +46860,12 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/explain-plan-helper": "^1.1.10", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -46906,13 +46908,13 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", "bson-transpilers": "^3.0.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", @@ -46937,13 +46939,13 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", "bson-transpilers": "^3.0.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -47358,6 +47360,7 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-utils": "^0.6.1", @@ -47367,8 +47370,7 @@ "electron": "^28.2.5", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-ipc": "^3.2.12", - "mongodb-data-service": "^22.18.1" + "hadron-ipc": "^3.2.12" }, "devDependencies": { "@electron/remote": "^2.1.2", @@ -47399,6 +47401,7 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb": "^6.5.0", + "mongodb-data-service": "^22.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", "mongodb-schema": "^12.1.0", @@ -47419,6 +47422,7 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-utils": "^0.6.1", @@ -47429,7 +47433,6 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -47538,6 +47541,7 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -47546,8 +47550,7 @@ "@mongodb-js/mongodb-constants": "^0.9.0", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", @@ -47567,6 +47570,7 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb": "^6.5.0", + "mongodb-data-service": "^22.18.1", "mongodb-query-parser": "^4.1.0", "numeral": "^2.0.6", "nyc": "^15.1.0", @@ -47582,6 +47586,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -47591,7 +47596,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -48022,6 +48026,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-generative-ai": "^0.8.1", @@ -48031,7 +48036,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9" }, "devDependencies": { @@ -48068,6 +48072,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-generative-ai": "^0.8.1", @@ -48077,7 +48082,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9", "react": "^17.0.2" } @@ -48116,12 +48120,12 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/my-queries-storage": "^0.5.1", "bson": "^6.5.0", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -48157,12 +48161,12 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/my-queries-storage": "^0.5.1", "bson": "^6.5.0", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -48199,6 +48203,7 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-query-bar": "^8.25.1", "@mongodb-js/connection-storage": "^0.8.1", @@ -48206,7 +48211,6 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9" }, "devDependencies": { @@ -48252,6 +48256,7 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-query-bar": "^8.25.1", "@mongodb-js/connection-storage": "^0.8.1", @@ -48259,7 +48264,6 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9", "react": "^17.0.2" } @@ -48271,14 +48275,14 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", @@ -48312,6 +48316,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -48319,7 +48324,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -48366,9 +48370,9 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-workspaces": "^0.5.1", @@ -48398,9 +48402,9 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -48489,15 +48493,16 @@ "license": "SSPL", "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-user-data": "^0.1.17", "@mongodb-js/compass-utils": "^0.6.1", "@mongosh/node-runtime-worker-thread": "^2.2.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { + "@mongodb-js/connection-storage": "^0.8.1", "@mongodb-js/eslint-config-compass": "^1.0.17", "@mongodb-js/mocha-config-compass": "^1.3.7", "@mongodb-js/prettier-config-compass": "^1.0.1", @@ -48521,13 +48526,13 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-user-data": "^0.1.17", "@mongodb-js/compass-utils": "^0.6.1", "@mongosh/node-runtime-worker-thread": "^2.2.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -48575,7 +48580,6 @@ "@mongodb-js/connection-storage": "^0.8.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1" }, "devDependencies": { @@ -48600,6 +48604,7 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb": "^6.5.0", + "mongodb-data-service": "^22.18.1", "mongodb-ns": "^2.4.0", "nyc": "^15.1.0", "prettier": "^2.7.1", @@ -48624,7 +48629,6 @@ "@mongodb-js/connection-storage": "^0.8.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "react": "^17.0.2" } @@ -48858,6 +48862,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-databases-collections": "^1.23.1", "@mongodb-js/compass-explain-plan": "^6.24.1", @@ -49208,10 +49213,10 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -49249,10 +49254,10 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -49699,7 +49704,6 @@ "@mongodb-js/devtools-connect": "^2.6.0", "@mongodb-js/oidc-plugin": "^0.4.0", "@mongodb-js/ssh-tunnel": "^2.1.13", - "hadron-app-registry": "^9.1.8", "lodash": "^4.17.21", "mongodb-build-info": "^1.7.0", "mongodb-connection-string-url": "^2.6.0", @@ -49848,14 +49852,14 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/databases-collections-list": "^1.23.1", "@mongodb-js/my-queries-storage": "^0.5.1", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -49873,6 +49877,7 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb-collection-model": "^5.18.1", + "mongodb-data-service": "^22.18.1", "mongodb-database-model": "^2.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", @@ -49889,6 +49894,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", @@ -49896,7 +49902,6 @@ "@mongodb-js/my-queries-storage": "^0.5.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" } }, @@ -58193,6 +58198,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -58285,6 +58291,7 @@ "version": "file:packages/compass-app-stores", "requires": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/eslint-config-compass": "^1.0.17", "@mongodb-js/mocha-config-compass": "^1.3.7", @@ -58300,7 +58307,6 @@ "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "nyc": "^15.1.0", @@ -58336,6 +58342,7 @@ "requires": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -58360,7 +58367,6 @@ "hadron-app-registry": "^9.1.8", "mocha": "^10.2.0", "mongodb-collection-model": "^5.18.1", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "numeral": "^2.0.6", @@ -58668,6 +58674,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -58722,6 +58729,7 @@ "requires": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", @@ -58906,6 +58914,7 @@ "requires": { "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -58931,7 +58940,6 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb": "^6.5.0", - "mongodb-data-service": "^22.18.1", "nyc": "^15.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -58975,6 +58983,7 @@ "requires": { "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", @@ -58993,7 +59002,6 @@ "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "mongodb-ns": "^2.4.0", "nyc": "^15.1.0", "react-dom": "^17.0.2", @@ -59305,6 +59313,7 @@ "requires": { "@electron/remote": "^2.1.2", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-test-server": "^0.1.13", @@ -59445,6 +59454,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -59742,6 +59752,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-generative-ai": "^0.8.1", @@ -59766,7 +59777,6 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb": "^6.5.0", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", @@ -59809,6 +59819,7 @@ "requires": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -59834,7 +59845,6 @@ "fuse.js": "^6.5.3", "hadron-app-registry": "^9.1.8", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "mongodb-ns": "^2.4.0", "nyc": "^15.1.0", "prettier": "^2.7.1", @@ -59875,6 +59885,7 @@ "requires": { "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-query-bar": "^8.25.1", "@mongodb-js/connection-storage": "^0.8.1", @@ -59908,7 +59919,6 @@ "mocha": "^10.2.0", "moment": "^2.29.4", "mongodb": "^6.5.0", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9", "mongodb-schema": "^12.1.0", "numeral": "^1.5.6", @@ -59952,6 +59962,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -59974,7 +59985,6 @@ "javascript-stringify": "^2.0.1", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", @@ -60213,6 +60223,7 @@ "requires": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/eslint-config-compass": "^1.0.17", @@ -60233,7 +60244,6 @@ "hadron-app-registry": "^9.1.8", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "mongodb-ns": "^2.4.0", "prop-types": "^15.7.2", "react-dom": "^17.0.2", @@ -60316,9 +60326,11 @@ "version": "file:packages/compass-shell", "requires": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-user-data": "^0.1.17", "@mongodb-js/compass-utils": "^0.6.1", + "@mongodb-js/connection-storage": "^0.8.1", "@mongodb-js/eslint-config-compass": "^1.0.17", "@mongodb-js/mocha-config-compass": "^1.3.7", "@mongodb-js/prettier-config-compass": "^1.0.1", @@ -60336,7 +60348,6 @@ "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", "mocha": "^10.2.0", - "mongodb-data-service": "^22.18.1", "nyc": "^15.1.0", "prop-types": "^15.7.2", "react-dom": "^17.0.2", @@ -60602,6 +60613,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-databases-collections": "^1.23.1", "@mongodb-js/compass-explain-plan": "^6.24.1", @@ -60903,6 +60915,7 @@ "requires": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/eslint-config-compass": "^1.0.17", "@mongodb-js/mocha-config-compass": "^1.3.7", @@ -60927,7 +60940,6 @@ "lodash": "^4.17.21", "mocha": "^10.2.0", "mongodb-collection-model": "^5.18.1", - "mongodb-data-service": "^22.18.1", "mongodb-database-model": "^2.18.1", "mongodb-ns": "^2.4.0", "nyc": "^15.1.0", @@ -84059,7 +84071,6 @@ "chai-as-promised": "^7.1.1", "depcheck": "^1.4.1", "eslint": "^7.25.0", - "hadron-app-registry": "^9.1.8", "kerberos": "^2.1.0", "lodash": "^4.17.21", "mocha": "^10.2.0", diff --git a/packages/compass-aggregations/package.json b/packages/compass-aggregations/package.json index b4e810f5765..1c027ac6536 100644 --- a/packages/compass-aggregations/package.json +++ b/packages/compass-aggregations/package.json @@ -41,6 +41,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -56,7 +57,6 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -86,6 +86,7 @@ "mocha": "^10.2.0", "mongodb": "^6.5.0", "mongodb-collection-model": "^5.18.1", + "mongodb-data-service": "^22.18.1", "mongodb-database-model": "^2.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", @@ -108,6 +109,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -122,8 +124,7 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1" + "hadron-type-checker": "^7.1.2" }, "homepage": "https://github.com/mongodb-js/compass", "bugs": { diff --git a/packages/compass-aggregations/src/index.ts b/packages/compass-aggregations/src/index.ts index aa79d76b88d..c8cf5ebdf77 100644 --- a/packages/compass-aggregations/src/index.ts +++ b/packages/compass-aggregations/src/index.ts @@ -8,7 +8,7 @@ import CreateViewModal from './components/create-view-modal'; import { dataServiceLocator, type DataServiceLocator, -} from 'mongodb-data-service/provider'; +} from '@mongodb-js/compass-connections/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; import type { OptionalDataServiceProps, diff --git a/packages/compass-app-stores/package.json b/packages/compass-app-stores/package.json index 87a81c6abe6..91e4c9d1c8e 100644 --- a/packages/compass-app-stores/package.json +++ b/packages/compass-app-stores/package.json @@ -78,16 +78,16 @@ }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1" }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "react": "^17.0.2" }, diff --git a/packages/compass-app-stores/src/plugin.tsx b/packages/compass-app-stores/src/plugin.tsx index 323aec4870b..30e3ed54b38 100644 --- a/packages/compass-app-stores/src/plugin.tsx +++ b/packages/compass-app-stores/src/plugin.tsx @@ -6,8 +6,10 @@ import type { ActivateHelpers } from 'hadron-app-registry'; import { registerHadronPlugin } from 'hadron-app-registry'; import type { MongoDBInstance } from 'mongodb-instance-model'; import { InstanceContext } from './provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; -import type { DataService } from 'mongodb-data-service'; +import { + dataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; import { createInstanceStore } from './stores'; interface InstanceStoreProviderProps { diff --git a/packages/compass-app-stores/src/stores/instance-store.ts b/packages/compass-app-stores/src/stores/instance-store.ts index 6fb6e55daf7..c3172cc9e5d 100644 --- a/packages/compass-app-stores/src/stores/instance-store.ts +++ b/packages/compass-app-stores/src/stores/instance-store.ts @@ -1,7 +1,7 @@ import type { MongoDBInstanceProps } from 'mongodb-instance-model'; import { MongoDBInstance } from 'mongodb-instance-model'; import toNS from 'mongodb-ns'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { ActivateHelpers, AppRegistry } from 'hadron-app-registry'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import { openToast } from '@mongodb-js/compass-components'; diff --git a/packages/compass-collection/package.json b/packages/compass-collection/package.json index 795f1eba687..f266f6c6ab1 100644 --- a/packages/compass-collection/package.json +++ b/packages/compass-collection/package.json @@ -58,21 +58,21 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", diff --git a/packages/compass-collection/src/index.ts b/packages/compass-collection/src/index.ts index 51da3b9c1f0..3ef1780e0ec 100644 --- a/packages/compass-collection/src/index.ts +++ b/packages/compass-collection/src/index.ts @@ -1,10 +1,12 @@ import CollectionTab from './components/collection-tab'; import { activatePlugin as activateCollectionTabPlugin } from './stores/collection-tab'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; -import type { DataService } from 'mongodb-data-service'; import type { WorkspaceComponent } from '@mongodb-js/compass-workspaces'; export const CollectionTabPlugin = registerHadronPlugin( diff --git a/packages/compass-collection/src/modules/collection-tab.ts b/packages/compass-collection/src/modules/collection-tab.ts index 7cef0d0a417..3551c4b119b 100644 --- a/packages/compass-collection/src/modules/collection-tab.ts +++ b/packages/compass-collection/src/modules/collection-tab.ts @@ -3,7 +3,7 @@ import type { CollectionMetadata } from 'mongodb-collection-model'; import type Collection from 'mongodb-collection-model'; import type { ThunkAction } from 'redux-thunk'; import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; type CollectionThunkAction< ReturnType, diff --git a/packages/compass-collection/src/stores/collection-tab.ts b/packages/compass-collection/src/stores/collection-tab.ts index 9cf4064ce95..96d12f712c7 100644 --- a/packages/compass-collection/src/stores/collection-tab.ts +++ b/packages/compass-collection/src/stores/collection-tab.ts @@ -1,5 +1,5 @@ import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import { createStore, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import reducer, { diff --git a/packages/compass-connections/src/components/connections.spec.tsx b/packages/compass-connections/src/components/connections.spec.tsx index f9a3cdbd5db..ff93d498eea 100644 --- a/packages/compass-connections/src/components/connections.spec.tsx +++ b/packages/compass-connections/src/components/connections.spec.tsx @@ -8,7 +8,7 @@ import { within, } from '@testing-library/react'; import { expect } from 'chai'; -import type { ConnectionOptions } from 'mongodb-data-service'; +import type { ConnectionOptions, connect } from 'mongodb-data-service'; import type { ConnectionInfo, ConnectionStorage, @@ -26,6 +26,17 @@ import { ConnectionRepositoryContext, ConnectionStorageContext, } from '@mongodb-js/connection-storage/provider'; +import { ConnectionsManager, ConnectionsManagerProvider } from '../provider'; +import type { DataService } from 'mongodb-data-service'; +import { createNoopLoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; + +function getConnectionsManager(mockTestConnectFn?: typeof connect) { + const { log } = createNoopLoggerAndTelemetry(); + return new ConnectionsManager({ + logger: log.unbound, + __TEST_CONNECT_FN: mockTestConnectFn, + }); +} function getMockConnectionStorage(mockConnections: ConnectionInfo[]) { return { @@ -40,7 +51,7 @@ function getMockConnectionStorage(mockConnections: ConnectionInfo[]) { importConnections: () => Promise.resolve([]), exportConnections: () => Promise.resolve('{}'), deserializeConnections: () => Promise.resolve([]), - } as unknown as ConnectionStorage; + } as unknown as typeof ConnectionStorage; } async function loadSavedConnectionAndConnect(connectionInfo: ConnectionInfo) { @@ -85,23 +96,24 @@ describe('Connections Component', function () { cleanup(); }); - describe('when rendered', function () { + context('when rendered', function () { let loadConnectionsSpy: sinon.SinonSpy; beforeEach(function () { const mockStorage = getMockConnectionStorage([]); loadConnectionsSpy = sinon.spy(mockStorage, 'loadAll'); const connectionRepository = new ConnectionRepository(mockStorage); - render( - + + + @@ -150,18 +162,15 @@ describe('Connections Component', function () { }); }); - describe('when rendered with saved connections in storage', function () { - let mockConnectFn: sinon.SinonSpy; - let mockStorage: ConnectionStorage; + context('when rendered with saved connections in storage', function () { + let connectSpyFn: sinon.SinonSpy; + let mockStorage: typeof ConnectionStorage; let savedConnectionId: string; let savedConnectionWithAppNameId: string; let saveConnectionSpy: sinon.SinonSpy; let connections: ConnectionInfo[]; beforeEach(async function () { - mockConnectFn = sinon.fake.resolves({ - mockDataService: 'yes', - }); savedConnectionId = uuid(); savedConnectionWithAppNameId = uuid(); saveConnectionSpy = sinon.spy(); @@ -186,19 +195,28 @@ describe('Connections Component', function () { sinon.replace(mockStorage, 'save', saveConnectionSpy); const connectionRepository = new ConnectionRepository(mockStorage); + const connectionsManager = getConnectionsManager(() => { + return Promise.resolve({ + mockDataService: 'yes', + addReauthenticationHandler() {}, + } as unknown as DataService); + }); + connectSpyFn = sinon.spy(connectionsManager, 'connect'); + render( - - - + + + + + @@ -222,280 +240,296 @@ describe('Connections Component', function () { expect(screen.getByText('localhost:27018')).to.be.visible; }); - describe('when a saved connection is clicked on and connected to', function () { - const _Date = globalThis.Date; - beforeEach(async function () { - globalThis.Date = class { - constructor() { - return new _Date(0); - } - static now() { - return 0; - } - } as DateConstructor; - await loadSavedConnectionAndConnect( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connections.find(({ id }) => id === savedConnectionId)! - ); - }); + context( + 'when a saved connection is clicked on and connected to', + function () { + const _Date = globalThis.Date; + beforeEach(async function () { + globalThis.Date = class { + constructor() { + return new _Date(0); + } + static now() { + return 0; + } + } as DateConstructor; + await loadSavedConnectionAndConnect( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + connections.find(({ id }) => id === savedConnectionId)! + ); + }); - afterEach(function () { - globalThis.Date = _Date; - }); + afterEach(function () { + globalThis.Date = _Date; + }); - it('should call the connect function with the connection options to connect', function () { - expect(mockConnectFn.callCount).to.equal(1); - expect(mockConnectFn.firstCall.args[0].connectionOptions).to.deep.equal( - { + it('should call the connect function on ConnectionsManager with the connection options to connect', function () { + expect(connectSpyFn.callCount).to.equal(1); + expect( + connectSpyFn.firstCall.args[0].connectionOptions + ).to.deep.equal({ connectionString: 'mongodb://localhost:27018/?readPreference=primary&ssl=false&appName=Test+App+Name', oidc: {}, - } - ); - }); - - it('should call to save the connection with the connection config', function () { - expect(saveConnectionSpy.callCount).to.equal(1); - expect(saveConnectionSpy.firstCall.args[0].connectionInfo.id).to.equal( - savedConnectionId - ); - expect( - saveConnectionSpy.firstCall.args[0].connectionInfo.connectionOptions - ).to.deep.equal({ - connectionString: - 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + }); }); - }); - it('should call to save the connection with a new lastUsed time', function () { - expect(saveConnectionSpy.callCount).to.equal(1); - expect( - saveConnectionSpy.firstCall.args[0].connectionInfo.lastUsed.getTime() - ).to.equal(0); - }); + it('should call to save the connection with the connection config', function () { + expect(saveConnectionSpy.callCount).to.equal(1); + expect( + saveConnectionSpy.firstCall.args[0].connectionInfo.id + ).to.equal(savedConnectionId); + expect( + saveConnectionSpy.firstCall.args[0].connectionInfo.connectionOptions + ).to.deep.equal({ + connectionString: + 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + }); + }); - it('should emit the connection configuration used to connect', function () { - expect(onConnectedSpy.firstCall.args[0].id).to.equal(savedConnectionId); - expect( - onConnectedSpy.firstCall.args[0].connectionOptions - ).to.deep.equal({ - connectionString: - 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + it('should call to save the connection with a new lastUsed time', function () { + expect(saveConnectionSpy.callCount).to.equal(1); + expect( + saveConnectionSpy.firstCall.args[0].connectionInfo.lastUsed.getTime() + ).to.equal(0); }); - }); - it('should emit the data service', function () { - expect(onConnectedSpy.firstCall.args[1].mockDataService).to.equal( - 'yes' - ); - }); - }); + it('should emit the connection configuration used to connect', function () { + expect(onConnectedSpy.firstCall.args[0].id).to.equal( + savedConnectionId + ); + expect( + onConnectedSpy.firstCall.args[0].connectionOptions + ).to.deep.equal({ + connectionString: + 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + }); + }); + } + ); - describe('when a saved connection with appName is clicked on and connected to', function () { - beforeEach(async function () { - await loadSavedConnectionAndConnect( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connections.find(({ id }) => id === savedConnectionWithAppNameId)! - ); - }); + context( + 'when a saved connection with appName is clicked on and connected to', + function () { + beforeEach(async function () { + await loadSavedConnectionAndConnect( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + connections.find(({ id }) => id === savedConnectionWithAppNameId)! + ); + }); - it('should call the connect function without replacing appName', function () { - expect(mockConnectFn.callCount).to.equal(1); - expect(mockConnectFn.firstCall.args[0].connectionOptions).to.deep.equal( - { + it('should call the connect function without replacing appName', function () { + expect(connectSpyFn.callCount).to.equal(1); + expect( + connectSpyFn.firstCall.args[0].connectionOptions + ).to.deep.equal({ connectionString: 'mongodb://localhost:27019/?appName=Some+App+Name', oidc: {}, - } - ); - }); - }); + }); + }); + } + ); }); - describe('connecting to a connection that is not succeeding', function () { - let mockConnectFn: sinon.SinonSpy; - let saveConnectionSpy: sinon.SinonSpy; - let savedConnectableId: string; - let savedUnconnectableId: string; - let connections: ConnectionInfo[]; + context( + 'when connecting to a connection that is not succeeding', + function () { + let mockConnectFn: sinon.SinonSpy; + let saveConnectionSpy: sinon.SinonSpy; + let savedConnectableId: string; + let savedUnconnectableId: string; + let connections: ConnectionInfo[]; + let connectSpyFn: sinon.SinonSpy; - beforeEach(async function () { - saveConnectionSpy = sinon.spy(); - savedConnectableId = uuid(); - savedUnconnectableId = uuid(); - - mockConnectFn = sinon.fake( - async ({ - connectionOptions, - }: { - connectionOptions: ConnectionOptions; - }) => { - if ( - connectionOptions.connectionString === - 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000&appName=Test+App+Name' - ) { - return new Promise((resolve) => { - // On first call we want this attempt to be cancelled before - // this promise resolves. - setTimeout(resolve, 20); + beforeEach(async function () { + saveConnectionSpy = sinon.spy(); + savedConnectableId = uuid(); + savedUnconnectableId = uuid(); + + mockConnectFn = sinon.fake( + async ({ + connectionOptions, + }: { + connectionOptions: ConnectionOptions; + }) => { + if ( + connectionOptions.connectionString === + 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000&appName=Test+App+Name' + ) { + return new Promise((resolve) => { + // On first call we want this attempt to be cancelled before + // this promise resolves. + setTimeout(() => { + resolve({ + mockDataService: 'yes', + addReauthenticationHandler() {}, + }); + }, 500); + }); + } + return Promise.resolve({ + mockDataService: 'yes', + addReauthenticationHandler() {}, }); } - return Promise.resolve({ - mockDataService: 'yes', - }); - } - ); + ); - connections = [ - { - id: savedConnectableId, - connectionOptions: { - connectionString: - 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + const connectionsManager = getConnectionsManager(mockConnectFn); + connectSpyFn = sinon.spy(connectionsManager, 'connect'); + connections = [ + { + id: savedConnectableId, + connectionOptions: { + connectionString: + 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + }, }, - }, - { - id: savedUnconnectableId, - connectionOptions: { - connectionString: - 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000', + { + id: savedUnconnectableId, + connectionOptions: { + connectionString: + 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000', + }, }, - }, - ]; - const mockStorage = getMockConnectionStorage(connections); - sinon.replace(mockStorage, 'save', saveConnectionSpy); - const connectionRepository = new ConnectionRepository(mockStorage); - - render( - - - - - - - - - - ); - - await waitFor( - () => - expect( - screen.queryByTestId( - `saved-connection-button-${savedUnconnectableId}` - ) - ).to.exist - ); - - const savedConnectionButton = screen.getByTestId( - `saved-connection-button-${savedUnconnectableId}` - ); - fireEvent.click(savedConnectionButton); - - // Wait for the connection to load in the form. - await waitFor(() => - expect(screen.queryByRole('textbox')?.textContent).to.equal( - 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000' - ) - ); - - const connectButton = screen.getByText('Connect'); - fireEvent.click(connectButton); + ]; + const mockStorage = getMockConnectionStorage(connections); + sinon.replace(mockStorage, 'save', saveConnectionSpy); + const connectionRepository = new ConnectionRepository(mockStorage); + + render( + + + + + + + + + + + + ); - // Wait for the connecting... modal to be shown. - await waitFor(() => expect(screen.queryByText('Cancel')).to.be.visible); - }); + await waitFor( + () => + expect( + screen.queryByTestId( + `saved-connection-button-${savedUnconnectableId}` + ) + ).to.exist + ); - describe('when the connection attempt is cancelled', function () { - beforeEach(async function () { - const cancelButton = screen.getByText('Cancel'); - fireEvent.click(cancelButton); + const savedConnectionButton = screen.getByTestId( + `saved-connection-button-${savedUnconnectableId}` + ); + fireEvent.click(savedConnectionButton); - // Wait for the connecting... modal to hide. - await waitFor(() => expect(screen.queryByText('Cancel')).to.not.exist); - }); + // Wait for the connection to load in the form. + await waitFor(() => + expect(screen.queryByRole('textbox')?.textContent).to.equal( + 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000' + ) + ); - it('should enable the connect button', function () { const connectButton = screen.getByText('Connect'); - expect(connectButton).to.not.match('disabled'); - }); - - it('should not call to save the connection', function () { - expect(saveConnectionSpy.callCount).to.equal(0); - }); - - it('should not emit connected', function () { - expect(onConnectedSpy.called).to.equal(false); - }); - - it('should have the connections-wrapper test id', function () { - expect(screen.getByTestId('connections-wrapper')).to.be.visible; - }); + fireEvent.click(connectButton); - it('should call the connect function with the connection options to connect', function () { - expect(mockConnectFn.callCount).to.equal(1); - expect(mockConnectFn.firstCall.args[0].connectionOptions).to.deep.equal( - { - connectionString: - 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000&appName=Test+App+Name', - oidc: {}, - } - ); + // Wait for the connecting... modal to be shown. + await waitFor(() => expect(screen.queryByText('Cancel')).to.be.visible); }); - describe('connecting to a successful connection after cancelling a connect', function () { + context('when the connection attempt is cancelled', function () { beforeEach(async function () { - await loadSavedConnectionAndConnect( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - connections.find(({ id }) => id === savedConnectableId)! + const cancelButton = screen.getByText('Cancel'); + fireEvent.click(cancelButton); + + // Wait for the connecting... modal to hide. + await waitFor( + () => expect(screen.queryByText('Cancel')).to.not.exist ); }); - it('should call onConnected once', function () { - expect(onConnectedSpy.callCount).to.equal(1); + it('should enable the connect button', function () { + const connectButton = screen.getByText('Connect'); + expect(connectButton).to.not.match('disabled'); }); - it('should call to save the connection once', function () { - expect(saveConnectionSpy.callCount).to.equal(1); + it('should not call to save the connection', function () { + expect(saveConnectionSpy.callCount).to.equal(0); }); - it('should emit the connection configuration used to connect', function () { - expect(onConnectedSpy.firstCall.args[0].id).to.equal( - savedConnectableId - ); - expect( - onConnectedSpy.firstCall.args[0].connectionOptions - ).to.deep.equal({ - connectionString: - 'mongodb://localhost:27018/?readPreference=primary&ssl=false', - }); + it('should not emit connected', function () { + expect(onConnectedSpy.called).to.equal(false); + }); + + it('should have the connections-wrapper test id', function () { + expect(screen.getByTestId('connections-wrapper')).to.be.visible; }); it('should call the connect function with the connection options to connect', function () { - expect(mockConnectFn.callCount).to.equal(2); + expect(connectSpyFn.callCount).to.equal(1); expect( - mockConnectFn.secondCall.args[0].connectionOptions + connectSpyFn.firstCall.args[0].connectionOptions ).to.deep.equal({ connectionString: - 'mongodb://localhost:27018/?readPreference=primary&ssl=false&appName=Test+App+Name', + 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000&appName=Test+App+Name', oidc: {}, }); }); - it('should emit the data service', function () { - expect(onConnectedSpy.firstCall.args[1].mockDataService).to.equal( - 'yes' - ); - }); + context( + 'connecting to a successful connection after cancelling a connect', + function () { + beforeEach(async function () { + await loadSavedConnectionAndConnect( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + connections.find(({ id }) => id === savedConnectableId)! + ); + }); + + it('should call onConnected once', function () { + expect(onConnectedSpy.callCount).to.equal(1); + }); + + it('should call to save the connection once', function () { + expect(saveConnectionSpy.callCount).to.equal(1); + }); + + it('should emit the connection configuration used to connect', function () { + expect(onConnectedSpy.firstCall.args[0].id).to.equal( + savedConnectableId + ); + expect( + onConnectedSpy.firstCall.args[0].connectionOptions + ).to.deep.equal({ + connectionString: + 'mongodb://localhost:27018/?readPreference=primary&ssl=false', + }); + }); + + it('should call the connect function with the connection options to connect', function () { + expect(connectSpyFn.callCount).to.equal(2); + expect( + connectSpyFn.secondCall.args[0].connectionOptions + ).to.deep.equal({ + connectionString: + 'mongodb://localhost:27018/?readPreference=primary&ssl=false&appName=Test+App+Name', + oidc: {}, + }); + }); + } + ); }); - }); - }); + } + ); context('when user has any legacy connection', function () { it('shows modal', async function () { @@ -510,14 +544,16 @@ describe('Connections Component', function () { - - - + + + + + @@ -543,14 +579,16 @@ describe('Connections Component', function () { - - - + + + + + @@ -570,15 +608,16 @@ describe('Connections Component', function () { - - - + + + + + @@ -608,10 +647,14 @@ describe('Connections Component', function () { - + + + diff --git a/packages/compass-connections/src/components/connections.tsx b/packages/compass-connections/src/components/connections.tsx index db0c6225ff6..6f8d9b236d6 100644 --- a/packages/compass-connections/src/components/connections.tsx +++ b/packages/compass-connections/src/components/connections.tsx @@ -17,8 +17,7 @@ import ConnectionForm from '@mongodb-js/connection-form'; import { type ConnectionInfo } from '@mongodb-js/connection-storage/renderer'; import { useConnectionStorageContext } from '@mongodb-js/connection-storage/provider'; import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; -import { connect } from 'mongodb-data-service'; +import type { connect, DataService } from 'mongodb-data-service'; import React, { useCallback, useMemo, useState } from 'react'; import { usePreference } from 'compass-preferences-model/provider'; import { cloneDeep } from 'lodash'; @@ -88,22 +87,21 @@ function Connections({ onConnected, onConnectionFailed, onConnectionAttemptStarted, - isConnected, appName, getAutoConnectInfo, - connectFn = connect, }: { appRegistry: AppRegistry; onConnected: ( connectionInfo: ConnectionInfo, dataService: DataService ) => void; - onConnectionFailed: (connectionInfo: ConnectionInfo, error: Error) => void; + onConnectionFailed: ( + connectionInfo: ConnectionInfo | null, + error: Error + ) => void; onConnectionAttemptStarted: (connectionInfo: ConnectionInfo) => void; - isConnected: boolean; appName: string; getAutoConnectInfo?: () => Promise; - connectFn?: ConnectFn; }): React.ReactElement { const { log, mongoLogId } = useLoggerAndTelemetry('COMPASS-CONNECTIONS'); // TODO(COMPASS-7397): services should not be used directly in render method, @@ -128,15 +126,13 @@ function Connections({ onConnected, onConnectionFailed, onConnectionAttemptStarted, - isConnected, - connectFn, appName, getAutoConnectInfo, }); const { + connectingConnectionId, activeConnectionId, activeConnectionInfo, - connectionAttempt, connectionErrorMessage, connectingStatusText, oidcDeviceAuthVerificationUrl, @@ -258,12 +254,14 @@ function Connections({ - {!!connectionAttempt && !connectionAttempt.isClosed() && ( + {connectingConnectionId && ( + void cancelConnectionAttempt(connectingConnectionId) + } /> )} { + resolveCanceledPromise = resolve; + }); + + const connectionsManager = getConnectionsManager(mockTestConnectFn); + + const originalConnectFn: typeof connectionsManager.connect = + connectionsManager.connect.bind(connectionsManager); + let failures = 0; + sinon.stub(connectionsManager, 'connect').callsFake((info) => { + return originalConnectFn(info).finally(() => { + if (++failures === connectionsToBeConnected.length) { + resolveCanceledPromise(); + } + }); + }); + + return { + canceledPromise, + connectionsManager, + }; +} + +describe('ConnectionsManager', function () { + const connectedDataService1 = { + id: 1, + disconnect() {}, + addReauthenticationHandler() {}, + } as unknown as DataService; + const connectedConnectionInfo1 = { + id: '1', + connectionOptions: { + connectionString: 'mongodb://localhost:27017', + }, + }; + + const connectedDataService2 = { + id: 2, + disconnect() {}, + addReauthenticationHandler() {}, + } as unknown as DataService; + const connectedConnectionInfo2 = { + id: '2', + connectionOptions: { + connectionString: 'mongodb://localhost:27018', + }, + }; + let connectionsManager: ConnectionsManager; + let mockConnectFn: typeof connect; + + beforeEach(function () { + mockConnectFn = sinon.stub().callsFake(({ connectionOptions }) => { + if ( + connectionOptions.connectionString === + connectedConnectionInfo1.connectionOptions.connectionString + ) { + return Promise.resolve(connectedDataService1); + } else { + return Promise.resolve(connectedDataService2); + } + }); + connectionsManager = getConnectionsManager(mockConnectFn); + }); + + context( + 'when connecting to multiple connections simultaneously', + function () { + beforeEach(function () { + const originalMockFn = mockConnectFn; + mockConnectFn = async (connectionInfo) => { + await new Promise((resolve) => setTimeout(resolve, 50)); + return await originalMockFn(connectionInfo); + }; + connectionsManager = getConnectionsManager(mockConnectFn); + }); + + it('should emit connection-attempt-started event', async function () { + const onConnectionStarted = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptStarted, + onConnectionStarted + ); + + await Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + + expect(onConnectionStarted).to.be.calledTwice; + expect(onConnectionStarted.getCall(0).args).to.deep.equal([ + connectedConnectionInfo1.id, + ]); + expect(onConnectionStarted.getCall(1).args).to.deep.equal([ + connectedConnectionInfo2.id, + ]); + }); + + it('#statusOf should return connecting', function () { + void Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + expect( + connectionsManager.statusOf(connectedConnectionInfo1.id) + ).to.equal(ConnectionStatus.Connecting); + expect( + connectionsManager.statusOf(connectedConnectionInfo2.id) + ).to.equal(ConnectionStatus.Connecting); + }); + + it('#getDataServiceForConnection should not return anything for connecting connection', function () { + void Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo1.id + ) + ).to.be.undefined; + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo2.id + ) + ).to.be.undefined; + }); + + context('when all connection attempts are cancelled', function () { + let canceledPromise; + beforeEach(function () { + const connectionsToBeConnected = [ + connectedConnectionInfo1, + connectedConnectionInfo2, + ]; + const { + canceledPromise: setupCanceledPromise, + connectionsManager: setupConnectionsManager, + } = canceledPromiseSetup(connectionsToBeConnected, mockConnectFn); + canceledPromise = setupCanceledPromise; + connectionsManager = setupConnectionsManager; + }); + + it('should emit connection-attempt-cancelled for all attempted connections', async function () { + const onConnectionAttemptCancelled = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptCancelled, + onConnectionAttemptCancelled + ); + void Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]).catch(() => { + // noop + }); + connectionsManager.cancelAllConnectionAttempts(); + await canceledPromise; + expect(onConnectionAttemptCancelled).to.be.calledTwice; + expect(onConnectionAttemptCancelled.getCall(0).args).to.deep.equal([ + connectedConnectionInfo1.id, + ]); + expect(onConnectionAttemptCancelled.getCall(1).args).to.deep.equal([ + connectedConnectionInfo2.id, + ]); + }); + + it('#statusOf should return disconnected', async function () { + void Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]).catch(() => { + // noop + }); + connectionsManager.cancelAllConnectionAttempts(); + await canceledPromise; + expect( + connectionsManager.statusOf(connectedConnectionInfo1.id) + ).to.equal(ConnectionStatus.Disconnected); + expect( + connectionsManager.statusOf(connectedConnectionInfo2.id) + ).to.equal(ConnectionStatus.Disconnected); + }); + + it('#getDataServiceForConnection should not return anything for canceled connections', async function () { + void Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]).catch(() => { + // noop + }); + connectionsManager.cancelAllConnectionAttempts(); + await canceledPromise; + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo1.id + ) + ).to.be.undefined; + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo2.id + ) + ).to.be.undefined; + }); + }); + } + ); + + context('when a connection attempt is cancelled', function () { + let canceledPromise; + beforeEach(function () { + const connectionsToBeConnected = [connectedConnectionInfo1]; + const { + canceledPromise: setupCanceledPromise, + connectionsManager: setupConnectionsManager, + } = canceledPromiseSetup(connectionsToBeConnected, mockConnectFn); + canceledPromise = setupCanceledPromise; + connectionsManager = setupConnectionsManager; + }); + it('should emit connection attempt cancelled event', async function () { + const onConnectionCancelled = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptCancelled, + onConnectionCancelled + ); + + void connectionsManager.connect(connectedConnectionInfo1).catch(() => { + // + }); + void connectionsManager.closeConnection(connectedConnectionInfo1.id); + await canceledPromise; + expect(onConnectionCancelled).to.be.calledWithExactly( + connectedConnectionInfo1.id + ); + }); + + it('#statusOf should return ConnectionStatus.Disconnected', async function () { + void connectionsManager.connect(connectedConnectionInfo1).catch(() => { + // + }); + void connectionsManager.closeConnection(connectedConnectionInfo1.id); + await canceledPromise; + expect(connectionsManager.statusOf(connectedConnectionInfo1.id)).to.equal( + ConnectionStatus.Disconnected + ); + }); + + it('#getDataServiceForConnection should not return anything for cancelled connection attempt', async function () { + void connectionsManager.connect(connectedConnectionInfo1).catch(() => { + // + }); + void connectionsManager.closeConnection(connectedConnectionInfo1.id); + await canceledPromise; + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo1.id + ) + ).to.be.undefined; + }); + + context( + 'when attempting to connect to a cancelled connection', + function () { + let canceledPromise; + beforeEach(function () { + const connectionsToBeConnected = [connectedConnectionInfo1]; + const { + canceledPromise: setupCanceledPromise, + connectionsManager: setupConnectionsManager, + } = canceledPromiseSetup(connectionsToBeConnected, () => + Promise.resolve(connectedDataService1) + ); + canceledPromise = setupCanceledPromise; + connectionsManager = setupConnectionsManager; + }); + + it('should be able to connect', async function () { + const onConnectionCancelled = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptCancelled, + onConnectionCancelled + ); + + void connectionsManager + .connect(connectedConnectionInfo1) + .catch(() => { + // + }); + await connectionsManager.closeConnection(connectedConnectionInfo1.id); + await canceledPromise; + expect(onConnectionCancelled).to.be.calledWithExactly( + connectedConnectionInfo1.id + ); + expect( + connectionsManager.statusOf(connectedConnectionInfo1.id) + ).to.equal(ConnectionStatus.Disconnected); + + await connectionsManager.connect(connectedConnectionInfo1); + expect( + connectionsManager.statusOf(connectedConnectionInfo1.id) + ).to.equal(ConnectionStatus.Connected); + }); + } + ); + }); + + context( + 'when connected successfully to multiple connections simultaneously', + function () { + it('should emit connection successful event for each connected connection', async function () { + const onSuccessfulConnections = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptSuccessful, + onSuccessfulConnections + ); + + await Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + expect(onSuccessfulConnections).to.be.calledTwice; + expect(onSuccessfulConnections.getCall(0).args).to.deep.equal([ + connectedConnectionInfo1.id, + connectedDataService1, + ]); + expect(onSuccessfulConnections.getCall(1).args).to.deep.equal([ + connectedConnectionInfo2.id, + connectedDataService2, + ]); + }); + + it('#statusOf should return ConnectionStatus.Connected', async function () { + await Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + expect( + connectionsManager.statusOf(connectedConnectionInfo1.id) + ).to.equal(ConnectionStatus.Connected); + expect( + connectionsManager.statusOf(connectedConnectionInfo2.id) + ).to.equal(ConnectionStatus.Connected); + }); + + it('#getDataServiceForConnection should be able to return connected dataService', async function () { + await Promise.all([ + connectionsManager.connect(connectedConnectionInfo1), + connectionsManager.connect(connectedConnectionInfo2), + ]); + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo1.id + ) + ).to.deep.equal(connectedDataService1); + expect( + connectionsManager.getDataServiceForConnection( + connectedConnectionInfo2.id + ) + ).to.deep.equal(connectedDataService2); + }); + + it('should return the connected DataService for an already connected connection', async function () { + await connectionsManager.connect(connectedConnectionInfo1); + await connectionsManager.connect(connectedConnectionInfo1); + expect(mockConnectFn).to.be.calledOnce; + }); + } + ); + + context('when a connection fails to connect', function () { + const failedConnectionInfo = { + id: '3', + connectionOptions: { + connectionString: 'mongodb://localhost:2', + }, + }; + const error = new Error('Connection rejected'); + beforeEach(function () { + mockConnectFn = () => Promise.reject(error); + connectionsManager = getConnectionsManager(mockConnectFn); + }); + + it('should emit connection failed event for the failed connection', async function () { + const onConnectionFailed = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionAttemptFailed, + onConnectionFailed + ); + + try { + await connectionsManager.connect(failedConnectionInfo); + } catch (error) { + expect(error.message).to.equal('Connection rejected'); + expect(onConnectionFailed).to.be.calledWithExactly( + failedConnectionInfo.id, + error + ); + } + }); + + it('#statusOf should return ConnectionStatus.Failed', async function () { + try { + await connectionsManager.connect(failedConnectionInfo); + } catch (error) { + // nothing + } + expect(connectionsManager.statusOf(failedConnectionInfo.id)).to.equal( + ConnectionStatus.Failed + ); + }); + + it('#getDataServiceForConnection should not return anything for failed connection', async function () { + try { + await connectionsManager.connect(failedConnectionInfo); + } catch (error) { + // nothing + } + expect( + connectionsManager.getDataServiceForConnection(failedConnectionInfo.id) + ).to.be.undefined; + }); + }); + + context('when an active connection is disconnected', function () { + const activeConnectionInfo = { + id: '4', + connectionOptions: { + connectionString: 'mongodb://localhost:27019', + }, + }; + const activeDataService = { + id: '4', + disconnect() {}, + addReauthenticationHandler() {}, + } as unknown as DataService; + beforeEach(function () { + mockConnectFn = () => Promise.resolve(activeDataService); + connectionsManager = getConnectionsManager(mockConnectFn); + }); + + it('should emit connection disconnected event', async function () { + const onConnectionDisconnected = sinon.stub(); + connectionsManager.on( + ConnectionsManagerEvents.ConnectionDisconnected, + onConnectionDisconnected + ); + + await connectionsManager.connect(activeConnectionInfo); + expect(connectionsManager.statusOf(activeConnectionInfo.id)).to.equal( + ConnectionStatus.Connected + ); + + await connectionsManager.closeConnection(activeConnectionInfo.id); + expect(onConnectionDisconnected).to.be.calledWithExactly( + activeConnectionInfo.id + ); + }); + + it('#statusOf should return ConnectionStatus.Disconnected', async function () { + await connectionsManager.connect(activeConnectionInfo); + expect(connectionsManager.statusOf(activeConnectionInfo.id)).to.equal( + ConnectionStatus.Connected + ); + + await connectionsManager.closeConnection(activeConnectionInfo.id); + expect(connectionsManager.statusOf(activeConnectionInfo.id)).to.equal( + ConnectionStatus.Disconnected + ); + }); + + it('#getDataServiceForConnection should not return anything for disconnected connection', async function () { + await connectionsManager.connect(activeConnectionInfo); + await connectionsManager.closeConnection(activeConnectionInfo.id); + expect( + connectionsManager.getDataServiceForConnection(activeConnectionInfo.id) + ).to.be.undefined; + }); + }); +}); diff --git a/packages/compass-connections/src/connections-manager.ts b/packages/compass-connections/src/connections-manager.ts new file mode 100644 index 00000000000..da73c87ff63 --- /dev/null +++ b/packages/compass-connections/src/connections-manager.ts @@ -0,0 +1,277 @@ +import { EventEmitter } from 'events'; +import { createConnectionAttempt } from 'mongodb-data-service'; + +import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging'; +import type { ConnectionInfo } from '@mongodb-js/connection-info'; +import type { + ConnectionAttempt, + DataService, + ReauthenticationHandler, + connect, +} from 'mongodb-data-service'; +import { mongoLogId } from '@mongodb-js/compass-logging/provider'; + +type ConnectFn = typeof connect; +type ConnectionInfoId = ConnectionInfo['id']; + +export enum ConnectionsManagerEvents { + ConnectionAttemptStarted = 'connection-attempt-started', + ConnectionAttemptCancelled = 'connection-attempt-cancelled', + ConnectionAttemptSuccessful = 'connection-attempt-successful', + ConnectionAttemptFailed = 'connection-attempt-failed', + ConnectionDisconnected = 'connection-disconnected', +} + +export type ConnectionManagerEventListeners = { + [ConnectionsManagerEvents.ConnectionAttemptStarted]: ( + connectionInfoId: ConnectionInfoId + ) => void; + [ConnectionsManagerEvents.ConnectionAttemptCancelled]: ( + connectionInfoId: ConnectionInfoId + ) => void; + [ConnectionsManagerEvents.ConnectionAttemptSuccessful]: ( + connectionInfoId: ConnectionInfoId, + dataService: DataService + ) => void; + [ConnectionsManagerEvents.ConnectionAttemptFailed]: ( + connectionInfoId: ConnectionInfoId, + error: any + ) => void; + [ConnectionsManagerEvents.ConnectionDisconnected]: ( + connectionInfoId: ConnectionInfoId + ) => void; +}; + +export enum ConnectionStatus { + Disconnected = 'disconnected', + Connecting = 'connecting', + Connected = 'connected', + Failed = 'failed', +} + +type ConnectionStatusTransitions = { + [event in ConnectionsManagerEvents]?: { + [status in ConnectionStatus]?: ConnectionStatus; + }; +}; + +const connectionStatusTransitions: ConnectionStatusTransitions = { + [ConnectionsManagerEvents.ConnectionAttemptStarted]: { + [ConnectionStatus.Disconnected]: ConnectionStatus.Connecting, + [ConnectionStatus.Failed]: ConnectionStatus.Connecting, + }, + [ConnectionsManagerEvents.ConnectionAttemptCancelled]: { + [ConnectionStatus.Connecting]: ConnectionStatus.Disconnected, + }, + [ConnectionsManagerEvents.ConnectionAttemptFailed]: { + [ConnectionStatus.Connecting]: ConnectionStatus.Failed, + }, + [ConnectionsManagerEvents.ConnectionAttemptSuccessful]: { + [ConnectionStatus.Connecting]: ConnectionStatus.Connected, + }, + [ConnectionsManagerEvents.ConnectionDisconnected]: { + [ConnectionStatus.Connected]: ConnectionStatus.Disconnected, + }, +}; + +export const CONNECTION_CANCELED_ERR = 'Connection attempt was canceled'; + +export class ConnectionsManager extends EventEmitter { + private readonly logger: LoggerAndTelemetry['log']['unbound']; + private readonly reAuthenticationHandler?: ReauthenticationHandler; + private readonly __TEST_CONNECT_FN?: ConnectFn; + private connectionAttempts = new Map(); + private connectionStatuses = new Map(); + private dataServices = new Map(); + + constructor({ + logger, + reAuthenticationHandler, + __TEST_CONNECT_FN, + }: { + logger: LoggerAndTelemetry['log']['unbound']; + reAuthenticationHandler?: ReauthenticationHandler; + __TEST_CONNECT_FN?: ConnectFn; + }) { + super(); + this.logger = logger; + this.reAuthenticationHandler = reAuthenticationHandler; + this.__TEST_CONNECT_FN = __TEST_CONNECT_FN; + } + + getDataServiceForConnection( + connectionInfoId: ConnectionInfoId + ): DataService | undefined { + return this.dataServices.get(connectionInfoId); + } + + statusOf(connectionInfoId: ConnectionInfoId): ConnectionStatus { + return ( + this.connectionStatuses.get(connectionInfoId) ?? + ConnectionStatus.Disconnected + ); + } + + cancelAllConnectionAttempts(): void { + for (const connectionInfoId of this.connectionAttempts.keys()) { + this.cancelConnectionAttempt(connectionInfoId); + } + } + + /** + * @param connectionInfo The adjusted ConnectionInfo object that already has + * parameters such as appName. + */ + async connect(connectionInfo: ConnectionInfo): Promise { + try { + const existingDataService = this.getDataServiceForConnection( + connectionInfo.id + ); + if ( + existingDataService && + this.statusOf(connectionInfo.id) === ConnectionStatus.Connected + ) { + return existingDataService; + } + + this.updateAndNotifyConnectionStatus( + connectionInfo.id, + ConnectionsManagerEvents.ConnectionAttemptStarted, + [connectionInfo.id] + ); + const connectionAttempt = createConnectionAttempt({ + logger: this.logger, + connectFn: this.__TEST_CONNECT_FN, + }); + this.connectionAttempts.set(connectionInfo.id, connectionAttempt); + + const dataService = await connectionAttempt.connect( + connectionInfo.connectionOptions + ); + + if (!dataService || connectionAttempt.isClosed()) { + throw new Error(CONNECTION_CANCELED_ERR); + } + + if (this.reAuthenticationHandler) { + dataService.addReauthenticationHandler(this.reAuthenticationHandler); + } + + this.connectionAttempts.delete(connectionInfo.id); + this.dataServices.set(connectionInfo.id, dataService); + this.updateAndNotifyConnectionStatus( + connectionInfo.id, + ConnectionsManagerEvents.ConnectionAttemptSuccessful, + [connectionInfo.id, dataService] + ); + return dataService; + } catch (error) { + if ((error as Error).message === CONNECTION_CANCELED_ERR) { + this.updateAndNotifyConnectionStatus( + connectionInfo.id, + ConnectionsManagerEvents.ConnectionAttemptCancelled, + [connectionInfo.id] + ); + } else { + this.updateAndNotifyConnectionStatus( + connectionInfo.id, + ConnectionsManagerEvents.ConnectionAttemptFailed, + [connectionInfo.id, error] + ); + } + throw error; + } + } + + async closeConnection(connectionInfoId: ConnectionInfoId): Promise { + const currentStatus = this.statusOf(connectionInfoId); + if (currentStatus === ConnectionStatus.Connecting) { + this.cancelConnectionAttempt(connectionInfoId); + } else if (currentStatus === ConnectionStatus.Connected) { + const dataService = this.dataServices.get(connectionInfoId); + if (dataService) { + await dataService.disconnect(); + this.dataServices.delete(connectionInfoId); + } else { + this.logger.warn( + 'ConnectionsManager', + mongoLogId(1_001_000_305), + 'closeConnection', + `Started closing connection but found no DataService to disconnect` + ); + } + this.updateAndNotifyConnectionStatus( + connectionInfoId, + ConnectionsManagerEvents.ConnectionDisconnected, + [connectionInfoId] + ); + } else { + this.logger.warn( + 'ConnectionsManager', + mongoLogId(1_001_000_304), + 'closeConnection', + `Attempting to close a connection that is neither being connected to, nor connected but the status is ${currentStatus}` + ); + } + } + + on( + eventName: T, + listener: ConnectionManagerEventListeners[T] + ): this { + return super.on(eventName, listener); + } + + off( + eventName: T, + listener: ConnectionManagerEventListeners[T] + ): this { + return super.off(eventName, listener); + } + + once( + eventName: T, + listener: ConnectionManagerEventListeners[T] + ): this { + return super.once(eventName, listener); + } + + removeListener( + eventName: T, + listener: ConnectionManagerEventListeners[T] + ): this { + return super.removeListener(eventName, listener); + } + + emit( + eventName: T, + ...args: Parameters + ): boolean { + return super.emit(eventName, ...args); + } + + private cancelConnectionAttempt(connectionInfoId: ConnectionInfoId): void { + const connectionAttempt = this.connectionAttempts.get(connectionInfoId); + if (connectionAttempt) { + connectionAttempt.cancelConnectionAttempt(); + this.connectionAttempts.delete(connectionInfoId); + } + } + + private updateAndNotifyConnectionStatus( + connectionInfoId: ConnectionInfoId, + connectionEvent: T, + connectionEventParams: Parameters + ) { + const currentStatus = this.statusOf(connectionInfoId); + const nextStatus = + connectionStatusTransitions[connectionEvent]?.[currentStatus]; + if (nextStatus === undefined) { + throw new Error( + `Unexpected state for ConnectionInfoId ${connectionInfoId}. Encountered ${connectionEvent} with currentStatus=${currentStatus}` + ); + } + this.connectionStatuses.set(connectionInfoId, nextStatus); + this.emit(connectionEvent, ...connectionEventParams); + } +} diff --git a/packages/compass-connections/src/provider.ts b/packages/compass-connections/src/provider.ts index 61f1351dd57..747f650d2da 100644 --- a/packages/compass-connections/src/provider.ts +++ b/packages/compass-connections/src/provider.ts @@ -1 +1,62 @@ +import { createContext, useContext } from 'react'; +import { createServiceLocator } from 'hadron-app-registry'; +import { useConnectionInfo } from '@mongodb-js/connection-storage/provider'; + +import type { DataService } from 'mongodb-data-service'; +import type { ConnectionsManager } from './connections-manager'; + +export type { DataService }; +export * from './connections-manager'; export { useConnections } from './stores/connections-store'; + +const ConnectionsManagerContext = createContext( + null +); +export const ConnectionsManagerProvider = ConnectionsManagerContext.Provider; + +export const useConnectionsManagerContext = (): ConnectionsManager => { + const connectionsManager = useContext(ConnectionsManagerContext); + if (!connectionsManager) { + throw new Error( + 'ConnectionsManager not available in context. Did you forget to setup ConnectionsManagerProvider' + ); + } + return connectionsManager; +}; + +export const connectionsManagerLocator = createServiceLocator( + useConnectionsManagerContext, + 'connectionsManagerLocator' +); + +export type DataServiceLocator< + K extends keyof DataService = keyof DataService, + L extends keyof DataService = K +> = () => Pick & Partial>; + +/** + * DataService locator method. Generic type can be used to limit the required / + * available methods on the injected service (only on compilation time, doesn't + * have the effect otherwise) + */ +export const dataServiceLocator = createServiceLocator( + function dataServiceLocator< + K extends keyof DataService = keyof DataService, + L extends keyof DataService = K + >(): Pick & Partial> { + const connectionInfo = useConnectionInfo(); + if (!connectionInfo) { + throw new Error( + 'ConnectionInfo for an active connection not available in context. Did you forget to setup ConnectionInfoProvider' + ); + } + const connectionsManager = useConnectionsManagerContext(); + const ds = connectionsManager.getDataServiceForConnection( + connectionInfo.id + ); + if (!ds) { + throw new Error('DataService is not available for the active connection'); + } + return ds; + } +); diff --git a/packages/compass-connections/src/stores/connections-store.spec.ts b/packages/compass-connections/src/stores/connections-store.spec.ts index 89a72abde26..741755daefb 100644 --- a/packages/compass-connections/src/stores/connections-store.spec.ts +++ b/packages/compass-connections/src/stores/connections-store.spec.ts @@ -15,11 +15,22 @@ import { } from '@mongodb-js/connection-storage/main'; import { ConnectionRepositoryContext } from '@mongodb-js/connection-storage/provider'; +import { ConnectionsManager, ConnectionsManagerProvider } from '../provider'; +import type { DataService, connect } from 'mongodb-data-service'; +import { createNoopLoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; const noop = (): any => { /* no-op */ }; +function getConnectionsManager(mockTestConnectFn?: typeof connect) { + const { log } = createNoopLoggerAndTelemetry(); + return new ConnectionsManager({ + logger: log.unbound, + __TEST_CONNECT_FN: mockTestConnectFn, + }); +} + const mockConnections: ConnectionInfo[] = [ { id: 'turtle', @@ -45,7 +56,8 @@ const mockConnections: ConnectionInfo[] = [ describe('use-connections hook', function () { let connectionRepository: ConnectionRepository; - let mockConnectionStorage: ConnectionStorage; + let connectionsManager: ConnectionsManager; + let mockConnectionStorage: typeof ConnectionStorage; let loadAllSpy: sinon.SinonSpy; let saveSpy: sinon.SinonSpy; let deleteSpy: sinon.SinonSpy; @@ -61,7 +73,12 @@ describe('use-connections hook', function () { children: [ createElement(ConnectionRepositoryContext.Provider, { value: connectionRepository, - children, + children: [ + createElement(ConnectionsManagerProvider, { + value: connectionsManager, + children, + }), + ], }), ], }); @@ -84,10 +101,43 @@ describe('use-connections hook', function () { }; connectionRepository = new ConnectionRepository(mockConnectionStorage); + connectionsManager = getConnectionsManager(() => + Promise.resolve({ + mockDataService: 'yes', + addReauthenticationHandler() {}, + } as unknown as DataService) + ); }); afterEach(cleanup); + describe('#onMount', function () { + const getAutoConnectInfo = () => + Promise.resolve({ + id: 'new', + connectionOptions: { + connectionString: 'mongodb://new-recent', + }, + }); + it('allows connecting to a dynamically provided connection info object', async function () { + const onConnected = sinon.spy(); + renderHookWithContext(() => + useConnections({ + onConnected, + onConnectionFailed: noop, + onConnectionAttemptStarted: noop, + appName: 'Test App Name', + getAutoConnectInfo, + }) + ); + + await waitFor(() => { + expect(onConnected).to.have.been.called; + }); + expect(saveSpy).to.not.have.been.called; + }); + }); + describe('#loadConnections', function () { it('loads the connections from the connection storage', async function () { const loadAllSpyWithData = sinon.fake.resolves(mockConnections); @@ -98,7 +148,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -137,7 +186,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -210,7 +258,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -253,8 +300,6 @@ describe('use-connections hook', function () { onConnected, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectionRepository, - connectFn: () => Promise.resolve({} as any), appName: 'Test App Name', }) ); @@ -271,34 +316,6 @@ describe('use-connections hook', function () { }); expect(saveSpy).to.have.been.calledOnce; }); - - it('allows connecting to a dynamically provided connection info object', async function () { - const onConnected = sinon.spy(); - const { result } = renderHookWithContext(() => - useConnections({ - onConnected, - onConnectionFailed: noop, - onConnectionAttemptStarted: noop, - connectionRepository, - connectFn: () => Promise.resolve({} as any), - appName: 'Test App Name', - }) - ); - - await result.current.connect(() => - Promise.resolve({ - id: 'new', - connectionOptions: { - connectionString: 'mongodb://new-recent', - }, - }) - ); - - await waitFor(() => { - expect(onConnected).to.have.been.called; - }); - expect(saveSpy).to.not.have.been.called; - }); }); describe('#saveConnection', function () { @@ -313,7 +330,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -374,7 +390,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -406,7 +421,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -446,7 +460,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -534,7 +547,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -560,7 +572,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -594,7 +605,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); @@ -650,7 +660,6 @@ describe('use-connections hook', function () { onConnected: noop, onConnectionFailed: noop, onConnectionAttemptStarted: noop, - connectFn: noop, appName: 'Test App Name', }) ); diff --git a/packages/compass-connections/src/stores/connections-store.ts b/packages/compass-connections/src/stores/connections-store.ts index 29d6a69c4d3..643db6f2c74 100644 --- a/packages/compass-connections/src/stores/connections-store.ts +++ b/packages/compass-connections/src/stores/connections-store.ts @@ -1,11 +1,9 @@ -import { - type Dispatch, - useCallback, - useEffect, - useReducer, - useRef, -} from 'react'; +import { type Dispatch, useCallback, useEffect, useReducer } from 'react'; import type { DataService, connect } from 'mongodb-data-service'; +import { + useConnectionsManagerContext, + CONNECTION_CANCELED_ERR, +} from '../provider'; import { getConnectionTitle } from '@mongodb-js/connection-info'; import { type ConnectionInfo, @@ -15,8 +13,7 @@ import { import { useConnectionRepositoryContext } from '@mongodb-js/connection-storage/provider'; import { cloneDeep, merge } from 'lodash'; import { v4 as uuidv4 } from 'uuid'; -import type { ConnectionAttempt } from 'mongodb-data-service'; -import { createConnectionAttempt } from 'mongodb-data-service'; + import ConnectionString from 'mongodb-connection-string-url'; import { adjustConnectionOptionsBeforeConnect } from '@mongodb-js/connection-form'; import { useEffectOnChange, useToast } from '@mongodb-js/compass-components'; @@ -63,8 +60,8 @@ type State = { favoriteConnections: ConnectionInfo[]; recentConnections: ConnectionInfo[]; activeConnectionInfo: ConnectionInfo; + connectingConnectionId: string | null; connectingStatusText: string; - connectionAttempt: ConnectionAttempt | null; connectionErrorMessage: string | null; oidcDeviceAuthVerificationUrl: string | null; oidcDeviceAuthUserCode: string | null; @@ -82,7 +79,7 @@ export function defaultConnectionsState(): State { recentConnections: [], activeConnectionInfo: createNewConnectionInfo(), connectingStatusText: '', - connectionAttempt: null, + connectingConnectionId: null, connectionErrorMessage: null, oidcDeviceAuthVerificationUrl: null, oidcDeviceAuthUserCode: null, @@ -93,8 +90,8 @@ export function defaultConnectionsState(): State { type Action = | { type: 'attempt-connect'; - connectionAttempt: ConnectionAttempt; connectingStatusText: string; + connectingConnectionId: string; } | { type: 'oidc-attempt-connect-notify-device-auth'; @@ -135,7 +132,7 @@ export function connectionsReducer(state: State, action: Action): State { case 'attempt-connect': return { ...state, - connectionAttempt: action.connectionAttempt, + connectingConnectionId: action.connectingConnectionId, connectingStatusText: action.connectingStatusText, connectionErrorMessage: null, oidcDeviceAuthVerificationUrl: null, @@ -144,19 +141,19 @@ export function connectionsReducer(state: State, action: Action): State { case 'cancel-connection-attempt': return { ...state, - connectionAttempt: null, + connectingConnectionId: null, connectionErrorMessage: null, }; case 'connection-attempt-succeeded': return { ...state, - connectionAttempt: null, + connectingConnectionId: null, connectionErrorMessage: null, }; case 'connection-attempt-errored': return { ...state, - connectionAttempt: null, + connectingConnectionId: null, connectionErrorMessage: action.connectionErrorMessage, }; case 'oidc-attempt-connect-notify-device-auth': @@ -252,34 +249,31 @@ export function useConnections({ onConnected, onConnectionFailed, onConnectionAttemptStarted, - isConnected, appName, getAutoConnectInfo, - connectFn, }: { onConnected: ( connectionInfo: ConnectionInfo, dataService: DataService ) => void; - onConnectionFailed: (connectionInfo: ConnectionInfo, error: Error) => void; + onConnectionFailed: ( + connectionInfo: ConnectionInfo | null, + error: Error + ) => void; onConnectionAttemptStarted: (connectionInfo: ConnectionInfo) => void; - isConnected: boolean; getAutoConnectInfo?: () => Promise; - connectFn: ConnectFn; appName: string; }): { state: State; recentConnections: ConnectionInfo[]; favoriteConnections: ConnectionInfo[]; - cancelConnectionAttempt: () => void; - connect: ( - connectionInfo: ConnectionInfo | (() => Promise) - ) => Promise; + cancelConnectionAttempt: (connectionInfoId: string) => Promise; + connect: (connectionInfo: ConnectionInfo) => Promise; createNewConnection: () => void; saveConnection: (connectionInfo: ConnectionInfo) => Promise; setActiveConnectionById: (newConnectionId: string) => void; removeAllRecentsConnections: () => Promise; - duplicateConnection: (connectioInfo: ConnectionInfo) => void; + duplicateConnection: (connectionInfo: ConnectionInfo) => void; removeConnection: (connectionInfo: ConnectionInfo) => void; reloadConnections: () => void; } { @@ -287,6 +281,7 @@ export function useConnections({ // when this code is refactored to use the hadron plugin interface, storage // should be handled through the plugin activation lifecycle const connectionRepository = useConnectionRepositoryContext(); + const connectionsManager = useConnectionsManagerContext(); const { openToast } = useToast('compass-connections'); const persistOIDCTokens = usePreference('persistOIDCTokens'); @@ -297,13 +292,7 @@ export function useConnections({ connectionsReducer, defaultConnectionsState() ); - const { - activeConnectionId, - connectionAttempt, - recentConnections, - favoriteConnections, - } = state; - const connectingConnectionAttempt = useRef(); + const { activeConnectionId, recentConnections, favoriteConnections } = state; async function saveConnectionInfo( connectionInfo: PartialConnectionInfo @@ -436,25 +425,48 @@ export function useConnections({ useEffect(() => { // Load connections after first render. void loadConnections(dispatch, connectionRepository, { persistOIDCTokens }); + void connectWithAutoConnectInfoIfAvailable(); + async function connectWithAutoConnectInfoIfAvailable() { + let connectionInfo: ConnectionInfo | undefined; + try { + connectionInfo = + typeof getAutoConnectInfo === 'function' + ? await getAutoConnectInfo() + : undefined; + if (connectionInfo) { + log.info( + mongoLogId(1_001_000_160), + 'Connection Store', + 'Performing automatic connection attempt' + ); + dispatch({ + type: 'set-active-connection', + connectionInfo, + }); + void connect(connectionInfo, false); + } + } catch (error) { + onConnectionFailed(connectionInfo ?? null, error as Error); + log.error( + mongoLogId(1_001_000_290), + 'Connection Store', + 'Error performing connection attempt using auto connect info', + { + error: (error as Error).message, + } + ); - if (getAutoConnectInfo) { - log.info( - mongoLogId(1_001_000_160), - 'Connection Store', - 'Performing automatic connection attempt' - ); - void connect(getAutoConnectInfo); + dispatch({ + type: 'connection-attempt-errored', + connectionErrorMessage: (error as Error).message, + }); + } } return () => { // When unmounting, clean up any current connection attempts that have // not resolved. - if ( - connectingConnectionAttempt.current && - !connectingConnectionAttempt.current.isClosed() - ) { - connectingConnectionAttempt.current.cancelConnectionAttempt(); - } + connectionsManager.cancelAllConnectionAttempts(); }; }, [getAutoConnectInfo, persistOIDCTokens]); @@ -466,50 +478,45 @@ export function useConnections({ }, [persistOIDCTokens]); const connect = async ( - getAutoConnectInfo: - | ConnectionInfo - | (() => Promise) + originalConnectionInfo: ConnectionInfo, + shouldSaveConnectionInfo = true ) => { - if (connectionAttempt || isConnected) { - // Ensure we aren't currently connecting. - return; - } - - const newConnectionAttempt = createConnectionAttempt({ - connectFn, - logger: log.unbound, - }); - connectingConnectionAttempt.current = newConnectionAttempt; - - let connectionInfo: ConnectionInfo | undefined = undefined; - let shouldSaveConnectionInfo = false; try { - if (typeof getAutoConnectInfo === 'function') { - connectionInfo = await getAutoConnectInfo(); - if (!connectionInfo) { - connectingConnectionAttempt.current = undefined; - return; - } + const connectionInfo = merge( + cloneDeep(originalConnectionInfo), + state.connectionMergeInfos[originalConnectionInfo.id] ?? {} + ); - dispatch({ - type: 'set-active-connection', - connectionInfo, - }); - } else { - connectionInfo = getAutoConnectInfo; - shouldSaveConnectionInfo = true; - } + const isOIDCConnectionAttempt = isOIDCAuth( + originalConnectionInfo.connectionOptions.connectionString + ); - connectionInfo = merge( + const adjustedConnectionInfoForConnection: ConnectionInfo = merge( cloneDeep(connectionInfo), - state.connectionMergeInfos[connectionInfo.id] ?? {} + { + connectionOptions: adjustConnectionOptionsBeforeConnect({ + connectionOptions: originalConnectionInfo.connectionOptions, + defaultAppName: appName, + preferences: { forceConnectionOptions, browserCommandForOIDCAuth }, + notifyDeviceFlow: !isOIDCConnectionAttempt + ? undefined + : (deviceFlowInformation: { + verificationUrl: string; + userCode: string; + }) => { + dispatch({ + type: 'oidc-attempt-connect-notify-device-auth', + verificationUrl: deviceFlowInformation.verificationUrl, + userCode: deviceFlowInformation.userCode, + }); + }, + }), + } ); - const isOIDCConnectionAttempt = isOIDCAuth( - connectionInfo.connectionOptions.connectionString - ); dispatch({ type: 'attempt-connect', + connectingConnectionId: connectionInfo.id, connectingStatusText: `Connecting to ${getConnectionTitle( connectionInfo )}${ @@ -517,52 +524,19 @@ export function useConnections({ ? '. Go to the browser to complete authentication.' : '' }`, - connectionAttempt: newConnectionAttempt, }); onConnectionAttemptStarted(connectionInfo); debug('connecting with connectionInfo', connectionInfo); - - let notifyDeviceFlow: - | ((deviceFlowInformation: { - verificationUrl: string; - userCode: string; - }) => void) - | undefined; - if (isOIDCConnectionAttempt) { - notifyDeviceFlow = (deviceFlowInformation: { - verificationUrl: string; - userCode: string; - }) => { - dispatch({ - type: 'oidc-attempt-connect-notify-device-auth', - verificationUrl: deviceFlowInformation.verificationUrl, - userCode: deviceFlowInformation.userCode, - }); - }; - } - log.info( mongoLogId(1001000004), 'Connection UI', 'Initiating connection attempt' ); - const newConnectionDataService = await newConnectionAttempt.connect( - adjustConnectionOptionsBeforeConnect({ - connectionOptions: connectionInfo.connectionOptions, - defaultAppName: appName, - notifyDeviceFlow, - preferences: { forceConnectionOptions, browserCommandForOIDCAuth }, - }) + const newConnectionDataService = await connectionsManager.connect( + adjustedConnectionInfoForConnection ); - connectingConnectionAttempt.current = undefined; - - if (!newConnectionDataService || newConnectionAttempt.isClosed()) { - // The connection attempt was cancelled. - return; - } - dispatch({ type: 'connection-attempt-succeeded', }); @@ -578,10 +552,14 @@ export function useConnections({ connectionInfo ); } catch (error) { - connectingConnectionAttempt.current = undefined; - if (connectionInfo) { - onConnectionFailed(connectionInfo, error as Error); + if ((error as Error).message === CONNECTION_CANCELED_ERR) { + dispatch({ + type: 'cancel-connection-attempt', + }); + return; } + + onConnectionFailed(originalConnectionInfo, error as Error); log.error( mongoLogId(1_001_000_161), 'Connection Store', @@ -602,18 +580,24 @@ export function useConnections({ state, recentConnections, favoriteConnections, - cancelConnectionAttempt() { + async cancelConnectionAttempt(connectionInfoId: string) { log.info( mongoLogId(1001000005), 'Connection UI', 'Canceling connection attempt' ); - - connectionAttempt?.cancelConnectionAttempt(); - - dispatch({ - type: 'cancel-connection-attempt', - }); + try { + await connectionsManager.closeConnection(connectionInfoId); + } catch (error) { + log.error( + mongoLogId(1_001_000_303), + 'Connection UI', + 'Canceling connection attempt failed', + { + error: (error as Error).message, + } + ); + } }, connect, createNewConnection() { diff --git a/packages/compass-crud/package.json b/packages/compass-crud/package.json index d5676cdd24e..76d0a9cc157 100644 --- a/packages/compass-crud/package.json +++ b/packages/compass-crud/package.json @@ -58,6 +58,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -70,7 +71,6 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -98,6 +98,7 @@ "jsondiffpatch": "^0.5.0", "lodash": "^4.17.21", "mocha": "^10.2.0", + "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", @@ -113,6 +114,7 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -124,7 +126,6 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-type-checker": "^7.1.2", - "mongodb-data-service": "^22.18.1" + "hadron-type-checker": "^7.1.2" } } diff --git a/packages/compass-crud/src/index.ts b/packages/compass-crud/src/index.ts index 6947538de8a..3c66f82606e 100644 --- a/packages/compass-crud/src/index.ts +++ b/packages/compass-crud/src/index.ts @@ -8,7 +8,7 @@ import { activateDocumentsPlugin } from './stores/crud-store'; import { dataServiceLocator, type DataServiceLocator, -} from 'mongodb-data-service/provider'; +} from '@mongodb-js/compass-connections/provider'; import type { OptionalDataServiceProps, RequiredDataServiceProps, diff --git a/packages/compass-explain-plan/package.json b/packages/compass-explain-plan/package.json index 1e68121aa60..b020a926280 100644 --- a/packages/compass-explain-plan/package.json +++ b/packages/compass-explain-plan/package.json @@ -57,12 +57,12 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/explain-plan-helper": "^1.1.10", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -98,11 +98,11 @@ }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/explain-plan-helper": "^1.1.10", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" } } diff --git a/packages/compass-explain-plan/src/index.ts b/packages/compass-explain-plan/src/index.ts index bb2a3073c0c..8aa11338fe8 100644 --- a/packages/compass-explain-plan/src/index.ts +++ b/packages/compass-explain-plan/src/index.ts @@ -1,8 +1,10 @@ import ExplainPlanModal from './components/explain-plan-modal'; import { activatePlugin } from './stores'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; import { preferencesLocator } from 'compass-preferences-model/provider'; diff --git a/packages/compass-explain-plan/src/stores/index.ts b/packages/compass-explain-plan/src/stores/index.ts index 03386477cc4..d90b5db3b84 100644 --- a/packages/compass-explain-plan/src/stores/index.ts +++ b/packages/compass-explain-plan/src/stores/index.ts @@ -9,7 +9,7 @@ import { import type { AggregateOptions, Document, FindOptions } from 'mongodb'; import type AppRegistry from 'hadron-app-registry'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; -import type { DataService } from 'mongodb-data-service/provider'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import type { PreferencesAccess } from 'compass-preferences-model/provider'; diff --git a/packages/compass-export-to-language/package.json b/packages/compass-export-to-language/package.json index c7da5d5847f..60b612a69c5 100644 --- a/packages/compass-export-to-language/package.json +++ b/packages/compass-export-to-language/package.json @@ -57,24 +57,24 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", "bson-transpilers": "^3.0.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", "bson-transpilers": "^3.0.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-collection": "^4.23.1", diff --git a/packages/compass-export-to-language/src/index.ts b/packages/compass-export-to-language/src/index.ts index 8f01888f8ed..0bdfcf2473f 100644 --- a/packages/compass-export-to-language/src/index.ts +++ b/packages/compass-export-to-language/src/index.ts @@ -1,8 +1,10 @@ import { registerHadronPlugin } from 'hadron-app-registry'; import ExportToLanguageModal from './components/modal'; import { activatePlugin } from './stores'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; const ExportToLanguagePlugin = registerHadronPlugin( { diff --git a/packages/compass-export-to-language/src/stores/index.ts b/packages/compass-export-to-language/src/stores/index.ts index 1f3d6e2a971..4c1d185fb9c 100644 --- a/packages/compass-export-to-language/src/stores/index.ts +++ b/packages/compass-export-to-language/src/stores/index.ts @@ -2,7 +2,7 @@ import { createStore, type Reducer } from 'redux'; import type { QueryExpression, InputExpression } from '../modules/transpiler'; import { isValidExportMode } from '../modules/transpiler'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { ActivateHelpers } from 'hadron-app-registry'; import type AppRegistry from 'hadron-app-registry'; diff --git a/packages/compass-home/src/components/home.tsx b/packages/compass-home/src/components/home.tsx index 28bae777a4c..8323d8dc4e0 100644 --- a/packages/compass-home/src/components/home.tsx +++ b/packages/compass-home/src/components/home.tsx @@ -8,11 +8,11 @@ import { getScrollbarStyles, palette, resetGlobalCSS, - useConfirmationModal, openToast, ButtonVariant, Button, spacing, + showConfirmation, } from '@mongodb-js/compass-components'; import Connections from '@mongodb-js/compass-connections'; import { CompassFindInPagePlugin } from '@mongodb-js/compass-find-in-page'; @@ -26,11 +26,14 @@ import { ConnectionStorage, } from '@mongodb-js/connection-storage/renderer'; import { AppRegistryProvider, useLocalAppRegistry } from 'hadron-app-registry'; +import { + ConnectionsManagerProvider, + ConnectionsManager, +} from '@mongodb-js/compass-connections/provider'; import type { DataService, ReauthenticationHandler, } from 'mongodb-data-service'; -import { DataServiceProvider } from 'mongodb-data-service/provider'; import React, { useCallback, useEffect, @@ -186,17 +189,8 @@ function Home({ __TEST_CONNECTION_STORAGE?: typeof ConnectionStorage; }): React.ReactElement | null { const appRegistry = useLocalAppRegistry(); - const connectedDataService = useRef(); const loggerAndTelemetry = useLoggerAndTelemetry('COMPASS-CONNECT-UI'); - const [ - { connectionInfo, isConnected, hasDisconnectedAtLeastOnce }, - dispatch, - ] = useReducer(reducer, { - ...initialState, - }); - - const { showConfirmation } = useConfirmationModal(); const reauthenticationHandler = useRef(async () => { const confirmed = await showConfirmation({ title: 'Authentication expired', @@ -208,40 +202,50 @@ function Home({ } }); + const connectionsManager = useRef( + new ConnectionsManager({ + logger: loggerAndTelemetry.log.unbound, + reAuthenticationHandler: reauthenticationHandler.current, + __TEST_CONNECT_FN: __TEST_MONGODB_DATA_SERVICE_CONNECT_FN, + }) + ); + + const [ + { connectionInfo, isConnected, hasDisconnectedAtLeastOnce }, + dispatch, + ] = useReducer(reducer, { + ...initialState, + }); + const onConnected = useCallback( (connectionInfo: ConnectionInfo, dataService: DataService) => { trackNewConnectionEvent(connectionInfo, dataService, loggerAndTelemetry); - connectedDataService.current = dataService; - dataService.addReauthenticationHandler(reauthenticationHandler.current); - dispatch({ type: 'connected', connectionInfo: connectionInfo }); }, - [] + [loggerAndTelemetry] ); const onConnectionFailed = useCallback( - (connectionInfo: ConnectionInfo, error: Error) => { + (connectionInfo: ConnectionInfo | null, error: Error) => { trackConnectionFailedEvent(connectionInfo, error, loggerAndTelemetry); }, - [] + [loggerAndTelemetry] ); const onConnectionAttemptStarted = useCallback( (connectionInfo: ConnectionInfo) => { trackConnectionAttemptEvent(connectionInfo, loggerAndTelemetry); }, - [] + [loggerAndTelemetry] ); useEffect(() => { async function handleDisconnectClicked() { - if (!connectedDataService.current) { - // We aren't connected. + if (!connectionInfo) { return; } - await connectedDataService.current.disconnect(); - connectedDataService.current = undefined; + await connectionsManager.current.closeConnection(connectionInfo.id); dispatch({ type: 'disconnected' }); } @@ -255,7 +259,7 @@ function Home({ // Clean up the ipc listener. hadronIpc.ipcRenderer?.removeListener('app:disconnect', onDisconnect); }; - }, [appRegistry]); + }, [appRegistry, appName, connectionInfo]); const onWorkspaceChange = useCallback( (ws: WorkspaceTab | null, collectionInfo) => { @@ -280,7 +284,7 @@ function Home({ [appName, connectionInfo] ); - const onDataSeviceDisconnected = useCallback(() => { + const onDataServiceDisconnected = useCallback(() => { if (!isConnected) { updateTitle(appName); hideCollectionSubMenu(); @@ -288,13 +292,7 @@ function Home({ } }, [appName, isConnected]); - useLayoutEffect(onDataSeviceDisconnected); - - if (isConnected && !connectedDataService.current) { - throw new Error( - 'Application is connected, but DataService is not available' - ); - } + useLayoutEffect(onDataServiceDisconnected); const electronFileInputBackendRef = useRef( remote ? createElectronFileInputBackend(remote) : null @@ -401,13 +399,13 @@ function Home({ > - {isConnected && connectedDataService.current && ( - - - + + + {isConnected && connectionInfo && ( + - - - - )} - {/* TODO(COMPASS-7397): Hide but keep it in scope if - connected so that the connection import/export functionality can still - be used through the application menu */} -
-
- + + )} + + {/* TODO(COMPASS-7397): Hide but keep it in scope if + connected so that the connection import/export functionality can still + be used through the application menu */} +
+
+ +
-
- - - - + + + + + diff --git a/packages/compass-home/src/modules/telemetry.ts b/packages/compass-home/src/modules/telemetry.ts index 7d1e9ef1490..4e52ee5ed47 100644 --- a/packages/compass-home/src/modules/telemetry.ts +++ b/packages/compass-home/src/modules/telemetry.ts @@ -1,7 +1,4 @@ -import { - type DataService, - configuredKMSProviders, -} from 'mongodb-data-service/provider'; +import { type DataService, configuredKMSProviders } from 'mongodb-data-service'; import type { ConnectionInfo } from '@mongodb-js/connection-storage/renderer'; import { type LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import { isLocalhost, isDigitalOcean, isAtlas } from 'mongodb-build-info'; @@ -200,13 +197,14 @@ export function trackNewConnectionEvent( } export function trackConnectionFailedEvent( - connectionInfo: Pick, + connectionInfo: Pick | null, connectionError: Error & Partial>, { track, debug }: LoggerAndTelemetry ): void { try { const callback = async () => { - const connectionData = await getConnectionData(connectionInfo); + const connectionData = + connectionInfo !== null ? await getConnectionData(connectionInfo) : {}; const trackEvent = { ...connectionData, error_code: connectionError.code, diff --git a/packages/compass-import-export/package.json b/packages/compass-import-export/package.json index 41cecafaa7d..5dac212fa6e 100644 --- a/packages/compass-import-export/package.json +++ b/packages/compass-import-export/package.json @@ -57,6 +57,7 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-utils": "^0.6.1", @@ -67,11 +68,11 @@ "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-utils": "^0.6.1", @@ -81,8 +82,7 @@ "electron": "^28.2.5", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "hadron-ipc": "^3.2.12", - "mongodb-data-service": "^22.18.1" + "hadron-ipc": "^3.2.12" }, "devDependencies": { "@electron/remote": "^2.1.2", @@ -116,6 +116,7 @@ "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", "mongodb-schema": "^12.1.0", + "mongodb-data-service": "^22.18.1", "nyc": "^15.1.0", "papaparse": "^5.3.2", "prettier": "^2.7.1", diff --git a/packages/compass-import-export/src/index.ts b/packages/compass-import-export/src/index.ts index 21768a7cc24..9ecfb399487 100644 --- a/packages/compass-import-export/src/index.ts +++ b/packages/compass-import-export/src/index.ts @@ -2,7 +2,7 @@ import { registerHadronPlugin } from 'hadron-app-registry'; import { dataServiceLocator, type DataServiceLocator, -} from 'mongodb-data-service/provider'; +} from '@mongodb-js/compass-connections/provider'; import ImportPluginComponent from './import-plugin'; import { activatePlugin as activateImportPlugin } from './stores/import-store'; import ExportPluginComponent from './export-plugin'; diff --git a/packages/compass-indexes/package.json b/packages/compass-indexes/package.json index 122aae3fae0..9df9a75aa23 100644 --- a/packages/compass-indexes/package.json +++ b/packages/compass-indexes/package.json @@ -58,6 +58,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -67,7 +68,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -89,6 +89,7 @@ "mocha": "^10.2.0", "mongodb": "^6.5.0", "mongodb-query-parser": "^4.1.0", + "mongodb-data-service": "^22.18.1", "numeral": "^2.0.6", "nyc": "^15.1.0", "react": "^17.0.2", @@ -103,6 +104,7 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", @@ -111,7 +113,6 @@ "@mongodb-js/mongodb-constants": "^0.9.0", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" } } diff --git a/packages/compass-indexes/src/index.ts b/packages/compass-indexes/src/index.ts index 6960693eee2..58933fde680 100644 --- a/packages/compass-indexes/src/index.ts +++ b/packages/compass-indexes/src/index.ts @@ -12,8 +12,10 @@ import { type IndexesDataServiceProps, } from './stores/store'; import Indexes from './components/indexes/indexes'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import type { MongoDBInstance } from '@mongodb-js/compass-app-stores/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging'; diff --git a/packages/compass-indexes/src/stores/drop-index.tsx b/packages/compass-indexes/src/stores/drop-index.tsx index 06f7b3e28fa..fd1980880c0 100644 --- a/packages/compass-indexes/src/stores/drop-index.tsx +++ b/packages/compass-indexes/src/stores/drop-index.tsx @@ -7,7 +7,7 @@ import { } from '@mongodb-js/compass-components'; import type { ActivateHelpers, AppRegistry } from 'hadron-app-registry'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; -import type { DataService } from 'mongodb-data-service/provider'; +import type { DataService } from 'mongodb-data-service'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; type DropIndexInitialProps = Pick; diff --git a/packages/compass-query-bar/package.json b/packages/compass-query-bar/package.json index db3808563ca..3fc2ad7fbf0 100644 --- a/packages/compass-query-bar/package.json +++ b/packages/compass-query-bar/package.json @@ -59,6 +59,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-generative-ai": "^0.8.1", @@ -68,7 +69,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9", "react": "^17.0.2" }, @@ -106,6 +106,7 @@ "@mongodb-js/atlas-service": "^0.15.1", "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-generative-ai": "^0.8.1", @@ -115,7 +116,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9" } } diff --git a/packages/compass-query-bar/src/index.tsx b/packages/compass-query-bar/src/index.tsx index 9287f2c62da..ed8c5352a32 100644 --- a/packages/compass-query-bar/src/index.tsx +++ b/packages/compass-query-bar/src/index.tsx @@ -1,8 +1,10 @@ import React from 'react'; import { registerHadronPlugin } from 'hadron-app-registry'; import { activatePlugin } from './stores/query-bar-store'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import { QueryBarComponentProvider, diff --git a/packages/compass-query-bar/src/stores/query-bar-store.ts b/packages/compass-query-bar/src/stores/query-bar-store.ts index 53af955beb5..f322c20a26c 100644 --- a/packages/compass-query-bar/src/stores/query-bar-store.ts +++ b/packages/compass-query-bar/src/stores/query-bar-store.ts @@ -7,7 +7,7 @@ import { import thunk from 'redux-thunk'; import type { AnyAction } from 'redux'; import type { ThunkAction, ThunkDispatch } from 'redux-thunk'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import { DEFAULT_FIELD_VALUES } from '../constants/query-bar-store'; import { mapQueryToFormFields } from '../utils/query'; import { diff --git a/packages/compass-saved-aggregations-queries/package.json b/packages/compass-saved-aggregations-queries/package.json index 8ad4cd26413..6d33eb90b66 100644 --- a/packages/compass-saved-aggregations-queries/package.json +++ b/packages/compass-saved-aggregations-queries/package.json @@ -58,23 +58,23 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/my-queries-storage": "^0.5.1", "bson": "^6.5.0", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/my-queries-storage": "^0.5.1", "bson": "^6.5.0", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", diff --git a/packages/compass-saved-aggregations-queries/src/index.ts b/packages/compass-saved-aggregations-queries/src/index.ts index 0b2f577c05c..3ba896ad856 100644 --- a/packages/compass-saved-aggregations-queries/src/index.ts +++ b/packages/compass-saved-aggregations-queries/src/index.ts @@ -1,11 +1,11 @@ import { registerHadronPlugin } from 'hadron-app-registry'; import { dataServiceLocator, + type DataService, type DataServiceLocator, -} from 'mongodb-data-service/provider'; +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; -import type { DataService } from 'mongodb-data-service'; import { activatePlugin } from './stores'; import AggregationsQueriesList from './components/aggregations-queries-list'; import type { WorkspaceComponent } from '@mongodb-js/compass-workspaces'; diff --git a/packages/compass-saved-aggregations-queries/src/stores/index.ts b/packages/compass-saved-aggregations-queries/src/stores/index.ts index 64aaa5dd4b9..67dcbba3c5f 100644 --- a/packages/compass-saved-aggregations-queries/src/stores/index.ts +++ b/packages/compass-saved-aggregations-queries/src/stores/index.ts @@ -6,7 +6,7 @@ import type { ThunkAction } from 'redux-thunk'; import itemsReducer from './aggregations-queries-items'; import openItemReducer from './open-item'; import editItemReducer from './edit-item'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { MongoDBInstance } from '@mongodb-js/compass-app-stores/provider'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import type { workspacesServiceLocator } from '@mongodb-js/compass-workspaces/provider'; diff --git a/packages/compass-schema-validation/package.json b/packages/compass-schema-validation/package.json index 05e96869168..bc02bc92d0e 100644 --- a/packages/compass-schema-validation/package.json +++ b/packages/compass-schema-validation/package.json @@ -58,6 +58,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", @@ -65,7 +66,6 @@ "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -100,13 +100,13 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-field-store": "^9.0.19", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" } } diff --git a/packages/compass-schema-validation/src/index.ts b/packages/compass-schema-validation/src/index.ts index e313b59bfaa..b543cc40781 100644 --- a/packages/compass-schema-validation/src/index.ts +++ b/packages/compass-schema-validation/src/index.ts @@ -1,8 +1,10 @@ import { onActivated } from './stores'; import CompassSchemaValidation from './components/compass-schema-validation'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import { preferencesLocator } from 'compass-preferences-model/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; diff --git a/packages/compass-schema-validation/src/modules/index.ts b/packages/compass-schema-validation/src/modules/index.ts index 67ec515f8f8..55305fe7a66 100644 --- a/packages/compass-schema-validation/src/modules/index.ts +++ b/packages/compass-schema-validation/src/modules/index.ts @@ -23,7 +23,7 @@ import type { EditModeAction, EditModeState } from './edit-mode'; import editMode, { INITIAL_STATE as EDIT_MODE_STATE } from './edit-mode'; import type { ThunkAction } from 'redux-thunk'; import type { PreferencesAccess } from 'compass-preferences-model'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type AppRegistry from 'hadron-app-registry'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; diff --git a/packages/compass-schema-validation/src/modules/sample-documents.ts b/packages/compass-schema-validation/src/modules/sample-documents.ts index ff6ce409fdc..a27a572d9c2 100644 --- a/packages/compass-schema-validation/src/modules/sample-documents.ts +++ b/packages/compass-schema-validation/src/modules/sample-documents.ts @@ -1,6 +1,6 @@ import type { PreferencesAccess } from 'compass-preferences-model'; import { checkValidator } from './validation'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { RootAction, SchemaValidationThunkAction } from '.'; export const SAMPLE_SIZE = 10000; diff --git a/packages/compass-schema-validation/src/stores/store.ts b/packages/compass-schema-validation/src/stores/store.ts index 5c235029211..fceb43ec486 100644 --- a/packages/compass-schema-validation/src/stores/store.ts +++ b/packages/compass-schema-validation/src/stores/store.ts @@ -8,7 +8,7 @@ import { editModeChanged } from '../modules/edit-mode'; import semver from 'semver'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; import type { ActivateHelpers, AppRegistry } from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { MongoDBInstance } from '@mongodb-js/compass-app-stores/provider'; import type { PreferencesAccess } from 'compass-preferences-model'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; diff --git a/packages/compass-schema/package.json b/packages/compass-schema/package.json index 084f3fb3a54..2b138e2f138 100644 --- a/packages/compass-schema/package.json +++ b/packages/compass-schema/package.json @@ -57,6 +57,7 @@ }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-query-bar": "^8.25.1", "@mongodb-js/connection-storage": "^0.8.1", @@ -64,7 +65,6 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9", "react": "^17.0.2" }, @@ -111,6 +111,7 @@ }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-query-bar": "^8.25.1", "@mongodb-js/connection-storage": "^0.8.1", @@ -118,7 +119,6 @@ "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", - "mongodb-data-service": "^22.18.1", "mongodb-query-util": "^2.1.9" } } diff --git a/packages/compass-schema/src/index.ts b/packages/compass-schema/src/index.ts index e589fe8442f..7204a1d1596 100644 --- a/packages/compass-schema/src/index.ts +++ b/packages/compass-schema/src/index.ts @@ -1,5 +1,7 @@ -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; import CompassSchema from './components/compass-schema'; diff --git a/packages/compass-schema/src/stores/store.ts b/packages/compass-schema/src/stores/store.ts index 049fe2d4ff6..89010885642 100644 --- a/packages/compass-schema/src/stores/store.ts +++ b/packages/compass-schema/src/stores/store.ts @@ -20,7 +20,7 @@ import { import { capMaxTimeMSAtPreferenceLimit } from 'compass-preferences-model/provider'; import { openToast } from '@mongodb-js/compass-components'; import type { CollectionTabPluginMetadata } from '@mongodb-js/compass-collection'; -import type { DataService as OriginalDataService } from 'mongodb-data-service'; +import type { DataService as OriginalDataService } from '@mongodb-js/compass-connections/provider'; import type { ActivateHelpers } from 'hadron-app-registry'; import type AppRegistry from 'hadron-app-registry'; import { configureActions } from '../actions'; diff --git a/packages/compass-serverstats/package.json b/packages/compass-serverstats/package.json index a7c60da3fe7..990e40cdf6a 100644 --- a/packages/compass-serverstats/package.json +++ b/packages/compass-serverstats/package.json @@ -37,17 +37,17 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/compass-workspaces": "^0.5.1", diff --git a/packages/compass-serverstats/src/index.ts b/packages/compass-serverstats/src/index.ts index 995b417db5b..5b10bced541 100644 --- a/packages/compass-serverstats/src/index.ts +++ b/packages/compass-serverstats/src/index.ts @@ -1,10 +1,10 @@ import { PerformanceComponent } from './components'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; import { dataServiceLocator, type DataServiceLocator, -} from 'mongodb-data-service/provider'; + type DataService, +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import CurrentOpStore from './stores/current-op-store'; import ServerStatsStore from './stores/server-stats-graphs-store'; diff --git a/packages/compass-shell/package.json b/packages/compass-shell/package.json index 214ac6781d6..bbc718d6029 100644 --- a/packages/compass-shell/package.json +++ b/packages/compass-shell/package.json @@ -58,26 +58,27 @@ }, "dependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-user-data": "^0.1.17", "@mongodb-js/compass-utils": "^0.6.1", "@mongosh/node-runtime-worker-thread": "^2.2.0", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "peerDependencies": { "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-user-data": "^0.1.17", "@mongodb-js/compass-utils": "^0.6.1", "@mongosh/node-runtime-worker-thread": "^2.2.0", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { + "@mongodb-js/connection-storage": "^0.8.1", "@mongodb-js/eslint-config-compass": "^1.0.17", "@mongodb-js/mocha-config-compass": "^1.3.7", "@mongodb-js/prettier-config-compass": "^1.0.1", diff --git a/packages/compass-shell/src/index.ts b/packages/compass-shell/src/index.ts index 9b2ea5e361d..c09c1a63312 100644 --- a/packages/compass-shell/src/index.ts +++ b/packages/compass-shell/src/index.ts @@ -2,8 +2,10 @@ import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; import { ShellPlugin, onActivated } from './plugin'; import { registerHadronPlugin } from 'hadron-app-registry'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; -import type { DataService } from 'mongodb-data-service'; +import { + dataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; import { preferencesLocator, type PreferencesAccess, diff --git a/packages/compass-shell/src/modules/runtime.ts b/packages/compass-shell/src/modules/runtime.ts index 1495bc62a65..fa52137965c 100644 --- a/packages/compass-shell/src/modules/runtime.ts +++ b/packages/compass-shell/src/modules/runtime.ts @@ -1,4 +1,4 @@ -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import { WorkerRuntime } from './worker-runtime'; import type AppRegistry from 'hadron-app-registry'; import type { RootAction } from '.'; diff --git a/packages/compass-shell/src/plugin.spec.tsx b/packages/compass-shell/src/plugin.spec.tsx index 35a8c094dd1..2207b3b12f4 100644 --- a/packages/compass-shell/src/plugin.spec.tsx +++ b/packages/compass-shell/src/plugin.spec.tsx @@ -1,3 +1,4 @@ +import sinon from 'sinon'; import React from 'react'; import type { ReactWrapper } from 'enzyme'; import { mount } from 'enzyme'; @@ -6,7 +7,12 @@ import { expect } from 'chai'; import { CompassShell } from './components/compass-shell'; import { CompassShellPlugin } from './index'; import { AppRegistryProvider, globalAppRegistry } from 'hadron-app-registry'; -import { DataServiceProvider } from 'mongodb-data-service/provider'; +import { + ConnectionsManager, + ConnectionsManagerProvider, +} from '@mongodb-js/compass-connections/provider'; +import { ConnectionInfoProvider } from '@mongodb-js/connection-storage/provider'; +import { createNoopLoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; // Wait until a component is present that is rendered in a limited number // of microtask queue iterations. In particular, this does *not* wait for the @@ -27,9 +33,24 @@ async function waitForAsyncComponent(wrapper, Component, attempts = 10) { } describe('CompassShellPlugin', function () { + const dummyConnectionInfo = { + id: '1', + connectionOptions: { + connectionString: 'mongodb://localhost:27017', + }, + }; + const fakeDataService = { getMongoClientConnectionOptions() {}, } as any; + + const connectionsManager = new ConnectionsManager({ + logger: createNoopLoggerAndTelemetry().log.unbound, + }); + sinon.replace(connectionsManager, 'getDataServiceForConnection', () => { + return fakeDataService; + }); + let wrapper: ReactWrapper | null; afterEach(() => { @@ -42,9 +63,11 @@ describe('CompassShellPlugin', function () { {/* global */} {/* local */} - - - + + + + + ); @@ -65,9 +88,11 @@ describe('CompassShellPlugin', function () { {/* global */} {/* local */} - - - + + + + + ); diff --git a/packages/compass-shell/src/plugin.tsx b/packages/compass-shell/src/plugin.tsx index 20ff44445a3..2a8f8cc3eec 100644 --- a/packages/compass-shell/src/plugin.tsx +++ b/packages/compass-shell/src/plugin.tsx @@ -7,7 +7,7 @@ import { createLoggerAndTelemetryLocator, type LoggerAndTelemetry, } from '@mongodb-js/compass-logging/provider'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { PreferencesAccess } from 'compass-preferences-model'; export function ShellPlugin() { diff --git a/packages/compass-shell/src/stores/store.ts b/packages/compass-shell/src/stores/store.ts index 0e06096db4d..31860236926 100644 --- a/packages/compass-shell/src/stores/store.ts +++ b/packages/compass-shell/src/stores/store.ts @@ -7,7 +7,7 @@ import { setupLoggerAndTelemetry } from '@mongosh/logging'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import type { PreferencesAccess } from 'compass-preferences-model'; import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; export default class CompassShellStore { reduxStore: Store; diff --git a/packages/compass-sidebar/package.json b/packages/compass-sidebar/package.json index 5f3b1dd8fa6..fa0ecc74449 100644 --- a/packages/compass-sidebar/package.json +++ b/packages/compass-sidebar/package.json @@ -58,6 +58,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-databases-navigation": "^1.23.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", @@ -68,13 +69,13 @@ "@mongodb-js/compass-connections": "^1.25.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-databases-navigation": "^1.23.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-maybe-protect-connection-string": "^0.16.1", @@ -85,7 +86,6 @@ "@mongodb-js/compass-connections": "^1.25.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "mongodb-instance-model": "^12.18.1" }, "devDependencies": { @@ -111,6 +111,7 @@ "mocha": "^10.2.0", "mongodb": "^6.5.0", "mongodb-ns": "^2.4.0", + "mongodb-data-service": "^22.18.1", "nyc": "^15.1.0", "prettier": "^2.7.1", "react": "^17.0.2", diff --git a/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx b/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx index ab9cf3d7ad5..1050cf075bb 100644 --- a/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx +++ b/packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx @@ -40,8 +40,6 @@ export function MultipleConnectionSidebar({}: MultipleConnectionSidebarProps) { onConnected: noop_tmp, // TODO: COMPASS-7710, onConnectionAttemptStarted: noop_tmp, onConnectionFailed: noop_tmp, - isConnected: true, // TODO: COMPASS-7710 - connectFn: noop_tmp, // TODO: COMPASS-7710 appName: '', // TODO: COMPASS-7710 getAutoConnectInfo: noop_tmp, // TODO: COMPASS-7710 }); diff --git a/packages/compass-sidebar/src/index.ts b/packages/compass-sidebar/src/index.ts index ac182a65135..fa163ff4f3f 100644 --- a/packages/compass-sidebar/src/index.ts +++ b/packages/compass-sidebar/src/index.ts @@ -4,8 +4,10 @@ import type { SidebarPluginProps } from './plugin'; import SidebarPlugin from './plugin'; import { createSidebarStore } from './stores'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; -import type { DataService } from 'mongodb-data-service'; +import { + dataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; import type { MongoDBInstance } from 'mongodb-instance-model'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/provider'; diff --git a/packages/compass-sidebar/src/modules/data-service.ts b/packages/compass-sidebar/src/modules/data-service.ts index de77db9a4b2..0d3b3cfc43d 100644 --- a/packages/compass-sidebar/src/modules/data-service.ts +++ b/packages/compass-sidebar/src/modules/data-service.ts @@ -1,4 +1,4 @@ -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { RootAction, SidebarThunkAction } from '.'; export const SET_DATASERVICE = 'sidebar/SET_DATASERVICE' as const; diff --git a/packages/compass-sidebar/src/stores/store.ts b/packages/compass-sidebar/src/stores/store.ts index 27c5ab86103..6491c942094 100644 --- a/packages/compass-sidebar/src/stores/store.ts +++ b/packages/compass-sidebar/src/stores/store.ts @@ -12,7 +12,7 @@ import { setDataService } from '../modules/data-service'; import { toggleSidebar } from '../modules/is-expanded'; import type { ActivateHelpers, AppRegistry } from 'hadron-app-registry'; import type { MongoDBInstance } from 'mongodb-instance-model'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { ConnectionInfo } from '@mongodb-js/connection-info'; import { setIsPerformanceTabSupported } from '../modules/is-performance-tab-supported'; import type { MongoServerError } from 'mongodb'; diff --git a/packages/compass-web/package.json b/packages/compass-web/package.json index 8b5553f5a1a..55544ebf87e 100644 --- a/packages/compass-web/package.json +++ b/packages/compass-web/package.json @@ -65,6 +65,7 @@ "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-collection": "^4.23.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-crud": "^13.24.1", "@mongodb-js/compass-databases-collections": "^1.23.1", "@mongodb-js/compass-explain-plan": "^6.24.1", diff --git a/packages/compass-web/src/index.spec.tsx b/packages/compass-web/src/index.spec.tsx index a681927c57e..e6127a4f148 100644 --- a/packages/compass-web/src/index.spec.tsx +++ b/packages/compass-web/src/index.spec.tsx @@ -40,6 +40,7 @@ class MockDataService extends EventEmitter { return Promise.resolve([mockDb('foo'), mockDb('bar'), mockDb('buz')]); } disconnect() {} + addReauthenticationHandler() {} } describe('CompassWeb', function () { diff --git a/packages/compass-web/src/index.tsx b/packages/compass-web/src/index.tsx index f1e643b7ba1..68365cfdf6c 100644 --- a/packages/compass-web/src/index.tsx +++ b/packages/compass-web/src/index.tsx @@ -1,8 +1,11 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { connect } from 'mongodb-data-service'; -import type { DataService } from 'mongodb-data-service'; +import type { connect } from 'mongodb-data-service'; import { AppRegistryProvider } from 'hadron-app-registry'; -import { DataServiceProvider } from 'mongodb-data-service/provider'; +import { + ConnectionStatus, + ConnectionsManager, + ConnectionsManagerProvider, +} from '@mongodb-js/compass-connections/provider'; import { CompassInstanceStorePlugin } from '@mongodb-js/compass-app-stores'; import WorkspacesPlugin, { WorkspacesProvider, @@ -57,6 +60,7 @@ import type { AtlasUserInfo } from '@mongodb-js/atlas-service/renderer'; import { AtlasAuthService } from '@mongodb-js/atlas-service/provider'; import { ConnectionInfoProvider } from '@mongodb-js/connection-storage/provider'; import type { ConnectionInfo } from '@mongodb-js/connection-storage/renderer'; +import { useLoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; class CloudAtlasAuthService extends AtlasAuthService { signIn() { @@ -231,27 +235,28 @@ const CompassWeb = ({ ); const [connected, setConnected] = useState(false); const [connectionError, setConnectionError] = useState(null); - const dataService = useRef(); + const { log } = useLoggerAndTelemetry('CONNECTIONS-MANAGER'); + const connectionsManager = useRef( + new ConnectionsManager({ + logger: log.unbound, + __TEST_CONNECT_FN: __TEST_MONGODB_DATA_SERVICE_CONNECT_FN as + | typeof connect + | undefined, + }) + ); useEffect(() => { - const controller = new AbortController(); - let ds: DataService; + const connectionsManagerCurrent = connectionsManager.current; void (async () => { try { - const connectFn = - (__TEST_MONGODB_DATA_SERVICE_CONNECT_FN as typeof connect) ?? connect; - ds = await connectFn({ - connectionOptions: connectionInfo.connectionOptions, - signal: controller.signal, - }); - dataService.current = ds; + await connectionsManagerCurrent.connect(connectionInfo); setConnected(true); } catch (err) { setConnectionError(err); } })(); return () => { - void ds?.disconnect(); + void connectionsManagerCurrent.closeConnection(connectionInfo.id); }; }, [connectionInfo, __TEST_MONGODB_DATA_SERVICE_CONNECT_FN]); @@ -267,7 +272,11 @@ const CompassWeb = ({ utmMedium: 'product', }; - if (!connected || !dataService.current) { + if ( + !connected || + connectionsManager.current.statusOf(connectionInfo.id) !== + ConnectionStatus.Connected + ) { return ( - + @@ -292,7 +301,7 @@ const CompassWeb = ({ - + diff --git a/packages/compass-workspaces/package.json b/packages/compass-workspaces/package.json index 450028e1ee0..4a3788e11ea 100644 --- a/packages/compass-workspaces/package.json +++ b/packages/compass-workspaces/package.json @@ -63,19 +63,19 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-logging": "^1.2.14", "bson": "^6.5.0", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", diff --git a/packages/compass-workspaces/src/index.ts b/packages/compass-workspaces/src/index.ts index 42ac50fe2d3..0e137305708 100644 --- a/packages/compass-workspaces/src/index.ts +++ b/packages/compass-workspaces/src/index.ts @@ -18,9 +18,11 @@ import type { MongoDBInstance } from '@mongodb-js/compass-app-stores/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import type Collection from 'mongodb-collection-model'; import type Database from 'mongodb-database-model'; -import type { DataService } from 'mongodb-data-service'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; +import { + dataServiceLocator, + type DataService, + type DataServiceLocator, +} from '@mongodb-js/compass-connections/provider'; import { WorkspacesStoreContext } from './stores/context'; import toNS from 'mongodb-ns'; diff --git a/packages/data-service/package.json b/packages/data-service/package.json index 3199892be1f..f49d44328e3 100644 --- a/packages/data-service/package.json +++ b/packages/data-service/package.json @@ -19,20 +19,16 @@ "main": "lib/index.js", "compass:main": "src/index.ts", "exports": { - ".": "./lib/index.js", - "./provider": "./lib/provider.js" + ".": "./lib/index.js" }, "compass:exports": { - ".": "./src/index.ts", - "./provider": "./src/provider.ts" + ".": "./src/index.ts" }, "types": "./lib/index.d.ts", "files": [ "lib", "package.json", - "README.md", - "provider.js", - "provider.d.ts" + "README.md" ], "scripts": { "bootstrap": "npm run compile", @@ -64,7 +60,6 @@ "@mongodb-js/devtools-connect": "^2.6.0", "@mongodb-js/oidc-plugin": "^0.4.0", "@mongodb-js/ssh-tunnel": "^2.1.13", - "hadron-app-registry": "^9.1.8", "lodash": "^4.17.21", "mongodb-build-info": "^1.7.0", "mongodb-connection-string-url": "^2.6.0", diff --git a/packages/data-service/provider.d.ts b/packages/data-service/provider.d.ts deleted file mode 100644 index 7d54ead4225..00000000000 --- a/packages/data-service/provider.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/provider.d'; diff --git a/packages/data-service/provider.js b/packages/data-service/provider.js deleted file mode 100644 index 4b9a3c1e201..00000000000 --- a/packages/data-service/provider.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/provider'); diff --git a/packages/data-service/src/connection-attempt.ts b/packages/data-service/src/connection-attempt.ts index 524a3f99f00..c0591c4a769 100644 --- a/packages/data-service/src/connection-attempt.ts +++ b/packages/data-service/src/connection-attempt.ts @@ -130,7 +130,7 @@ export function createConnectionAttempt({ connectFn = connect, }: { logger: UnboundDataServiceImplLogger; - connectFn: typeof connect; + connectFn?: typeof connect; }): ConnectionAttempt { return new ConnectionAttempt({ logger, diff --git a/packages/data-service/src/provider.ts b/packages/data-service/src/provider.ts deleted file mode 100644 index ec6a03c55d9..00000000000 --- a/packages/data-service/src/provider.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { createContext, useContext } from 'react'; -import type DataService from './data-service'; -import { createServiceLocator } from 'hadron-app-registry'; - -const DataServiceContext = createContext(null); - -export const DataServiceProvider = DataServiceContext.Provider; - -export type DataServiceLocator< - K extends keyof DataService = keyof DataService, - L extends keyof DataService = K -> = () => Pick & Partial>; - -/** - * DataService locator method. Generic type can be used to limit the required / - * available methods on the injected service (only on compilation time, doesn't - * have the effect otherwise) - */ -export const dataServiceLocator = createServiceLocator( - function dataServiceLocator< - K extends keyof DataService = keyof DataService, - L extends keyof DataService = K - >(): Pick & Partial> { - const ds = useContext(DataServiceContext); - if (!ds) { - throw new Error('DataService is not available in the component context'); - } - return ds; - } -); - -export type { DataService }; -export { configuredKMSProviders } from './instance-detail-helper'; diff --git a/packages/databases-collections/package.json b/packages/databases-collections/package.json index b8f0e27f2e1..12c338e617d 100644 --- a/packages/databases-collections/package.json +++ b/packages/databases-collections/package.json @@ -49,6 +49,7 @@ "peerDependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", @@ -56,7 +57,6 @@ "@mongodb-js/my-queries-storage": "^0.5.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1", "react": "^17.0.2" }, "devDependencies": { @@ -79,6 +79,7 @@ "mongodb-instance-model": "^12.18.1", "mongodb-ns": "^2.4.0", "mongodb-query-parser": "^4.1.0", + "mongodb-data-service": "^22.18.1", "nyc": "^15.1.0", "prop-types": "^15.7.2", "react-dom": "^17.0.2", @@ -91,13 +92,13 @@ "dependencies": { "@mongodb-js/compass-app-stores": "^7.10.1", "@mongodb-js/compass-components": "^1.22.1", + "@mongodb-js/compass-connections": "^1.25.1", "@mongodb-js/compass-editor": "^0.21.1", "@mongodb-js/compass-logging": "^1.2.14", "@mongodb-js/compass-workspaces": "^0.5.1", "@mongodb-js/databases-collections-list": "^1.23.1", "@mongodb-js/my-queries-storage": "^0.5.1", "compass-preferences-model": "^2.18.1", - "hadron-app-registry": "^9.1.8", - "mongodb-data-service": "^22.18.1" + "hadron-app-registry": "^9.1.8" } } diff --git a/packages/databases-collections/src/collections-plugin.tsx b/packages/databases-collections/src/collections-plugin.tsx index ca0353298d7..5f6306ba8e4 100644 --- a/packages/databases-collections/src/collections-plugin.tsx +++ b/packages/databases-collections/src/collections-plugin.tsx @@ -2,9 +2,11 @@ import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider' import CollectionsList from './components/collections'; import { activatePlugin as activateCollectionsTabPlugin } from './stores/collections-store'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; -import type { DataService } from 'mongodb-data-service'; +import { + dataServiceLocator, + type DataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; export const CollectionsPlugin = registerHadronPlugin( { diff --git a/packages/databases-collections/src/databases-plugin.tsx b/packages/databases-collections/src/databases-plugin.tsx index 17f0642ecb6..23ab01032a7 100644 --- a/packages/databases-collections/src/databases-plugin.tsx +++ b/packages/databases-collections/src/databases-plugin.tsx @@ -2,9 +2,11 @@ import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider' import Databases from './components/databases'; import { activatePlugin as activateDatabasesTabPlugin } from './stores/databases-store'; import { registerHadronPlugin } from 'hadron-app-registry'; -import type { DataServiceLocator } from 'mongodb-data-service/provider'; -import { dataServiceLocator } from 'mongodb-data-service/provider'; -import type { DataService } from 'mongodb-data-service'; +import { + dataServiceLocator, + type DataServiceLocator, + type DataService, +} from '@mongodb-js/compass-connections/provider'; export const DatabasesPlugin = registerHadronPlugin( { diff --git a/packages/databases-collections/src/index.ts b/packages/databases-collections/src/index.ts index 937138c9e99..7f13fa59384 100644 --- a/packages/databases-collections/src/index.ts +++ b/packages/databases-collections/src/index.ts @@ -3,7 +3,7 @@ import { createLoggerAndTelemetryLocator } from '@mongodb-js/compass-logging/pro import { dataServiceLocator, type DataServiceLocator, -} from 'mongodb-data-service/provider'; +} from '@mongodb-js/compass-connections/provider'; import { mongoDBInstanceLocator } from '@mongodb-js/compass-app-stores/provider'; import { CollectionsPlugin } from './collections-plugin'; import { diff --git a/packages/databases-collections/src/modules/create-namespace.ts b/packages/databases-collections/src/modules/create-namespace.ts index b8458203e86..880368e4b07 100644 --- a/packages/databases-collections/src/modules/create-namespace.ts +++ b/packages/databases-collections/src/modules/create-namespace.ts @@ -1,6 +1,6 @@ import type { Reducer } from 'redux'; import { parseFilter } from 'mongodb-query-parser'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { CreateNamespaceThunkAction } from '../stores/create-namespace'; /** diff --git a/packages/databases-collections/src/stores/collections-store.ts b/packages/databases-collections/src/stores/collections-store.ts index 3fc4f9e80ae..33e10b39f82 100644 --- a/packages/databases-collections/src/stores/collections-store.ts +++ b/packages/databases-collections/src/stores/collections-store.ts @@ -4,7 +4,7 @@ import thunk from 'redux-thunk'; import { collectionsReducer } from '../modules'; import type AppRegistry from 'hadron-app-registry'; import type { MongoDBInstance } from 'mongodb-instance-model'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { ActivateHelpers } from 'hadron-app-registry'; import { collectionsChanged, instanceChanged } from '../modules/collections'; import type Database from 'mongodb-database-model'; diff --git a/packages/databases-collections/src/stores/create-namespace.ts b/packages/databases-collections/src/stores/create-namespace.ts index c736d160de1..85310c3ea41 100644 --- a/packages/databases-collections/src/stores/create-namespace.ts +++ b/packages/databases-collections/src/stores/create-namespace.ts @@ -1,5 +1,5 @@ import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { MongoDBInstance } from 'mongodb-instance-model'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging'; import type { Action, AnyAction } from 'redux'; diff --git a/packages/databases-collections/src/stores/databases-store.ts b/packages/databases-collections/src/stores/databases-store.ts index 84b3c06ba75..7cca099fd12 100644 --- a/packages/databases-collections/src/stores/databases-store.ts +++ b/packages/databases-collections/src/stores/databases-store.ts @@ -7,7 +7,7 @@ import databasesReducer, { } from '../modules/databases'; import type AppRegistry from 'hadron-app-registry'; import type { MongoDBInstance } from '@mongodb-js/compass-app-stores/provider'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import type { ActivateHelpers } from 'hadron-app-registry'; type DatabasesTabServices = { diff --git a/packages/databases-collections/src/stores/drop-namespace.tsx b/packages/databases-collections/src/stores/drop-namespace.tsx index 2119670467a..38940bca03b 100644 --- a/packages/databases-collections/src/stores/drop-namespace.tsx +++ b/packages/databases-collections/src/stores/drop-namespace.tsx @@ -7,7 +7,7 @@ import { } from '@mongodb-js/compass-components'; import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging/provider'; import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import toNS from 'mongodb-ns'; import type { ActivateHelpers } from 'hadron-app-registry'; diff --git a/packages/databases-collections/src/stores/rename-collection.ts b/packages/databases-collections/src/stores/rename-collection.ts index 1697588d8ed..ecc9cc5bc8e 100644 --- a/packages/databases-collections/src/stores/rename-collection.ts +++ b/packages/databases-collections/src/stores/rename-collection.ts @@ -1,7 +1,7 @@ import { legacy_createStore, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import type AppRegistry from 'hadron-app-registry'; -import type { DataService } from 'mongodb-data-service'; +import type { DataService } from '@mongodb-js/compass-connections/provider'; import reducer, { open } from '../modules/rename-collection/rename-collection'; import type { MongoDBInstance } from 'mongodb-instance-model'; import type { From aecfc3ab136a7add9ae5cf56a35b76c479b0df71 Mon Sep 17 00:00:00 2001 From: Basit <1305718+mabaasit@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:35:36 +0100 Subject: [PATCH 4/6] chore(compass-aggregations): remove pipeline text from toolbar COMPASS-7742 (#5579) remove pipeline text --- .../pipeline-toolbar/index.spec.tsx | 2 - .../src/components/pipeline-toolbar/index.tsx | 2 +- .../pipeline-header/index.spec.tsx | 4 -- .../pipeline-header/index.tsx | 47 +++++++------------ .../src/components/query-bar.tsx | 11 ++++- 5 files changed, 27 insertions(+), 39 deletions(-) diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx index df1f6c76694..d18f408ac82 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx @@ -40,8 +40,6 @@ describe('PipelineToolbar', function () { const header = within(toolbar).getByTestId('pipeline-header'); expect(header).to.exist; - expect(within(header).getByText('Pipeline'), 'shows pipeline text').to - .exist; expect( within(header).getByTestId('pipeline-toolbar-open-pipelines-button'), 'shows open saved pipelines button' diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/index.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/index.tsx index d5a9648f946..dfa7785e790 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/index.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/index.tsx @@ -23,7 +23,7 @@ const headerAndOptionsRowStyles = css({ border: '1px solid', borderRadius: '6px', borderColor: palette.gray.light2, - padding: `${spacing[2]}px ${spacing[2]}px ${spacing[2]}px ${spacing[3]}px`, + padding: spacing[2], background: palette.white, }); diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.spec.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.spec.tsx index 0529b994f72..f9c72703884 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.spec.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.spec.tsx @@ -33,10 +33,6 @@ describe('PipelineHeader', function () { container = screen.getByTestId('pipeline-header'); }); - it('renders pipeline text heading', function () { - expect(within(container).getByText('Pipeline')).to.exist; - }); - it('open saved pipelines button', async function () { const button = within(container).getByTestId( 'pipeline-toolbar-open-pipelines-button' diff --git a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx index 4728498e1ea..1e6c99d7532 100644 --- a/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx +++ b/packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/index.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { - Body, Icon, css, cx, @@ -22,12 +21,6 @@ const containerStyles = css({ alignItems: 'center', }); -const pipelineTextAndOpenStyles = css({ - display: 'flex', - gap: spacing[2], - alignItems: 'center', -}); - const openSavedPipelinesStyles = cx( css({ border: 'none', @@ -119,29 +112,23 @@ export const PipelineHeader: React.FunctionComponent = ({ }) => { const isSavingAggregationsEnabled = !!usePipelineStorage(); return ( -
-
-
- Pipeline - {isOpenPipelineVisible && isSavingAggregationsEnabled && ( - - )} -
-
- -
-
- -
+
+
+ {isOpenPipelineVisible && isSavingAggregationsEnabled && ( + + )} +
+
+ +
+
+
); diff --git a/packages/compass-query-bar/src/components/query-bar.tsx b/packages/compass-query-bar/src/components/query-bar.tsx index e2fa1e83e41..6f5b4225950 100644 --- a/packages/compass-query-bar/src/components/query-bar.tsx +++ b/packages/compass-query-bar/src/components/query-bar.tsx @@ -67,7 +67,6 @@ const queryBarFirstRowStyles = css({ // to account for their height individually. alignItems: 'flex-start', gap: spacing[2], - paddingLeft: spacing[1], }); const moreOptionsContainerStyles = css({ @@ -101,6 +100,9 @@ const queryOptionsContainerStyles = css({ const queryAIContainerStyles = css({ margin: `0px ${spacing[2]}px`, +}); + +const visibleAIContainerStyles = css({ marginTop: '2px', }); @@ -312,7 +314,12 @@ export const QueryBar: React.FunctionComponent = ({
)} {isAIFeatureEnabled && ( -
+
{ onHideAIInputClick?.(); From 4384d1fb0545d3f19fa808079b2b78538a3277a8 Mon Sep 17 00:00:00 2001 From: Himanshu Singh Date: Mon, 18 Mar 2024 17:22:11 +0100 Subject: [PATCH 5/6] chore: electron update to address SNYK-JS-ELECTRON-6405830 and SNYK-JS-ELECTRON-6346758 (#5590) --- configs/webpack-config-compass/package.json | 2 +- package-lock.json | 82 +++++++++---------- packages/atlas-service/package.json | 2 +- packages/compass-crud/package.json | 2 +- packages/compass-e2e-tests/package.json | 2 +- packages/compass-explain-plan/package.json | 2 +- packages/compass-find-in-page/package.json | 2 +- packages/compass-import-export/package.json | 4 +- packages/compass-indexes/package.json | 2 +- packages/compass-query-bar/package.json | 2 +- .../compass-schema-validation/package.json | 2 +- packages/compass-shell/package.json | 2 +- packages/compass-sidebar/package.json | 2 - packages/compass-utils/package.json | 2 +- packages/compass/package.json | 2 +- packages/connection-storage/package.json | 2 +- packages/hadron-build/package.json | 2 +- packages/hadron-ipc/package.json | 2 +- scripts/package.json | 2 +- 19 files changed, 59 insertions(+), 61 deletions(-) diff --git a/configs/webpack-config-compass/package.json b/configs/webpack-config-compass/package.json index 2d5e0eb5bcd..f9f31b51fba 100644 --- a/configs/webpack-config-compass/package.json +++ b/configs/webpack-config-compass/package.json @@ -74,7 +74,7 @@ "cli-progress": "^3.9.1", "core-js": "^3.17.3", "css-loader": "^4.3.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "html-webpack-plugin": "^5.3.2", "less-loader": "^10.0.1", "mini-css-extract-plugin": "^2.3.0", diff --git a/package-lock.json b/package-lock.json index e7643b90f3f..b2cb341ba9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -187,7 +187,7 @@ "cli-progress": "^3.9.1", "core-js": "^3.17.3", "css-loader": "^4.3.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "html-webpack-plugin": "^5.3.2", "less-loader": "^10.0.1", "mini-css-extract-plugin": "^2.3.0", @@ -21529,9 +21529,9 @@ } }, "node_modules/electron": { - "version": "28.2.5", - "resolved": "https://registry.npmjs.org/electron/-/electron-28.2.5.tgz", - "integrity": "sha512-qlvQkDNVAzN647NpiJJw7GYJqE0NwK4+1evkhrQ0Xv6Qgab1EtN50G4oDr4/x/+O5pGUG2P5d3isXu+37O3RDw==", + "version": "28.2.7", + "resolved": "https://registry.npmjs.org/electron/-/electron-28.2.7.tgz", + "integrity": "sha512-iEBTYNFuZtLpAS+8ql0ATUWBPAC9uMYqwNJtMLqlT3/zOzHj6aYpwoJILwWgIuTAx+/yTYgARS46Nr/RazxTpg==", "hasInstallScript": true, "dependencies": { "@electron/get": "^2.0.0", @@ -44870,7 +44870,7 @@ "@mongodb-js/devtools-connect": "^2.6.0", "@mongodb-js/oidc-plugin": "^0.4.0", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-ipc": "^3.2.12", "lodash": "^4.17.21", @@ -45645,7 +45645,7 @@ "compass-preferences-model": "^2.18.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-devtools-installer": "^3.2.0", "electron-dl": "^3.5.0", "electron-mocha": "^12.2.0", @@ -46325,7 +46325,7 @@ "classnames": "^2.2.6", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -46488,7 +46488,7 @@ "cross-spawn": "^7.0.3", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "fast-glob": "^3.2.7", "glob": "^10.2.5", @@ -46843,7 +46843,7 @@ "d3-flextree": "2.1.2", "d3-hierarchy": "^3.1.2", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", @@ -47066,7 +47066,7 @@ "@types/sinon-chai": "^3.2.5", "chai": "^4.3.4", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "mocha": "^10.2.0", @@ -47367,7 +47367,7 @@ "@mongodb-js/compass-workspaces": "^0.5.1", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12" @@ -47429,7 +47429,7 @@ "@mongodb-js/compass-workspaces": "^0.5.1", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12", @@ -47564,7 +47564,7 @@ "chai": "^4.2.0", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", @@ -48049,7 +48049,7 @@ "@testing-library/user-event": "^13.5.0", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", @@ -48293,7 +48293,7 @@ "@mongodb-js/webpack-config-compass": "^1.3.5", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -48512,7 +48512,7 @@ "@mongosh/logging": "^2.2.0", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -48818,7 +48818,7 @@ }, "optionalDependencies": { "@electron/remote": "^2.1.2", - "electron": "^28.2.5" + "electron": "^28.2.7" }, "peerDependencies": { "@mongodb-js/compass-logging": "^1.2.14" @@ -49638,7 +49638,7 @@ "@mongodb-js/compass-utils": "^0.6.1", "@mongodb-js/connection-info": "^0.1.5", "bson": "^6.5.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-ipc": "^3.2.12", "keytar": "^7.9.0", @@ -50190,7 +50190,7 @@ "debug": "^4.2.0", "del": "^2.0.2", "download": "^8.0.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-packager": "^15.5.1", "electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2", "flatnest": "^1.0.0", @@ -51037,7 +51037,7 @@ "license": "SSPL", "dependencies": { "debug": "^4.3.4", - "electron": "^28.2.5", + "electron": "^28.2.7", "is-electron-renderer": "^2.0.1" }, "devDependencies": { @@ -52204,7 +52204,7 @@ "@mongodb-js/monorepo-tools": "^1.1.1", "@mongodb-js/webpack-config-compass": "^1.3.5", "commander": "^11.0.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "glob": "^10.2.5", "jsdom": "^21.1.0", "make-fetch-happen": "^8.0.14", @@ -58138,7 +58138,7 @@ "chai": "^4.3.6", "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", "hadron-ipc": "^3.2.12", @@ -58700,7 +58700,7 @@ "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -58933,7 +58933,7 @@ "d3-flextree": "2.1.2", "d3-hierarchy": "^3.1.2", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", @@ -59105,7 +59105,7 @@ "@types/sinon-chai": "^3.2.5", "chai": "^4.3.4", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", @@ -59342,7 +59342,7 @@ "compass-preferences-model": "^2.18.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", @@ -59473,7 +59473,7 @@ "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", @@ -59770,7 +59770,7 @@ "chai": "^4.2.0", "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", @@ -59976,7 +59976,7 @@ "chai": "^4.2.0", "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -60015,7 +60015,7 @@ "@mongodb-js/webpack-config-compass": "^1.3.5", "commander": "^11.0.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "glob": "^10.2.5", "jsdom": "^21.1.0", @@ -60342,7 +60342,7 @@ "chai": "^4.2.0", "compass-preferences-model": "^2.18.1", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", @@ -60570,7 +60570,7 @@ "@types/sinon-chai": "^3.2.5", "chai": "^4.3.6", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.0", "mocha": "^10.2.0", @@ -61281,7 +61281,7 @@ "chai": "^4.3.6", "chai-as-promised": "^7.1.1", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "hadron-app-registry": "^9.1.8", "hadron-ipc": "^3.2.12", @@ -62243,7 +62243,7 @@ "core-js": "^3.17.3", "css-loader": "^4.3.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "html-webpack-plugin": "^5.3.2", "less-loader": "^10.0.1", @@ -71374,7 +71374,7 @@ "cross-spawn": "^7.0.3", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "fast-glob": "^3.2.7", "glob": "^10.2.5", @@ -73596,9 +73596,9 @@ } }, "electron": { - "version": "28.2.5", - "resolved": "https://registry.npmjs.org/electron/-/electron-28.2.5.tgz", - "integrity": "sha512-qlvQkDNVAzN647NpiJJw7GYJqE0NwK4+1evkhrQ0Xv6Qgab1EtN50G4oDr4/x/+O5pGUG2P5d3isXu+37O3RDw==", + "version": "28.2.7", + "resolved": "https://registry.npmjs.org/electron/-/electron-28.2.7.tgz", + "integrity": "sha512-iEBTYNFuZtLpAS+8ql0ATUWBPAC9uMYqwNJtMLqlT3/zOzHj6aYpwoJILwWgIuTAx+/yTYgARS46Nr/RazxTpg==", "requires": { "@electron/get": "^2.0.0", "@types/node": "^18.11.18", @@ -77505,7 +77505,7 @@ "del": "^2.0.2", "depcheck": "^1.4.1", "download": "^8.0.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-installer-debian": "^3.2.0", "electron-installer-dmg": "^4.0.0", "electron-installer-redhat": "^2.0.0", @@ -78226,7 +78226,7 @@ "chai": "^4.3.6", "debug": "^4.3.4", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "is-electron-renderer": "^2.0.1", "mocha": "^10.2.0", @@ -83967,7 +83967,7 @@ "compass-preferences-model": "^2.18.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-devtools-installer": "^3.2.0", "electron-dl": "^3.5.0", "electron-mocha": "^12.2.0", diff --git a/packages/atlas-service/package.json b/packages/atlas-service/package.json index 8acd2e74dcb..bd44a8dc3ed 100644 --- a/packages/atlas-service/package.json +++ b/packages/atlas-service/package.json @@ -81,7 +81,7 @@ "@mongodb-js/oidc-plugin": "^0.4.0", "hadron-app-registry": "^9.1.8", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-ipc": "^3.2.12", "lodash": "^4.17.21", "node-fetch": "^2.7.0", diff --git a/packages/compass-crud/package.json b/packages/compass-crud/package.json index 76d0a9cc157..75127fd1a94 100644 --- a/packages/compass-crud/package.json +++ b/packages/compass-crud/package.json @@ -91,7 +91,7 @@ "classnames": "^2.2.6", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", diff --git a/packages/compass-e2e-tests/package.json b/packages/compass-e2e-tests/package.json index b300485de02..10159c2585c 100644 --- a/packages/compass-e2e-tests/package.json +++ b/packages/compass-e2e-tests/package.json @@ -47,7 +47,7 @@ "cross-spawn": "^7.0.3", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "eslint": "^7.25.0", "fast-glob": "^3.2.7", "glob": "^10.2.5", diff --git a/packages/compass-explain-plan/package.json b/packages/compass-explain-plan/package.json index b020a926280..c61ebb6e314 100644 --- a/packages/compass-explain-plan/package.json +++ b/packages/compass-explain-plan/package.json @@ -81,7 +81,7 @@ "d3-flextree": "2.1.2", "d3-hierarchy": "^3.1.2", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", diff --git a/packages/compass-find-in-page/package.json b/packages/compass-find-in-page/package.json index 79bd3ac45d4..f30063f1144 100644 --- a/packages/compass-find-in-page/package.json +++ b/packages/compass-find-in-page/package.json @@ -77,7 +77,7 @@ "@types/sinon-chai": "^3.2.5", "chai": "^4.3.4", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "mocha": "^10.2.0", diff --git a/packages/compass-import-export/package.json b/packages/compass-import-export/package.json index 5dac212fa6e..757134112a1 100644 --- a/packages/compass-import-export/package.json +++ b/packages/compass-import-export/package.json @@ -64,7 +64,7 @@ "@mongodb-js/compass-workspaces": "^0.5.1", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12", @@ -79,7 +79,7 @@ "@mongodb-js/compass-workspaces": "^0.5.1", "bson": "^6.5.0", "compass-preferences-model": "^2.18.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-document": "^8.4.9", "hadron-ipc": "^3.2.12" diff --git a/packages/compass-indexes/package.json b/packages/compass-indexes/package.json index 9df9a75aa23..8b3aead8dc9 100644 --- a/packages/compass-indexes/package.json +++ b/packages/compass-indexes/package.json @@ -82,7 +82,7 @@ "chai": "^4.2.0", "depcheck": "^1.4.1", "ejson-shell-parser": "^2.0.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", diff --git a/packages/compass-query-bar/package.json b/packages/compass-query-bar/package.json index 3fc2ad7fbf0..bffc0170df7 100644 --- a/packages/compass-query-bar/package.json +++ b/packages/compass-query-bar/package.json @@ -83,7 +83,7 @@ "@testing-library/user-event": "^13.5.0", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "eslint": "^7.25.0", "lodash": "^4.17.21", diff --git a/packages/compass-schema-validation/package.json b/packages/compass-schema-validation/package.json index bc02bc92d0e..fc409d5303c 100644 --- a/packages/compass-schema-validation/package.json +++ b/packages/compass-schema-validation/package.json @@ -77,7 +77,7 @@ "@mongodb-js/webpack-config-compass": "^1.3.5", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", diff --git a/packages/compass-shell/package.json b/packages/compass-shell/package.json index bbc718d6029..1884cdb1178 100644 --- a/packages/compass-shell/package.json +++ b/packages/compass-shell/package.json @@ -88,7 +88,7 @@ "@mongosh/logging": "^2.2.0", "chai": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-mocha": "^12.2.0", "enzyme": "^3.11.0", "eslint": "^7.25.0", diff --git a/packages/compass-sidebar/package.json b/packages/compass-sidebar/package.json index fa0ecc74449..301ecc5d2b6 100644 --- a/packages/compass-sidebar/package.json +++ b/packages/compass-sidebar/package.json @@ -66,7 +66,6 @@ "@mongodb-js/connection-form": "^1.23.1", "@mongodb-js/connection-info": "^0.1.5", "@mongodb-js/connection-storage": "^0.8.1", - "@mongodb-js/compass-connections": "^1.25.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "mongodb-instance-model": "^12.18.1", @@ -83,7 +82,6 @@ "@mongodb-js/connection-form": "^1.23.1", "@mongodb-js/connection-info": "^0.1.5", "@mongodb-js/connection-storage": "^0.8.1", - "@mongodb-js/compass-connections": "^1.25.1", "compass-preferences-model": "^2.18.1", "hadron-app-registry": "^9.1.8", "mongodb-instance-model": "^12.18.1" diff --git a/packages/compass-utils/package.json b/packages/compass-utils/package.json index 8fe88ce93a2..9ff1e1185d6 100644 --- a/packages/compass-utils/package.json +++ b/packages/compass-utils/package.json @@ -51,7 +51,7 @@ }, "optionalDependencies": { "@electron/remote": "^2.1.2", - "electron": "^28.2.5" + "electron": "^28.2.7" }, "devDependencies": { "@mongodb-js/eslint-config-compass": "^1.0.17", diff --git a/packages/compass/package.json b/packages/compass/package.json index 7c1f95fcfc0..e9a65a77717 100644 --- a/packages/compass/package.json +++ b/packages/compass/package.json @@ -203,7 +203,7 @@ "compass-preferences-model": "^2.18.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-devtools-installer": "^3.2.0", "electron-dl": "^3.5.0", "electron-mocha": "^12.2.0", diff --git a/packages/connection-storage/package.json b/packages/connection-storage/package.json index 5b8257c59f8..e9a2bf2935e 100644 --- a/packages/connection-storage/package.json +++ b/packages/connection-storage/package.json @@ -61,7 +61,7 @@ "@mongodb-js/compass-utils": "^0.6.1", "@mongodb-js/connection-info": "^0.1.5", "bson": "^6.5.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "hadron-app-registry": "^9.1.8", "hadron-ipc": "^3.2.12", "keytar": "^7.9.0", diff --git a/packages/hadron-build/package.json b/packages/hadron-build/package.json index 28cd56a6efe..5875daf1185 100644 --- a/packages/hadron-build/package.json +++ b/packages/hadron-build/package.json @@ -34,7 +34,7 @@ "debug": "^4.2.0", "del": "^2.0.2", "download": "^8.0.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "electron-packager": "^15.5.1", "electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2", "flatnest": "^1.0.0", diff --git a/packages/hadron-ipc/package.json b/packages/hadron-ipc/package.json index b63b6107b89..ca35d0c2dfb 100644 --- a/packages/hadron-ipc/package.json +++ b/packages/hadron-ipc/package.json @@ -69,7 +69,7 @@ }, "dependencies": { "debug": "^4.3.4", - "electron": "^28.2.5", + "electron": "^28.2.7", "is-electron-renderer": "^2.0.1" } } diff --git a/scripts/package.json b/scripts/package.json index ca3859c3eb2..622afad66fb 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -40,7 +40,7 @@ "@mongodb-js/monorepo-tools": "^1.1.1", "@mongodb-js/webpack-config-compass": "^1.3.5", "commander": "^11.0.0", - "electron": "^28.2.5", + "electron": "^28.2.7", "glob": "^10.2.5", "jsdom": "^21.1.0", "make-fetch-happen": "^8.0.14", From 812d9700a51028f4282de709c236b4f11425f251 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:30:07 +0000 Subject: [PATCH 6/6] chore: update AUTHORS and THIRD-PARTY-NOTICES (#5591) Update report Co-authored-by: himanshusinghs --- THIRD-PARTY-NOTICES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index b73f8eca374..3fac367bb7e 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -246,7 +246,7 @@ This document was automatically generated on Mon Mar 18 2024. | **[ejson-shell-parser](#88e1a447c02d9ef3274034c023a5ebcec8188381b1bd951de7c57c140f7f3d4b)** | 2.0.1 | MIT | | **[electron-dl](#e97e034c7b93c63e7a433d75f6f1de3e0668764225ebbd61dbde8d1b55d6f3b7)** | 3.5.0 | MIT | | **[electron-squirrel-startup](#dcda22e402581a033ec2a017d6d05c094bf3173c1b03ae0471b2ce9078d3f601)** | 1.0.0 | Apache-2.0 | -| **[electron](#57679565310025c14cb661f0144f4d7a546a13b033a51522ca20a3fe4c3d9c43)** | 28.2.5 | MIT | +| **[electron](#48dc68a7cae0d8cb7b68405b921452da778d05f0adf9fe2397d8b267d4b8ace0)** | 28.2.7 | MIT | | **[encodeurl](#b89152db475e86531e570f87b45d8a51aa5e5d87d4cc3b960cee7b8febf1d26a)** | 1.0.2 | MIT | | **[end-of-stream](#fadc10994f5fa767d06fb25cfff35fb17a895daf3bc3477c782907668ed16563)** | 1.4.4 | MIT | | **[ensure-error](#3b1eba5276d89414cef21a1007e85c4f1d6749bf57b300e082ab23975a41dbc9)** | 3.0.1 | MIT | @@ -20783,9 +20783,9 @@ License files: See the License for the specific language governing permissions and limitations under the License. - + -### [electron](https://www.npmjs.com/package/electron) (version 28.2.5) +### [electron](https://www.npmjs.com/package/electron) (version 28.2.7) License tags: MIT