bson 4.6.1 → 4.6.4

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.
Files changed (51) hide show
  1. package/bower.json +1 -1
  2. package/bson-ts34.d.ts +1133 -0
  3. package/bson.d.ts +1228 -1118
  4. package/dist/bson.browser.esm.js +23 -5
  5. package/dist/bson.browser.esm.js.map +1 -1
  6. package/dist/bson.browser.umd.js +23 -5
  7. package/dist/bson.browser.umd.js.map +1 -1
  8. package/dist/bson.bundle.js +23 -5
  9. package/dist/bson.bundle.js.map +1 -1
  10. package/dist/bson.esm.js +23 -5
  11. package/dist/bson.esm.js.map +1 -1
  12. package/lib/binary.js +1 -0
  13. package/lib/binary.js.map +1 -1
  14. package/lib/code.js +1 -0
  15. package/lib/code.js.map +1 -1
  16. package/lib/db_ref.js +1 -0
  17. package/lib/db_ref.js.map +1 -1
  18. package/lib/decimal128.js +1 -0
  19. package/lib/decimal128.js.map +1 -1
  20. package/lib/double.js +1 -0
  21. package/lib/double.js.map +1 -1
  22. package/lib/int_32.js +1 -0
  23. package/lib/int_32.js.map +1 -1
  24. package/lib/long.js +1 -0
  25. package/lib/long.js.map +1 -1
  26. package/lib/max_key.js +1 -0
  27. package/lib/max_key.js.map +1 -1
  28. package/lib/min_key.js +1 -0
  29. package/lib/min_key.js.map +1 -1
  30. package/lib/objectid.js +8 -4
  31. package/lib/objectid.js.map +1 -1
  32. package/lib/regexp.js +1 -0
  33. package/lib/regexp.js.map +1 -1
  34. package/lib/symbol.js +1 -0
  35. package/lib/symbol.js.map +1 -1
  36. package/lib/timestamp.js +4 -1
  37. package/lib/timestamp.js.map +1 -1
  38. package/package.json +11 -3
  39. package/src/binary.ts +1 -0
  40. package/src/code.ts +1 -0
  41. package/src/db_ref.ts +1 -0
  42. package/src/decimal128.ts +1 -0
  43. package/src/double.ts +1 -0
  44. package/src/int_32.ts +1 -0
  45. package/src/long.ts +1 -0
  46. package/src/max_key.ts +1 -0
  47. package/src/min_key.ts +1 -0
  48. package/src/objectid.ts +9 -5
  49. package/src/regexp.ts +1 -0
  50. package/src/symbol.ts +1 -0
  51. package/src/timestamp.ts +4 -1
package/bson.d.ts CHANGED
@@ -1,1118 +1,1228 @@
1
- import { Buffer } from 'buffer';
2
- /**
3
- * A class representation of the BSON Binary type.
4
- * @public
5
- */
6
- export declare class Binary {
7
- _bsontype: 'Binary';
8
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
9
- /** Initial buffer default size */
10
- static readonly BUFFER_SIZE = 256;
11
- /** Default BSON type */
12
- static readonly SUBTYPE_DEFAULT = 0;
13
- /** Function BSON type */
14
- static readonly SUBTYPE_FUNCTION = 1;
15
- /** Byte Array BSON type */
16
- static readonly SUBTYPE_BYTE_ARRAY = 2;
17
- /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */
18
- static readonly SUBTYPE_UUID_OLD = 3;
19
- /** UUID BSON type */
20
- static readonly SUBTYPE_UUID = 4;
21
- /** MD5 BSON type */
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;
27
- /** User BSON type */
28
- static readonly SUBTYPE_USER_DEFINED = 128;
29
- buffer: Buffer;
30
- sub_type: number;
31
- position: number;
32
- /**
33
- * @param buffer - a buffer object containing the binary data.
34
- * @param subType - the option binary type.
35
- */
36
- constructor(buffer?: string | BinarySequence, subType?: number);
37
- /**
38
- * Updates this binary with byte_value.
39
- *
40
- * @param byteValue - a single byte we wish to write.
41
- */
42
- put(byteValue: string | number | Uint8Array | Buffer | number[]): void;
43
- /**
44
- * Writes a buffer or string to the binary.
45
- *
46
- * @param sequence - a string or buffer to be written to the Binary BSON object.
47
- * @param offset - specify the binary of where to write the content.
48
- */
49
- write(sequence: string | BinarySequence, offset: number): void;
50
- /**
51
- * Reads **length** bytes starting at **position**.
52
- *
53
- * @param position - read from the given position in the Binary.
54
- * @param length - the number of bytes to read.
55
- */
56
- read(position: number, length: number): BinarySequence;
57
- /**
58
- * Returns the value of this binary as a string.
59
- * @param asRaw - Will skip converting to a string
60
- * @remarks
61
- * This is handy when calling this function conditionally for some key value pairs and not others
62
- */
63
- value(asRaw?: boolean): string | BinarySequence;
64
- /** the length of the binary sequence */
65
- length(): number;
66
- toJSON(): string;
67
- toString(format?: string): string;
68
- /* Excluded from this release type: toExtendedJSON */
69
- toUUID(): UUID;
70
- /* Excluded from this release type: fromExtendedJSON */
71
- inspect(): string;
72
- }
73
- /** @public */
74
- export declare interface BinaryExtended {
75
- $binary: {
76
- subType: string;
77
- base64: string;
78
- };
79
- }
80
- /** @public */
81
- export declare interface BinaryExtendedLegacy {
82
- $type: string;
83
- $binary: string;
84
- }
85
- /** @public */
86
- export declare type BinarySequence = Uint8Array | Buffer | number[];
87
- /**
88
- * BSON default export
89
- * @deprecated Please use named exports
90
- * @privateRemarks
91
- * We want to someday deprecate the default export,
92
- * so none of the new TS types are being exported on the default
93
- * @public
94
- */
95
- declare const BSON: {
96
- Binary: typeof Binary;
97
- Code: typeof Code;
98
- DBRef: typeof DBRef;
99
- Decimal128: typeof Decimal128;
100
- Double: typeof Double;
101
- Int32: typeof Int32;
102
- Long: typeof Long;
103
- UUID: typeof UUID;
104
- Map: MapConstructor;
105
- MaxKey: typeof MaxKey;
106
- MinKey: typeof MinKey;
107
- ObjectId: typeof ObjectId;
108
- ObjectID: typeof ObjectId;
109
- BSONRegExp: typeof BSONRegExp;
110
- BSONSymbol: typeof BSONSymbol;
111
- Timestamp: typeof Timestamp;
112
- EJSON: typeof EJSON;
113
- setInternalBufferSize: typeof setInternalBufferSize;
114
- serialize: typeof serialize;
115
- serializeWithBufferAndIndex: typeof serializeWithBufferAndIndex;
116
- deserialize: typeof deserialize;
117
- calculateObjectSize: typeof calculateObjectSize;
118
- deserializeStream: typeof deserializeStream;
119
- BSONError: typeof BSONError;
120
- BSONTypeError: typeof BSONTypeError;
121
- };
122
- export default BSON;
123
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_BYTE_ARRAY */
124
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_COLUMN */
125
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
126
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_ENCRYPTED */
127
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_FUNCTION */
128
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_MD5 */
129
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_USER_DEFINED */
130
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID */
131
- /* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID_NEW */
132
- /* Excluded from this release type: BSON_DATA_ARRAY */
133
- /* Excluded from this release type: BSON_DATA_BINARY */
134
- /* Excluded from this release type: BSON_DATA_BOOLEAN */
135
- /* Excluded from this release type: BSON_DATA_CODE */
136
- /* Excluded from this release type: BSON_DATA_CODE_W_SCOPE */
137
- /* Excluded from this release type: BSON_DATA_DATE */
138
- /* Excluded from this release type: BSON_DATA_DBPOINTER */
139
- /* Excluded from this release type: BSON_DATA_DECIMAL128 */
140
- /* Excluded from this release type: BSON_DATA_INT */
141
- /* Excluded from this release type: BSON_DATA_LONG */
142
- /* Excluded from this release type: BSON_DATA_MAX_KEY */
143
- /* Excluded from this release type: BSON_DATA_MIN_KEY */
144
- /* Excluded from this release type: BSON_DATA_NULL */
145
- /* Excluded from this release type: BSON_DATA_NUMBER */
146
- /* Excluded from this release type: BSON_DATA_OBJECT */
147
- /* Excluded from this release type: BSON_DATA_OID */
148
- /* Excluded from this release type: BSON_DATA_REGEXP */
149
- /* Excluded from this release type: BSON_DATA_STRING */
150
- /* Excluded from this release type: BSON_DATA_SYMBOL */
151
- /* Excluded from this release type: BSON_DATA_TIMESTAMP */
152
- /* Excluded from this release type: BSON_DATA_UNDEFINED */
153
- /* Excluded from this release type: BSON_INT32_MAX */
154
- /* Excluded from this release type: BSON_INT32_MIN */
155
- /* Excluded from this release type: BSON_INT64_MAX */
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
- }
162
- /**
163
- * A class representation of the BSON RegExp type.
164
- * @public
165
- */
166
- export declare class BSONRegExp {
167
- _bsontype: 'BSONRegExp';
168
- pattern: string;
169
- options: string;
170
- /**
171
- * @param pattern - The regular expression pattern to match
172
- * @param options - The regular expression options
173
- */
174
- constructor(pattern: string, options?: string);
175
- static parseOptions(options?: string): string;
176
- }
177
- /** @public */
178
- export declare interface BSONRegExpExtended {
179
- $regularExpression: {
180
- pattern: string;
181
- options: string;
182
- };
183
- }
184
- /** @public */
185
- export declare interface BSONRegExpExtendedLegacy {
186
- $regex: string | BSONRegExp;
187
- $options: string;
188
- }
189
- /**
190
- * A class representation of the BSON Symbol type.
191
- * @public
192
- */
193
- export declare class BSONSymbol {
194
- _bsontype: 'Symbol';
195
- value: string;
196
- /**
197
- * @param value - the string representing the symbol.
198
- */
199
- constructor(value: string);
200
- /** Access the wrapped string value. */
201
- valueOf(): string;
202
- toString(): string;
203
- /* Excluded from this release type: inspect */
204
- toJSON(): string;
205
- }
206
- /** @public */
207
- export declare interface BSONSymbolExtended {
208
- $symbol: string;
209
- }
210
- /** @public */
211
- export declare class BSONTypeError extends TypeError {
212
- constructor(message: string);
213
- readonly name: string;
214
- }
215
- /**
216
- * Calculate the bson size for a passed in Javascript object.
217
- *
218
- * @param object - the Javascript object to calculate the BSON byte size for
219
- * @returns size of BSON object in bytes
220
- * @public
221
- */
222
- export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number;
223
- /** @public */
224
- export declare type CalculateObjectSizeOptions = Pick<SerializeOptions, 'serializeFunctions' | 'ignoreUndefined'>;
225
- /**
226
- * A class representation of the BSON Code type.
227
- * @public
228
- */
229
- export declare class Code {
230
- _bsontype: 'Code';
231
- code: string | Function;
232
- scope?: Document;
233
- /**
234
- * @param code - a string or function.
235
- * @param scope - an optional scope for the function.
236
- */
237
- constructor(code: string | Function, scope?: Document);
238
- toJSON(): {
239
- code: string | Function;
240
- scope?: Document;
241
- };
242
- /* Excluded from this release type: toExtendedJSON */
243
- /* Excluded from this release type: fromExtendedJSON */
244
- inspect(): string;
245
- }
246
- /** @public */
247
- export declare interface CodeExtended {
248
- $code: string | Function;
249
- $scope?: Document;
250
- }
251
- /**
252
- * A class representation of the BSON DBRef type.
253
- * @public
254
- */
255
- export declare class DBRef {
256
- _bsontype: 'DBRef';
257
- collection: string;
258
- oid: ObjectId;
259
- db?: string;
260
- fields: Document;
261
- /**
262
- * @param collection - the collection name.
263
- * @param oid - the reference ObjectId.
264
- * @param db - optional db name, if omitted the reference is local to the current db.
265
- */
266
- constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);
267
- /* Excluded from this release type: namespace */
268
- /* Excluded from this release type: namespace */
269
- toJSON(): DBRefLike & Document;
270
- /* Excluded from this release type: toExtendedJSON */
271
- /* Excluded from this release type: fromExtendedJSON */
272
- inspect(): string;
273
- }
274
- /** @public */
275
- export declare interface DBRefLike {
276
- $ref: string;
277
- $id: ObjectId;
278
- $db?: string;
279
- }
280
- /**
281
- * A class representation of the BSON Decimal128 type.
282
- * @public
283
- */
284
- export declare class Decimal128 {
285
- _bsontype: 'Decimal128';
286
- readonly bytes: Buffer;
287
- /**
288
- * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order,
289
- * or a string representation as returned by .toString()
290
- */
291
- constructor(bytes: Buffer | string);
292
- /**
293
- * Create a Decimal128 instance from a string representation
294
- *
295
- * @param representation - a numeric string representation.
296
- */
297
- static fromString(representation: string): Decimal128;
298
- /** Create a string representation of the raw Decimal128 value */
299
- toString(): string;
300
- toJSON(): Decimal128Extended;
301
- /* Excluded from this release type: toExtendedJSON */
302
- /* Excluded from this release type: fromExtendedJSON */
303
- inspect(): string;
304
- }
305
- /** @public */
306
- export declare interface Decimal128Extended {
307
- $numberDecimal: string;
308
- }
309
- /**
310
- * Deserialize data as BSON.
311
- *
312
- * @param buffer - the buffer containing the serialized set of BSON documents.
313
- * @returns returns the deserialized Javascript Object.
314
- * @public
315
- */
316
- export declare function deserialize(buffer: Buffer | ArrayBufferView | ArrayBuffer, options?: DeserializeOptions): Document;
317
- /** @public */
318
- export declare interface DeserializeOptions {
319
- /** evaluate functions in the BSON document scoped to the object deserialized. */
320
- evalFunctions?: boolean;
321
- /** cache evaluated functions for reuse. */
322
- cacheFunctions?: boolean;
323
- /**
324
- * use a crc32 code for caching, otherwise use the string of the function.
325
- * @deprecated this option to use the crc32 function never worked as intended
326
- * due to the fact that the crc32 function itself was never implemented.
327
- * */
328
- cacheFunctionsCrc32?: boolean;
329
- /** when deserializing a Long will fit it into a Number if it's smaller than 53 bits */
330
- promoteLongs?: boolean;
331
- /** when deserializing a Binary will return it as a node.js Buffer instance. */
332
- promoteBuffers?: boolean;
333
- /** when deserializing will promote BSON values to their Node.js closest equivalent types. */
334
- promoteValues?: boolean;
335
- /** allow to specify if there what fields we wish to return as unserialized raw buffer. */
336
- fieldsAsRaw?: Document;
337
- /** return BSON regular expressions as BSONRegExp instances. */
338
- bsonRegExp?: boolean;
339
- /** allows the buffer to be larger than the parsed BSON object */
340
- allowObjectSmallerThanBufferSize?: boolean;
341
- /** Offset into buffer to begin reading document from */
342
- index?: number;
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
- };
362
- }
363
- /**
364
- * Deserialize stream data as BSON documents.
365
- *
366
- * @param data - the buffer containing the serialized set of BSON documents.
367
- * @param startIndex - the start index in the data Buffer where the deserialization is to start.
368
- * @param numberOfDocuments - number of documents to deserialize.
369
- * @param documents - an array where to store the deserialized documents.
370
- * @param docStartIndex - the index in the documents array from where to start inserting documents.
371
- * @param options - additional options used for the deserialization.
372
- * @returns next index in the buffer after deserialization **x** numbers of documents.
373
- * @public
374
- */
375
- export declare function deserializeStream(data: Buffer | ArrayBufferView | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number;
376
- /** @public */
377
- export declare interface Document {
378
- [key: string]: any;
379
- }
380
- /**
381
- * A class representation of the BSON Double type.
382
- * @public
383
- */
384
- export declare class Double {
385
- _bsontype: 'Double';
386
- value: number;
387
- /**
388
- * Create a Double type
389
- *
390
- * @param value - the number we want to represent as a double.
391
- */
392
- constructor(value: number);
393
- /**
394
- * Access the number value.
395
- *
396
- * @returns returns the wrapped double number.
397
- */
398
- valueOf(): number;
399
- toJSON(): number;
400
- toString(radix?: number): string;
401
- /* Excluded from this release type: toExtendedJSON */
402
- /* Excluded from this release type: fromExtendedJSON */
403
- inspect(): string;
404
- }
405
- /** @public */
406
- export declare interface DoubleExtended {
407
- $numberDouble: string;
408
- }
409
- /**
410
- * EJSON parse / stringify API
411
- * @public
412
- */
413
- export declare namespace EJSON {
414
- export interface Options {
415
- /** Output using the Extended JSON v1 spec */
416
- legacy?: boolean;
417
- /** Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types */
418
- relaxed?: boolean;
419
- /**
420
- * Disable Extended JSON's `relaxed` mode, which attempts to return BSON types where possible, rather than native JS types
421
- * @deprecated Please use the relaxed property instead
422
- */
423
- strict?: boolean;
424
- }
425
- /**
426
- * Parse an Extended JSON string, constructing the JavaScript value or object described by that
427
- * string.
428
- *
429
- * @example
430
- * ```js
431
- * const { EJSON } = require('bson');
432
- * const text = '{ "int32": { "$numberInt": "10" } }';
433
- *
434
- * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
435
- * console.log(EJSON.parse(text, { relaxed: false }));
436
- *
437
- * // prints { int32: 10 }
438
- * console.log(EJSON.parse(text));
439
- * ```
440
- */
441
- export function parse(text: string, options?: EJSON.Options): SerializableTypes;
442
- export type JSONPrimitive = string | number | boolean | null;
443
- export type SerializableTypes = Document | Array<JSONPrimitive | Document> | JSONPrimitive;
444
- /**
445
- * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
446
- * function is specified or optionally including only the specified properties if a replacer array
447
- * is specified.
448
- *
449
- * @param value - The value to convert to extended JSON
450
- * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string
451
- * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes.
452
- * @param options - Optional settings
453
- *
454
- * @example
455
- * ```js
456
- * const { EJSON } = require('bson');
457
- * const Int32 = require('mongodb').Int32;
458
- * const doc = { int32: new Int32(10) };
459
- *
460
- * // prints '{"int32":{"$numberInt":"10"}}'
461
- * console.log(EJSON.stringify(doc, { relaxed: false }));
462
- *
463
- * // prints '{"int32":10}'
464
- * console.log(EJSON.stringify(doc));
465
- * ```
466
- */
467
- export function stringify(value: SerializableTypes, replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options, space?: string | number, options?: EJSON.Options): string;
468
- /**
469
- * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.
470
- *
471
- * @param value - The object to serialize
472
- * @param options - Optional settings passed to the `stringify` function
473
- */
474
- export function serialize(value: SerializableTypes, options?: EJSON.Options): Document;
475
- /**
476
- * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types
477
- *
478
- * @param ejson - The Extended JSON object to deserialize
479
- * @param options - Optional settings passed to the parse method
480
- */
481
- export function deserialize(ejson: Document, options?: EJSON.Options): SerializableTypes;
482
- }
483
- /** @public */
484
- export declare type EJSONOptions = EJSON.Options;
485
- /**
486
- * A class representation of a BSON Int32 type.
487
- * @public
488
- */
489
- export declare class Int32 {
490
- _bsontype: 'Int32';
491
- value: number;
492
- /**
493
- * Create an Int32 type
494
- *
495
- * @param value - the number we want to represent as an int32.
496
- */
497
- constructor(value: number | string);
498
- /**
499
- * Access the number value.
500
- *
501
- * @returns returns the wrapped int32 number.
502
- */
503
- valueOf(): number;
504
- toString(radix?: number): string;
505
- toJSON(): number;
506
- /* Excluded from this release type: toExtendedJSON */
507
- /* Excluded from this release type: fromExtendedJSON */
508
- inspect(): string;
509
- }
510
- /** @public */
511
- export declare interface Int32Extended {
512
- $numberInt: string;
513
- }
514
- declare const kId: unique symbol;
515
- declare const kId_2: unique symbol;
516
- /**
517
- * A class representing a 64-bit integer
518
- * @public
519
- * @remarks
520
- * The internal representation of a long is the two given signed, 32-bit values.
521
- * We use 32-bit pieces because these are the size of integers on which
522
- * Javascript performs bit-operations. For operations like addition and
523
- * multiplication, we split each number into 16 bit pieces, which can easily be
524
- * multiplied within Javascript's floating-point representation without overflow
525
- * or change in sign.
526
- * In the algorithms below, we frequently reduce the negative case to the
527
- * positive case by negating the input(s) and then post-processing the result.
528
- * Note that we must ALWAYS check specially whether those values are MIN_VALUE
529
- * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
530
- * a positive number, it overflows back into a negative). Not handling this
531
- * case would often result in infinite recursion.
532
- * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class.
533
- */
534
- export declare class Long {
535
- _bsontype: 'Long';
536
- /** An indicator used to reliably determine if an object is a Long or not. */
537
- __isLong__: true;
538
- /**
539
- * The high 32 bits as a signed value.
540
- */
541
- high: number;
542
- /**
543
- * The low 32 bits as a signed value.
544
- */
545
- low: number;
546
- /**
547
- * Whether unsigned or not.
548
- */
549
- unsigned: boolean;
550
- /**
551
- * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
552
- * See the from* functions below for more convenient ways of constructing Longs.
553
- *
554
- * Acceptable signatures are:
555
- * - Long(low, high, unsigned?)
556
- * - Long(bigint, unsigned?)
557
- * - Long(string, unsigned?)
558
- *
559
- * @param low - The low (signed) 32 bits of the long
560
- * @param high - The high (signed) 32 bits of the long
561
- * @param unsigned - Whether unsigned or not, defaults to signed
562
- */
563
- constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean);
564
- static TWO_PWR_24: Long;
565
- /** Maximum unsigned value. */
566
- static MAX_UNSIGNED_VALUE: Long;
567
- /** Signed zero */
568
- static ZERO: Long;
569
- /** Unsigned zero. */
570
- static UZERO: Long;
571
- /** Signed one. */
572
- static ONE: Long;
573
- /** Unsigned one. */
574
- static UONE: Long;
575
- /** Signed negative one. */
576
- static NEG_ONE: Long;
577
- /** Maximum signed value. */
578
- static MAX_VALUE: Long;
579
- /** Minimum signed value. */
580
- static MIN_VALUE: Long;
581
- /**
582
- * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits.
583
- * Each is assumed to use 32 bits.
584
- * @param lowBits - The low 32 bits
585
- * @param highBits - The high 32 bits
586
- * @param unsigned - Whether unsigned or not, defaults to signed
587
- * @returns The corresponding Long value
588
- */
589
- static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
590
- /**
591
- * Returns a Long representing the given 32 bit integer value.
592
- * @param value - The 32 bit integer in question
593
- * @param unsigned - Whether unsigned or not, defaults to signed
594
- * @returns The corresponding Long value
595
- */
596
- static fromInt(value: number, unsigned?: boolean): Long;
597
- /**
598
- * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
599
- * @param value - The number in question
600
- * @param unsigned - Whether unsigned or not, defaults to signed
601
- * @returns The corresponding Long value
602
- */
603
- static fromNumber(value: number, unsigned?: boolean): Long;
604
- /**
605
- * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
606
- * @param value - The number in question
607
- * @param unsigned - Whether unsigned or not, defaults to signed
608
- * @returns The corresponding Long value
609
- */
610
- static fromBigInt(value: bigint, unsigned?: boolean): Long;
611
- /**
612
- * Returns a Long representation of the given string, written using the specified radix.
613
- * @param str - The textual representation of the Long
614
- * @param unsigned - Whether unsigned or not, defaults to signed
615
- * @param radix - The radix in which the text is written (2-36), defaults to 10
616
- * @returns The corresponding Long value
617
- */
618
- static fromString(str: string, unsigned?: boolean, radix?: number): Long;
619
- /**
620
- * Creates a Long from its byte representation.
621
- * @param bytes - Byte representation
622
- * @param unsigned - Whether unsigned or not, defaults to signed
623
- * @param le - Whether little or big endian, defaults to big endian
624
- * @returns The corresponding Long value
625
- */
626
- static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;
627
- /**
628
- * Creates a Long from its little endian byte representation.
629
- * @param bytes - Little endian byte representation
630
- * @param unsigned - Whether unsigned or not, defaults to signed
631
- * @returns The corresponding Long value
632
- */
633
- static fromBytesLE(bytes: number[], unsigned?: boolean): Long;
634
- /**
635
- * Creates a Long from its big endian byte representation.
636
- * @param bytes - Big endian byte representation
637
- * @param unsigned - Whether unsigned or not, defaults to signed
638
- * @returns The corresponding Long value
639
- */
640
- static fromBytesBE(bytes: number[], unsigned?: boolean): Long;
641
- /**
642
- * Tests if the specified object is a Long.
643
- */
644
- static isLong(value: any): value is Long;
645
- /**
646
- * Converts the specified value to a Long.
647
- * @param unsigned - Whether unsigned or not, defaults to signed
648
- */
649
- static fromValue(val: number | string | {
650
- low: number;
651
- high: number;
652
- unsigned?: boolean;
653
- }, unsigned?: boolean): Long;
654
- /** Returns the sum of this and the specified Long. */
655
- add(addend: string | number | Long | Timestamp): Long;
656
- /**
657
- * Returns the sum of this and the specified Long.
658
- * @returns Sum
659
- */
660
- and(other: string | number | Long | Timestamp): Long;
661
- /**
662
- * Compares this Long's value with the specified's.
663
- * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
664
- */
665
- compare(other: string | number | Long | Timestamp): 0 | 1 | -1;
666
- /** This is an alias of {@link Long.compare} */
667
- comp(other: string | number | Long | Timestamp): 0 | 1 | -1;
668
- /**
669
- * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned.
670
- * @returns Quotient
671
- */
672
- divide(divisor: string | number | Long | Timestamp): Long;
673
- /**This is an alias of {@link Long.divide} */
674
- div(divisor: string | number | Long | Timestamp): Long;
675
- /**
676
- * Tests if this Long's value equals the specified's.
677
- * @param other - Other value
678
- */
679
- equals(other: string | number | Long | Timestamp): boolean;
680
- /** This is an alias of {@link Long.equals} */
681
- eq(other: string | number | Long | Timestamp): boolean;
682
- /** Gets the high 32 bits as a signed integer. */
683
- getHighBits(): number;
684
- /** Gets the high 32 bits as an unsigned integer. */
685
- getHighBitsUnsigned(): number;
686
- /** Gets the low 32 bits as a signed integer. */
687
- getLowBits(): number;
688
- /** Gets the low 32 bits as an unsigned integer. */
689
- getLowBitsUnsigned(): number;
690
- /** Gets the number of bits needed to represent the absolute value of this Long. */
691
- getNumBitsAbs(): number;
692
- /** Tests if this Long's value is greater than the specified's. */
693
- greaterThan(other: string | number | Long | Timestamp): boolean;
694
- /** This is an alias of {@link Long.greaterThan} */
695
- gt(other: string | number | Long | Timestamp): boolean;
696
- /** Tests if this Long's value is greater than or equal the specified's. */
697
- greaterThanOrEqual(other: string | number | Long | Timestamp): boolean;
698
- /** This is an alias of {@link Long.greaterThanOrEqual} */
699
- gte(other: string | number | Long | Timestamp): boolean;
700
- /** This is an alias of {@link Long.greaterThanOrEqual} */
701
- ge(other: string | number | Long | Timestamp): boolean;
702
- /** Tests if this Long's value is even. */
703
- isEven(): boolean;
704
- /** Tests if this Long's value is negative. */
705
- isNegative(): boolean;
706
- /** Tests if this Long's value is odd. */
707
- isOdd(): boolean;
708
- /** Tests if this Long's value is positive. */
709
- isPositive(): boolean;
710
- /** Tests if this Long's value equals zero. */
711
- isZero(): boolean;
712
- /** Tests if this Long's value is less than the specified's. */
713
- lessThan(other: string | number | Long | Timestamp): boolean;
714
- /** This is an alias of {@link Long#lessThan}. */
715
- lt(other: string | number | Long | Timestamp): boolean;
716
- /** Tests if this Long's value is less than or equal the specified's. */
717
- lessThanOrEqual(other: string | number | Long | Timestamp): boolean;
718
- /** This is an alias of {@link Long.lessThanOrEqual} */
719
- lte(other: string | number | Long | Timestamp): boolean;
720
- /** Returns this Long modulo the specified. */
721
- modulo(divisor: string | number | Long | Timestamp): Long;
722
- /** This is an alias of {@link Long.modulo} */
723
- mod(divisor: string | number | Long | Timestamp): Long;
724
- /** This is an alias of {@link Long.modulo} */
725
- rem(divisor: string | number | Long | Timestamp): Long;
726
- /**
727
- * Returns the product of this and the specified Long.
728
- * @param multiplier - Multiplier
729
- * @returns Product
730
- */
731
- multiply(multiplier: string | number | Long | Timestamp): Long;
732
- /** This is an alias of {@link Long.multiply} */
733
- mul(multiplier: string | number | Long | Timestamp): Long;
734
- /** Returns the Negation of this Long's value. */
735
- negate(): Long;
736
- /** This is an alias of {@link Long.negate} */
737
- neg(): Long;
738
- /** Returns the bitwise NOT of this Long. */
739
- not(): Long;
740
- /** Tests if this Long's value differs from the specified's. */
741
- notEquals(other: string | number | Long | Timestamp): boolean;
742
- /** This is an alias of {@link Long.notEquals} */
743
- neq(other: string | number | Long | Timestamp): boolean;
744
- /** This is an alias of {@link Long.notEquals} */
745
- ne(other: string | number | Long | Timestamp): boolean;
746
- /**
747
- * Returns the bitwise OR of this Long and the specified.
748
- */
749
- or(other: number | string | Long): Long;
750
- /**
751
- * Returns this Long with bits shifted to the left by the given amount.
752
- * @param numBits - Number of bits
753
- * @returns Shifted Long
754
- */
755
- shiftLeft(numBits: number | Long): Long;
756
- /** This is an alias of {@link Long.shiftLeft} */
757
- shl(numBits: number | Long): Long;
758
- /**
759
- * Returns this Long with bits arithmetically shifted to the right by the given amount.
760
- * @param numBits - Number of bits
761
- * @returns Shifted Long
762
- */
763
- shiftRight(numBits: number | Long): Long;
764
- /** This is an alias of {@link Long.shiftRight} */
765
- shr(numBits: number | Long): Long;
766
- /**
767
- * Returns this Long with bits logically shifted to the right by the given amount.
768
- * @param numBits - Number of bits
769
- * @returns Shifted Long
770
- */
771
- shiftRightUnsigned(numBits: Long | number): Long;
772
- /** This is an alias of {@link Long.shiftRightUnsigned} */
773
- shr_u(numBits: number | Long): Long;
774
- /** This is an alias of {@link Long.shiftRightUnsigned} */
775
- shru(numBits: number | Long): Long;
776
- /**
777
- * Returns the difference of this and the specified Long.
778
- * @param subtrahend - Subtrahend
779
- * @returns Difference
780
- */
781
- subtract(subtrahend: string | number | Long | Timestamp): Long;
782
- /** This is an alias of {@link Long.subtract} */
783
- sub(subtrahend: string | number | Long | Timestamp): Long;
784
- /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */
785
- toInt(): number;
786
- /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */
787
- toNumber(): number;
788
- /** Converts the Long to a BigInt (arbitrary precision). */
789
- toBigInt(): bigint;
790
- /**
791
- * Converts this Long to its byte representation.
792
- * @param le - Whether little or big endian, defaults to big endian
793
- * @returns Byte representation
794
- */
795
- toBytes(le?: boolean): number[];
796
- /**
797
- * Converts this Long to its little endian byte representation.
798
- * @returns Little endian byte representation
799
- */
800
- toBytesLE(): number[];
801
- /**
802
- * Converts this Long to its big endian byte representation.
803
- * @returns Big endian byte representation
804
- */
805
- toBytesBE(): number[];
806
- /**
807
- * Converts this Long to signed.
808
- */
809
- toSigned(): Long;
810
- /**
811
- * Converts the Long to a string written in the specified radix.
812
- * @param radix - Radix (2-36), defaults to 10
813
- * @throws RangeError If `radix` is out of range
814
- */
815
- toString(radix?: number): string;
816
- /** Converts this Long to unsigned. */
817
- toUnsigned(): Long;
818
- /** Returns the bitwise XOR of this Long and the given one. */
819
- xor(other: Long | number | string): Long;
820
- /** This is an alias of {@link Long.isZero} */
821
- eqz(): boolean;
822
- /** This is an alias of {@link Long.lessThanOrEqual} */
823
- le(other: string | number | Long | Timestamp): boolean;
824
- toExtendedJSON(options?: EJSONOptions): number | LongExtended;
825
- static fromExtendedJSON(doc: {
826
- $numberLong: string;
827
- }, options?: EJSONOptions): number | Long;
828
- inspect(): string;
829
- }
830
- /** @public */
831
- export declare interface LongExtended {
832
- $numberLong: string;
833
- }
834
- /** @public */
835
- export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => {
836
- [P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
837
- };
838
- /** @public */
839
- export declare const LongWithoutOverridesClass: LongWithoutOverrides;
840
- /** @public */
841
- declare let Map_2: MapConstructor;
842
- export { Map_2 as Map };
843
- /**
844
- * A class representation of the BSON MaxKey type.
845
- * @public
846
- */
847
- export declare class MaxKey {
848
- _bsontype: 'MaxKey';
849
- constructor();
850
- /* Excluded from this release type: toExtendedJSON */
851
- /* Excluded from this release type: fromExtendedJSON */
852
- inspect(): string;
853
- }
854
- /** @public */
855
- export declare interface MaxKeyExtended {
856
- $maxKey: 1;
857
- }
858
- /**
859
- * A class representation of the BSON MinKey type.
860
- * @public
861
- */
862
- export declare class MinKey {
863
- _bsontype: 'MinKey';
864
- constructor();
865
- /* Excluded from this release type: toExtendedJSON */
866
- /* Excluded from this release type: fromExtendedJSON */
867
- inspect(): string;
868
- }
869
- /** @public */
870
- export declare interface MinKeyExtended {
871
- $minKey: 1;
872
- }
873
- /**
874
- * A class representation of the BSON ObjectId type.
875
- * @public
876
- */
877
- declare class ObjectId {
878
- _bsontype: 'ObjectId';
879
- /* Excluded from this release type: index */
880
- static cacheHexString: boolean;
881
- /* Excluded from this release type: [kId] */
882
- /* Excluded from this release type: __id */
883
- /**
884
- * Create an ObjectId type
885
- *
886
- * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
887
- */
888
- constructor(inputId?: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array);
889
- /*
890
- * The ObjectId bytes
891
- * @readonly
892
- */
893
- id: Buffer;
894
- /*
895
- * The generation time of this ObjectId instance
896
- * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch
897
- */
898
- generationTime: number;
899
- /** Returns the ObjectId id as a 24 character hex string representation */
900
- toHexString(): string;
901
- /* Excluded from this release type: getInc */
902
- /**
903
- * Generate a 12 byte id buffer used in ObjectId's
904
- *
905
- * @param time - pass in a second based timestamp.
906
- */
907
- static generate(time?: number): Buffer;
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;
916
- /**
917
- * Compares the equality of this ObjectId with `otherID`.
918
- *
919
- * @param otherId - ObjectId instance to compare against.
920
- */
921
- equals(otherId: string | ObjectId | ObjectIdLike): boolean;
922
- /** Returns the generation date (accurate up to the second) that this ID was generated. */
923
- getTimestamp(): Date;
924
- /* Excluded from this release type: createPk */
925
- /**
926
- * Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
927
- *
928
- * @param time - an integer number representing a number of seconds.
929
- */
930
- static createFromTime(time: number): ObjectId;
931
- /**
932
- * Creates an ObjectId from a hex string representation of an ObjectId.
933
- *
934
- * @param hexString - create a ObjectId from a passed in 24 character hexstring.
935
- */
936
- static createFromHexString(hexString: string): ObjectId;
937
- /**
938
- * Checks if a value is a valid bson ObjectId
939
- *
940
- * @param id - ObjectId instance to validate.
941
- */
942
- static isValid(id: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array): boolean;
943
- /* Excluded from this release type: toExtendedJSON */
944
- /* Excluded from this release type: fromExtendedJSON */
945
- inspect(): string;
946
- }
947
- export { ObjectId as ObjectID };
948
- export { ObjectId };
949
- /** @public */
950
- export declare interface ObjectIdExtended {
951
- $oid: string;
952
- }
953
- /** @public */
954
- export declare interface ObjectIdLike {
955
- id: string | Buffer;
956
- __id?: string;
957
- toHexString(): string;
958
- }
959
- /**
960
- * Serialize a Javascript object.
961
- *
962
- * @param object - the Javascript object to serialize.
963
- * @returns Buffer object containing the serialized object.
964
- * @public
965
- */
966
- export declare function serialize(object: Document, options?: SerializeOptions): Buffer;
967
- /** @public */
968
- export declare interface SerializeOptions {
969
- /** the serializer will check if keys are valid. */
970
- checkKeys?: boolean;
971
- /** serialize the javascript functions **(default:false)**. */
972
- serializeFunctions?: boolean;
973
- /** serialize will not emit undefined fields **(default:true)** */
974
- ignoreUndefined?: boolean;
975
- /* Excluded from this release type: minInternalBufferSize */
976
- /** the index in the buffer where we wish to start serializing into */
977
- index?: number;
978
- }
979
- /**
980
- * Serialize a Javascript object using a predefined Buffer and index into the buffer,
981
- * useful when pre-allocating the space for serialization.
982
- *
983
- * @param object - the Javascript object to serialize.
984
- * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object.
985
- * @returns the index pointing to the last written byte in the buffer.
986
- * @public
987
- */
988
- export declare function serializeWithBufferAndIndex(object: Document, finalBuffer: Buffer, options?: SerializeOptions): number;
989
- /**
990
- * Sets the size of the internal serialization buffer.
991
- *
992
- * @param size - The desired size for the internal serialization buffer
993
- * @public
994
- */
995
- export declare function setInternalBufferSize(size: number): void;
996
- /** @public */
997
- export declare class Timestamp extends LongWithoutOverridesClass {
998
- _bsontype: 'Timestamp';
999
- static readonly MAX_VALUE: Long;
1000
- /**
1001
- * @param low - A 64-bit Long representing the Timestamp.
1002
- */
1003
- constructor(long: Long);
1004
- /**
1005
- * @param value - A pair of two values indicating timestamp and increment.
1006
- */
1007
- constructor(value: {
1008
- t: number;
1009
- i: number;
1010
- });
1011
- /**
1012
- * @param low - the low (signed) 32 bits of the Timestamp.
1013
- * @param high - the high (signed) 32 bits of the Timestamp.
1014
- * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead.
1015
- */
1016
- constructor(low: number, high: number);
1017
- toJSON(): {
1018
- $timestamp: string;
1019
- };
1020
- /** Returns a Timestamp represented by the given (32-bit) integer value. */
1021
- static fromInt(value: number): Timestamp;
1022
- /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
1023
- static fromNumber(value: number): Timestamp;
1024
- /**
1025
- * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
1026
- *
1027
- * @param lowBits - the low 32-bits.
1028
- * @param highBits - the high 32-bits.
1029
- */
1030
- static fromBits(lowBits: number, highBits: number): Timestamp;
1031
- /**
1032
- * Returns a Timestamp from the given string, optionally using the given radix.
1033
- *
1034
- * @param str - the textual representation of the Timestamp.
1035
- * @param optRadix - the radix in which the text is written.
1036
- */
1037
- static fromString(str: string, optRadix: number): Timestamp;
1038
- /* Excluded from this release type: toExtendedJSON */
1039
- /* Excluded from this release type: fromExtendedJSON */
1040
- inspect(): string;
1041
- }
1042
- /** @public */
1043
- export declare interface TimestampExtended {
1044
- $timestamp: {
1045
- t: number;
1046
- i: number;
1047
- };
1048
- }
1049
- /** @public */
1050
- export declare type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect';
1051
- /**
1052
- * A class representation of the BSON UUID type.
1053
- * @public
1054
- */
1055
- export declare class UUID {
1056
- _bsontype: 'UUID';
1057
- static cacheHexString: boolean;
1058
- /* Excluded from this release type: [kId] */
1059
- /* Excluded from this release type: __id */
1060
- /**
1061
- * Create an UUID type
1062
- *
1063
- * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer.
1064
- */
1065
- constructor(input?: string | Buffer | UUID);
1066
- /*
1067
- * The UUID bytes
1068
- * @readonly
1069
- */
1070
- id: Buffer;
1071
- /**
1072
- * Generate a 16 byte uuid v4 buffer used in UUIDs
1073
- */
1074
- /**
1075
- * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated)
1076
- * @param includeDashes - should the string exclude dash-separators.
1077
- * */
1078
- toHexString(includeDashes?: boolean): string;
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;
1088
- /**
1089
- * Compares the equality of this UUID with `otherID`.
1090
- *
1091
- * @param otherId - UUID instance to compare against.
1092
- */
1093
- equals(otherId: string | Buffer | UUID): boolean;
1094
- /**
1095
- * Creates a Binary instance from the current UUID.
1096
- */
1097
- toBinary(): Binary;
1098
- /**
1099
- * Generates a populated buffer containing a v4 uuid
1100
- */
1101
- static generate(): Buffer;
1102
- /**
1103
- * Checks if a value is a valid bson UUID
1104
- * @param input - UUID, string or Buffer to validate.
1105
- */
1106
- static isValid(input: string | Buffer | UUID): boolean;
1107
- /**
1108
- * Creates an UUID from a hex string representation of an UUID.
1109
- * @param hexString - 32 or 36 character hex string (dashes excluded/included).
1110
- */
1111
- static createFromHexString(hexString: string): UUID;
1112
- inspect(): string;
1113
- }
1114
- /** @public */
1115
- export declare type UUIDExtended = {
1116
- $uuid: string;
1117
- };
1118
- export {};
1
+ import { Buffer } from 'buffer';
2
+
3
+ /**
4
+ * A class representation of the BSON Binary type.
5
+ * @public
6
+ * @category BSONType
7
+ */
8
+ export declare class Binary {
9
+ _bsontype: 'Binary';
10
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
11
+ /** Initial buffer default size */
12
+ static readonly BUFFER_SIZE = 256;
13
+ /** Default BSON type */
14
+ static readonly SUBTYPE_DEFAULT = 0;
15
+ /** Function BSON type */
16
+ static readonly SUBTYPE_FUNCTION = 1;
17
+ /** Byte Array BSON type */
18
+ static readonly SUBTYPE_BYTE_ARRAY = 2;
19
+ /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */
20
+ static readonly SUBTYPE_UUID_OLD = 3;
21
+ /** UUID BSON type */
22
+ static readonly SUBTYPE_UUID = 4;
23
+ /** MD5 BSON type */
24
+ static readonly SUBTYPE_MD5 = 5;
25
+ /** Encrypted BSON type */
26
+ static readonly SUBTYPE_ENCRYPTED = 6;
27
+ /** Column BSON type */
28
+ static readonly SUBTYPE_COLUMN = 7;
29
+ /** User BSON type */
30
+ static readonly SUBTYPE_USER_DEFINED = 128;
31
+ buffer: Buffer;
32
+ sub_type: number;
33
+ position: number;
34
+ /**
35
+ * @param buffer - a buffer object containing the binary data.
36
+ * @param subType - the option binary type.
37
+ */
38
+ constructor(buffer?: string | BinarySequence, subType?: number);
39
+ /**
40
+ * Updates this binary with byte_value.
41
+ *
42
+ * @param byteValue - a single byte we wish to write.
43
+ */
44
+ put(byteValue: string | number | Uint8Array | Buffer | number[]): void;
45
+ /**
46
+ * Writes a buffer or string to the binary.
47
+ *
48
+ * @param sequence - a string or buffer to be written to the Binary BSON object.
49
+ * @param offset - specify the binary of where to write the content.
50
+ */
51
+ write(sequence: string | BinarySequence, offset: number): void;
52
+ /**
53
+ * Reads **length** bytes starting at **position**.
54
+ *
55
+ * @param position - read from the given position in the Binary.
56
+ * @param length - the number of bytes to read.
57
+ */
58
+ read(position: number, length: number): BinarySequence;
59
+ /**
60
+ * Returns the value of this binary as a string.
61
+ * @param asRaw - Will skip converting to a string
62
+ * @remarks
63
+ * This is handy when calling this function conditionally for some key value pairs and not others
64
+ */
65
+ value(asRaw?: boolean): string | BinarySequence;
66
+ /** the length of the binary sequence */
67
+ length(): number;
68
+ toJSON(): string;
69
+ toString(format?: string): string;
70
+ /* Excluded from this release type: toExtendedJSON */
71
+ toUUID(): UUID;
72
+ /* Excluded from this release type: fromExtendedJSON */
73
+ inspect(): string;
74
+ }
75
+
76
+ /** @public */
77
+ export declare interface BinaryExtended {
78
+ $binary: {
79
+ subType: string;
80
+ base64: string;
81
+ };
82
+ }
83
+
84
+ /** @public */
85
+ export declare interface BinaryExtendedLegacy {
86
+ $type: string;
87
+ $binary: string;
88
+ }
89
+
90
+ /** @public */
91
+ export declare type BinarySequence = Uint8Array | Buffer | number[];
92
+
93
+ /**
94
+ * BSON default export
95
+ * @deprecated Please use named exports
96
+ * @privateRemarks
97
+ * We want to someday deprecate the default export,
98
+ * so none of the new TS types are being exported on the default
99
+ * @public
100
+ */
101
+ declare const BSON: {
102
+ Binary: typeof Binary;
103
+ Code: typeof Code;
104
+ DBRef: typeof DBRef;
105
+ Decimal128: typeof Decimal128;
106
+ Double: typeof Double;
107
+ Int32: typeof Int32;
108
+ Long: typeof Long;
109
+ UUID: typeof UUID;
110
+ Map: MapConstructor;
111
+ MaxKey: typeof MaxKey;
112
+ MinKey: typeof MinKey;
113
+ ObjectId: typeof ObjectId;
114
+ ObjectID: typeof ObjectId;
115
+ BSONRegExp: typeof BSONRegExp;
116
+ BSONSymbol: typeof BSONSymbol;
117
+ Timestamp: typeof Timestamp;
118
+ EJSON: typeof EJSON;
119
+ setInternalBufferSize: typeof setInternalBufferSize;
120
+ serialize: typeof serialize;
121
+ serializeWithBufferAndIndex: typeof serializeWithBufferAndIndex;
122
+ deserialize: typeof deserialize;
123
+ calculateObjectSize: typeof calculateObjectSize;
124
+ deserializeStream: typeof deserializeStream;
125
+ BSONError: typeof BSONError;
126
+ BSONTypeError: typeof BSONTypeError;
127
+ };
128
+ export default BSON;
129
+
130
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_BYTE_ARRAY */
131
+
132
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_COLUMN */
133
+
134
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
135
+
136
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_ENCRYPTED */
137
+
138
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_FUNCTION */
139
+
140
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_MD5 */
141
+
142
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_USER_DEFINED */
143
+
144
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID */
145
+
146
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_UUID_NEW */
147
+
148
+ /* Excluded from this release type: BSON_DATA_ARRAY */
149
+
150
+ /* Excluded from this release type: BSON_DATA_BINARY */
151
+
152
+ /* Excluded from this release type: BSON_DATA_BOOLEAN */
153
+
154
+ /* Excluded from this release type: BSON_DATA_CODE */
155
+
156
+ /* Excluded from this release type: BSON_DATA_CODE_W_SCOPE */
157
+
158
+ /* Excluded from this release type: BSON_DATA_DATE */
159
+
160
+ /* Excluded from this release type: BSON_DATA_DBPOINTER */
161
+
162
+ /* Excluded from this release type: BSON_DATA_DECIMAL128 */
163
+
164
+ /* Excluded from this release type: BSON_DATA_INT */
165
+
166
+ /* Excluded from this release type: BSON_DATA_LONG */
167
+
168
+ /* Excluded from this release type: BSON_DATA_MAX_KEY */
169
+
170
+ /* Excluded from this release type: BSON_DATA_MIN_KEY */
171
+
172
+ /* Excluded from this release type: BSON_DATA_NULL */
173
+
174
+ /* Excluded from this release type: BSON_DATA_NUMBER */
175
+
176
+ /* Excluded from this release type: BSON_DATA_OBJECT */
177
+
178
+ /* Excluded from this release type: BSON_DATA_OID */
179
+
180
+ /* Excluded from this release type: BSON_DATA_REGEXP */
181
+
182
+ /* Excluded from this release type: BSON_DATA_STRING */
183
+
184
+ /* Excluded from this release type: BSON_DATA_SYMBOL */
185
+
186
+ /* Excluded from this release type: BSON_DATA_TIMESTAMP */
187
+
188
+ /* Excluded from this release type: BSON_DATA_UNDEFINED */
189
+
190
+ /* Excluded from this release type: BSON_INT32_MAX */
191
+
192
+ /* Excluded from this release type: BSON_INT32_MIN */
193
+
194
+ /* Excluded from this release type: BSON_INT64_MAX */
195
+
196
+ /* Excluded from this release type: BSON_INT64_MIN */
197
+
198
+ /** @public */
199
+ export declare class BSONError extends Error {
200
+ constructor(message: string);
201
+ get name(): string;
202
+ }
203
+
204
+ /**
205
+ * A class representation of the BSON RegExp type.
206
+ * @public
207
+ * @category BSONType
208
+ */
209
+ export declare class BSONRegExp {
210
+ _bsontype: 'BSONRegExp';
211
+ pattern: string;
212
+ options: string;
213
+ /**
214
+ * @param pattern - The regular expression pattern to match
215
+ * @param options - The regular expression options
216
+ */
217
+ constructor(pattern: string, options?: string);
218
+ static parseOptions(options?: string): string;
219
+ /* Excluded from this release type: toExtendedJSON */
220
+ /* Excluded from this release type: fromExtendedJSON */
221
+ }
222
+
223
+ /** @public */
224
+ export declare interface BSONRegExpExtended {
225
+ $regularExpression: {
226
+ pattern: string;
227
+ options: string;
228
+ };
229
+ }
230
+
231
+ /** @public */
232
+ export declare interface BSONRegExpExtendedLegacy {
233
+ $regex: string | BSONRegExp;
234
+ $options: string;
235
+ }
236
+
237
+ /**
238
+ * A class representation of the BSON Symbol type.
239
+ * @public
240
+ * @category BSONType
241
+ */
242
+ export declare class BSONSymbol {
243
+ _bsontype: 'Symbol';
244
+ value: string;
245
+ /**
246
+ * @param value - the string representing the symbol.
247
+ */
248
+ constructor(value: string);
249
+ /** Access the wrapped string value. */
250
+ valueOf(): string;
251
+ toString(): string;
252
+ /* Excluded from this release type: inspect */
253
+ toJSON(): string;
254
+ /* Excluded from this release type: toExtendedJSON */
255
+ /* Excluded from this release type: fromExtendedJSON */
256
+ }
257
+
258
+ /** @public */
259
+ export declare interface BSONSymbolExtended {
260
+ $symbol: string;
261
+ }
262
+
263
+ /** @public */
264
+ export declare class BSONTypeError extends TypeError {
265
+ constructor(message: string);
266
+ get name(): string;
267
+ }
268
+
269
+ /**
270
+ * Calculate the bson size for a passed in Javascript object.
271
+ *
272
+ * @param object - the Javascript object to calculate the BSON byte size for
273
+ * @returns size of BSON object in bytes
274
+ * @public
275
+ */
276
+ export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number;
277
+
278
+ /** @public */
279
+ export declare type CalculateObjectSizeOptions = Pick<SerializeOptions, 'serializeFunctions' | 'ignoreUndefined'>;
280
+
281
+ /**
282
+ * A class representation of the BSON Code type.
283
+ * @public
284
+ * @category BSONType
285
+ */
286
+ export declare class Code {
287
+ _bsontype: 'Code';
288
+ code: string | Function;
289
+ scope?: Document;
290
+ /**
291
+ * @param code - a string or function.
292
+ * @param scope - an optional scope for the function.
293
+ */
294
+ constructor(code: string | Function, scope?: Document);
295
+ toJSON(): {
296
+ code: string | Function;
297
+ scope?: Document;
298
+ };
299
+ /* Excluded from this release type: toExtendedJSON */
300
+ /* Excluded from this release type: fromExtendedJSON */
301
+ inspect(): string;
302
+ }
303
+
304
+ /** @public */
305
+ export declare interface CodeExtended {
306
+ $code: string | Function;
307
+ $scope?: Document;
308
+ }
309
+
310
+ /**
311
+ * A class representation of the BSON DBRef type.
312
+ * @public
313
+ * @category BSONType
314
+ */
315
+ export declare class DBRef {
316
+ _bsontype: 'DBRef';
317
+ collection: string;
318
+ oid: ObjectId;
319
+ db?: string;
320
+ fields: Document;
321
+ /**
322
+ * @param collection - the collection name.
323
+ * @param oid - the reference ObjectId.
324
+ * @param db - optional db name, if omitted the reference is local to the current db.
325
+ */
326
+ constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);
327
+ /* Excluded from this release type: namespace */
328
+ /* Excluded from this release type: namespace */
329
+ toJSON(): DBRefLike & Document;
330
+ /* Excluded from this release type: toExtendedJSON */
331
+ /* Excluded from this release type: fromExtendedJSON */
332
+ inspect(): string;
333
+ }
334
+
335
+ /** @public */
336
+ export declare interface DBRefLike {
337
+ $ref: string;
338
+ $id: ObjectId;
339
+ $db?: string;
340
+ }
341
+
342
+ /**
343
+ * A class representation of the BSON Decimal128 type.
344
+ * @public
345
+ * @category BSONType
346
+ */
347
+ export declare class Decimal128 {
348
+ _bsontype: 'Decimal128';
349
+ readonly bytes: Buffer;
350
+ /**
351
+ * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order,
352
+ * or a string representation as returned by .toString()
353
+ */
354
+ constructor(bytes: Buffer | string);
355
+ /**
356
+ * Create a Decimal128 instance from a string representation
357
+ *
358
+ * @param representation - a numeric string representation.
359
+ */
360
+ static fromString(representation: string): Decimal128;
361
+ /** Create a string representation of the raw Decimal128 value */
362
+ toString(): string;
363
+ toJSON(): Decimal128Extended;
364
+ /* Excluded from this release type: toExtendedJSON */
365
+ /* Excluded from this release type: fromExtendedJSON */
366
+ inspect(): string;
367
+ }
368
+
369
+ /** @public */
370
+ export declare interface Decimal128Extended {
371
+ $numberDecimal: string;
372
+ }
373
+
374
+ /**
375
+ * Deserialize data as BSON.
376
+ *
377
+ * @param buffer - the buffer containing the serialized set of BSON documents.
378
+ * @returns returns the deserialized Javascript Object.
379
+ * @public
380
+ */
381
+ export declare function deserialize(buffer: Buffer | ArrayBufferView | ArrayBuffer, options?: DeserializeOptions): Document;
382
+
383
+ /** @public */
384
+ export declare interface DeserializeOptions {
385
+ /** evaluate functions in the BSON document scoped to the object deserialized. */
386
+ evalFunctions?: boolean;
387
+ /** cache evaluated functions for reuse. */
388
+ cacheFunctions?: boolean;
389
+ /**
390
+ * use a crc32 code for caching, otherwise use the string of the function.
391
+ * @deprecated this option to use the crc32 function never worked as intended
392
+ * due to the fact that the crc32 function itself was never implemented.
393
+ * */
394
+ cacheFunctionsCrc32?: boolean;
395
+ /** when deserializing a Long will fit it into a Number if it's smaller than 53 bits */
396
+ promoteLongs?: boolean;
397
+ /** when deserializing a Binary will return it as a node.js Buffer instance. */
398
+ promoteBuffers?: boolean;
399
+ /** when deserializing will promote BSON values to their Node.js closest equivalent types. */
400
+ promoteValues?: boolean;
401
+ /** allow to specify if there what fields we wish to return as unserialized raw buffer. */
402
+ fieldsAsRaw?: Document;
403
+ /** return BSON regular expressions as BSONRegExp instances. */
404
+ bsonRegExp?: boolean;
405
+ /** allows the buffer to be larger than the parsed BSON object */
406
+ allowObjectSmallerThanBufferSize?: boolean;
407
+ /** Offset into buffer to begin reading document from */
408
+ index?: number;
409
+ raw?: boolean;
410
+ /** Allows for opt-out utf-8 validation for all keys or
411
+ * specified keys. Must be all true or all false.
412
+ *
413
+ * @example
414
+ * ```js
415
+ * // disables validation on all keys
416
+ * validation: { utf8: false }
417
+ *
418
+ * // enables validation only on specified keys a, b, and c
419
+ * validation: { utf8: { a: true, b: true, c: true } }
420
+ *
421
+ * // disables validation only on specified keys a, b
422
+ * validation: { utf8: { a: false, b: false } }
423
+ * ```
424
+ */
425
+ validation?: {
426
+ utf8: boolean | Record<string, true> | Record<string, false>;
427
+ };
428
+ }
429
+
430
+ /**
431
+ * Deserialize stream data as BSON documents.
432
+ *
433
+ * @param data - the buffer containing the serialized set of BSON documents.
434
+ * @param startIndex - the start index in the data Buffer where the deserialization is to start.
435
+ * @param numberOfDocuments - number of documents to deserialize.
436
+ * @param documents - an array where to store the deserialized documents.
437
+ * @param docStartIndex - the index in the documents array from where to start inserting documents.
438
+ * @param options - additional options used for the deserialization.
439
+ * @returns next index in the buffer after deserialization **x** numbers of documents.
440
+ * @public
441
+ */
442
+ export declare function deserializeStream(data: Buffer | ArrayBufferView | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number;
443
+
444
+ /** @public */
445
+ export declare interface Document {
446
+ [key: string]: any;
447
+ }
448
+
449
+ /**
450
+ * A class representation of the BSON Double type.
451
+ * @public
452
+ * @category BSONType
453
+ */
454
+ export declare class Double {
455
+ _bsontype: 'Double';
456
+ value: number;
457
+ /**
458
+ * Create a Double type
459
+ *
460
+ * @param value - the number we want to represent as a double.
461
+ */
462
+ constructor(value: number);
463
+ /**
464
+ * Access the number value.
465
+ *
466
+ * @returns returns the wrapped double number.
467
+ */
468
+ valueOf(): number;
469
+ toJSON(): number;
470
+ toString(radix?: number): string;
471
+ /* Excluded from this release type: toExtendedJSON */
472
+ /* Excluded from this release type: fromExtendedJSON */
473
+ inspect(): string;
474
+ }
475
+
476
+ /** @public */
477
+ export declare interface DoubleExtended {
478
+ $numberDouble: string;
479
+ }
480
+
481
+ /**
482
+ * EJSON parse / stringify API
483
+ * @public
484
+ */
485
+ export declare namespace EJSON {
486
+ export interface Options {
487
+ /** Output using the Extended JSON v1 spec */
488
+ legacy?: boolean;
489
+ /** Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types */
490
+ relaxed?: boolean;
491
+ /**
492
+ * Disable Extended JSON's `relaxed` mode, which attempts to return BSON types where possible, rather than native JS types
493
+ * @deprecated Please use the relaxed property instead
494
+ */
495
+ strict?: boolean;
496
+ }
497
+ /**
498
+ * Parse an Extended JSON string, constructing the JavaScript value or object described by that
499
+ * string.
500
+ *
501
+ * @example
502
+ * ```js
503
+ * const { EJSON } = require('bson');
504
+ * const text = '{ "int32": { "$numberInt": "10" } }';
505
+ *
506
+ * // prints { int32: { [String: '10'] _bsontype: 'Int32', value: '10' } }
507
+ * console.log(EJSON.parse(text, { relaxed: false }));
508
+ *
509
+ * // prints { int32: 10 }
510
+ * console.log(EJSON.parse(text));
511
+ * ```
512
+ */
513
+ export function parse(text: string, options?: EJSON.Options): SerializableTypes;
514
+ export type JSONPrimitive = string | number | boolean | null;
515
+ export type SerializableTypes = Document | Array<JSONPrimitive | Document> | JSONPrimitive;
516
+ /**
517
+ * Converts a BSON document to an Extended JSON string, optionally replacing values if a replacer
518
+ * function is specified or optionally including only the specified properties if a replacer array
519
+ * is specified.
520
+ *
521
+ * @param value - The value to convert to extended JSON
522
+ * @param replacer - A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string
523
+ * @param space - A String or Number object that's used to insert white space into the output JSON string for readability purposes.
524
+ * @param options - Optional settings
525
+ *
526
+ * @example
527
+ * ```js
528
+ * const { EJSON } = require('bson');
529
+ * const Int32 = require('mongodb').Int32;
530
+ * const doc = { int32: new Int32(10) };
531
+ *
532
+ * // prints '{"int32":{"$numberInt":"10"}}'
533
+ * console.log(EJSON.stringify(doc, { relaxed: false }));
534
+ *
535
+ * // prints '{"int32":10}'
536
+ * console.log(EJSON.stringify(doc));
537
+ * ```
538
+ */
539
+ export function stringify(value: SerializableTypes, replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options, space?: string | number, options?: EJSON.Options): string;
540
+ /**
541
+ * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.
542
+ *
543
+ * @param value - The object to serialize
544
+ * @param options - Optional settings passed to the `stringify` function
545
+ */
546
+ export function serialize(value: SerializableTypes, options?: EJSON.Options): Document;
547
+ /**
548
+ * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types
549
+ *
550
+ * @param ejson - The Extended JSON object to deserialize
551
+ * @param options - Optional settings passed to the parse method
552
+ */
553
+ export function deserialize(ejson: Document, options?: EJSON.Options): SerializableTypes;
554
+ }
555
+
556
+ /** @public */
557
+ export declare type EJSONOptions = EJSON.Options;
558
+
559
+ /**
560
+ * A class representation of a BSON Int32 type.
561
+ * @public
562
+ * @category BSONType
563
+ */
564
+ export declare class Int32 {
565
+ _bsontype: 'Int32';
566
+ value: number;
567
+ /**
568
+ * Create an Int32 type
569
+ *
570
+ * @param value - the number we want to represent as an int32.
571
+ */
572
+ constructor(value: number | string);
573
+ /**
574
+ * Access the number value.
575
+ *
576
+ * @returns returns the wrapped int32 number.
577
+ */
578
+ valueOf(): number;
579
+ toString(radix?: number): string;
580
+ toJSON(): number;
581
+ /* Excluded from this release type: toExtendedJSON */
582
+ /* Excluded from this release type: fromExtendedJSON */
583
+ inspect(): string;
584
+ }
585
+
586
+ /** @public */
587
+ export declare interface Int32Extended {
588
+ $numberInt: string;
589
+ }
590
+
591
+ declare const kId: unique symbol;
592
+
593
+ declare const kId_2: unique symbol;
594
+
595
+ /**
596
+ * A class representing a 64-bit integer
597
+ * @public
598
+ * @category BSONType
599
+ * @remarks
600
+ * The internal representation of a long is the two given signed, 32-bit values.
601
+ * We use 32-bit pieces because these are the size of integers on which
602
+ * Javascript performs bit-operations. For operations like addition and
603
+ * multiplication, we split each number into 16 bit pieces, which can easily be
604
+ * multiplied within Javascript's floating-point representation without overflow
605
+ * or change in sign.
606
+ * In the algorithms below, we frequently reduce the negative case to the
607
+ * positive case by negating the input(s) and then post-processing the result.
608
+ * Note that we must ALWAYS check specially whether those values are MIN_VALUE
609
+ * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
610
+ * a positive number, it overflows back into a negative). Not handling this
611
+ * case would often result in infinite recursion.
612
+ * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class.
613
+ */
614
+ export declare class Long {
615
+ _bsontype: 'Long';
616
+ /** An indicator used to reliably determine if an object is a Long or not. */
617
+ __isLong__: true;
618
+ /**
619
+ * The high 32 bits as a signed value.
620
+ */
621
+ high: number;
622
+ /**
623
+ * The low 32 bits as a signed value.
624
+ */
625
+ low: number;
626
+ /**
627
+ * Whether unsigned or not.
628
+ */
629
+ unsigned: boolean;
630
+ /**
631
+ * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
632
+ * See the from* functions below for more convenient ways of constructing Longs.
633
+ *
634
+ * Acceptable signatures are:
635
+ * - Long(low, high, unsigned?)
636
+ * - Long(bigint, unsigned?)
637
+ * - Long(string, unsigned?)
638
+ *
639
+ * @param low - The low (signed) 32 bits of the long
640
+ * @param high - The high (signed) 32 bits of the long
641
+ * @param unsigned - Whether unsigned or not, defaults to signed
642
+ */
643
+ constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean);
644
+ static TWO_PWR_24: Long;
645
+ /** Maximum unsigned value. */
646
+ static MAX_UNSIGNED_VALUE: Long;
647
+ /** Signed zero */
648
+ static ZERO: Long;
649
+ /** Unsigned zero. */
650
+ static UZERO: Long;
651
+ /** Signed one. */
652
+ static ONE: Long;
653
+ /** Unsigned one. */
654
+ static UONE: Long;
655
+ /** Signed negative one. */
656
+ static NEG_ONE: Long;
657
+ /** Maximum signed value. */
658
+ static MAX_VALUE: Long;
659
+ /** Minimum signed value. */
660
+ static MIN_VALUE: Long;
661
+ /**
662
+ * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits.
663
+ * Each is assumed to use 32 bits.
664
+ * @param lowBits - The low 32 bits
665
+ * @param highBits - The high 32 bits
666
+ * @param unsigned - Whether unsigned or not, defaults to signed
667
+ * @returns The corresponding Long value
668
+ */
669
+ static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
670
+ /**
671
+ * Returns a Long representing the given 32 bit integer value.
672
+ * @param value - The 32 bit integer in question
673
+ * @param unsigned - Whether unsigned or not, defaults to signed
674
+ * @returns The corresponding Long value
675
+ */
676
+ static fromInt(value: number, unsigned?: boolean): Long;
677
+ /**
678
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
679
+ * @param value - The number in question
680
+ * @param unsigned - Whether unsigned or not, defaults to signed
681
+ * @returns The corresponding Long value
682
+ */
683
+ static fromNumber(value: number, unsigned?: boolean): Long;
684
+ /**
685
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
686
+ * @param value - The number in question
687
+ * @param unsigned - Whether unsigned or not, defaults to signed
688
+ * @returns The corresponding Long value
689
+ */
690
+ static fromBigInt(value: bigint, unsigned?: boolean): Long;
691
+ /**
692
+ * Returns a Long representation of the given string, written using the specified radix.
693
+ * @param str - The textual representation of the Long
694
+ * @param unsigned - Whether unsigned or not, defaults to signed
695
+ * @param radix - The radix in which the text is written (2-36), defaults to 10
696
+ * @returns The corresponding Long value
697
+ */
698
+ static fromString(str: string, unsigned?: boolean, radix?: number): Long;
699
+ /**
700
+ * Creates a Long from its byte representation.
701
+ * @param bytes - Byte representation
702
+ * @param unsigned - Whether unsigned or not, defaults to signed
703
+ * @param le - Whether little or big endian, defaults to big endian
704
+ * @returns The corresponding Long value
705
+ */
706
+ static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;
707
+ /**
708
+ * Creates a Long from its little endian byte representation.
709
+ * @param bytes - Little endian byte representation
710
+ * @param unsigned - Whether unsigned or not, defaults to signed
711
+ * @returns The corresponding Long value
712
+ */
713
+ static fromBytesLE(bytes: number[], unsigned?: boolean): Long;
714
+ /**
715
+ * Creates a Long from its big endian byte representation.
716
+ * @param bytes - Big endian byte representation
717
+ * @param unsigned - Whether unsigned or not, defaults to signed
718
+ * @returns The corresponding Long value
719
+ */
720
+ static fromBytesBE(bytes: number[], unsigned?: boolean): Long;
721
+ /**
722
+ * Tests if the specified object is a Long.
723
+ */
724
+ static isLong(value: any): value is Long;
725
+ /**
726
+ * Converts the specified value to a Long.
727
+ * @param unsigned - Whether unsigned or not, defaults to signed
728
+ */
729
+ static fromValue(val: number | string | {
730
+ low: number;
731
+ high: number;
732
+ unsigned?: boolean;
733
+ }, unsigned?: boolean): Long;
734
+ /** Returns the sum of this and the specified Long. */
735
+ add(addend: string | number | Long | Timestamp): Long;
736
+ /**
737
+ * Returns the sum of this and the specified Long.
738
+ * @returns Sum
739
+ */
740
+ and(other: string | number | Long | Timestamp): Long;
741
+ /**
742
+ * Compares this Long's value with the specified's.
743
+ * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
744
+ */
745
+ compare(other: string | number | Long | Timestamp): 0 | 1 | -1;
746
+ /** This is an alias of {@link Long.compare} */
747
+ comp(other: string | number | Long | Timestamp): 0 | 1 | -1;
748
+ /**
749
+ * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned.
750
+ * @returns Quotient
751
+ */
752
+ divide(divisor: string | number | Long | Timestamp): Long;
753
+ /**This is an alias of {@link Long.divide} */
754
+ div(divisor: string | number | Long | Timestamp): Long;
755
+ /**
756
+ * Tests if this Long's value equals the specified's.
757
+ * @param other - Other value
758
+ */
759
+ equals(other: string | number | Long | Timestamp): boolean;
760
+ /** This is an alias of {@link Long.equals} */
761
+ eq(other: string | number | Long | Timestamp): boolean;
762
+ /** Gets the high 32 bits as a signed integer. */
763
+ getHighBits(): number;
764
+ /** Gets the high 32 bits as an unsigned integer. */
765
+ getHighBitsUnsigned(): number;
766
+ /** Gets the low 32 bits as a signed integer. */
767
+ getLowBits(): number;
768
+ /** Gets the low 32 bits as an unsigned integer. */
769
+ getLowBitsUnsigned(): number;
770
+ /** Gets the number of bits needed to represent the absolute value of this Long. */
771
+ getNumBitsAbs(): number;
772
+ /** Tests if this Long's value is greater than the specified's. */
773
+ greaterThan(other: string | number | Long | Timestamp): boolean;
774
+ /** This is an alias of {@link Long.greaterThan} */
775
+ gt(other: string | number | Long | Timestamp): boolean;
776
+ /** Tests if this Long's value is greater than or equal the specified's. */
777
+ greaterThanOrEqual(other: string | number | Long | Timestamp): boolean;
778
+ /** This is an alias of {@link Long.greaterThanOrEqual} */
779
+ gte(other: string | number | Long | Timestamp): boolean;
780
+ /** This is an alias of {@link Long.greaterThanOrEqual} */
781
+ ge(other: string | number | Long | Timestamp): boolean;
782
+ /** Tests if this Long's value is even. */
783
+ isEven(): boolean;
784
+ /** Tests if this Long's value is negative. */
785
+ isNegative(): boolean;
786
+ /** Tests if this Long's value is odd. */
787
+ isOdd(): boolean;
788
+ /** Tests if this Long's value is positive. */
789
+ isPositive(): boolean;
790
+ /** Tests if this Long's value equals zero. */
791
+ isZero(): boolean;
792
+ /** Tests if this Long's value is less than the specified's. */
793
+ lessThan(other: string | number | Long | Timestamp): boolean;
794
+ /** This is an alias of {@link Long#lessThan}. */
795
+ lt(other: string | number | Long | Timestamp): boolean;
796
+ /** Tests if this Long's value is less than or equal the specified's. */
797
+ lessThanOrEqual(other: string | number | Long | Timestamp): boolean;
798
+ /** This is an alias of {@link Long.lessThanOrEqual} */
799
+ lte(other: string | number | Long | Timestamp): boolean;
800
+ /** Returns this Long modulo the specified. */
801
+ modulo(divisor: string | number | Long | Timestamp): Long;
802
+ /** This is an alias of {@link Long.modulo} */
803
+ mod(divisor: string | number | Long | Timestamp): Long;
804
+ /** This is an alias of {@link Long.modulo} */
805
+ rem(divisor: string | number | Long | Timestamp): Long;
806
+ /**
807
+ * Returns the product of this and the specified Long.
808
+ * @param multiplier - Multiplier
809
+ * @returns Product
810
+ */
811
+ multiply(multiplier: string | number | Long | Timestamp): Long;
812
+ /** This is an alias of {@link Long.multiply} */
813
+ mul(multiplier: string | number | Long | Timestamp): Long;
814
+ /** Returns the Negation of this Long's value. */
815
+ negate(): Long;
816
+ /** This is an alias of {@link Long.negate} */
817
+ neg(): Long;
818
+ /** Returns the bitwise NOT of this Long. */
819
+ not(): Long;
820
+ /** Tests if this Long's value differs from the specified's. */
821
+ notEquals(other: string | number | Long | Timestamp): boolean;
822
+ /** This is an alias of {@link Long.notEquals} */
823
+ neq(other: string | number | Long | Timestamp): boolean;
824
+ /** This is an alias of {@link Long.notEquals} */
825
+ ne(other: string | number | Long | Timestamp): boolean;
826
+ /**
827
+ * Returns the bitwise OR of this Long and the specified.
828
+ */
829
+ or(other: number | string | Long): Long;
830
+ /**
831
+ * Returns this Long with bits shifted to the left by the given amount.
832
+ * @param numBits - Number of bits
833
+ * @returns Shifted Long
834
+ */
835
+ shiftLeft(numBits: number | Long): Long;
836
+ /** This is an alias of {@link Long.shiftLeft} */
837
+ shl(numBits: number | Long): Long;
838
+ /**
839
+ * Returns this Long with bits arithmetically shifted to the right by the given amount.
840
+ * @param numBits - Number of bits
841
+ * @returns Shifted Long
842
+ */
843
+ shiftRight(numBits: number | Long): Long;
844
+ /** This is an alias of {@link Long.shiftRight} */
845
+ shr(numBits: number | Long): Long;
846
+ /**
847
+ * Returns this Long with bits logically shifted to the right by the given amount.
848
+ * @param numBits - Number of bits
849
+ * @returns Shifted Long
850
+ */
851
+ shiftRightUnsigned(numBits: Long | number): Long;
852
+ /** This is an alias of {@link Long.shiftRightUnsigned} */
853
+ shr_u(numBits: number | Long): Long;
854
+ /** This is an alias of {@link Long.shiftRightUnsigned} */
855
+ shru(numBits: number | Long): Long;
856
+ /**
857
+ * Returns the difference of this and the specified Long.
858
+ * @param subtrahend - Subtrahend
859
+ * @returns Difference
860
+ */
861
+ subtract(subtrahend: string | number | Long | Timestamp): Long;
862
+ /** This is an alias of {@link Long.subtract} */
863
+ sub(subtrahend: string | number | Long | Timestamp): Long;
864
+ /** Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. */
865
+ toInt(): number;
866
+ /** Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). */
867
+ toNumber(): number;
868
+ /** Converts the Long to a BigInt (arbitrary precision). */
869
+ toBigInt(): bigint;
870
+ /**
871
+ * Converts this Long to its byte representation.
872
+ * @param le - Whether little or big endian, defaults to big endian
873
+ * @returns Byte representation
874
+ */
875
+ toBytes(le?: boolean): number[];
876
+ /**
877
+ * Converts this Long to its little endian byte representation.
878
+ * @returns Little endian byte representation
879
+ */
880
+ toBytesLE(): number[];
881
+ /**
882
+ * Converts this Long to its big endian byte representation.
883
+ * @returns Big endian byte representation
884
+ */
885
+ toBytesBE(): number[];
886
+ /**
887
+ * Converts this Long to signed.
888
+ */
889
+ toSigned(): Long;
890
+ /**
891
+ * Converts the Long to a string written in the specified radix.
892
+ * @param radix - Radix (2-36), defaults to 10
893
+ * @throws RangeError If `radix` is out of range
894
+ */
895
+ toString(radix?: number): string;
896
+ /** Converts this Long to unsigned. */
897
+ toUnsigned(): Long;
898
+ /** Returns the bitwise XOR of this Long and the given one. */
899
+ xor(other: Long | number | string): Long;
900
+ /** This is an alias of {@link Long.isZero} */
901
+ eqz(): boolean;
902
+ /** This is an alias of {@link Long.lessThanOrEqual} */
903
+ le(other: string | number | Long | Timestamp): boolean;
904
+ toExtendedJSON(options?: EJSONOptions): number | LongExtended;
905
+ static fromExtendedJSON(doc: {
906
+ $numberLong: string;
907
+ }, options?: EJSONOptions): number | Long;
908
+ inspect(): string;
909
+ }
910
+
911
+ /** @public */
912
+ export declare interface LongExtended {
913
+ $numberLong: string;
914
+ }
915
+
916
+ /** @public */
917
+ export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => {
918
+ [P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
919
+ };
920
+
921
+ /** @public */
922
+ export declare const LongWithoutOverridesClass: LongWithoutOverrides;
923
+
924
+ /** @public */
925
+ declare let Map_2: MapConstructor;
926
+ export { Map_2 as Map }
927
+
928
+ /**
929
+ * A class representation of the BSON MaxKey type.
930
+ * @public
931
+ * @category BSONType
932
+ */
933
+ export declare class MaxKey {
934
+ _bsontype: 'MaxKey';
935
+ constructor();
936
+ /* Excluded from this release type: toExtendedJSON */
937
+ /* Excluded from this release type: fromExtendedJSON */
938
+ inspect(): string;
939
+ }
940
+
941
+ /** @public */
942
+ export declare interface MaxKeyExtended {
943
+ $maxKey: 1;
944
+ }
945
+
946
+ /**
947
+ * A class representation of the BSON MinKey type.
948
+ * @public
949
+ * @category BSONType
950
+ */
951
+ export declare class MinKey {
952
+ _bsontype: 'MinKey';
953
+ constructor();
954
+ /* Excluded from this release type: toExtendedJSON */
955
+ /* Excluded from this release type: fromExtendedJSON */
956
+ inspect(): string;
957
+ }
958
+
959
+ /** @public */
960
+ export declare interface MinKeyExtended {
961
+ $minKey: 1;
962
+ }
963
+
964
+ /**
965
+ * A class representation of the BSON ObjectId type.
966
+ * @public
967
+ * @category BSONType
968
+ */
969
+ declare class ObjectId {
970
+ _bsontype: 'ObjectID';
971
+ /* Excluded from this release type: index */
972
+ static cacheHexString: boolean;
973
+ /* Excluded from this release type: [kId] */
974
+ /* Excluded from this release type: __id */
975
+ /**
976
+ * Create an ObjectId type
977
+ *
978
+ * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
979
+ */
980
+ constructor(inputId?: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array);
981
+ /**
982
+ * The ObjectId bytes
983
+ * @readonly
984
+ */
985
+ get id(): Buffer;
986
+ set id(value: Buffer);
987
+ /**
988
+ * The generation time of this ObjectId instance
989
+ * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch
990
+ */
991
+ get generationTime(): number;
992
+ set generationTime(value: number);
993
+ /** Returns the ObjectId id as a 24 character hex string representation */
994
+ toHexString(): string;
995
+ /* Excluded from this release type: getInc */
996
+ /**
997
+ * Generate a 12 byte id buffer used in ObjectId's
998
+ *
999
+ * @param time - pass in a second based timestamp.
1000
+ */
1001
+ static generate(time?: number): Buffer;
1002
+ /**
1003
+ * Converts the id into a 24 character hex string for printing
1004
+ *
1005
+ * @param format - The Buffer toString format parameter.
1006
+ */
1007
+ toString(format?: string): string;
1008
+ /** Converts to its JSON the 24 character hex string representation. */
1009
+ toJSON(): string;
1010
+ /**
1011
+ * Compares the equality of this ObjectId with `otherID`.
1012
+ *
1013
+ * @param otherId - ObjectId instance to compare against.
1014
+ */
1015
+ equals(otherId: string | ObjectId | ObjectIdLike): boolean;
1016
+ /** Returns the generation date (accurate up to the second) that this ID was generated. */
1017
+ getTimestamp(): Date;
1018
+ /* Excluded from this release type: createPk */
1019
+ /**
1020
+ * Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
1021
+ *
1022
+ * @param time - an integer number representing a number of seconds.
1023
+ */
1024
+ static createFromTime(time: number): ObjectId;
1025
+ /**
1026
+ * Creates an ObjectId from a hex string representation of an ObjectId.
1027
+ *
1028
+ * @param hexString - create a ObjectId from a passed in 24 character hexstring.
1029
+ */
1030
+ static createFromHexString(hexString: string): ObjectId;
1031
+ /**
1032
+ * Checks if a value is a valid bson ObjectId
1033
+ *
1034
+ * @param id - ObjectId instance to validate.
1035
+ */
1036
+ static isValid(id: string | number | ObjectId | ObjectIdLike | Buffer | Uint8Array): boolean;
1037
+ /* Excluded from this release type: toExtendedJSON */
1038
+ /* Excluded from this release type: fromExtendedJSON */
1039
+ inspect(): string;
1040
+ }
1041
+ export { ObjectId as ObjectID }
1042
+ export { ObjectId }
1043
+
1044
+ /** @public */
1045
+ export declare interface ObjectIdExtended {
1046
+ $oid: string;
1047
+ }
1048
+
1049
+ /** @public */
1050
+ export declare interface ObjectIdLike {
1051
+ id: string | Buffer;
1052
+ __id?: string;
1053
+ toHexString(): string;
1054
+ }
1055
+
1056
+ /**
1057
+ * Serialize a Javascript object.
1058
+ *
1059
+ * @param object - the Javascript object to serialize.
1060
+ * @returns Buffer object containing the serialized object.
1061
+ * @public
1062
+ */
1063
+ export declare function serialize(object: Document, options?: SerializeOptions): Buffer;
1064
+
1065
+ /** @public */
1066
+ export declare interface SerializeOptions {
1067
+ /** the serializer will check if keys are valid. */
1068
+ checkKeys?: boolean;
1069
+ /** serialize the javascript functions **(default:false)**. */
1070
+ serializeFunctions?: boolean;
1071
+ /** serialize will not emit undefined fields **(default:true)** */
1072
+ ignoreUndefined?: boolean;
1073
+ /* Excluded from this release type: minInternalBufferSize */
1074
+ /** the index in the buffer where we wish to start serializing into */
1075
+ index?: number;
1076
+ }
1077
+
1078
+ /**
1079
+ * Serialize a Javascript object using a predefined Buffer and index into the buffer,
1080
+ * useful when pre-allocating the space for serialization.
1081
+ *
1082
+ * @param object - the Javascript object to serialize.
1083
+ * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object.
1084
+ * @returns the index pointing to the last written byte in the buffer.
1085
+ * @public
1086
+ */
1087
+ export declare function serializeWithBufferAndIndex(object: Document, finalBuffer: Buffer, options?: SerializeOptions): number;
1088
+
1089
+ /**
1090
+ * Sets the size of the internal serialization buffer.
1091
+ *
1092
+ * @param size - The desired size for the internal serialization buffer
1093
+ * @public
1094
+ */
1095
+ export declare function setInternalBufferSize(size: number): void;
1096
+
1097
+ /**
1098
+ * @public
1099
+ * @category BSONType
1100
+ * */
1101
+ export declare class Timestamp extends LongWithoutOverridesClass {
1102
+ _bsontype: 'Timestamp';
1103
+ static readonly MAX_VALUE: Long;
1104
+ /**
1105
+ * @param low - A 64-bit Long representing the Timestamp.
1106
+ */
1107
+ constructor(long: Long);
1108
+ /**
1109
+ * @param value - A pair of two values indicating timestamp and increment.
1110
+ */
1111
+ constructor(value: {
1112
+ t: number;
1113
+ i: number;
1114
+ });
1115
+ /**
1116
+ * @param low - the low (signed) 32 bits of the Timestamp.
1117
+ * @param high - the high (signed) 32 bits of the Timestamp.
1118
+ * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead.
1119
+ */
1120
+ constructor(low: number, high: number);
1121
+ toJSON(): {
1122
+ $timestamp: string;
1123
+ };
1124
+ /** Returns a Timestamp represented by the given (32-bit) integer value. */
1125
+ static fromInt(value: number): Timestamp;
1126
+ /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
1127
+ static fromNumber(value: number): Timestamp;
1128
+ /**
1129
+ * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
1130
+ *
1131
+ * @param lowBits - the low 32-bits.
1132
+ * @param highBits - the high 32-bits.
1133
+ */
1134
+ static fromBits(lowBits: number, highBits: number): Timestamp;
1135
+ /**
1136
+ * Returns a Timestamp from the given string, optionally using the given radix.
1137
+ *
1138
+ * @param str - the textual representation of the Timestamp.
1139
+ * @param optRadix - the radix in which the text is written.
1140
+ */
1141
+ static fromString(str: string, optRadix: number): Timestamp;
1142
+ /* Excluded from this release type: toExtendedJSON */
1143
+ /* Excluded from this release type: fromExtendedJSON */
1144
+ inspect(): string;
1145
+ }
1146
+
1147
+ /** @public */
1148
+ export declare interface TimestampExtended {
1149
+ $timestamp: {
1150
+ t: number;
1151
+ i: number;
1152
+ };
1153
+ }
1154
+
1155
+ /** @public */
1156
+ export declare type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect';
1157
+
1158
+ /**
1159
+ * A class representation of the BSON UUID type.
1160
+ * @public
1161
+ */
1162
+ export declare class UUID {
1163
+ _bsontype: 'UUID';
1164
+ static cacheHexString: boolean;
1165
+ /* Excluded from this release type: [kId] */
1166
+ /* Excluded from this release type: __id */
1167
+ /**
1168
+ * Create an UUID type
1169
+ *
1170
+ * @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer.
1171
+ */
1172
+ constructor(input?: string | Buffer | UUID);
1173
+ /**
1174
+ * The UUID bytes
1175
+ * @readonly
1176
+ */
1177
+ get id(): Buffer;
1178
+ set id(value: Buffer);
1179
+ /**
1180
+ * Generate a 16 byte uuid v4 buffer used in UUIDs
1181
+ */
1182
+ /**
1183
+ * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated)
1184
+ * @param includeDashes - should the string exclude dash-separators.
1185
+ * */
1186
+ toHexString(includeDashes?: boolean): string;
1187
+ /**
1188
+ * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
1189
+ */
1190
+ toString(encoding?: string): string;
1191
+ /**
1192
+ * Converts the id into its JSON string representation.
1193
+ * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1194
+ */
1195
+ toJSON(): string;
1196
+ /**
1197
+ * Compares the equality of this UUID with `otherID`.
1198
+ *
1199
+ * @param otherId - UUID instance to compare against.
1200
+ */
1201
+ equals(otherId: string | Buffer | UUID): boolean;
1202
+ /**
1203
+ * Creates a Binary instance from the current UUID.
1204
+ */
1205
+ toBinary(): Binary;
1206
+ /**
1207
+ * Generates a populated buffer containing a v4 uuid
1208
+ */
1209
+ static generate(): Buffer;
1210
+ /**
1211
+ * Checks if a value is a valid bson UUID
1212
+ * @param input - UUID, string or Buffer to validate.
1213
+ */
1214
+ static isValid(input: string | Buffer | UUID): boolean;
1215
+ /**
1216
+ * Creates an UUID from a hex string representation of an UUID.
1217
+ * @param hexString - 32 or 36 character hex string (dashes excluded/included).
1218
+ */
1219
+ static createFromHexString(hexString: string): UUID;
1220
+ inspect(): string;
1221
+ }
1222
+
1223
+ /** @public */
1224
+ export declare type UUIDExtended = {
1225
+ $uuid: string;
1226
+ };
1227
+
1228
+ export { }