diff --git a/README.md b/README.md index 7ec0b5fc646..492b5370472 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,6 @@ The following table describes add-on component version compatibility for the Nod | [bson-ext](https://www.npmjs.com/package/bson-ext) | ^1.0.0 \|\| ^2.0.0 | ^4.0.0 | N/A | N/A | N/A | | [kerberos](https://www.npmjs.com/package/kerberos) | ^1.0.0 | ^1.0.0 \|\| ^2.0.0 | ^1.0.0 \|\| ^2.0.0 | ^2.0.1 | ^2.0.1 | | [mongodb-client-encryption](https://www.npmjs.com/package/mongodb-client-encryption) | ^1.0.0 | ^1.0.0 \|\| ^2.0.0 | ^2.3.0 | ^6.0.0 | ^6.0.0 | -| [mongodb-legacy](https://www.npmjs.com/package/mongodb-legacy) | N/A | ^4.0.0 | ^5.0.0 | ^6.0.0 | ^6.0.0 | | [@mongodb-js/zstd](https://www.npmjs.com/package/@mongodb-js/zstd) | N/A | ^1.0.0 | ^1.0.0 | ^1.1.0 | ^1.1.0 \|\| ^2.0.0 | diff --git a/etc/docs/build.ts b/etc/docs/build.ts index cf2c61a4ed2..89ff67271cb 100755 --- a/etc/docs/build.ts +++ b/etc/docs/build.ts @@ -24,7 +24,6 @@ const RELEASES_JSON_FILE = './template/static/versions.json'; const copyGeneratedDocsToDocsFolder = () => exec(`cp -R temp/. ../../docs/.`); const removeTempDirectory = () => exec('rm -rf temp'); -const installDependencies = () => exec('npm i --no-save --legacy-peer-deps typedoc@0.26.7'); const buildDocs = ({ tag }: VersionSchema) => { const revision = tag === LATEST_TAG ? 'main' : `v${tag}.0`; return exec(`npm run build:typedoc -- --gitRevision ${revision}`); diff --git a/etc/notes/releasing.md b/etc/notes/releasing.md index e1012316236..ebc09d79010 100644 --- a/etc/notes/releasing.md +++ b/etc/notes/releasing.md @@ -162,6 +162,5 @@ The following is a list of packages the Node.js team is responsible for and thes - https://github.com/mongodb-js/mongodb-client-encryption - https://github.com/mongodb-js/kerberos - https://github.com/mongodb-js/zstd -- https://github.com/mongodb-js/nodejs-mongodb-legacy - https://github.com/mongodb-js/mongodb-connection-string-url - https://github.com/mongodb-js/dbx-js-tools (Node.js team developer tools, not a product) diff --git a/package-lock.json b/package-lock.json index 2bd38207c2f..4381a2ddea1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,7 +49,6 @@ "mocha": "^11.7.1", "mocha-sinon": "^2.1.2", "mongodb-client-encryption": "^7.0.0-alpha.1", - "mongodb-legacy": "^6.1.3", "nyc": "^15.1.0", "prettier": "^3.6.2", "semver": "^7.7.2", @@ -7154,202 +7153,6 @@ "@types/webidl-conversions": "*" } }, - "node_modules/mongodb-legacy": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/mongodb-legacy/-/mongodb-legacy-6.1.3.tgz", - "integrity": "sha512-XJ2PIbVEHUUF4/SyH00dfeprfeLOdWiHcKq8At+JoEZeTue+IAG39G2ixRwClnI7roPb/46K8IF713v9dgQ8rg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "mongodb": "^6.0.0" - }, - "engines": { - "node": ">=16.20.1" - } - }, - "node_modules/mongodb-legacy/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/mongodb-legacy/node_modules/gaxios": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-5.1.3.tgz", - "integrity": "sha512-95hVgBRgEIRQQQHIbnxBXeHbW4TqFk4ZDJW7wmVtvYar72FdhRIo1UGOLS2eRAKCPEdPBWu+M7+A33D9CdX9rA==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "extend": "^3.0.2", - "https-proxy-agent": "^5.0.0", - "is-stream": "^2.0.0", - "node-fetch": "^2.6.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/mongodb-legacy/node_modules/gcp-metadata": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", - "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "gaxios": "^5.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/mongodb-legacy/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/mongodb-legacy/node_modules/mongodb": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.20.0.tgz", - "integrity": "sha512-Tl6MEIU3K4Rq3TSHd+sZQqRBoGlFsOgNrH5ltAcFBV62Re3Fd+FcaVf8uSEQFOJ51SDowDVttBTONMfoYWrWlQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@mongodb-js/saslprep": "^1.3.0", - "bson": "^6.10.4", - "mongodb-connection-string-url": "^3.0.2" - }, - "engines": { - "node": ">=16.20.1" - }, - "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.3.2", - "socks": "^2.7.1" - }, - "peerDependenciesMeta": { - "@aws-sdk/credential-providers": { - "optional": true - }, - "@mongodb-js/zstd": { - "optional": true - }, - "gcp-metadata": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "snappy": { - "optional": true - }, - "socks": { - "optional": true - } - } - }, - "node_modules/mongodb-legacy/node_modules/mongodb-client-encryption": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/mongodb-client-encryption/-/mongodb-client-encryption-6.5.0.tgz", - "integrity": "sha512-Gj8EeyYKsssdko0NKhWRBGDif6uVFBbv+e+Nyn7E316UmRzApc4IP+p2NLm+av+fU+dFHVT5WqfzaQVDTh8i9w==", - "dev": true, - "hasInstallScript": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "node-addon-api": "^4.3.0", - "prebuild-install": "^7.1.3" - }, - "engines": { - "node": ">=16.20.1" - } - }, - "node_modules/mongodb-legacy/node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/mongodb-legacy/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, - "node_modules/mongodb-legacy/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "peer": true - }, - "node_modules/mongodb-legacy/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", diff --git a/package.json b/package.json index 23fd21a4d65..0d65976c526 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,6 @@ "mocha": "^11.7.1", "mocha-sinon": "^2.1.2", "mongodb-client-encryption": "^7.0.0-alpha.1", - "mongodb-legacy": "^6.1.3", "nyc": "^15.1.0", "prettier": "^3.6.2", "semver": "^7.7.2", diff --git a/test/mongodb.ts b/test/mongodb.ts index 0c1783dfcec..b289249eb65 100644 --- a/test/mongodb.ts +++ b/test/mongodb.ts @@ -1,7 +1,5 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; -import * as process from 'node:process'; -import * as vm from 'node:vm'; // eslint-disable-next-line @typescript-eslint/no-unused-vars function printExports() { @@ -24,78 +22,6 @@ function printExports() { } } -/** - * Using node's require resolution logic this function will locate the entrypoint for the `'mongodb-legacy'` module, - * then execute the `mongodb-legacy` module in a `vm` context that replaces the global require function with a custom - * implementation. The custom version of `require` will return the local instance of the driver import (magically compiled by ts-node) when - * the module specifier is 'mongodb' and otherwise defer to the normal require behavior to import relative files and stdlib modules. - * Each of the legacy module's patched classes are placed on the input object. - * - * @param exportsToOverride - An object that is an import of the MongoDB driver to be modified by this function - */ -function importMongoDBLegacy(exportsToOverride: Record) { - const mongodbLegacyEntryPoint = require.resolve('mongodb-legacy'); - const mongodbLegacyLocation = path.dirname(mongodbLegacyEntryPoint); - const mongodbLegacyIndex = fs.readFileSync(mongodbLegacyEntryPoint, { - encoding: 'utf8' - }); - - // eslint-disable-next-line @typescript-eslint/no-require-imports - const localMongoDB = require('../src/index'); - const ctx = vm.createContext({ - module: { exports: null }, - require: (mod: string) => { - if (mod === 'mongodb') { - return localMongoDB; - } else if (mod.startsWith('.')) { - // eslint-disable-next-line @typescript-eslint/no-require-imports - return require(path.join(mongodbLegacyLocation, mod)); - } - // eslint-disable-next-line @typescript-eslint/no-require-imports - return require(mod); - } - }); - vm.runInContext(mongodbLegacyIndex, ctx); - - const mongodbLegacy = ctx.module.exports; - - Object.defineProperty(exportsToOverride, 'Admin', { get: () => mongodbLegacy.Admin }); - Object.defineProperty(exportsToOverride, 'FindCursor', { get: () => mongodbLegacy.FindCursor }); - Object.defineProperty(exportsToOverride, 'ListCollectionsCursor', { - get: () => mongodbLegacy.ListCollectionsCursor - }); - Object.defineProperty(exportsToOverride, 'ListIndexesCursor', { - get: () => mongodbLegacy.ListIndexesCursor - }); - Object.defineProperty(exportsToOverride, 'AggregationCursor', { - get: () => mongodbLegacy.AggregationCursor - }); - Object.defineProperty(exportsToOverride, 'ChangeStream', { - get: () => mongodbLegacy.ChangeStream - }); - Object.defineProperty(exportsToOverride, 'Collection', { get: () => mongodbLegacy.Collection }); - Object.defineProperty(exportsToOverride, 'Db', { get: () => mongodbLegacy.Db }); - Object.defineProperty(exportsToOverride, 'GridFSBucket', { - get: () => mongodbLegacy.GridFSBucket - }); - Object.defineProperty(exportsToOverride, 'ClientSession', { - get: () => mongodbLegacy.ClientSession - }); - Object.defineProperty(exportsToOverride, 'MongoClient', { get: () => mongodbLegacy.MongoClient }); - Object.defineProperty(exportsToOverride, 'ClientSession', { - get: () => mongodbLegacy.ClientSession - }); - Object.defineProperty(exportsToOverride, 'GridFSBucketWriteStream', { - get: () => mongodbLegacy.GridFSBucketWriteStream - }); - Object.defineProperty(exportsToOverride, 'OrderedBulkOperation', { - get: () => mongodbLegacy.OrderedBulkOperation - }); - Object.defineProperty(exportsToOverride, 'UnorderedBulkOperation', { - get: () => mongodbLegacy.UnorderedBulkOperation - }); -} - export * from '../src/admin'; export * from '../src/bson'; export * from '../src/bulk/common'; @@ -212,16 +138,3 @@ export * from '../src/write_concern'; // Must be last for precedence export * from '../src/index'; - -/** - * TODO(NODE-4979): ENABLE_MONGODB_LEGACY is 'true' by default for now - */ -const ENABLE_MONGODB_LEGACY = - typeof process.env.ENABLE_MONGODB_LEGACY === 'string' && process.env.ENABLE_MONGODB_LEGACY !== '' - ? process.env.ENABLE_MONGODB_LEGACY - : 'true'; - -if (ENABLE_MONGODB_LEGACY === 'true') { - // Override our own exports with the legacy patched ones - importMongoDBLegacy(module.exports); -} diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts index 69314408a3f..91780cd8008 100644 --- a/test/tools/runner/config.ts +++ b/test/tools/runner/config.ts @@ -4,10 +4,10 @@ import * as types from 'node:util/types'; import { expect } from 'chai'; import { type Context } from 'mocha'; import ConnectionString from 'mongodb-connection-string-url'; -import { type CompressorName } from 'mongodb-legacy'; import * as qs from 'querystring'; import * as url from 'url'; +import type { CompressorName } from '../../../src/cmap/wire_protocol/compression'; import { type AuthMechanism, Double,