From ee1a4d32ac95b7d143b08896bc486cfa8c2895a1 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 19 Feb 2021 17:19:46 -0500 Subject: [PATCH] refactor!: remove deprecated items (#2740) Removals are noted in JIRA ticket. NODE-2317 --- .eslintrc.json | 4 +- package-lock.json | 991 ++++++++++-------- package.json | 19 +- src/cmap/auth/scram.ts | 4 +- src/cmap/commands.ts | 8 +- src/cmap/connection_pool.ts | 30 +- src/cmap/events.ts | 46 +- src/collection.ts | 226 +--- src/connection_string.ts | 11 +- src/db.ts | 117 +-- src/index.ts | 35 +- src/logger.ts | 1 + src/mongo_client.ts | 23 - src/operations/add_user.ts | 54 +- src/operations/connect.ts | 63 +- src/sdam/events.ts | 8 + src/sdam/monitor.ts | 2 - src/sdam/server.ts | 5 +- src/sdam/topology.ts | 24 +- src/sdam/topology_description.ts | 8 +- src/sessions.ts | 9 +- src/utils.ts | 41 +- test/.eslintrc.json | 5 +- test/functional/aggregation.test.js | 20 +- test/functional/bulk.test.js | 16 +- test/functional/collations.test.js | 41 - test/functional/collection.test.js | 44 +- test/functional/command_write_concern.test.js | 13 - test/functional/connection.test.js | 38 +- test/functional/core/topology.test.js | 2 +- test/functional/core/undefined.test.js | 4 +- test/functional/cursor.test.js | 8 +- test/functional/explain.test.js | 6 +- test/functional/find.test.js | 223 ++-- test/functional/index.test.js | 44 +- test/functional/insert.test.js | 5 +- test/functional/multiple_db.test.js | 4 +- test/functional/operation_example.test.js | 278 +---- .../operation_generators_example.test.js | 210 +--- .../operation_promises_example.test.js | 146 +-- test/functional/promises_db.test.js | 2 +- test/functional/shared.test.js | 12 - test/functional/spec-runner/index.js | 1 - .../unified-spec-runner/.eslintrc.json | 1 - test/unit/bypass_validation.test.js | 28 +- test/unit/core/scram_iterations.test.js | 6 +- 46 files changed, 1036 insertions(+), 1850 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 90b4d1186e..5bd15af3ce 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,7 +7,6 @@ "plugins": [ "@typescript-eslint", "prettier", - "promise", "eslint-plugin-tsdoc" ], "extends": [ @@ -27,10 +26,9 @@ "tsdoc/syntax": "warn", - "no-console": "off", + "no-console": "error", "eqeqeq": ["error", "always", { "null": "ignore" }], "strict": ["error", "global"], - "promise/no-native": "error", "@typescript-eslint/no-explicit-any": "off", diff --git a/package-lock.json b/package-lock.json index cfef98ead5..2e91967c52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -251,6 +251,24 @@ "to-fast-properties": "^2.0.0" } }, + "@eslint/eslintrc": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.3.0.tgz", + "integrity": "sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "lodash": "^4.17.20", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + } + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -325,14 +343,14 @@ "dev": true }, "@microsoft/api-extractor": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.12.1.tgz", - "integrity": "sha512-lleLrKkqiRvOQeoRMSHQY0wl/j9SxRVd9+Btyh/WWw0kHNy7nAKyzGmejvlz2XTn13H0elJWV6C3dxhaQy4mtA==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.13.1.tgz", + "integrity": "sha512-mnWb5Vuyn/JnjC359HfsRmLDM4/vzyKcJuxQr5Cg/apbkMHuTB1hQrqA8zBda4N+MJZ5ET2BPsrKaUX1qhz8jw==", "dev": true, "requires": { - "@microsoft/api-extractor-model": "7.12.1", + "@microsoft/api-extractor-model": "7.12.2", "@microsoft/tsdoc": "0.12.24", - "@rushstack/node-core-library": "3.35.2", + "@rushstack/node-core-library": "3.36.0", "@rushstack/rig-package": "0.2.9", "@rushstack/ts-command-line": "4.7.8", "colors": "~1.2.1", @@ -340,7 +358,7 @@ "resolve": "~1.17.0", "semver": "~7.3.0", "source-map": "~0.6.1", - "typescript": "~4.0.5" + "typescript": "~4.1.3" }, "dependencies": { "semver": { @@ -355,13 +373,13 @@ } }, "@microsoft/api-extractor-model": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.12.1.tgz", - "integrity": "sha512-Hw+kYfUb1gt6xPWGFW8APtLVWeNEWz4JE6PbLkSHw/j+G1hAaStzgxhBx3GOAWM/G0SCDGVJOpd5YheVOyu/KQ==", + "version": "7.12.2", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.12.2.tgz", + "integrity": "sha512-EU+U09Mj65zUH0qwPF4PFJiL6Y+PQQE/RRGEHEDGJJzab/mRQDpKOyrzSdb00xvcd/URehIHJqC55cY2Y4jGOA==", "dev": true, "requires": { "@microsoft/tsdoc": "0.12.24", - "@rushstack/node-core-library": "3.35.2" + "@rushstack/node-core-library": "3.36.0" } }, "@microsoft/tsdoc": { @@ -371,17 +389,23 @@ "dev": true }, "@microsoft/tsdoc-config": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.13.9.tgz", - "integrity": "sha512-VqqZn+rT9f6XujFPFR2aN9XKF/fuir/IzKVzoxI0vXIzxysp4ee6S2jCakmlGFHEasibifFTsJr7IYmRPxfzYw==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.14.0.tgz", + "integrity": "sha512-KSj15FwyaxMCGJkC320rvNXxuJNCOVO02pNqIEdf5cbLakvHK8afoHTmcjdBEWl0cfBFZlMu/1DhL4VCzZq0rQ==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.12.24", + "@microsoft/tsdoc": "0.13.0", "ajv": "~6.12.6", "jju": "~1.4.0", "resolve": "~1.19.0" }, "dependencies": { + "@microsoft/tsdoc": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.0.tgz", + "integrity": "sha512-/8J+4DdvexBH1Qh1yR8VZ6bPay2DL/TDdmSIypAa3dAghJzsdaiZG8COvzpYIML6HV2UVN0g4qbuqzjG4YKgWg==", + "dev": true + }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -406,10 +430,36 @@ } } }, + "@nodelib/fs.scandir": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", + "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.4", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", + "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", + "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.4", + "fastq": "^1.6.0" + } + }, "@rushstack/node-core-library": { - "version": "3.35.2", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.35.2.tgz", - "integrity": "sha512-SPd0uG7mwsf3E30np9afCUhtaM1SBpibrbxOXPz82KWV6SQiPUtXeQfhXq9mSnGxOb3WLWoSDe7AFxQNex3+kQ==", + "version": "3.36.0", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.36.0.tgz", + "integrity": "sha512-bID2vzXpg8zweXdXgQkKToEdZwVrVCN9vE9viTRk58gqzYaTlz4fMId6V3ZfpXN6H0d319uGi2KDlm+lUEeqCg==", "dev": true, "requires": { "@types/node": "10.17.13", @@ -548,16 +598,10 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, - "@types/eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", - "dev": true - }, "@types/json-schema": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz", - "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==", + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", "dev": true }, "@types/kerberos": { @@ -603,90 +647,116 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz", - "integrity": "sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.1.tgz", + "integrity": "sha512-yW2epMYZSpNJXZy22Biu+fLdTG8Mn6b22kR3TqblVk50HGNV8Zya15WAXuQCr8tKw4Qf1BL4QtI6kv6PCkLoJw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "3.10.1", + "@typescript-eslint/experimental-utils": "4.15.1", + "@typescript-eslint/scope-manager": "4.15.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", + "lodash": "^4.17.15", "regexpp": "^3.0.0", "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, "@typescript-eslint/experimental-utils": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz", - "integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.15.1.tgz", + "integrity": "sha512-9LQRmOzBRI1iOdJorr4jEnQhadxK4c9R2aEAsm7WE/7dq8wkKD1suaV0S/JucTL8QlYUPU1y2yjqg+aGC0IQBQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.10.1", - "@typescript-eslint/typescript-estree": "3.10.1", + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz", - "integrity": "sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.15.1.tgz", + "integrity": "sha512-V8eXYxNJ9QmXi5ETDguB7O9diAXlIyS+e3xzLoP/oVE4WCAjssxLIa0mqCLsCGXulYJUfT+GV70Jv1vHsdKwtA==", "dev": true, "requires": { - "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.10.1", - "@typescript-eslint/types": "3.10.1", - "@typescript-eslint/typescript-estree": "3.10.1", - "eslint-visitor-keys": "^1.1.0" + "@typescript-eslint/scope-manager": "4.15.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/typescript-estree": "4.15.1", + "debug": "^4.1.1" + } + }, + "@typescript-eslint/scope-manager": { + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.15.1.tgz", + "integrity": "sha512-ibQrTFcAm7yG4C1iwpIYK7vDnFg+fKaZVfvyOm3sNsGAerKfwPVFtYft5EbjzByDJ4dj1WD8/34REJfw/9wdVA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1" } }, "@typescript-eslint/types": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz", - "integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.15.1.tgz", + "integrity": "sha512-iGsaUyWFyLz0mHfXhX4zO6P7O3sExQpBJ2dgXB0G5g/8PRVfBBsmQIc3r83ranEQTALLR3Vko/fnCIVqmH+mPw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz", - "integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.1.tgz", + "integrity": "sha512-z8MN3CicTEumrWAEB2e2CcoZa3KP9+SMYLIA2aM49XW3cWIaiVSOAGq30ffR5XHxRirqE90fgLw3e6WmNx5uNw==", "dev": true, "requires": { - "@typescript-eslint/types": "3.10.1", - "@typescript-eslint/visitor-keys": "3.10.1", + "@typescript-eslint/types": "4.15.1", + "@typescript-eslint/visitor-keys": "4.15.1", "debug": "^4.1.1", - "glob": "^7.1.6", + "globby": "^11.0.1", "is-glob": "^4.0.1", - "lodash": "^4.17.15", "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, "@typescript-eslint/visitor-keys": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz", - "integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==", + "version": "4.15.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.1.tgz", + "integrity": "sha512-tYzaTP9plooRJY8eNlpAewTOqtWW/4ff/5wBjNVaJ0S0wC4Gpq/zDVRTJa5bq2v1pCNQ08xxMCndcvR+h7lMww==", "dev": true, "requires": { - "eslint-visitor-keys": "^1.1.0" + "@typescript-eslint/types": "4.15.1", + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", + "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", + "dev": true + } } }, "JSONStream": { @@ -700,15 +770,15 @@ } }, "acorn": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", - "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-jsx": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", - "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, "add-stream": { @@ -745,23 +815,6 @@ "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", "dev": true }, - "ansi-escapes": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", - "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", - "dev": true, - "requires": { - "type-fest": "^0.11.0" - }, - "dependencies": { - "type-fest": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", - "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", - "dev": true - } - } - }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -857,6 +910,12 @@ "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", "dev": true }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -891,9 +950,9 @@ "dev": true }, "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, "asynckit": { @@ -1179,12 +1238,6 @@ } } }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -1234,12 +1287,6 @@ "integrity": "sha512-sJAofoarcm76ZGpuooaO0eDy8saEy+YoZBLjC4h8srt4jeBnkYeOgqxgsJQTpyt2LjI5PTfLJHSL+41Yu4fEJA==", "dev": true }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true - }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -2037,17 +2084,32 @@ "request": "^2.88.2" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } } }, "currently-unhandled": { @@ -2364,6 +2426,23 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + }, + "dependencies": { + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + } + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -2436,6 +2515,23 @@ "tapable": "^1.0.0" } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + }, + "dependencies": { + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + } + } + }, "entities": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", @@ -2531,81 +2627,148 @@ } }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.20.0.tgz", + "integrity": "sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", + "@eslint/eslintrc": "^0.3.0", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.4.0", "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", + "file-entry-cache": "^6.0.0", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", "globals": "^12.1.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", + "levn": "^0.4.1", + "lodash": "^4.17.20", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", - "table": "^5.2.3", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "table": "^6.0.4", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "@babel/highlight": "^7.10.4" } }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, "requires": { - "eslint-visitor-keys": "^1.1.0" + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" } }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "eslint-visitor-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", + "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", "dev": true }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true + }, + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } } } }, @@ -2659,20 +2822,22 @@ "prettier-linter-helpers": "^1.0.0" } }, - "eslint-plugin-promise": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz", - "integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==", - "dev": true - }, "eslint-plugin-tsdoc": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.10.tgz", - "integrity": "sha512-LDK6K0tQ7tIyVzyktwX7P9V/aZZOMSIGYRnDP3x6+obITkVyrCrkc5yUhBiUjTc/S9gEy5GpjwD02wgcMPBFbA==", + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.11.tgz", + "integrity": "sha512-vEjGANpmBfrvpKj9rwePGhA+gIe1mp+dhDZsrkxlHqPVOZvzVdFSV9fxu/o3eppmxhybI8brD88jOrLEAIB9Gw==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.12.24", - "@microsoft/tsdoc-config": "0.13.9" + "@microsoft/tsdoc": "0.13.0", + "@microsoft/tsdoc-config": "0.14.0" + }, + "dependencies": { + "@microsoft/tsdoc": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.0.tgz", + "integrity": "sha512-/8J+4DdvexBH1Qh1yR8VZ6bPay2DL/TDdmSIypAa3dAghJzsdaiZG8COvzpYIML6HV2UVN0g4qbuqzjG4YKgWg==", + "dev": true + } } }, "eslint-scope": { @@ -2701,14 +2866,14 @@ "dev": true }, "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", "dev": true, "requires": { - "acorn": "^7.1.1", - "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "acorn": "^7.4.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^1.3.0" } }, "esprima": { @@ -2718,9 +2883,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -2767,17 +2932,6 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -2796,6 +2950,20 @@ "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", "dev": true }, + "fast-glob": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz", + "integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + } + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2808,6 +2976,15 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fastq": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.1.tgz", + "integrity": "sha512-AWuv6Ery3pM+dY7LYS8YIaCiQvUaos9OB1RyNgaOWnaX+Tik7Onvcsf8x8c+YtDeT0maYLniBip2hox5KtEXXA==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -2818,12 +2995,12 @@ } }, "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz", + "integrity": "sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA==", "dev": true, "requires": { - "flat-cache": "^2.0.1" + "flat-cache": "^3.0.4" } }, "file-exists-dazinatorfork": { @@ -2932,31 +3109,19 @@ } }, "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - }, - "dependencies": { - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } + "flatted": "^3.1.0", + "rimraf": "^3.0.2" } }, "flatted": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", - "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", + "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, "flatten": { @@ -3501,6 +3666,28 @@ "type-fest": "^0.8.1" } }, + "globby": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.2.tgz", + "integrity": "sha512-2ZThXDvvV8fYFRVIxnrMQBipZQDr7MxKAmQK1vujaj9/7eF0efG7BPUKJ7jP7G5SLF37xKDXvO4S/KKLj/Z0og==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true + } + } + }, "gonzales-pe": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.3.0.tgz", @@ -3635,15 +3822,6 @@ "sshpk": "^1.7.0" } }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -3656,9 +3834,9 @@ "dev": true }, "import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -3711,88 +3889,6 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, - "inquirer": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", - "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.19", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.6.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "interpret": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", @@ -4833,6 +4929,22 @@ } } }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, "mime-db": { "version": "1.44.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", @@ -5127,12 +5239,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "nise": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", @@ -5631,12 +5737,6 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -5728,9 +5828,9 @@ "dev": true }, "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true }, "path-parse": { @@ -6059,6 +6159,12 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "queue-microtask": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.2.tgz", + "integrity": "sha512-dB15eXv3p2jDlbOiNLyMabYg1/sXvppd8DP2J3EOCQ0AkuSXCW2tP7mnVouVLJKgUMY6yP0kcQDVpLCN13h4Xg==", + "dev": true + }, "quick-lru": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", @@ -6335,6 +6441,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -6398,6 +6510,12 @@ "signal-exit": "^3.0.2" } }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -6407,19 +6525,13 @@ "glob": "^7.1.3" } }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, - "rxjs": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", - "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "requires": { - "tslib": "^1.9.0" + "queue-microtask": "^1.2.2" } }, "safe-buffer": { @@ -6477,18 +6589,18 @@ "dev": true }, "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "^3.0.0" } }, "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, "shelljs": { @@ -6503,33 +6615,12 @@ } }, "shiki": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.2.7.tgz", - "integrity": "sha512-bwVc7cdtYYHEO9O+XJ8aNOskKRfaQd5Y4ovLRfbQkmiLSUaR+bdlssbZUUhbQ0JAFMYcTcJ5tjG5KtnufttDHQ==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.2.tgz", + "integrity": "sha512-BjUCxVbxMnvjs8jC4b+BQ808vwjJ9Q8NtLqPwXShZ307HdXiDFYP968ORSVfaTNNSWYDBYdMnVKJ0fYNsoZUBA==", "dev": true, "requires": { "onigasm": "^2.2.5", - "shiki-languages": "^0.2.7", - "shiki-themes": "^0.2.7", - "vscode-textmate": "^5.2.0" - } - }, - "shiki-languages": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/shiki-languages/-/shiki-languages-0.2.7.tgz", - "integrity": "sha512-REmakh7pn2jCn9GDMRSK36oDgqhh+rSvJPo77sdWTOmk44C5b0XlYPwJZcFOMJWUZJE0c7FCbKclw4FLwUKLRw==", - "dev": true, - "requires": { - "vscode-textmate": "^5.2.0" - } - }, - "shiki-themes": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/shiki-themes/-/shiki-themes-0.2.7.tgz", - "integrity": "sha512-ZMmboDYw5+SEpugM8KGUq3tkZ0vXg+k60XX6NngDK7gc1Sv6YLUlanpvG3evm57uKJvfXsky/S5MzSOTtYKLjA==", - "dev": true, - "requires": { - "json5": "^2.1.0", "vscode-textmate": "^5.2.0" } }, @@ -6585,21 +6676,45 @@ "integrity": "sha512-IifbusYiQBpUxxFJkR3wTU68xzBN0+bxCScEaKMjBvAQERg6FnTTc1F17rseLb1tjmkJ23730AXpFI0c47FgAg==", "dev": true }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" }, "dependencies": { - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true } } @@ -7064,39 +7179,34 @@ } }, "table": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", - "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz", + "integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==", "dev": true, "requires": { - "ajv": "^6.10.2", - "lodash": "^4.17.14", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" + "ajv": "^7.0.2", + "lodash": "^4.17.20", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.0" }, "dependencies": { - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "ajv": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.0.tgz", + "integrity": "sha512-svS9uILze/cXbH0z2myCK2Brqprx/+JJYK5pHicT/GQiBfzzhUVAIT6MwqJg8y4xV/zoGsUeuPuwtoiKSGE15g==", "dev": true, "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true } } }, @@ -7214,15 +7324,6 @@ "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "dev": true }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, "to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", @@ -7273,12 +7374,13 @@ "dev": true }, "ts-node": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz", - "integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", "dev": true, "requires": { "arg": "^4.1.0", + "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", "source-map-support": "^0.5.17", @@ -7352,22 +7454,22 @@ } }, "typedoc": { - "version": "0.20.14", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.14.tgz", - "integrity": "sha512-9bsZp5/qkl+gDSv9DRvHbfbY8Sr0tD8fKx7hNIvcluxeAFzBCEo9o0qDCdLUZw+/axbfd9TaqHvSuCVRu+YH6Q==", + "version": "0.20.25", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.20.25.tgz", + "integrity": "sha512-ZQZnjJPrt0rjp216gp6FQC1QC4ojcoKikhfOJ/51CqaJunVDilRLlIO5tCGWj1tzlYYT9eOGhJv7MF3t7rxSmw==", "dev": true, "requires": { "colors": "^1.4.0", - "fs-extra": "^9.0.1", + "fs-extra": "^9.1.0", "handlebars": "^4.7.6", "lodash": "^4.17.20", "lunr": "^2.3.9", - "marked": "^1.2.5", + "marked": "^2.0.0", "minimatch": "^3.0.0", "progress": "^2.0.3", "shelljs": "^0.8.4", - "shiki": "^0.2.7", - "typedoc-default-themes": "0.12.1" + "shiki": "^0.9.2", + "typedoc-default-themes": "^0.12.7" }, "dependencies": { "colors": { @@ -7377,15 +7479,15 @@ "dev": true }, "fs-extra": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", - "integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", "dev": true, "requires": { "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", - "universalify": "^1.0.0" + "universalify": "^2.0.0" } }, "jsonfile": { @@ -7396,40 +7498,32 @@ "requires": { "graceful-fs": "^4.1.6", "universalify": "^2.0.0" - }, - "dependencies": { - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - } } }, "marked": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/marked/-/marked-1.2.7.tgz", - "integrity": "sha512-No11hFYcXr/zkBvL6qFmAp1z6BKY3zqLMHny/JN/ey+al7qwCM2+CMBL9BOgqMxZU36fz4cCWfn2poWIf7QRXA==", - "dev": true - }, - "typedoc-default-themes": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.1.tgz", - "integrity": "sha512-6PEvV+/kWAJeUwEtrKgIsZQSbybW5DGCr6s2mMjHsDplpgN8iBHI52UbA+2C+c2TMCxBNMK9TMS6pdeIdwsLSw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-2.0.0.tgz", + "integrity": "sha512-NqRSh2+LlN2NInpqTQnS614Y/3NkVMFFU6sJlRFEpxJ/LHuK/qJECH7/fXZjk4VZstPW/Pevjil/VtSONsLc7Q==", "dev": true }, "universalify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", - "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", "dev": true } } }, + "typedoc-default-themes": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.7.tgz", + "integrity": "sha512-0XAuGEqID+gon1+fhi4LycOEFM+5Mvm2PjwaiVZNAzU7pn3G2DEpsoXnFOPlLDnHY6ZW0BY0nO7ur9fHOFkBLQ==", + "dev": true + }, "typescript": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", - "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.5.tgz", + "integrity": "sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==", "dev": true }, "typescript-cached-transpile": { @@ -7515,9 +7609,9 @@ "dev": true }, "v8-compile-cache": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", - "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", + "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", "dev": true }, "validate-npm-package-license": { @@ -7694,15 +7788,6 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, "write-file-atomic": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", diff --git a/package.json b/package.json index 553ef081e0..5e0d7ab48f 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@microsoft/api-extractor": "^7.12.1", - "@microsoft/tsdoc-config": "^0.13.9", + "@microsoft/api-extractor": "^7.13.1", + "@microsoft/tsdoc-config": "^0.14.0", "@types/aws4": "^1.5.1", "@types/bl": "^2.1.0", "@types/chai": "^4.2.14", @@ -42,19 +42,18 @@ "@types/node": "^14.6.4", "@types/saslprep": "^1.0.0", "@types/semver": "^7.3.4", - "@typescript-eslint/eslint-plugin": "^3.10.0", - "@typescript-eslint/parser": "^3.10.0", + "@typescript-eslint/eslint-plugin": "^4.15.1", + "@typescript-eslint/parser": "^4.15.1", "chai": "^4.2.0", "chai-subset": "^1.6.0", "chalk": "^4.1.0", "co": "4.6.0", "coveralls": "^3.0.11", - "eslint": "^6.8.0", + "eslint": "^7.20.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jsdoc": "^30.7.8", "eslint-plugin-prettier": "^3.1.3", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-tsdoc": "^0.2.10", + "eslint-plugin-tsdoc": "^0.2.11", "js-yaml": "^3.14.0", "jsdoc": "^3.6.4", "lodash.camelcase": "^4.3.0", @@ -72,9 +71,9 @@ "source-map-support": "^0.5.19", "standard-version": "^8.0.2", "through2": "^3.0.1", - "ts-node": "^9.0.0", - "typedoc": "^0.20.14", - "typescript": "^4.0.5", + "ts-node": "^9.1.1", + "typedoc": "^0.20.25", + "typescript": "^4.1.5", "typescript-cached-transpile": "^0.0.6", "worker-farm": "^1.5.0", "wtfnode": "^0.8.2", diff --git a/src/cmap/auth/scram.ts b/src/cmap/auth/scram.ts index d7362d8132..8953a0232b 100644 --- a/src/cmap/auth/scram.ts +++ b/src/cmap/auth/scram.ts @@ -2,7 +2,7 @@ import * as crypto from 'crypto'; import { Binary, Document } from '../../bson'; import { MongoError, AnyError } from '../../error'; import { AuthProvider, AuthContext } from './auth_provider'; -import { Callback, ns } from '../../utils'; +import { Callback, emitWarning, ns } from '../../utils'; import type { MongoCredentials } from './mongo_credentials'; import type { HandshakeDocument } from '../connect'; @@ -25,7 +25,7 @@ class ScramSHA extends AuthProvider { return callback(new MongoError('AuthContext must provide credentials.')); } if (cryptoMethod === 'sha256' && saslprep == null) { - console.warn('Warning: no saslprep library specified. Passwords will not be sanitized'); + emitWarning('Warning: no saslprep library specified. Passwords will not be sanitized'); } crypto.randomBytes(24, (err, nonce) => { diff --git a/src/cmap/commands.ts b/src/cmap/commands.ts index 759ac1b156..eadbf3d1c3 100644 --- a/src/cmap/commands.ts +++ b/src/cmap/commands.ts @@ -5,6 +5,7 @@ import { OP_QUERY, OP_GETMORE, OP_KILL_CURSORS, OP_MSG } from './wire_protocol/c import type { Long, Document, BSONSerializeOptions } from '../bson'; import type { ClientSession } from '../sessions'; import type { CommandOptions } from './connection'; +import { MongoError } from '../error'; // Incrementing request id let _requestId = 0; @@ -825,14 +826,15 @@ export class BinMsg { while (this.index < this.data.length) { const payloadType = this.data.readUInt8(this.index++); - if (payloadType === 1) { - console.error('TYPE 1'); - } else if (payloadType === 0) { + if (payloadType === 0) { const bsonSize = this.data.readUInt32LE(this.index); const bin = this.data.slice(this.index, this.index + bsonSize); this.documents.push(raw ? bin : BSON.deserialize(bin, _options)); this.index += bsonSize; + } else if (payloadType === 1) { + // It was decided that no driver makes use of payload type 1 + throw new MongoError('OP_MSG Payload Type 1 detected unsupported protocol'); } } diff --git a/src/cmap/connection_pool.ts b/src/cmap/connection_pool.ts index a27dce5ca9..879c508e16 100644 --- a/src/cmap/connection_pool.ts +++ b/src/cmap/connection_pool.ts @@ -1,7 +1,7 @@ import Denque = require('denque'); import { EventEmitter } from 'events'; import { Logger } from '../logger'; -import { Connection, ConnectionOptions, CommandOptions } from './connection'; +import { Connection, ConnectionOptions } from './connection'; import { connect } from './connect'; import { eachAsync, relayEvents, makeCounter, Callback } from '../utils'; import { MongoError } from '../error'; @@ -18,7 +18,6 @@ import { ConnectionCheckedInEvent, ConnectionPoolClearedEvent } from './events'; -import type { Document } from '../bson'; const kLogger = Symbol('logger'); const kConnections = Symbol('connections'); @@ -360,33 +359,6 @@ export class ConnectionPool extends EventEmitter { }); }); } - - // NOTE: remove `isConnected` and `write` as part of NODE-2745 - // These functions only exist if makeServerTrampoline is - // called when using the wire protocol methods - - /** - * @internal - * @deprecated Remove sever trampoline code. (NODE-2745) - */ - isConnected(): boolean { - throw new TypeError('This is not a server trampoline instance'); - } - - /** - * @internal - * @deprecated Remove sever trampoline code. (NODE-2745) - */ - write( - message: Document, - commandOptions: CommandOptions, - callback: (err: MongoError, ...args: Document[]) => void - ): void { - message; - commandOptions; - callback; - throw new TypeError('This is not a server trampoline instance'); - } } function ensureMinPoolSize(pool: ConnectionPool) { diff --git a/src/cmap/events.ts b/src/cmap/events.ts index 084e4a91aa..43ea5dc2c2 100644 --- a/src/cmap/events.ts +++ b/src/cmap/events.ts @@ -1,12 +1,13 @@ import { GetMore, KillCursor, Msg, WriteProtocolMessageType } from './commands'; import { calculateDurationInMs, deepCopy } from '../utils'; -import type { ConnectionPool, ConnectionPoolOptions } from './connection_pool'; +import { ConnectionPool, ConnectionPoolOptions } from './connection_pool'; import type { Connection } from './connection'; import type { Document } from '../bson'; import type { AnyError } from '../error'; /** * The base export class for all monitoring events published from the connection pool + * @public * @category Event */ export class ConnectionPoolMonitoringEvent { @@ -23,6 +24,7 @@ export class ConnectionPoolMonitoringEvent { /** * An event published when a connection pool is created + * @public * @category Event */ export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent { @@ -37,6 +39,7 @@ export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection pool is closed + * @public * @category Event */ export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent { @@ -47,6 +50,7 @@ export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection pool creates a new connection + * @public * @category Event */ export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent { @@ -61,6 +65,7 @@ export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection is ready for use + * @public * @category Event */ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent { @@ -75,6 +80,7 @@ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection is closed + * @public * @category Event */ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent { @@ -90,7 +96,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent { } } -/** An event published when a request to check a connection out begins @category Event */ +/** + * An event published when a request to check a connection out begins + * @public + * @category Event + */ export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent { constructor(pool: ConnectionPool) { super(pool); @@ -99,6 +109,7 @@ export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEven /** * An event published when a request to check a connection out fails + * @public * @category Event */ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent { @@ -113,6 +124,7 @@ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent /** * An event published when a connection is checked out of the connection pool + * @public * @category Event */ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent { @@ -127,6 +139,7 @@ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection is checked into the connection pool + * @public * @category Event */ export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent { @@ -141,6 +154,7 @@ export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent { /** * An event published when a connection pool is cleared + * @public * @category Event */ export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent { @@ -150,20 +164,21 @@ export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent { } export const CMAP_EVENT_NAMES = [ - 'connectionPoolCreated', - 'connectionPoolClosed', - 'connectionCreated', - 'connectionReady', - 'connectionClosed', - 'connectionCheckOutStarted', - 'connectionCheckOutFailed', - 'connectionCheckedOut', - 'connectionCheckedIn', - 'connectionPoolCleared' -]; + ConnectionPool.CONNECTION_POOL_CREATED, + ConnectionPool.CONNECTION_POOL_CLOSED, + ConnectionPool.CONNECTION_CREATED, + ConnectionPool.CONNECTION_READY, + ConnectionPool.CONNECTION_CLOSED, + ConnectionPool.CONNECTION_CHECK_OUT_STARTED, + ConnectionPool.CONNECTION_CHECK_OUT_FAILED, + ConnectionPool.CONNECTION_CHECKED_OUT, + ConnectionPool.CONNECTION_CHECKED_IN, + ConnectionPool.CONNECTION_POOL_CLEARED +] as const; /** * An event indicating the start of a given + * @public * @category Event */ export class CommandStartedEvent { @@ -178,6 +193,7 @@ export class CommandStartedEvent { /** * Create a started event * + * @internal * @param pool - the pool that originated the command * @param command - the command */ @@ -203,6 +219,7 @@ export class CommandStartedEvent { /** * An event indicating the success of a given command + * @public * @category Event */ export class CommandSucceededEvent { @@ -216,6 +233,7 @@ export class CommandSucceededEvent { /** * Create a succeeded event * + * @internal * @param pool - the pool that originated the command * @param command - the command * @param reply - the reply for this command from the server @@ -242,6 +260,7 @@ export class CommandSucceededEvent { /** * An event indicating the failure of a given command + * @public * @category Event */ export class CommandFailedEvent { @@ -254,6 +273,7 @@ export class CommandFailedEvent { /** * Create a failure event * + * @internal * @param pool - the pool that originated the command * @param command - the command * @param error - the generated error or a server error response diff --git a/src/collection.ts b/src/collection.ts index 67534ab23b..1db738a803 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -1,10 +1,8 @@ -import { DEFAULT_PK_FACTORY, resolveOptions } from './utils'; +import { DEFAULT_PK_FACTORY, emitWarningOnce, resolveOptions } from './utils'; import { ReadPreference, ReadPreferenceLike } from './read_preference'; -import { deprecate } from 'util'; import { normalizeHintField, checkCollectionName, - deprecateOptions, MongoDBNamespace, Callback, getTopology @@ -25,7 +23,6 @@ import { CreateIndexOperation, DropIndexOperation, DropIndexesOperation, - EnsureIndexOperation, IndexesOperation, IndexExistsOperation, IndexInformationOperation, @@ -45,7 +42,6 @@ import { import type { FindOptions } from './operations/find'; import { FindOneOperation } from './operations/find_one'; import { - FindAndModifyOperation, FindOneAndDeleteOperation, FindOneAndReplaceOperation, FindOneAndUpdateOperation, @@ -86,29 +82,11 @@ import { executeOperation } from './operations/execute_operation'; import type { Db } from './db'; import type { OperationOptions, Hint } from './operations/operation'; import type { IndexInformationOptions } from './operations/common_functions'; -import type { CountOptions } from './operations/count'; import type { BulkWriteResult, BulkWriteOptions, AnyBulkWriteOperation } from './bulk/common'; import type { PkFactory } from './mongo_client'; import type { Logger, LoggerOptions } from './logger'; -import type { Sort } from './sort'; import { FindCursor } from './cursor/find_cursor'; - -/** @public */ -export interface Collection { - /** @deprecated Use {@link Collection#dropIndexes} instead */ - dropAllIndexes(): void; - removeMany( - filter: Document, - options?: DeleteOptions, - callback?: Callback - ): Promise | void; - removeOne( - filter: Document, - options?: DeleteOptions, - callback?: Callback - ): Promise | void; - findAndModify(this: any, query: any, sort: any, doc: any, options: any, callback: Callback): any; -} +import type { CountOptions } from './operations/count'; /** @public */ export interface CollectionOptions @@ -1359,6 +1337,9 @@ export class Collection { options: BulkWriteOptions, callback: Callback ): Promise | void { + emitWarningOnce( + 'collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.' + ); if (typeof options === 'function') (callback = options), (options = {}); options = options || { ordered: false }; docs = !Array.isArray(docs) ? [docs] : docs; @@ -1385,6 +1366,9 @@ export class Collection { options: UpdateOptions, callback: Callback ): Promise | void { + emitWarningOnce( + 'collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.' + ); if (typeof options === 'function') (callback = options), (options = {}); options = options ?? {}; @@ -1404,39 +1388,15 @@ export class Collection { options: DeleteOptions, callback: Callback ): Promise | void { + emitWarningOnce( + 'collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.' + ); if (typeof options === 'function') (callback = options), (options = {}); options = options ?? {}; return this.deleteMany(selector, options, callback); } - /** - * Ensures that an index exists, if it does not it creates it - * - * @deprecated use createIndexes instead - * @param fieldOrSpec - Defines the index. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - ensureIndex( - fieldOrSpec: string | Document, - options: CreateIndexesOptions, - callback: Callback - ): Promise | void { - if (typeof options === 'function') (callback = options), (options = {}); - - return executeOperation( - getTopology(this), - new EnsureIndexOperation( - this.s.db, - this.collectionName, - fieldOrSpec, - resolveOptions(this, options) - ), - callback - ); - } - /** * An estimated count of matching documents in the db to a query. * @@ -1474,168 +1434,4 @@ export class Collection { callback ); } - - /** - * Find and remove a document. - * - * @deprecated use findOneAndDelete instead - * - * @param query - Query object to locate the object to modify. - * @param sort - If multiple docs match, choose the first one in the specified sort order as the object to manipulate. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - findAndRemove(query: Document, callback: Callback): void; - findAndRemove(query: Document): Promise; - findAndRemove(query: Document, sort: Sort, callback: Callback): void; - findAndRemove(query: Document, sort: Sort): Promise; - findAndRemove( - query: Document, - sort: Sort, - options: FindAndModifyOptions, - callback: Callback - ): void; - findAndRemove(query: Document, sort: Sort, options: FindAndModifyOptions): Promise; - findAndRemove( - query: Document, - sortOrOptionsOrCallback?: Sort | FindAndModifyOptions | Callback, - optionsOrCallback?: FindAndModifyOptions | Callback, - _callback?: Callback - ): Promise | void { - let sort = sortOrOptionsOrCallback ?? {}; - let options = optionsOrCallback ?? {}; - let callback = _callback; - if (typeof sort === 'function') { - callback = sort; - sort = {}; - } - if (typeof options === 'function') { - callback = options; - options = {}; - } - - options = resolveOptions(this, options); - // Add the remove option - options.remove = true; - - return executeOperation( - getTopology(this), - new FindAndModifyOperation(this, query, sort as Sort, undefined, options), - callback - ); - } - - /** - * Find and modify a document. - * - * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead - * - * @param query - Query object to locate the object to modify. - * @param sort - If multiple docs match, choose the first one in the specified sort order as the object to manipulate. - * @param doc - The fields/values to be updated. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - _findAndModify(query: Document, sort: Document, doc: Document): Promise; - _findAndModify( - query: Document, - sort: Document, - doc: Document, - callback: Callback - ): void; - _findAndModify( - query: Document, - sort: Document, - doc: Document, - options: FindAndModifyOptions - ): Promise; - _findAndModify( - query: Document, - sort: Document, - doc: Document, - options: FindAndModifyOptions, - callback: Callback - ): Promise | void; - _findAndModify( - query: Document, - sort: Document, - doc: Document, - options?: FindAndModifyOptions | Callback, - callback?: Callback - ): Promise | void { - if (typeof options === 'function') (callback = options), (options = {}); - options = resolveOptions(this, options); - - // Force read preference primary - options.readPreference = ReadPreference.primary; - - return executeOperation( - getTopology(this), - new FindAndModifyOperation(this, query, sort, doc, options), - callback - ); - } } - -const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot', 'oplogReplay']; -Collection.prototype.find = deprecateOptions( - { - name: 'collection.find', - deprecatedOptions: DEPRECATED_FIND_OPTIONS, - optionsIndex: 1 - }, - Collection.prototype.find -); - -Collection.prototype.findOne = deprecateOptions( - { - name: 'collection.find', - deprecatedOptions: DEPRECATED_FIND_OPTIONS, - optionsIndex: 1 - }, - Collection.prototype.findOne -); - -Collection.prototype.insert = deprecate( - Collection.prototype.insert, - 'collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.' -); - -Collection.prototype.update = deprecate( - Collection.prototype.update, - 'collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.' -); - -Collection.prototype.removeOne = Collection.prototype.deleteOne; -Collection.prototype.removeMany = Collection.prototype.deleteMany; - -Collection.prototype.remove = deprecate( - Collection.prototype.remove, - 'collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.' -); - -Collection.prototype.dropAllIndexes = deprecate( - Collection.prototype.dropIndexes, - 'collection.dropAllIndexes is deprecated. Use dropIndexes instead.' -); - -Collection.prototype.ensureIndex = deprecate( - Collection.prototype.ensureIndex, - 'collection.ensureIndex is deprecated. Use createIndexes instead.' -); - -Collection.prototype.count = deprecate( - Collection.prototype.count, - 'collection.count is deprecated, and will be removed in a future version.' + - ' Use Collection.countDocuments or Collection.estimatedDocumentCount instead' -); - -Collection.prototype.findAndModify = deprecate( - Collection.prototype._findAndModify, - 'collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.' -); - -Collection.prototype.findAndRemove = deprecate( - Collection.prototype.findAndRemove, - 'collection.findAndRemove is deprecated. Use findOneAndDelete instead.' -); diff --git a/src/connection_string.ts b/src/connection_string.ts index 99e188b694..cbfdd92c58 100644 --- a/src/connection_string.ts +++ b/src/connection_string.ts @@ -13,7 +13,8 @@ import { isRecord, makeClientMetadata, setDifference, - HostAddress + HostAddress, + emitWarning } from './utils'; import type { Document } from './bson'; import { @@ -445,7 +446,7 @@ function setOption( if (deprecated) { const deprecatedMsg = typeof deprecated === 'string' ? `: ${deprecated}` : ''; - console.warn(`${key} is a deprecated option${deprecatedMsg}`); + emitWarning(`${key} is a deprecated option${deprecatedMsg}`); } switch (type) { @@ -705,7 +706,7 @@ export const OPTIONS = { if (value instanceof Logger) { return value; } - console.warn('Alternative loggers might not be supported'); + emitWarning('Alternative loggers might not be supported'); // TODO: make Logger an interface that others can implement, make usage consistent in driver // DRIVERS-1204 } @@ -967,10 +968,6 @@ export const OPTIONS = { return tlsInsecure; } }, - useRecoveryToken: { - default: true, - type: 'boolean' - }, w: { target: 'writeConcern', transform({ values: [value], options }) { diff --git a/src/db.ts b/src/db.ts index 8c1be9e33f..1403fb07c1 100644 --- a/src/db.ts +++ b/src/db.ts @@ -1,16 +1,14 @@ -import { deprecate } from 'util'; import { Callback, resolveOptions, filterOptions, - deprecateOptions, MongoDBNamespace, getTopology, DEFAULT_PK_FACTORY } from './utils'; import { loadAdmin } from './dynamic_loaders'; import { AggregationCursor } from './cursor/aggregation_cursor'; -import { Code, Document, BSONSerializeOptions, resolveBSONOptions } from './bson'; +import { Document, BSONSerializeOptions, resolveBSONOptions } from './bson'; import { ReadPreference, ReadPreferenceLike } from './read_preference'; import { MongoError } from './error'; import { Collection, CollectionOptions } from './collection'; @@ -27,7 +25,6 @@ import { RunCommandOperation, RunCommandOptions } from './operations/run_command import { CreateCollectionOperation, CreateCollectionOptions } from './operations/create_collection'; import { CreateIndexOperation, - EnsureIndexOperation, IndexInformationOperation, CreateIndexesOptions, IndexSpecification @@ -48,7 +45,6 @@ import { ProfilingLevelId } from './operations/set_profiling_level'; import { executeOperation } from './operations/execute_operation'; -import { EvalOperation, EvalOptions } from './operations/eval'; import type { IndexInformationOptions } from './operations/common_functions'; import type { MongoClient, PkFactory } from './mongo_client'; import type { Admin } from './admin'; @@ -752,119 +748,8 @@ export class Db { get logger(): Logger { return this.s.logger; } - - /** - * Evaluate JavaScript on the server - * - * @deprecated Eval is deprecated on MongoDB 3.2 and forward - * @param code - JavaScript to execute on server. - * @param parameters - The parameters for the call. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - eval(code: Code, parameters: Document | Document[]): Promise; - eval(code: Code, parameters: Document | Document[], callback: Callback): void; - eval(code: Code, parameters: Document | Document[], options: EvalOptions): Promise; - eval( - code: Code, - parameters: Document | Document[], - options: EvalOptions, - callback: Callback - ): Promise; - eval( - code: Code, - parameters: Document | Document[], - options?: EvalOptions | Callback, - callback?: Callback - ): Promise | void { - if (typeof options === 'function') (callback = options), (options = {}); - - return executeOperation( - getTopology(this), - new EvalOperation(this, code, parameters, resolveOptions(this, options)), - callback - ); - } - - /** - * Ensures that an index exists, if it does not it creates it - * - * @deprecated since version 2.0 - * @param name - The index name - * @param fieldOrSpec - Defines the index. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - ensureIndex(name: string, fieldOrSpec: string | Document): Promise; - ensureIndex(name: string, fieldOrSpec: string | Document, callback: Callback): void; - ensureIndex( - name: string, - fieldOrSpec: string | Document, - options: CreateIndexesOptions - ): Promise; - ensureIndex( - name: string, - fieldOrSpec: string | Document, - options: CreateIndexesOptions, - callback: Callback - ): void; - ensureIndex( - name: string, - fieldOrSpec: string | Document, - options?: CreateIndexesOptions | Callback, - callback?: Callback - ): Promise | void { - if (typeof options === 'function') (callback = options), (options = {}); - - return executeOperation( - getTopology(this), - new EnsureIndexOperation(this, name, fieldOrSpec, resolveOptions(this, options)), - callback - ); - } - - /** - * Retrieve the current profiling information for MongoDB - * - * @deprecated Query the `system.profile` collection directly. - * @param options - Optional settings for the command - * @param callback - An optional callback, a Promise will be returned if none is provided - */ - profilingInfo(): Promise; - profilingInfo(callback: Callback): void; - profilingInfo(options: ProfilingLevelOptions): Promise; - profilingInfo(options: ProfilingLevelOptions, callback: Callback): void; - profilingInfo( - options?: ProfilingLevelOptions | Callback, - callback?: Callback - ): Promise | void { - if (typeof options === 'function') (callback = options), (options = {}); - options = options ?? {}; - - const cursor = this.collection('system.profile').find({}, options); - return callback ? cursor.toArray(callback) : cursor.toArray(); - } } -Db.prototype.createCollection = deprecateOptions( - { - name: 'Db.createCollection', - deprecatedOptions: ['autoIndexId'], - optionsIndex: 1 - }, - Db.prototype.createCollection -); - -Db.prototype.eval = deprecate(Db.prototype.eval, 'Db.eval is deprecated as of MongoDB version 3.2'); -Db.prototype.ensureIndex = deprecate( - Db.prototype.ensureIndex, - 'Db.ensureIndex is deprecated as of MongoDB version 3.0 / driver version 2.0' -); -Db.prototype.profilingInfo = deprecate( - Db.prototype.profilingInfo, - 'Db.profilingInfo is deprecated. Query the system.profile collection directly.' -); - // Validate the database name function validateDatabaseName(databaseName: string) { if (typeof databaseName !== 'string') throw new MongoError('database name must be a string'); diff --git a/src/index.ts b/src/index.ts index 6688cca10a..3717087fe8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -86,6 +86,36 @@ export { ExplainVerbosity } from './explain'; export { ReadConcernLevel } from './read_concern'; export { ReadPreferenceMode } from './read_preference'; +// events +export { + CommandStartedEvent, + CommandSucceededEvent, + CommandFailedEvent, + ConnectionCheckOutFailedEvent, + ConnectionCheckOutStartedEvent, + ConnectionCheckedInEvent, + ConnectionCheckedOutEvent, + ConnectionClosedEvent, + ConnectionCreatedEvent, + ConnectionPoolClearedEvent, + ConnectionPoolClosedEvent, + ConnectionPoolCreatedEvent, + ConnectionPoolMonitoringEvent, + ConnectionReadyEvent +} from './cmap/events'; +export { + ServerHeartbeatStartedEvent, + ServerHeartbeatSucceededEvent, + ServerHeartbeatFailedEvent, + ServerClosedEvent, + ServerDescriptionChangedEvent, + ServerOpeningEvent, + TopologyClosedEvent, + TopologyDescriptionChangedEvent, + TopologyOpeningEvent +} from './sdam/events'; +export { SrvPollingEvent } from './sdam/srv_polling'; + // type only exports below, these are removed from emitted JS export type { AdminPrivate } from './admin'; export type { Instrumentation } from './apm'; @@ -186,7 +216,7 @@ export type { SupportedTLSSocketOptions, SupportedSocketOptions } from './mongo_client'; -export type { AddUserOptions } from './operations/add_user'; +export type { AddUserOptions, RoleSpecification } from './operations/add_user'; export type { AggregateOptions, AggregateOperation, @@ -251,7 +281,6 @@ export type { HedgeOptions } from './read_preference'; export type { ClusterTime, ServerTypeId, TimerQueue, TopologyTypeId } from './sdam/common'; -export type { TopologyDescriptionChangedEvent } from './sdam/events'; export type { Monitor, MonitorPrivate, @@ -267,7 +296,7 @@ export type { ServerDescriptionOptions } from './sdam/server_description'; export type { ServerSelector } from './sdam/server_selection'; -export type { SrvPoller, SrvPollingEvent, SrvPollerOptions } from './sdam/srv_polling'; +export type { SrvPoller, SrvPollerOptions } from './sdam/srv_polling'; export type { Topology, TopologyPrivate, diff --git a/src/logger.ts b/src/logger.ts index c7c55cfea9..197bef2486 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -10,6 +10,7 @@ let level: LoggerLevelId; const pid = process.pid; // current logger +// eslint-disable-next-line no-console let currentLogger: LoggerFunction = console.warn; /** @public */ diff --git a/src/mongo_client.ts b/src/mongo_client.ts index b5fbefdbdf..671de8d529 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -13,7 +13,6 @@ import { ns, HostAddress } from './utils'; -import { deprecate } from 'util'; import { connect } from './operations/connect'; import { PromiseProvider } from './promise_provider'; import type { Logger, LoggerLevelId } from './logger'; @@ -204,7 +203,6 @@ export interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeC /** Allows a wrapping driver to amend the client metadata generated by the driver to include information about the wrapping driver */ driverInfo?: DriverInfo; - useRecoveryToken?: boolean; // legacy? srvPoller?: SrvPoller; connectionType?: typeof Connection; } @@ -422,12 +420,6 @@ export class MongoClient extends EventEmitter { return db; } - /** Check if MongoClient is connected */ - isConnected(): boolean { - if (!this.topology) return false; - return this.topology.isConnected(); - } - /** * Connect to MongoDB using a url * @@ -560,14 +552,6 @@ export class MongoClient extends EventEmitter { getLogger(): Logger { return this.s.logger; } - - /** - * @deprecated You cannot logout a MongoClient, you can create a new instance. - */ - logout = deprecate((options: any, callback: Callback): void => { - if (typeof options === 'function') (callback = options), (options = {}); - if (typeof callback === 'function') callback(undefined, true); - }, 'Multiple authentication is prohibited on a connected client, please only authenticate once per MongoClient'); } /** @@ -625,9 +609,6 @@ export interface MongoOptions userSpecifiedAuthSource: boolean; userSpecifiedReplicaSet: boolean; - // TODO: remove in v4 - useRecoveryToken: boolean; - /** * # NOTE ABOUT TLS Options * @@ -647,10 +628,6 @@ export interface MongoOptions */ tls: boolean; - /** - * Turn these options into a reusable options dictionary - */ - toJSON(): Record; /** * Turn these options into a reusable connection URI */ diff --git a/src/operations/add_user.ts b/src/operations/add_user.ts index 6adc9b032a..800603d429 100644 --- a/src/operations/add_user.ts +++ b/src/operations/add_user.ts @@ -2,18 +2,29 @@ import * as crypto from 'crypto'; import { Aspect, defineAspects } from './operation'; import { CommandOperation, CommandOperationOptions } from './command'; import { MongoError } from '../error'; -import { Callback, getTopology } from '../utils'; +import { Callback, emitWarningOnce, getTopology } from '../utils'; import type { Document } from '../bson'; import type { Server } from '../sdam/server'; import type { Db } from '../db'; import type { ClientSession } from '../sessions'; +/** @public */ +export interface RoleSpecification { + /** + * A role grants privileges to perform sets of actions on defined resources. + * A given role applies to the database on which it is defined and can grant access down to a collection level of granularity. + */ + role: string; + /** The database this user's role should effect. */ + db: string; +} + /** @public */ export interface AddUserOptions extends CommandOperationOptions { /** @deprecated Please use db.command('createUser', ...) instead for this option */ digestPassword?: null; - /** Roles associated with the created user (only Mongodb 2.6 or higher) */ - roles?: string | string[]; + /** Roles associated with the created user */ + roles?: string | string[] | RoleSpecification | RoleSpecification[]; /** Custom data associated with the user (only Mongodb 2.6 or higher) */ customData?: Document; } @@ -28,12 +39,6 @@ export class AddUserOperation extends CommandOperation { constructor(db: Db, username: string, password: string | undefined, options?: AddUserOptions) { super(db, options); - // Special case where there is no password ($external users) - if (typeof username === 'string' && password != null && typeof password === 'object') { - options = password; - password = undefined; - } - this.db = db; this.username = username; this.password = password; @@ -56,25 +61,18 @@ export class AddUserOperation extends CommandOperation { ); } - // Get additional values - let roles: string[] = []; - if (Array.isArray(options.roles)) roles = options.roles; - if (typeof options.roles === 'string') roles = [options.roles]; - - // If not roles defined print deprecated message - // TODO: handle deprecation properly - if (roles.length === 0) { - console.warn('Creating a user without roles is deprecated in MongoDB >= 2.6'); - } - - // Check the db name and add roles if needed - if ( - (db.databaseName.toLowerCase() === 'admin' || options.dbName === 'admin') && - !Array.isArray(options.roles) - ) { - roles = ['root']; - } else if (!Array.isArray(options.roles)) { - roles = ['dbOwner']; + let roles; + if (!options.roles || (Array.isArray(options.roles) && options.roles.length === 0)) { + emitWarningOnce( + 'Creating a user without roles is deprecated. Defaults to "root" if db is "admin" or "dbOwner" otherwise' + ); + if (db.databaseName.toLowerCase() === 'admin') { + roles = ['root']; + } else { + roles = ['dbOwner']; + } + } else { + roles = Array.isArray(options.roles) ? options.roles : [options.roles]; } const digestPassword = getTopology(db).lastIsMaster().maxWireVersion >= 7; diff --git a/src/operations/connect.ts b/src/operations/connect.ts index f1b10839c0..256054adb4 100644 --- a/src/operations/connect.ts +++ b/src/operations/connect.ts @@ -1,7 +1,7 @@ import { MongoError } from '../error'; import { Topology } from '../sdam/topology'; import { resolveSRVRecord } from '../connection_string'; -import { emitDeprecationWarning, Callback } from '../utils'; +import type { Callback } from '../utils'; import { CMAP_EVENT_NAMES } from '../cmap/events'; import * as BSON from '../bson'; import type { MongoClient, MongoOptions } from '../mongo_client'; @@ -9,18 +9,6 @@ import { Connection } from '../cmap/connection'; import { Server } from '../sdam/server'; import type { AutoEncrypter } from '../deps'; -function addListeners(mongoClient: MongoClient, topology: Topology) { - topology.on('authenticated', createListener(mongoClient, 'authenticated')); - topology.on('error', createListener(mongoClient, 'error')); - topology.on('timeout', createListener(mongoClient, 'timeout')); - topology.on('close', createListener(mongoClient, 'close')); - topology.on('parseError', createListener(mongoClient, 'parseError')); - topology.once('open', createListener(mongoClient, 'open')); - topology.once('fullsetup', createListener(mongoClient, 'fullsetup')); - topology.once('all', createListener(mongoClient, 'all')); - topology.on('reconnect', createListener(mongoClient, 'reconnect')); -} - export function connect( mongoClient: MongoClient, options: MongoOptions, @@ -35,7 +23,6 @@ export function connect( return callback(undefined, mongoClient); } - const didRequestAuthentication = false; const logger = mongoClient.logger; const connectCallback: Callback = err => { const warningMessage = @@ -51,10 +38,6 @@ export function connect( return callback(new MongoError(warningMessage)); } - if (didRequestAuthentication) { - mongoClient.emit('authenticated', null, true); - } - callback(err, mongoClient); }; @@ -85,30 +68,6 @@ function createListener(mongoClient: MongoClient, event: string): Listen }; } -const DEPRECATED_UNIFIED_EVENTS = new Set([ - 'reconnect', - 'reconnectFailed', - 'attemptReconnect', - 'joined', - 'left', - 'ping', - 'ha', - 'all', - 'fullsetup', - 'open' -]); - -function registerDeprecatedEventNotifiers(client: MongoClient) { - client.on('newListener', (eventName: string) => { - if (DEPRECATED_UNIFIED_EVENTS.has(eventName)) { - emitDeprecationWarning( - `The \`${eventName}\` event is no longer supported by the unified topology, ` + - 'please read more by visiting http://bit.ly/2D8WfT6' - ); - } - }); -} - /** * If AutoEncryption is requested, handles the optional dependency logic and passing through options * returns undefined if CSFLE is not enabled. @@ -158,10 +117,11 @@ function createTopology( // save the reference to the topology on the client ASAP if the event handlers need to access it mongoClient.topology = topology; - registerDeprecatedEventNotifiers(mongoClient); - // Add listeners - addListeners(mongoClient, topology); + topology.on('error', createListener(mongoClient, 'error')); + topology.on('timeout', createListener(mongoClient, 'timeout')); + topology.on('close', createListener(mongoClient, 'close')); + topology.once('open', createListener(mongoClient, 'open')); // Propagate the events to the client relayEvents(mongoClient, topology); @@ -217,17 +177,12 @@ function relayEvents(mongoClient: MongoClient, topology: Topology) { Topology.TOPOLOGY_OPENING, Topology.TOPOLOGY_CLOSED, Topology.TOPOLOGY_DESCRIPTION_CHANGED, + ...CMAP_EVENT_NAMES + ]; - // Legacy - 'joined', - 'left', - 'ping', - 'ha' - ].concat(CMAP_EVENT_NAMES); - - serverOrCommandEvents.forEach(event => { + for (const event of serverOrCommandEvents) { topology.on(event, (object1, object2) => { mongoClient.emit(event, object1, object2); }); - }); + } } diff --git a/src/sdam/events.ts b/src/sdam/events.ts index 69475cc33f..ff8c4600a6 100644 --- a/src/sdam/events.ts +++ b/src/sdam/events.ts @@ -4,6 +4,7 @@ import type { Document } from '../bson'; /** * Emitted when server description changes, but does NOT include changes to the RTT. + * @public * @category Event */ export class ServerDescriptionChangedEvent { @@ -32,6 +33,7 @@ export class ServerDescriptionChangedEvent { /** * Emitted when server is initialized. + * @public * @category Event */ export class ServerOpeningEvent { @@ -49,6 +51,7 @@ export class ServerOpeningEvent { /** * Emitted when server is closed. + * @public * @category Event */ export class ServerClosedEvent { @@ -91,6 +94,7 @@ export class TopologyDescriptionChangedEvent { /** * Emitted when topology is initialized. + * @public * @category Event */ export class TopologyOpeningEvent { @@ -105,6 +109,7 @@ export class TopologyOpeningEvent { /** * Emitted when topology is closed. + * @public * @category Event */ export class TopologyClosedEvent { @@ -121,6 +126,7 @@ export class TopologyClosedEvent { * Emitted when the server monitor’s ismaster command is started - immediately before * the ismaster command is serialized into raw BSON and written to the socket. * + * @public * @category Event */ export class ServerHeartbeatStartedEvent { @@ -135,6 +141,7 @@ export class ServerHeartbeatStartedEvent { /** * Emitted when the server monitor’s ismaster succeeds. + * @public * @category Event */ export class ServerHeartbeatSucceededEvent { @@ -155,6 +162,7 @@ export class ServerHeartbeatSucceededEvent { /** * Emitted when the server monitor’s ismaster fails, either with an “ok: 0” or a socket exception. + * @public * @category Event */ export class ServerHeartbeatFailedEvent { diff --git a/src/sdam/monitor.ts b/src/sdam/monitor.ts index 98a7786047..c8147b7aaa 100644 --- a/src/sdam/monitor.ts +++ b/src/sdam/monitor.ts @@ -317,8 +317,6 @@ function monitorServer(monitor: Monitor) { callback(); } - // TODO: the next line is a legacy event, remove in v4 - process.nextTick(() => monitor.emit('monitoring', monitor[kServer])); checkServer(monitor, (err, isMaster) => { if (err) { // otherwise an error occurred on initial discovery, also bail diff --git a/src/sdam/server.ts b/src/sdam/server.ts index d72dc6d619..a9ccfb01fd 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -157,10 +157,7 @@ export class Server extends EventEmitter { relayEvents(this[kMonitor], this, [ Server.SERVER_HEARTBEAT_STARTED, Server.SERVER_HEARTBEAT_SUCCEEDED, - Server.SERVER_HEARTBEAT_FAILED, - - // legacy events - 'monitoring' + Server.SERVER_HEARTBEAT_FAILED ]); this[kMonitor].on('resetConnectionPool', () => { diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index c4d81bd3ba..0ee086c5a6 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -14,7 +14,6 @@ import { SrvPoller, SrvPollingEvent } from './srv_polling'; import { CMAP_EVENT_NAMES } from '../cmap/events'; import { MongoError, MongoServerSelectionError, AnyError } from '../error'; import { readPreferenceServerSelector, ServerSelector } from './server_selection'; -import { deprecate } from 'util'; import { relayEvents, makeStateMachine, @@ -22,7 +21,8 @@ import { ClientMetadata, Callback, HostAddress, - ns + ns, + emitWarning } from '../utils'; import { TopologyType, @@ -65,10 +65,8 @@ const SERVER_RELAY_EVENTS = [ Connection.COMMAND_STARTED, Connection.COMMAND_SUCCEEDED, Connection.COMMAND_FAILED, - - // NOTE: Legacy events - 'monitoring' -].concat(CMAP_EVENT_NAMES); + ...CMAP_EVENT_NAMES +]; // all events we listen to from `Server` instances const LOCAL_SERVER_EVENTS = ['connect', 'descriptionReceived', 'closed', 'ended']; @@ -141,7 +139,6 @@ export interface TopologyOptions extends BSONSerializeOptions, ServerOptions { /** Indicates that a client should directly connect to a node without attempting to discover its topology type */ directConnection: boolean; metadata: ClientMetadata; - useRecoveryToken: boolean; } /** @public */ @@ -218,7 +215,6 @@ export class Topology extends EventEmitter { serverSelectionTimeoutMS: DEFAULT_OPTIONS.get('serverSelectionTimeoutMS'), directConnection: DEFAULT_OPTIONS.get('directConnection'), metadata: DEFAULT_OPTIONS.get('metadata'), - useRecoveryToken: DEFAULT_OPTIONS.get('useRecoveryToken'), monitorCommands: DEFAULT_OPTIONS.get('monitorCommands'), tls: DEFAULT_OPTIONS.get('tls'), maxPoolSize: DEFAULT_OPTIONS.get('maxPoolSize'), @@ -686,10 +682,6 @@ export class Topology extends EventEmitter { if (typeof callback === 'function') callback(undefined, true); } - logout(callback: Callback): void { - if (typeof callback === 'function') callback(undefined, true); - } - get clientMetadata(): ClientMetadata { return this.s.options.metadata; } @@ -703,7 +695,7 @@ export class Topology extends EventEmitter { } unref(): void { - console.log('not implemented: `unref`'); + emitWarning('not implemented: `unref`'); } // NOTE: There are many places in code where we explicitly check the last isMaster @@ -731,12 +723,6 @@ export class Topology extends EventEmitter { set clusterTime(clusterTime: ClusterTime | undefined) { this.s.clusterTime = clusterTime; } - - // legacy aliases - destroy = deprecate( - Topology.prototype.close, - 'destroy() is deprecated, please use close() instead' - ); } /** Destroys a server, and removes all event listeners from the instance */ diff --git a/src/sdam/topology_description.ts b/src/sdam/topology_description.ts index 225d07770b..c99c9f59e2 100644 --- a/src/sdam/topology_description.ts +++ b/src/sdam/topology_description.ts @@ -166,15 +166,9 @@ export class TopologyDescription { */ update(serverDescription: ServerDescription): TopologyDescription { const address = serverDescription.address; - // NOTE: there are a number of prime targets for refactoring here - // once we support destructuring assignments // potentially mutated values - let topologyType = this.type; - let setName = this.setName; - let maxSetVersion = this.maxSetVersion; - let maxElectionId = this.maxElectionId; - let commonWireVersion = this.commonWireVersion; + let { type: topologyType, setName, maxSetVersion, maxElectionId, commonWireVersion } = this; if (serverDescription.setName && setName && serverDescription.setName !== setName) { serverDescription = new ServerDescription(address, undefined); diff --git a/src/sessions.ts b/src/sessions.ts index 799495dc7e..c96210bf0a 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -547,8 +547,8 @@ function endTransaction(session: ClientSession, commandName: string, callback: C callback(e, r); } - if (session.transaction.recoveryToken && supportsRecoveryToken(session)) { - // Assumption here that commandName is "commitTransaction" or "abortTransaction" + // Assumption here that commandName is "commitTransaction" or "abortTransaction" + if (session.transaction.recoveryToken) { command.recoveryToken = session.transaction.recoveryToken; } @@ -588,11 +588,6 @@ function endTransaction(session: ClientSession, commandName: string, callback: C ); } -function supportsRecoveryToken(session: ClientSession) { - const topology = session.topology; - return !!topology.s.options.useRecoveryToken; -} - /** @public */ export type ServerSessionId = { id: Binary }; diff --git a/src/utils.ts b/src/utils.ts index d80f77c9fd..372620bb81 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -231,7 +231,7 @@ export function filterOptions(options: AnyOptions, names: string[]): AnyOptions * @param args - Arguments to apply the provided operation * @param options - Options that modify the behavior of the method */ -export function executeLegacyOperation( +export function executeLegacyOperation( topology: Topology, operation: (...args: any[]) => void | Promise, args: any[], @@ -473,11 +473,6 @@ export function getTopology(provider: MongoClient | Db | Collection): Topology { throw new MongoError('MongoClient must be connected to perform this operation'); } -/** @internal */ -export function emitDeprecationWarning(msg: string): void { - return process.emitWarning(msg, 'DeprecationWarning'); -} - /** * Default message handler for generating deprecation warnings. * @internal @@ -535,7 +530,7 @@ export function deprecateOptions( if (deprecatedOption in options && !optionsWarned.has(deprecatedOption)) { optionsWarned.add(deprecatedOption); const msg = msgHandler(config.name, deprecatedOption); - emitDeprecationWarning(msg); + emitWarning(msg); if (this && 'getLogger' in this) { const logger = this.getLogger(); if (logger) { @@ -1374,3 +1369,35 @@ export const DEFAULT_PK_FACTORY = { return new ObjectId(); } }; + +/** + * When the driver used emitWarning the code will be equal to this. + * @public + * + * @example + * ```js + * process.on('warning', (warning) => { + * if (warning.code === MONGODB_WARNING_CODE) console.error('Ah an important warning! :)') + * }) + * ``` + */ +export const MONGODB_WARNING_CODE = 'MONGODB DRIVER' as const; + +/** @internal */ +export function emitWarning(message: string): void { + return process.emitWarning(message, { code: MONGODB_WARNING_CODE } as any); +} + +const emittedWarnings = new Set(); +/** + * Will emit a warning once for the duration of the application. + * Uses the message to identify if it has already been emitted + * so using string interpolation can cause multiple emits + * @internal + */ +export function emitWarningOnce(message: string): void { + if (!emittedWarnings.has(message)) { + emittedWarnings.add(message); + return emitWarning(message); + } +} diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 2ce7fc2eb9..06d208873c 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -3,7 +3,7 @@ "parserOptions": { "ecmaVersion": 2018 }, - "plugins": ["prettier", "promise", "jsdoc"], + "plugins": ["prettier", "jsdoc"], "extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:jsdoc/recommended"], "env": { "node": true, @@ -34,8 +34,7 @@ "no-console": "off", "eqeqeq": ["error", "always", { "null": "ignore" }], - "strict": ["error", "global"], - "promise/no-native": "off" + "strict": ["error", "global"] }, "settings": { "jsdoc": { diff --git a/test/functional/aggregation.test.js b/test/functional/aggregation.test.js index 299180c3f3..648be6ebe9 100644 --- a/test/functional/aggregation.test.js +++ b/test/functional/aggregation.test.js @@ -53,7 +53,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyExecuteSimpleAggregationPipelineUsingArray'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -172,7 +172,7 @@ describe('Aggregation', function () { 'shouldCorrectlyExecuteSimpleAggregationPipelineUsingArguments' ); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -260,7 +260,7 @@ describe('Aggregation', function () { 'shouldCorrectlyExecuteSimpleAggregationPipelineUsingArguments' ); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -346,7 +346,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyDoAggWithCursorGet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(err).to.not.exist; expect(result).to.exist; @@ -426,7 +426,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyDoAggWithCursorGet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -515,7 +515,7 @@ describe('Aggregation', function () { // Create a collection const collection = db.collection('shouldCorrectlyDoAggWithCursorGet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, (err, result) => { + collection.insertMany(docs, { writeConcern: { w: 1 } }, (err, result) => { expect(result).to.exist; expect(err).to.not.exist; @@ -604,7 +604,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyDoAggWithCursorGet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -689,7 +689,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyDoAggWithCursorGet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -885,7 +885,7 @@ describe('Aggregation', function () { // Create a collection var collection = db.collection('shouldCorrectlyDoAggWithCursorGetStream'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, function (err, result) { + collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) { expect(result).to.exist; expect(err).to.not.exist; @@ -1027,7 +1027,7 @@ describe('Aggregation', function () { // Create a collection const collection = db.collection('shouldCorrectlyDoAggWithCursorMaxTimeMSSet'); // Insert the docs - collection.insert(docs, { writeConcern: { w: 1 } }, (err, result) => { + collection.insertMany(docs, { writeConcern: { w: 1 } }, (err, result) => { expect(result).to.exist; expect(err).to.not.exist; diff --git a/test/functional/bulk.test.js b/test/functional/bulk.test.js index bdef079b9f..a0201543f3 100644 --- a/test/functional/bulk.test.js +++ b/test/functional/bulk.test.js @@ -37,7 +37,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_ordered_ops_10'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; var batch = col.initializeOrderedBulkOp(); @@ -286,7 +286,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_ordered_ops_2'); // Add unique index on field `a` causing all updates to fail - col.ensureIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; var batch = col.initializeOrderedBulkOp(); @@ -433,7 +433,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_ordered_ops_6'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; var batch = col.initializeOrderedBulkOp(); @@ -489,7 +489,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_ordered_ops_7'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; var batch = col.initializeOrderedBulkOp(); @@ -660,7 +660,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_unordered_ops_legacy_1'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ a: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; // Initialize the unordered Batch @@ -724,7 +724,7 @@ describe('Bulk', function () { const col = db.collection('batch_write_unordered_ops_legacy_2'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ a: 1 }, { unique: true, sparse: false }, err => { + col.createIndex({ a: 1 }, { unique: true, sparse: false }, err => { expect(err).to.not.exist; // Initialize the unordered Batch @@ -854,7 +854,7 @@ describe('Bulk', function () { writeConcern.sparse = false; // Add unique index on b field causing all updates to fail - col.ensureIndex({ b: 1 }, writeConcern, function (err) { + col.createIndex({ b: 1 }, writeConcern, function (err) { expect(err).to.not.exist; // Initialize the unordered Batch @@ -960,7 +960,7 @@ describe('Bulk', function () { var col = db.collection('batch_write_unordered_ops_legacy_7'); // Add unique index on b field causing all updates to fail - col.ensureIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { + col.createIndex({ b: 1 }, { unique: true, sparse: false }, function (err) { expect(err).to.not.exist; // Initialize the unordered Batch diff --git a/test/functional/collations.test.js b/test/functional/collations.test.js index 85468f7049..10863ee58d 100644 --- a/test/functional/collations.test.js +++ b/test/functional/collations.test.js @@ -15,47 +15,6 @@ describe('Collation', function () { return mock.createServer().then(mockServer => (testContext.server = mockServer)); }); - it('Successfully pass through collation to findAndModify command', { - metadata: { requires: { generators: true, topology: 'single' } }, - - test: function () { - const configuration = this.configuration; - const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`); - const primary = [Object.assign({}, mock.DEFAULT_ISMASTER)]; - - let commandResult; - testContext.server.setMessageHandler(request => { - var doc = request.document; - if (doc.ismaster) { - request.reply(primary[0]); - } else if (doc.findAndModify) { - commandResult = doc; - request.reply({ ok: 1, result: {} }); - } else if (doc.endSessions) { - request.reply({ ok: 1 }); - } - }); - - return client.connect().then(() => { - const db = client.db(configuration.db); - - return db - .collection('test') - .findAndModify( - { a: 1 }, - [['a', 1]], - { $set: { b1: 1 } }, - { new: true, collation: { caseLevel: true } } - ) - .then(() => { - expect(commandResult).to.have.property('collation'); - expect(commandResult.collation).to.eql({ caseLevel: true }); - return client.close(); - }); - }); - } - }); - it('Successfully pass through collation to count command', { metadata: { requires: { generators: true, topology: 'single' } }, diff --git a/test/functional/collection.test.js b/test/functional/collection.test.js index 42b96b575b..3e3ae0e3a6 100644 --- a/test/functional/collection.test.js +++ b/test/functional/collection.test.js @@ -599,20 +599,10 @@ describe('Collection', function () { }); }); - const collectionTTLtests = [ - { - title: 'should correctly create TTL collection with index using createIndex', - collectionName: 'shouldCorrectlyCreateTTLCollectionWithIndexCreateIndex' - }, - { - title: 'should correctly create TTL collection with index using ensureIndex', - collectionName: 'shouldCorrectlyCreateTTLCollectionWithIndexUsingEnsureIndex' - } - ]; - - collectionTTLtests.forEach(test => { - it(test.title, function (done) { - db.createCollection(test.collectionName, (err, collection) => { + it('should correctly create TTL collection with index using createIndex', function (done) { + db.createCollection( + 'shouldCorrectlyCreateTTLCollectionWithIndexCreateIndex', + (err, collection) => { const errorCallBack = err => { expect(err).to.not.exist; @@ -638,25 +628,13 @@ describe('Collection', function () { } ); }; - if ( - test.title === 'should correctly create TTL collection with index using createIndex' - ) { - collection.createIndex( - { createdAt: 1 }, - { expireAfterSeconds: 1, writeConcern: { w: 1 } }, - errorCallBack - ); - } else if ( - test.title === 'should correctly create TTL collection with index using ensureIndex' - ) { - collection.ensureIndex( - { createdAt: 1 }, - { expireAfterSeconds: 1, writeConcern: { w: 1 } }, - errorCallBack - ); - } - }); - }); + collection.createIndex( + { createdAt: 1 }, + { expireAfterSeconds: 1, writeConcern: { w: 1 } }, + errorCallBack + ); + } + ); }); it('should support createIndex with no options', function (done) { diff --git a/test/functional/command_write_concern.test.js b/test/functional/command_write_concern.test.js index 440b90e703..05f99f9892 100644 --- a/test/functional/command_write_concern.test.js +++ b/test/functional/command_write_concern.test.js @@ -202,17 +202,4 @@ describe('Command Write Concern', function () { db.admin().removeUser('kay:kay', writeConcernTestOptions, done); }) }); - - it('successfully pass through writeConcern to findAndModify command', { - metadata, - test: writeConcernTest('findAndModify', function (db, writeConcernTestOptions, done) { - db.collection('test').findAndModify( - { a: 1 }, - [['a', 1]], - { $set: { b1: 1 } }, - Object.assign({ new: true }, writeConcernTestOptions), - done - ); - }) - }); }); diff --git a/test/functional/connection.test.js b/test/functional/connection.test.js index 19d3544e57..7c755d0344 100644 --- a/test/functional/connection.test.js +++ b/test/functional/connection.test.js @@ -2,6 +2,7 @@ const { withClient, setupDatabase } = require('./shared'); const test = require('./shared').assert; const { expect } = require('chai'); +const { ServerHeartbeatStartedEvent } = require('../../src'); describe('Connection - functional', function () { before(function () { @@ -10,8 +11,7 @@ describe('Connection - functional', function () { it('should correctly start monitoring for single server connection', { metadata: { requires: { topology: 'single', os: '!win32' } }, - - test: function (done) { + test() { var configuration = this.configuration; var client = configuration.newClient( `mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`, @@ -21,13 +21,18 @@ describe('Connection - functional', function () { } ); - client.connect(function (err, client) { - expect(err).to.not.exist; - - client.topology.once('monitoring', function () { - client.close(done); - }); + let isMonitoring = false; + client.once('serverHeartbeatStarted', event => { + // just to be sure we get what we expect, checking the instanceof + isMonitoring = event instanceof ServerHeartbeatStartedEvent; }); + + return client + .connect() + .then(() => { + expect(isMonitoring); + }) + .finally(() => client.close()); } }); @@ -231,22 +236,9 @@ describe('Connection - functional', function () { } }); - it('should correctly return false on `isConnected` before connection happened', { - metadata: { requires: { topology: 'single' } }, - - test: function (done) { - var configuration = this.configuration; - var client = configuration.newClient({ w: 1 }, { maxPoolSize: 1 }); - test.equal(false, client.isConnected()); - done(); - } - }); - it( 'should be able to connect again after close', withClient(function (client, done) { - expect(client.isConnected()).to.be.true; - const collection = client.db('shouldConnectAfterClose').collection('test'); collection.insertOne({ a: 1, b: 2 }, (err, result) => { expect(err).to.not.exist; @@ -254,11 +246,9 @@ describe('Connection - functional', function () { client.close(err => { expect(err).to.not.exist; - expect(client.isConnected()).to.be.false; client.connect(err => { expect(err).to.not.exist; - expect(client.isConnected()).to.be.true; collection.findOne({ a: 1 }, (err, result) => { expect(err).to.not.exist; @@ -277,7 +267,6 @@ describe('Connection - functional', function () { it( 'should correctly fail on retry when client has been closed', withClient(function (client, done) { - expect(client.isConnected()).to.be.true; const collection = client.db('shouldCorrectlyFailOnRetry').collection('test'); collection.insertOne({ a: 1 }, (err, result) => { expect(err).to.not.exist; @@ -285,7 +274,6 @@ describe('Connection - functional', function () { client.close(true, function (err) { expect(err).to.not.exist; - expect(client.isConnected()).to.be.false; expect(() => { collection.insertOne({ a: 2 }); diff --git a/test/functional/core/topology.test.js b/test/functional/core/topology.test.js index aca9f80c9b..5c53ab239c 100644 --- a/test/functional/core/topology.test.js +++ b/test/functional/core/topology.test.js @@ -9,7 +9,7 @@ describe('Topology', function () { topology.on('stateChanged', (_, newState) => states.push(newState)); topology.connect(err => { expect(err).to.not.exist; - topology.destroy(err => { + topology.close(err => { expect(err).to.not.exist; expect(states).to.eql(['connecting', 'connected', 'closing', 'closed']); done(); diff --git a/test/functional/core/undefined.test.js b/test/functional/core/undefined.test.js index 6ba21f2ba4..c2b8ce68d0 100644 --- a/test/functional/core/undefined.test.js +++ b/test/functional/core/undefined.test.js @@ -75,7 +75,7 @@ describe('A server', function () { expect(err).to.not.exist; expect(res).property('insertedCount').to.equal(2); - coll.removeMany({ b: undefined }, { ignoreUndefined: true }, (err, res) => { + coll.deleteMany({ b: undefined }, { ignoreUndefined: true }, (err, res) => { expect(err).to.not.exist; expect(res).property('deletedCount').to.equal(2); done(); @@ -101,7 +101,7 @@ describe('A server', function () { expect(err).to.not.exist; expect(res).property('insertedCount').to.equal(2); - coll.removeMany({ b: null }, (err, res) => { + coll.deleteMany({ b: null }, (err, res) => { expect(err).to.not.exist; expect(res).property('deletedCount').to.equal(1); done(); diff --git a/test/functional/cursor.test.js b/test/functional/cursor.test.js index f33ebd1063..406f557544 100644 --- a/test/functional/cursor.test.js +++ b/test/functional/cursor.test.js @@ -2245,7 +2245,7 @@ describe('Cursor', function () { collection.insert(docs, configuration.writeConcernMax(), err => { expect(err).to.not.exist; - collection.ensureIndex({ _keywords: 1 }, configuration.writeConcernMax(), err => { + collection.createIndex({ _keywords: 1 }, configuration.writeConcernMax(), err => { expect(err).to.not.exist; collection @@ -2633,7 +2633,7 @@ describe('Cursor', function () { col.insert([{ i: 1 }, { i: 2 }], { writeConcern: { w: 1 } }, err => { expect(err).to.not.exist; - col.ensureIndex({ i: 1 }, err => { + col.createIndex({ i: 1 }, err => { expect(err).to.not.exist; col.find({ i: 1 }, { hint: '_id_' }).count((err, count) => { @@ -2647,7 +2647,7 @@ describe('Cursor', function () { col.find({ i: 1 }, { hint: 'BAD HINT' }).count(err => { test.ok(err != null); - col.ensureIndex({ x: 1 }, { sparse: true }, err => { + col.createIndex({ x: 1 }, { sparse: true }, err => { expect(err).to.not.exist; col.find({ i: 1 }, { hint: 'x_1' }).count((err, count) => { @@ -3330,7 +3330,7 @@ describe('Cursor', function () { expect(err).to.not.exist; // ensure index of createdAt index - collection.ensureIndex({ createdAt: 1 }, err => { + collection.createIndex({ createdAt: 1 }, err => { expect(err).to.not.exist; // insert all docs diff --git a/test/functional/explain.test.js b/test/functional/explain.test.js index 8a900f0d66..981fd701ce 100644 --- a/test/functional/explain.test.js +++ b/test/functional/explain.test.js @@ -128,7 +128,7 @@ describe('Explain', function () { expect(err).to.not.exist; expect(res).to.exist; - collection.removeOne({ a: 1 }, { explain: true }, (err, explanation) => { + collection.deleteOne({ a: 1 }, { explain: true }, (err, explanation) => { expect(err).to.not.exist; expect(explanation).to.exist; expect(explanation).property('queryPlanner').to.exist; @@ -152,7 +152,7 @@ describe('Explain', function () { expect(err).to.not.exist; expect(res).to.exist; - collection.removeMany({ a: 1 }, { explain: true }, (err, explanation) => { + collection.deleteMany({ a: 1 }, { explain: true }, (err, explanation) => { expect(err).to.not.exist; expect(explanation).to.exist; expect(explanation).property('queryPlanner').to.exist; @@ -362,7 +362,7 @@ describe('Explain', function () { expect(res).to.exist; // Verify explanation result contains properties of allPlansExecution output - collection.removeOne({ a: 1 }, { explain: 'allPlansExecution' }, (err, explanation) => { + collection.deleteOne({ a: 1 }, { explain: 'allPlansExecution' }, (err, explanation) => { expect(err).to.not.exist; expect(explanation).to.exist; expect(explanation).property('queryPlanner').to.exist; diff --git a/test/functional/find.test.js b/test/functional/find.test.js index b6161a2f7d..8f7e42ef9a 100644 --- a/test/functional/find.test.js +++ b/test/functional/find.test.js @@ -789,9 +789,9 @@ describe('Find', function () { }); /** - * Test findAndModify a document + * Test findOneAndUpdate a document */ - it('shouldCorrectlyFindAndModifyDocument', { + it('shouldCorrectlyfindOneAndUpdateDocument', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -807,11 +807,10 @@ describe('Find', function () { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b: 3 } }, - { new: true }, + { returnOriginal: false }, function (err, updated_doc) { test.equal(1, updated_doc.value.a); test.equal(3, updated_doc.value.b); @@ -821,9 +820,8 @@ describe('Find', function () { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 2 }, - [['a', 1]], { $set: { b: 3 } }, configuration.writeConcernMax(), function (err, result) { @@ -836,9 +834,8 @@ describe('Find', function () { ) { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 3 }, - [], { $set: { b: 3 } }, { remove: true }, function (err, updated_doc) { @@ -846,11 +843,10 @@ describe('Find', function () { test.equal(2, updated_doc.value.b); // Let's upsert! - collection.findAndModify( + collection.findOneAndUpdate( { a: 4 }, - [], { $set: { b: 3 } }, - { new: true, upsert: true }, + { returnOriginal: false, upsert: true }, function (err, updated_doc) { test.equal(4, updated_doc.value.a); test.equal(3, updated_doc.value.b); @@ -862,11 +858,10 @@ describe('Find', function () { function (err, r) { expect(err).to.not.exist; - collection.findAndModify( + collection.findOneAndUpdate( { a: 100 }, - [], { $set: { b: 5 } }, - { new: true, projection: { b: 1 } }, + { returnOriginal: false, projection: { b: 1 } }, function (err, updated_doc) { test.equal(2, Object.keys(updated_doc.value).length); test.equal( @@ -897,9 +892,9 @@ describe('Find', function () { }); /** - * Test findAndModify a document with fields + * Test findOneAndUpdate a document with fields */ - it('shouldCorrectlyFindAndModifyDocumentAndReturnSelectedFieldsOnly', { + it('shouldCorrectlyfindOneAndUpdateDocumentAndReturnSelectedFieldsOnly', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -915,11 +910,10 @@ describe('Find', function () { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b: 3 } }, - { new: true, projection: { a: 1 } }, + { returnOriginal: false, projection: { a: 1 } }, function (err, updated_doc) { test.equal(2, Object.keys(updated_doc.value).length); test.equal(1, updated_doc.value.a); @@ -981,9 +975,9 @@ describe('Find', function () { }); /** - * Test findAndModify a document + * Test findOneAndUpdate a document */ - it('Should Correctly Handle FindAndModify Duplicate Key Error', { + it('Should Correctly Handle findOneAndUpdate Duplicate Key Error', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -994,9 +988,9 @@ describe('Find', function () { client.connect(function (err, client) { expect(err).to.not.exist; var db = client.db(configuration.db); - db.createCollection('FindAndModifyDuplicateKeyError', function (err, collection) { + db.createCollection('findOneAndUpdateDuplicateKeyError', function (err, collection) { expect(err).to.not.exist; - collection.ensureIndex(['name', 1], { unique: true, writeConcern: { w: 1 } }, function ( + collection.createIndex(['name', 1], { unique: true, writeConcern: { w: 1 } }, function ( err ) { expect(err).to.not.exist; @@ -1007,9 +1001,8 @@ describe('Find', function () { function (err) { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { name: 'test1' }, - [], { $set: { name: 'test2' } }, {}, function (err, updated_doc) { @@ -1036,22 +1029,19 @@ describe('Find', function () { var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); client.connect(function (err, client) { var db = client.db(configuration.db); - db.createCollection('AttemptToFindAndModifyNonExistingDocument', function ( + db.createCollection('AttemptTofindOneAndUpdateNonExistingDocument', function ( err, collection ) { // Let's modify the document in place - collection.findAndModify( - { name: 'test1' }, - [], - { $set: { name: 'test2' } }, - {}, - function (err, updated_doc) { - expect(updated_doc.value).to.not.exist; - test.ok(err == null || err.errmsg.match('No matching object found')); - client.close(done); - } - ); + collection.findOneAndUpdate({ name: 'test1' }, { $set: { name: 'test2' } }, {}, function ( + err, + updated_doc + ) { + expect(updated_doc.value).to.not.exist; + test.ok(err == null || err.errmsg.match('No matching object found')); + client.close(done); + }); }); }); } @@ -1142,9 +1132,9 @@ describe('Find', function () { ); /** - * Test findAndModify a document with strict mode enabled + * Test findOneAndUpdate a document with strict mode enabled */ - it('shouldCorrectlyFindAndModifyDocumentWithDBStrict', { + it('shouldCorrectlyfindOneAndUpdateDocumentWithDBStrict', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1158,7 +1148,7 @@ describe('Find', function () { p_client.connect(function (err, client) { var db = client.db(configuration.db); - db.createCollection('shouldCorrectlyFindAndModifyDocumentWithDBStrict', function ( + db.createCollection('shouldCorrectlyfindOneAndUpdateDocumentWithDBStrict', function ( err, collection ) { @@ -1167,11 +1157,10 @@ describe('Find', function () { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 2 }, - [['a', 1]], { $set: { b: 3 } }, - { new: true }, + { returnOriginal: false }, function (err, result) { test.equal(2, result.value.a); test.equal(3, result.value.b); @@ -1185,9 +1174,9 @@ describe('Find', function () { }); /** - * Test findAndModify a document that fails in first step before safe + * Test findOneAndUpdate a document that fails in first step before safe */ - it('shouldCorrectlyFindAndModifyDocumentThatFailsInFirstStep', { + it('shouldCorrectlyfindOneAndUpdateDocumentThatFailsInFirstStep', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1198,44 +1187,43 @@ describe('Find', function () { client.connect(function (err, client) { expect(err).to.not.exist; var db = client.db(configuration.db); - db.createCollection('shouldCorrectlyFindAndModifyDocumentThatFailsInFirstStep', function ( - err, - collection - ) { - expect(err).to.not.exist; - // Set up an index to force duplicate index erro - collection.ensureIndex( - [['failIndex', 1]], - { unique: true, writeConcern: { w: 1 } }, - function (err) { - expect(err).to.not.exist; + db.createCollection( + 'shouldCorrectlyfindOneAndUpdateDocumentThatFailsInFirstStep', + function (err, collection) { + expect(err).to.not.exist; + // Set up an index to force duplicate index erro + collection.createIndex( + [['failIndex', 1]], + { unique: true, writeConcern: { w: 1 } }, + function (err) { + expect(err).to.not.exist; - // Setup a new document - collection.insert( - { a: 2, b: 2, failIndex: 2 }, - configuration.writeConcernMax(), - function (err) { - expect(err).to.not.exist; + // Setup a new document + collection.insert( + { a: 2, b: 2, failIndex: 2 }, + configuration.writeConcernMax(), + function (err) { + expect(err).to.not.exist; - // Let's attempt to upsert with a duplicate key error - collection.findAndModify( - { c: 2 }, - [['a', 1]], - { a: 10, b: 10, failIndex: 2 }, - { writeConcern: { w: 1 }, upsert: true }, - function (err, result) { - expect(result).to.not.exist; - expect(err) - .property('errmsg') - .to.match(/duplicate key/); - client.close(done); - } - ); - } - ); - } - ); - }); + // Let's attempt to upsert with a duplicate key error + collection.findOneAndUpdate( + { c: 2 }, + { $set: { a: 10, b: 10, failIndex: 2 } }, + { writeConcern: { w: 1 }, upsert: true }, + function (err, result) { + expect(result).to.not.exist; + expect(err) + .property('errmsg') + .to.match(/duplicate key/); + client.close(done); + } + ); + } + ); + } + ); + } + ); }); } }); @@ -1261,11 +1249,10 @@ describe('Find', function () { expect(err).to.not.exist; // Find and modify returning the new object - collection.findAndModify( + collection.findOneAndUpdate( { _id: id }, - [], { $set: { 'c.c': 100 } }, - { new: true }, + { returnOriginal: false }, function (err, item) { test.equal(doc._id.toString(), item.value._id.toString()); test.equal(doc.a, item.value.a); @@ -1283,9 +1270,9 @@ describe('Find', function () { }); /** - * Should correctly execute findAndModify that is breaking in prod + * Should correctly execute findOneAndUpdate that is breaking in prod */ - it('shouldCorrectlyExecuteFindAndModify', { + it('shouldCorrectlyExecutefindOneAndUpdate', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1299,11 +1286,10 @@ describe('Find', function () { var self = { _id: new ObjectId() }; var _uuid = 'sddffdss'; - collection.findAndModify( + collection.findOneAndUpdate( { _id: self._id, 'plays.uuid': _uuid }, - [], { $set: { 'plays.$.active': true } }, - { new: true, projection: { plays: 0, results: 0 }, safe: true }, + { returnOriginal: false, projection: { plays: 0, results: 0 }, safe: true }, function (err) { expect(err).to.not.exist; client.close(done); @@ -1435,7 +1421,7 @@ describe('Find', function () { } }); - it('shouldCorrectlyHandlerErrorForFindAndModifyWhenNoRecordExists', { + it('shouldCorrectlyHandlerErrorForfindOneAndUpdateWhenNoRecordExists', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1446,23 +1432,25 @@ describe('Find', function () { client.connect(function (err, client) { var db = client.db(configuration.db); db.createCollection( - 'shouldCorrectlyHandlerErrorForFindAndModifyWhenNoRecordExists', + 'shouldCorrectlyHandlerErrorForfindOneAndUpdateWhenNoRecordExists', function (err, collection) { - collection.findAndModify({ a: 1 }, [], { $set: { b: 3 } }, { new: true }, function ( - err, - updated_doc - ) { - expect(err).to.not.exist; - expect(updated_doc.value).to.not.exist; - client.close(done); - }); + collection.findOneAndUpdate( + { a: 1 }, + { $set: { b: 3 } }, + { returnOriginal: false }, + function (err, updated_doc) { + expect(err).to.not.exist; + expect(updated_doc.value).to.not.exist; + client.close(done); + } + ); } ); }); } }); - it('shouldCorrectlyExecuteFindAndModifyShouldGenerateCorrectBSON', { + it('shouldCorrectlyExecutefindOneAndUpdateShouldGenerateCorrectBSON', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1505,15 +1493,14 @@ describe('Find', function () { function (err, item) { test.ok(item != null); - collection.findAndModify( + collection.findOneAndUpdate( { _id: r.insertedIds[0], 'funds.remaining': { $gte: 3.0 }, 'transactions.id': { $ne: transaction.transactionId } }, - [], { $push: { transactions: transaction } }, - { new: true, safe: true }, + { returnOriginal: false, safe: true }, function (err) { expect(err).to.not.exist; client.close(done); @@ -1585,7 +1572,7 @@ describe('Find', function () { } }); - it('shouldCorrectlyReturnErrorFromMongodbOnFindAndModifyForcedError', { + it('shouldCorrectlyReturnErrorFromMongodbOnfindOneAndUpdateForcedError', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1596,18 +1583,18 @@ describe('Find', function () { client.connect(function (err, client) { var db = client.db(configuration.db); db.createCollection( - 'shouldCorrectlyReturnErrorFromMongodbOnFindAndModifyForcedError', + 'shouldCorrectlyReturnErrorFromMongodbOnfindOneAndUpdateForcedError', function (err, collection) { var q = { x: 1 }; var set = { y: 2, _id: new ObjectId() }; - var opts = { new: true, upsert: true }; + var opts = { returnOriginal: false, upsert: true }; // Original doc var doc = { _id: new ObjectId(), x: 1 }; // Insert original doc collection.insert(doc, configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; - collection.findAndModify(q, [], set, opts, function (/* err */) { + collection.findOneAndUpdate(q, { $set: set }, opts, function (/* err */) { client.close(done); }); }); @@ -1617,7 +1604,7 @@ describe('Find', function () { } }); - it('shouldCorrectlyExecuteFindAndModifyUnderConcurrentLoad', { + it('shouldCorrectlyExecutefindOneAndUpdateUnderConcurrentLoad', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1714,7 +1701,7 @@ describe('Find', function () { } }); - it('shouldCorrectlyErrorOutFindAndModifyOnDuplicateRecord', { + it('shouldCorrectlyErrorOutfindOneAndUpdateOnDuplicateRecord', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1728,7 +1715,7 @@ describe('Find', function () { var db = client.db(configuration.db); expect(err).to.not.exist; - db.createCollection('shouldCorrectlyErrorOutFindAndModifyOnDuplicateRecord', function ( + db.createCollection('shouldCorrectlyErrorOutfindOneAndUpdateOnDuplicateRecord', function ( err, collection ) { @@ -1742,15 +1729,14 @@ describe('Find', function () { expect(err).to.not.exist; var id = r.insertedIds[1]; // Set an index - collection.ensureIndex('login', { unique: true, writeConcern: { w: 1 } }, function ( + collection.createIndex('login', { unique: true, writeConcern: { w: 1 } }, function ( err ) { expect(err).to.not.exist; // Attemp to modify document - collection.findAndModify( + collection.findOneAndUpdate( { _id: id }, - [], { $set: { login: 'user1' } }, {}, function (err) { @@ -2261,7 +2247,7 @@ describe('Find', function () { // Get the collection var collection = db.collection('textSearchWithSort'); - collection.ensureIndex({ s: 'text' }, function (err) { + collection.createIndex({ s: 'text' }, function (err) { expect(err).to.not.exist; collection.insert( @@ -2311,7 +2297,7 @@ describe('Find', function () { /** * Find and modify should allow for a write Concern without failing */ - it('should correctly execute a findAndModifyWithAWriteConcern', { + it('should correctly execute a findOneAndUpdateWithAWriteConcern', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -2327,11 +2313,10 @@ describe('Find', function () { expect(err).to.not.exist; // Let's modify the document in place - collection.findAndModify( + collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b: 3 } }, - { new: true }, + { returnOriginal: false }, function (err, updated_doc) { test.equal(1, updated_doc.value.a); test.equal(3, updated_doc.value.b); diff --git a/test/functional/index.test.js b/test/functional/index.test.js index 99b0a504ce..d3246843a5 100644 --- a/test/functional/index.test.js +++ b/test/functional/index.test.js @@ -241,7 +241,7 @@ describe('Indexes', function () { function (err, indexName) { test.equal('a_1', indexName); // Drop all the indexes - collection.dropAllIndexes(function (err, result) { + collection.dropIndexes(function (err, result) { test.equal(true, result); collection.indexInformation(function (err, result) { @@ -308,7 +308,7 @@ describe('Indexes', function () { db.createCollection('test_ensure_index', function (err, collection) { expect(err).to.not.exist; // Create an index on the collection - db.ensureIndex(collection.collectionName, 'a', configuration.writeConcernMax(), function ( + db.createIndex(collection.collectionName, 'a', configuration.writeConcernMax(), function ( err, indexName ) { @@ -321,7 +321,7 @@ describe('Indexes', function () { test.ok(collectionInfo['a_1'] != null); test.deepEqual([['a', 1]], collectionInfo['a_1']); - db.ensureIndex( + db.createIndex( collection.collectionName, 'a', configuration.writeConcernMax(), @@ -359,7 +359,7 @@ describe('Indexes', function () { expect(err).to.not.exist; db.collection('create_and_use_sparse_index_test', function (err, collection) { expect(err).to.not.exist; - collection.ensureIndex( + collection.createIndex( { title: 1 }, { sparse: true, writeConcern: { w: 1 } }, function (err) { @@ -411,7 +411,7 @@ describe('Indexes', function () { db.createCollection('geospatial_index_test', function (err) { expect(err).to.not.exist; db.collection('geospatial_index_test', function (err, collection) { - collection.ensureIndex({ loc: '2d' }, configuration.writeConcernMax(), function (err) { + collection.createIndex({ loc: '2d' }, configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; collection.insert({ loc: [-100, 100] }, configuration.writeConcernMax(), function ( err @@ -452,7 +452,7 @@ describe('Indexes', function () { db.createCollection('geospatial_index_altered_test', function (err) { expect(err).to.not.exist; db.collection('geospatial_index_altered_test', function (err, collection) { - collection.ensureIndex( + collection.createIndex( { loc: '2d' }, { min: 0, max: 1024, writeConcern: { w: 1 } }, function (err) { @@ -502,7 +502,7 @@ describe('Indexes', function () { collection.insert([{ a: 1 }, { a: 1 }], configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; - collection.ensureIndex({ a: 1 }, { unique: true, writeConcern: { w: 1 } }, function ( + collection.createIndex({ a: 1 }, { unique: true, writeConcern: { w: 1 } }, function ( err ) { test.ok(err != null); @@ -531,7 +531,7 @@ describe('Indexes', function () { collection.insert([{ a: 1 }, { a: 1 }], configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; - collection.ensureIndex({ a: 1 }, { unique: true, writeConcern: { w: 1 } }, function ( + collection.createIndex({ a: 1 }, { unique: true, writeConcern: { w: 1 } }, function ( err ) { test.ok(err != null); @@ -560,7 +560,7 @@ describe('Indexes', function () { ) { expect(err).to.not.exist; - collection.ensureIndex( + collection.createIndex( { loc: '2d' }, { min: 200, max: 1400, writeConcern: { w: 1 } }, function (err) { @@ -596,7 +596,7 @@ describe('Indexes', function () { ) { expect(err).to.not.exist; - collection.ensureIndex('name', { name: 'myfunky_name' }, function (err) { + collection.createIndex('name', { name: 'myfunky_name' }, function (err) { expect(err).to.not.exist; // Fetch full index information @@ -622,11 +622,11 @@ describe('Indexes', function () { var db = client.db(configuration.db); var shared = require('./contexts'); - db.collection('indexcontext').ensureIndex(shared.object, { background: true }, function ( + db.collection('indexcontext').createIndex(shared.object, { background: true }, function ( err ) { expect(err).to.not.exist; - db.collection('indexcontext').ensureIndex(shared.array, { background: true }, function ( + db.collection('indexcontext').createIndex(shared.array, { background: true }, function ( err ) { expect(err).to.not.exist; @@ -654,7 +654,7 @@ describe('Indexes', function () { function (err) { expect(err).to.not.exist; - collection.ensureIndex({ a: 1 }, { writeConcern: { w: 1 }, unique: true }, function ( + collection.createIndex({ a: 1 }, { writeConcern: { w: 1 }, unique: true }, function ( err ) { test.ok(err != null); @@ -680,7 +680,7 @@ describe('Indexes', function () { collection.insert([{ a: 1 }], configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; - collection.ensureIndex({ a: 1 }, configuration.writeConcernMax(), function (err) { + collection.createIndex({ a: 1 }, configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; collection .dropIndex('a_1') @@ -711,7 +711,7 @@ describe('Indexes', function () { collection.insert([{ a: 1 }], configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; - collection.ensureIndex({ a: 1 }, configuration.writeConcernMax(), function (err) { + collection.createIndex({ a: 1 }, configuration.writeConcernMax(), function (err) { expect(err).to.not.exist; collection.indexInformation({ full: false }, function (err) { @@ -748,7 +748,7 @@ describe('Indexes', function () { ) { expect(err).to.not.exist; - collection.ensureIndex( + collection.createIndex( { text: 'text' }, { language_override: 'langua', name: 'language_override_index' }, function (err) { @@ -780,7 +780,7 @@ describe('Indexes', function () { var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); client.connect(function (err, client) { var db = client.db(configuration.db); - db.collection('testListIndexes').ensureIndex({ a: 1 }, function (err) { + db.collection('testListIndexes').createIndex({ a: 1 }, function (err) { expect(err).to.not.exist; // Get the list of indexes @@ -807,7 +807,7 @@ describe('Indexes', function () { var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); client.connect(function (err, client) { var db = client.db(configuration.db); - db.collection('testListIndexes_2').ensureIndex({ a: 1 }, function (err) { + db.collection('testListIndexes_2').createIndex({ a: 1 }, function (err) { expect(err).to.not.exist; // Get the list of indexes @@ -834,7 +834,7 @@ describe('Indexes', function () { var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); client.connect(function (err, client) { var db = client.db(configuration.db); - db.collection('ensureIndexWithNestedStyleIndex').ensureIndex({ 'c.d': 1 }, function (err) { + db.collection('ensureIndexWithNestedStyleIndex').createIndex({ 'c.d': 1 }, function (err) { expect(err).to.not.exist; // Get the list of indexes @@ -1038,7 +1038,7 @@ describe('Indexes', function () { function (err) { expect(err).to.not.exist; - collection.ensureIndex({ 'a.a': 1 }, function (err) { + collection.createIndex({ 'a.a': 1 }, function (err) { expect(err).to.not.exist; client.close(done); }); @@ -1185,12 +1185,12 @@ describe('Indexes', function () { var db = client.db(configuration.db); var collection = db.collection('messed_up_options'); - collection.ensureIndex({ 'a.one': 1, 'a.two': 1 }, { name: 'n1', sparse: false }, function ( + collection.createIndex({ 'a.one': 1, 'a.two': 1 }, { name: 'n1', sparse: false }, function ( err ) { expect(err).to.not.exist; - collection.ensureIndex( + collection.createIndex( { 'a.one': 1, 'a.two': 1 }, { name: 'n2', sparse: true }, function (err) { diff --git a/test/functional/insert.test.js b/test/functional/insert.test.js index d5d83471cf..ebff4b03cd 100644 --- a/test/functional/insert.test.js +++ b/test/functional/insert.test.js @@ -964,11 +964,10 @@ describe('Insert', function () { expect(item.d).to.not.exist; // Execute a safe insert with replication to two servers - collection.findAndModify( + collection.findOneAndUpdate( { str: 'String' }, - [['a', 1]], { $set: { f: function () {} } }, - { new: true, safe: true, serializeFunctions: true }, + { returnOriginal: false, safe: true, serializeFunctions: true }, function (err, result) { test.ok(result.value.f._bsontype === 'Code'); client.close(done); diff --git a/test/functional/multiple_db.test.js b/test/functional/multiple_db.test.js index 63b4bf10d8..e6982ac449 100644 --- a/test/functional/multiple_db.test.js +++ b/test/functional/multiple_db.test.js @@ -78,7 +78,9 @@ describe('Multiple Databases', function () { db_instance.collection('counters', function (err, collection) { expect(err).to.not.exist; - collection.findAndModify({}, {}, { $inc: { db: 1 } }, { new: true }, function (err) { + collection.findOneAndUpdate({}, { $inc: { db: 1 } }, { returnOriginal: false }, function ( + err + ) { expect(err).to.not.exist; client.close(done); }); diff --git a/test/functional/operation_example.test.js b/test/functional/operation_example.test.js index 2d645cd61d..f445eeaa21 100644 --- a/test/functional/operation_example.test.js +++ b/test/functional/operation_example.test.js @@ -1071,12 +1071,12 @@ describe('Operation Examples', function () { }); /** - * Example of a how to drop all the indexes on a collection using dropAllIndexes + * Example of a how to drop all the indexes on a collection using dropIndexes * * @example-class Collection - * @example-method dropAllIndexes + * @example-method dropIndexes */ - it('dropAllIndexesExample1', { + it('dropIndexesExample1', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1101,7 +1101,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Drop the collection - db.collection('dropExample1').dropAllIndexes(function (err, reply) { + db.collection('dropExample1').dropIndexes(function (err, reply) { test.ok(reply); expect(err).to.not.exist; @@ -1155,7 +1155,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - collection.ensureIndex( + collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function (err, indexName) { @@ -1225,7 +1225,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - db.ensureIndex( + db.createIndex( 'ensureIndexExample1', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, @@ -1296,7 +1296,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - collection.ensureIndex( + collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function (err, indexName) { @@ -1488,16 +1488,16 @@ describe('Operation Examples', function () { }); /** - * A whole set of different ways to use the findAndModify command. + * A whole set of different ways to use the findOneAndUpdate command. * - * The first findAndModify command modifies a document and returns the modified document back. - * The second findAndModify command removes the document. - * The second findAndModify command upserts a document and returns the new document. + * The first findOneAndUpdate command modifies a document and returns the modified document back. + * The second findOneAndUpdate command removes the document. + * The second findOneAndUpdate command upserts a document and returns the new document. * * @example-class Collection - * @example-method findAndModify + * @example-method findOneAndUpdate */ - it('shouldPerformSimpleFindAndModifyOperations', { + it('shouldPerformSimplefindOneAndUpdateOperations', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1528,22 +1528,20 @@ describe('Operation Examples', function () { test.ok(result); expect(err).to.not.exist; - // Simple findAndModify command returning the new document - collection.findAndModify( + // Simple findOneAndUpdate command returning the new document + collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b1: 1 } }, - { new: true }, + { returnOriginal: false }, function (err, doc) { expect(err).to.not.exist; test.equal(1, doc.value.a); test.equal(1, doc.value.b1); - // Simple findAndModify command returning the new document and + // Simple findOneAndUpdate command returning the new document and // removing it at the same time - collection.findAndModify( + collection.findOneAndUpdate( { b: 1 }, - [['b', 1]], { $set: { b: 2 } }, { remove: true }, function (err, doc) { @@ -1555,13 +1553,12 @@ describe('Operation Examples', function () { expect(err).to.not.exist; expect(item).to.not.exist; - // Simple findAndModify command performing an upsert and returning the new document + // Simple findOneAndUpdate command performing an upsert and returning the new document // executing the command safely - collection.findAndModify( + collection.findOneAndUpdate( { d: 1 }, - [['b', 1]], - { d: 1, f: 1 }, - { new: true, upsert: true, writeConcern: { w: 1 } }, + { $set: { d: 1, f: 1 } }, + { returnOriginal: false, upsert: true, writeConcern: { w: 1 } }, function (err, doc) { expect(err).to.not.exist; test.equal(1, doc.value.d); @@ -1583,12 +1580,12 @@ describe('Operation Examples', function () { }); /** - * An example of using findAndRemove + * An example of using findOneAndDelete * * @example-class Collection - * @example-method findAndRemove + * @example-method findOneAndDelete */ - it('shouldPerformSimpleFindAndRemove', { + it('shouldPerformSimplefindOneAndDelete', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -1618,9 +1615,9 @@ describe('Operation Examples', function () { test.ok(result); expect(err).to.not.exist; - // Simple findAndModify command returning the old document and + // Simple findOneAndDelete command returning the old document and // removing it at the same time - collection.findAndRemove({ b: 1 }, [['b', 1]], function (err, doc) { + collection.findOneAndDelete({ b: 1 }, [['b', 1]], function (err, doc) { expect(err).to.not.exist; test.equal(1, doc.value.b); test.equal(1, doc.value.d); @@ -2065,7 +2062,7 @@ describe('Operation Examples', function () { // Crete the collection for the distinct example var collection = db.collection('simple_key_based_distinct'); // Create a geo 2d index - collection.ensureIndex({ loc: '2d' }, configuration.writeConcernMax(), function ( + collection.createIndex({ loc: '2d' }, configuration.writeConcernMax(), function ( err, result ) { @@ -2073,7 +2070,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create a simple single field index - collection.ensureIndex({ a: 1 }, configuration.writeConcernMax(), function (err, result) { + collection.createIndex({ a: 1 }, configuration.writeConcernMax(), function (err, result) { test.ok(result); expect(err).to.not.exist; @@ -2194,7 +2191,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - collection.ensureIndex( + collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function (err, indexName) { @@ -2274,7 +2271,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - collection.ensureIndex( + collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function (err, indexName) { @@ -2498,7 +2495,7 @@ describe('Operation Examples', function () { var collection = db.collection('keepGoingExample'); // Add an unique index to title to force errors in the batch insert - collection.ensureIndex({ title: 1 }, { unique: true }, function (err, indexName) { + collection.createIndex({ title: 1 }, { unique: true }, function (err, indexName) { test.ok(indexName); expect(err).to.not.exist; @@ -2722,7 +2719,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Remove all the document - collection.removeOne({ a: 1 }, { writeConcern: { w: 1 } }, function (err, r) { + collection.deleteOne({ a: 1 }, { writeConcern: { w: 1 } }, function (err, r) { expect(err).to.not.exist; expect(r).property('deletedCount').to.equal(1); client.close(done); @@ -3105,7 +3102,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - collection.ensureIndex( + collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function (err, indexName) { @@ -3113,12 +3110,12 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an additional index - collection.ensureIndex( + collection.createIndex( { c: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, function () { // Drop the index - collection.dropAllIndexes(function (err, result) { + collection.dropIndexes(function (err, result) { test.ok(result); expect(err).to.not.exist; @@ -3506,77 +3503,6 @@ describe('Operation Examples', function () { } }); - /** - * An example of removing a user. - * - * @example-class Db - * @example-method removeUser - */ - it('shouldCorrectlyAddAndRemoveUser', { - metadata: { requires: { topology: 'single' } }, - - test: function (done) { - var configuration = this.configuration; - - var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - client.connect(function (err, client) { - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE test = require('assert'); - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE client.connect(function(err, client) { - // LINE var db = client.db('test); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // REMOVE-LINE restartAndDone - // REMOVE-LINE done(); - // REMOVE-LINE var db = client.db(configuration.db); - // BEGIN - var db = client.db(configuration.db); - expect(err).to.not.exist; - - // Add a user to the database - db.addUser('user', 'name', function (err, result) { - test.ok(result); - expect(err).to.not.exist; - client.close(); - - const secondClient = configuration.newClient( - 'mongodb://user:name@localhost:27017/integration_tests' - ); - - secondClient.connect(function (err) { - expect(err).to.not.exist; - var db = secondClient.db(configuration.db); - - // Logout the db - secondClient.logout(function (err, result) { - test.equal(true, result); - - // Remove the user from the db - db.removeUser('user', function (err, result) { - test.ok(result); - expect(err).to.not.exist; - - const oldClient = secondClient; - const thirdClient = configuration.newClient( - 'mongodb://user:name@localhost:27017/integration_tests', - { serverSelectionTimeoutMS: 10 } - ); - - // Authenticate - thirdClient.connect(function (err) { - expect(err).to.exist; - oldClient.close(); - done(); - }); - }); - }); - }); - }); - }); - // END - } - }); - /** * A simple example showing the creation of a collection. * @@ -3936,7 +3862,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; // Create an index on the a field - db.ensureIndex( + db.createIndex( 'more_complex_ensure_index_db_test', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } }, @@ -4260,126 +4186,6 @@ describe('Operation Examples', function () { } }); - /** - * Retrieve the current profiling level set for the MongoDB instance - * - * @example-class Db - * @example-method profilingLevel - */ - it('shouldCorrectlySetDefaultProfilingLevel', { - metadata: { requires: { topology: 'single' } }, - - test: function (done) { - var configuration = this.configuration; - var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - client.connect(function (err, client) { - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE test = require('assert'); - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE client.connect(function(err, client) { - // LINE var db = client.db('test); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // REMOVE-LINE restartAndDone - // REMOVE-LINE done(); - // REMOVE-LINE var db = client.db(configuration.db); - // BEGIN - var db = client.db(configuration.db); - - // Grab a collection object - var collection = db.collection('test'); - - // Force the creation of the collection by inserting a document - // Collections are not created until the first document is inserted - collection.insertOne({ a: 1 }, { writeConcern: { w: 1 } }, function (err, doc) { - test.ok(doc); - expect(err).to.not.exist; - - // Use the admin database for the operation - var adminDb = client.db('admin'); - - // Retrieve the profiling level - adminDb.profilingLevel(function (err, level) { - test.ok(level); - expect(err).to.not.exist; - - client.close(done); - }); - }); - }); - // END - } - }); - - /** - * An example of how to use the profilingInfo - * Use this command to pull back the profiling information currently set for Mongodb - * - * @example-class Db - * @example-method profilingInfo - */ - it('shouldCorrectlySetAndExtractProfilingInfo', { - metadata: { requires: { topology: 'single' } }, - - test: function (done) { - var configuration = this.configuration; - var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - client.connect(function (err, client) { - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE test = require('assert'); - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE client.connect(function(err, client) { - // LINE var db = client.db('test); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // REMOVE-LINE restartAndDone - // REMOVE-LINE done(); - // REMOVE-LINE var db = client.db(configuration.db); - // BEGIN - var db = client.db(configuration.db); - - // Grab a collection object - var collection = db.collection('test'); - - // Force the creation of the collection by inserting a document - // Collections are not created until the first document is inserted - collection.insertOne({ a: 1 }, { writeConcern: { w: 1 } }, function (err, doc) { - test.ok(doc); - expect(err).to.not.exist; - - // Use the admin database for the operation - // Set the profiling level to all - db.setProfilingLevel('all', function (err, level) { - test.ok(level); - expect(err).to.not.exist; - - // Execute a query command - collection.find().toArray(function (err, items) { - expect(err).to.not.exist; - test.ok(items.length > 0); - - // Turn off profiling - db.setProfilingLevel('off', function (err, level) { - test.ok(level); - expect(err).to.not.exist; - - // Retrieve the profiling information - db.profilingInfo(function (err, infos) { - expect(err).to.not.exist; - test.ok(infos.constructor === Array); - test.ok(infos.length >= 1); - test.ok(infos[0].ts.constructor === Date); - test.ok(infos[0].millis.constructor === Number); - - client.close(done); - }); - }); - }); - }); - }); - }); - // END - } - }); - /** * An example of how to use the validateCollection command * Use this command to check that a collection is valid (not corrupt) and to get various statistics. @@ -6363,12 +6169,12 @@ describe('Operation Examples', function () { }); /** - * Example of a simple removeOne operation + * Example of a simple deleteOne operation * * @example-class Collection - * @example-method removeOne + * @example-method deleteOne */ - it('Should correctly execute removeOne operation', { + it('Should correctly execute deleteOne operation', { metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } }, @@ -6394,7 +6200,7 @@ describe('Operation Examples', function () { expect(err).to.not.exist; test.equal(2, r.insertedCount); - col.removeOne({ a: 1 }, function (err, r) { + col.deleteOne({ a: 1 }, function (err, r) { expect(err).to.not.exist; test.equal(1, r.deletedCount); // Finish up test @@ -6439,7 +6245,7 @@ describe('Operation Examples', function () { test.equal(2, r.insertedCount); // Update all documents - col.removeMany({ a: 1 }, function (err, r) { + col.deleteMany({ a: 1 }, function (err, r) { expect(err).to.not.exist; test.equal(2, r.deletedCount); diff --git a/test/functional/operation_generators_example.test.js b/test/functional/operation_generators_example.test.js index e9faf7c23a..9c89bdf053 100644 --- a/test/functional/operation_generators_example.test.js +++ b/test/functional/operation_generators_example.test.js @@ -475,12 +475,12 @@ describe('Operation (Generators)', function () { }); /** - * Example of a how to drop all the indexes on a collection using dropAllIndexes with a Generator and the co module + * Example of a how to drop all the indexes on a collection using dropIndexes with a Generator and the co module * * @example-class Collection - * @example-method dropAllIndexes + * @example-method dropIndexes */ - it('dropAllIndexesExample1WithGenerators', { + it('dropIndexesExample1WithGenerators', { metadata: { requires: { generators: true, topology: ['single'] } }, test: function () { @@ -506,7 +506,7 @@ describe('Operation (Generators)', function () { // BEGIN yield db.createCollection('dropExample1_with_generators'); // Drop the collection - yield db.collection('dropExample1_with_generators').dropAllIndexes(); + yield db.collection('dropExample1_with_generators').dropIndexes(); // Let's close the db yield client.close(); }); @@ -557,7 +557,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield collection.ensureIndex( + yield collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -620,7 +620,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield db.ensureIndex( + yield db.createIndex( 'ensureIndexExample1_with_generators', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } @@ -683,7 +683,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield collection.ensureIndex( + yield collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -903,23 +903,17 @@ describe('Operation (Generators)', function () { ); // Simple findAndModify command returning the new document - var doc = yield collection.findAndModify( + var doc = yield collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b1: 1 } }, - { new: true } + { returnOriginal: false } ); test.equal(1, doc.value.a); test.equal(1, doc.value.b1); // Simple findAndModify command returning the new document and // removing it at the same time - doc = yield collection.findAndModify( - { b: 1 }, - [['b', 1]], - { $set: { b: 2 } }, - { remove: true } - ); + doc = yield collection.findOneAndUpdate({ b: 1 }, { $set: { b: 2 } }, { remove: true }); // Verify that the document is gone var item = yield collection.findOne({ b: 1 }); @@ -927,11 +921,10 @@ describe('Operation (Generators)', function () { // Simple findAndModify command performing an upsert and returning the new document // executing the command safely - doc = yield collection.findAndModify( + doc = yield collection.findOneAndUpdate( { d: 1 }, - [['b', 1]], - { d: 1, f: 1 }, - { new: true, upsert: true, writeConcern: { w: 1 } } + { $set: { d: 1, f: 1 } }, + { returnOriginal: false, upsert: true, writeConcern: { w: 1 } } ); test.equal(1, doc.value.d); test.equal(1, doc.value.f); @@ -982,9 +975,9 @@ describe('Operation (Generators)', function () { configuration.writeConcernMax() ); - // Simple findAndModify command returning the old document and + // Simple findOneAndDelete command returning the old document and // removing it at the same time - var doc = yield collection.findAndRemove({ b: 1 }, [['b', 1]]); + var doc = yield collection.findOneAndDelete({ b: 1 }); test.equal(1, doc.value.b); test.equal(1, doc.value.d); @@ -1402,10 +1395,10 @@ describe('Operation (Generators)', function () { var collection = db.collection('simple_key_based_distinct_with_generators'); // Create a geo 2d index - yield collection.ensureIndex({ loc: '2d' }, configuration.writeConcernMax()); + yield collection.createIndex({ loc: '2d' }, configuration.writeConcernMax()); // Create a simple single field index - yield collection.ensureIndex({ a: 1 }, configuration.writeConcernMax()); + yield collection.createIndex({ a: 1 }, configuration.writeConcernMax()); // List all of the indexes on the collection var indexes = yield collection.indexes(); @@ -1520,7 +1513,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield collection.ensureIndex( + yield collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -1595,7 +1588,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield collection.ensureIndex( + yield collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -1803,7 +1796,7 @@ describe('Operation (Generators)', function () { var collection = db.collection('keepGoingExample_with_generators'); // Add an unique index to title to force errors in the batch insert - yield collection.ensureIndex({ title: 1 }, { unique: true }); + yield collection.createIndex({ title: 1 }, { unique: true }); // Insert some intial data into the collection yield collection.insertMany( @@ -1967,7 +1960,7 @@ describe('Operation (Generators)', function () { yield collection.insertMany([{ a: 1 }, { b: 2 }], { writeConcern: { w: 1 } }); // Remove all the document - yield collection.removeMany(); + yield collection.deleteMany(); // Fetch all results var items = yield collection.find().toArray(); @@ -2014,7 +2007,7 @@ describe('Operation (Generators)', function () { // Insert a bunch of documents yield collection.insertMany([{ a: 1 }, { b: 2 }], { writeConcern: { w: 1 } }); // Remove all the document - var r = yield collection.removeOne({ a: 1 }, { writeConcern: { w: 1 } }); + var r = yield collection.deleteOne({ a: 1 }, { writeConcern: { w: 1 } }); expect(r).property('deletedCount').to.equal(1); yield client.close(); }); @@ -2386,19 +2379,19 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield collection.ensureIndex( + yield collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); // Create an additional index - yield collection.ensureIndex( + yield collection.createIndex( { c: 1 }, { unique: true, background: true, sparse: true, writeConcern: { w: 1 } } ); // Drop the index - yield collection.dropAllIndexes(); + yield collection.dropIndexes(); // Verify that the index is gone var indexInformation = yield collection.indexInformation(); @@ -2937,7 +2930,7 @@ describe('Operation (Generators)', function () { ); // Create an index on the a field - yield db.ensureIndex( + yield db.createIndex( 'more_complex_ensure_index_db_test_with_generators', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } @@ -3214,141 +3207,6 @@ describe('Operation (Generators)', function () { } }); - /** - * An example of how to use the setProfilingInfo using a Generator and the co module. - * Use this command to set the Profiling level on the MongoDB server - * - * @example-class Db - * @example-method setProfilingLevel - */ - it('shouldCorrectlyChangeProfilingLevelWithGenerators', { - metadata: { requires: { generators: true, topology: 'single' } }, - - test: function () { - var configuration = this.configuration; - var co = require('co'); - - return co(function* () { - // Connect - var client = yield configuration - .newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }) - .connect(); - var db = client.db(configuration.db); - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE co = require('co'); - // LINE test = require('assert'); - // LINE - // LINE co(function*() { - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE yield client.connect(); - // LINE - // LINE var db = client.db('test'); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // BEGIN - - // Grab a collection object - var collection = db.collection('test_with_generators'); - - // Force the creation of the collection by inserting a document - // Collections are not created until the first document is inserted - yield collection.insertOne({ a: 1 }, { writeConcern: { w: 1 } }); - - // Set the profiling level to only profile slow queries - yield db.setProfilingLevel('slow_only'); - - // Retrieve the profiling level and verify that it's set to slow_only - var level = yield db.profilingLevel(); - test.equal('slow_only', level); - - // Turn profiling off - yield db.setProfilingLevel('off'); - - // Retrieve the profiling level and verify that it's set to off - level = yield db.profilingLevel(); - test.equal('off', level); - - // Set the profiling level to log all queries - yield db.setProfilingLevel('all'); - - // Retrieve the profiling level and verify that it's set to all - level = yield db.profilingLevel(); - test.equal('all', level); - - try { - // Attempt to set an illegal profiling level - yield db.setProfilingLevel('medium'); - } catch (err) { - test.ok(err instanceof Error); - test.equal('Error: illegal profiling level value medium', err.message); - - yield client.close(); - } - }); - // END - } - }); - - /** - * An example of how to use the profilingInfo using a Generator and the co module. - * Use this command to pull back the profiling information currently set for Mongodb - * - * @example-class Db - * @example-method profilingInfo - */ - it('shouldCorrectlySetAndExtractProfilingInfoWithGenerators', { - metadata: { requires: { generators: true, topology: 'single' } }, - - test: function () { - var configuration = this.configuration; - var co = require('co'); - - return co(function* () { - // Connect - var client = yield configuration - .newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }) - .connect(); - var db = client.db(configuration.db); - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE co = require('co'); - // LINE test = require('assert'); - // LINE - // LINE co(function*() { - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE yield client.connect(); - // LINE - // LINE var db = client.db('test'); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // BEGIN - - // Grab a collection object - var collection = db.collection('test_with_generators'); - - // Force the creation of the collection by inserting a document - // Collections are not created until the first document is inserted - yield collection.insertOne({ a: 1 }, { writeConcern: { w: 1 } }); - - // Set the profiling level to all - yield db.setProfilingLevel('all'); - - // Execute a query command - yield collection.find().toArray(); - - // Turn off profiling - yield db.setProfilingLevel('off'); - - // Retrieve the profiling information - var infos = yield db.profilingInfo(); - test.ok(infos.constructor === Array); - test.ok(infos.length >= 1); - test.ok(infos[0].ts.constructor === Date); - test.ok(infos[0].millis.constructor === Number); - - yield client.close(); - }); - // END - } - }); - /** * An example of how to use the validateCollection command using a Generator and the co module. * Use this command to check that a collection is valid (not corrupt) and to get various statistics. @@ -4279,12 +4137,12 @@ describe('Operation (Generators)', function () { }); /** - * Example of a simple removeOne operation using a Generator and the co module. + * Example of a simple deleteOne operation using a Generator and the co module. * * @example-class Collection - * @example-method removeOne + * @example-method deleteOne */ - it('Should correctly execute removeOne operation with Generators', { + it('Should correctly execute deleteOne operation with Generators', { metadata: { requires: { generators: true, topology: ['single'] } }, test: function () { @@ -4313,7 +4171,7 @@ describe('Operation (Generators)', function () { var r = yield col.insertMany([{ a: 1 }, { a: 1 }]); test.equal(2, r.insertedCount); - r = yield col.removeOne({ a: 1 }); + r = yield col.deleteOne({ a: 1 }); test.equal(1, r.deletedCount); // Finish up test yield client.close(); @@ -4323,12 +4181,12 @@ describe('Operation (Generators)', function () { }); /** - * Example of a simple removeMany operation using a Generator and the co module. + * Example of a simple deleteMany operation using a Generator and the co module. * * @example-class Collection - * @example-method removeMany + * @example-method deleteMany */ - it('Should correctly execute removeMany operation with Generators', { + it('Should correctly execute deleteMany operation with Generators', { metadata: { requires: { generators: true, topology: ['single'] } }, test: function () { @@ -4358,7 +4216,7 @@ describe('Operation (Generators)', function () { test.equal(2, r.insertedCount); // Update all documents - r = yield col.removeMany({ a: 1 }); + r = yield col.deleteMany({ a: 1 }); test.equal(2, r.deletedCount); // Finish up test diff --git a/test/functional/operation_promises_example.test.js b/test/functional/operation_promises_example.test.js index 9414fdcf53..0422db2016 100644 --- a/test/functional/operation_promises_example.test.js +++ b/test/functional/operation_promises_example.test.js @@ -484,12 +484,12 @@ describe('Operation (Promises)', function () { }); /** - * Example of a how to drop all the indexes on a collection using dropAllIndexes with a Promise + * Example of a how to drop all the indexes on a collection using dropIndexes with a Promise * * @example-class Collection - * @example-method dropAllIndexes + * @example-method dropIndexes */ - it('dropAllIndexesExample1WithPromises', { + it('dropIndexesExample1WithPromises', { metadata: { requires: { topology: ['single'] } }, test: function () { @@ -512,7 +512,7 @@ describe('Operation (Promises)', function () { test.ok(r); // Drop the collection - return db.collection('dropExample1_with_promise').dropAllIndexes(); + return db.collection('dropExample1_with_promise').dropIndexes(); }) .then(function (reply) { test.ok(reply); @@ -565,7 +565,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return collection.ensureIndex( + return collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -633,7 +633,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return db.ensureIndex( + return db.createIndex( 'ensureIndexExample1_with_promise', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } @@ -700,7 +700,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return collection.ensureIndex( + return collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -915,11 +915,10 @@ describe('Operation (Promises)', function () { test.ok(result); // Simple findAndModify command returning the new document - return collection.findAndModify( + return collection.findOneAndUpdate( { a: 1 }, - [['a', 1]], { $set: { b1: 1 } }, - { new: true } + { returnOriginal: false } ); }) .then(function (doc) { @@ -928,12 +927,7 @@ describe('Operation (Promises)', function () { // Simple findAndModify command returning the new document and // removing it at the same time - return collection.findAndModify( - { b: 1 }, - [['b', 1]], - { $set: { b: 2 } }, - { remove: true } - ); + return collection.findOneAndUpdate({ b: 1 }, { $set: { b: 2 } }, { remove: true }); }) .then(function (doc) { test.ok(doc); @@ -946,11 +940,10 @@ describe('Operation (Promises)', function () { // Simple findAndModify command performing an upsert and returning the new document // executing the command safely - return collection.findAndModify( + return collection.findOneAndUpdate( { d: 1 }, - [['b', 1]], - { d: 1, f: 1 }, - { new: true, upsert: true, writeConcern: { w: 1 } } + { $set: { d: 1, f: 1 } }, + { returnOriginal: false, upsert: true, writeConcern: { w: 1 } } ); }) .then(function (doc) { @@ -964,12 +957,12 @@ describe('Operation (Promises)', function () { }); /** - * An example of using findAndRemove using a Promise. + * An example of using findOneAndDelete using a Promise. * * @example-class Collection - * @example-method findAndRemove + * @example-method findOneAndDelete */ - it('shouldPerformSimpleFindAndRemoveWithPromises', { + it('shouldPerformSimplefindOneAndDeleteWithPromises', { metadata: { requires: { topology: ['single'] } }, test: function () { @@ -1000,7 +993,7 @@ describe('Operation (Promises)', function () { // Simple findAndModify command returning the old document and // removing it at the same time - return collection.findAndRemove({ b: 1 }, [['b', 1]]); + return collection.findOneAndDelete({ b: 1 }, [['b', 1]]); }) .then(function (doc) { test.equal(1, doc.value.b); @@ -1420,12 +1413,12 @@ describe('Operation (Promises)', function () { // Create a geo 2d index return collection - .ensureIndex({ loc: '2d' }, configuration.writeConcernMax()) + .createIndex({ loc: '2d' }, configuration.writeConcernMax()) .then(function (result) { test.ok(result); // Create a simple single field index - return collection.ensureIndex({ a: 1 }, configuration.writeConcernMax()); + return collection.createIndex({ a: 1 }, configuration.writeConcernMax()); }) .then(function (result) { test.ok(result); @@ -1548,7 +1541,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return collection.ensureIndex( + return collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -1624,7 +1617,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return collection.ensureIndex( + return collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -1835,7 +1828,7 @@ describe('Operation (Promises)', function () { .catch(function () {}) .then(function () { // Add an unique index to title to force errors in the batch insert - return collection.ensureIndex({ title: 1 }, { unique: true }); + return collection.createIndex({ title: 1 }, { unique: true }); }) .then(function (indexName) { test.ok(indexName); @@ -1991,7 +1984,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Remove all the document - return collection.removeMany(); + return collection.deleteMany(); }) .then(function () { // Fetch all results @@ -2040,7 +2033,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Remove all the document - return collection.removeOne({ a: 1 }, { writeConcern: { w: 1 } }); + return collection.deleteOne({ a: 1 }, { writeConcern: { w: 1 } }); }) .then(function (r) { expect(r).property('deletedCount').to.equal(1); @@ -2422,7 +2415,7 @@ describe('Operation (Promises)', function () { test.ok(result); // Create an index on the a field - return collection.ensureIndex( + return collection.createIndex( { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } ); @@ -2430,7 +2423,7 @@ describe('Operation (Promises)', function () { .then(function (indexName) { test.ok(indexName); // Create an additional index - return collection.ensureIndex( + return collection.createIndex( { c: 1 }, { unique: true, background: true, sparse: true, writeConcern: { w: 1 } } ); @@ -2438,7 +2431,7 @@ describe('Operation (Promises)', function () { .then(function (indexName) { test.ok(indexName); // Drop the index - return collection.dropAllIndexes(); + return collection.dropIndexes(); }) .then(function (result) { test.ok(result); @@ -3130,7 +3123,7 @@ describe('Operation (Promises)', function () { .then(function (result) { test.ok(result); // Create an index on the a field - return db.ensureIndex( + return db.createIndex( 'more_complex_ensure_index_db_test_with_promise', { a: 1, b: 1 }, { unique: true, background: true, writeConcern: { w: 1 } } @@ -3532,73 +3525,6 @@ describe('Operation (Promises)', function () { } }); - /** - * An example of how to use the profilingInfo using a Promise. - * Use this command to pull back the profiling information currently set for Mongodb - * - * @example-class Admin - * @example-method profilingInfo - */ - it('shouldCorrectlySetAndExtractProfilingInfoWithPromises', { - metadata: { requires: { topology: 'single' } }, - - test: function () { - var configuration = this.configuration; - var client = configuration.newClient(configuration.writeConcernMax(), { maxPoolSize: 1 }); - - return client.connect().then(function (client) { - var db = client.db(configuration.db); - // LINE var MongoClient = require('mongodb').MongoClient, - // LINE test = require('assert'); - // LINE const client = new MongoClient('mongodb://localhost:27017/test'); - // LINE client.connect().then(() => { - // LINE var db = client.db('test); - // REPLACE configuration.writeConcernMax() WITH {w:1} - // REMOVE-LINE restartAndDone - // REMOVE-LINE done(); - // BEGIN - - // Grab a collection object - var collection = db.collection('test_with_promise'); - - // Force the creation of the collection by inserting a document - // Collections are not created until the first document is inserted - return collection - .insertOne({ a: 1 }, { writeConcern: { w: 1 } }) - .then(function (doc) { - test.ok(doc); - // Use the admin database for the operation - // Set the profiling level to all - return db.setProfilingLevel('all'); - }) - .then(function (level) { - test.ok(level); - // Execute a query command - return collection.find().toArray(); - }) - .then(function (items) { - test.ok(items.length > 0); - - // Turn off profiling - return db.setProfilingLevel('off'); - }) - .then(function (level) { - test.ok(level); - // Retrieve the profiling information - return db.profilingInfo(); - }) - .then(function (infos) { - test.ok(infos.constructor === Array); - test.ok(infos.length >= 1); - test.ok(infos[0].ts.constructor === Date); - test.ok(infos[0].millis.constructor === Number); - return client.close(); - }); - }); - // END - } - }); - /** * An example of how to use the validateCollection command using a Promise. * Use this command to check that a collection is valid (not corrupt) and to get various statistics. @@ -4580,12 +4506,12 @@ describe('Operation (Promises)', function () { }); /** - * Example of a simple removeOne operation using a Promise. + * Example of a simple deleteOne operation using a Promise. * * @example-class Collection - * @example-method removeOne + * @example-method deleteOne */ - it('Should correctly execute removeOne operation With Promises', { + it('Should correctly execute deleteOne operation With Promises', { metadata: { requires: { topology: ['single'] } }, test: function () { @@ -4611,7 +4537,7 @@ describe('Operation (Promises)', function () { .then(function (r) { test.equal(2, r.insertedCount); - return col.removeOne({ a: 1 }); + return col.deleteOne({ a: 1 }); }) .then(function (r) { test.equal(1, r.deletedCount); @@ -4624,12 +4550,12 @@ describe('Operation (Promises)', function () { }); /** - * Example of a simple removeMany operation using a Promise. + * Example of a simple deleteMany operation using a Promise. * * @example-class Collection - * @example-method removeMany + * @example-method deleteMany */ - it('Should correctly execute removeMany operation With Promises', { + it('Should correctly execute deleteMany operation With Promises', { metadata: { requires: { topology: ['single'] } }, test: function () { @@ -4656,7 +4582,7 @@ describe('Operation (Promises)', function () { test.equal(2, r.insertedCount); // Update all documents - return col.removeMany({ a: 1 }); + return col.deleteMany({ a: 1 }); }) .then(function (r) { test.equal(2, r.deletedCount); diff --git a/test/functional/promises_db.test.js b/test/functional/promises_db.test.js index 08f3724cea..6d31b726cd 100644 --- a/test/functional/promises_db.test.js +++ b/test/functional/promises_db.test.js @@ -325,7 +325,7 @@ describe('Promises (Db)', function () { // Create an index client .db(configuration.db) - .ensureIndex('promiseCollectionCollections2', { a: 1 }) + .createIndex('promiseCollectionCollections2', { a: 1 }) .then(function (r) { test.ok(r != null); diff --git a/test/functional/shared.test.js b/test/functional/shared.test.js index eb34eeecae..ca10d83d41 100644 --- a/test/functional/shared.test.js +++ b/test/functional/shared.test.js @@ -18,15 +18,12 @@ describe('shared test utilities', function () { }); it('should call done and close connection with callback', function (done) { - var c = null; var e = []; const fakeDone = () => { - expect(c.isConnected()).to.be.false; expect(e.length).to.equal(1); done(); }; const encapsulatedTest = withMonitoredClient(['find'], function (client, events, innerDone) { - c = client; e = events; client .db('integration_test') @@ -40,16 +37,13 @@ describe('shared test utilities', function () { }); it('should propagate passed error to done', function (done) { - var c = null; var e = []; const fakeDone = err => { expect(err).to.be.instanceOf(Error); - expect(c.isConnected()).to.be.false; expect(e.length).to.equal(1); done(); }; const encapsulatedTest = withMonitoredClient(['find'], function (client, events, innerDone) { - c = client; e = events; client .db('integration_test') @@ -63,15 +57,12 @@ describe('shared test utilities', function () { }); it('should call done and close connection with promise', function (done) { - var c = null; var e = []; const fakeDone = () => { - expect(c.isConnected()).to.be.false; expect(e.length).to.equal(1); done(); }; const encapsulatedTest = withMonitoredClient(['find'], function (client, events, innerDone) { - c = client; e = events; client .db('integration_test') @@ -86,17 +77,14 @@ describe('shared test utilities', function () { }); it('should propagate passed error to done from promise', function (done) { - var c = null; var e = []; const fakeDone = err => { expect(err).to.be.instanceOf(Error); - expect(c.isConnected()).to.be.false; expect(e.length).to.equal(1); done(); }; const encapsulatedTest = withMonitoredClient(['find'], function (client, events, innerDone) { e = events; - c = client; client .db('integration_test') .collection('test') diff --git a/test/functional/spec-runner/index.js b/test/functional/spec-runner/index.js index 5aa9a2989a..90b334ea80 100644 --- a/test/functional/spec-runner/index.js +++ b/test/functional/spec-runner/index.js @@ -267,7 +267,6 @@ function runTestSuiteTest(configuration, spec, context) { { heartbeatFrequencyMS: 100, minHeartbeatFrequencyMS: 100, - useRecoveryToken: true, monitorCommands: true }, spec.clientOptions diff --git a/test/functional/unified-spec-runner/.eslintrc.json b/test/functional/unified-spec-runner/.eslintrc.json index cc92fa60ac..0fb7de09fa 100644 --- a/test/functional/unified-spec-runner/.eslintrc.json +++ b/test/functional/unified-spec-runner/.eslintrc.json @@ -6,7 +6,6 @@ "plugins": [ "@typescript-eslint", "prettier", - "promise", "eslint-plugin-tsdoc" ], "extends": [ diff --git a/test/unit/bypass_validation.test.js b/test/unit/bypass_validation.test.js index e7be3c7578..324bb4a974 100644 --- a/test/unit/bypass_validation.test.js +++ b/test/unit/bypass_validation.test.js @@ -127,8 +127,8 @@ describe('bypass document validation', function () { testMapReduce(this.configuration, { expected: undefined, actual: false }, done); }); - // general test for findAndModify function - function testFindAndModify(testConfiguration, config, done) { + // general test for findOneAndUpdate function + function testFindOneAndUpdate(testConfiguration, config, done) { const client = testConfiguration.newClient(`mongodb://${test.server.uri()}/test`); let close = e => { close = () => {}; @@ -162,27 +162,21 @@ describe('bypass document validation', function () { const options = { bypassDocumentValidation: config.actual }; - collection.findAndModify( - { name: 'Andy' }, - { rating: 1 }, - { $inc: { score: 1 } }, - options, - e => { - close(e); - } - ); + collection.findOneAndUpdate({ name: 'Andy' }, { $inc: { score: 1 } }, options, e => { + close(e); + }); }); } - // find and modify - it('should only set bypass document validation if strictly true in findAndModify', function (done) { - testFindAndModify(this.configuration, { expected: true, actual: true }, done); + // find one and update + it('should only set bypass document validation if strictly true in findOneAndUpdate', function (done) { + testFindOneAndUpdate(this.configuration, { expected: true, actual: true }, done); }); - it('should not set bypass document validation if not strictly true in findAndModify', function (done) { - testFindAndModify(this.configuration, { expected: undefined, actual: false }, done); + it('should not set bypass document validation if not strictly true in findOneAndUpdate', function (done) { + testFindOneAndUpdate(this.configuration, { expected: undefined, actual: false }, done); }); - // general test for BlukWrite to test changes made in ordered.js and unordered.js + // general test for BulkWrite to test changes made in ordered.js and unordered.js function testBulkWrite(testConfiguration, config, done) { const client = testConfiguration.newClient(`mongodb://${test.server.uri()}/test`); let close = e => { diff --git a/test/unit/core/scram_iterations.test.js b/test/unit/core/scram_iterations.test.js index ee95897a78..1dcf3ed4cf 100644 --- a/test/unit/core/scram_iterations.test.js +++ b/test/unit/core/scram_iterations.test.js @@ -58,7 +58,7 @@ describe('SCRAM Iterations Tests', function () { } catch (e) { testErr = e; } - client.destroy(); + client.close(); done(testErr); }); @@ -106,7 +106,7 @@ describe('SCRAM Iterations Tests', function () { .to.have.property('message') .that.matches(/Server returned an invalid signature/); - client.destroy(done); + client.close(done); }); client.connect(); @@ -149,7 +149,7 @@ describe('SCRAM Iterations Tests', function () { .to.have.property('message') .that.matches(/connection(.+)closed/); - client.destroy(done); + client.close(done); }); client.connect();