1 | import { Buffer } from 'buffer';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export declare class Binary {
|
7 | _bsontype: 'Binary';
|
8 |
|
9 |
|
10 | static readonly BUFFER_SIZE = 256;
|
11 |
|
12 | static readonly SUBTYPE_DEFAULT = 0;
|
13 |
|
14 | static readonly SUBTYPE_FUNCTION = 1;
|
15 |
|
16 | static readonly SUBTYPE_BYTE_ARRAY = 2;
|
17 |
|
18 | static readonly SUBTYPE_UUID_OLD = 3;
|
19 |
|
20 | static readonly SUBTYPE_UUID = 4;
|
21 |
|
22 | static readonly SUBTYPE_MD5 = 5;
|
23 |
|
24 | static readonly SUBTYPE_ENCRYPTED = 6;
|
25 |
|
26 | static readonly SUBTYPE_COLUMN = 7;
|
27 |
|
28 | static readonly SUBTYPE_USER_DEFINED = 128;
|
29 | buffer: Buffer;
|
30 | sub_type: number;
|
31 | position: number;
|
32 | |
33 |
|
34 |
|
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 |
|
81 | export declare interface BinaryExtendedLegacy {
|
82 | $type: string;
|
83 | $binary: string;
|
84 | }
|
85 |
|
86 | export declare type BinarySequence = Uint8Array | Buffer | number[];
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
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 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 | export declare class BSONError extends Error {
|
159 | readonly name: string;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 |
|
165 | export declare class BSONRegExp {
|
166 | _bsontype: 'BSONRegExp';
|
167 | pattern: string;
|
168 | options: string;
|
169 | |
170 |
|
171 |
|
172 |
|
173 | constructor(pattern: string, options?: string);
|
174 | static parseOptions(options?: string): string;
|
175 | }
|
176 | /** @public */
|
177 | export declare interface BSONRegExpExtended {
|
178 | $regularExpression: {
|
179 | pattern: string;
|
180 | options: string;
|
181 | };
|
182 | }
|
183 |
|
184 | export declare interface BSONRegExpExtendedLegacy {
|
185 | $regex: string | BSONRegExp;
|
186 | $options: string;
|
187 | }
|
188 |
|
189 |
|
190 |
|
191 |
|
192 | export declare class BSONSymbol {
|
193 | _bsontype: 'Symbol';
|
194 | value: string;
|
195 | |
196 |
|
197 |
|
198 | constructor(value: string);
|
199 | /** Access the wrapped string value. */
|
200 | valueOf(): string;
|
201 | toString(): string;
|
202 | /* Excluded from this release type: inspect */
|
203 | toJSON(): string;
|
204 | }
|
205 | /** @public */
|
206 | export declare interface BSONSymbolExtended {
|
207 | $symbol: string;
|
208 | }
|
209 |
|
210 | export declare class BSONTypeError extends TypeError {
|
211 | readonly name: string;
|
212 | }
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number;
|
221 |
|
222 | export declare type CalculateObjectSizeOptions = Pick<SerializeOptions, 'serializeFunctions' | 'ignoreUndefined'>;
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | export declare class Code {
|
228 | _bsontype: 'Code';
|
229 | code: string | Function;
|
230 | scope?: Document;
|
231 | |
232 |
|
233 |
|
234 |
|
235 | constructor(code: string | Function, scope?: Document);
|
236 | toJSON(): {
|
237 | code: string | Function;
|
238 | scope?: Document;
|
239 | };
|
240 |
|
241 |
|
242 | inspect(): string;
|
243 | }
|
244 |
|
245 | export declare interface CodeExtended {
|
246 | $code: string | Function;
|
247 | $scope?: Document;
|
248 | }
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | export declare class DBRef {
|
254 | _bsontype: 'DBRef';
|
255 | collection: string;
|
256 | oid: ObjectId;
|
257 | db?: string;
|
258 | fields: Document;
|
259 | |
260 |
|
261 |
|
262 |
|
263 |
|
264 | constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);
|
265 | /* Excluded from this release type: namespace */
|
266 | /* Excluded from this release type: namespace */
|
267 | toJSON(): DBRefLike & Document;
|
268 | /* Excluded from this release type: toExtendedJSON */
|
269 | /* Excluded from this release type: fromExtendedJSON */
|
270 | inspect(): string;
|
271 | }
|
272 | /** @public */
|
273 | export declare interface DBRefLike {
|
274 | $ref: string;
|
275 | $id: ObjectId;
|
276 | $db?: string;
|
277 | }
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | export declare class Decimal128 {
|
283 | _bsontype: 'Decimal128';
|
284 | readonly bytes: Buffer;
|
285 | |
286 |
|
287 |
|
288 |
|
289 | constructor(bytes: Buffer | string);
|
290 | /**
|
291 | * Create a Decimal128 instance from a string representation
|
292 | *
|
293 | * @param representation - a numeric string representation.
|
294 | */
|
295 | static fromString(representation: string): Decimal128;
|
296 | /** Create a string representation of the raw Decimal128 value */
|
297 | toString(): string;
|
298 | toJSON(): Decimal128Extended;
|
299 | /* Excluded from this release type: toExtendedJSON */
|
300 | /* Excluded from this release type: fromExtendedJSON */
|
301 | inspect(): string;
|
302 | }
|
303 | /** @public */
|
304 | export declare interface Decimal128Extended {
|
305 | $numberDecimal: string;
|
306 | }
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 | export declare function deserialize(buffer: Buffer | ArrayBufferView | ArrayBuffer, options?: DeserializeOptions): Document;
|
315 |
|
316 | export declare interface DeserializeOptions {
|
317 |
|
318 | evalFunctions?: boolean;
|
319 |
|
320 | cacheFunctions?: boolean;
|
321 | |
322 |
|
323 |
|
324 |
|
325 |
|
326 | cacheFunctionsCrc32?: boolean;
|
327 |
|
328 | promoteLongs?: boolean;
|
329 |
|
330 | promoteBuffers?: boolean;
|
331 |
|
332 | promoteValues?: boolean;
|
333 |
|
334 | fieldsAsRaw?: Document;
|
335 |
|
336 | bsonRegExp?: boolean;
|
337 |
|
338 | allowObjectSmallerThanBufferSize?: boolean;
|
339 |
|
340 | index?: number;
|
341 | raw?: boolean;
|
342 | }
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 | export declare function deserializeStream(data: Buffer | ArrayBufferView | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number;
|
356 |
|
357 | export declare interface Document {
|
358 | [key: string]: any;
|
359 | }
|
360 |
|
361 |
|
362 |
|
363 |
|
364 | export declare class Double {
|
365 | _bsontype: 'Double';
|
366 | value: number;
|
367 | |
368 |
|
369 |
|
370 |
|
371 |
|
372 | constructor(value: number);
|
373 | /**
|
374 | * Access the number value.
|
375 | *
|
376 | * @returns returns the wrapped double number.
|
377 | */
|
378 | valueOf(): number;
|
379 | toJSON(): number;
|
380 | toString(radix?: number): string;
|
381 | /* Excluded from this release type: toExtendedJSON */
|
382 | /* Excluded from this release type: fromExtendedJSON */
|
383 | inspect(): string;
|
384 | }
|
385 | /** @public */
|
386 | export declare interface DoubleExtended {
|
387 | $numberDouble: string;
|
388 | }
|
389 |
|
390 |
|
391 |
|
392 |
|
393 | export declare namespace EJSON {
|
394 | export interface Options {
|
395 |
|
396 | legacy?: boolean;
|
397 |
|
398 | relaxed?: boolean;
|
399 | |
400 |
|
401 |
|
402 |
|
403 | strict?: boolean;
|
404 | }
|
405 | |
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 | export function parse(text: string, options?: EJSON.Options): SerializableTypes;
|
422 | export type JSONPrimitive = string | number | boolean | null;
|
423 | export type SerializableTypes = Document | Array<JSONPrimitive | Document> | JSONPrimitive;
|
424 | |
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 | export function stringify(value: SerializableTypes, replacer?: (number | string)[] | ((this: any, key: string, value: any) => any) | EJSON.Options, space?: string | number, options?: EJSON.Options): string;
|
448 | |
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 | export function serialize(value: SerializableTypes, options?: EJSON.Options): Document;
|
455 | |
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 | export function deserialize(ejson: Document, options?: EJSON.Options): SerializableTypes;
|
462 | }
|
463 |
|
464 | export declare type EJSONOptions = EJSON.Options;
|
465 |
|
466 |
|
467 |
|
468 |
|
469 | export declare class Int32 {
|
470 | _bsontype: 'Int32';
|
471 | value: number;
|
472 | |
473 |
|
474 |
|
475 |
|
476 |
|
477 | constructor(value: number | string);
|
478 | /**
|
479 | * Access the number value.
|
480 | *
|
481 | * @returns returns the wrapped int32 number.
|
482 | */
|
483 | valueOf(): number;
|
484 | toString(radix?: number): string;
|
485 | toJSON(): number;
|
486 | /* Excluded from this release type: toExtendedJSON */
|
487 | /* Excluded from this release type: fromExtendedJSON */
|
488 | inspect(): string;
|
489 | }
|
490 | /** @public */
|
491 | export declare interface Int32Extended {
|
492 | $numberInt: string;
|
493 | }
|
494 | declare const kId: unique symbol;
|
495 | declare const kId_2: unique symbol;
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 | export declare class Long {
|
515 | _bsontype: 'Long';
|
516 |
|
517 | __isLong__: true;
|
518 | |
519 |
|
520 |
|
521 | high: number;
|
522 | |
523 |
|
524 |
|
525 | low: number;
|
526 | |
527 |
|
528 |
|
529 | unsigned: boolean;
|
530 | |
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 | constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean);
|
544 | static TWO_PWR_24: Long;
|
545 | /** Maximum unsigned value. */
|
546 | static MAX_UNSIGNED_VALUE: Long;
|
547 | /** Signed zero */
|
548 | static ZERO: Long;
|
549 | /** Unsigned zero. */
|
550 | static UZERO: Long;
|
551 | /** Signed one. */
|
552 | static ONE: Long;
|
553 | /** Unsigned one. */
|
554 | static UONE: Long;
|
555 | /** Signed negative one. */
|
556 | static NEG_ONE: Long;
|
557 | /** Maximum signed value. */
|
558 | static MAX_VALUE: Long;
|
559 | /** Minimum signed value. */
|
560 | static MIN_VALUE: Long;
|
561 | /**
|
562 | * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits.
|
563 | * Each is assumed to use 32 bits.
|
564 | * @param lowBits - The low 32 bits
|
565 | * @param highBits - The high 32 bits
|
566 | * @param unsigned - Whether unsigned or not, defaults to signed
|
567 | * @returns The corresponding Long value
|
568 | */
|
569 | static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
|
570 | /**
|
571 | * Returns a Long representing the given 32 bit integer value.
|
572 | * @param value - The 32 bit integer in question
|
573 | * @param unsigned - Whether unsigned or not, defaults to signed
|
574 | * @returns The corresponding Long value
|
575 | */
|
576 | static fromInt(value: number, unsigned?: boolean): Long;
|
577 | /**
|
578 | * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
579 | * @param value - The number in question
|
580 | * @param unsigned - Whether unsigned or not, defaults to signed
|
581 | * @returns The corresponding Long value
|
582 | */
|
583 | static fromNumber(value: number, unsigned?: boolean): Long;
|
584 | /**
|
585 | * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
|
586 | * @param value - The number in question
|
587 | * @param unsigned - Whether unsigned or not, defaults to signed
|
588 | * @returns The corresponding Long value
|
589 | */
|
590 | static fromBigInt(value: bigint, unsigned?: boolean): Long;
|
591 | /**
|
592 | * Returns a Long representation of the given string, written using the specified radix.
|
593 | * @param str - The textual representation of the Long
|
594 | * @param unsigned - Whether unsigned or not, defaults to signed
|
595 | * @param radix - The radix in which the text is written (2-36), defaults to 10
|
596 | * @returns The corresponding Long value
|
597 | */
|
598 | static fromString(str: string, unsigned?: boolean, radix?: number): Long;
|
599 | /**
|
600 | * Creates a Long from its byte representation.
|
601 | * @param bytes - Byte representation
|
602 | * @param unsigned - Whether unsigned or not, defaults to signed
|
603 | * @param le - Whether little or big endian, defaults to big endian
|
604 | * @returns The corresponding Long value
|
605 | */
|
606 | static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;
|
607 | /**
|
608 | * Creates a Long from its little endian byte representation.
|
609 | * @param bytes - Little endian byte representation
|
610 | * @param unsigned - Whether unsigned or not, defaults to signed
|
611 | * @returns The corresponding Long value
|
612 | */
|
613 | static fromBytesLE(bytes: number[], unsigned?: boolean): Long;
|
614 | /**
|
615 | * Creates a Long from its big endian byte representation.
|
616 | * @param bytes - Big endian byte representation
|
617 | * @param unsigned - Whether unsigned or not, defaults to signed
|
618 | * @returns The corresponding Long value
|
619 | */
|
620 | static fromBytesBE(bytes: number[], unsigned?: boolean): Long;
|
621 | /**
|
622 | * Tests if the specified object is a Long.
|
623 | */
|
624 | static isLong(value: any): value is Long;
|
625 | /**
|
626 | * Converts the specified value to a Long.
|
627 | * @param unsigned - Whether unsigned or not, defaults to signed
|
628 | */
|
629 | static fromValue(val: number | string | {
|
630 | low: number;
|
631 | high: number;
|
632 | unsigned?: boolean;
|
633 | }, unsigned?: boolean): Long;
|
634 | /** Returns the sum of this and the specified Long. */
|
635 | add(addend: string | number | Long | Timestamp): Long;
|
636 | /**
|
637 | * Returns the sum of this and the specified Long.
|
638 | * @returns Sum
|
639 | */
|
640 | and(other: string | number | Long | Timestamp): Long;
|
641 | /**
|
642 | * Compares this Long's value with the specified's.
|
643 | * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
|
644 | */
|
645 | compare(other: string | number | Long | Timestamp): 0 | 1 | -1;
|
646 | /** This is an alias of {@link Long.compare} */
|
647 | comp(other: string | number | Long | Timestamp): 0 | 1 | -1;
|
648 | |
649 |
|
650 |
|
651 |
|
652 | divide(divisor: string | number | Long | Timestamp): Long;
|
653 |
|
654 | div(divisor: string | number | Long | Timestamp): Long;
|
655 | |
656 |
|
657 |
|
658 |
|
659 | equals(other: string | number | Long | Timestamp): boolean;
|
660 |
|
661 | eq(other: string | number | Long | Timestamp): boolean;
|
662 |
|
663 | getHighBits(): number;
|
664 |
|
665 | getHighBitsUnsigned(): number;
|
666 |
|
667 | getLowBits(): number;
|
668 |
|
669 | getLowBitsUnsigned(): number;
|
670 |
|
671 | getNumBitsAbs(): number;
|
672 |
|
673 | greaterThan(other: string | number | Long | Timestamp): boolean;
|
674 |
|
675 | gt(other: string | number | Long | Timestamp): boolean;
|
676 |
|
677 | greaterThanOrEqual(other: string | number | Long | Timestamp): boolean;
|
678 |
|
679 | gte(other: string | number | Long | Timestamp): boolean;
|
680 |
|
681 | ge(other: string | number | Long | Timestamp): boolean;
|
682 |
|
683 | isEven(): boolean;
|
684 |
|
685 | isNegative(): boolean;
|
686 |
|
687 | isOdd(): boolean;
|
688 |
|
689 | isPositive(): boolean;
|
690 |
|
691 | isZero(): boolean;
|
692 |
|
693 | lessThan(other: string | number | Long | Timestamp): boolean;
|
694 |
|
695 | lt(other: string | number | Long | Timestamp): boolean;
|
696 |
|
697 | lessThanOrEqual(other: string | number | Long | Timestamp): boolean;
|
698 |
|
699 | lte(other: string | number | Long | Timestamp): boolean;
|
700 |
|
701 | modulo(divisor: string | number | Long | Timestamp): Long;
|
702 |
|
703 | mod(divisor: string | number | Long | Timestamp): Long;
|
704 |
|
705 | rem(divisor: string | number | Long | Timestamp): Long;
|
706 | |
707 |
|
708 |
|
709 |
|
710 |
|
711 | multiply(multiplier: string | number | Long | Timestamp): Long;
|
712 |
|
713 | mul(multiplier: string | number | Long | Timestamp): Long;
|
714 |
|
715 | negate(): Long;
|
716 |
|
717 | neg(): Long;
|
718 |
|
719 | not(): Long;
|
720 |
|
721 | notEquals(other: string | number | Long | Timestamp): boolean;
|
722 |
|
723 | neq(other: string | number | Long | Timestamp): boolean;
|
724 |
|
725 | ne(other: string | number | Long | Timestamp): boolean;
|
726 | |
727 |
|
728 |
|
729 | or(other: number | string | Long): Long;
|
730 | |
731 |
|
732 |
|
733 |
|
734 |
|
735 | shiftLeft(numBits: number | Long): Long;
|
736 |
|
737 | shl(numBits: number | Long): Long;
|
738 | |
739 |
|
740 |
|
741 |
|
742 |
|
743 | shiftRight(numBits: number | Long): Long;
|
744 |
|
745 | shr(numBits: number | Long): Long;
|
746 | |
747 |
|
748 |
|
749 |
|
750 |
|
751 | shiftRightUnsigned(numBits: Long | number): Long;
|
752 |
|
753 | shr_u(numBits: number | Long): Long;
|
754 |
|
755 | shru(numBits: number | Long): Long;
|
756 | |
757 |
|
758 |
|
759 |
|
760 |
|
761 | subtract(subtrahend: string | number | Long | Timestamp): Long;
|
762 |
|
763 | sub(subtrahend: string | number | Long | Timestamp): Long;
|
764 |
|
765 | toInt(): number;
|
766 |
|
767 | toNumber(): number;
|
768 |
|
769 | toBigInt(): bigint;
|
770 | |
771 |
|
772 |
|
773 |
|
774 |
|
775 | toBytes(le?: boolean): number[];
|
776 | |
777 |
|
778 |
|
779 |
|
780 | toBytesLE(): number[];
|
781 | |
782 |
|
783 |
|
784 |
|
785 | toBytesBE(): number[];
|
786 | |
787 |
|
788 |
|
789 | toSigned(): Long;
|
790 | |
791 |
|
792 |
|
793 |
|
794 |
|
795 | toString(radix?: number): string;
|
796 |
|
797 | toUnsigned(): Long;
|
798 |
|
799 | xor(other: Long | number | string): Long;
|
800 |
|
801 | eqz(): boolean;
|
802 |
|
803 | le(other: string | number | Long | Timestamp): boolean;
|
804 | toExtendedJSON(options?: EJSONOptions): number | LongExtended;
|
805 | static fromExtendedJSON(doc: {
|
806 | $numberLong: string;
|
807 | }, options?: EJSONOptions): number | Long;
|
808 | inspect(): string;
|
809 | }
|
810 |
|
811 | export declare interface LongExtended {
|
812 | $numberLong: string;
|
813 | }
|
814 |
|
815 | export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => {
|
816 | [P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
|
817 | };
|
818 |
|
819 | export declare const LongWithoutOverridesClass: LongWithoutOverrides;
|
820 |
|
821 | declare let Map_2: MapConstructor;
|
822 | export { Map_2 as Map };
|
823 |
|
824 |
|
825 |
|
826 |
|
827 | export declare class MaxKey {
|
828 | _bsontype: 'MaxKey';
|
829 | constructor();
|
830 | /* Excluded from this release type: toExtendedJSON */
|
831 | /* Excluded from this release type: fromExtendedJSON */
|
832 | inspect(): string;
|
833 | }
|
834 | /** @public */
|
835 | export declare interface MaxKeyExtended {
|
836 | $maxKey: 1;
|
837 | }
|
838 |
|
839 |
|
840 |
|
841 |
|
842 | export declare class MinKey {
|
843 | _bsontype: 'MinKey';
|
844 | constructor();
|
845 | /* Excluded from this release type: toExtendedJSON */
|
846 | /* Excluded from this release type: fromExtendedJSON */
|
847 | inspect(): string;
|
848 | }
|
849 | /** @public */
|
850 | export declare interface MinKeyExtended {
|
851 | $minKey: 1;
|
852 | }
|
853 |
|
854 |
|
855 |
|
856 |
|
857 | declare class ObjectId {
|
858 | _bsontype: 'ObjectId';
|
859 |
|
860 | static cacheHexString: boolean;
|
861 |
|
862 |
|
863 | |
864 |
|
865 |
|
866 |
|
867 |
|
868 | constructor(id?: string | Buffer | number | ObjectIdLike | ObjectId);
|
869 | /*
|
870 | * The ObjectId bytes
|
871 | * @readonly
|
872 | */
|
873 | id: Buffer;
|
874 | /*
|
875 | * The generation time of this ObjectId instance
|
876 | * @deprecated Please use getTimestamp / createFromTime which returns an int32 epoch
|
877 | */
|
878 | generationTime: number;
|
879 | /** Returns the ObjectId id as a 24 character hex string representation */
|
880 | toHexString(): string;
|
881 | /* Excluded from this release type: getInc */
|
882 | /**
|
883 | * Generate a 12 byte id buffer used in ObjectId's
|
884 | *
|
885 | * @param time - pass in a second based timestamp.
|
886 | */
|
887 | static generate(time?: number): Buffer;
|
888 | /**
|
889 | * Converts the id into a 24 character hex string for printing
|
890 | *
|
891 | * @param format - The Buffer toString format parameter.
|
892 | */
|
893 | toString(format?: string): string;
|
894 | /** Converts to its JSON the 24 character hex string representation. */
|
895 | toJSON(): string;
|
896 | /**
|
897 | * Compares the equality of this ObjectId with `otherID`.
|
898 | *
|
899 | * @param otherId - ObjectId instance to compare against.
|
900 | */
|
901 | equals(otherId: string | ObjectId | ObjectIdLike): boolean;
|
902 | /** Returns the generation date (accurate up to the second) that this ID was generated. */
|
903 | getTimestamp(): Date;
|
904 | /* Excluded from this release type: createPk */
|
905 | /**
|
906 | * Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
|
907 | *
|
908 | * @param time - an integer number representing a number of seconds.
|
909 | */
|
910 | static createFromTime(time: number): ObjectId;
|
911 | /**
|
912 | * Creates an ObjectId from a hex string representation of an ObjectId.
|
913 | *
|
914 | * @param hexString - create a ObjectId from a passed in 24 character hexstring.
|
915 | */
|
916 | static createFromHexString(hexString: string): ObjectId;
|
917 | /**
|
918 | * Checks if a value is a valid bson ObjectId
|
919 | *
|
920 | * @param id - ObjectId instance to validate.
|
921 | */
|
922 | static isValid(id: number | string | ObjectId | Uint8Array | ObjectIdLike): boolean;
|
923 | /* Excluded from this release type: toExtendedJSON */
|
924 | /* Excluded from this release type: fromExtendedJSON */
|
925 | inspect(): string;
|
926 | }
|
927 | export { ObjectId as ObjectID };
|
928 | export { ObjectId };
|
929 |
|
930 | export declare interface ObjectIdExtended {
|
931 | $oid: string;
|
932 | }
|
933 |
|
934 | export declare interface ObjectIdLike {
|
935 | id: string | Buffer;
|
936 | __id?: string;
|
937 | toHexString(): string;
|
938 | }
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 | export declare function serialize(object: Document, options?: SerializeOptions): Buffer;
|
947 |
|
948 | export declare interface SerializeOptions {
|
949 |
|
950 | checkKeys?: boolean;
|
951 |
|
952 | serializeFunctions?: boolean;
|
953 |
|
954 | ignoreUndefined?: boolean;
|
955 |
|
956 |
|
957 | index?: number;
|
958 | }
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 | export declare function serializeWithBufferAndIndex(object: Document, finalBuffer: Buffer, options?: SerializeOptions): number;
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | export declare function setInternalBufferSize(size: number): void;
|
976 |
|
977 | export declare class Timestamp extends LongWithoutOverridesClass {
|
978 | _bsontype: 'Timestamp';
|
979 | static readonly MAX_VALUE: Long;
|
980 | |
981 |
|
982 |
|
983 | constructor(long: Long);
|
984 | /**
|
985 | * @param value - A pair of two values indicating timestamp and increment.
|
986 | */
|
987 | constructor(value: {
|
988 | t: number;
|
989 | i: number;
|
990 | });
|
991 | /**
|
992 | * @param low - the low (signed) 32 bits of the Timestamp.
|
993 | * @param high - the high (signed) 32 bits of the Timestamp.
|
994 | * @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead.
|
995 | */
|
996 | constructor(low: number, high: number);
|
997 | toJSON(): {
|
998 | $timestamp: string;
|
999 | };
|
1000 | /** Returns a Timestamp represented by the given (32-bit) integer value. */
|
1001 | static fromInt(value: number): Timestamp;
|
1002 | /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
|
1003 | static fromNumber(value: number): Timestamp;
|
1004 | /**
|
1005 | * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
|
1006 | *
|
1007 | * @param lowBits - the low 32-bits.
|
1008 | * @param highBits - the high 32-bits.
|
1009 | */
|
1010 | static fromBits(lowBits: number, highBits: number): Timestamp;
|
1011 | /**
|
1012 | * Returns a Timestamp from the given string, optionally using the given radix.
|
1013 | *
|
1014 | * @param str - the textual representation of the Timestamp.
|
1015 | * @param optRadix - the radix in which the text is written.
|
1016 | */
|
1017 | static fromString(str: string, optRadix: number): Timestamp;
|
1018 | /* Excluded from this release type: toExtendedJSON */
|
1019 | /* Excluded from this release type: fromExtendedJSON */
|
1020 | inspect(): string;
|
1021 | }
|
1022 | /** @public */
|
1023 | export declare interface TimestampExtended {
|
1024 | $timestamp: {
|
1025 | t: number;
|
1026 | i: number;
|
1027 | };
|
1028 | }
|
1029 |
|
1030 | export declare type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect';
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 | export declare class UUID {
|
1036 | _bsontype: 'UUID';
|
1037 | static cacheHexString: boolean;
|
1038 |
|
1039 |
|
1040 | |
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 | constructor(input?: string | Buffer | UUID);
|
1046 | /*
|
1047 | * The UUID bytes
|
1048 | * @readonly
|
1049 | */
|
1050 | id: Buffer;
|
1051 | /**
|
1052 | * Generate a 16 byte uuid v4 buffer used in UUIDs
|
1053 | */
|
1054 | /**
|
1055 | * Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated)
|
1056 | * @param includeDashes - should the string exclude dash-separators.
|
1057 | * */
|
1058 | toHexString(includeDashes?: boolean): string;
|
1059 | /**
|
1060 | * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
|
1061 | */
|
1062 | toString(encoding?: string): string;
|
1063 | /**
|
1064 | * Converts the id into its JSON string representation.
|
1065 | * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
1066 | */
|
1067 | toJSON(): string;
|
1068 | /**
|
1069 | * Compares the equality of this UUID with `otherID`.
|
1070 | *
|
1071 | * @param otherId - UUID instance to compare against.
|
1072 | */
|
1073 | equals(otherId: string | Buffer | UUID): boolean;
|
1074 | /**
|
1075 | * Creates a Binary instance from the current UUID.
|
1076 | */
|
1077 | toBinary(): Binary;
|
1078 | /**
|
1079 | * Generates a populated buffer containing a v4 uuid
|
1080 | */
|
1081 | static generate(): Buffer;
|
1082 | /**
|
1083 | * Checks if a value is a valid bson UUID
|
1084 | * @param input - UUID, string or Buffer to validate.
|
1085 | */
|
1086 | static isValid(input: string | Buffer | UUID): boolean;
|
1087 | /**
|
1088 | * Creates an UUID from a hex string representation of an UUID.
|
1089 | * @param hexString - 32 or 36 character hex string (dashes excluded/included).
|
1090 | */
|
1091 | static createFromHexString(hexString: string): UUID;
|
1092 | inspect(): string;
|
1093 | }
|
1094 | /** @public */
|
1095 | export declare type UUIDExtended = {
|
1096 | $uuid: string;
|
1097 | };
|
1098 | export {};
|