mongodb 6.10.0 → 6.11.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 +2 -0
- package/lib/admin.js +3 -2
- package/lib/admin.js.map +1 -1
- package/lib/beta.d.ts +562 -45
- package/lib/bulk/common.js +4 -4
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +111 -51
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +8 -5
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +48 -18
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +43 -29
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +5 -2
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +38 -0
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc.js +2 -0
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/connect.js +13 -1
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +75 -17
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +14 -12
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/wire_protocol/on_data.js +5 -1
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +30 -0
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/collection.js +62 -3
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +2 -0
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +221 -38
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +29 -7
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js +2 -2
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/client_bulk_write_cursor.js +1 -1
- package/lib/cursor/client_bulk_write_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +18 -8
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/list_collections_cursor.js +1 -1
- package/lib/cursor/list_collections_cursor.js.map +1 -1
- package/lib/cursor/list_indexes_cursor.js +1 -1
- package/lib/cursor/list_indexes_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js +6 -4
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/db.js +63 -3
- package/lib/db.js.map +1 -1
- package/lib/error.js +34 -9
- package/lib/error.js.map +1 -1
- package/lib/explain.js +57 -1
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +31 -3
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +49 -14
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +80 -22
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +9 -5
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +70 -1
- package/lib/mongo_client.js.map +1 -1
- package/lib/operations/aggregate.js +2 -2
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js +7 -2
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/client_bulk_write/client_bulk_write.js +3 -3
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -1
- package/lib/operations/client_bulk_write/executor.js +14 -3
- package/lib/operations/client_bulk_write/executor.js.map +1 -1
- package/lib/operations/command.js +5 -2
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js +2 -2
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js +8 -7
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +6 -6
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js +2 -2
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js +8 -8
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js +2 -2
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +16 -10
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +6 -3
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +2 -2
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js +2 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js +6 -6
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +6 -6
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/kill_cursors.js +5 -2
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js +2 -2
- 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/operation.js.map +1 -1
- package/lib/operations/profiling_level.js +2 -2
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/remove_user.js +2 -2
- package/lib/operations/remove_user.js.map +1 -1
- package/lib/operations/rename.js +2 -2
- package/lib/operations/rename.js.map +1 -1
- package/lib/operations/run_command.js +6 -4
- package/lib/operations/run_command.js.map +1 -1
- package/lib/operations/search_indexes/create.js +5 -2
- package/lib/operations/search_indexes/create.js.map +1 -1
- package/lib/operations/search_indexes/drop.js +2 -2
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/search_indexes/update.js +2 -2
- package/lib/operations/search_indexes/update.js.map +1 -1
- package/lib/operations/set_profiling_level.js +2 -2
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js +2 -2
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +8 -8
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js +2 -2
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_concern.js +1 -1
- package/lib/sdam/common.js +0 -7
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/server.js +4 -1
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +4 -2
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -2
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/topology.js +38 -15
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +157 -98
- package/lib/sessions.js.map +1 -1
- package/lib/timeout.js +231 -16
- package/lib/timeout.js.map +1 -1
- package/lib/utils.js +36 -19
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +562 -45
- package/package.json +17 -16
- package/src/admin.ts +6 -2
- package/src/bulk/common.ts +17 -5
- package/src/change_stream.ts +127 -52
- package/src/client-side-encryption/auto_encrypter.ts +12 -5
- package/src/client-side-encryption/client_encryption.ts +103 -20
- package/src/client-side-encryption/state_machine.ts +66 -32
- package/src/cmap/auth/mongo_credentials.ts +6 -3
- package/src/cmap/auth/mongodb_aws.ts +1 -1
- package/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +38 -0
- package/src/cmap/auth/mongodb_oidc.ts +3 -1
- package/src/cmap/connect.ts +18 -1
- package/src/cmap/connection.ts +105 -17
- package/src/cmap/connection_pool.ts +15 -17
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/on_data.ts +11 -1
- package/src/cmap/wire_protocol/responses.ts +35 -1
- package/src/collection.ts +81 -9
- package/src/connection_string.ts +2 -0
- package/src/cursor/abstract_cursor.ts +287 -39
- package/src/cursor/aggregation_cursor.ts +54 -8
- package/src/cursor/change_stream_cursor.ts +6 -2
- package/src/cursor/client_bulk_write_cursor.ts +6 -2
- package/src/cursor/find_cursor.ts +40 -9
- package/src/cursor/list_collections_cursor.ts +1 -1
- package/src/cursor/list_indexes_cursor.ts +1 -1
- package/src/cursor/run_command_cursor.ts +50 -5
- package/src/db.ts +75 -7
- package/src/error.ts +33 -8
- package/src/explain.ts +85 -0
- package/src/gridfs/download.ts +43 -4
- package/src/gridfs/index.ts +64 -16
- package/src/gridfs/upload.ts +153 -45
- package/src/index.ts +27 -5
- package/src/mongo_client.ts +76 -4
- package/src/operations/aggregate.ts +10 -2
- package/src/operations/bulk_write.ts +9 -2
- package/src/operations/client_bulk_write/client_bulk_write.ts +11 -3
- package/src/operations/client_bulk_write/executor.ts +15 -3
- package/src/operations/command.ts +18 -8
- package/src/operations/count.ts +10 -3
- package/src/operations/create_collection.ts +14 -7
- package/src/operations/delete.ts +15 -6
- package/src/operations/distinct.ts +7 -2
- package/src/operations/drop.ts +18 -8
- package/src/operations/estimated_document_count.ts +7 -2
- package/src/operations/execute_operation.ts +22 -13
- package/src/operations/find.ts +17 -5
- package/src/operations/find_and_modify.ts +7 -2
- package/src/operations/get_more.ts +4 -1
- package/src/operations/indexes.ts +20 -7
- package/src/operations/insert.ts +13 -6
- package/src/operations/kill_cursors.ts +10 -2
- package/src/operations/list_collections.ts +10 -1
- package/src/operations/list_databases.ts +9 -2
- package/src/operations/operation.ts +16 -2
- package/src/operations/profiling_level.ts +7 -2
- package/src/operations/remove_user.ts +7 -2
- package/src/operations/rename.ts +7 -2
- package/src/operations/run_command.ts +23 -4
- package/src/operations/search_indexes/create.ts +10 -2
- package/src/operations/search_indexes/drop.ts +7 -2
- package/src/operations/search_indexes/update.ts +7 -2
- package/src/operations/set_profiling_level.ts +4 -2
- package/src/operations/stats.ts +7 -2
- package/src/operations/update.ts +16 -8
- package/src/operations/validate_collection.ts +7 -2
- package/src/read_concern.ts +1 -1
- package/src/sdam/common.ts +0 -11
- package/src/sdam/server.ts +14 -4
- package/src/sdam/server_description.ts +6 -2
- package/src/sdam/server_selection.ts +5 -2
- package/src/sdam/topology.ts +43 -27
- package/src/sessions.ts +206 -120
- package/src/timeout.ts +327 -23
- package/src/transactions.ts +1 -1
- package/src/utils.ts +47 -30
- package/src/write_concern.ts +6 -3
package/lib/beta.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
43
43
|
/* Excluded from this release type: isClosed */
|
|
44
44
|
/* Excluded from this release type: isKilled */
|
|
45
45
|
/* Excluded from this release type: cursorOptions */
|
|
46
|
+
/* Excluded from this release type: timeoutContext */
|
|
46
47
|
/** @event */
|
|
47
48
|
static readonly CLOSE: "close";
|
|
48
49
|
/* Excluded from this release type: deserializationOptions */
|
|
@@ -105,7 +106,9 @@ export declare abstract class AbstractCursor<TSchema = any, CursorEvents extends
|
|
|
105
106
|
/**
|
|
106
107
|
* Frees any client-side resources used by the cursor.
|
|
107
108
|
*/
|
|
108
|
-
close(
|
|
109
|
+
close(options?: {
|
|
110
|
+
timeoutMS?: number;
|
|
111
|
+
}): Promise<void>;
|
|
109
112
|
/**
|
|
110
113
|
* Returns an array of documents. The caller is responsible for making sure that there
|
|
111
114
|
* is enough memory to store the results. Note that the array only contains partial
|
|
@@ -256,7 +259,39 @@ export declare interface AbstractCursorOptions extends BSONSerializeOptions {
|
|
|
256
259
|
*/
|
|
257
260
|
awaitData?: boolean;
|
|
258
261
|
noCursorTimeout?: boolean;
|
|
259
|
-
|
|
262
|
+
/** Specifies the time an operation will run until it throws a timeout error. See {@link AbstractCursorOptions.timeoutMode} for more details on how this option applies to cursors. */
|
|
263
|
+
timeoutMS?: number;
|
|
264
|
+
/**
|
|
265
|
+
* @public
|
|
266
|
+
* @experimental
|
|
267
|
+
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
|
|
268
|
+
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
269
|
+
* `cursor.next()`.
|
|
270
|
+
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
271
|
+
*
|
|
272
|
+
* Depending on the type of cursor being used, this option has different default values.
|
|
273
|
+
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
274
|
+
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
275
|
+
* definition can have an arbitrarily long lifetime.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
280
|
+
* for await (const doc of cursor) {
|
|
281
|
+
* // process doc
|
|
282
|
+
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
283
|
+
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
290
|
+
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
timeoutMode?: CursorTimeoutMode;
|
|
294
|
+
/* Excluded from this release type: timeoutContext */
|
|
260
295
|
}
|
|
261
296
|
|
|
262
297
|
/* Excluded from this release type: AbstractOperation */
|
|
@@ -382,7 +417,9 @@ export declare interface AggregateOptions extends Omit<CommandOperationOptions,
|
|
|
382
417
|
bypassDocumentValidation?: boolean;
|
|
383
418
|
/** Return the query as cursor, on 2.6 \> it returns as a real cursor on pre 2.6 it returns as an emulated cursor. */
|
|
384
419
|
cursor?: Document;
|
|
385
|
-
/**
|
|
420
|
+
/**
|
|
421
|
+
* Specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.
|
|
422
|
+
*/
|
|
386
423
|
maxTimeMS?: number;
|
|
387
424
|
/** The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. */
|
|
388
425
|
maxAwaitTimeMS?: number;
|
|
@@ -399,6 +436,7 @@ export declare interface AggregateOptions extends Omit<CommandOperationOptions,
|
|
|
399
436
|
* or `db.aggregate().explain()`.
|
|
400
437
|
*/
|
|
401
438
|
explain?: ExplainOptions['explain'];
|
|
439
|
+
/* Excluded from this release type: timeoutMode */
|
|
402
440
|
}
|
|
403
441
|
|
|
404
442
|
/**
|
|
@@ -408,7 +446,7 @@ export declare interface AggregateOptions extends Omit<CommandOperationOptions,
|
|
|
408
446
|
* or higher stream
|
|
409
447
|
* @public
|
|
410
448
|
*/
|
|
411
|
-
export declare class AggregationCursor<TSchema = any> extends
|
|
449
|
+
export declare class AggregationCursor<TSchema = any> extends ExplainableCursor<TSchema> {
|
|
412
450
|
readonly pipeline: Document[];
|
|
413
451
|
/* Excluded from this release type: aggregateOptions */
|
|
414
452
|
/* Excluded from this release type: __constructor */
|
|
@@ -416,7 +454,14 @@ export declare class AggregationCursor<TSchema = any> extends AbstractCursor<TSc
|
|
|
416
454
|
map<T>(transform: (doc: TSchema) => T): AggregationCursor<T>;
|
|
417
455
|
/* Excluded from this release type: _initialize */
|
|
418
456
|
/** Execute the explain for the cursor */
|
|
419
|
-
explain(
|
|
457
|
+
explain(): Promise<Document>;
|
|
458
|
+
explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document>;
|
|
459
|
+
explain(options: {
|
|
460
|
+
timeoutMS?: number;
|
|
461
|
+
}): Promise<Document>;
|
|
462
|
+
explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions, options: {
|
|
463
|
+
timeoutMS?: number;
|
|
464
|
+
}): Promise<Document>;
|
|
420
465
|
/** Add a stage to the aggregation pipeline
|
|
421
466
|
* @example
|
|
422
467
|
* ```
|
|
@@ -597,7 +642,7 @@ export declare interface AuthMechanismProperties extends Document {
|
|
|
597
642
|
/** A user provided OIDC human interacted callback function. */
|
|
598
643
|
OIDC_HUMAN_CALLBACK?: OIDCCallbackFunction;
|
|
599
644
|
/** The OIDC environment. Note that 'test' is for internal use only. */
|
|
600
|
-
ENVIRONMENT?: 'test' | 'azure' | 'gcp';
|
|
645
|
+
ENVIRONMENT?: 'test' | 'azure' | 'gcp' | 'k8s';
|
|
601
646
|
/** Allowed hosts that OIDC auth can connect to. */
|
|
602
647
|
ALLOWED_HOSTS?: string[];
|
|
603
648
|
/** The resource token for OIDC auth in Azure and GCP. */
|
|
@@ -982,6 +1027,7 @@ export declare interface BulkWriteOptions extends CommandOperationOptions {
|
|
|
982
1027
|
forceServerObjectId?: boolean;
|
|
983
1028
|
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
|
|
984
1029
|
let?: Document;
|
|
1030
|
+
/* Excluded from this release type: timeoutContext */
|
|
985
1031
|
}
|
|
986
1032
|
|
|
987
1033
|
/**
|
|
@@ -1098,6 +1144,13 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
|
|
|
1098
1144
|
* @event
|
|
1099
1145
|
*/
|
|
1100
1146
|
static readonly RESUME_TOKEN_CHANGED: "resumeTokenChanged";
|
|
1147
|
+
private timeoutContext?;
|
|
1148
|
+
/**
|
|
1149
|
+
* Note that this property is here to uniquely identify a ChangeStream instance as the owner of
|
|
1150
|
+
* the {@link CursorTimeoutContext} instance (see {@link ChangeStream._createChangeStreamCursor}) to ensure
|
|
1151
|
+
* that {@link AbstractCursor.close} does not mutate the timeoutContext.
|
|
1152
|
+
*/
|
|
1153
|
+
private contextOwner;
|
|
1101
1154
|
/* Excluded from this release type: __constructor */
|
|
1102
1155
|
/* Excluded from this release type: cursorStream */
|
|
1103
1156
|
/** The cached resume token that is used to resume after the most recently returned change. */
|
|
@@ -1135,6 +1188,7 @@ export declare class ChangeStream<TSchema extends Document = Document, TChange e
|
|
|
1135
1188
|
/* Excluded from this release type: _processChange */
|
|
1136
1189
|
/* Excluded from this release type: _processErrorStreamMode */
|
|
1137
1190
|
/* Excluded from this release type: _processErrorIteratorMode */
|
|
1191
|
+
private _resume;
|
|
1138
1192
|
}
|
|
1139
1193
|
|
|
1140
1194
|
/**
|
|
@@ -1310,7 +1364,14 @@ export declare type ChangeStreamEvents<TSchema extends Document = Document, TCha
|
|
|
1310
1364
|
end(): void;
|
|
1311
1365
|
error(error: Error): void;
|
|
1312
1366
|
change(change: TChange): void;
|
|
1313
|
-
|
|
1367
|
+
/**
|
|
1368
|
+
* @remarks Note that the `close` event is currently emitted whenever the internal `ChangeStreamCursor`
|
|
1369
|
+
* instance is closed, which can occur multiple times for a given `ChangeStream` instance.
|
|
1370
|
+
*
|
|
1371
|
+
* TODO(NODE-6434): address this issue in NODE-6434
|
|
1372
|
+
*/
|
|
1373
|
+
close(): void;
|
|
1374
|
+
};
|
|
1314
1375
|
|
|
1315
1376
|
/**
|
|
1316
1377
|
* @public
|
|
@@ -1649,6 +1710,7 @@ export declare class ClientEncryption {
|
|
|
1649
1710
|
/* Excluded from this release type: _proxyOptions */
|
|
1650
1711
|
/* Excluded from this release type: _tlsOptions */
|
|
1651
1712
|
/* Excluded from this release type: _kmsProviders */
|
|
1713
|
+
/* Excluded from this release type: _timeoutMS */
|
|
1652
1714
|
/* Excluded from this release type: _mongoCrypt */
|
|
1653
1715
|
/* Excluded from this release type: getMongoCrypt */
|
|
1654
1716
|
/**
|
|
@@ -1952,6 +2014,7 @@ export declare interface ClientEncryptionCreateDataKeyProviderOptions {
|
|
|
1952
2014
|
keyAltNames?: string[] | undefined;
|
|
1953
2015
|
/** @experimental */
|
|
1954
2016
|
keyMaterial?: Buffer | Binary;
|
|
2017
|
+
/* Excluded from this release type: timeoutContext */
|
|
1955
2018
|
}
|
|
1956
2019
|
|
|
1957
2020
|
/**
|
|
@@ -2018,6 +2081,38 @@ export declare interface ClientEncryptionOptions {
|
|
|
2018
2081
|
* TLS options for kms providers to use.
|
|
2019
2082
|
*/
|
|
2020
2083
|
tlsOptions?: CSFLEKMSTlsOptions;
|
|
2084
|
+
/**
|
|
2085
|
+
* @experimental
|
|
2086
|
+
*
|
|
2087
|
+
* The timeout setting to be used for all the operations on ClientEncryption.
|
|
2088
|
+
*
|
|
2089
|
+
* When provided, `timeoutMS` is used as the timeout for each operation executed on
|
|
2090
|
+
* the ClientEncryption object. For example:
|
|
2091
|
+
*
|
|
2092
|
+
* ```typescript
|
|
2093
|
+
* const clientEncryption = new ClientEncryption(client, {
|
|
2094
|
+
* timeoutMS: 1_000
|
|
2095
|
+
* kmsProviders: { local: { key: '<KEY>' } }
|
|
2096
|
+
* });
|
|
2097
|
+
*
|
|
2098
|
+
* // `1_000` is used as the timeout for createDataKey call
|
|
2099
|
+
* await clientEncryption.createDataKey('local');
|
|
2100
|
+
* ```
|
|
2101
|
+
*
|
|
2102
|
+
* If `timeoutMS` is configured on the provided client, the client's `timeoutMS` value
|
|
2103
|
+
* will be used unless `timeoutMS` is also provided as a client encryption option.
|
|
2104
|
+
*
|
|
2105
|
+
* ```typescript
|
|
2106
|
+
* const client = new MongoClient('<uri>', { timeoutMS: 2_000 });
|
|
2107
|
+
*
|
|
2108
|
+
* // timeoutMS is set to 1_000 on clientEncryption
|
|
2109
|
+
* const clientEncryption = new ClientEncryption(client, {
|
|
2110
|
+
* timeoutMS: 1_000
|
|
2111
|
+
* kmsProviders: { local: { key: '<KEY>' } }
|
|
2112
|
+
* });
|
|
2113
|
+
* ```
|
|
2114
|
+
*/
|
|
2115
|
+
timeoutMS?: number;
|
|
2021
2116
|
}
|
|
2022
2117
|
|
|
2023
2118
|
/**
|
|
@@ -2076,7 +2171,7 @@ export declare interface ClientInsertOneResult {
|
|
|
2076
2171
|
|
|
2077
2172
|
/**
|
|
2078
2173
|
* @public
|
|
2079
|
-
* @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.
|
|
2174
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#hello-command
|
|
2080
2175
|
*/
|
|
2081
2176
|
export declare interface ClientMetadata {
|
|
2082
2177
|
driver: {
|
|
@@ -2141,7 +2236,7 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2141
2236
|
/* Excluded from this release type: client */
|
|
2142
2237
|
/* Excluded from this release type: sessionPool */
|
|
2143
2238
|
hasEnded: boolean;
|
|
2144
|
-
clientOptions
|
|
2239
|
+
clientOptions: MongoOptions;
|
|
2145
2240
|
supports: {
|
|
2146
2241
|
causalConsistency: boolean;
|
|
2147
2242
|
};
|
|
@@ -2157,7 +2252,12 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2157
2252
|
/* Excluded from this release type: [kSnapshotEnabled] */
|
|
2158
2253
|
/* Excluded from this release type: [kPinnedConnection] */
|
|
2159
2254
|
/* Excluded from this release type: [kTxnNumberIncrement] */
|
|
2160
|
-
|
|
2255
|
+
/**
|
|
2256
|
+
* @experimental
|
|
2257
|
+
* Specifies the time an operation in a given `ClientSession` will run until it throws a timeout error
|
|
2258
|
+
*/
|
|
2259
|
+
timeoutMS?: number;
|
|
2260
|
+
/* Excluded from this release type: timeoutContext */
|
|
2161
2261
|
/* Excluded from this release type: __constructor */
|
|
2162
2262
|
/** The server id associated with this session */
|
|
2163
2263
|
get id(): ServerSessionId | undefined;
|
|
@@ -2227,12 +2327,21 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2227
2327
|
startTransaction(options?: TransactionOptions): void;
|
|
2228
2328
|
/**
|
|
2229
2329
|
* Commits the currently active transaction in this session.
|
|
2330
|
+
*
|
|
2331
|
+
* @param options - Optional options, can be used to override `defaultTimeoutMS`.
|
|
2230
2332
|
*/
|
|
2231
|
-
commitTransaction(
|
|
2333
|
+
commitTransaction(options?: {
|
|
2334
|
+
timeoutMS?: number;
|
|
2335
|
+
}): Promise<void>;
|
|
2232
2336
|
/**
|
|
2233
2337
|
* Aborts the currently active transaction in this session.
|
|
2338
|
+
*
|
|
2339
|
+
* @param options - Optional options, can be used to override `defaultTimeoutMS`.
|
|
2234
2340
|
*/
|
|
2235
|
-
abortTransaction(
|
|
2341
|
+
abortTransaction(options?: {
|
|
2342
|
+
timeoutMS?: number;
|
|
2343
|
+
}): Promise<void>;
|
|
2344
|
+
/* Excluded from this release type: abortTransaction */
|
|
2236
2345
|
/**
|
|
2237
2346
|
* This is here to ensure that ClientSession is never serialized to BSON.
|
|
2238
2347
|
*/
|
|
@@ -2246,6 +2355,9 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2246
2355
|
* `Promise.allSettled`, `Promise.race`, etc to parallelize operations inside a transaction is
|
|
2247
2356
|
* undefined behaviour.
|
|
2248
2357
|
*
|
|
2358
|
+
* **IMPORTANT:** When running an operation inside a `withTransaction` callback, if it is not
|
|
2359
|
+
* provided the explicit session in its options, it will not be part of the transaction and it will not respect timeoutMS.
|
|
2360
|
+
*
|
|
2249
2361
|
*
|
|
2250
2362
|
* @remarks
|
|
2251
2363
|
* - If all operations successfully complete and the `commitTransaction` operation is successful, then the provided function will return the result of the provided function.
|
|
@@ -2269,7 +2381,16 @@ export declare class ClientSession extends TypedEventEmitter<ClientSessionEvents
|
|
|
2269
2381
|
* @param options - optional settings for the transaction
|
|
2270
2382
|
* @returns A raw command response or undefined
|
|
2271
2383
|
*/
|
|
2272
|
-
withTransaction<T = any>(fn: WithTransactionCallback<T>, options?: TransactionOptions
|
|
2384
|
+
withTransaction<T = any>(fn: WithTransactionCallback<T>, options?: TransactionOptions & {
|
|
2385
|
+
/**
|
|
2386
|
+
* Configures a timeoutMS expiry for the entire withTransactionCallback.
|
|
2387
|
+
*
|
|
2388
|
+
* @remarks
|
|
2389
|
+
* - The remaining timeout will not be applied to callback operations that do not use the ClientSession.
|
|
2390
|
+
* - Overriding timeoutMS for operations executed using the explicit session inside the provided callback will result in a client-side error.
|
|
2391
|
+
*/
|
|
2392
|
+
timeoutMS?: number;
|
|
2393
|
+
}): Promise<T>;
|
|
2273
2394
|
}
|
|
2274
2395
|
|
|
2275
2396
|
/** @public */
|
|
@@ -2285,7 +2406,13 @@ export declare interface ClientSessionOptions {
|
|
|
2285
2406
|
snapshot?: boolean;
|
|
2286
2407
|
/** The default TransactionOptions to use for transactions started on this session. */
|
|
2287
2408
|
defaultTransactionOptions?: TransactionOptions;
|
|
2288
|
-
|
|
2409
|
+
/**
|
|
2410
|
+
* @public
|
|
2411
|
+
* @experimental
|
|
2412
|
+
* An overriding timeoutMS value to use for a client-side timeout.
|
|
2413
|
+
* If not provided the session uses the timeoutMS specified on the MongoClient.
|
|
2414
|
+
*/
|
|
2415
|
+
defaultTimeoutMS?: number;
|
|
2289
2416
|
/* Excluded from this release type: owner */
|
|
2290
2417
|
/* Excluded from this release type: explicit */
|
|
2291
2418
|
/* Excluded from this release type: initialClusterTime */
|
|
@@ -2487,6 +2614,7 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2487
2614
|
/** The current index hint for the collection */
|
|
2488
2615
|
get hint(): Hint | undefined;
|
|
2489
2616
|
set hint(v: Hint | undefined);
|
|
2617
|
+
get timeoutMS(): number | undefined;
|
|
2490
2618
|
/**
|
|
2491
2619
|
* Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field,
|
|
2492
2620
|
* one will be added to each of the documents missing it by the driver, mutating the document. This behavior
|
|
@@ -2595,10 +2723,10 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2595
2723
|
*/
|
|
2596
2724
|
findOne(): Promise<WithId<TSchema> | null>;
|
|
2597
2725
|
findOne(filter: Filter<TSchema>): Promise<WithId<TSchema> | null>;
|
|
2598
|
-
findOne(filter: Filter<TSchema>, options: FindOptions): Promise<WithId<TSchema> | null>;
|
|
2726
|
+
findOne(filter: Filter<TSchema>, options: Omit<FindOptions, 'timeoutMode'>): Promise<WithId<TSchema> | null>;
|
|
2599
2727
|
findOne<T = TSchema>(): Promise<T | null>;
|
|
2600
2728
|
findOne<T = TSchema>(filter: Filter<TSchema>): Promise<T | null>;
|
|
2601
|
-
findOne<T = TSchema>(filter: Filter<TSchema>, options?: FindOptions): Promise<T | null>;
|
|
2729
|
+
findOne<T = TSchema>(filter: Filter<TSchema>, options?: Omit<FindOptions, 'timeoutMode'>): Promise<T | null>;
|
|
2602
2730
|
/**
|
|
2603
2731
|
* Creates a cursor for a filter that can be used to iterate over results from MongoDB
|
|
2604
2732
|
*
|
|
@@ -2869,6 +2997,59 @@ export declare class Collection<TSchema extends Document = Document> {
|
|
|
2869
2997
|
* });
|
|
2870
2998
|
* ```
|
|
2871
2999
|
*
|
|
3000
|
+
* @remarks
|
|
3001
|
+
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
3002
|
+
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
3003
|
+
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
3004
|
+
* event.
|
|
3005
|
+
*
|
|
3006
|
+
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
3007
|
+
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
3008
|
+
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
3009
|
+
* `timeoutMS`.
|
|
3010
|
+
*
|
|
3011
|
+
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
3012
|
+
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
3013
|
+
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
3014
|
+
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
3015
|
+
* emitter mode.
|
|
3016
|
+
*
|
|
3017
|
+
* To determine whether or not the change stream is still open following a timeout, check the
|
|
3018
|
+
* {@link ChangeStream.closed} getter.
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
3022
|
+
* The next call can just be retried after this succeeds.
|
|
3023
|
+
* ```ts
|
|
3024
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
3025
|
+
* try {
|
|
3026
|
+
* await changeStream.next();
|
|
3027
|
+
* } catch (e) {
|
|
3028
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
3029
|
+
* await changeStream.next();
|
|
3030
|
+
* }
|
|
3031
|
+
* throw e;
|
|
3032
|
+
* }
|
|
3033
|
+
* ```
|
|
3034
|
+
*
|
|
3035
|
+
* @example
|
|
3036
|
+
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
3037
|
+
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
3038
|
+
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
3039
|
+
* this will automatically continue emitting change events once the resume attempt completes.
|
|
3040
|
+
*
|
|
3041
|
+
* ```ts
|
|
3042
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
3043
|
+
* changeStream.on('change', console.log);
|
|
3044
|
+
* changeStream.on('error', e => {
|
|
3045
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
3046
|
+
* // do nothing
|
|
3047
|
+
* } else {
|
|
3048
|
+
* changeStream.close();
|
|
3049
|
+
* }
|
|
3050
|
+
* });
|
|
3051
|
+
* ```
|
|
3052
|
+
*
|
|
2872
3053
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
2873
3054
|
* @param options - Optional settings for the command
|
|
2874
3055
|
* @typeParam TLocal - Type of the data being detected by the change stream
|
|
@@ -2979,7 +3160,11 @@ export declare interface CollectionOptions extends BSONSerializeOptions, WriteCo
|
|
|
2979
3160
|
readConcern?: ReadConcernLike;
|
|
2980
3161
|
/** The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). */
|
|
2981
3162
|
readPreference?: ReadPreferenceLike;
|
|
2982
|
-
|
|
3163
|
+
/**
|
|
3164
|
+
* @experimental
|
|
3165
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
3166
|
+
*/
|
|
3167
|
+
timeoutMS?: number;
|
|
2983
3168
|
}
|
|
2984
3169
|
|
|
2985
3170
|
/* Excluded from this release type: CollectionPrivate */
|
|
@@ -3022,6 +3207,9 @@ export declare interface CommandOperationOptions extends OperationOptions, Write
|
|
|
3022
3207
|
readConcern?: ReadConcernLike;
|
|
3023
3208
|
/** Collation */
|
|
3024
3209
|
collation?: CollationOptions;
|
|
3210
|
+
/**
|
|
3211
|
+
* maxTimeMS is a server-side time limit in milliseconds for processing an operation.
|
|
3212
|
+
*/
|
|
3025
3213
|
maxTimeMS?: number;
|
|
3026
3214
|
/**
|
|
3027
3215
|
* Comment to apply to the operation.
|
|
@@ -3419,7 +3607,9 @@ export declare interface CountOptions extends CommandOperationOptions {
|
|
|
3419
3607
|
skip?: number;
|
|
3420
3608
|
/** The maximum amounts to count before aborting. */
|
|
3421
3609
|
limit?: number;
|
|
3422
|
-
/**
|
|
3610
|
+
/**
|
|
3611
|
+
* Number of milliseconds to wait before aborting the query.
|
|
3612
|
+
*/
|
|
3423
3613
|
maxTimeMS?: number;
|
|
3424
3614
|
/** An index name hint for the query. */
|
|
3425
3615
|
hint?: string | Document;
|
|
@@ -3516,6 +3706,10 @@ export declare type CSFLEKMSTlsOptions = {
|
|
|
3516
3706
|
[key: string]: ClientEncryptionTlsOptions | undefined;
|
|
3517
3707
|
};
|
|
3518
3708
|
|
|
3709
|
+
/* Excluded from this release type: CSOTTimeoutContext */
|
|
3710
|
+
|
|
3711
|
+
/* Excluded from this release type: CSOTTimeoutContextOptions */
|
|
3712
|
+
|
|
3519
3713
|
/** @public */
|
|
3520
3714
|
export declare const CURSOR_FLAGS: readonly ["tailable", "oplogReplay", "noCursorTimeout", "awaitData", "exhaust", "partial"];
|
|
3521
3715
|
|
|
@@ -3530,6 +3724,48 @@ export declare interface CursorStreamOptions {
|
|
|
3530
3724
|
transform?(this: void, doc: Document): Document;
|
|
3531
3725
|
}
|
|
3532
3726
|
|
|
3727
|
+
/* Excluded from this release type: CursorTimeoutContext */
|
|
3728
|
+
|
|
3729
|
+
/**
|
|
3730
|
+
* @public
|
|
3731
|
+
* @experimental
|
|
3732
|
+
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
|
|
3733
|
+
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
3734
|
+
* `cursor.next()`.
|
|
3735
|
+
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
3736
|
+
*
|
|
3737
|
+
* Depending on the type of cursor being used, this option has different default values.
|
|
3738
|
+
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
3739
|
+
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
3740
|
+
* definition can have an arbitrarily long lifetime.
|
|
3741
|
+
*
|
|
3742
|
+
* @example
|
|
3743
|
+
* ```ts
|
|
3744
|
+
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
3745
|
+
* for await (const doc of cursor) {
|
|
3746
|
+
* // process doc
|
|
3747
|
+
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
3748
|
+
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
3749
|
+
* }
|
|
3750
|
+
* ```
|
|
3751
|
+
*
|
|
3752
|
+
* @example
|
|
3753
|
+
* ```ts
|
|
3754
|
+
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
3755
|
+
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
3756
|
+
* ```
|
|
3757
|
+
*/
|
|
3758
|
+
export declare const CursorTimeoutMode: Readonly<{
|
|
3759
|
+
readonly ITERATION: "iteration";
|
|
3760
|
+
readonly LIFETIME: "cursorLifetime";
|
|
3761
|
+
}>;
|
|
3762
|
+
|
|
3763
|
+
/**
|
|
3764
|
+
* @public
|
|
3765
|
+
* @experimental
|
|
3766
|
+
*/
|
|
3767
|
+
export declare type CursorTimeoutMode = (typeof CursorTimeoutMode)[keyof typeof CursorTimeoutMode];
|
|
3768
|
+
|
|
3533
3769
|
/**
|
|
3534
3770
|
* @public
|
|
3535
3771
|
* The schema for a DataKey in the key vault collection.
|
|
@@ -3601,6 +3837,7 @@ export declare class Db {
|
|
|
3601
3837
|
get bsonOptions(): BSONSerializeOptions;
|
|
3602
3838
|
get writeConcern(): WriteConcern | undefined;
|
|
3603
3839
|
get namespace(): string;
|
|
3840
|
+
get timeoutMS(): number | undefined;
|
|
3604
3841
|
/**
|
|
3605
3842
|
* Create a new collection on a server with the specified options. Use this to create capped collections.
|
|
3606
3843
|
* More information about command options available at https://www.mongodb.com/docs/manual/reference/command/create/
|
|
@@ -3756,6 +3993,58 @@ export declare class Db {
|
|
|
3756
3993
|
* - The first is to provide the schema that may be defined for all the collections within this database
|
|
3757
3994
|
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
|
|
3758
3995
|
*
|
|
3996
|
+
* @remarks
|
|
3997
|
+
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
3998
|
+
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
3999
|
+
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
4000
|
+
* event.
|
|
4001
|
+
*
|
|
4002
|
+
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
4003
|
+
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
4004
|
+
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
4005
|
+
* `timeoutMS`.
|
|
4006
|
+
*
|
|
4007
|
+
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
4008
|
+
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
4009
|
+
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
4010
|
+
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
4011
|
+
* emitter mode.
|
|
4012
|
+
*
|
|
4013
|
+
* To determine whether or not the change stream is still open following a timeout, check the
|
|
4014
|
+
* {@link ChangeStream.closed} getter.
|
|
4015
|
+
*
|
|
4016
|
+
* @example
|
|
4017
|
+
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
4018
|
+
* The next call can just be retried after this succeeds.
|
|
4019
|
+
* ```ts
|
|
4020
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
4021
|
+
* try {
|
|
4022
|
+
* await changeStream.next();
|
|
4023
|
+
* } catch (e) {
|
|
4024
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
4025
|
+
* await changeStream.next();
|
|
4026
|
+
* }
|
|
4027
|
+
* throw e;
|
|
4028
|
+
* }
|
|
4029
|
+
* ```
|
|
4030
|
+
*
|
|
4031
|
+
* @example
|
|
4032
|
+
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
4033
|
+
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
4034
|
+
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
4035
|
+
* this will automatically continue emitting change events once the resume attempt completes.
|
|
4036
|
+
*
|
|
4037
|
+
* ```ts
|
|
4038
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
4039
|
+
* changeStream.on('change', console.log);
|
|
4040
|
+
* changeStream.on('error', e => {
|
|
4041
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
4042
|
+
* // do nothing
|
|
4043
|
+
* } else {
|
|
4044
|
+
* changeStream.close();
|
|
4045
|
+
* }
|
|
4046
|
+
* });
|
|
4047
|
+
* ```
|
|
3759
4048
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
3760
4049
|
* @param options - Optional settings for the command
|
|
3761
4050
|
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
@@ -3790,7 +4079,11 @@ export declare interface DbOptions extends BSONSerializeOptions, WriteConcernOpt
|
|
|
3790
4079
|
readConcern?: ReadConcern;
|
|
3791
4080
|
/** Should retry failed writes */
|
|
3792
4081
|
retryWrites?: boolean;
|
|
3793
|
-
|
|
4082
|
+
/**
|
|
4083
|
+
* @experimental
|
|
4084
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
4085
|
+
*/
|
|
4086
|
+
timeoutMS?: number;
|
|
3794
4087
|
}
|
|
3795
4088
|
|
|
3796
4089
|
/* Excluded from this release type: DbPrivate */
|
|
@@ -3893,6 +4186,8 @@ export declare interface EndSessionOptions {
|
|
|
3893
4186
|
/* Excluded from this release type: error */
|
|
3894
4187
|
force?: boolean;
|
|
3895
4188
|
forceClear?: boolean;
|
|
4189
|
+
/** Specifies the time an operation will run until it throws a timeout error */
|
|
4190
|
+
timeoutMS?: number;
|
|
3896
4191
|
}
|
|
3897
4192
|
|
|
3898
4193
|
/** TypeScript Omit (Exclude to be specific) does not work for objects with an "any" indexed type, and breaks discriminated unions @public */
|
|
@@ -3930,6 +4225,38 @@ export declare type EventsDescription = Record<string, GenericListener>;
|
|
|
3930
4225
|
|
|
3931
4226
|
/* Excluded from this release type: Explain */
|
|
3932
4227
|
|
|
4228
|
+
/**
|
|
4229
|
+
* @public
|
|
4230
|
+
*
|
|
4231
|
+
* A base class for any cursors that have `explain()` methods.
|
|
4232
|
+
*/
|
|
4233
|
+
export declare abstract class ExplainableCursor<TSchema> extends AbstractCursor<TSchema> {
|
|
4234
|
+
/** Execute the explain for the cursor */
|
|
4235
|
+
abstract explain(): Promise<Document>;
|
|
4236
|
+
abstract explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document>;
|
|
4237
|
+
abstract explain(options: {
|
|
4238
|
+
timeoutMS?: number;
|
|
4239
|
+
}): Promise<Document>;
|
|
4240
|
+
abstract explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions, options: {
|
|
4241
|
+
timeoutMS?: number;
|
|
4242
|
+
}): Promise<Document>;
|
|
4243
|
+
abstract explain(verbosity?: ExplainVerbosityLike | ExplainCommandOptions | {
|
|
4244
|
+
timeoutMS?: number;
|
|
4245
|
+
}, options?: {
|
|
4246
|
+
timeoutMS?: number;
|
|
4247
|
+
}): Promise<Document>;
|
|
4248
|
+
protected resolveExplainTimeoutOptions(verbosity?: ExplainVerbosityLike | ExplainCommandOptions | {
|
|
4249
|
+
timeoutMS?: number;
|
|
4250
|
+
}, options?: {
|
|
4251
|
+
timeoutMS?: number;
|
|
4252
|
+
}): {
|
|
4253
|
+
timeout?: {
|
|
4254
|
+
timeoutMS?: number;
|
|
4255
|
+
};
|
|
4256
|
+
explain?: ExplainVerbosityLike | ExplainCommandOptions;
|
|
4257
|
+
};
|
|
4258
|
+
}
|
|
4259
|
+
|
|
3933
4260
|
/** @public */
|
|
3934
4261
|
export declare interface ExplainCommandOptions {
|
|
3935
4262
|
/** The explain verbosity for the command. */
|
|
@@ -4040,7 +4367,7 @@ export declare interface FilterOperators<TValue> extends NonObjectIdLikeDocument
|
|
|
4040
4367
|
}
|
|
4041
4368
|
|
|
4042
4369
|
/** @public */
|
|
4043
|
-
export declare class FindCursor<TSchema = any> extends
|
|
4370
|
+
export declare class FindCursor<TSchema = any> extends ExplainableCursor<TSchema> {
|
|
4044
4371
|
/* Excluded from this release type: cursorFilter */
|
|
4045
4372
|
/* Excluded from this release type: numReturned */
|
|
4046
4373
|
/* Excluded from this release type: findOptions */
|
|
@@ -4055,7 +4382,14 @@ export declare class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
|
|
|
4055
4382
|
*/
|
|
4056
4383
|
count(options?: CountOptions): Promise<number>;
|
|
4057
4384
|
/** Execute the explain for the cursor */
|
|
4058
|
-
explain(
|
|
4385
|
+
explain(): Promise<Document>;
|
|
4386
|
+
explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions): Promise<Document>;
|
|
4387
|
+
explain(options: {
|
|
4388
|
+
timeoutMS?: number;
|
|
4389
|
+
}): Promise<Document>;
|
|
4390
|
+
explain(verbosity: ExplainVerbosityLike | ExplainCommandOptions, options: {
|
|
4391
|
+
timeoutMS?: number;
|
|
4392
|
+
}): Promise<Document>;
|
|
4059
4393
|
/** Set the cursor query */
|
|
4060
4394
|
filter(filter: Document): this;
|
|
4061
4395
|
/**
|
|
@@ -4285,7 +4619,7 @@ export declare class FindOperators {
|
|
|
4285
4619
|
* @public
|
|
4286
4620
|
* @typeParam TSchema - Unused schema definition, deprecated usage, only specify `FindOptions` with no generic
|
|
4287
4621
|
*/
|
|
4288
|
-
export declare interface FindOptions<TSchema extends Document = Document> extends Omit<CommandOperationOptions, 'writeConcern' | 'explain'
|
|
4622
|
+
export declare interface FindOptions<TSchema extends Document = Document> extends Omit<CommandOperationOptions, 'writeConcern' | 'explain'>, AbstractCursorOptions {
|
|
4289
4623
|
/** Sets the limit of documents returned in the query. */
|
|
4290
4624
|
limit?: number;
|
|
4291
4625
|
/** Set to sort the documents coming back from the query. Array of indexes, `[['a', 1]]` etc. */
|
|
@@ -4338,6 +4672,7 @@ export declare interface FindOptions<TSchema extends Document = Document> extend
|
|
|
4338
4672
|
* @deprecated This API is deprecated in favor of `collection.find().explain()`.
|
|
4339
4673
|
*/
|
|
4340
4674
|
explain?: ExplainOptions['explain'];
|
|
4675
|
+
/* Excluded from this release type: timeoutMode */
|
|
4341
4676
|
}
|
|
4342
4677
|
|
|
4343
4678
|
/** @public */
|
|
@@ -4437,7 +4772,9 @@ export declare class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents>
|
|
|
4437
4772
|
*
|
|
4438
4773
|
* @param id - The id of the file doc
|
|
4439
4774
|
*/
|
|
4440
|
-
delete(id: ObjectId
|
|
4775
|
+
delete(id: ObjectId, options?: {
|
|
4776
|
+
timeoutMS: number;
|
|
4777
|
+
}): Promise<void>;
|
|
4441
4778
|
/** Convenience wrapper around find on the files collection */
|
|
4442
4779
|
find(filter?: Filter<GridFSFile>, options?: FindOptions): FindCursor<GridFSFile>;
|
|
4443
4780
|
/**
|
|
@@ -4454,9 +4791,13 @@ export declare class GridFSBucket extends TypedEventEmitter<GridFSBucketEvents>
|
|
|
4454
4791
|
* @param id - the id of the file to rename
|
|
4455
4792
|
* @param filename - new name for the file
|
|
4456
4793
|
*/
|
|
4457
|
-
rename(id: ObjectId, filename: string
|
|
4794
|
+
rename(id: ObjectId, filename: string, options?: {
|
|
4795
|
+
timeoutMS: number;
|
|
4796
|
+
}): Promise<void>;
|
|
4458
4797
|
/** Removes this bucket's files collection, followed by its chunks collection. */
|
|
4459
|
-
drop(
|
|
4798
|
+
drop(options?: {
|
|
4799
|
+
timeoutMS: number;
|
|
4800
|
+
}): Promise<void>;
|
|
4460
4801
|
}
|
|
4461
4802
|
|
|
4462
4803
|
/** @public */
|
|
@@ -4472,7 +4813,12 @@ export declare interface GridFSBucketOptions extends WriteConcernOptions {
|
|
|
4472
4813
|
chunkSizeBytes?: number;
|
|
4473
4814
|
/** Read preference to be passed to read operations */
|
|
4474
4815
|
readPreference?: ReadPreference;
|
|
4475
|
-
|
|
4816
|
+
/**
|
|
4817
|
+
* @experimental
|
|
4818
|
+
* Specifies the lifetime duration of a gridFS stream. If any async operations are in progress
|
|
4819
|
+
* when this timeout expires, the stream will throw a timeout error.
|
|
4820
|
+
*/
|
|
4821
|
+
timeoutMS?: number;
|
|
4476
4822
|
}
|
|
4477
4823
|
|
|
4478
4824
|
/* Excluded from this release type: GridFSBucketPrivate */
|
|
@@ -4529,7 +4875,11 @@ export declare interface GridFSBucketReadStreamOptions {
|
|
|
4529
4875
|
* to be returned by the stream. `end` is non-inclusive
|
|
4530
4876
|
*/
|
|
4531
4877
|
end?: number;
|
|
4532
|
-
|
|
4878
|
+
/**
|
|
4879
|
+
* @experimental
|
|
4880
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
4881
|
+
*/
|
|
4882
|
+
timeoutMS?: number;
|
|
4533
4883
|
}
|
|
4534
4884
|
|
|
4535
4885
|
/** @public */
|
|
@@ -4600,6 +4950,7 @@ export declare class GridFSBucketWriteStream extends Writable {
|
|
|
4600
4950
|
* ```
|
|
4601
4951
|
*/
|
|
4602
4952
|
gridFSFile: GridFSFile | null;
|
|
4953
|
+
/* Excluded from this release type: timeoutContext */
|
|
4603
4954
|
/* Excluded from this release type: __constructor */
|
|
4604
4955
|
/* Excluded from this release type: _construct */
|
|
4605
4956
|
/* Excluded from this release type: _write */
|
|
@@ -4629,7 +4980,11 @@ export declare interface GridFSBucketWriteStreamOptions extends WriteConcernOpti
|
|
|
4629
4980
|
* @deprecated Will be removed in the next major version. Add an aliases field to the metadata document instead.
|
|
4630
4981
|
*/
|
|
4631
4982
|
aliases?: string[];
|
|
4632
|
-
|
|
4983
|
+
/**
|
|
4984
|
+
* @experimental
|
|
4985
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
4986
|
+
*/
|
|
4987
|
+
timeoutMS?: number;
|
|
4633
4988
|
}
|
|
4634
4989
|
|
|
4635
4990
|
/** @public */
|
|
@@ -4986,6 +5341,10 @@ export declare interface KMSProviders {
|
|
|
4986
5341
|
|
|
4987
5342
|
/* Excluded from this release type: kWaitQueue_2 */
|
|
4988
5343
|
|
|
5344
|
+
/* Excluded from this release type: LegacyTimeoutContext */
|
|
5345
|
+
|
|
5346
|
+
/* Excluded from this release type: LegacyTimeoutContextOptions */
|
|
5347
|
+
|
|
4989
5348
|
/** @public */
|
|
4990
5349
|
export declare const LEGAL_TCP_SOCKET_OPTIONS: readonly ["autoSelectFamily", "autoSelectFamilyAttemptTimeout", "family", "hints", "localAddress", "localPort", "lookup"];
|
|
4991
5350
|
|
|
@@ -5012,6 +5371,8 @@ export declare interface ListCollectionsOptions extends Omit<CommandOperationOpt
|
|
|
5012
5371
|
authorizedCollections?: boolean;
|
|
5013
5372
|
/** The batchSize for the returned command cursor or if pre 2.8 the systems batch collection */
|
|
5014
5373
|
batchSize?: number;
|
|
5374
|
+
/* Excluded from this release type: timeoutMode */
|
|
5375
|
+
/* Excluded from this release type: timeoutContext */
|
|
5015
5376
|
}
|
|
5016
5377
|
|
|
5017
5378
|
/** @public */
|
|
@@ -5046,7 +5407,9 @@ export declare class ListIndexesCursor extends AbstractCursor {
|
|
|
5046
5407
|
}
|
|
5047
5408
|
|
|
5048
5409
|
/** @public */
|
|
5049
|
-
export declare type ListIndexesOptions = AbstractCursorOptions
|
|
5410
|
+
export declare type ListIndexesOptions = AbstractCursorOptions & {
|
|
5411
|
+
/* Excluded from this release type: omitMaxTimeMS */
|
|
5412
|
+
};
|
|
5050
5413
|
|
|
5051
5414
|
/** @public */
|
|
5052
5415
|
export declare class ListSearchIndexesCursor extends AggregationCursor<{
|
|
@@ -5316,6 +5679,7 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5316
5679
|
get writeConcern(): WriteConcern | undefined;
|
|
5317
5680
|
get readPreference(): ReadPreference;
|
|
5318
5681
|
get bsonOptions(): BSONSerializeOptions;
|
|
5682
|
+
get timeoutMS(): number | undefined;
|
|
5319
5683
|
/**
|
|
5320
5684
|
* Executes a client bulk write operation, available on server 8.0+.
|
|
5321
5685
|
* @param models - The client bulk write models.
|
|
@@ -5326,6 +5690,13 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5326
5690
|
/**
|
|
5327
5691
|
* Connect to MongoDB using a url
|
|
5328
5692
|
*
|
|
5693
|
+
* @remarks
|
|
5694
|
+
* Calling `connect` is optional since the first operation you perform will call `connect` if it's needed.
|
|
5695
|
+
* `timeoutMS` will bound the time any operation can take before throwing a timeout error.
|
|
5696
|
+
* However, when the operation being run is automatically connecting your `MongoClient` the `timeoutMS` will not apply to the time taken to connect the MongoClient.
|
|
5697
|
+
* This means the time to setup the `MongoClient` does not count against `timeoutMS`.
|
|
5698
|
+
* If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
|
|
5699
|
+
*
|
|
5329
5700
|
* @see docs.mongodb.org/manual/reference/connection-string/
|
|
5330
5701
|
*/
|
|
5331
5702
|
connect(): Promise<this>;
|
|
@@ -5355,6 +5726,13 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5355
5726
|
* Connect to MongoDB using a url
|
|
5356
5727
|
*
|
|
5357
5728
|
* @remarks
|
|
5729
|
+
* Calling `connect` is optional since the first operation you perform will call `connect` if it's needed.
|
|
5730
|
+
* `timeoutMS` will bound the time any operation can take before throwing a timeout error.
|
|
5731
|
+
* However, when the operation being run is automatically connecting your `MongoClient` the `timeoutMS` will not apply to the time taken to connect the MongoClient.
|
|
5732
|
+
* This means the time to setup the `MongoClient` does not count against `timeoutMS`.
|
|
5733
|
+
* If you are using `timeoutMS` we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
|
|
5734
|
+
*
|
|
5735
|
+
* @remarks
|
|
5358
5736
|
* The programmatically provided options take precedence over the URI options.
|
|
5359
5737
|
*
|
|
5360
5738
|
* @see https://www.mongodb.com/docs/manual/reference/connection-string/
|
|
@@ -5388,6 +5766,58 @@ export declare class MongoClient extends TypedEventEmitter<MongoClientEvents> im
|
|
|
5388
5766
|
* - The first is to provide the schema that may be defined for all the data within the current cluster
|
|
5389
5767
|
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
|
|
5390
5768
|
*
|
|
5769
|
+
* @remarks
|
|
5770
|
+
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
|
|
5771
|
+
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
|
|
5772
|
+
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
|
|
5773
|
+
* event.
|
|
5774
|
+
*
|
|
5775
|
+
* Note that if a change stream is consistently timing out when watching a collection, database or
|
|
5776
|
+
* client that is being changed, then this may be due to the server timing out before it can finish
|
|
5777
|
+
* processing the existing oplog. To address this, restart the change stream with a higher
|
|
5778
|
+
* `timeoutMS`.
|
|
5779
|
+
*
|
|
5780
|
+
* If the change stream times out the initial aggregate operation to establish the change stream on
|
|
5781
|
+
* the server, then the client will close the change stream. If the getMore calls to the server
|
|
5782
|
+
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
|
|
5783
|
+
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
|
|
5784
|
+
* emitter mode.
|
|
5785
|
+
*
|
|
5786
|
+
* To determine whether or not the change stream is still open following a timeout, check the
|
|
5787
|
+
* {@link ChangeStream.closed} getter.
|
|
5788
|
+
*
|
|
5789
|
+
* @example
|
|
5790
|
+
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
|
|
5791
|
+
* The next call can just be retried after this succeeds.
|
|
5792
|
+
* ```ts
|
|
5793
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
5794
|
+
* try {
|
|
5795
|
+
* await changeStream.next();
|
|
5796
|
+
* } catch (e) {
|
|
5797
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
5798
|
+
* await changeStream.next();
|
|
5799
|
+
* }
|
|
5800
|
+
* throw e;
|
|
5801
|
+
* }
|
|
5802
|
+
* ```
|
|
5803
|
+
*
|
|
5804
|
+
* @example
|
|
5805
|
+
* In emitter mode, if the change stream goes `timeoutMS` without emitting a change event, it will
|
|
5806
|
+
* emit an error event that returns a MongoOperationTimeoutError, but will not close the change
|
|
5807
|
+
* stream unless the resume attempt fails. There is no need to re-establish change listeners as
|
|
5808
|
+
* this will automatically continue emitting change events once the resume attempt completes.
|
|
5809
|
+
*
|
|
5810
|
+
* ```ts
|
|
5811
|
+
* const changeStream = collection.watch([], { timeoutMS: 100 });
|
|
5812
|
+
* changeStream.on('change', console.log);
|
|
5813
|
+
* changeStream.on('error', e => {
|
|
5814
|
+
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
|
|
5815
|
+
* // do nothing
|
|
5816
|
+
* } else {
|
|
5817
|
+
* changeStream.close();
|
|
5818
|
+
* }
|
|
5819
|
+
* });
|
|
5820
|
+
* ```
|
|
5391
5821
|
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
|
|
5392
5822
|
* @param options - Optional settings for the command
|
|
5393
5823
|
* @typeParam TSchema - Type of the data being detected by the change stream
|
|
@@ -5485,7 +5915,11 @@ export declare type MongoClientEvents = Pick<TopologyEvents, (typeof MONGO_CLIEN
|
|
|
5485
5915
|
export declare interface MongoClientOptions extends BSONSerializeOptions, SupportedNodeConnectionOptions {
|
|
5486
5916
|
/** Specifies the name of the replica set, if the mongod is a member of a replica set. */
|
|
5487
5917
|
replicaSet?: string;
|
|
5488
|
-
|
|
5918
|
+
/**
|
|
5919
|
+
* @experimental
|
|
5920
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
5921
|
+
*/
|
|
5922
|
+
timeoutMS?: number;
|
|
5489
5923
|
/** Enables or disables TLS/SSL for the connection. */
|
|
5490
5924
|
tls?: boolean;
|
|
5491
5925
|
/** A boolean to enable or disables TLS/SSL for the connection. (The ssl option is equivalent to the tls option.) */
|
|
@@ -5605,7 +6039,7 @@ export declare interface MongoClientOptions extends BSONSerializeOptions, Suppor
|
|
|
5605
6039
|
*
|
|
5606
6040
|
* @remarks
|
|
5607
6041
|
* Automatic encryption is an enterprise only feature that only applies to operations on a collection. Automatic encryption is not supported for operations on a database or view, and operations that are not bypassed will result in error
|
|
5608
|
-
* (see [libmongocrypt: Auto Encryption Allow-List](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.
|
|
6042
|
+
* (see [libmongocrypt: Auto Encryption Allow-List](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md#libmongocrypt-auto-encryption-allow-list)). To bypass automatic encryption for all operations, set bypassAutoEncryption=true in AutoEncryptionOpts.
|
|
5609
6043
|
*
|
|
5610
6044
|
* Automatic encryption requires the authenticated user to have the [listCollections privilege action](https://www.mongodb.com/docs/manual/reference/command/listCollections/#dbcmd.listCollections).
|
|
5611
6045
|
*
|
|
@@ -6309,6 +6743,29 @@ export declare class MongoOIDCError extends MongoRuntimeError {
|
|
|
6309
6743
|
get name(): string;
|
|
6310
6744
|
}
|
|
6311
6745
|
|
|
6746
|
+
/**
|
|
6747
|
+
* @public
|
|
6748
|
+
* @category Error
|
|
6749
|
+
*
|
|
6750
|
+
* The `MongoOperationTimeoutError` class represents an error that occurs when an operation could not be completed within the specified `timeoutMS`.
|
|
6751
|
+
* It is generated by the driver in support of the "client side operation timeout" feature so inherits from `MongoDriverError`.
|
|
6752
|
+
* When `timeoutMS` is enabled `MongoServerError`s relating to `MaxTimeExpired` errors will be converted to `MongoOperationTimeoutError`
|
|
6753
|
+
*
|
|
6754
|
+
* @example
|
|
6755
|
+
* ```ts
|
|
6756
|
+
* try {
|
|
6757
|
+
* await blogs.insertOne(blogPost, { timeoutMS: 60_000 })
|
|
6758
|
+
* } catch (error) {
|
|
6759
|
+
* if (error instanceof MongoOperationTimeoutError) {
|
|
6760
|
+
* console.log(`Oh no! writer's block!`, error);
|
|
6761
|
+
* }
|
|
6762
|
+
* }
|
|
6763
|
+
* ```
|
|
6764
|
+
*/
|
|
6765
|
+
export declare class MongoOperationTimeoutError extends MongoDriverError {
|
|
6766
|
+
get name(): string;
|
|
6767
|
+
}
|
|
6768
|
+
|
|
6312
6769
|
/**
|
|
6313
6770
|
* Parsed Mongo Client Options.
|
|
6314
6771
|
*
|
|
@@ -6397,7 +6854,7 @@ export declare interface MongoOptions extends Required<Pick<MongoClientOptions,
|
|
|
6397
6854
|
/* Excluded from this release type: __index */
|
|
6398
6855
|
/* Excluded from this release type: mongoLoggerOptions */
|
|
6399
6856
|
/* Excluded from this release type: mongodbLogPath */
|
|
6400
|
-
|
|
6857
|
+
timeoutMS?: number;
|
|
6401
6858
|
}
|
|
6402
6859
|
|
|
6403
6860
|
/**
|
|
@@ -6423,7 +6880,7 @@ export declare class MongoParseError extends MongoDriverError {
|
|
|
6423
6880
|
|
|
6424
6881
|
/**
|
|
6425
6882
|
* An error generated when the driver encounters unexpected input
|
|
6426
|
-
* or reaches an unexpected/invalid internal state
|
|
6883
|
+
* or reaches an unexpected/invalid internal state.
|
|
6427
6884
|
*
|
|
6428
6885
|
* @privateRemarks
|
|
6429
6886
|
* Should **never** be directly instantiated.
|
|
@@ -6811,7 +7268,12 @@ export declare interface OperationOptions extends BSONSerializeOptions {
|
|
|
6811
7268
|
readPreference?: ReadPreferenceLike;
|
|
6812
7269
|
/* Excluded from this release type: bypassPinningCheck */
|
|
6813
7270
|
omitReadPreference?: boolean;
|
|
6814
|
-
/* Excluded from this release type:
|
|
7271
|
+
/* Excluded from this release type: omitMaxTimeMS */
|
|
7272
|
+
/**
|
|
7273
|
+
* @experimental
|
|
7274
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
7275
|
+
*/
|
|
7276
|
+
timeoutMS?: number;
|
|
6815
7277
|
}
|
|
6816
7278
|
|
|
6817
7279
|
/* Excluded from this release type: OperationParent */
|
|
@@ -7200,7 +7662,7 @@ export declare class RunCommandCursor extends AbstractCursor {
|
|
|
7200
7662
|
setMaxTimeMS(maxTimeMS: number): this;
|
|
7201
7663
|
/**
|
|
7202
7664
|
* Controls the `getMore.batchSize` field
|
|
7203
|
-
* @param
|
|
7665
|
+
* @param batchSize - the number documents to return in the `nextBatch`
|
|
7204
7666
|
*/
|
|
7205
7667
|
setBatchSize(batchSize: number): this;
|
|
7206
7668
|
/** Unsupported for RunCommandCursor */
|
|
@@ -7209,7 +7671,9 @@ export declare class RunCommandCursor extends AbstractCursor {
|
|
|
7209
7671
|
withReadConcern(_: ReadConcernLike): never;
|
|
7210
7672
|
/** Unsupported for RunCommandCursor: various cursor flags must be configured directly on command document */
|
|
7211
7673
|
addCursorFlag(_: string, __: boolean): never;
|
|
7212
|
-
/**
|
|
7674
|
+
/**
|
|
7675
|
+
* Unsupported for RunCommandCursor: maxTimeMS must be configured directly on command document
|
|
7676
|
+
*/
|
|
7213
7677
|
maxTimeMS(_: number): never;
|
|
7214
7678
|
/** Unsupported for RunCommandCursor: batchSize must be configured directly on command document */
|
|
7215
7679
|
batchSize(_: number): never;
|
|
@@ -7225,12 +7689,57 @@ export declare type RunCommandOptions = {
|
|
|
7225
7689
|
session?: ClientSession;
|
|
7226
7690
|
/** The read preference */
|
|
7227
7691
|
readPreference?: ReadPreferenceLike;
|
|
7692
|
+
/**
|
|
7693
|
+
* @experimental
|
|
7694
|
+
* Specifies the time an operation will run until it throws a timeout error
|
|
7695
|
+
*/
|
|
7696
|
+
timeoutMS?: number;
|
|
7697
|
+
/* Excluded from this release type: omitMaxTimeMS */
|
|
7228
7698
|
} & BSONSerializeOptions;
|
|
7229
7699
|
|
|
7230
7700
|
/** @public */
|
|
7231
7701
|
export declare type RunCursorCommandOptions = {
|
|
7232
7702
|
readPreference?: ReadPreferenceLike;
|
|
7233
7703
|
session?: ClientSession;
|
|
7704
|
+
/**
|
|
7705
|
+
* @experimental
|
|
7706
|
+
* Specifies the time an operation will run until it throws a timeout error. Note that if
|
|
7707
|
+
* `maxTimeMS` is provided in the command in addition to setting `timeoutMS` in the options, then
|
|
7708
|
+
* the original value of `maxTimeMS` will be overwritten.
|
|
7709
|
+
*/
|
|
7710
|
+
timeoutMS?: number;
|
|
7711
|
+
/**
|
|
7712
|
+
* @public
|
|
7713
|
+
* @experimental
|
|
7714
|
+
* Specifies how `timeoutMS` is applied to the cursor. Can be either `'cursorLifeTime'` or `'iteration'`
|
|
7715
|
+
* When set to `'iteration'`, the deadline specified by `timeoutMS` applies to each call of
|
|
7716
|
+
* `cursor.next()`.
|
|
7717
|
+
* When set to `'cursorLifetime'`, the deadline applies to the life of the entire cursor.
|
|
7718
|
+
*
|
|
7719
|
+
* Depending on the type of cursor being used, this option has different default values.
|
|
7720
|
+
* For non-tailable cursors, this value defaults to `'cursorLifetime'`
|
|
7721
|
+
* For tailable cursors, this value defaults to `'iteration'` since tailable cursors, by
|
|
7722
|
+
* definition can have an arbitrarily long lifetime.
|
|
7723
|
+
*
|
|
7724
|
+
* @example
|
|
7725
|
+
* ```ts
|
|
7726
|
+
* const cursor = collection.find({}, {timeoutMS: 100, timeoutMode: 'iteration'});
|
|
7727
|
+
* for await (const doc of cursor) {
|
|
7728
|
+
* // process doc
|
|
7729
|
+
* // This will throw a timeout error if any of the iterator's `next()` calls takes more than 100ms, but
|
|
7730
|
+
* // will continue to iterate successfully otherwise, regardless of the number of batches.
|
|
7731
|
+
* }
|
|
7732
|
+
* ```
|
|
7733
|
+
*
|
|
7734
|
+
* @example
|
|
7735
|
+
* ```ts
|
|
7736
|
+
* const cursor = collection.find({}, { timeoutMS: 1000, timeoutMode: 'cursorLifetime' });
|
|
7737
|
+
* const docs = await cursor.toArray(); // This entire line will throw a timeout error if all batches are not fetched and returned within 1000ms.
|
|
7738
|
+
* ```
|
|
7739
|
+
*/
|
|
7740
|
+
timeoutMode?: CursorTimeoutMode;
|
|
7741
|
+
tailable?: boolean;
|
|
7742
|
+
awaitData?: boolean;
|
|
7234
7743
|
} & BSONSerializeOptions;
|
|
7235
7744
|
|
|
7236
7745
|
/** @public */
|
|
@@ -7260,7 +7769,7 @@ export declare interface SelectServerOptions {
|
|
|
7260
7769
|
session?: ClientSession;
|
|
7261
7770
|
operationName: string;
|
|
7262
7771
|
previousServer?: ServerDescription;
|
|
7263
|
-
/* Excluded from this release type:
|
|
7772
|
+
/* Excluded from this release type: timeoutContext */
|
|
7264
7773
|
}
|
|
7265
7774
|
|
|
7266
7775
|
export { serialize }
|
|
@@ -7330,6 +7839,8 @@ export declare class ServerClosedEvent {
|
|
|
7330
7839
|
/* Excluded from this release type: __constructor */
|
|
7331
7840
|
}
|
|
7332
7841
|
|
|
7842
|
+
/* Excluded from this release type: ServerCommandOptions */
|
|
7843
|
+
|
|
7333
7844
|
/**
|
|
7334
7845
|
* The client's view of a single server, based on the most recent hello outcome.
|
|
7335
7846
|
*
|
|
@@ -7364,6 +7875,8 @@ export declare class ServerDescription {
|
|
|
7364
7875
|
maxWriteBatchSize: number | null;
|
|
7365
7876
|
/** The max bson object size. */
|
|
7366
7877
|
maxBsonObjectSize: number | null;
|
|
7878
|
+
/** Indicates server is a mongocryptd instance. */
|
|
7879
|
+
iscryptd: boolean;
|
|
7367
7880
|
$clusterTime?: ClusterTime;
|
|
7368
7881
|
/* Excluded from this release type: __constructor */
|
|
7369
7882
|
get hostAddress(): HostAddress;
|
|
@@ -7377,8 +7890,8 @@ export declare class ServerDescription {
|
|
|
7377
7890
|
get host(): string;
|
|
7378
7891
|
get port(): number;
|
|
7379
7892
|
/**
|
|
7380
|
-
* Determines if another `ServerDescription` is equal to this one per the rules defined
|
|
7381
|
-
*
|
|
7893
|
+
* Determines if another `ServerDescription` is equal to this one per the rules defined in the SDAM specification.
|
|
7894
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.md
|
|
7382
7895
|
*/
|
|
7383
7896
|
equals(other?: ServerDescription | null): boolean;
|
|
7384
7897
|
}
|
|
@@ -7525,7 +8038,6 @@ export declare class ServerSession {
|
|
|
7525
8038
|
* @param sessionTimeoutMinutes - The server's "logicalSessionTimeoutMinutes"
|
|
7526
8039
|
*/
|
|
7527
8040
|
hasTimedOut(sessionTimeoutMinutes: number): boolean;
|
|
7528
|
-
/* Excluded from this release type: clone */
|
|
7529
8041
|
}
|
|
7530
8042
|
|
|
7531
8043
|
/** @public */
|
|
@@ -7699,7 +8211,9 @@ export declare type TagSet = {
|
|
|
7699
8211
|
|
|
7700
8212
|
/* Excluded from this release type: Timeout */
|
|
7701
8213
|
|
|
7702
|
-
/* Excluded from this release type:
|
|
8214
|
+
/* Excluded from this release type: TimeoutContext */
|
|
8215
|
+
|
|
8216
|
+
/* Excluded from this release type: TimeoutContextOptions */
|
|
7703
8217
|
|
|
7704
8218
|
/** @public
|
|
7705
8219
|
* Configuration options for timeseries collections
|
|
@@ -7883,7 +8397,7 @@ export declare class Transaction {
|
|
|
7883
8397
|
* Configuration options for a transaction.
|
|
7884
8398
|
* @public
|
|
7885
8399
|
*/
|
|
7886
|
-
export declare interface TransactionOptions extends CommandOperationOptions {
|
|
8400
|
+
export declare interface TransactionOptions extends Omit<CommandOperationOptions, 'timeoutMS'> {
|
|
7887
8401
|
/** A default read concern for commands in this transaction */
|
|
7888
8402
|
readConcern?: ReadConcernLike;
|
|
7889
8403
|
/** A default writeConcern for commands in this transaction */
|
|
@@ -8162,7 +8676,9 @@ export declare class WriteConcern {
|
|
|
8162
8676
|
readonly w?: W;
|
|
8163
8677
|
/** Request acknowledgment that the write operation has been written to the on-disk journal */
|
|
8164
8678
|
readonly journal?: boolean;
|
|
8165
|
-
/**
|
|
8679
|
+
/**
|
|
8680
|
+
* Specify a time limit to prevent write operations from blocking indefinitely.
|
|
8681
|
+
*/
|
|
8166
8682
|
readonly wtimeoutMS?: number;
|
|
8167
8683
|
/**
|
|
8168
8684
|
* Specify a time limit to prevent write operations from blocking indefinitely.
|
|
@@ -8247,7 +8763,9 @@ export declare interface WriteConcernOptions {
|
|
|
8247
8763
|
export declare interface WriteConcernSettings {
|
|
8248
8764
|
/** The write concern */
|
|
8249
8765
|
w?: W;
|
|
8250
|
-
/**
|
|
8766
|
+
/**
|
|
8767
|
+
* The write concern timeout.
|
|
8768
|
+
*/
|
|
8251
8769
|
wtimeoutMS?: number;
|
|
8252
8770
|
/** The journal write concern */
|
|
8253
8771
|
journal?: boolean;
|
|
@@ -8258,7 +8776,6 @@ export declare interface WriteConcernSettings {
|
|
|
8258
8776
|
j?: boolean;
|
|
8259
8777
|
/**
|
|
8260
8778
|
* The write concern timeout.
|
|
8261
|
-
* @deprecated Will be removed in the next major version. Please use the wtimeoutMS option.
|
|
8262
8779
|
*/
|
|
8263
8780
|
wtimeout?: number;
|
|
8264
8781
|
/**
|