mongodb 5.0.1 → 5.2.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 +25 -22
- package/lib/bson.js +3 -1
- package/lib/bson.js.map +1 -1
- package/lib/change_stream.js +3 -2
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js +21 -10
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +71 -116
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +17 -0
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js +20 -29
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +126 -140
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +28 -0
- package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +178 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/service_workflow.js +41 -0
- package/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js +115 -0
- package/lib/cmap/auth/mongodb_oidc/token_entry_cache.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/workflow.js +3 -0
- package/lib/cmap/auth/mongodb_oidc/workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc.js +62 -0
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -0
- package/lib/cmap/auth/plain.js +4 -5
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/providers.js +4 -1
- package/lib/cmap/auth/providers.js.map +1 -1
- package/lib/cmap/auth/scram.js +45 -73
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js +8 -11
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +8 -5
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +9 -1
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +72 -86
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +68 -74
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +51 -13
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/message_stream.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +1 -16
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js +10 -10
- package/lib/connection_string.js +47 -33
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +13 -7
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +1 -1
- package/lib/db.js +3 -2
- package/lib/db.js.map +1 -1
- package/lib/error.js +2 -1
- package/lib/error.js.map +1 -1
- package/lib/mongo_client.js +22 -2
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_logger.js +17 -1
- package/lib/mongo_logger.js.map +1 -1
- package/lib/operations/aggregate.js +4 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/create_collection.js +1 -0
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/execute_operation.js +8 -27
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +3 -2
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/indexes.js +2 -1
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/list_collections.js +2 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/read_concern.js +1 -1
- package/lib/read_preference.js +2 -2
- package/lib/sdam/monitor.js +1 -0
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +4 -2
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/topology.js +3 -26
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sessions.js +2 -1
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +15 -70
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js +1 -1
- package/mongodb.d.ts +137 -68
- package/package.json +30 -30
- package/src/bson.ts +3 -1
- package/src/bulk/common.ts +1 -1
- package/src/change_stream.ts +16 -8
- package/src/cmap/auth/auth_provider.ts +29 -16
- package/src/cmap/auth/gssapi.ts +102 -149
- package/src/cmap/auth/mongo_credentials.ts +47 -1
- package/src/cmap/auth/mongocr.ts +31 -36
- package/src/cmap/auth/mongodb_aws.ts +167 -189
- package/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +26 -0
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +259 -0
- package/src/cmap/auth/mongodb_oidc/service_workflow.ts +47 -0
- package/src/cmap/auth/mongodb_oidc/token_entry_cache.ts +166 -0
- package/src/cmap/auth/mongodb_oidc/workflow.ts +21 -0
- package/src/cmap/auth/mongodb_oidc.ts +123 -0
- package/src/cmap/auth/plain.ts +6 -6
- package/src/cmap/auth/providers.ts +5 -2
- package/src/cmap/auth/scram.ts +56 -90
- package/src/cmap/auth/x509.ts +12 -18
- package/src/cmap/command_monitoring_events.ts +5 -2
- package/src/cmap/commands.ts +11 -1
- package/src/cmap/connect.ts +90 -114
- package/src/cmap/connection.ts +92 -90
- package/src/cmap/connection_pool.ts +77 -16
- package/src/cmap/message_stream.ts +0 -2
- package/src/cmap/wire_protocol/compression.ts +1 -1
- package/src/cmap/wire_protocol/shared.ts +1 -23
- package/src/collection.ts +11 -11
- package/src/connection_string.ts +52 -35
- package/src/cursor/abstract_cursor.ts +13 -6
- package/src/cursor/change_stream_cursor.ts +5 -5
- package/src/cursor/find_cursor.ts +1 -1
- package/src/db.ts +3 -2
- package/src/deps.ts +56 -38
- package/src/error.ts +3 -2
- package/src/index.ts +7 -0
- package/src/mongo_client.ts +35 -10
- package/src/mongo_logger.ts +20 -2
- package/src/mongo_types.ts +4 -3
- package/src/operations/aggregate.ts +4 -2
- package/src/operations/create_collection.ts +2 -1
- package/src/operations/execute_operation.ts +8 -25
- package/src/operations/find.ts +13 -4
- package/src/operations/find_and_modify.ts +4 -4
- package/src/operations/indexes.ts +12 -4
- package/src/operations/list_collections.ts +11 -3
- package/src/operations/set_profiling_level.ts +1 -1
- package/src/operations/stats.ts +1 -1
- package/src/read_concern.ts +2 -2
- package/src/read_preference.ts +3 -3
- package/src/sdam/common.ts +2 -2
- package/src/sdam/monitor.ts +1 -0
- package/src/sdam/server.ts +4 -1
- package/src/sdam/topology.ts +4 -33
- package/src/sessions.ts +2 -1
- package/src/transactions.ts +1 -1
- package/src/utils.ts +24 -98
- package/src/write_concern.ts +1 -1
package/src/read_preference.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const ReadPreferenceMode = Object.freeze({
|
|
|
16
16
|
} as const);
|
|
17
17
|
|
|
18
18
|
/** @public */
|
|
19
|
-
export type ReadPreferenceMode = typeof ReadPreferenceMode[keyof typeof ReadPreferenceMode];
|
|
19
|
+
export type ReadPreferenceMode = (typeof ReadPreferenceMode)[keyof typeof ReadPreferenceMode];
|
|
20
20
|
|
|
21
21
|
/** @public */
|
|
22
22
|
export interface HedgeOptions {
|
|
@@ -56,7 +56,7 @@ export interface ReadPreferenceFromOptions extends ReadPreferenceLikeOptions {
|
|
|
56
56
|
* used to construct connections.
|
|
57
57
|
* @public
|
|
58
58
|
*
|
|
59
|
-
* @see https://
|
|
59
|
+
* @see https://www.mongodb.com/docs/manual/core/read-preference/
|
|
60
60
|
*/
|
|
61
61
|
export class ReadPreference {
|
|
62
62
|
mode: ReadPreferenceMode;
|
|
@@ -229,7 +229,7 @@ export class ReadPreference {
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* Indicates that this readPreference needs the "SecondaryOk" bit when sent over the wire
|
|
232
|
-
* @see https://
|
|
232
|
+
* @see https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/#op-query
|
|
233
233
|
*/
|
|
234
234
|
secondaryOk(): boolean {
|
|
235
235
|
const NEEDS_SECONDARYOK = new Set<string>([
|
package/src/sdam/common.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const TopologyType = Object.freeze({
|
|
|
24
24
|
} as const);
|
|
25
25
|
|
|
26
26
|
/** @public */
|
|
27
|
-
export type TopologyType = typeof TopologyType[keyof typeof TopologyType];
|
|
27
|
+
export type TopologyType = (typeof TopologyType)[keyof typeof TopologyType];
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* An enumeration of server types we know about
|
|
@@ -44,7 +44,7 @@ export const ServerType = Object.freeze({
|
|
|
44
44
|
} as const);
|
|
45
45
|
|
|
46
46
|
/** @public */
|
|
47
|
-
export type ServerType = typeof ServerType[keyof typeof ServerType];
|
|
47
|
+
export type ServerType = (typeof ServerType)[keyof typeof ServerType];
|
|
48
48
|
|
|
49
49
|
/** @internal */
|
|
50
50
|
export type TimerQueue = Set<NodeJS.Timeout>;
|
package/src/sdam/monitor.ts
CHANGED
package/src/sdam/server.ts
CHANGED
|
@@ -241,7 +241,10 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
241
241
|
|
|
242
242
|
/** Destroy the server connection */
|
|
243
243
|
destroy(options?: DestroyOptions, callback?: Callback): void {
|
|
244
|
-
if (typeof options === 'function')
|
|
244
|
+
if (typeof options === 'function') {
|
|
245
|
+
callback = options;
|
|
246
|
+
options = { force: false };
|
|
247
|
+
}
|
|
245
248
|
options = Object.assign({}, { force: false }, options);
|
|
246
249
|
|
|
247
250
|
if (this.s.state === STATE_CLOSED) {
|
package/src/sdam/topology.ts
CHANGED
|
@@ -466,26 +466,17 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
|
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
/** Close this topology */
|
|
469
|
-
close(callback: Callback): void;
|
|
470
469
|
close(options: CloseOptions): void;
|
|
471
470
|
close(options: CloseOptions, callback: Callback): void;
|
|
472
|
-
close(options?: CloseOptions
|
|
473
|
-
|
|
474
|
-
callback = options;
|
|
475
|
-
options = {};
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (typeof options === 'boolean') {
|
|
479
|
-
options = { force: options };
|
|
480
|
-
}
|
|
481
|
-
options = options ?? {};
|
|
471
|
+
close(options?: CloseOptions, callback?: Callback): void {
|
|
472
|
+
options = options ?? { force: false };
|
|
482
473
|
|
|
483
474
|
if (this.s.state === STATE_CLOSED || this.s.state === STATE_CLOSING) {
|
|
484
475
|
return callback?.();
|
|
485
476
|
}
|
|
486
477
|
|
|
487
478
|
const destroyedServers = Array.from(this.s.servers.values(), server => {
|
|
488
|
-
return promisify(destroyServer)(server, this, options
|
|
479
|
+
return promisify(destroyServer)(server, this, { force: !!options?.force });
|
|
489
480
|
});
|
|
490
481
|
|
|
491
482
|
Promise.all(destroyedServers)
|
|
@@ -583,26 +574,6 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
|
|
|
583
574
|
processWaitQueue(this);
|
|
584
575
|
}
|
|
585
576
|
|
|
586
|
-
// Sessions related methods
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* @returns Whether the topology should initiate selection to determine session support
|
|
590
|
-
*/
|
|
591
|
-
shouldCheckForSessionSupport(): boolean {
|
|
592
|
-
if (this.description.type === TopologyType.Single) {
|
|
593
|
-
return !this.description.hasKnownServers;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
return !this.description.hasDataBearingServers;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* @returns Whether sessions are supported on the current topology
|
|
601
|
-
*/
|
|
602
|
-
hasSessionSupport(): boolean {
|
|
603
|
-
return this.loadBalanced || this.description.logicalSessionTimeoutMinutes != null;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
577
|
/**
|
|
607
578
|
* Update the internal TopologyDescription with a ServerDescription
|
|
608
579
|
*
|
|
@@ -740,7 +711,7 @@ function destroyServer(
|
|
|
740
711
|
options?: DestroyOptions,
|
|
741
712
|
callback?: Callback
|
|
742
713
|
) {
|
|
743
|
-
options = options ?? {};
|
|
714
|
+
options = options ?? { force: false };
|
|
744
715
|
for (const event of LOCAL_SERVER_EVENTS) {
|
|
745
716
|
server.removeAllListeners(event);
|
|
746
717
|
}
|
package/src/sessions.ts
CHANGED
|
@@ -307,7 +307,8 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
|
|
|
307
307
|
if (
|
|
308
308
|
!clusterTime.signature ||
|
|
309
309
|
clusterTime.signature.hash?._bsontype !== 'Binary' ||
|
|
310
|
-
(typeof clusterTime.signature.keyId !== '
|
|
310
|
+
(typeof clusterTime.signature.keyId !== 'bigint' &&
|
|
311
|
+
typeof clusterTime.signature.keyId !== 'number' &&
|
|
311
312
|
clusterTime.signature.keyId?._bsontype !== 'Long') // apparently we decode the key to number?
|
|
312
313
|
) {
|
|
313
314
|
throw new MongoInvalidArgumentError(
|
package/src/transactions.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const TxnState = Object.freeze({
|
|
|
18
18
|
} as const);
|
|
19
19
|
|
|
20
20
|
/** @internal */
|
|
21
|
-
export type TxnState = typeof TxnState[keyof typeof TxnState];
|
|
21
|
+
export type TxnState = (typeof TxnState)[keyof typeof TxnState];
|
|
22
22
|
|
|
23
23
|
const stateMachine: { [state in TxnState]: TxnState[] } = {
|
|
24
24
|
[TxnState.NO_TRANSACTION]: [TxnState.NO_TRANSACTION, TxnState.STARTING_TRANSACTION],
|
package/src/utils.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
MongoRuntimeError
|
|
21
21
|
} from './error';
|
|
22
22
|
import type { Explain } from './explain';
|
|
23
|
-
import type { MongoClient } from './mongo_client';
|
|
23
|
+
import type { MongoClient, MongoOptions } from './mongo_client';
|
|
24
24
|
import type { CommandOperationOptions, OperationParent } from './operations/command';
|
|
25
25
|
import type { Hint, OperationOptions } from './operations/operation';
|
|
26
26
|
import { ReadConcern } from './read_concern';
|
|
@@ -29,7 +29,7 @@ import { ServerType } from './sdam/common';
|
|
|
29
29
|
import type { Server } from './sdam/server';
|
|
30
30
|
import type { Topology } from './sdam/topology';
|
|
31
31
|
import type { ClientSession } from './sessions';
|
|
32
|
-
import {
|
|
32
|
+
import { WriteConcern } from './write_concern';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* MongoDB Driver style callback
|
|
@@ -167,9 +167,6 @@ export function applyRetryableWrites<T extends HasRetryableWrites>(target: T, db
|
|
|
167
167
|
return target;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
interface HasWriteConcern {
|
|
171
|
-
writeConcern?: WriteConcernOptions | WriteConcern | W;
|
|
172
|
-
}
|
|
173
170
|
/**
|
|
174
171
|
* Applies a write concern to a command based on well defined inheritance rules, optionally
|
|
175
172
|
* detecting support for the write concern in the first place.
|
|
@@ -179,39 +176,6 @@ interface HasWriteConcern {
|
|
|
179
176
|
* @param sources - sources where we can inherit default write concerns from
|
|
180
177
|
* @param options - optional settings passed into a command for write concern overrides
|
|
181
178
|
*/
|
|
182
|
-
export function applyWriteConcern<T extends HasWriteConcern>(
|
|
183
|
-
target: T,
|
|
184
|
-
sources: { db?: Db; collection?: Collection },
|
|
185
|
-
options?: OperationOptions & WriteConcernOptions
|
|
186
|
-
): T {
|
|
187
|
-
options = options ?? {};
|
|
188
|
-
const db = sources.db;
|
|
189
|
-
const coll = sources.collection;
|
|
190
|
-
|
|
191
|
-
if (options.session && options.session.inTransaction()) {
|
|
192
|
-
// writeConcern is not allowed within a multi-statement transaction
|
|
193
|
-
if (target.writeConcern) {
|
|
194
|
-
delete target.writeConcern;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return target;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const writeConcern = WriteConcern.fromOptions(options);
|
|
201
|
-
if (writeConcern) {
|
|
202
|
-
return Object.assign(target, { writeConcern });
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (coll && coll.writeConcern) {
|
|
206
|
-
return Object.assign(target, { writeConcern: Object.assign({}, coll.writeConcern) });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (db && db.writeConcern) {
|
|
210
|
-
return Object.assign(target, { writeConcern: Object.assign({}, db.writeConcern) });
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return target;
|
|
214
|
-
}
|
|
215
179
|
|
|
216
180
|
/**
|
|
217
181
|
* Checks if a given value is a Promise
|
|
@@ -483,40 +447,6 @@ export function eachAsync<T = Document>(
|
|
|
483
447
|
}
|
|
484
448
|
}
|
|
485
449
|
|
|
486
|
-
/** @internal */
|
|
487
|
-
export function eachAsyncSeries<T = any>(
|
|
488
|
-
arr: T[],
|
|
489
|
-
eachFn: (item: T, callback: (err?: AnyError) => void) => void,
|
|
490
|
-
callback: Callback
|
|
491
|
-
): void {
|
|
492
|
-
arr = arr || [];
|
|
493
|
-
|
|
494
|
-
let idx = 0;
|
|
495
|
-
let awaiting = arr.length;
|
|
496
|
-
if (awaiting === 0) {
|
|
497
|
-
callback();
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function eachCallback(err?: AnyError) {
|
|
502
|
-
idx++;
|
|
503
|
-
awaiting--;
|
|
504
|
-
if (err) {
|
|
505
|
-
callback(err);
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (idx === arr.length && awaiting <= 0) {
|
|
510
|
-
callback();
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
eachFn(arr[idx], eachCallback);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
eachFn(arr[idx], eachCallback);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
450
|
/** @internal */
|
|
521
451
|
export function arrayStrictEqual(arr: unknown[], arr2: unknown[]): boolean {
|
|
522
452
|
if (!Array.isArray(arr) || !Array.isArray(arr2)) {
|
|
@@ -583,7 +513,10 @@ export function makeStateMachine(stateTable: StateTable): StateTransitionFunctio
|
|
|
583
513
|
};
|
|
584
514
|
}
|
|
585
515
|
|
|
586
|
-
/**
|
|
516
|
+
/**
|
|
517
|
+
* @public
|
|
518
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.rst#hello-command
|
|
519
|
+
*/
|
|
587
520
|
export interface ClientMetadata {
|
|
588
521
|
driver: {
|
|
589
522
|
name: string;
|
|
@@ -596,7 +529,6 @@ export interface ClientMetadata {
|
|
|
596
529
|
version: string;
|
|
597
530
|
};
|
|
598
531
|
platform: string;
|
|
599
|
-
version?: string;
|
|
600
532
|
application?: {
|
|
601
533
|
name: string;
|
|
602
534
|
};
|
|
@@ -615,13 +547,21 @@ export interface ClientMetadataOptions {
|
|
|
615
547
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
616
548
|
const NODE_DRIVER_VERSION = require('../package.json').version;
|
|
617
549
|
|
|
618
|
-
export function makeClientMetadata(
|
|
619
|
-
options
|
|
550
|
+
export function makeClientMetadata(
|
|
551
|
+
options: Pick<MongoOptions, 'appName' | 'driverInfo'>
|
|
552
|
+
): ClientMetadata {
|
|
553
|
+
const name = options.driverInfo.name ? `nodejs|${options.driverInfo.name}` : 'nodejs';
|
|
554
|
+
const version = options.driverInfo.version
|
|
555
|
+
? `${NODE_DRIVER_VERSION}|${options.driverInfo.version}`
|
|
556
|
+
: NODE_DRIVER_VERSION;
|
|
557
|
+
const platform = options.driverInfo.platform
|
|
558
|
+
? `Node.js ${process.version}, ${os.endianness()}|${options.driverInfo.platform}`
|
|
559
|
+
: `Node.js ${process.version}, ${os.endianness()}`;
|
|
620
560
|
|
|
621
561
|
const metadata: ClientMetadata = {
|
|
622
562
|
driver: {
|
|
623
|
-
name
|
|
624
|
-
version
|
|
563
|
+
name,
|
|
564
|
+
version
|
|
625
565
|
},
|
|
626
566
|
os: {
|
|
627
567
|
type: os.type(),
|
|
@@ -629,30 +569,16 @@ export function makeClientMetadata(options?: ClientMetadataOptions): ClientMetad
|
|
|
629
569
|
architecture: process.arch,
|
|
630
570
|
version: os.release()
|
|
631
571
|
},
|
|
632
|
-
platform
|
|
572
|
+
platform
|
|
633
573
|
};
|
|
634
574
|
|
|
635
|
-
// support optionally provided wrapping driver info
|
|
636
|
-
if (options.driverInfo) {
|
|
637
|
-
if (options.driverInfo.name) {
|
|
638
|
-
metadata.driver.name = `${metadata.driver.name}|${options.driverInfo.name}`;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
if (options.driverInfo.version) {
|
|
642
|
-
metadata.version = `${metadata.driver.version}|${options.driverInfo.version}`;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
if (options.driverInfo.platform) {
|
|
646
|
-
metadata.platform = `${metadata.platform}|${options.driverInfo.platform}`;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
575
|
if (options.appName) {
|
|
651
576
|
// MongoDB requires the appName not exceed a byte length of 128
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
577
|
+
const name =
|
|
578
|
+
Buffer.byteLength(options.appName, 'utf8') <= 128
|
|
579
|
+
? options.appName
|
|
580
|
+
: Buffer.from(options.appName, 'utf8').subarray(0, 128).toString('utf8');
|
|
581
|
+
metadata.application = { name };
|
|
656
582
|
}
|
|
657
583
|
|
|
658
584
|
return metadata;
|
package/src/write_concern.ts
CHANGED
|
@@ -32,7 +32,7 @@ export const WRITE_CONCERN_KEYS = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
|
|
|
32
32
|
* requested from MongoDB for write operations.
|
|
33
33
|
* @public
|
|
34
34
|
*
|
|
35
|
-
* @see https://
|
|
35
|
+
* @see https://www.mongodb.com/docs/manual/reference/write-concern/
|
|
36
36
|
*/
|
|
37
37
|
export class WriteConcern {
|
|
38
38
|
/** request acknowledgment that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags. */
|