bson 5.0.0-alpha.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bson.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @public
4
4
  * @category BSONType
5
5
  */
6
- export declare class Binary {
6
+ export declare class Binary extends BSONValue {
7
7
  get _bsontype(): 'Binary';
8
8
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
9
9
  /** Initial buffer default size */
@@ -141,7 +141,9 @@ declare namespace BSON {
141
141
  MaxKey,
142
142
  BSONRegExp,
143
143
  Decimal128,
144
+ BSONValue,
144
145
  BSONError,
146
+ BSONVersionError,
145
147
  BSONType,
146
148
  EJSON,
147
149
  Document,
@@ -175,7 +177,7 @@ export declare class BSONError extends Error {
175
177
  * @public
176
178
  * @category BSONType
177
179
  */
178
- export declare class BSONRegExp {
180
+ export declare class BSONRegExp extends BSONValue {
179
181
  get _bsontype(): 'BSONRegExp';
180
182
  pattern: string;
181
183
  options: string;
@@ -209,7 +211,7 @@ export declare interface BSONRegExpExtendedLegacy {
209
211
  * @public
210
212
  * @category BSONType
211
213
  */
212
- export declare class BSONSymbol {
214
+ export declare class BSONSymbol extends BSONValue {
213
215
  get _bsontype(): 'BSONSymbol';
214
216
  value: string;
215
217
  /**
@@ -219,7 +221,7 @@ export declare class BSONSymbol {
219
221
  /** Access the wrapped string value. */
220
222
  valueOf(): string;
221
223
  toString(): string;
222
- /* Excluded from this release type: inspect */
224
+ inspect(): string;
223
225
  toJSON(): string;
224
226
  /* Excluded from this release type: toExtendedJSON */
225
227
  /* Excluded from this release type: fromExtendedJSON */
@@ -258,6 +260,21 @@ export declare const BSONType: Readonly<{
258
260
  /** @public */
259
261
  export declare type BSONType = typeof BSONType[keyof typeof BSONType];
260
262
 
263
+ /** @public */
264
+ export declare abstract class BSONValue {
265
+ /** @public */
266
+ abstract get _bsontype(): string;
267
+ /** @public */
268
+ abstract inspect(): string;
269
+ /* Excluded from this release type: toExtendedJSON */
270
+ }
271
+
272
+ /** @public */
273
+ export declare class BSONVersionError extends BSONError {
274
+ get name(): 'BSONVersionError';
275
+ constructor();
276
+ }
277
+
261
278
  /**
262
279
  * Calculate the bson size for a passed in Javascript object.
263
280
  *
@@ -275,7 +292,7 @@ export declare type CalculateObjectSizeOptions = Pick<SerializeOptions, 'seriali
275
292
  * @public
276
293
  * @category BSONType
277
294
  */
278
- export declare class Code {
295
+ export declare class Code extends BSONValue {
279
296
  get _bsontype(): 'Code';
280
297
  code: string;
281
298
  scope: Document | null;
@@ -304,7 +321,7 @@ export declare interface CodeExtended {
304
321
  * @public
305
322
  * @category BSONType
306
323
  */
307
- export declare class DBRef {
324
+ export declare class DBRef extends BSONValue {
308
325
  get _bsontype(): 'DBRef';
309
326
  collection: string;
310
327
  oid: ObjectId;
@@ -336,7 +353,7 @@ export declare interface DBRefLike {
336
353
  * @public
337
354
  * @category BSONType
338
355
  */
339
- export declare class Decimal128 {
356
+ export declare class Decimal128 extends BSONValue {
340
357
  get _bsontype(): 'Decimal128';
341
358
  readonly bytes: Uint8Array;
342
359
  /**
@@ -435,7 +452,7 @@ export declare interface Document {
435
452
  * @public
436
453
  * @category BSONType
437
454
  */
438
- export declare class Double {
455
+ export declare class Double extends BSONValue {
439
456
  get _bsontype(): 'Double';
440
457
  value: number;
441
458
  /**
@@ -484,6 +501,8 @@ export declare type EJSONOptions = {
484
501
  legacy?: boolean;
485
502
  /** Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types */
486
503
  relaxed?: boolean;
504
+ /** Enable native bigint support */
505
+ useBigInt64?: boolean;
487
506
  };
488
507
 
489
508
  /**
@@ -499,7 +518,7 @@ declare function EJSONserialize(value: any, options?: EJSONOptions): Document;
499
518
  * @public
500
519
  * @category BSONType
501
520
  */
502
- export declare class Int32 {
521
+ export declare class Int32 extends BSONValue {
503
522
  get _bsontype(): 'Int32';
504
523
  value: number;
505
524
  /**
@@ -547,7 +566,7 @@ declare const kId: unique symbol;
547
566
  * case would often result in infinite recursion.
548
567
  * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class.
549
568
  */
550
- export declare class Long {
569
+ export declare class Long extends BSONValue {
551
570
  get _bsontype(): 'Long';
552
571
  /** An indicator used to reliably determine if an object is a Long or not. */
553
572
  get __isLong__(): boolean;
@@ -840,7 +859,7 @@ export declare class Long {
840
859
  toExtendedJSON(options?: EJSONOptions): number | LongExtended;
841
860
  static fromExtendedJSON(doc: {
842
861
  $numberLong: string;
843
- }, options?: EJSONOptions): number | Long;
862
+ }, options?: EJSONOptions): number | Long | bigint;
844
863
  inspect(): string;
845
864
  }
846
865
 
@@ -862,7 +881,7 @@ export declare const LongWithoutOverridesClass: LongWithoutOverrides;
862
881
  * @public
863
882
  * @category BSONType
864
883
  */
865
- export declare class MaxKey {
884
+ export declare class MaxKey extends BSONValue {
866
885
  get _bsontype(): 'MaxKey';
867
886
  /* Excluded from this release type: toExtendedJSON */
868
887
  /* Excluded from this release type: fromExtendedJSON */
@@ -879,7 +898,7 @@ export declare interface MaxKeyExtended {
879
898
  * @public
880
899
  * @category BSONType
881
900
  */
882
- export declare class MinKey {
901
+ export declare class MinKey extends BSONValue {
883
902
  get _bsontype(): 'MinKey';
884
903
  /* Excluded from this release type: toExtendedJSON */
885
904
  /* Excluded from this release type: fromExtendedJSON */
@@ -896,7 +915,7 @@ export declare interface MinKeyExtended {
896
915
  * @public
897
916
  * @category BSONType
898
917
  */
899
- export declare class ObjectId {
918
+ export declare class ObjectId extends BSONValue {
900
919
  get _bsontype(): 'ObjectId';
901
920
  /* Excluded from this release type: index */
902
921
  static cacheHexString: boolean;