From 5ec3cbfe57a96aa6a5d32a1db2da2102936438a2 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 13:33:13 -0700 Subject: [PATCH 01/13] add pipeline utils --- packages/mongodb-constants/src/index.ts | 1 + .../mongodb-constants/src/pipeline.spec.ts | 69 +++++++++++++++++++ packages/mongodb-constants/src/pipeline.ts | 34 +++++++++ packages/saslprep/src/code-points-data.ts | 2 +- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 packages/mongodb-constants/src/pipeline.spec.ts create mode 100644 packages/mongodb-constants/src/pipeline.ts diff --git a/packages/mongodb-constants/src/index.ts b/packages/mongodb-constants/src/index.ts index d58137de..506a1731 100644 --- a/packages/mongodb-constants/src/index.ts +++ b/packages/mongodb-constants/src/index.ts @@ -16,3 +16,4 @@ export type { FilterOptions as CompletionFilterOptions, } from './filter'; export * from './atlas-search-templates'; +export * from './pipeline'; diff --git a/packages/mongodb-constants/src/pipeline.spec.ts b/packages/mongodb-constants/src/pipeline.spec.ts new file mode 100644 index 00000000..d61e0139 --- /dev/null +++ b/packages/mongodb-constants/src/pipeline.spec.ts @@ -0,0 +1,69 @@ +import { expect } from 'chai'; +import { isPipelineSearchQueryable } from './pipeline'; +import type { Document } from 'mongodb'; + +describe('isPipelineSearchQueryable', function () { + it('should return true for a valid pipeline with $addFields stage', function () { + const pipeline: Document[] = [{ $addFields: { testField: 'testValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return true for a valid pipeline with $set stage', function () { + const pipeline: Document[] = [{ $set: { testField: 'testValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return true for a valid pipeline with $match stage using $expr', function () { + const pipeline: Document[] = [ + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false for a pipeline with an unsupported stage', function () { + const pipeline: Document[] = [{ $group: { _id: '$field' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return false for a $match stage without $expr', function () { + const pipeline: Document[] = [{ $match: { nonExprKey: 'someValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return false for a $match stage with $expr and additional fields', function () { + const pipeline: Document[] = [ + { + $match: { $expr: { $eq: ['$field', 'value'] }, anotherField: 'value' }, + }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return true for an empty pipeline', function () { + const pipeline: Document[] = []; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false if any stage in the pipeline is invalid', function () { + const pipeline: Document[] = [ + { $addFields: { testField: 'testValue' } }, + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + { $group: { _id: '$field' } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should handle a pipeline with multiple valid stages', function () { + const pipeline: Document[] = [ + { $addFields: { field1: 'value1' } }, + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + { $set: { field2: 'value2' } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false for a $match stage with no conditions', function () { + const pipeline: Document[] = [{ $match: {} }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); +}); diff --git a/packages/mongodb-constants/src/pipeline.ts b/packages/mongodb-constants/src/pipeline.ts new file mode 100644 index 00000000..44515805 --- /dev/null +++ b/packages/mongodb-constants/src/pipeline.ts @@ -0,0 +1,34 @@ +/** utils related to view pipeline **/ + +import type { Document } from 'mongodb'; + +/** A view pipeline is searchQueryable (ie: a search index can be created on view) if + * a pipeline consists of only addFields, set and match with expr stages**/ +export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { + for (const stage of pipeline) { + const stageKey = Object.keys(stage)[0]; + + // Check if the stage is $addFields, $set, or $match + if ( + !( + stageKey === '$addFields' || + stageKey === '$set' || + stageKey === '$match' + ) + ) { + return false; + } + + // If the stage is $match, check if it uses $expr + if (stageKey === '$match') { + const matchStage = stage['$match'] as Document; + const matchKeys = Object.keys(matchStage || {}); + + if (!(matchKeys.length === 1 && matchKeys.includes('$expr'))) { + return false; + } + } + } + + return true; +}; diff --git a/packages/saslprep/src/code-points-data.ts b/packages/saslprep/src/code-points-data.ts index ad121e4c..0e5fb08a 100644 --- a/packages/saslprep/src/code-points-data.ts +++ b/packages/saslprep/src/code-points-data.ts @@ -2,7 +2,7 @@ import { gunzipSync } from 'zlib'; export default gunzipSync( Buffer.from( - 'H4sIAAAAAAACA+3dTYgcaRkA4LemO9Mhxm0FITnE9Cwr4jHgwgZ22B6YywqCJ0HQg5CL4sGTuOjCtGSF4CkHEW856MlTQHD3EJnWkU0Owh5VxE3LHlYQdNxd2U6mU59UV/d09fw4M2EySSXPAzNdP1/9fX/99bzVNZEN4jisRDulVFnQmLxm1aXF9Id/2/xMxNJ4XZlg576yuYlGt9gupV6xoFf8jhu9YvulVrFlp5XSx+lfvYhORGPXvqIRWSxERKtIm8bKFd10WNfKDS5Fo9jJWrq2+M2IlW+8uHgl/+BsROfPF4v5L7148Ur68Sha6dqZpYiVVy8tvLCWXo80Sf/lS89dGX2wHGvpzoXVn75/YWH5wmqe8uika82ViJXTy83Ve2k5Urozm38wm4/ls6t5uT6yfsTSJ7J3T0VKt8c5ExEXI8aFkH729c3eT+7EC6ca8cVULZUiYacX0R5PNWNxlh9L1y90q5kyzrpyy+9WcvOV6URntqw7La9sNVstXyczWVaWYbaaTYqzOHpr7pyiNT3/YzKuT63Z/FqKZlFTiuXtFM2vVOtIq7jiyKJbWZaOWD0euz0yoV2Z7kY0xq2x0YhfzVpmM5px9nTEH7JZ0ot5u39p0ma75Z472/s/H+2yr2inYyuq7fMvJivH2rM72N/Z3lyL31F2b1ya1P0zn816k2KP6JU9UzseucdQH5YqVeH/lFajSN2udg+TLJ9rksNxlvV2lki19rXKI43TPLejFu4ov7k3nMbhyhfY3Xb37f8BAGCf0eMTOH5szf154KmnNgKcnLb+Fzi2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XQAAHkX82zfXAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACeAgkAAAAAAAAAqLuRLAAAAAAAAACA2hv9D1iu/VAYaAYA', 'base64', ), ); From 6f06f7272fc4e5c30137d174df08fb64f298e840 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 13:38:16 -0700 Subject: [PATCH 02/13] undo change to not related file --- packages/saslprep/src/code-points-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/saslprep/src/code-points-data.ts b/packages/saslprep/src/code-points-data.ts index 0e5fb08a..ad121e4c 100644 --- a/packages/saslprep/src/code-points-data.ts +++ b/packages/saslprep/src/code-points-data.ts @@ -2,7 +2,7 @@ import { gunzipSync } from 'zlib'; export default gunzipSync( Buffer.from( - 'H4sIAAAAAAACE+3dTYgcaRkA4LemO9Mhxm0FITnE9Cwr4jHgwgZ22B6YywqCJ0HQg5CL4sGTuOjCtGSF4CkHEW856MlTQHD3EJnWkU0Owh5VxE3LHlYQdNxd2U6mU59UV/d09fw4M2EySSXPAzNdP1/9fX/99bzVNZEN4jisRDulVFnQmLxm1aXF9Id/2/xMxNJ4XZlg576yuYlGt9gupV6xoFf8jhu9YvulVrFlp5XSx+lfvYhORGPXvqIRWSxERKtIm8bKFd10WNfKDS5Fo9jJWrq2+M2IlW+8uHgl/+BsROfPF4v5L7148Ur68Sha6dqZpYiVVy8tvLCWXo80Sf/lS89dGX2wHGvpzoXVn75/YWH5wmqe8uika82ViJXTy83Ve2k5Urozm38wm4/ls6t5uT6yfsTSJ7J3T0VKt8c5ExEXI8aFkH729c3eT+7EC6ca8cVULZUiYacX0R5PNWNxlh9L1y90q5kyzrpyy+9WcvOV6URntqw7La9sNVstXyczWVaWYbaaTYqzOHpr7pyiNT3/YzKuT63Z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oHpS4PddV8ki1it61//pw1g7z6p1U/26Nm2llST57B5rUvuG0XqSU/rPd7jYrqWcbd+beJQ77BgPMDwn37/8BAGCf0eMTOH4cPlufv9VGgJOzqf8Fjm1APXkd7B7f5dF57GPMaWy/MTvjvNvtXj6h8W2+GXvnzXaseeeHEgAAAAAAAB7aQXeKlcGiadBoEOeLb2dtpGOL2MyOtf391a3P/zD96c3JzIP3t4oV797vrh8+vn+YRL5bBuj/AQAAAABqJvfHXQAAHkX82zfXAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACeAgkAAAAAAAAAqLuRLAAAAAAAAACA2hv9D1iu/VAYaAYA', 'base64', ), ); From 729dc1f14ecb1b08e3f311e62c6910b5881d66a4 Mon Sep 17 00:00:00 2001 From: DarshanaVenkatesh <70602567+DarshanaVenkatesh@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:39:34 -0700 Subject: [PATCH 03/13] syntax fix Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/mongodb-constants/src/pipeline.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mongodb-constants/src/pipeline.ts b/packages/mongodb-constants/src/pipeline.ts index 44515805..fd4db484 100644 --- a/packages/mongodb-constants/src/pipeline.ts +++ b/packages/mongodb-constants/src/pipeline.ts @@ -24,7 +24,7 @@ export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { const matchStage = stage['$match'] as Document; const matchKeys = Object.keys(matchStage || {}); - if (!(matchKeys.length === 1 && matchKeys.includes('$expr'))) { + if (matchKeys.length !== 1 || !matchKeys.includes('$expr')) { return false; } } From 698426f08745f042507c8b967200a5c4281a4695 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 13:42:55 -0700 Subject: [PATCH 04/13] comment method --- packages/mongodb-constants/src/pipeline.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/mongodb-constants/src/pipeline.ts b/packages/mongodb-constants/src/pipeline.ts index fd4db484..dceaacfa 100644 --- a/packages/mongodb-constants/src/pipeline.ts +++ b/packages/mongodb-constants/src/pipeline.ts @@ -3,7 +3,11 @@ import type { Document } from 'mongodb'; /** A view pipeline is searchQueryable (ie: a search index can be created on view) if - * a pipeline consists of only addFields, set and match with expr stages**/ + * a pipeline consists of only addFields, set and match with expr stages* + * + * @param pipeline the view pipeline + * @returns whether pipeline is search queryable + * */ export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { for (const stage of pipeline) { const stageKey = Object.keys(stage)[0]; From d0c3e1eda69d45dd0aca5a8cb4ea1bdfd5d8a38e Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 13:45:31 -0700 Subject: [PATCH 05/13] export specific method --- packages/mongodb-constants/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mongodb-constants/src/index.ts b/packages/mongodb-constants/src/index.ts index 506a1731..7c8fc7c2 100644 --- a/packages/mongodb-constants/src/index.ts +++ b/packages/mongodb-constants/src/index.ts @@ -16,4 +16,4 @@ export type { FilterOptions as CompletionFilterOptions, } from './filter'; export * from './atlas-search-templates'; -export * from './pipeline'; +export { isPipelineSearchQueryable } from './pipeline'; From 77fc67ce5522b98a9768b6f91372ad4553a64afd Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 13:54:35 -0700 Subject: [PATCH 06/13] add missing dep --- package-lock.json | 30 +++++++++++++------------ packages/mongodb-constants/package.json | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 183d374b..d1fa9575 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12168,9 +12168,9 @@ } }, "node_modules/bson": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", - "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==", + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", + "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", "license": "Apache-2.0", "engines": { "node": ">=16.20.1" @@ -22416,13 +22416,13 @@ } }, "node_modules/mongodb": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.16.0.tgz", - "integrity": "sha512-D1PNcdT0y4Grhou5Zi/qgipZOYeWrhLEpk33n3nm6LGtz61jvO88WlrWCK/bigMjpnOdAUKKQwsGIl0NtWMyYw==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.18.0.tgz", + "integrity": "sha512-fO5ttN9VC8P0F5fqtQmclAkgXZxbIkYRTUi1j8JO6IYwvamkhtYDilJr35jOPELR49zqCJgXZWwCtW7B+TM8vQ==", "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.1.9", - "bson": "^6.10.3", + "bson": "^6.10.4", "mongodb-connection-string-url": "^3.0.0" }, "engines": { @@ -30587,6 +30587,7 @@ "version": "0.12.2", "license": "Apache-2.0", "dependencies": { + "mongodb": "^6.18.0", "semver": "^7.7.1" }, "devDependencies": { @@ -38769,6 +38770,7 @@ "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", + "mongodb": "^6.18.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "semver": "^7.7.1", @@ -42989,9 +42991,9 @@ } }, "bson": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", - "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==" + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", + "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==" }, "buffer": { "version": "5.7.1", @@ -50533,12 +50535,12 @@ "dev": true }, "mongodb": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.16.0.tgz", - "integrity": "sha512-D1PNcdT0y4Grhou5Zi/qgipZOYeWrhLEpk33n3nm6LGtz61jvO88WlrWCK/bigMjpnOdAUKKQwsGIl0NtWMyYw==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.18.0.tgz", + "integrity": "sha512-fO5ttN9VC8P0F5fqtQmclAkgXZxbIkYRTUi1j8JO6IYwvamkhtYDilJr35jOPELR49zqCJgXZWwCtW7B+TM8vQ==", "requires": { "@mongodb-js/saslprep": "^1.1.9", - "bson": "^6.10.3", + "bson": "^6.10.4", "mongodb-connection-string-url": "^3.0.0" } }, diff --git a/packages/mongodb-constants/package.json b/packages/mongodb-constants/package.json index e7fa65e4..e5c5c4f0 100644 --- a/packages/mongodb-constants/package.json +++ b/packages/mongodb-constants/package.json @@ -72,6 +72,7 @@ "typescript": "^5.0.4" }, "dependencies": { + "mongodb": "^6.18.0", "semver": "^7.7.1" } } From 7fc5f83f2825c1ff5e9833db220d3e5c9b23c150 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 14:11:23 -0700 Subject: [PATCH 07/13] update index.spec.ts --- packages/mongodb-constants/src/index.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mongodb-constants/src/index.spec.ts b/packages/mongodb-constants/src/index.spec.ts index 62e7a779..d3ee58a5 100644 --- a/packages/mongodb-constants/src/index.spec.ts +++ b/packages/mongodb-constants/src/index.spec.ts @@ -6,6 +6,7 @@ describe('constants', function () { expect(Object.keys(constants)).to.deep.eq([ 'getFilteredCompletions', 'wrapField', + 'isPipelineSearchQueryable', 'ACCUMULATORS', 'BSON_TYPE_ALIASES', 'BSON_TYPES', From 73e9e9e45a9b17fd9a510aee505279dde26451be Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 15:39:16 -0700 Subject: [PATCH 08/13] add isVersionSearchCompatible methods --- packages/mongodb-constants/src/index.ts | 2 +- .../mongodb-constants/src/pipeline.spec.ts | 69 ---------- packages/mongodb-constants/src/pipeline.ts | 38 ------ packages/mongodb-constants/src/views.spec.ts | 129 ++++++++++++++++++ packages/mongodb-constants/src/views.ts | 81 +++++++++++ 5 files changed, 211 insertions(+), 108 deletions(-) delete mode 100644 packages/mongodb-constants/src/pipeline.spec.ts delete mode 100644 packages/mongodb-constants/src/pipeline.ts create mode 100644 packages/mongodb-constants/src/views.spec.ts create mode 100644 packages/mongodb-constants/src/views.ts diff --git a/packages/mongodb-constants/src/index.ts b/packages/mongodb-constants/src/index.ts index 7c8fc7c2..af174c2c 100644 --- a/packages/mongodb-constants/src/index.ts +++ b/packages/mongodb-constants/src/index.ts @@ -16,4 +16,4 @@ export type { FilterOptions as CompletionFilterOptions, } from './filter'; export * from './atlas-search-templates'; -export { isPipelineSearchQueryable } from './pipeline'; +export * from './views'; diff --git a/packages/mongodb-constants/src/pipeline.spec.ts b/packages/mongodb-constants/src/pipeline.spec.ts deleted file mode 100644 index d61e0139..00000000 --- a/packages/mongodb-constants/src/pipeline.spec.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { expect } from 'chai'; -import { isPipelineSearchQueryable } from './pipeline'; -import type { Document } from 'mongodb'; - -describe('isPipelineSearchQueryable', function () { - it('should return true for a valid pipeline with $addFields stage', function () { - const pipeline: Document[] = [{ $addFields: { testField: 'testValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); - }); - - it('should return true for a valid pipeline with $set stage', function () { - const pipeline: Document[] = [{ $set: { testField: 'testValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); - }); - - it('should return true for a valid pipeline with $match stage using $expr', function () { - const pipeline: Document[] = [ - { $match: { $expr: { $eq: ['$field', 'value'] } } }, - ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); - }); - - it('should return false for a pipeline with an unsupported stage', function () { - const pipeline: Document[] = [{ $group: { _id: '$field' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); - }); - - it('should return false for a $match stage without $expr', function () { - const pipeline: Document[] = [{ $match: { nonExprKey: 'someValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); - }); - - it('should return false for a $match stage with $expr and additional fields', function () { - const pipeline: Document[] = [ - { - $match: { $expr: { $eq: ['$field', 'value'] }, anotherField: 'value' }, - }, - ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); - }); - - it('should return true for an empty pipeline', function () { - const pipeline: Document[] = []; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); - }); - - it('should return false if any stage in the pipeline is invalid', function () { - const pipeline: Document[] = [ - { $addFields: { testField: 'testValue' } }, - { $match: { $expr: { $eq: ['$field', 'value'] } } }, - { $group: { _id: '$field' } }, - ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); - }); - - it('should handle a pipeline with multiple valid stages', function () { - const pipeline: Document[] = [ - { $addFields: { field1: 'value1' } }, - { $match: { $expr: { $eq: ['$field', 'value'] } } }, - { $set: { field2: 'value2' } }, - ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); - }); - - it('should return false for a $match stage with no conditions', function () { - const pipeline: Document[] = [{ $match: {} }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); - }); -}); diff --git a/packages/mongodb-constants/src/pipeline.ts b/packages/mongodb-constants/src/pipeline.ts deleted file mode 100644 index dceaacfa..00000000 --- a/packages/mongodb-constants/src/pipeline.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** utils related to view pipeline **/ - -import type { Document } from 'mongodb'; - -/** A view pipeline is searchQueryable (ie: a search index can be created on view) if - * a pipeline consists of only addFields, set and match with expr stages* - * - * @param pipeline the view pipeline - * @returns whether pipeline is search queryable - * */ -export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { - for (const stage of pipeline) { - const stageKey = Object.keys(stage)[0]; - - // Check if the stage is $addFields, $set, or $match - if ( - !( - stageKey === '$addFields' || - stageKey === '$set' || - stageKey === '$match' - ) - ) { - return false; - } - - // If the stage is $match, check if it uses $expr - if (stageKey === '$match') { - const matchStage = stage['$match'] as Document; - const matchKeys = Object.keys(matchStage || {}); - - if (matchKeys.length !== 1 || !matchKeys.includes('$expr')) { - return false; - } - } - } - - return true; -}; diff --git a/packages/mongodb-constants/src/views.spec.ts b/packages/mongodb-constants/src/views.spec.ts new file mode 100644 index 00000000..96eddca9 --- /dev/null +++ b/packages/mongodb-constants/src/views.spec.ts @@ -0,0 +1,129 @@ +import { expect } from 'chai'; +import { + isPipelineSearchQueryable, + isVersionSearchCompatibleForViewsCompass, + isVersionSearchCompatibleForViewsDataExplorer, +} from './views'; +import type { Document } from 'mongodb'; + +describe('views', function () { + describe('isPipelineSearchQueryable', function () { + it('should return true for a valid pipeline with $addFields stage', function () { + const pipeline: Document[] = [{ $addFields: { testField: 'testValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return true for a valid pipeline with $set stage', function () { + const pipeline: Document[] = [{ $set: { testField: 'testValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return true for a valid pipeline with $match stage using $expr', function () { + const pipeline: Document[] = [ + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false for a pipeline with an unsupported stage', function () { + const pipeline: Document[] = [{ $group: { _id: '$field' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return false for a $match stage without $expr', function () { + const pipeline: Document[] = [{ $match: { nonExprKey: 'someValue' } }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return false for a $match stage with $expr and additional fields', function () { + const pipeline: Document[] = [ + { + $match: { + $expr: { $eq: ['$field', 'value'] }, + anotherField: 'value', + }, + }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should return true for an empty pipeline', function () { + const pipeline: Document[] = []; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false if any stage in the pipeline is invalid', function () { + const pipeline: Document[] = [ + { $addFields: { testField: 'testValue' } }, + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + { $group: { _id: '$field' } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + + it('should handle a pipeline with multiple valid stages', function () { + const pipeline: Document[] = [ + { $addFields: { field1: 'value1' } }, + { $match: { $expr: { $eq: ['$field', 'value'] } } }, + { $set: { field2: 'value2' } }, + ]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + }); + + it('should return false for a $match stage with no conditions', function () { + const pipeline: Document[] = [{ $match: {} }]; + expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + }); + }); + + describe('isVersionSearchCompatibleForViewsDataExplorer', function () { + it('should return true for a version greater than or equal to 8.0.0', function () { + expect(isVersionSearchCompatibleForViewsDataExplorer('8.0.0')).to.equal( + true, + ); + expect(isVersionSearchCompatibleForViewsDataExplorer('8.0.1')).to.equal( + true, + ); + expect(isVersionSearchCompatibleForViewsDataExplorer('8.1.0')).to.equal( + true, + ); + }); + + it('should return false for a version less than 8.0.0', function () { + expect(isVersionSearchCompatibleForViewsDataExplorer('7.9.9')).to.equal( + false, + ); + expect(isVersionSearchCompatibleForViewsDataExplorer('7.0.0')).to.equal( + false, + ); + }); + + it('should handle invalid version format by returning false', function () { + expect( + isVersionSearchCompatibleForViewsDataExplorer('invalid-version'), + ).to.equal(false); + expect(isVersionSearchCompatibleForViewsDataExplorer('')).to.equal(false); + }); + }); + + describe('isVersionSearchCompatibleForViewsCompass', function () { + it('should return true for a version greater than or equal to 8.1.0', function () { + expect(isVersionSearchCompatibleForViewsCompass('8.1.0')).to.equal(true); + expect(isVersionSearchCompatibleForViewsCompass('8.1.1')).to.equal(true); + expect(isVersionSearchCompatibleForViewsCompass('8.2.0')).to.equal(true); + }); + + it('should return false for a version less than 8.1.0', function () { + expect(isVersionSearchCompatibleForViewsCompass('8.0.9')).to.equal(false); + expect(isVersionSearchCompatibleForViewsCompass('8.0.0')).to.equal(false); + expect(isVersionSearchCompatibleForViewsCompass('7.9.9')).to.equal(false); + }); + + it('should handle invalid version format by returning false', function () { + expect( + isVersionSearchCompatibleForViewsCompass('invalid-version'), + ).to.equal(false); + expect(isVersionSearchCompatibleForViewsCompass('')).to.equal(false); + }); + }); +}); diff --git a/packages/mongodb-constants/src/views.ts b/packages/mongodb-constants/src/views.ts new file mode 100644 index 00000000..cc41fb5e --- /dev/null +++ b/packages/mongodb-constants/src/views.ts @@ -0,0 +1,81 @@ +/** utils related to view pipeline **/ + +import type { Document } from 'mongodb'; +import semver from 'semver'; + +/** + * Constants for view compatibility; + */ +export const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE = '8.0.0'; +export const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_COMPASS = '8.1.0'; + +/** A view pipeline is searchQueryable (ie: a search index can be created on view) if + * a pipeline consists of only addFields, set and match with expr stages* + * + * @param pipeline the view pipeline + * @returns whether pipeline is search queryable + * */ +export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { + for (const stage of pipeline) { + const stageKey = Object.keys(stage)[0]; + + // Check if the stage is $addFields, $set, or $match + if ( + !( + stageKey === '$addFields' || + stageKey === '$set' || + stageKey === '$match' + ) + ) { + return false; + } + + // If the stage is $match, check if it uses $expr + if (stageKey === '$match') { + const matchStage = stage['$match'] as Document; + const matchKeys = Object.keys(matchStage || {}); + + if (matchKeys.length !== 1 || !matchKeys.includes('$expr')) { + return false; + } + } + } + + return true; +}; + +/** Views allow search indexes to be made on them in DE for server version 8.1+ + * + * @param serverVersion the server version + * @returns whether serverVersion is search compatible for views in DE + * */ +export const isVersionSearchCompatibleForViewsDataExplorer = ( + serverVersion: string, +) => { + try { + return semver.gte( + serverVersion, + MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE, + ); + } catch { + return false; + } +}; + +/** Views allow search indexes to be made on them in compass for mongodb version 8.0+ + * + * @param serverVersion the view pipeline + * @returns whether serverVersion is search compatible for views in DE + * */ +export const isVersionSearchCompatibleForViewsCompass = ( + serverVersion: string, +) => { + try { + return semver.gte( + serverVersion, + MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_COMPASS, + ); + } catch { + return false; + } +}; From d72e15213361e022c68f6f36f4316fdc2bc8bd4c Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 15:45:25 -0700 Subject: [PATCH 09/13] export as one --- packages/mongodb-constants/src/index.spec.ts | 2 +- packages/mongodb-constants/src/views.ts | 44 ++++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/packages/mongodb-constants/src/index.spec.ts b/packages/mongodb-constants/src/index.spec.ts index d3ee58a5..987ba3ff 100644 --- a/packages/mongodb-constants/src/index.spec.ts +++ b/packages/mongodb-constants/src/index.spec.ts @@ -6,7 +6,6 @@ describe('constants', function () { expect(Object.keys(constants)).to.deep.eq([ 'getFilteredCompletions', 'wrapField', - 'isPipelineSearchQueryable', 'ACCUMULATORS', 'BSON_TYPE_ALIASES', 'BSON_TYPES', @@ -33,6 +32,7 @@ describe('constants', function () { 'VALIDATION_TEMPLATE', 'ATLAS_SEARCH_TEMPLATES', 'ATLAS_VECTOR_SEARCH_TEMPLATE', + 'VIEW_PIPELINE_UTILS', ]); }); }); diff --git a/packages/mongodb-constants/src/views.ts b/packages/mongodb-constants/src/views.ts index cc41fb5e..cbd9d9a4 100644 --- a/packages/mongodb-constants/src/views.ts +++ b/packages/mongodb-constants/src/views.ts @@ -3,19 +3,17 @@ import type { Document } from 'mongodb'; import semver from 'semver'; -/** - * Constants for view compatibility; - */ -export const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE = '8.0.0'; -export const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_COMPASS = '8.1.0'; +const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE = '8.0.0'; +const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_COMPASS = '8.1.0'; -/** A view pipeline is searchQueryable (ie: a search index can be created on view) if - * a pipeline consists of only addFields, set and match with expr stages* +/** + * A view pipeline is searchQueryable (ie: a search index can be created on view) if + * a pipeline consists of only addFields, set and match with expr stages * * @param pipeline the view pipeline * @returns whether pipeline is search queryable - * */ -export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { + */ +const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { for (const stage of pipeline) { const stageKey = Object.keys(stage)[0]; @@ -44,14 +42,15 @@ export const isPipelineSearchQueryable = (pipeline: Document[]): boolean => { return true; }; -/** Views allow search indexes to be made on them in DE for server version 8.1+ +/** + * Views allow search indexes to be made on them in DE for server version 8.1+ * * @param serverVersion the server version * @returns whether serverVersion is search compatible for views in DE - * */ -export const isVersionSearchCompatibleForViewsDataExplorer = ( + */ +const isVersionSearchCompatibleForViewsDataExplorer = ( serverVersion: string, -) => { +): boolean => { try { return semver.gte( serverVersion, @@ -62,14 +61,15 @@ export const isVersionSearchCompatibleForViewsDataExplorer = ( } }; -/** Views allow search indexes to be made on them in compass for mongodb version 8.0+ +/** + * Views allow search indexes to be made on them in compass for mongodb version 8.0+ * * @param serverVersion the view pipeline - * @returns whether serverVersion is search compatible for views in DE - * */ -export const isVersionSearchCompatibleForViewsCompass = ( + * @returns whether serverVersion is search compatible for views in Compass + */ +const isVersionSearchCompatibleForViewsCompass = ( serverVersion: string, -) => { +): boolean => { try { return semver.gte( serverVersion, @@ -79,3 +79,11 @@ export const isVersionSearchCompatibleForViewsCompass = ( return false; } }; + +export const VIEW_PIPELINE_UTILS = { + MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE, + MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_COMPASS, + isPipelineSearchQueryable, + isVersionSearchCompatibleForViewsDataExplorer, + isVersionSearchCompatibleForViewsCompass, +}; From 0a8de98f4078519892ab97ed2437381be6f51a84 Mon Sep 17 00:00:00 2001 From: DarshanaVenkatesh <70602567+DarshanaVenkatesh@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:48:03 -0700 Subject: [PATCH 10/13] typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/mongodb-constants/src/views.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mongodb-constants/src/views.ts b/packages/mongodb-constants/src/views.ts index cbd9d9a4..2054bde2 100644 --- a/packages/mongodb-constants/src/views.ts +++ b/packages/mongodb-constants/src/views.ts @@ -64,7 +64,7 @@ const isVersionSearchCompatibleForViewsDataExplorer = ( /** * Views allow search indexes to be made on them in compass for mongodb version 8.0+ * - * @param serverVersion the view pipeline + * @param serverVersion the server version * @returns whether serverVersion is search compatible for views in Compass */ const isVersionSearchCompatibleForViewsCompass = ( From 3ba08d8e8aa7753bd33c127366001e444d954058 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 16:01:00 -0700 Subject: [PATCH 11/13] update view.spec file --- packages/mongodb-constants/src/views.spec.ts | 126 +++++++++++++------ 1 file changed, 86 insertions(+), 40 deletions(-) diff --git a/packages/mongodb-constants/src/views.spec.ts b/packages/mongodb-constants/src/views.spec.ts index 96eddca9..6a83c53f 100644 --- a/packages/mongodb-constants/src/views.spec.ts +++ b/packages/mongodb-constants/src/views.spec.ts @@ -1,38 +1,44 @@ import { expect } from 'chai'; -import { - isPipelineSearchQueryable, - isVersionSearchCompatibleForViewsCompass, - isVersionSearchCompatibleForViewsDataExplorer, -} from './views'; +import { VIEW_PIPELINE_UTILS } from './views'; import type { Document } from 'mongodb'; describe('views', function () { describe('isPipelineSearchQueryable', function () { it('should return true for a valid pipeline with $addFields stage', function () { const pipeline: Document[] = [{ $addFields: { testField: 'testValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + true, + ); }); it('should return true for a valid pipeline with $set stage', function () { const pipeline: Document[] = [{ $set: { testField: 'testValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + true, + ); }); it('should return true for a valid pipeline with $match stage using $expr', function () { const pipeline: Document[] = [ { $match: { $expr: { $eq: ['$field', 'value'] } } }, ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + true, + ); }); it('should return false for a pipeline with an unsupported stage', function () { const pipeline: Document[] = [{ $group: { _id: '$field' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + false, + ); }); it('should return false for a $match stage without $expr', function () { const pipeline: Document[] = [{ $match: { nonExprKey: 'someValue' } }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + false, + ); }); it('should return false for a $match stage with $expr and additional fields', function () { @@ -44,12 +50,16 @@ describe('views', function () { }, }, ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + false, + ); }); it('should return true for an empty pipeline', function () { const pipeline: Document[] = []; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + true, + ); }); it('should return false if any stage in the pipeline is invalid', function () { @@ -58,7 +68,9 @@ describe('views', function () { { $match: { $expr: { $eq: ['$field', 'value'] } } }, { $group: { _id: '$field' } }, ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + false, + ); }); it('should handle a pipeline with multiple valid stages', function () { @@ -67,63 +79,97 @@ describe('views', function () { { $match: { $expr: { $eq: ['$field', 'value'] } } }, { $set: { field2: 'value2' } }, ]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(true); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + true, + ); }); it('should return false for a $match stage with no conditions', function () { const pipeline: Document[] = [{ $match: {} }]; - expect(isPipelineSearchQueryable(pipeline)).to.equal(false); + expect(VIEW_PIPELINE_UTILS.isPipelineSearchQueryable(pipeline)).to.equal( + false, + ); }); }); describe('isVersionSearchCompatibleForViewsDataExplorer', function () { it('should return true for a version greater than or equal to 8.0.0', function () { - expect(isVersionSearchCompatibleForViewsDataExplorer('8.0.0')).to.equal( - true, - ); - expect(isVersionSearchCompatibleForViewsDataExplorer('8.0.1')).to.equal( - true, - ); - expect(isVersionSearchCompatibleForViewsDataExplorer('8.1.0')).to.equal( - true, - ); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + '8.0.0', + ), + ).to.equal(true); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + '8.0.1', + ), + ).to.equal(true); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + '8.1.0', + ), + ).to.equal(true); }); it('should return false for a version less than 8.0.0', function () { - expect(isVersionSearchCompatibleForViewsDataExplorer('7.9.9')).to.equal( - false, - ); - expect(isVersionSearchCompatibleForViewsDataExplorer('7.0.0')).to.equal( - false, - ); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + '7.9.9', + ), + ).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + '7.0.0', + ), + ).to.equal(false); }); it('should handle invalid version format by returning false', function () { expect( - isVersionSearchCompatibleForViewsDataExplorer('invalid-version'), + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer( + 'invalid-version', + ), + ).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer(''), ).to.equal(false); - expect(isVersionSearchCompatibleForViewsDataExplorer('')).to.equal(false); }); }); describe('isVersionSearchCompatibleForViewsCompass', function () { it('should return true for a version greater than or equal to 8.1.0', function () { - expect(isVersionSearchCompatibleForViewsCompass('8.1.0')).to.equal(true); - expect(isVersionSearchCompatibleForViewsCompass('8.1.1')).to.equal(true); - expect(isVersionSearchCompatibleForViewsCompass('8.2.0')).to.equal(true); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('8.1.0'), + ).to.equal(true); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('8.1.1'), + ).to.equal(true); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('8.2.0'), + ).to.equal(true); }); it('should return false for a version less than 8.1.0', function () { - expect(isVersionSearchCompatibleForViewsCompass('8.0.9')).to.equal(false); - expect(isVersionSearchCompatibleForViewsCompass('8.0.0')).to.equal(false); - expect(isVersionSearchCompatibleForViewsCompass('7.9.9')).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('8.0.9'), + ).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('8.0.0'), + ).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass('7.9.9'), + ).to.equal(false); }); it('should handle invalid version format by returning false', function () { expect( - isVersionSearchCompatibleForViewsCompass('invalid-version'), + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass( + 'invalid-version', + ), + ).to.equal(false); + expect( + VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass(''), ).to.equal(false); - expect(isVersionSearchCompatibleForViewsCompass('')).to.equal(false); }); }); }); From e2e36f9be2c702190562b386703daf5882604b7e Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Wed, 20 Aug 2025 18:13:31 -0700 Subject: [PATCH 12/13] change to peerDep and devDep --- package-lock.json | 7 +++++-- packages/mongodb-constants/package.json | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d1fa9575..d83cdb78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30587,7 +30587,6 @@ "version": "0.12.2", "license": "Apache-2.0", "dependencies": { - "mongodb": "^6.18.0", "semver": "^7.7.1" }, "devDependencies": { @@ -30605,10 +30604,14 @@ "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", + "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "sinon": "^9.2.3", "typescript": "^5.0.4" + }, + "peerDependencies": { + "mongodb": "^6.9.0" } }, "packages/mongodb-constants/node_modules/acorn": { @@ -38770,7 +38773,7 @@ "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", - "mongodb": "^6.18.0", + "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "semver": "^7.7.1", diff --git a/packages/mongodb-constants/package.json b/packages/mongodb-constants/package.json index e5c5c4f0..a4181f07 100644 --- a/packages/mongodb-constants/package.json +++ b/packages/mongodb-constants/package.json @@ -51,6 +51,9 @@ "test-ci": "npm run test-cov", "reformat": "npm run prettier -- --write ." }, + "peerDependencies": { + "mongodb": "^6.9.0" + }, "devDependencies": { "@mongodb-js/eslint-config-devtools": "0.9.11", "@mongodb-js/mocha-config-devtools": "^1.0.5", @@ -66,13 +69,13 @@ "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", + "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "sinon": "^9.2.3", "typescript": "^5.0.4" }, "dependencies": { - "mongodb": "^6.18.0", "semver": "^7.7.1" } } From 68211bbc2205e4f2cbffe0299d63c346876cd0fd Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Thu, 21 Aug 2025 08:52:56 -0700 Subject: [PATCH 13/13] replace with bson import --- package-lock.json | 34 ++++++++++---------- packages/mongodb-constants/package.json | 4 +-- packages/mongodb-constants/src/views.spec.ts | 2 +- packages/mongodb-constants/src/views.ts | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index d83cdb78..ad1f557d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12168,9 +12168,9 @@ } }, "node_modules/bson": { - "version": "6.10.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", - "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", + "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==", "license": "Apache-2.0", "engines": { "node": ">=16.20.1" @@ -22416,13 +22416,13 @@ } }, "node_modules/mongodb": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.18.0.tgz", - "integrity": "sha512-fO5ttN9VC8P0F5fqtQmclAkgXZxbIkYRTUi1j8JO6IYwvamkhtYDilJr35jOPELR49zqCJgXZWwCtW7B+TM8vQ==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.16.0.tgz", + "integrity": "sha512-D1PNcdT0y4Grhou5Zi/qgipZOYeWrhLEpk33n3nm6LGtz61jvO88WlrWCK/bigMjpnOdAUKKQwsGIl0NtWMyYw==", "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.1.9", - "bson": "^6.10.4", + "bson": "^6.10.3", "mongodb-connection-string-url": "^3.0.0" }, "engines": { @@ -30599,19 +30599,19 @@ "@types/semver": "^7.7.0", "@types/sinon-chai": "^3.2.5", "acorn": "^8.14.1", + "bson": "^6.10.3", "chai": "^4.5.0", "depcheck": "^1.4.7", "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", - "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "sinon": "^9.2.3", "typescript": "^5.0.4" }, "peerDependencies": { - "mongodb": "^6.9.0" + "bson": "^6.10.3" } }, "packages/mongodb-constants/node_modules/acorn": { @@ -38768,12 +38768,12 @@ "@types/semver": "^7.7.0", "@types/sinon-chai": "^3.2.5", "acorn": "^8.14.1", + "bson": "^6.10.3", "chai": "^4.5.0", "depcheck": "^1.4.7", "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", - "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "semver": "^7.7.1", @@ -42994,9 +42994,9 @@ } }, "bson": { - "version": "6.10.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", - "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==" + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", + "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==" }, "buffer": { "version": "5.7.1", @@ -50538,12 +50538,12 @@ "dev": true }, "mongodb": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.18.0.tgz", - "integrity": "sha512-fO5ttN9VC8P0F5fqtQmclAkgXZxbIkYRTUi1j8JO6IYwvamkhtYDilJr35jOPELR49zqCJgXZWwCtW7B+TM8vQ==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.16.0.tgz", + "integrity": "sha512-D1PNcdT0y4Grhou5Zi/qgipZOYeWrhLEpk33n3nm6LGtz61jvO88WlrWCK/bigMjpnOdAUKKQwsGIl0NtWMyYw==", "requires": { "@mongodb-js/saslprep": "^1.1.9", - "bson": "^6.10.4", + "bson": "^6.10.3", "mongodb-connection-string-url": "^3.0.0" } }, diff --git a/packages/mongodb-constants/package.json b/packages/mongodb-constants/package.json index a4181f07..056e8478 100644 --- a/packages/mongodb-constants/package.json +++ b/packages/mongodb-constants/package.json @@ -52,7 +52,7 @@ "reformat": "npm run prettier -- --write ." }, "peerDependencies": { - "mongodb": "^6.9.0" + "bson": "^6.10.3" }, "devDependencies": { "@mongodb-js/eslint-config-devtools": "0.9.11", @@ -63,13 +63,13 @@ "@types/mocha": "^9.1.1", "@types/semver": "^7.7.0", "@types/sinon-chai": "^3.2.5", + "bson": "^6.10.3", "acorn": "^8.14.1", "chai": "^4.5.0", "depcheck": "^1.4.7", "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.3", "mocha": "^8.4.0", - "mongodb": "^6.9.0", "nyc": "^15.1.0", "prettier": "^3.5.3", "sinon": "^9.2.3", diff --git a/packages/mongodb-constants/src/views.spec.ts b/packages/mongodb-constants/src/views.spec.ts index 6a83c53f..b56770e5 100644 --- a/packages/mongodb-constants/src/views.spec.ts +++ b/packages/mongodb-constants/src/views.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { VIEW_PIPELINE_UTILS } from './views'; -import type { Document } from 'mongodb'; +import type { Document } from 'bson'; describe('views', function () { describe('isPipelineSearchQueryable', function () { diff --git a/packages/mongodb-constants/src/views.ts b/packages/mongodb-constants/src/views.ts index 2054bde2..8f49707e 100644 --- a/packages/mongodb-constants/src/views.ts +++ b/packages/mongodb-constants/src/views.ts @@ -1,6 +1,6 @@ /** utils related to view pipeline **/ -import type { Document } from 'mongodb'; +import type { Document } from 'bson'; import semver from 'semver'; const MIN_VERSION_FOR_VIEW_SEARCH_COMPATIBILITY_DE = '8.0.0';