bson 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +3 -126
  2. package/bson.d.ts +71 -22
  3. package/lib/binary.d.ts +182 -0
  4. package/lib/binary.d.ts.map +1 -0
  5. package/lib/bson.bundle.js +68 -86
  6. package/lib/bson.bundle.js.map +1 -1
  7. package/lib/bson.cjs +68 -86
  8. package/lib/bson.cjs.map +1 -1
  9. package/lib/bson.d.ts +97 -0
  10. package/lib/bson.d.ts.map +1 -0
  11. package/lib/bson.mjs +68 -86
  12. package/lib/bson.mjs.map +1 -1
  13. package/lib/bson_value.d.ts +10 -0
  14. package/lib/bson_value.d.ts.map +1 -0
  15. package/lib/code.d.ts +32 -0
  16. package/lib/code.d.ts.map +1 -0
  17. package/lib/constants.d.ts +107 -0
  18. package/lib/constants.d.ts.map +1 -0
  19. package/lib/db_ref.d.ts +40 -0
  20. package/lib/db_ref.d.ts.map +1 -0
  21. package/lib/decimal128.d.ts +34 -0
  22. package/lib/decimal128.d.ts.map +1 -0
  23. package/lib/double.d.ts +35 -0
  24. package/lib/double.d.ts.map +1 -0
  25. package/lib/error.d.ts +50 -0
  26. package/lib/error.d.ts.map +1 -0
  27. package/lib/extended_json.d.ts +82 -0
  28. package/lib/extended_json.d.ts.map +1 -0
  29. package/lib/index.d.ts +4 -0
  30. package/lib/index.d.ts.map +1 -0
  31. package/lib/int_32.d.ts +35 -0
  32. package/lib/int_32.d.ts.map +1 -0
  33. package/lib/long.d.ts +323 -0
  34. package/lib/long.d.ts.map +1 -0
  35. package/lib/max_key.d.ts +19 -0
  36. package/lib/max_key.d.ts.map +1 -0
  37. package/lib/min_key.d.ts +19 -0
  38. package/lib/min_key.d.ts.map +1 -0
  39. package/lib/objectid.d.ts +96 -0
  40. package/lib/objectid.d.ts.map +1 -0
  41. package/lib/regexp.d.ts +36 -0
  42. package/lib/regexp.d.ts.map +1 -0
  43. package/lib/symbol.d.ts +28 -0
  44. package/lib/symbol.d.ts.map +1 -0
  45. package/lib/timestamp.d.ts +66 -0
  46. package/lib/timestamp.d.ts.map +1 -0
  47. package/lib/validate_utf8.d.ts +10 -0
  48. package/lib/validate_utf8.d.ts.map +1 -0
  49. package/package.json +20 -20
  50. package/src/binary.ts +49 -41
  51. package/src/bson.ts +1 -1
  52. package/src/constants.ts +1 -1
  53. package/src/extended_json.ts +11 -3
  54. package/src/parser/deserializer.ts +37 -12
  55. package/src/parser/serializer.ts +17 -4
  56. package/src/timestamp.ts +1 -1
  57. package/src/uuid_utils.ts +0 -33
package/lib/bson.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ import { Binary, UUID } from './binary';
2
+ import { Code } from './code';
3
+ import { DBRef } from './db_ref';
4
+ import { Decimal128 } from './decimal128';
5
+ import { Double } from './double';
6
+ import { Int32 } from './int_32';
7
+ import { Long } from './long';
8
+ import { MaxKey } from './max_key';
9
+ import { MinKey } from './min_key';
10
+ import { ObjectId } from './objectid';
11
+ import { DeserializeOptions } from './parser/deserializer';
12
+ import { SerializeOptions } from './parser/serializer';
13
+ import { BSONRegExp } from './regexp';
14
+ import { BSONSymbol } from './symbol';
15
+ import { Timestamp } from './timestamp';
16
+ export type { UUIDExtended, BinaryExtended, BinaryExtendedLegacy, BinarySequence } from './binary';
17
+ export type { CodeExtended } from './code';
18
+ export type { DBRefLike } from './db_ref';
19
+ export type { Decimal128Extended } from './decimal128';
20
+ export type { DoubleExtended } from './double';
21
+ export type { EJSONOptions } from './extended_json';
22
+ export type { Int32Extended } from './int_32';
23
+ export type { LongExtended } from './long';
24
+ export type { MaxKeyExtended } from './max_key';
25
+ export type { MinKeyExtended } from './min_key';
26
+ export type { ObjectIdExtended, ObjectIdLike } from './objectid';
27
+ export type { BSONRegExpExtended, BSONRegExpExtendedLegacy } from './regexp';
28
+ export type { BSONSymbolExtended } from './symbol';
29
+ export type { LongWithoutOverrides, TimestampExtended, TimestampOverrides } from './timestamp';
30
+ export type { LongWithoutOverridesClass } from './timestamp';
31
+ export type { SerializeOptions, DeserializeOptions };
32
+ export { Code, BSONSymbol, DBRef, Binary, ObjectId, UUID, Long, Timestamp, Double, Int32, MinKey, MaxKey, BSONRegExp, Decimal128 };
33
+ export { BSONValue } from './bson_value';
34
+ export { BSONError, BSONVersionError, BSONRuntimeError } from './error';
35
+ export { BSONType } from './constants';
36
+ export { EJSON } from './extended_json';
37
+ /** @public */
38
+ export interface Document {
39
+ [key: string]: any;
40
+ }
41
+ /**
42
+ * Sets the size of the internal serialization buffer.
43
+ *
44
+ * @param size - The desired size for the internal serialization buffer in bytes
45
+ * @public
46
+ */
47
+ export declare function setInternalBufferSize(size: number): void;
48
+ /**
49
+ * Serialize a Javascript object.
50
+ *
51
+ * @param object - the Javascript object to serialize.
52
+ * @returns Buffer object containing the serialized object.
53
+ * @public
54
+ */
55
+ export declare function serialize(object: Document, options?: SerializeOptions): Uint8Array;
56
+ /**
57
+ * Serialize a Javascript object using a predefined Buffer and index into the buffer,
58
+ * useful when pre-allocating the space for serialization.
59
+ *
60
+ * @param object - the Javascript object to serialize.
61
+ * @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object.
62
+ * @returns the index pointing to the last written byte in the buffer.
63
+ * @public
64
+ */
65
+ export declare function serializeWithBufferAndIndex(object: Document, finalBuffer: Uint8Array, options?: SerializeOptions): number;
66
+ /**
67
+ * Deserialize data as BSON.
68
+ *
69
+ * @param buffer - the buffer containing the serialized set of BSON documents.
70
+ * @returns returns the deserialized Javascript Object.
71
+ * @public
72
+ */
73
+ export declare function deserialize(buffer: Uint8Array, options?: DeserializeOptions): Document;
74
+ /** @public */
75
+ export type CalculateObjectSizeOptions = Pick<SerializeOptions, 'serializeFunctions' | 'ignoreUndefined'>;
76
+ /**
77
+ * Calculate the bson size for a passed in Javascript object.
78
+ *
79
+ * @param object - the Javascript object to calculate the BSON byte size for
80
+ * @returns size of BSON object in bytes
81
+ * @public
82
+ */
83
+ export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number;
84
+ /**
85
+ * Deserialize stream data as BSON documents.
86
+ *
87
+ * @param data - the buffer containing the serialized set of BSON documents.
88
+ * @param startIndex - the start index in the data Buffer where the deserialization is to start.
89
+ * @param numberOfDocuments - number of documents to deserialize.
90
+ * @param documents - an array where to store the deserialized documents.
91
+ * @param docStartIndex - the index in the documents array from where to start inserting documents.
92
+ * @param options - additional options used for the deserialization.
93
+ * @returns next index in the buffer after deserialization **x** numbers of documents.
94
+ * @public
95
+ */
96
+ export declare function deserializeStream(data: Uint8Array | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number;
97
+ //# sourceMappingURL=bson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bson.d.ts","sourceRoot":"","sources":["../src/bson.ts"],"names":[],"mappings":"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"}
package/lib/bson.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ function isAnyArrayBuffer(value) {
2
+ return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
3
+ }
4
+ function isUint8Array(value) {
5
+ return Object.prototype.toString.call(value) === '[object Uint8Array]';
6
+ }
7
+ function isRegExp(d) {
8
+ return Object.prototype.toString.call(d) === '[object RegExp]';
9
+ }
10
+ function isMap(d) {
11
+ return Object.prototype.toString.call(d) === '[object Map]';
12
+ }
13
+ function isDate(d) {
14
+ return Object.prototype.toString.call(d) === '[object Date]';
15
+ }
16
+
1
17
  const BSON_MAJOR_VERSION = 5;
2
18
  const BSON_INT32_MAX = 0x7fffffff;
3
19
  const BSON_INT32_MIN = -0x80000000;
@@ -280,44 +296,6 @@ class BSONDataView extends DataView {
280
296
  }
281
297
  }
282
298
 
283
- const VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i;
284
- const uuidValidateString = (str) => typeof str === 'string' && VALIDATION_REGEX.test(str);
285
- const uuidHexStringToBuffer = (hexString) => {
286
- if (!uuidValidateString(hexString)) {
287
- throw new BSONError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');
288
- }
289
- const sanitizedHexString = hexString.replace(/-/g, '');
290
- return ByteUtils.fromHex(sanitizedHexString);
291
- };
292
- function bufferToUuidHexString(buffer, includeDashes = true) {
293
- if (includeDashes) {
294
- return [
295
- ByteUtils.toHex(buffer.subarray(0, 4)),
296
- ByteUtils.toHex(buffer.subarray(4, 6)),
297
- ByteUtils.toHex(buffer.subarray(6, 8)),
298
- ByteUtils.toHex(buffer.subarray(8, 10)),
299
- ByteUtils.toHex(buffer.subarray(10, 16))
300
- ].join('-');
301
- }
302
- return ByteUtils.toHex(buffer);
303
- }
304
-
305
- function isAnyArrayBuffer(value) {
306
- return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
307
- }
308
- function isUint8Array(value) {
309
- return Object.prototype.toString.call(value) === '[object Uint8Array]';
310
- }
311
- function isRegExp(d) {
312
- return Object.prototype.toString.call(d) === '[object RegExp]';
313
- }
314
- function isMap(d) {
315
- return Object.prototype.toString.call(d) === '[object Map]';
316
- }
317
- function isDate(d) {
318
- return Object.prototype.toString.call(d) === '[object Date]';
319
- }
320
-
321
299
  class BSONValue {
322
300
  get [Symbol.for('@@mdb.bson.version')]() {
323
301
  return BSON_MAJOR_VERSION;
@@ -479,7 +457,7 @@ class Binary extends BSONValue {
479
457
  }
480
458
  else if ('$uuid' in doc) {
481
459
  type = 4;
482
- data = uuidHexStringToBuffer(doc.$uuid);
460
+ data = UUID.bytesFromString(doc.$uuid);
483
461
  }
484
462
  if (!data) {
485
463
  throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`);
@@ -506,47 +484,45 @@ Binary.SUBTYPE_ENCRYPTED = 6;
506
484
  Binary.SUBTYPE_COLUMN = 7;
507
485
  Binary.SUBTYPE_USER_DEFINED = 128;
508
486
  const UUID_BYTE_LENGTH = 16;
487
+ const UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
488
+ const UUID_WITH_DASHES = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
509
489
  class UUID extends Binary {
510
490
  constructor(input) {
511
491
  let bytes;
512
- let hexStr;
513
492
  if (input == null) {
514
493
  bytes = UUID.generate();
515
494
  }
516
495
  else if (input instanceof UUID) {
517
496
  bytes = ByteUtils.toLocalBufferType(new Uint8Array(input.buffer));
518
- hexStr = input.__id;
519
497
  }
520
498
  else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) {
521
499
  bytes = ByteUtils.toLocalBufferType(input);
522
500
  }
523
501
  else if (typeof input === 'string') {
524
- bytes = uuidHexStringToBuffer(input);
502
+ bytes = UUID.bytesFromString(input);
525
503
  }
526
504
  else {
527
505
  throw new BSONError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).');
528
506
  }
529
507
  super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW);
530
- this.__id = hexStr;
531
508
  }
532
509
  get id() {
533
510
  return this.buffer;
534
511
  }
535
512
  set id(value) {
536
513
  this.buffer = value;
537
- if (UUID.cacheHexString) {
538
- this.__id = bufferToUuidHexString(value);
539
- }
540
514
  }
541
515
  toHexString(includeDashes = true) {
542
- if (UUID.cacheHexString && this.__id) {
543
- return this.__id;
544
- }
545
- const uuidHexString = bufferToUuidHexString(this.id, includeDashes);
546
- if (UUID.cacheHexString) {
547
- this.__id = uuidHexString;
516
+ if (includeDashes) {
517
+ return [
518
+ ByteUtils.toHex(this.buffer.subarray(0, 4)),
519
+ ByteUtils.toHex(this.buffer.subarray(4, 6)),
520
+ ByteUtils.toHex(this.buffer.subarray(6, 8)),
521
+ ByteUtils.toHex(this.buffer.subarray(8, 10)),
522
+ ByteUtils.toHex(this.buffer.subarray(10, 16))
523
+ ].join('-');
548
524
  }
549
- return uuidHexString;
525
+ return ByteUtils.toHex(this.buffer);
550
526
  }
551
527
  toString(encoding) {
552
528
  if (encoding === 'hex')
@@ -585,27 +561,32 @@ class UUID extends Binary {
585
561
  if (!input) {
586
562
  return false;
587
563
  }
588
- if (input instanceof UUID) {
589
- return true;
590
- }
591
564
  if (typeof input === 'string') {
592
- return uuidValidateString(input);
565
+ return UUID.isValidUUIDString(input);
593
566
  }
594
567
  if (isUint8Array(input)) {
595
- if (input.byteLength !== UUID_BYTE_LENGTH) {
596
- return false;
597
- }
598
- return (input[6] & 0xf0) === 0x40 && (input[8] & 0x80) === 0x80;
568
+ return input.byteLength === UUID_BYTE_LENGTH;
599
569
  }
600
- return false;
570
+ return (input._bsontype === 'Binary' &&
571
+ input.sub_type === this.SUBTYPE_UUID &&
572
+ input.buffer.byteLength === 16);
601
573
  }
602
574
  static createFromHexString(hexString) {
603
- const buffer = uuidHexStringToBuffer(hexString);
575
+ const buffer = UUID.bytesFromString(hexString);
604
576
  return new UUID(buffer);
605
577
  }
606
578
  static createFromBase64(base64) {
607
579
  return new UUID(ByteUtils.fromBase64(base64));
608
580
  }
581
+ static bytesFromString(representation) {
582
+ if (!UUID.isValidUUIDString(representation)) {
583
+ throw new BSONError('UUID string representation must be 32 hex digits or canonical hyphenated representation');
584
+ }
585
+ return ByteUtils.fromHex(representation.replace(/-/g, ''));
586
+ }
587
+ static isValidUUIDString(representation) {
588
+ return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation);
589
+ }
609
590
  [Symbol.for('nodejs.util.inspect.custom')]() {
610
591
  return this.inspect();
611
592
  }
@@ -613,6 +594,7 @@ class UUID extends Binary {
613
594
  return `new UUID("${this.toHexString()}")`;
614
595
  }
615
596
  }
597
+ UUID.cacheHexString = false;
616
598
 
617
599
  class Code extends BSONValue {
618
600
  get _bsontype() {
@@ -2789,7 +2771,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
2789
2771
  }
2790
2772
  else {
2791
2773
  value = new Binary(buffer.slice(index, index + binarySize), subType);
2792
- if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) {
2774
+ if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
2793
2775
  value = value.toUUID();
2794
2776
  }
2795
2777
  }
@@ -2815,11 +2797,11 @@ function deserializeObject(buffer, index, options, isArray = false) {
2815
2797
  if (promoteBuffers && promoteValues) {
2816
2798
  value = _buffer;
2817
2799
  }
2818
- else if (subType === BSON_BINARY_SUBTYPE_UUID_NEW) {
2819
- value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID();
2820
- }
2821
2800
  else {
2822
2801
  value = new Binary(buffer.slice(index, index + binarySize), subType);
2802
+ if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
2803
+ value = value.toUUID();
2804
+ }
2823
2805
  }
2824
2806
  }
2825
2807
  index = index + binarySize;
@@ -4051,32 +4033,32 @@ function deserializeStream(data, startIndex, numberOfDocuments, documents, docSt
4051
4033
 
4052
4034
  var bson = /*#__PURE__*/Object.freeze({
4053
4035
  __proto__: null,
4054
- Code: Code,
4036
+ BSONError: BSONError,
4037
+ BSONRegExp: BSONRegExp,
4038
+ BSONRuntimeError: BSONRuntimeError,
4055
4039
  BSONSymbol: BSONSymbol,
4056
- DBRef: DBRef,
4040
+ BSONType: BSONType,
4041
+ BSONValue: BSONValue,
4042
+ BSONVersionError: BSONVersionError,
4057
4043
  Binary: Binary,
4058
- ObjectId: ObjectId,
4059
- UUID: UUID,
4060
- Long: Long,
4061
- Timestamp: Timestamp,
4044
+ Code: Code,
4045
+ DBRef: DBRef,
4046
+ Decimal128: Decimal128,
4062
4047
  Double: Double,
4048
+ EJSON: EJSON,
4063
4049
  Int32: Int32,
4064
- MinKey: MinKey,
4050
+ Long: Long,
4065
4051
  MaxKey: MaxKey,
4066
- BSONRegExp: BSONRegExp,
4067
- Decimal128: Decimal128,
4068
- setInternalBufferSize: setInternalBufferSize,
4069
- serialize: serialize,
4070
- serializeWithBufferAndIndex: serializeWithBufferAndIndex,
4071
- deserialize: deserialize,
4052
+ MinKey: MinKey,
4053
+ ObjectId: ObjectId,
4054
+ Timestamp: Timestamp,
4055
+ UUID: UUID,
4072
4056
  calculateObjectSize: calculateObjectSize,
4057
+ deserialize: deserialize,
4073
4058
  deserializeStream: deserializeStream,
4074
- BSONValue: BSONValue,
4075
- BSONError: BSONError,
4076
- BSONVersionError: BSONVersionError,
4077
- BSONRuntimeError: BSONRuntimeError,
4078
- BSONType: BSONType,
4079
- EJSON: EJSON
4059
+ serialize: serialize,
4060
+ serializeWithBufferAndIndex: serializeWithBufferAndIndex,
4061
+ setInternalBufferSize: setInternalBufferSize
4080
4062
  });
4081
4063
 
4082
4064
  export { bson as BSON, BSONError, BSONRegExp, BSONRuntimeError, BSONSymbol, BSONType, BSONValue, BSONVersionError, Binary, Code, DBRef, Decimal128, Double, EJSON, Int32, Long, MaxKey, MinKey, ObjectId, Timestamp, UUID, calculateObjectSize, deserialize, deserializeStream, serialize, serializeWithBufferAndIndex, setInternalBufferSize };