bson 4.5.1 → 4.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/HISTORY.md +572 -0
- package/bower.json +1 -1
- package/bson.d.ts +70 -13
- package/dist/bson.browser.esm.js +314 -177
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +317 -176
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +317 -176
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +314 -177
- package/dist/bson.esm.js.map +1 -1
- package/lib/binary.js +11 -9
- package/lib/binary.js.map +1 -1
- package/lib/bson.js +11 -3
- package/lib/bson.js.map +1 -1
- package/lib/code.js +0 -1
- package/lib/code.js.map +1 -1
- package/lib/constants.js +5 -1
- package/lib/constants.js.map +1 -1
- package/lib/db_ref.js +0 -1
- package/lib/db_ref.js.map +1 -1
- package/lib/decimal128.js +6 -5
- package/lib/decimal128.js.map +1 -1
- package/lib/double.js +3 -1
- package/lib/double.js.map +1 -1
- package/lib/ensure_buffer.js +3 -2
- package/lib/ensure_buffer.js.map +1 -1
- package/lib/error.js +55 -0
- package/lib/error.js.map +1 -0
- package/lib/extended_json.js +11 -5
- package/lib/extended_json.js.map +1 -1
- package/lib/int_32.js +4 -2
- package/lib/int_32.js.map +1 -1
- package/lib/objectid.js +39 -35
- package/lib/objectid.js.map +1 -1
- package/lib/parser/deserializer.js +131 -53
- package/lib/parser/deserializer.js.map +1 -1
- package/lib/parser/serializer.js +13 -12
- package/lib/parser/serializer.js.map +1 -1
- package/lib/regexp.js +9 -2
- package/lib/regexp.js.map +1 -1
- package/lib/symbol.js +0 -2
- package/lib/symbol.js.map +1 -1
- package/lib/uuid.js +4 -4
- package/lib/uuid.js.map +1 -1
- package/lib/uuid_utils.js +2 -1
- package/lib/uuid_utils.js.map +1 -1
- package/package.json +16 -3
- package/src/binary.ts +12 -10
- package/src/bson.ts +7 -1
- package/src/code.ts +0 -1
- package/src/constants.ts +6 -0
- package/src/db_ref.ts +0 -1
- package/src/decimal128.ts +6 -5
- package/src/double.ts +4 -1
- package/src/ensure_buffer.ts +3 -2
- package/src/error.ts +23 -0
- package/src/extended_json.ts +13 -5
- package/src/int_32.ts +5 -2
- package/src/objectid.ts +40 -43
- package/src/parser/deserializer.ts +159 -57
- package/src/parser/serializer.ts +13 -12
- package/src/regexp.ts +14 -2
- package/src/symbol.ts +0 -2
- package/src/uuid.ts +4 -4
- package/src/uuid_utils.ts +2 -1
package/bson.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export declare class Binary {
|
|
|
20
20
|
static readonly SUBTYPE_UUID = 4;
|
|
21
21
|
/** MD5 BSON type */
|
|
22
22
|
static readonly SUBTYPE_MD5 = 5;
|
|
23
|
+
/** Encrypted BSON type */
|
|
24
|
+
static readonly SUBTYPE_ENCRYPTED = 6;
|
|
25
|
+
/** Column BSON type */
|
|
26
|
+
static readonly SUBTYPE_COLUMN = 7;
|
|
23
27
|
/** User BSON type */
|
|
24
28
|
static readonly SUBTYPE_USER_DEFINED = 128;
|
|
25
29
|
buffer: Buffer;
|
|
@@ -59,10 +63,10 @@ export declare class Binary {
|
|
|
59
63
|
value(asRaw?: boolean): string | BinarySequence;
|
|
60
64
|
/** the length of the binary sequence */
|
|
61
65
|
length(): number;
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
toJSON(): string;
|
|
67
|
+
toString(format?: string): string;
|
|
64
68
|
/* Excluded from this release type: toExtendedJSON */
|
|
65
|
-
|
|
69
|
+
toUUID(): UUID;
|
|
66
70
|
/* Excluded from this release type: fromExtendedJSON */
|
|
67
71
|
inspect(): string;
|
|
68
72
|
}
|
|
@@ -112,10 +116,14 @@ declare const BSON: {
|
|
|
112
116
|
deserialize: typeof deserialize;
|
|
113
117
|
calculateObjectSize: typeof calculateObjectSize;
|
|
114
118
|
deserializeStream: typeof deserializeStream;
|
|
119
|
+
BSONError: typeof BSONError;
|
|
120
|
+
BSONTypeError: typeof BSONTypeError;
|
|
115
121
|
};
|
|
116
122
|
export default BSON;
|
|
117
123
|
/* Excluded from this release type: BSON_BINARY_SUBTYPE_BYTE_ARRAY */
|
|
124
|
+
/* Excluded from this release type: BSON_BINARY_SUBTYPE_COLUMN */
|
|
118
125
|
/* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
|
|
126
|
+
/* Excluded from this release type: BSON_BINARY_SUBTYPE_ENCRYPTED */
|
|
119
127
|
/* Excluded from this release type: BSON_BINARY_SUBTYPE_FUNCTION */
|
|
120
128
|
/* Excluded from this release type: BSON_BINARY_SUBTYPE_MD5 */
|
|
121
129
|
/* Excluded from this release type: BSON_BINARY_SUBTYPE_USER_DEFINED */
|
|
@@ -146,6 +154,11 @@ export default BSON;
|
|
|
146
154
|
/* Excluded from this release type: BSON_INT32_MIN */
|
|
147
155
|
/* Excluded from this release type: BSON_INT64_MAX */
|
|
148
156
|
/* Excluded from this release type: BSON_INT64_MIN */
|
|
157
|
+
/** @public */
|
|
158
|
+
export declare class BSONError extends Error {
|
|
159
|
+
constructor(message: string);
|
|
160
|
+
readonly name: string;
|
|
161
|
+
}
|
|
149
162
|
/**
|
|
150
163
|
* A class representation of the BSON RegExp type.
|
|
151
164
|
* @public
|
|
@@ -186,11 +199,19 @@ export declare class BSONSymbol {
|
|
|
186
199
|
constructor(value: string);
|
|
187
200
|
/** Access the wrapped string value. */
|
|
188
201
|
valueOf(): string;
|
|
202
|
+
toString(): string;
|
|
203
|
+
/* Excluded from this release type: inspect */
|
|
204
|
+
toJSON(): string;
|
|
189
205
|
}
|
|
190
206
|
/** @public */
|
|
191
207
|
export declare interface BSONSymbolExtended {
|
|
192
208
|
$symbol: string;
|
|
193
209
|
}
|
|
210
|
+
/** @public */
|
|
211
|
+
export declare class BSONTypeError extends TypeError {
|
|
212
|
+
constructor(message: string);
|
|
213
|
+
readonly name: string;
|
|
214
|
+
}
|
|
194
215
|
/**
|
|
195
216
|
* Calculate the bson size for a passed in Javascript object.
|
|
196
217
|
*
|
|
@@ -214,7 +235,10 @@ export declare class Code {
|
|
|
214
235
|
* @param scope - an optional scope for the function.
|
|
215
236
|
*/
|
|
216
237
|
constructor(code: string | Function, scope?: Document);
|
|
217
|
-
|
|
238
|
+
toJSON(): {
|
|
239
|
+
code: string | Function;
|
|
240
|
+
scope?: Document;
|
|
241
|
+
};
|
|
218
242
|
/* Excluded from this release type: toExtendedJSON */
|
|
219
243
|
/* Excluded from this release type: fromExtendedJSON */
|
|
220
244
|
inspect(): string;
|
|
@@ -242,7 +266,7 @@ export declare class DBRef {
|
|
|
242
266
|
constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);
|
|
243
267
|
/* Excluded from this release type: namespace */
|
|
244
268
|
/* Excluded from this release type: namespace */
|
|
245
|
-
|
|
269
|
+
toJSON(): DBRefLike & Document;
|
|
246
270
|
/* Excluded from this release type: toExtendedJSON */
|
|
247
271
|
/* Excluded from this release type: fromExtendedJSON */
|
|
248
272
|
inspect(): string;
|
|
@@ -317,6 +341,24 @@ export declare interface DeserializeOptions {
|
|
|
317
341
|
/** Offset into buffer to begin reading document from */
|
|
318
342
|
index?: number;
|
|
319
343
|
raw?: boolean;
|
|
344
|
+
/** Allows for opt-out utf-8 validation for all keys or
|
|
345
|
+
* specified keys. Must be all true or all false.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```js
|
|
349
|
+
* // disables validation on all keys
|
|
350
|
+
* validation: { utf8: false }
|
|
351
|
+
*
|
|
352
|
+
* // enables validation only on specified keys a, b, and c
|
|
353
|
+
* validation: { utf8: { a: true, b: true, c: true } }
|
|
354
|
+
*
|
|
355
|
+
* // disables validation only on specified keys a, b
|
|
356
|
+
* validation: { utf8: { a: false, b: false } }
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
validation?: {
|
|
360
|
+
utf8: boolean | Record<string, true> | Record<string, false>;
|
|
361
|
+
};
|
|
320
362
|
}
|
|
321
363
|
/**
|
|
322
364
|
* Deserialize stream data as BSON documents.
|
|
@@ -354,7 +396,8 @@ export declare class Double {
|
|
|
354
396
|
* @returns returns the wrapped double number.
|
|
355
397
|
*/
|
|
356
398
|
valueOf(): number;
|
|
357
|
-
|
|
399
|
+
toJSON(): number;
|
|
400
|
+
toString(radix?: number): string;
|
|
358
401
|
/* Excluded from this release type: toExtendedJSON */
|
|
359
402
|
/* Excluded from this release type: fromExtendedJSON */
|
|
360
403
|
inspect(): string;
|
|
@@ -458,7 +501,8 @@ export declare class Int32 {
|
|
|
458
501
|
* @returns returns the wrapped int32 number.
|
|
459
502
|
*/
|
|
460
503
|
valueOf(): number;
|
|
461
|
-
|
|
504
|
+
toString(radix?: number): string;
|
|
505
|
+
toJSON(): number;
|
|
462
506
|
/* Excluded from this release type: toExtendedJSON */
|
|
463
507
|
/* Excluded from this release type: fromExtendedJSON */
|
|
464
508
|
inspect(): string;
|
|
@@ -839,9 +883,9 @@ declare class ObjectId {
|
|
|
839
883
|
/**
|
|
840
884
|
* Create an ObjectId type
|
|
841
885
|
*
|
|
842
|
-
* @param
|
|
886
|
+
* @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
|
|
843
887
|
*/
|
|
844
|
-
constructor(
|
|
888
|
+
constructor(inputId?: string | Buffer | number | ObjectIdLike | ObjectId);
|
|
845
889
|
/*
|
|
846
890
|
* The ObjectId bytes
|
|
847
891
|
* @readonly
|
|
@@ -861,8 +905,14 @@ declare class ObjectId {
|
|
|
861
905
|
* @param time - pass in a second based timestamp.
|
|
862
906
|
*/
|
|
863
907
|
static generate(time?: number): Buffer;
|
|
864
|
-
|
|
865
|
-
|
|
908
|
+
/**
|
|
909
|
+
* Converts the id into a 24 character hex string for printing
|
|
910
|
+
*
|
|
911
|
+
* @param format - The Buffer toString format parameter.
|
|
912
|
+
*/
|
|
913
|
+
toString(format?: string): string;
|
|
914
|
+
/** Converts to its JSON the 24 character hex string representation. */
|
|
915
|
+
toJSON(): string;
|
|
866
916
|
/**
|
|
867
917
|
* Compares the equality of this ObjectId with `otherID`.
|
|
868
918
|
*
|
|
@@ -1026,8 +1076,15 @@ export declare class UUID {
|
|
|
1026
1076
|
* @param includeDashes - should the string exclude dash-separators.
|
|
1027
1077
|
* */
|
|
1028
1078
|
toHexString(includeDashes?: boolean): string;
|
|
1029
|
-
|
|
1030
|
-
|
|
1079
|
+
/**
|
|
1080
|
+
* Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
|
|
1081
|
+
*/
|
|
1082
|
+
toString(encoding?: string): string;
|
|
1083
|
+
/**
|
|
1084
|
+
* Converts the id into its JSON string representation.
|
|
1085
|
+
* A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
1086
|
+
*/
|
|
1087
|
+
toJSON(): string;
|
|
1031
1088
|
/**
|
|
1032
1089
|
* Compares the equality of this UUID with `otherID`.
|
|
1033
1090
|
*
|