mongodb 6.5.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/lib/admin.js +9 -9
- package/lib/admin.js.map +1 -1
- package/lib/bson.js +33 -22
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +13 -12
- package/lib/bulk/common.js.map +1 -1
- package/lib/change_stream.js +28 -18
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +2 -2
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +6 -6
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/providers/aws.js +13 -10
- package/lib/client-side-encryption/providers/aws.js.map +1 -1
- package/lib/client-side-encryption/providers/azure.js +6 -3
- package/lib/client-side-encryption/providers/azure.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js +140 -0
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
- package/lib/cmap/auth/gssapi.js +7 -6
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +8 -101
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +1 -1
- package/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js +2 -1
- package/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/service_workflow.js +1 -1
- package/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -1
- package/lib/cmap/auth/scram.js +2 -2
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/commands.js +24 -111
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +4 -4
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +61 -36
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +22 -13
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +2 -2
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +8 -8
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js +218 -0
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
- package/lib/cmap/wire_protocol/responses.js +184 -0
- package/lib/cmap/wire_protocol/responses.js.map +1 -0
- package/lib/collection.js +42 -38
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +4 -6
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +76 -43
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +16 -33
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +36 -18
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/cursor/run_command_cursor.js +3 -2
- package/lib/cursor/run_command_cursor.js.map +1 -1
- package/lib/db.js +15 -19
- package/lib/db.js.map +1 -1
- package/lib/deps.js +31 -26
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js +14 -5
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +4 -3
- package/lib/error.js.map +1 -1
- package/lib/gridfs/download.js +19 -14
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +6 -1
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +11 -7
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_logger.js +3 -0
- package/lib/mongo_logger.js.map +1 -1
- package/lib/operations/aggregate.js +2 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/command.js +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/create_collection.js +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +4 -3
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/drop.js +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/execute_operation.js +23 -8
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js +4 -4
- 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/operations/indexes.js +29 -121
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js +3 -3
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/kill_cursors.js +3 -1
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js +1 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/run_command.js +4 -2
- package/lib/operations/run_command.js.map +1 -1
- package/lib/operations/search_indexes/create.js.map +1 -1
- package/lib/operations/stats.js +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +1 -1
- package/lib/operations/update.js.map +1 -1
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/monitor.js +139 -42
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +5 -15
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +1 -0
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +1 -1
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +2 -1
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +67 -54
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js +10 -0
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +133 -93
- package/lib/sessions.js.map +1 -1
- package/lib/timeout.js +77 -0
- package/lib/timeout.js.map +1 -0
- package/lib/utils.js +61 -28
- package/lib/utils.js.map +1 -1
- package/mongodb.d.ts +150 -38
- package/package.json +16 -13
- package/src/admin.ts +9 -9
- package/src/bson.ts +14 -0
- package/src/bulk/common.ts +3 -2
- package/src/change_stream.ts +39 -30
- package/src/client-side-encryption/auto_encrypter.ts +2 -2
- package/src/client-side-encryption/client_encryption.ts +6 -6
- package/src/client-side-encryption/providers/aws.ts +17 -10
- package/src/client-side-encryption/providers/azure.ts +5 -3
- package/src/cmap/auth/aws_temporary_credentials.ts +169 -0
- package/src/cmap/auth/gssapi.ts +9 -11
- package/src/cmap/auth/mongodb_aws.ts +19 -126
- package/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +1 -1
- package/src/cmap/auth/mongodb_oidc/callback_lock_cache.ts +2 -1
- package/src/cmap/auth/mongodb_oidc/service_workflow.ts +1 -1
- package/src/cmap/auth/scram.ts +2 -2
- package/src/cmap/commands.ts +28 -132
- package/src/cmap/connect.ts +4 -4
- package/src/cmap/connection.ts +107 -43
- package/src/cmap/connection_pool.ts +32 -29
- package/src/cmap/handshake/client_metadata.ts +2 -5
- package/src/cmap/wire_protocol/compression.ts +11 -13
- package/src/cmap/wire_protocol/on_demand/document.ts +338 -0
- package/src/cmap/wire_protocol/responses.ts +237 -0
- package/src/collection.ts +87 -58
- package/src/connection_string.ts +9 -7
- package/src/cursor/abstract_cursor.ts +102 -38
- package/src/cursor/aggregation_cursor.ts +32 -34
- package/src/cursor/find_cursor.ts +33 -21
- package/src/cursor/list_search_indexes_cursor.ts +1 -1
- package/src/cursor/run_command_cursor.ts +3 -2
- package/src/db.ts +42 -21
- package/src/deps.ts +52 -40
- package/src/encrypter.ts +14 -5
- package/src/error.ts +9 -3
- package/src/gridfs/download.ts +19 -31
- package/src/gridfs/index.ts +2 -0
- package/src/gridfs/upload.ts +11 -8
- package/src/index.ts +13 -5
- package/src/mongo_client.ts +21 -15
- package/src/mongo_logger.ts +3 -0
- package/src/mongo_types.ts +1 -1
- package/src/operations/aggregate.ts +2 -1
- package/src/operations/command.ts +1 -1
- package/src/operations/create_collection.ts +7 -2
- package/src/operations/delete.ts +4 -3
- package/src/operations/drop.ts +1 -1
- package/src/operations/execute_operation.ts +29 -10
- package/src/operations/find.ts +13 -14
- package/src/operations/get_more.ts +9 -1
- package/src/operations/indexes.ts +103 -176
- package/src/operations/insert.ts +2 -2
- package/src/operations/kill_cursors.ts +3 -2
- package/src/operations/list_collections.ts +5 -1
- package/src/operations/list_databases.ts +1 -1
- package/src/operations/operation.ts +3 -0
- package/src/operations/run_command.ts +6 -4
- package/src/operations/search_indexes/create.ts +4 -1
- package/src/operations/stats.ts +1 -1
- package/src/operations/update.ts +7 -7
- package/src/sdam/common.ts +8 -2
- package/src/sdam/monitor.ts +178 -61
- package/src/sdam/server.ts +27 -20
- package/src/sdam/server_description.ts +8 -3
- package/src/sdam/server_selection.ts +2 -3
- package/src/sdam/srv_polling.ts +3 -2
- package/src/sdam/topology.ts +114 -117
- package/src/sdam/topology_description.ts +14 -4
- package/src/sessions.ts +168 -148
- package/src/timeout.ts +96 -0
- package/src/utils.ts +85 -32
- package/lib/operations/common_functions.js +0 -38
- package/lib/operations/common_functions.js.map +0 -1
- package/src/operations/common_functions.ts +0 -79
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnDemandDocument = void 0;
|
|
4
|
+
const bson_1 = require("../../../bson");
|
|
5
|
+
/** @internal */
|
|
6
|
+
class OnDemandDocument {
|
|
7
|
+
constructor(
|
|
8
|
+
/** BSON bytes, this document begins at offset */
|
|
9
|
+
bson,
|
|
10
|
+
/** The start of the document */
|
|
11
|
+
offset = 0,
|
|
12
|
+
/** If this is an embedded document, indicates if this was a BSON array */
|
|
13
|
+
isArray = false) {
|
|
14
|
+
this.bson = bson;
|
|
15
|
+
this.offset = offset;
|
|
16
|
+
this.isArray = isArray;
|
|
17
|
+
/**
|
|
18
|
+
* Maps JS strings to elements and jsValues for speeding up subsequent lookups.
|
|
19
|
+
* - If `false` then name does not exist in the BSON document
|
|
20
|
+
* - If `CachedBSONElement` instance name exists
|
|
21
|
+
* - If `cache[name].value == null` jsValue has not yet been parsed
|
|
22
|
+
* - Null/Undefined values do not get cached because they are zero-length values.
|
|
23
|
+
*/
|
|
24
|
+
this.cache = Object.create(null);
|
|
25
|
+
/** Caches the index of elements that have been named */
|
|
26
|
+
this.indexFound = Object.create(null);
|
|
27
|
+
this.elements = (0, bson_1.parseToElementsToArray)(this.bson, offset);
|
|
28
|
+
}
|
|
29
|
+
/** Only supports basic latin strings */
|
|
30
|
+
isElementName(name, element) {
|
|
31
|
+
const nameLength = element[2 /* BSONElementOffset.nameLength */];
|
|
32
|
+
const nameOffset = element[1 /* BSONElementOffset.nameOffset */];
|
|
33
|
+
if (name.length !== nameLength)
|
|
34
|
+
return false;
|
|
35
|
+
for (let i = 0; i < name.length; i++) {
|
|
36
|
+
if (this.bson[nameOffset + i] !== name.charCodeAt(i))
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Seeks into the elements array for an element matching the given name.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Caching:
|
|
46
|
+
* - Caches the existence of a property making subsequent look ups for non-existent properties return immediately
|
|
47
|
+
* - Caches names mapped to elements to avoid reiterating the array and comparing the name again
|
|
48
|
+
* - Caches the index at which an element has been found to prevent rechecking against elements already determined to belong to another name
|
|
49
|
+
*
|
|
50
|
+
* @param name - a basic latin string name of a BSON element
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
getElement(name) {
|
|
54
|
+
const cachedElement = this.cache[name];
|
|
55
|
+
if (cachedElement === false)
|
|
56
|
+
return null;
|
|
57
|
+
if (cachedElement != null) {
|
|
58
|
+
return cachedElement;
|
|
59
|
+
}
|
|
60
|
+
if (typeof name === 'number') {
|
|
61
|
+
if (this.isArray) {
|
|
62
|
+
if (name < this.elements.length) {
|
|
63
|
+
const element = this.elements[name];
|
|
64
|
+
const cachedElement = { element, value: undefined };
|
|
65
|
+
this.cache[name] = cachedElement;
|
|
66
|
+
this.indexFound[name] = true;
|
|
67
|
+
return cachedElement;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (let index = 0; index < this.elements.length; index++) {
|
|
78
|
+
const element = this.elements[index];
|
|
79
|
+
// skip this element if it has already been associated with a name
|
|
80
|
+
if (!this.indexFound[index] && this.isElementName(name, element)) {
|
|
81
|
+
const cachedElement = { element, value: undefined };
|
|
82
|
+
this.cache[name] = cachedElement;
|
|
83
|
+
this.indexFound[index] = true;
|
|
84
|
+
return cachedElement;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.cache[name] = false;
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
toJSValue(element, as) {
|
|
91
|
+
const type = element[0 /* BSONElementOffset.type */];
|
|
92
|
+
const offset = element[3 /* BSONElementOffset.offset */];
|
|
93
|
+
const length = element[4 /* BSONElementOffset.length */];
|
|
94
|
+
if (as !== type) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
switch (as) {
|
|
98
|
+
case bson_1.BSONType.null:
|
|
99
|
+
case bson_1.BSONType.undefined:
|
|
100
|
+
return null;
|
|
101
|
+
case bson_1.BSONType.double:
|
|
102
|
+
return (0, bson_1.getFloat64LE)(this.bson, offset);
|
|
103
|
+
case bson_1.BSONType.int:
|
|
104
|
+
return (0, bson_1.getInt32LE)(this.bson, offset);
|
|
105
|
+
case bson_1.BSONType.long:
|
|
106
|
+
return (0, bson_1.getBigInt64LE)(this.bson, offset);
|
|
107
|
+
case bson_1.BSONType.bool:
|
|
108
|
+
return Boolean(this.bson[offset]);
|
|
109
|
+
case bson_1.BSONType.objectId:
|
|
110
|
+
return new bson_1.ObjectId(this.bson.subarray(offset, offset + 12));
|
|
111
|
+
case bson_1.BSONType.timestamp:
|
|
112
|
+
return new bson_1.Timestamp((0, bson_1.getBigInt64LE)(this.bson, offset));
|
|
113
|
+
case bson_1.BSONType.string:
|
|
114
|
+
return (0, bson_1.toUTF8)(this.bson, offset + 4, offset + length - 1, false);
|
|
115
|
+
case bson_1.BSONType.binData: {
|
|
116
|
+
const totalBinarySize = (0, bson_1.getInt32LE)(this.bson, offset);
|
|
117
|
+
const subType = this.bson[offset + 4];
|
|
118
|
+
if (subType === 2) {
|
|
119
|
+
const subType2BinarySize = (0, bson_1.getInt32LE)(this.bson, offset + 1 + 4);
|
|
120
|
+
if (subType2BinarySize < 0)
|
|
121
|
+
throw new bson_1.BSONError('Negative binary type element size found for subtype 0x02');
|
|
122
|
+
if (subType2BinarySize > totalBinarySize - 4)
|
|
123
|
+
throw new bson_1.BSONError('Binary type with subtype 0x02 contains too long binary size');
|
|
124
|
+
if (subType2BinarySize < totalBinarySize - 4)
|
|
125
|
+
throw new bson_1.BSONError('Binary type with subtype 0x02 contains too short binary size');
|
|
126
|
+
return new bson_1.Binary(this.bson.subarray(offset + 1 + 4 + 4, offset + 1 + 4 + 4 + subType2BinarySize), 2);
|
|
127
|
+
}
|
|
128
|
+
return new bson_1.Binary(this.bson.subarray(offset + 1 + 4, offset + 1 + 4 + totalBinarySize), subType);
|
|
129
|
+
}
|
|
130
|
+
case bson_1.BSONType.date:
|
|
131
|
+
// Pretend this is correct.
|
|
132
|
+
return new Date(Number((0, bson_1.getBigInt64LE)(this.bson, offset)));
|
|
133
|
+
case bson_1.BSONType.object:
|
|
134
|
+
return new OnDemandDocument(this.bson, offset);
|
|
135
|
+
case bson_1.BSONType.array:
|
|
136
|
+
return new OnDemandDocument(this.bson, offset, true);
|
|
137
|
+
default:
|
|
138
|
+
throw new bson_1.BSONError(`Unsupported BSON type: ${as}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the number of elements in this BSON document
|
|
143
|
+
*/
|
|
144
|
+
size() {
|
|
145
|
+
return this.elements.length;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Checks for the existence of an element by name.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Uses `getElement` with the expectation that will populate caches such that a `has` call
|
|
152
|
+
* followed by a `getElement` call will not repeat the cost paid by the first look up.
|
|
153
|
+
*
|
|
154
|
+
* @param name - element name
|
|
155
|
+
*/
|
|
156
|
+
has(name) {
|
|
157
|
+
const cachedElement = this.cache[name];
|
|
158
|
+
if (cachedElement === false)
|
|
159
|
+
return false;
|
|
160
|
+
if (cachedElement != null)
|
|
161
|
+
return true;
|
|
162
|
+
return this.getElement(name) != null;
|
|
163
|
+
}
|
|
164
|
+
get(name, as, required) {
|
|
165
|
+
const element = this.getElement(name);
|
|
166
|
+
if (element == null) {
|
|
167
|
+
if (required === true) {
|
|
168
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (element.value == null) {
|
|
175
|
+
const value = this.toJSValue(element.element, as);
|
|
176
|
+
if (value == null) {
|
|
177
|
+
if (required === true) {
|
|
178
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// It is important to never store null
|
|
185
|
+
element.value = value;
|
|
186
|
+
}
|
|
187
|
+
return element.value;
|
|
188
|
+
}
|
|
189
|
+
getNumber(name, required) {
|
|
190
|
+
const maybeBool = this.get(name, bson_1.BSONType.bool);
|
|
191
|
+
const bool = maybeBool == null ? null : maybeBool ? 1 : 0;
|
|
192
|
+
const maybeLong = this.get(name, bson_1.BSONType.long);
|
|
193
|
+
const long = maybeLong == null ? null : Number(maybeLong);
|
|
194
|
+
const result = bool ?? long ?? this.get(name, bson_1.BSONType.int) ?? this.get(name, bson_1.BSONType.double);
|
|
195
|
+
if (required === true && result == null) {
|
|
196
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Deserialize this object, DOES NOT cache result so avoid multiple invocations
|
|
202
|
+
* @param options - BSON deserialization options
|
|
203
|
+
*/
|
|
204
|
+
toObject(options) {
|
|
205
|
+
return bson_1.BSON.deserialize(this.bson, {
|
|
206
|
+
...options,
|
|
207
|
+
index: this.offset,
|
|
208
|
+
allowObjectSmallerThanBufferSize: true
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/** Returns this document's bytes only */
|
|
212
|
+
toBytes() {
|
|
213
|
+
const size = (0, bson_1.getInt32LE)(this.bson, this.offset);
|
|
214
|
+
return this.bson.subarray(this.offset, this.offset + size);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.OnDemandDocument = OnDemandDocument;
|
|
218
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../src/cmap/wire_protocol/on_demand/document.ts"],"names":[],"mappings":";;;AAAA,wCAcuB;AA+BvB,gBAAgB;AAChB,MAAa,gBAAgB;IAgB3B;IACE,iDAAiD;IAC9B,IAAgB;IACnC,gCAAgC;IACf,SAAS,CAAC;IAC3B,0EAA0E;IAC1D,UAAU,KAAK;QAJZ,SAAI,GAAJ,IAAI,CAAY;QAElB,WAAM,GAAN,MAAM,CAAI;QAEX,YAAO,GAAP,OAAO,CAAQ;QArBjC;;;;;;WAMG;QACc,UAAK,GACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,wDAAwD;QACvC,eAAU,GAA4B,MAAM,CAAC,MAA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C,GAAG,CAAC,IAAI,EAAE,eAAQ,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,eAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,eAAQ,CAAC,MAAM,CAAC,CAAC;QAE/F,IAAI,QAAQ,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,EAAE;YACvC,MAAM,IAAI,gBAAS,CAAC,iBAAiB,IAAI,cAAc,CAAC,CAAC;SAC1D;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,OAA8B;QAC5C,OAAO,WAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YACjC,GAAG,OAAO;YACV,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,gCAAgC,EAAE,IAAI;SACvC,CAAC,CAAC;IACL,CAAC;IAED,yCAAyC;IACzC,OAAO;QACL,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,CAAC;CACF;AAnSD,4CAmSC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CursorResponse = exports.MongoDBResponse = exports.isErrorResponse = void 0;
|
|
4
|
+
const bson_1 = require("../../bson");
|
|
5
|
+
const error_1 = require("../../error");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const document_1 = require("./on_demand/document");
|
|
8
|
+
/**
|
|
9
|
+
* Accepts a BSON payload and checks for na "ok: 0" element.
|
|
10
|
+
* This utility is intended to prevent calling response class constructors
|
|
11
|
+
* that expect the result to be a success and demand certain properties to exist.
|
|
12
|
+
*
|
|
13
|
+
* For example, a cursor response always expects a cursor embedded document.
|
|
14
|
+
* In order to write the class such that the properties reflect that assertion (non-null)
|
|
15
|
+
* we cannot invoke the subclass constructor if the BSON represents an error.
|
|
16
|
+
*
|
|
17
|
+
* @param bytes - BSON document returned from the server
|
|
18
|
+
*/
|
|
19
|
+
function isErrorResponse(bson) {
|
|
20
|
+
const elements = (0, bson_1.parseToElementsToArray)(bson, 0);
|
|
21
|
+
for (let eIdx = 0; eIdx < elements.length; eIdx++) {
|
|
22
|
+
const element = elements[eIdx];
|
|
23
|
+
if (element[2 /* BSONElementOffset.nameLength */] === 2) {
|
|
24
|
+
const nameOffset = element[1 /* BSONElementOffset.nameOffset */];
|
|
25
|
+
// 111 == "o", 107 == "k"
|
|
26
|
+
if (bson[nameOffset] === 111 && bson[nameOffset + 1] === 107) {
|
|
27
|
+
const valueOffset = element[3 /* BSONElementOffset.offset */];
|
|
28
|
+
const valueLength = element[4 /* BSONElementOffset.length */];
|
|
29
|
+
// If any byte in the length of the ok number (works for any type) is non zero,
|
|
30
|
+
// then it is considered "ok: 1"
|
|
31
|
+
for (let i = valueOffset; i < valueOffset + valueLength; i++) {
|
|
32
|
+
if (bson[i] !== 0x00)
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
exports.isErrorResponse = isErrorResponse;
|
|
42
|
+
/** @internal */
|
|
43
|
+
class MongoDBResponse extends document_1.OnDemandDocument {
|
|
44
|
+
static is(value) {
|
|
45
|
+
return value instanceof MongoDBResponse;
|
|
46
|
+
}
|
|
47
|
+
/** Indicates this document is a server error */
|
|
48
|
+
get isError() {
|
|
49
|
+
let isError = this.ok === 0;
|
|
50
|
+
isError ||= this.has('errmsg');
|
|
51
|
+
isError ||= this.has('code');
|
|
52
|
+
isError ||= this.has('$err'); // The '$err' field is used in OP_REPLY responses
|
|
53
|
+
return isError;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Drivers can safely assume that the `recoveryToken` field is always a BSON document but drivers MUST NOT modify the
|
|
57
|
+
* contents of the document.
|
|
58
|
+
*/
|
|
59
|
+
get recoveryToken() {
|
|
60
|
+
return (this.get('recoveryToken', bson_1.BSONType.object)?.toObject({
|
|
61
|
+
promoteValues: false,
|
|
62
|
+
promoteLongs: false,
|
|
63
|
+
promoteBuffers: false
|
|
64
|
+
}) ?? null);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The server creates a cursor in response to a snapshot find/aggregate command and reports atClusterTime within the cursor field in the response.
|
|
68
|
+
* For the distinct command the server adds a top-level atClusterTime field to the response.
|
|
69
|
+
* The atClusterTime field represents the timestamp of the read and is guaranteed to be majority committed.
|
|
70
|
+
*/
|
|
71
|
+
get atClusterTime() {
|
|
72
|
+
return (this.get('cursor', bson_1.BSONType.object)?.get('atClusterTime', bson_1.BSONType.timestamp) ??
|
|
73
|
+
this.get('atClusterTime', bson_1.BSONType.timestamp));
|
|
74
|
+
}
|
|
75
|
+
get operationTime() {
|
|
76
|
+
return this.get('operationTime', bson_1.BSONType.timestamp);
|
|
77
|
+
}
|
|
78
|
+
get ok() {
|
|
79
|
+
return this.getNumber('ok') ? 1 : 0;
|
|
80
|
+
}
|
|
81
|
+
get $err() {
|
|
82
|
+
return this.get('$err', bson_1.BSONType.string);
|
|
83
|
+
}
|
|
84
|
+
get errmsg() {
|
|
85
|
+
return this.get('errmsg', bson_1.BSONType.string);
|
|
86
|
+
}
|
|
87
|
+
get code() {
|
|
88
|
+
return this.getNumber('code');
|
|
89
|
+
}
|
|
90
|
+
get $clusterTime() {
|
|
91
|
+
if (!('clusterTime' in this)) {
|
|
92
|
+
const clusterTimeDoc = this.get('$clusterTime', bson_1.BSONType.object);
|
|
93
|
+
if (clusterTimeDoc == null) {
|
|
94
|
+
this.clusterTime = null;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const clusterTime = clusterTimeDoc.get('clusterTime', bson_1.BSONType.timestamp, true);
|
|
98
|
+
const signature = clusterTimeDoc.get('signature', bson_1.BSONType.object)?.toObject();
|
|
99
|
+
// @ts-expect-error: `signature` is incorrectly typed. It is public API.
|
|
100
|
+
this.clusterTime = { clusterTime, signature };
|
|
101
|
+
}
|
|
102
|
+
return this.clusterTime ?? null;
|
|
103
|
+
}
|
|
104
|
+
toObject(options) {
|
|
105
|
+
const exactBSONOptions = {
|
|
106
|
+
useBigInt64: options?.useBigInt64,
|
|
107
|
+
promoteLongs: options?.promoteLongs,
|
|
108
|
+
promoteValues: options?.promoteValues,
|
|
109
|
+
promoteBuffers: options?.promoteBuffers,
|
|
110
|
+
bsonRegExp: options?.bsonRegExp,
|
|
111
|
+
raw: options?.raw ?? false,
|
|
112
|
+
fieldsAsRaw: options?.fieldsAsRaw ?? {},
|
|
113
|
+
validation: this.parseBsonSerializationOptions(options)
|
|
114
|
+
};
|
|
115
|
+
return super.toObject(exactBSONOptions);
|
|
116
|
+
}
|
|
117
|
+
parseBsonSerializationOptions(options) {
|
|
118
|
+
const enableUtf8Validation = options?.enableUtf8Validation;
|
|
119
|
+
if (enableUtf8Validation === false) {
|
|
120
|
+
return { utf8: false };
|
|
121
|
+
}
|
|
122
|
+
return { utf8: { writeErrors: false } };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// {ok:1}
|
|
126
|
+
MongoDBResponse.empty = new MongoDBResponse(new Uint8Array([13, 0, 0, 0, 16, 111, 107, 0, 1, 0, 0, 0, 0]));
|
|
127
|
+
exports.MongoDBResponse = MongoDBResponse;
|
|
128
|
+
/** @internal */
|
|
129
|
+
class CursorResponse extends MongoDBResponse {
|
|
130
|
+
static is(value) {
|
|
131
|
+
return value instanceof CursorResponse || value === CursorResponse.emptyGetMore;
|
|
132
|
+
}
|
|
133
|
+
constructor(bytes, offset, isArray) {
|
|
134
|
+
super(bytes, offset, isArray);
|
|
135
|
+
this.ns = null;
|
|
136
|
+
this.batchSize = 0;
|
|
137
|
+
this.iterated = 0;
|
|
138
|
+
const cursor = this.get('cursor', bson_1.BSONType.object, true);
|
|
139
|
+
const id = cursor.get('id', bson_1.BSONType.long, true);
|
|
140
|
+
this.id = new bson_1.Long(Number(id & 0xffffffffn), Number((id >> 32n) & 0xffffffffn));
|
|
141
|
+
const namespace = cursor.get('ns', bson_1.BSONType.string);
|
|
142
|
+
if (namespace != null)
|
|
143
|
+
this.ns = (0, utils_1.ns)(namespace);
|
|
144
|
+
if (cursor.has('firstBatch'))
|
|
145
|
+
this.batch = cursor.get('firstBatch', bson_1.BSONType.array, true);
|
|
146
|
+
else if (cursor.has('nextBatch'))
|
|
147
|
+
this.batch = cursor.get('nextBatch', bson_1.BSONType.array, true);
|
|
148
|
+
else
|
|
149
|
+
throw new error_1.MongoUnexpectedServerResponseError('Cursor document did not contain a batch');
|
|
150
|
+
this.batchSize = this.batch.size();
|
|
151
|
+
}
|
|
152
|
+
get length() {
|
|
153
|
+
return Math.max(this.batchSize - this.iterated, 0);
|
|
154
|
+
}
|
|
155
|
+
shift(options) {
|
|
156
|
+
if (this.iterated >= this.batchSize) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const result = this.batch.get(this.iterated, bson_1.BSONType.object, true) ?? null;
|
|
160
|
+
this.iterated += 1;
|
|
161
|
+
if (options?.raw) {
|
|
162
|
+
return result.toBytes();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return result.toObject(options);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
clear() {
|
|
169
|
+
this.iterated = this.batchSize;
|
|
170
|
+
}
|
|
171
|
+
pushMany() {
|
|
172
|
+
throw new Error('pushMany Unsupported method');
|
|
173
|
+
}
|
|
174
|
+
push() {
|
|
175
|
+
throw new Error('push Unsupported method');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* This supports a feature of the FindCursor.
|
|
180
|
+
* It is an optimization to avoid an extra getMore when the limit has been reached
|
|
181
|
+
*/
|
|
182
|
+
CursorResponse.emptyGetMore = { id: new bson_1.Long(0), length: 0, shift: () => null };
|
|
183
|
+
exports.CursorResponse = CursorResponse;
|
|
184
|
+
//# sourceMappingURL=responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../src/cmap/wire_protocol/responses.ts"],"names":[],"mappings":";;;AAAA,qCAOoB;AACpB,uCAAiE;AAEjE,uCAAwD;AACxD,mDAAwD;AAUxD;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,IAAgB;IAC9C,MAAM,QAAQ,GAAG,IAAA,6BAAsB,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,OAAO,sCAA8B,KAAK,CAAC,EAAE;YAC/C,MAAM,UAAU,GAAG,OAAO,sCAA8B,CAAC;YAEzD,yBAAyB;YACzB,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC5D,MAAM,WAAW,GAAG,OAAO,kCAA0B,CAAC;gBACtD,MAAM,WAAW,GAAG,OAAO,kCAA0B,CAAC;gBAEtD,+EAA+E;gBAC/E,gCAAgC;gBAChC,KAAK,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,WAAW,GAAG,WAAW,EAAE,CA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