bson 6.1.0 → 6.3.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/bson.d.ts +70 -18
- package/lib/bson.bundle.js +201 -139
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +201 -139
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +201 -139
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.rn.cjs +201 -139
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +19 -16
- package/src/binary.ts +12 -17
- package/src/bson_value.ts +15 -2
- package/src/code.ts +10 -10
- package/src/db_ref.ts +13 -11
- package/src/decimal128.ts +5 -8
- package/src/double.ts +4 -8
- package/src/error.ts +4 -6
- package/src/int_32.ts +4 -7
- package/src/long.ts +6 -7
- package/src/max_key.ts +0 -5
- package/src/min_key.ts +0 -5
- package/src/objectid.ts +46 -10
- package/src/parser/deserializer.ts +10 -31
- package/src/parser/utils.ts +27 -0
- package/src/regexp.ts +7 -7
- package/src/symbol.ts +4 -7
- package/src/timestamp.ts +6 -7
- package/src/utils/byte_utils.ts +2 -2
- package/src/utils/latin.ts +61 -0
- package/src/utils/node_byte_utils.ts +21 -2
- package/src/utils/web_byte_utils.ts +15 -2
package/bson.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class Binary extends BSONValue {
|
|
|
68
68
|
/** Creates an Binary instance from a base64 string */
|
|
69
69
|
static createFromBase64(base64: string, subType?: number): Binary;
|
|
70
70
|
/* Excluded from this release type: fromExtendedJSON */
|
|
71
|
-
inspect(): string;
|
|
71
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/** @public */
|
|
@@ -150,14 +150,16 @@ export { BSON }
|
|
|
150
150
|
* @public
|
|
151
151
|
* @category Error
|
|
152
152
|
*
|
|
153
|
-
* `BSONError` objects are thrown when BSON
|
|
153
|
+
* `BSONError` objects are thrown when BSON encounters an error.
|
|
154
154
|
*
|
|
155
155
|
* This is the parent class for all the other errors thrown by this library.
|
|
156
156
|
*/
|
|
157
157
|
export declare class BSONError extends Error {
|
|
158
158
|
/* Excluded from this release type: bsonError */
|
|
159
159
|
get name(): string;
|
|
160
|
-
constructor(message: string
|
|
160
|
+
constructor(message: string, options?: {
|
|
161
|
+
cause?: unknown;
|
|
162
|
+
});
|
|
161
163
|
/**
|
|
162
164
|
* @public
|
|
163
165
|
*
|
|
@@ -187,7 +189,7 @@ export declare class BSONRegExp extends BSONValue {
|
|
|
187
189
|
static parseOptions(options?: string): string;
|
|
188
190
|
/* Excluded from this release type: toExtendedJSON */
|
|
189
191
|
/* Excluded from this release type: fromExtendedJSON */
|
|
190
|
-
inspect(): string;
|
|
192
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
/** @public */
|
|
@@ -232,10 +234,10 @@ export declare class BSONSymbol extends BSONValue {
|
|
|
232
234
|
/** Access the wrapped string value. */
|
|
233
235
|
valueOf(): string;
|
|
234
236
|
toString(): string;
|
|
235
|
-
inspect(): string;
|
|
236
237
|
toJSON(): string;
|
|
237
238
|
/* Excluded from this release type: toExtendedJSON */
|
|
238
239
|
/* Excluded from this release type: fromExtendedJSON */
|
|
240
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
239
241
|
}
|
|
240
242
|
|
|
241
243
|
/** @public */
|
|
@@ -275,8 +277,12 @@ export declare type BSONType = (typeof BSONType)[keyof typeof BSONType];
|
|
|
275
277
|
export declare abstract class BSONValue {
|
|
276
278
|
/** @public */
|
|
277
279
|
abstract get _bsontype(): string;
|
|
278
|
-
/**
|
|
279
|
-
|
|
280
|
+
/**
|
|
281
|
+
* @public
|
|
282
|
+
* Prints a human-readable string of BSON value information
|
|
283
|
+
* If invoked manually without node.js.inspect function, this will default to a modified JSON.stringify
|
|
284
|
+
*/
|
|
285
|
+
abstract inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
280
286
|
/* Excluded from this release type: toExtendedJSON */
|
|
281
287
|
}
|
|
282
288
|
|
|
@@ -321,7 +327,7 @@ export declare class Code extends BSONValue {
|
|
|
321
327
|
};
|
|
322
328
|
/* Excluded from this release type: toExtendedJSON */
|
|
323
329
|
/* Excluded from this release type: fromExtendedJSON */
|
|
324
|
-
inspect(): string;
|
|
330
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
/** @public */
|
|
@@ -352,7 +358,7 @@ export declare class DBRef extends BSONValue {
|
|
|
352
358
|
toJSON(): DBRefLike & Document;
|
|
353
359
|
/* Excluded from this release type: toExtendedJSON */
|
|
354
360
|
/* Excluded from this release type: fromExtendedJSON */
|
|
355
|
-
inspect(): string;
|
|
361
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
356
362
|
}
|
|
357
363
|
|
|
358
364
|
/** @public */
|
|
@@ -406,7 +412,7 @@ export declare class Decimal128 extends BSONValue {
|
|
|
406
412
|
toJSON(): Decimal128Extended;
|
|
407
413
|
/* Excluded from this release type: toExtendedJSON */
|
|
408
414
|
/* Excluded from this release type: fromExtendedJSON */
|
|
409
|
-
inspect(): string;
|
|
415
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
410
416
|
}
|
|
411
417
|
|
|
412
418
|
/** @public */
|
|
@@ -529,7 +535,7 @@ export declare class Double extends BSONValue {
|
|
|
529
535
|
toString(radix?: number): string;
|
|
530
536
|
/* Excluded from this release type: toExtendedJSON */
|
|
531
537
|
/* Excluded from this release type: fromExtendedJSON */
|
|
532
|
-
inspect(): string;
|
|
538
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
533
539
|
}
|
|
534
540
|
|
|
535
541
|
/** @public */
|
|
@@ -579,6 +585,8 @@ export declare type EJSONOptions = {
|
|
|
579
585
|
*/
|
|
580
586
|
declare function EJSONserialize(value: any, options?: EJSONOptions): Document;
|
|
581
587
|
|
|
588
|
+
declare type InspectFn = (x: unknown, options?: unknown) => string;
|
|
589
|
+
|
|
582
590
|
/**
|
|
583
591
|
* A class representation of a BSON Int32 type.
|
|
584
592
|
* @public
|
|
@@ -603,7 +611,7 @@ export declare class Int32 extends BSONValue {
|
|
|
603
611
|
toJSON(): number;
|
|
604
612
|
/* Excluded from this release type: toExtendedJSON */
|
|
605
613
|
/* Excluded from this release type: fromExtendedJSON */
|
|
606
|
-
inspect(): string;
|
|
614
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
607
615
|
}
|
|
608
616
|
|
|
609
617
|
/** @public */
|
|
@@ -926,7 +934,7 @@ export declare class Long extends BSONValue {
|
|
|
926
934
|
static fromExtendedJSON(doc: {
|
|
927
935
|
$numberLong: string;
|
|
928
936
|
}, options?: EJSONOptions): number | Long | bigint;
|
|
929
|
-
inspect(): string;
|
|
937
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
930
938
|
}
|
|
931
939
|
|
|
932
940
|
/** @public */
|
|
@@ -988,9 +996,42 @@ export declare class ObjectId extends BSONValue {
|
|
|
988
996
|
/* Excluded from this release type: [kId] */
|
|
989
997
|
/* Excluded from this release type: __id */
|
|
990
998
|
/**
|
|
991
|
-
* Create
|
|
999
|
+
* Create ObjectId from a number.
|
|
1000
|
+
*
|
|
1001
|
+
* @param inputId - A number.
|
|
1002
|
+
* @deprecated Instead, use `static createFromTime()` to set a numeric value for the new ObjectId.
|
|
1003
|
+
*/
|
|
1004
|
+
constructor(inputId: number);
|
|
1005
|
+
/**
|
|
1006
|
+
* Create ObjectId from a 24 character hex string.
|
|
1007
|
+
*
|
|
1008
|
+
* @param inputId - A 24 character hex string.
|
|
1009
|
+
*/
|
|
1010
|
+
constructor(inputId: string);
|
|
1011
|
+
/**
|
|
1012
|
+
* Create ObjectId from the BSON ObjectId type.
|
|
1013
|
+
*
|
|
1014
|
+
* @param inputId - The BSON ObjectId type.
|
|
1015
|
+
*/
|
|
1016
|
+
constructor(inputId: ObjectId);
|
|
1017
|
+
/**
|
|
1018
|
+
* Create ObjectId from the object type that has the toHexString method.
|
|
1019
|
+
*
|
|
1020
|
+
* @param inputId - The ObjectIdLike type.
|
|
1021
|
+
*/
|
|
1022
|
+
constructor(inputId: ObjectIdLike);
|
|
1023
|
+
/**
|
|
1024
|
+
* Create ObjectId from a 12 byte binary Buffer.
|
|
1025
|
+
*
|
|
1026
|
+
* @param inputId - A 12 byte binary Buffer.
|
|
1027
|
+
*/
|
|
1028
|
+
constructor(inputId: Uint8Array);
|
|
1029
|
+
/** To generate a new ObjectId, use ObjectId() with no argument. */
|
|
1030
|
+
constructor();
|
|
1031
|
+
/**
|
|
1032
|
+
* Implementation overload.
|
|
992
1033
|
*
|
|
993
|
-
* @param inputId -
|
|
1034
|
+
* @param inputId - All input types that are used in the constructor implementation.
|
|
994
1035
|
*/
|
|
995
1036
|
constructor(inputId?: string | number | ObjectId | ObjectIdLike | Uint8Array);
|
|
996
1037
|
/**
|
|
@@ -1046,7 +1087,12 @@ export declare class ObjectId extends BSONValue {
|
|
|
1046
1087
|
static isValid(id: string | number | ObjectId | ObjectIdLike | Uint8Array): boolean;
|
|
1047
1088
|
/* Excluded from this release type: toExtendedJSON */
|
|
1048
1089
|
/* Excluded from this release type: fromExtendedJSON */
|
|
1049
|
-
|
|
1090
|
+
/**
|
|
1091
|
+
* Converts to a string representation of this Id.
|
|
1092
|
+
*
|
|
1093
|
+
* @returns return the 24 character hex string representation.
|
|
1094
|
+
*/
|
|
1095
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
1050
1096
|
}
|
|
1051
1097
|
|
|
1052
1098
|
/** @public */
|
|
@@ -1203,7 +1249,7 @@ export declare class Timestamp extends LongWithoutOverridesClass {
|
|
|
1203
1249
|
static fromString(str: string, optRadix: number): Timestamp;
|
|
1204
1250
|
/* Excluded from this release type: toExtendedJSON */
|
|
1205
1251
|
/* Excluded from this release type: fromExtendedJSON */
|
|
1206
|
-
inspect(): string;
|
|
1252
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
1207
1253
|
}
|
|
1208
1254
|
|
|
1209
1255
|
/** @public */
|
|
@@ -1278,7 +1324,13 @@ export declare class UUID extends Binary {
|
|
|
1278
1324
|
static createFromBase64(base64: string): UUID;
|
|
1279
1325
|
/* Excluded from this release type: bytesFromString */
|
|
1280
1326
|
/* Excluded from this release type: isValidUUIDString */
|
|
1281
|
-
|
|
1327
|
+
/**
|
|
1328
|
+
* Converts to a string representation of this Id.
|
|
1329
|
+
*
|
|
1330
|
+
* @returns return the 36 character hex string representation.
|
|
1331
|
+
*
|
|
1332
|
+
*/
|
|
1333
|
+
inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;
|
|
1282
1334
|
}
|
|
1283
1335
|
|
|
1284
1336
|
/** @public */
|