mongodb 6.5.0-dev.20240426.sha.6d8ad33 → 6.5.0-dev.20240502.sha.9d73f45
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/lib/cmap/connection.js +8 -4
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js +27 -16
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +106 -10
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +33 -27
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +14 -8
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js +2 -1
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +4 -3
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/get_more.js +2 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/sdam/server.js +3 -7
- package/lib/sdam/server.js.map +1 -1
- package/lib/utils.js +13 -2
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +2 -0
- package/package.json +1 -1
- package/src/cmap/connection.ts +14 -5
- package/src/cmap/wire_protocol/on_demand/document.ts +36 -21
- package/src/cmap/wire_protocol/responses.ts +139 -11
- package/src/cursor/abstract_cursor.ts +61 -21
- package/src/cursor/find_cursor.ts +12 -9
- package/src/cursor/run_command_cursor.ts +2 -1
- package/src/index.ts +5 -1
- package/src/operations/execute_operation.ts +2 -1
- package/src/operations/find.ts +14 -14
- package/src/operations/get_more.ts +9 -1
- package/src/sdam/server.ts +22 -7
- package/src/utils.ts +13 -0
package/src/sdam/server.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type ConnectionPoolOptions
|
|
8
8
|
} from '../cmap/connection_pool';
|
|
9
9
|
import { PoolClearedError } from '../cmap/errors';
|
|
10
|
+
import { type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses';
|
|
10
11
|
import {
|
|
11
12
|
APM_EVENTS,
|
|
12
13
|
CLOSED,
|
|
@@ -262,11 +263,25 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
public async command<T extends MongoDBResponseConstructor>(
|
|
267
|
+
ns: MongoDBNamespace,
|
|
268
|
+
command: Document,
|
|
269
|
+
options: CommandOptions | undefined,
|
|
270
|
+
responseType: T | undefined
|
|
271
|
+
): Promise<typeof responseType extends undefined ? Document : InstanceType<T>>;
|
|
272
|
+
|
|
273
|
+
public async command(
|
|
274
|
+
ns: MongoDBNamespace,
|
|
275
|
+
command: Document,
|
|
276
|
+
options?: CommandOptions
|
|
277
|
+
): Promise<Document>;
|
|
278
|
+
|
|
279
|
+
public async command(
|
|
280
|
+
ns: MongoDBNamespace,
|
|
281
|
+
cmd: Document,
|
|
282
|
+
options: CommandOptions,
|
|
283
|
+
responseType?: MongoDBResponseConstructor
|
|
284
|
+
): Promise<Document> {
|
|
270
285
|
if (ns.db == null || typeof ns === 'string') {
|
|
271
286
|
throw new MongoInvalidArgumentError('Namespace must not be a string');
|
|
272
287
|
}
|
|
@@ -308,7 +323,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
308
323
|
|
|
309
324
|
try {
|
|
310
325
|
try {
|
|
311
|
-
return await conn.command(ns, cmd, finalOptions);
|
|
326
|
+
return await conn.command(ns, cmd, finalOptions, responseType);
|
|
312
327
|
} catch (commandError) {
|
|
313
328
|
throw this.decorateCommandError(conn, cmd, finalOptions, commandError);
|
|
314
329
|
}
|
|
@@ -319,7 +334,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
|
|
|
319
334
|
) {
|
|
320
335
|
await this.pool.reauthenticate(conn);
|
|
321
336
|
try {
|
|
322
|
-
return await conn.command(ns, cmd, finalOptions);
|
|
337
|
+
return await conn.command(ns, cmd, finalOptions, responseType);
|
|
323
338
|
} catch (commandError) {
|
|
324
339
|
throw this.decorateCommandError(conn, cmd, finalOptions, commandError);
|
|
325
340
|
}
|
package/src/utils.ts
CHANGED
|
@@ -64,6 +64,19 @@ export const ByteUtils = {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Returns true if value is a Uint8Array or a Buffer
|
|
69
|
+
* @param value - any value that may be a Uint8Array
|
|
70
|
+
*/
|
|
71
|
+
export function isUint8Array(value: unknown): value is Uint8Array {
|
|
72
|
+
return (
|
|
73
|
+
value != null &&
|
|
74
|
+
typeof value === 'object' &&
|
|
75
|
+
Symbol.toStringTag in value &&
|
|
76
|
+
value[Symbol.toStringTag] === 'Uint8Array'
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
67
80
|
/**
|
|
68
81
|
* Determines if a connection's address matches a user provided list
|
|
69
82
|
* of domain wildcards.
|