mongodb 7.5.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/lib/bulk/common.js +27 -5
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js +25 -7
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js +25 -7
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +8 -2
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +12 -4
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/kms_options.js +3 -0
- package/lib/client-side-encryption/kms_options.js.map +1 -0
- package/lib/client-side-encryption/state_machine.js +54 -7
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +2 -1
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +0 -1
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +0 -3
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +6 -7
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +13 -0
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +2 -2
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +3 -1
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +2 -1
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/connection_string.js +4 -0
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/error.js +7 -11
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +1 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/delete.js +7 -10
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/execute_operation.js +29 -2
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find_and_modify.js +1 -5
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js +2 -3
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js +3 -9
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +6 -2
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/list_collections.js +2 -3
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js +2 -2
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/update.js +6 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/runtime_adapters.js +15 -16
- package/lib/runtime_adapters.js.map +1 -1
- package/lib/sdam/server.js +1 -1
- package/lib/sdam/server.js.map +1 -1
- package/lib/sessions.js +2 -2
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +1 -3
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +77 -20
- package/package.json +3 -2
- package/src/bulk/common.ts +37 -5
- package/src/bulk/ordered.ts +23 -7
- package/src/bulk/unordered.ts +23 -8
- package/src/client-side-encryption/auto_encrypter.ts +19 -3
- package/src/client-side-encryption/client_encryption.ts +29 -9
- package/src/client-side-encryption/kms_options.ts +93 -0
- package/src/client-side-encryption/state_machine.ts +68 -47
- package/src/cmap/auth/gssapi.ts +3 -4
- package/src/cmap/auth/mongo_credentials.ts +0 -1
- package/src/cmap/auth/mongodb_aws.ts +2 -12
- package/src/cmap/command_monitoring_events.ts +9 -10
- package/src/cmap/commands.ts +17 -0
- package/src/cmap/connect.ts +3 -3
- package/src/cmap/connection.ts +4 -2
- package/src/cmap/handshake/client_metadata.ts +2 -1
- package/src/cmap/wire_protocol/constants.ts +2 -2
- package/src/connection_string.ts +4 -0
- package/src/cursor/abstract_cursor.ts +0 -5
- package/src/error.ts +7 -19
- package/src/gridfs/download.ts +1 -1
- package/src/index.ts +7 -6
- package/src/mongo_client.ts +1 -1
- package/src/operations/command.ts +0 -5
- package/src/operations/delete.ts +17 -15
- package/src/operations/execute_operation.ts +29 -2
- package/src/operations/find_and_modify.ts +3 -15
- package/src/operations/get_more.ts +3 -5
- package/src/operations/indexes.ts +6 -16
- package/src/operations/insert.ts +13 -2
- package/src/operations/list_collections.ts +5 -6
- package/src/operations/list_databases.ts +3 -3
- package/src/operations/update.ts +9 -2
- package/src/operations/validate_collection.ts +1 -1
- package/src/runtime_adapters.ts +19 -18
- package/src/sdam/server.ts +1 -1
- package/src/sessions.ts +2 -5
- package/src/utils.ts +1 -3
- package/tsconfig.json +9 -2
package/src/runtime_adapters.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* eslint-disable no-restricted-imports*/
|
|
2
2
|
|
|
3
|
-
// We squash the restricted import errors here
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// We squash the restricted import errors here: the module-scope imports are type-only, and the
|
|
4
|
+
// one runtime dependency this file takes — the dynamic `import('os')` fallback in
|
|
5
|
+
// resolveRuntimeAdapters — is deliberate: this file is expected to be the only place that loads
|
|
6
|
+
// restricted Node APIs at runtime.
|
|
6
7
|
|
|
7
8
|
import type * as os from 'os';
|
|
8
9
|
|
|
@@ -11,8 +12,9 @@ import { type MongoClientOptions } from './mongo_client';
|
|
|
11
12
|
/**
|
|
12
13
|
* @internal
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* Legacy escape hatch for the test sandbox's restricted `require`: the driver no longer sets this
|
|
16
|
+
* property (the os adapter loads via dynamic `import()`), but the vm test harness
|
|
17
|
+
* still checks it. Kept until the sandbox contract is revisited in a follow-up.
|
|
16
18
|
*/
|
|
17
19
|
export const ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME = 'allowedDriverRequire';
|
|
18
20
|
|
|
@@ -47,18 +49,17 @@ export interface Runtime {
|
|
|
47
49
|
/**
|
|
48
50
|
* @internal
|
|
49
51
|
*
|
|
50
|
-
* Given a MongoClientOptions, this function resolves the set of runtime options, providing Nodejs
|
|
51
|
-
* not provided
|
|
52
|
+
* Given a MongoClientOptions, this function resolves the set of runtime options, providing Nodejs
|
|
53
|
+
* implementations if not provided in `options`, and returns a `Runtime`.
|
|
54
|
+
*
|
|
55
|
+
* Resolution is asynchronous because the default `os` adapter is loaded via a dynamic `import()`.
|
|
56
|
+
* Unlike `require`, dynamic import exists in every module system the driver ships into or is
|
|
57
|
+
* bundled into (CJS, ESM, and bundled ESM output), and the literal specifier keeps it
|
|
58
|
+
* statically analyzable for bundlers. The promise is created during synchronous
|
|
59
|
+
* options parsing and awaited later by consumers, so the public constructor stays synchronous.
|
|
52
60
|
*/
|
|
53
|
-
export function resolveRuntimeAdapters(options: MongoClientOptions): Runtime {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
58
|
-
os: options.runtimeAdapters?.os ?? require('os')
|
|
59
|
-
};
|
|
60
|
-
return runtime;
|
|
61
|
-
} finally {
|
|
62
|
-
(globalThis as any)[ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME] = false;
|
|
63
|
-
}
|
|
61
|
+
export async function resolveRuntimeAdapters(options: MongoClientOptions): Promise<Runtime> {
|
|
62
|
+
return {
|
|
63
|
+
os: options.runtimeAdapters?.os ?? (await import('os'))
|
|
64
|
+
};
|
|
64
65
|
}
|
package/src/sdam/server.ts
CHANGED
|
@@ -494,7 +494,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
494
494
|
} else {
|
|
495
495
|
if (
|
|
496
496
|
(isRetryableWritesEnabled(this.topology) || isTransactionCommand(cmd)) &&
|
|
497
|
-
needsRetryableWriteLabel(error
|
|
497
|
+
needsRetryableWriteLabel(error) &&
|
|
498
498
|
!inActiveTransaction(session, cmd)
|
|
499
499
|
) {
|
|
500
500
|
error.addErrorLabel(MongoErrorLabel.RetryableWriteError);
|
package/src/sessions.ts
CHANGED
|
@@ -771,7 +771,7 @@ export class ClientSession
|
|
|
771
771
|
) {
|
|
772
772
|
// 2. If `transactionAttempt` > 0:
|
|
773
773
|
if (isRetry) {
|
|
774
|
-
// 2.1 Calculate backoffMS to be jitter * min(BACKOFF_INITIAL * 1.5 ** (transactionAttempt
|
|
774
|
+
// 2.1 Calculate backoffMS to be jitter * min(BACKOFF_INITIAL * 1.5 ** (transactionAttempt), BACKOFF_MAX).
|
|
775
775
|
// If elapsed time + backoffMS > TIMEOUT_MS, then propagate the previously encountered error to the caller of
|
|
776
776
|
// withTransaction as per timeout error propagation and return immediately. Otherwise, sleep for backoffMS.
|
|
777
777
|
// 2.1.1 jitter is a random float between [0, 1), optionally including 1, depending on what is most natural
|
|
@@ -785,10 +785,7 @@ export class ClientSession
|
|
|
785
785
|
const jitter = Math.random();
|
|
786
786
|
const backoffMS =
|
|
787
787
|
jitter *
|
|
788
|
-
Math.min(
|
|
789
|
-
BACKOFF_INITIAL_MS * BACKOFF_GROWTH ** (transactionAttempt - 1),
|
|
790
|
-
BACKOFF_MAX_MS
|
|
791
|
-
);
|
|
788
|
+
Math.min(BACKOFF_INITIAL_MS * BACKOFF_GROWTH ** transactionAttempt, BACKOFF_MAX_MS);
|
|
792
789
|
|
|
793
790
|
if (processTimeMS() + backoffMS >= deadline) {
|
|
794
791
|
throw makeTimeoutError(
|
package/src/utils.ts
CHANGED
|
@@ -343,9 +343,7 @@ export function maxWireVersion(handshakeAware?: Connection | Topology | Server):
|
|
|
343
343
|
// object being checked will be a connection, and we will have a hello response on
|
|
344
344
|
// it. For other cases, such as retryable writes, the object will be a server or
|
|
345
345
|
// topology, and there will be no hello response on those objects, so we return
|
|
346
|
-
// the max wire version so we support retryability.
|
|
347
|
-
// wire version of 9, then the needsRetryableWriteLabel() check can remove the
|
|
348
|
-
// usage of passing the wire version into it.
|
|
346
|
+
// the max wire version so we support retryability.
|
|
349
347
|
if (handshakeAware.loadBalanced) {
|
|
350
348
|
return MAX_SUPPORTED_WIRE_VERSION;
|
|
351
349
|
}
|
package/tsconfig.json
CHANGED
|
@@ -5,8 +5,15 @@
|
|
|
5
5
|
"strict": true,
|
|
6
6
|
"alwaysStrict": true,
|
|
7
7
|
"target": "ES2023",
|
|
8
|
-
"
|
|
9
|
-
|
|
8
|
+
// node16 still emits CommonJS for this package (no "type": "module") but, unlike
|
|
9
|
+
// `module: commonjs`, models Node's real semantics: dynamic `import()` is legal inside CJS
|
|
10
|
+
// and is preserved verbatim instead of being downleveled to `require()` (NODE-7603).
|
|
11
|
+
"module": "node16",
|
|
12
|
+
"moduleResolution": "node16",
|
|
13
|
+
// node16 defaults esModuleInterop on; keep it off to preserve this package's historical
|
|
14
|
+
// emit exactly (`import * as x` stays `const x = require(...)`, no __importStar wrappers —
|
|
15
|
+
// which sinon-based module stubbing in the test suite also relies on).
|
|
16
|
+
"esModuleInterop": false,
|
|
10
17
|
"skipLibCheck": true,
|
|
11
18
|
"lib": [
|
|
12
19
|
"es2023"
|