@mongoosejs/studio 0.0.45 → 0.0.46

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.
@@ -970,6 +970,24 @@ module.exports = app => app.component('edit-date', {
970
970
  data: () => ({
971
971
  inputType: ''
972
972
  }),
973
+ methods: {
974
+ updateFromISO($event) {
975
+ const value = $event.target.value;
976
+ if (value == null) {
977
+ return this.$emit('input', $event.target.value);
978
+ }
979
+ if (value === 'null') {
980
+ return this.$emit('input', null);
981
+ }
982
+ if (value === 'undefined') {
983
+ return this.$emit('input', undefined);
984
+ }
985
+ const valueAsDate = new Date(value);
986
+ if (!isNaN(valueAsDate.valueOf())) {
987
+ this.$emit('input', $event.target.value);
988
+ }
989
+ }
990
+ },
973
991
  computed: {
974
992
  valueAsLocalString() {
975
993
  if (this.value == null) {
@@ -990,7 +1008,7 @@ module.exports = app => app.component('edit-date', {
990
1008
  },
991
1009
  valueAsISOString() {
992
1010
  if (this.value == null) {
993
- return this.value;
1011
+ return '' + this.value;
994
1012
  }
995
1013
  const date = new Date(this.value);
996
1014
  return date.toISOString();
@@ -2680,7 +2698,7 @@ module.exports = "<div class=\"edit-array\">\n <textarea\n ref=\"arrayEditor
2680
2698
  /***/ ((module) => {
2681
2699
 
2682
2700
  "use strict";
2683
- module.exports = "<div>\n <input v-if=\"dateSelection == 'picker'\" class=\"w-64 h-8 border border-gray-300 outline-0\" type=\"datetime-local\" :value=\"valueAsLocalString\" @input=\"$emit('input', $event.target.value)\">\n <input v-if=\"dateSelection == 'iso'\" type=\"text\" class=\"w-64 h-8 border border-gray-300 outline-0\" :value=\"valueAsISOString\" @input=\"$emit('input', $event.target.value)\">\n</div>";
2701
+ module.exports = "<div>\n <input\n v-if=\"dateSelection == 'picker'\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n type=\"datetime-local\"\n :value=\"valueAsLocalString\"\n @input=\"$emit('input', $event.target.value)\">\n <input\n v-if=\"dateSelection == 'iso'\"\n type=\"text\"\n class=\"w-64 h-8 border border-gray-300 outline-0\"\n :value=\"valueAsISOString\"\n @input=\"updateFromISO\">\n</div>";
2684
2702
 
2685
2703
  /***/ }),
2686
2704
 
@@ -6112,20 +6130,31 @@ module.exports = axios;
6112
6130
  "use strict";
6113
6131
 
6114
6132
 
6115
- function isAnyArrayBuffer(value) {
6116
- return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(Object.prototype.toString.call(value));
6117
- }
6133
+ const TypedArrayPrototypeGetSymbolToStringTag = (() => {
6134
+ const g = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
6135
+ return (value) => g.call(value);
6136
+ })();
6118
6137
  function isUint8Array(value) {
6119
- return Object.prototype.toString.call(value) === '[object Uint8Array]';
6138
+ return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array';
6120
6139
  }
6121
- function isRegExp(d) {
6122
- return Object.prototype.toString.call(d) === '[object RegExp]';
6140
+ function isAnyArrayBuffer(value) {
6141
+ return (typeof value === 'object' &&
6142
+ value != null &&
6143
+ Symbol.toStringTag in value &&
6144
+ (value[Symbol.toStringTag] === 'ArrayBuffer' ||
6145
+ value[Symbol.toStringTag] === 'SharedArrayBuffer'));
6123
6146
  }
6124
- function isMap(d) {
6125
- return Object.prototype.toString.call(d) === '[object Map]';
6147
+ function isRegExp(regexp) {
6148
+ return regexp instanceof RegExp || Object.prototype.toString.call(regexp) === '[object RegExp]';
6126
6149
  }
6127
- function isDate(d) {
6128
- return Object.prototype.toString.call(d) === '[object Date]';
6150
+ function isMap(value) {
6151
+ return (typeof value === 'object' &&
6152
+ value != null &&
6153
+ Symbol.toStringTag in value &&
6154
+ value[Symbol.toStringTag] === 'Map');
6155
+ }
6156
+ function isDate(date) {
6157
+ return date instanceof Date || Object.prototype.toString.call(date) === '[object Date]';
6129
6158
  }
6130
6159
  function defaultInspect(x, _options) {
6131
6160
  return JSON.stringify(x, (k, v) => {
@@ -6149,6 +6178,7 @@ function getStylizeFunction(options) {
6149
6178
  }
6150
6179
 
6151
6180
  const BSON_MAJOR_VERSION = 6;
6181
+ const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
6152
6182
  const BSON_INT32_MAX = 0x7fffffff;
6153
6183
  const BSON_INT32_MIN = -0x80000000;
6154
6184
  const BSON_INT64_MAX = Math.pow(2, 63) - 1;
@@ -6341,7 +6371,7 @@ const nodeJsByteUtils = {
6341
6371
  stringTag === '[object SharedArrayBuffer]') {
6342
6372
  return Buffer.from(potentialBuffer);
6343
6373
  }
6344
- throw new BSONError(`Cannot create Buffer from ${String(potentialBuffer)}`);
6374
+ throw new BSONError(`Cannot create Buffer from the passed potentialBuffer.`);
6345
6375
  },
6346
6376
  allocate(size) {
6347
6377
  return Buffer.alloc(size);
@@ -6399,7 +6429,10 @@ const nodeJsByteUtils = {
6399
6429
  }
6400
6430
  return nodeJsByteUtils.toLocalBufferType(buffer).write(source, byteOffset, undefined, 'utf8');
6401
6431
  },
6402
- randomBytes: nodejsRandomBytes
6432
+ randomBytes: nodejsRandomBytes,
6433
+ swap32(buffer) {
6434
+ return nodeJsByteUtils.toLocalBufferType(buffer).swap32();
6435
+ }
6403
6436
  };
6404
6437
 
6405
6438
  function isReactNative() {
@@ -6444,7 +6477,7 @@ const webByteUtils = {
6444
6477
  stringTag === '[object SharedArrayBuffer]') {
6445
6478
  return new Uint8Array(potentialUint8array);
6446
6479
  }
6447
- throw new BSONError(`Cannot make a Uint8Array from ${String(potentialUint8array)}`);
6480
+ throw new BSONError(`Cannot make a Uint8Array from passed potentialBuffer.`);
6448
6481
  },
6449
6482
  allocate(size) {
6450
6483
  if (typeof size !== 'number') {
@@ -6516,14 +6549,30 @@ const webByteUtils = {
6516
6549
  uint8array.set(bytes, byteOffset);
6517
6550
  return bytes.byteLength;
6518
6551
  },
6519
- randomBytes: webRandomBytes
6552
+ randomBytes: webRandomBytes,
6553
+ swap32(buffer) {
6554
+ if (buffer.length % 4 !== 0) {
6555
+ throw new RangeError('Buffer size must be a multiple of 32-bits');
6556
+ }
6557
+ for (let i = 0; i < buffer.length; i += 4) {
6558
+ const byte0 = buffer[i];
6559
+ const byte1 = buffer[i + 1];
6560
+ const byte2 = buffer[i + 2];
6561
+ const byte3 = buffer[i + 3];
6562
+ buffer[i] = byte3;
6563
+ buffer[i + 1] = byte2;
6564
+ buffer[i + 2] = byte1;
6565
+ buffer[i + 3] = byte0;
6566
+ }
6567
+ return buffer;
6568
+ }
6520
6569
  };
6521
6570
 
6522
6571
  const hasGlobalBuffer = typeof Buffer === 'function' && Buffer.prototype?._isBuffer !== true;
6523
6572
  const ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils;
6524
6573
 
6525
6574
  class BSONValue {
6526
- get [Symbol.for('@@mdb.bson.version')]() {
6575
+ get [BSON_VERSION_SYMBOL]() {
6527
6576
  return BSON_MAJOR_VERSION;
6528
6577
  }
6529
6578
  [Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
@@ -6531,6 +6580,134 @@ class BSONValue {
6531
6580
  }
6532
6581
  }
6533
6582
 
6583
+ const FLOAT = new Float64Array(1);
6584
+ const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
6585
+ FLOAT[0] = -1;
6586
+ const isBigEndian = FLOAT_BYTES[7] === 0;
6587
+ const NumberUtils = {
6588
+ isBigEndian,
6589
+ getNonnegativeInt32LE(source, offset) {
6590
+ if (source[offset + 3] > 127) {
6591
+ throw new RangeError(`Size cannot be negative at offset: ${offset}`);
6592
+ }
6593
+ return (source[offset] |
6594
+ (source[offset + 1] << 8) |
6595
+ (source[offset + 2] << 16) |
6596
+ (source[offset + 3] << 24));
6597
+ },
6598
+ getInt32LE(source, offset) {
6599
+ return (source[offset] |
6600
+ (source[offset + 1] << 8) |
6601
+ (source[offset + 2] << 16) |
6602
+ (source[offset + 3] << 24));
6603
+ },
6604
+ getUint32LE(source, offset) {
6605
+ return (source[offset] +
6606
+ source[offset + 1] * 256 +
6607
+ source[offset + 2] * 65536 +
6608
+ source[offset + 3] * 16777216);
6609
+ },
6610
+ getUint32BE(source, offset) {
6611
+ return (source[offset + 3] +
6612
+ source[offset + 2] * 256 +
6613
+ source[offset + 1] * 65536 +
6614
+ source[offset] * 16777216);
6615
+ },
6616
+ getBigInt64LE(source, offset) {
6617
+ const lo = NumberUtils.getUint32LE(source, offset);
6618
+ const hi = NumberUtils.getUint32LE(source, offset + 4);
6619
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
6620
+ },
6621
+ getFloat64LE: isBigEndian
6622
+ ? (source, offset) => {
6623
+ FLOAT_BYTES[7] = source[offset];
6624
+ FLOAT_BYTES[6] = source[offset + 1];
6625
+ FLOAT_BYTES[5] = source[offset + 2];
6626
+ FLOAT_BYTES[4] = source[offset + 3];
6627
+ FLOAT_BYTES[3] = source[offset + 4];
6628
+ FLOAT_BYTES[2] = source[offset + 5];
6629
+ FLOAT_BYTES[1] = source[offset + 6];
6630
+ FLOAT_BYTES[0] = source[offset + 7];
6631
+ return FLOAT[0];
6632
+ }
6633
+ : (source, offset) => {
6634
+ FLOAT_BYTES[0] = source[offset];
6635
+ FLOAT_BYTES[1] = source[offset + 1];
6636
+ FLOAT_BYTES[2] = source[offset + 2];
6637
+ FLOAT_BYTES[3] = source[offset + 3];
6638
+ FLOAT_BYTES[4] = source[offset + 4];
6639
+ FLOAT_BYTES[5] = source[offset + 5];
6640
+ FLOAT_BYTES[6] = source[offset + 6];
6641
+ FLOAT_BYTES[7] = source[offset + 7];
6642
+ return FLOAT[0];
6643
+ },
6644
+ setInt32BE(destination, offset, value) {
6645
+ destination[offset + 3] = value;
6646
+ value >>>= 8;
6647
+ destination[offset + 2] = value;
6648
+ value >>>= 8;
6649
+ destination[offset + 1] = value;
6650
+ value >>>= 8;
6651
+ destination[offset] = value;
6652
+ return 4;
6653
+ },
6654
+ setInt32LE(destination, offset, value) {
6655
+ destination[offset] = value;
6656
+ value >>>= 8;
6657
+ destination[offset + 1] = value;
6658
+ value >>>= 8;
6659
+ destination[offset + 2] = value;
6660
+ value >>>= 8;
6661
+ destination[offset + 3] = value;
6662
+ return 4;
6663
+ },
6664
+ setBigInt64LE(destination, offset, value) {
6665
+ const mask32bits = BigInt(0xffff_ffff);
6666
+ let lo = Number(value & mask32bits);
6667
+ destination[offset] = lo;
6668
+ lo >>= 8;
6669
+ destination[offset + 1] = lo;
6670
+ lo >>= 8;
6671
+ destination[offset + 2] = lo;
6672
+ lo >>= 8;
6673
+ destination[offset + 3] = lo;
6674
+ let hi = Number((value >> BigInt(32)) & mask32bits);
6675
+ destination[offset + 4] = hi;
6676
+ hi >>= 8;
6677
+ destination[offset + 5] = hi;
6678
+ hi >>= 8;
6679
+ destination[offset + 6] = hi;
6680
+ hi >>= 8;
6681
+ destination[offset + 7] = hi;
6682
+ return 8;
6683
+ },
6684
+ setFloat64LE: isBigEndian
6685
+ ? (destination, offset, value) => {
6686
+ FLOAT[0] = value;
6687
+ destination[offset] = FLOAT_BYTES[7];
6688
+ destination[offset + 1] = FLOAT_BYTES[6];
6689
+ destination[offset + 2] = FLOAT_BYTES[5];
6690
+ destination[offset + 3] = FLOAT_BYTES[4];
6691
+ destination[offset + 4] = FLOAT_BYTES[3];
6692
+ destination[offset + 5] = FLOAT_BYTES[2];
6693
+ destination[offset + 6] = FLOAT_BYTES[1];
6694
+ destination[offset + 7] = FLOAT_BYTES[0];
6695
+ return 8;
6696
+ }
6697
+ : (destination, offset, value) => {
6698
+ FLOAT[0] = value;
6699
+ destination[offset] = FLOAT_BYTES[0];
6700
+ destination[offset + 1] = FLOAT_BYTES[1];
6701
+ destination[offset + 2] = FLOAT_BYTES[2];
6702
+ destination[offset + 3] = FLOAT_BYTES[3];
6703
+ destination[offset + 4] = FLOAT_BYTES[4];
6704
+ destination[offset + 5] = FLOAT_BYTES[5];
6705
+ destination[offset + 6] = FLOAT_BYTES[6];
6706
+ destination[offset + 7] = FLOAT_BYTES[7];
6707
+ return 8;
6708
+ }
6709
+ };
6710
+
6534
6711
  class Binary extends BSONValue {
6535
6712
  get _bsontype() {
6536
6713
  return 'Binary';
@@ -6603,7 +6780,8 @@ class Binary extends BSONValue {
6603
6780
  }
6604
6781
  read(position, length) {
6605
6782
  length = length && length > 0 ? length : this.position;
6606
- return this.buffer.slice(position, position + length);
6783
+ const end = position + length;
6784
+ return this.buffer.subarray(position, end > this.position ? this.position : end);
6607
6785
  }
6608
6786
  value() {
6609
6787
  return this.buffer.length === this.position
@@ -6627,6 +6805,9 @@ class Binary extends BSONValue {
6627
6805
  }
6628
6806
  toExtendedJSON(options) {
6629
6807
  options = options || {};
6808
+ if (this.sub_type === Binary.SUBTYPE_VECTOR) {
6809
+ validateBinaryVector(this);
6810
+ }
6630
6811
  const base64String = ByteUtils.toBase64(this.buffer);
6631
6812
  const subType = Number(this.sub_type).toString(16);
6632
6813
  if (options.legacy) {
@@ -6644,7 +6825,7 @@ class Binary extends BSONValue {
6644
6825
  }
6645
6826
  toUUID() {
6646
6827
  if (this.sub_type === Binary.SUBTYPE_UUID) {
6647
- return new UUID(this.buffer.slice(0, this.position));
6828
+ return new UUID(this.buffer.subarray(0, this.position));
6648
6829
  }
6649
6830
  throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Binary.SUBTYPE_UUID}" is currently supported.`);
6650
6831
  }
@@ -6686,6 +6867,99 @@ class Binary extends BSONValue {
6686
6867
  const subTypeArg = inspect(this.sub_type, options);
6687
6868
  return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`;
6688
6869
  }
6870
+ toInt8Array() {
6871
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
6872
+ throw new BSONError('Binary sub_type is not Vector');
6873
+ }
6874
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.Int8) {
6875
+ throw new BSONError('Binary datatype field is not Int8');
6876
+ }
6877
+ return new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
6878
+ }
6879
+ toFloat32Array() {
6880
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
6881
+ throw new BSONError('Binary sub_type is not Vector');
6882
+ }
6883
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.Float32) {
6884
+ throw new BSONError('Binary datatype field is not Float32');
6885
+ }
6886
+ const floatBytes = new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
6887
+ if (NumberUtils.isBigEndian)
6888
+ ByteUtils.swap32(floatBytes);
6889
+ return new Float32Array(floatBytes.buffer);
6890
+ }
6891
+ toPackedBits() {
6892
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
6893
+ throw new BSONError('Binary sub_type is not Vector');
6894
+ }
6895
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
6896
+ throw new BSONError('Binary datatype field is not packed bit');
6897
+ }
6898
+ return new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
6899
+ }
6900
+ toBits() {
6901
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
6902
+ throw new BSONError('Binary sub_type is not Vector');
6903
+ }
6904
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
6905
+ throw new BSONError('Binary datatype field is not packed bit');
6906
+ }
6907
+ const byteCount = this.length() - 2;
6908
+ const bitCount = byteCount * 8 - this.buffer[1];
6909
+ const bits = new Int8Array(bitCount);
6910
+ for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
6911
+ const byteOffset = (bitOffset / 8) | 0;
6912
+ const byte = this.buffer[byteOffset + 2];
6913
+ const shift = 7 - (bitOffset % 8);
6914
+ const bit = (byte >> shift) & 1;
6915
+ bits[bitOffset] = bit;
6916
+ }
6917
+ return bits;
6918
+ }
6919
+ static fromInt8Array(array) {
6920
+ const buffer = ByteUtils.allocate(array.byteLength + 2);
6921
+ buffer[0] = Binary.VECTOR_TYPE.Int8;
6922
+ buffer[1] = 0;
6923
+ const intBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
6924
+ buffer.set(intBytes, 2);
6925
+ return new this(buffer, this.SUBTYPE_VECTOR);
6926
+ }
6927
+ static fromFloat32Array(array) {
6928
+ const binaryBytes = ByteUtils.allocate(array.byteLength + 2);
6929
+ binaryBytes[0] = Binary.VECTOR_TYPE.Float32;
6930
+ binaryBytes[1] = 0;
6931
+ const floatBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
6932
+ binaryBytes.set(floatBytes, 2);
6933
+ if (NumberUtils.isBigEndian)
6934
+ ByteUtils.swap32(new Uint8Array(binaryBytes.buffer, 2));
6935
+ return new this(binaryBytes, this.SUBTYPE_VECTOR);
6936
+ }
6937
+ static fromPackedBits(array, padding = 0) {
6938
+ const buffer = ByteUtils.allocate(array.byteLength + 2);
6939
+ buffer[0] = Binary.VECTOR_TYPE.PackedBit;
6940
+ buffer[1] = padding;
6941
+ buffer.set(array, 2);
6942
+ return new this(buffer, this.SUBTYPE_VECTOR);
6943
+ }
6944
+ static fromBits(bits) {
6945
+ const byteLength = (bits.length + 7) >>> 3;
6946
+ const bytes = new Uint8Array(byteLength + 2);
6947
+ bytes[0] = Binary.VECTOR_TYPE.PackedBit;
6948
+ const remainder = bits.length % 8;
6949
+ bytes[1] = remainder === 0 ? 0 : 8 - remainder;
6950
+ for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
6951
+ const byteOffset = bitOffset >>> 3;
6952
+ const bit = bits[bitOffset];
6953
+ if (bit !== 0 && bit !== 1) {
6954
+ throw new BSONError(`Invalid bit value at ${bitOffset}: must be 0 or 1, found ${bits[bitOffset]}`);
6955
+ }
6956
+ if (bit === 0)
6957
+ continue;
6958
+ const shift = 7 - (bitOffset % 8);
6959
+ bytes[byteOffset + 2] |= bit << shift;
6960
+ }
6961
+ return new this(bytes, Binary.SUBTYPE_VECTOR);
6962
+ }
6689
6963
  }
6690
6964
  Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0;
6691
6965
  Binary.BUFFER_SIZE = 256;
@@ -6698,7 +6972,30 @@ Binary.SUBTYPE_MD5 = 5;
6698
6972
  Binary.SUBTYPE_ENCRYPTED = 6;
6699
6973
  Binary.SUBTYPE_COLUMN = 7;
6700
6974
  Binary.SUBTYPE_SENSITIVE = 8;
6975
+ Binary.SUBTYPE_VECTOR = 9;
6701
6976
  Binary.SUBTYPE_USER_DEFINED = 128;
6977
+ Binary.VECTOR_TYPE = Object.freeze({
6978
+ Int8: 0x03,
6979
+ Float32: 0x27,
6980
+ PackedBit: 0x10
6981
+ });
6982
+ function validateBinaryVector(vector) {
6983
+ if (vector.sub_type !== Binary.SUBTYPE_VECTOR)
6984
+ return;
6985
+ const size = vector.position;
6986
+ const datatype = vector.buffer[0];
6987
+ const padding = vector.buffer[1];
6988
+ if ((datatype === Binary.VECTOR_TYPE.Float32 || datatype === Binary.VECTOR_TYPE.Int8) &&
6989
+ padding !== 0) {
6990
+ throw new BSONError('Invalid Vector: padding must be zero for int8 and float32 vectors');
6991
+ }
6992
+ if (datatype === Binary.VECTOR_TYPE.PackedBit && padding !== 0 && size === 2) {
6993
+ throw new BSONError('Invalid Vector: padding must be zero for packed bit vectors that are empty');
6994
+ }
6995
+ if (datatype === Binary.VECTOR_TYPE.PackedBit && padding > 7) {
6996
+ throw new BSONError(`Invalid Vector: padding must be a value between 0 and 7. found: ${padding}`);
6997
+ }
6998
+ }
6702
6999
  const UUID_BYTE_LENGTH = 16;
6703
7000
  const UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
6704
7001
  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;
@@ -6967,19 +7264,18 @@ class Long extends BSONValue {
6967
7264
  get __isLong__() {
6968
7265
  return true;
6969
7266
  }
6970
- constructor(low = 0, high, unsigned) {
7267
+ constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
6971
7268
  super();
6972
- if (typeof low === 'bigint') {
6973
- Object.assign(this, Long.fromBigInt(low, !!high));
6974
- }
6975
- else if (typeof low === 'string') {
6976
- Object.assign(this, Long.fromString(low, !!high));
6977
- }
6978
- else {
6979
- this.low = low | 0;
6980
- this.high = high | 0;
6981
- this.unsigned = !!unsigned;
6982
- }
7269
+ const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
7270
+ const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
7271
+ const res = typeof lowOrValue === 'string'
7272
+ ? Long.fromString(lowOrValue, unsignedBool)
7273
+ : typeof lowOrValue === 'bigint'
7274
+ ? Long.fromBigInt(lowOrValue, unsignedBool)
7275
+ : { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
7276
+ this.low = res.low;
7277
+ this.high = res.high;
7278
+ this.unsigned = res.unsigned;
6983
7279
  }
6984
7280
  static fromBits(lowBits, highBits, unsigned) {
6985
7281
  return new Long(lowBits, highBits, unsigned);
@@ -7031,7 +7327,9 @@ class Long extends BSONValue {
7031
7327
  return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
7032
7328
  }
7033
7329
  static fromBigInt(value, unsigned) {
7034
- return Long.fromString(value.toString(), unsigned);
7330
+ const FROM_BIGINT_BIT_MASK = BigInt(0xffffffff);
7331
+ const FROM_BIGINT_BIT_SHIFT = BigInt(32);
7332
+ return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
7035
7333
  }
7036
7334
  static _fromString(str, unsigned, radix) {
7037
7335
  if (str.length === 0)
@@ -7699,7 +7997,7 @@ class Decimal128 extends BSONValue {
7699
7997
  if (typeof bytes === 'string') {
7700
7998
  this.bytes = Decimal128.fromString(bytes).bytes;
7701
7999
  }
7702
- else if (isUint8Array(bytes)) {
8000
+ else if (bytes instanceof Uint8Array || isUint8Array(bytes)) {
7703
8001
  if (bytes.byteLength !== 16) {
7704
8002
  throw new BSONError('Decimal128 must take a Buffer of 16 bytes');
7705
8003
  }
@@ -8309,135 +8607,8 @@ class MinKey extends BSONValue {
8309
8607
  }
8310
8608
  }
8311
8609
 
8312
- const FLOAT = new Float64Array(1);
8313
- const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
8314
- FLOAT[0] = -1;
8315
- const isBigEndian = FLOAT_BYTES[7] === 0;
8316
- const NumberUtils = {
8317
- getNonnegativeInt32LE(source, offset) {
8318
- if (source[offset + 3] > 127) {
8319
- throw new RangeError(`Size cannot be negative at offset: ${offset}`);
8320
- }
8321
- return (source[offset] |
8322
- (source[offset + 1] << 8) |
8323
- (source[offset + 2] << 16) |
8324
- (source[offset + 3] << 24));
8325
- },
8326
- getInt32LE(source, offset) {
8327
- return (source[offset] |
8328
- (source[offset + 1] << 8) |
8329
- (source[offset + 2] << 16) |
8330
- (source[offset + 3] << 24));
8331
- },
8332
- getUint32LE(source, offset) {
8333
- return (source[offset] +
8334
- source[offset + 1] * 256 +
8335
- source[offset + 2] * 65536 +
8336
- source[offset + 3] * 16777216);
8337
- },
8338
- getUint32BE(source, offset) {
8339
- return (source[offset + 3] +
8340
- source[offset + 2] * 256 +
8341
- source[offset + 1] * 65536 +
8342
- source[offset] * 16777216);
8343
- },
8344
- getBigInt64LE(source, offset) {
8345
- const lo = NumberUtils.getUint32LE(source, offset);
8346
- const hi = NumberUtils.getUint32LE(source, offset + 4);
8347
- return (BigInt(hi) << BigInt(32)) + BigInt(lo);
8348
- },
8349
- getFloat64LE: isBigEndian
8350
- ? (source, offset) => {
8351
- FLOAT_BYTES[7] = source[offset];
8352
- FLOAT_BYTES[6] = source[offset + 1];
8353
- FLOAT_BYTES[5] = source[offset + 2];
8354
- FLOAT_BYTES[4] = source[offset + 3];
8355
- FLOAT_BYTES[3] = source[offset + 4];
8356
- FLOAT_BYTES[2] = source[offset + 5];
8357
- FLOAT_BYTES[1] = source[offset + 6];
8358
- FLOAT_BYTES[0] = source[offset + 7];
8359
- return FLOAT[0];
8360
- }
8361
- : (source, offset) => {
8362
- FLOAT_BYTES[0] = source[offset];
8363
- FLOAT_BYTES[1] = source[offset + 1];
8364
- FLOAT_BYTES[2] = source[offset + 2];
8365
- FLOAT_BYTES[3] = source[offset + 3];
8366
- FLOAT_BYTES[4] = source[offset + 4];
8367
- FLOAT_BYTES[5] = source[offset + 5];
8368
- FLOAT_BYTES[6] = source[offset + 6];
8369
- FLOAT_BYTES[7] = source[offset + 7];
8370
- return FLOAT[0];
8371
- },
8372
- setInt32BE(destination, offset, value) {
8373
- destination[offset + 3] = value;
8374
- value >>>= 8;
8375
- destination[offset + 2] = value;
8376
- value >>>= 8;
8377
- destination[offset + 1] = value;
8378
- value >>>= 8;
8379
- destination[offset] = value;
8380
- return 4;
8381
- },
8382
- setInt32LE(destination, offset, value) {
8383
- destination[offset] = value;
8384
- value >>>= 8;
8385
- destination[offset + 1] = value;
8386
- value >>>= 8;
8387
- destination[offset + 2] = value;
8388
- value >>>= 8;
8389
- destination[offset + 3] = value;
8390
- return 4;
8391
- },
8392
- setBigInt64LE(destination, offset, value) {
8393
- const mask32bits = BigInt(4294967295);
8394
- let lo = Number(value & mask32bits);
8395
- destination[offset] = lo;
8396
- lo >>= 8;
8397
- destination[offset + 1] = lo;
8398
- lo >>= 8;
8399
- destination[offset + 2] = lo;
8400
- lo >>= 8;
8401
- destination[offset + 3] = lo;
8402
- let hi = Number((value >> BigInt(32)) & mask32bits);
8403
- destination[offset + 4] = hi;
8404
- hi >>= 8;
8405
- destination[offset + 5] = hi;
8406
- hi >>= 8;
8407
- destination[offset + 6] = hi;
8408
- hi >>= 8;
8409
- destination[offset + 7] = hi;
8410
- return 8;
8411
- },
8412
- setFloat64LE: isBigEndian
8413
- ? (destination, offset, value) => {
8414
- FLOAT[0] = value;
8415
- destination[offset] = FLOAT_BYTES[7];
8416
- destination[offset + 1] = FLOAT_BYTES[6];
8417
- destination[offset + 2] = FLOAT_BYTES[5];
8418
- destination[offset + 3] = FLOAT_BYTES[4];
8419
- destination[offset + 4] = FLOAT_BYTES[3];
8420
- destination[offset + 5] = FLOAT_BYTES[2];
8421
- destination[offset + 6] = FLOAT_BYTES[1];
8422
- destination[offset + 7] = FLOAT_BYTES[0];
8423
- return 8;
8424
- }
8425
- : (destination, offset, value) => {
8426
- FLOAT[0] = value;
8427
- destination[offset] = FLOAT_BYTES[0];
8428
- destination[offset + 1] = FLOAT_BYTES[1];
8429
- destination[offset + 2] = FLOAT_BYTES[2];
8430
- destination[offset + 3] = FLOAT_BYTES[3];
8431
- destination[offset + 4] = FLOAT_BYTES[4];
8432
- destination[offset + 5] = FLOAT_BYTES[5];
8433
- destination[offset + 6] = FLOAT_BYTES[6];
8434
- destination[offset + 7] = FLOAT_BYTES[7];
8435
- return 8;
8436
- }
8437
- };
8438
-
8439
- const checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
8440
8610
  let PROCESS_UNIQUE = null;
8611
+ const __idCache = new WeakMap();
8441
8612
  class ObjectId extends BSONValue {
8442
8613
  get _bsontype() {
8443
8614
  return 'ObjectId';
@@ -8466,8 +8637,11 @@ class ObjectId extends BSONValue {
8466
8637
  this.buffer = ByteUtils.toLocalBufferType(workingId);
8467
8638
  }
8468
8639
  else if (typeof workingId === 'string') {
8469
- if (workingId.length === 24 && checkForHexRegExp.test(workingId)) {
8640
+ if (ObjectId.validateHexString(workingId)) {
8470
8641
  this.buffer = ByteUtils.fromHex(workingId);
8642
+ if (ObjectId.cacheHexString) {
8643
+ __idCache.set(this, workingId);
8644
+ }
8471
8645
  }
8472
8646
  else {
8473
8647
  throw new BSONError('input must be a 24 character hex string, 12 byte Uint8Array, or an integer');
@@ -8476,9 +8650,6 @@ class ObjectId extends BSONValue {
8476
8650
  else {
8477
8651
  throw new BSONError('Argument passed in does not match the accepted types');
8478
8652
  }
8479
- if (ObjectId.cacheHexString) {
8480
- this.__id = ByteUtils.toHex(this.id);
8481
- }
8482
8653
  }
8483
8654
  get id() {
8484
8655
  return this.buffer;
@@ -8486,16 +8657,32 @@ class ObjectId extends BSONValue {
8486
8657
  set id(value) {
8487
8658
  this.buffer = value;
8488
8659
  if (ObjectId.cacheHexString) {
8489
- this.__id = ByteUtils.toHex(value);
8660
+ __idCache.set(this, ByteUtils.toHex(value));
8490
8661
  }
8491
8662
  }
8663
+ static validateHexString(string) {
8664
+ if (string?.length !== 24)
8665
+ return false;
8666
+ for (let i = 0; i < 24; i++) {
8667
+ const char = string.charCodeAt(i);
8668
+ if ((char >= 48 && char <= 57) ||
8669
+ (char >= 97 && char <= 102) ||
8670
+ (char >= 65 && char <= 70)) {
8671
+ continue;
8672
+ }
8673
+ return false;
8674
+ }
8675
+ return true;
8676
+ }
8492
8677
  toHexString() {
8493
- if (ObjectId.cacheHexString && this.__id) {
8494
- return this.__id;
8678
+ if (ObjectId.cacheHexString) {
8679
+ const __id = __idCache.get(this);
8680
+ if (__id)
8681
+ return __id;
8495
8682
  }
8496
8683
  const hexString = ByteUtils.toHex(this.id);
8497
- if (ObjectId.cacheHexString && !this.__id) {
8498
- this.__id = hexString;
8684
+ if (ObjectId.cacheHexString) {
8685
+ __idCache.set(this, hexString);
8499
8686
  }
8500
8687
  return hexString;
8501
8688
  }
@@ -8601,6 +8788,8 @@ class ObjectId extends BSONValue {
8601
8788
  static isValid(id) {
8602
8789
  if (id == null)
8603
8790
  return false;
8791
+ if (typeof id === 'string')
8792
+ return ObjectId.validateHexString(id);
8604
8793
  try {
8605
8794
  new ObjectId(id);
8606
8795
  return true;
@@ -8617,6 +8806,9 @@ class ObjectId extends BSONValue {
8617
8806
  static fromExtendedJSON(doc) {
8618
8807
  return new ObjectId(doc.$oid);
8619
8808
  }
8809
+ isCached() {
8810
+ return ObjectId.cacheHexString && __idCache.has(this);
8811
+ }
8620
8812
  inspect(depth, options, inspect) {
8621
8813
  inspect ??= defaultInspect;
8622
8814
  return `new ObjectId(${inspect(this.toHexString(), options)})`;
@@ -8671,7 +8863,7 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
8671
8863
  case 'object':
8672
8864
  if (value != null &&
8673
8865
  typeof value._bsontype === 'string' &&
8674
- value[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION) {
8866
+ value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
8675
8867
  throw new BSONVersionError();
8676
8868
  }
8677
8869
  else if (value == null || value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
@@ -8875,6 +9067,12 @@ class Timestamp extends LongWithoutOverridesClass {
8875
9067
  get _bsontype() {
8876
9068
  return 'Timestamp';
8877
9069
  }
9070
+ get i() {
9071
+ return this.low >>> 0;
9072
+ }
9073
+ get t() {
9074
+ return this.high >>> 0;
9075
+ }
8878
9076
  constructor(low) {
8879
9077
  if (low == null) {
8880
9078
  super(0, 0, true);
@@ -8900,10 +9098,10 @@ class Timestamp extends LongWithoutOverridesClass {
8900
9098
  if (i < 0 || Number.isNaN(i)) {
8901
9099
  throw new BSONError('Timestamp constructed from { t, i } must provide a positive i');
8902
9100
  }
8903
- if (t > 4294967295) {
9101
+ if (t > 0xffff_ffff) {
8904
9102
  throw new BSONError('Timestamp constructed from { t, i } must provide t equal or less than uint32 max');
8905
9103
  }
8906
- if (i > 4294967295) {
9104
+ if (i > 0xffff_ffff) {
8907
9105
  throw new BSONError('Timestamp constructed from { t, i } must provide i equal or less than uint32 max');
8908
9106
  }
8909
9107
  super(i, t, true);
@@ -8930,7 +9128,7 @@ class Timestamp extends LongWithoutOverridesClass {
8930
9128
  return new Timestamp(Long.fromString(str, true, optRadix));
8931
9129
  }
8932
9130
  toExtendedJSON() {
8933
- return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } };
9131
+ return { $timestamp: { t: this.t, i: this.i } };
8934
9132
  }
8935
9133
  static fromExtendedJSON(doc) {
8936
9134
  const i = Long.isLong(doc.$timestamp.i)
@@ -8943,8 +9141,8 @@ class Timestamp extends LongWithoutOverridesClass {
8943
9141
  }
8944
9142
  inspect(depth, options, inspect) {
8945
9143
  inspect ??= defaultInspect;
8946
- const t = inspect(this.high >>> 0, options);
8947
- const i = inspect(this.low >>> 0, options);
9144
+ const t = inspect(this.t, options);
9145
+ const i = inspect(this.i, options);
8948
9146
  return `new Timestamp({ t: ${t}, i: ${i} })`;
8949
9147
  }
8950
9148
  }
@@ -9101,7 +9299,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
9101
9299
  if (objectSize <= 0 || objectSize > buffer.length - index)
9102
9300
  throw new BSONError('bad embedded document length in bson');
9103
9301
  if (raw) {
9104
- value = buffer.slice(index, index + objectSize);
9302
+ value = buffer.subarray(index, index + objectSize);
9105
9303
  }
9106
9304
  else {
9107
9305
  let objectOptions = options;
@@ -9173,49 +9371,23 @@ function deserializeObject(buffer, index, options, isArray = false) {
9173
9371
  throw new BSONError('Negative binary type element size found');
9174
9372
  if (binarySize > buffer.byteLength)
9175
9373
  throw new BSONError('Binary type size larger than document size');
9176
- if (buffer['slice'] != null) {
9177
- if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
9178
- binarySize = NumberUtils.getInt32LE(buffer, index);
9179
- index += 4;
9180
- if (binarySize < 0)
9181
- throw new BSONError('Negative binary type element size found for subtype 0x02');
9182
- if (binarySize > totalBinarySize - 4)
9183
- throw new BSONError('Binary type with subtype 0x02 contains too long binary size');
9184
- if (binarySize < totalBinarySize - 4)
9185
- throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
9186
- }
9187
- if (promoteBuffers && promoteValues) {
9188
- value = ByteUtils.toLocalBufferType(buffer.slice(index, index + binarySize));
9189
- }
9190
- else {
9191
- value = new Binary(buffer.slice(index, index + binarySize), subType);
9192
- if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
9193
- value = value.toUUID();
9194
- }
9195
- }
9374
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
9375
+ binarySize = NumberUtils.getInt32LE(buffer, index);
9376
+ index += 4;
9377
+ if (binarySize < 0)
9378
+ throw new BSONError('Negative binary type element size found for subtype 0x02');
9379
+ if (binarySize > totalBinarySize - 4)
9380
+ throw new BSONError('Binary type with subtype 0x02 contains too long binary size');
9381
+ if (binarySize < totalBinarySize - 4)
9382
+ throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
9383
+ }
9384
+ if (promoteBuffers && promoteValues) {
9385
+ value = ByteUtils.toLocalBufferType(buffer.subarray(index, index + binarySize));
9196
9386
  }
9197
9387
  else {
9198
- if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
9199
- binarySize = NumberUtils.getInt32LE(buffer, index);
9200
- index += 4;
9201
- if (binarySize < 0)
9202
- throw new BSONError('Negative binary type element size found for subtype 0x02');
9203
- if (binarySize > totalBinarySize - 4)
9204
- throw new BSONError('Binary type with subtype 0x02 contains too long binary size');
9205
- if (binarySize < totalBinarySize - 4)
9206
- throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
9207
- }
9208
- if (promoteBuffers && promoteValues) {
9209
- value = ByteUtils.allocateUnsafe(binarySize);
9210
- for (i = 0; i < binarySize; i++) {
9211
- value[i] = buffer[index + i];
9212
- }
9213
- }
9214
- else {
9215
- value = new Binary(buffer.slice(index, index + binarySize), subType);
9216
- if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
9217
- value = value.toUUID();
9218
- }
9388
+ value = new Binary(buffer.subarray(index, index + binarySize), subType);
9389
+ if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
9390
+ value = value.toUUID();
9219
9391
  }
9220
9392
  }
9221
9393
  index = index + binarySize;
@@ -9637,6 +9809,9 @@ function serializeBinary(buffer, key, value, index) {
9637
9809
  size = size - 4;
9638
9810
  index += NumberUtils.setInt32LE(buffer, index, size);
9639
9811
  }
9812
+ if (value.sub_type === Binary.SUBTYPE_VECTOR) {
9813
+ validateBinaryVector(value);
9814
+ }
9640
9815
  if (size <= 16) {
9641
9816
  for (let i = 0; i < size; i++)
9642
9817
  buffer[index + i] = data[i];
@@ -9713,79 +9888,83 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
9713
9888
  if (typeof value?.toBSON === 'function') {
9714
9889
  value = value.toBSON();
9715
9890
  }
9716
- if (typeof value === 'string') {
9717
- index = serializeString(buffer, key, value, index);
9718
- }
9719
- else if (typeof value === 'number') {
9720
- index = serializeNumber(buffer, key, value, index);
9721
- }
9722
- else if (typeof value === 'bigint') {
9723
- index = serializeBigInt(buffer, key, value, index);
9724
- }
9725
- else if (typeof value === 'boolean') {
9726
- index = serializeBoolean(buffer, key, value, index);
9727
- }
9728
- else if (value instanceof Date || isDate(value)) {
9729
- index = serializeDate(buffer, key, value, index);
9730
- }
9731
- else if (value === undefined) {
9891
+ const type = typeof value;
9892
+ if (value === undefined) {
9732
9893
  index = serializeNull(buffer, key, value, index);
9733
9894
  }
9734
9895
  else if (value === null) {
9735
9896
  index = serializeNull(buffer, key, value, index);
9736
9897
  }
9737
- else if (isUint8Array(value)) {
9738
- index = serializeBuffer(buffer, key, value, index);
9739
- }
9740
- else if (value instanceof RegExp || isRegExp(value)) {
9741
- index = serializeRegExp(buffer, key, value, index);
9742
- }
9743
- else if (typeof value === 'object' && value._bsontype == null) {
9744
- index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9898
+ else if (type === 'string') {
9899
+ index = serializeString(buffer, key, value, index);
9745
9900
  }
9746
- else if (typeof value === 'object' &&
9747
- value[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION) {
9748
- throw new BSONVersionError();
9901
+ else if (type === 'number') {
9902
+ index = serializeNumber(buffer, key, value, index);
9749
9903
  }
9750
- else if (value._bsontype === 'ObjectId') {
9751
- index = serializeObjectId(buffer, key, value, index);
9904
+ else if (type === 'bigint') {
9905
+ index = serializeBigInt(buffer, key, value, index);
9752
9906
  }
9753
- else if (value._bsontype === 'Decimal128') {
9754
- index = serializeDecimal128(buffer, key, value, index);
9907
+ else if (type === 'boolean') {
9908
+ index = serializeBoolean(buffer, key, value, index);
9755
9909
  }
9756
- else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
9757
- index = serializeLong(buffer, key, value, index);
9910
+ else if (type === 'object' && value._bsontype == null) {
9911
+ if (value instanceof Date || isDate(value)) {
9912
+ index = serializeDate(buffer, key, value, index);
9913
+ }
9914
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
9915
+ index = serializeBuffer(buffer, key, value, index);
9916
+ }
9917
+ else if (value instanceof RegExp || isRegExp(value)) {
9918
+ index = serializeRegExp(buffer, key, value, index);
9919
+ }
9920
+ else {
9921
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9922
+ }
9758
9923
  }
9759
- else if (value._bsontype === 'Double') {
9760
- index = serializeDouble(buffer, key, value, index);
9924
+ else if (type === 'object') {
9925
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
9926
+ throw new BSONVersionError();
9927
+ }
9928
+ else if (value._bsontype === 'ObjectId') {
9929
+ index = serializeObjectId(buffer, key, value, index);
9930
+ }
9931
+ else if (value._bsontype === 'Decimal128') {
9932
+ index = serializeDecimal128(buffer, key, value, index);
9933
+ }
9934
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
9935
+ index = serializeLong(buffer, key, value, index);
9936
+ }
9937
+ else if (value._bsontype === 'Double') {
9938
+ index = serializeDouble(buffer, key, value, index);
9939
+ }
9940
+ else if (value._bsontype === 'Code') {
9941
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9942
+ }
9943
+ else if (value._bsontype === 'Binary') {
9944
+ index = serializeBinary(buffer, key, value, index);
9945
+ }
9946
+ else if (value._bsontype === 'BSONSymbol') {
9947
+ index = serializeSymbol(buffer, key, value, index);
9948
+ }
9949
+ else if (value._bsontype === 'DBRef') {
9950
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
9951
+ }
9952
+ else if (value._bsontype === 'BSONRegExp') {
9953
+ index = serializeBSONRegExp(buffer, key, value, index);
9954
+ }
9955
+ else if (value._bsontype === 'Int32') {
9956
+ index = serializeInt32(buffer, key, value, index);
9957
+ }
9958
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
9959
+ index = serializeMinMax(buffer, key, value, index);
9960
+ }
9961
+ else if (typeof value._bsontype !== 'undefined') {
9962
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
9963
+ }
9761
9964
  }
9762
- else if (typeof value === 'function' && serializeFunctions) {
9965
+ else if (type === 'function' && serializeFunctions) {
9763
9966
  index = serializeFunction(buffer, key, value, index);
9764
9967
  }
9765
- else if (value._bsontype === 'Code') {
9766
- index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9767
- }
9768
- else if (value._bsontype === 'Binary') {
9769
- index = serializeBinary(buffer, key, value, index);
9770
- }
9771
- else if (value._bsontype === 'BSONSymbol') {
9772
- index = serializeSymbol(buffer, key, value, index);
9773
- }
9774
- else if (value._bsontype === 'DBRef') {
9775
- index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
9776
- }
9777
- else if (value._bsontype === 'BSONRegExp') {
9778
- index = serializeBSONRegExp(buffer, key, value, index);
9779
- }
9780
- else if (value._bsontype === 'Int32') {
9781
- index = serializeInt32(buffer, key, value, index);
9782
- }
9783
- else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
9784
- index = serializeMinMax(buffer, key, value, index);
9785
- }
9786
- else if (typeof value._bsontype !== 'undefined') {
9787
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
9788
- }
9789
9968
  }
9790
9969
  }
9791
9970
  else if (object instanceof Map || isMap(object)) {
@@ -9815,7 +9994,14 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
9815
9994
  }
9816
9995
  }
9817
9996
  }
9818
- if (type === 'string') {
9997
+ if (value === undefined) {
9998
+ if (ignoreUndefined === false)
9999
+ index = serializeNull(buffer, key, value, index);
10000
+ }
10001
+ else if (value === null) {
10002
+ index = serializeNull(buffer, key, value, index);
10003
+ }
10004
+ else if (type === 'string') {
9819
10005
  index = serializeString(buffer, key, value, index);
9820
10006
  }
9821
10007
  else if (type === 'number') {
@@ -9827,64 +10013,64 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
9827
10013
  else if (type === 'boolean') {
9828
10014
  index = serializeBoolean(buffer, key, value, index);
9829
10015
  }
9830
- else if (value instanceof Date || isDate(value)) {
9831
- index = serializeDate(buffer, key, value, index);
9832
- }
9833
- else if (value === null || (value === undefined && ignoreUndefined === false)) {
9834
- index = serializeNull(buffer, key, value, index);
9835
- }
9836
- else if (isUint8Array(value)) {
9837
- index = serializeBuffer(buffer, key, value, index);
9838
- }
9839
- else if (value instanceof RegExp || isRegExp(value)) {
9840
- index = serializeRegExp(buffer, key, value, index);
9841
- }
9842
10016
  else if (type === 'object' && value._bsontype == null) {
9843
- index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9844
- }
9845
- else if (typeof value === 'object' &&
9846
- value[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION) {
9847
- throw new BSONVersionError();
9848
- }
9849
- else if (value._bsontype === 'ObjectId') {
9850
- index = serializeObjectId(buffer, key, value, index);
9851
- }
9852
- else if (type === 'object' && value._bsontype === 'Decimal128') {
9853
- index = serializeDecimal128(buffer, key, value, index);
9854
- }
9855
- else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
9856
- index = serializeLong(buffer, key, value, index);
9857
- }
9858
- else if (value._bsontype === 'Double') {
9859
- index = serializeDouble(buffer, key, value, index);
10017
+ if (value instanceof Date || isDate(value)) {
10018
+ index = serializeDate(buffer, key, value, index);
10019
+ }
10020
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
10021
+ index = serializeBuffer(buffer, key, value, index);
10022
+ }
10023
+ else if (value instanceof RegExp || isRegExp(value)) {
10024
+ index = serializeRegExp(buffer, key, value, index);
10025
+ }
10026
+ else {
10027
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10028
+ }
9860
10029
  }
9861
- else if (value._bsontype === 'Code') {
9862
- index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10030
+ else if (type === 'object') {
10031
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
10032
+ throw new BSONVersionError();
10033
+ }
10034
+ else if (value._bsontype === 'ObjectId') {
10035
+ index = serializeObjectId(buffer, key, value, index);
10036
+ }
10037
+ else if (value._bsontype === 'Decimal128') {
10038
+ index = serializeDecimal128(buffer, key, value, index);
10039
+ }
10040
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
10041
+ index = serializeLong(buffer, key, value, index);
10042
+ }
10043
+ else if (value._bsontype === 'Double') {
10044
+ index = serializeDouble(buffer, key, value, index);
10045
+ }
10046
+ else if (value._bsontype === 'Code') {
10047
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10048
+ }
10049
+ else if (value._bsontype === 'Binary') {
10050
+ index = serializeBinary(buffer, key, value, index);
10051
+ }
10052
+ else if (value._bsontype === 'BSONSymbol') {
10053
+ index = serializeSymbol(buffer, key, value, index);
10054
+ }
10055
+ else if (value._bsontype === 'DBRef') {
10056
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
10057
+ }
10058
+ else if (value._bsontype === 'BSONRegExp') {
10059
+ index = serializeBSONRegExp(buffer, key, value, index);
10060
+ }
10061
+ else if (value._bsontype === 'Int32') {
10062
+ index = serializeInt32(buffer, key, value, index);
10063
+ }
10064
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
10065
+ index = serializeMinMax(buffer, key, value, index);
10066
+ }
10067
+ else if (typeof value._bsontype !== 'undefined') {
10068
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
10069
+ }
9863
10070
  }
9864
- else if (typeof value === 'function' && serializeFunctions) {
10071
+ else if (type === 'function' && serializeFunctions) {
9865
10072
  index = serializeFunction(buffer, key, value, index);
9866
10073
  }
9867
- else if (value._bsontype === 'Binary') {
9868
- index = serializeBinary(buffer, key, value, index);
9869
- }
9870
- else if (value._bsontype === 'BSONSymbol') {
9871
- index = serializeSymbol(buffer, key, value, index);
9872
- }
9873
- else if (value._bsontype === 'DBRef') {
9874
- index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
9875
- }
9876
- else if (value._bsontype === 'BSONRegExp') {
9877
- index = serializeBSONRegExp(buffer, key, value, index);
9878
- }
9879
- else if (value._bsontype === 'Int32') {
9880
- index = serializeInt32(buffer, key, value, index);
9881
- }
9882
- else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
9883
- index = serializeMinMax(buffer, key, value, index);
9884
- }
9885
- else if (typeof value._bsontype !== 'undefined') {
9886
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
9887
- }
9888
10074
  }
9889
10075
  }
9890
10076
  else {
@@ -9913,7 +10099,14 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
9913
10099
  }
9914
10100
  }
9915
10101
  }
9916
- if (type === 'string') {
10102
+ if (value === undefined) {
10103
+ if (ignoreUndefined === false)
10104
+ index = serializeNull(buffer, key, value, index);
10105
+ }
10106
+ else if (value === null) {
10107
+ index = serializeNull(buffer, key, value, index);
10108
+ }
10109
+ else if (type === 'string') {
9917
10110
  index = serializeString(buffer, key, value, index);
9918
10111
  }
9919
10112
  else if (type === 'number') {
@@ -9925,68 +10118,64 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
9925
10118
  else if (type === 'boolean') {
9926
10119
  index = serializeBoolean(buffer, key, value, index);
9927
10120
  }
9928
- else if (value instanceof Date || isDate(value)) {
9929
- index = serializeDate(buffer, key, value, index);
9930
- }
9931
- else if (value === undefined) {
9932
- if (ignoreUndefined === false)
9933
- index = serializeNull(buffer, key, value, index);
9934
- }
9935
- else if (value === null) {
9936
- index = serializeNull(buffer, key, value, index);
9937
- }
9938
- else if (isUint8Array(value)) {
9939
- index = serializeBuffer(buffer, key, value, index);
9940
- }
9941
- else if (value instanceof RegExp || isRegExp(value)) {
9942
- index = serializeRegExp(buffer, key, value, index);
9943
- }
9944
10121
  else if (type === 'object' && value._bsontype == null) {
9945
- index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
9946
- }
9947
- else if (typeof value === 'object' &&
9948
- value[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION) {
9949
- throw new BSONVersionError();
9950
- }
9951
- else if (value._bsontype === 'ObjectId') {
9952
- index = serializeObjectId(buffer, key, value, index);
9953
- }
9954
- else if (type === 'object' && value._bsontype === 'Decimal128') {
9955
- index = serializeDecimal128(buffer, key, value, index);
9956
- }
9957
- else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
9958
- index = serializeLong(buffer, key, value, index);
9959
- }
9960
- else if (value._bsontype === 'Double') {
9961
- index = serializeDouble(buffer, key, value, index);
10122
+ if (value instanceof Date || isDate(value)) {
10123
+ index = serializeDate(buffer, key, value, index);
10124
+ }
10125
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
10126
+ index = serializeBuffer(buffer, key, value, index);
10127
+ }
10128
+ else if (value instanceof RegExp || isRegExp(value)) {
10129
+ index = serializeRegExp(buffer, key, value, index);
10130
+ }
10131
+ else {
10132
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10133
+ }
9962
10134
  }
9963
- else if (value._bsontype === 'Code') {
9964
- index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10135
+ else if (type === 'object') {
10136
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
10137
+ throw new BSONVersionError();
10138
+ }
10139
+ else if (value._bsontype === 'ObjectId') {
10140
+ index = serializeObjectId(buffer, key, value, index);
10141
+ }
10142
+ else if (value._bsontype === 'Decimal128') {
10143
+ index = serializeDecimal128(buffer, key, value, index);
10144
+ }
10145
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
10146
+ index = serializeLong(buffer, key, value, index);
10147
+ }
10148
+ else if (value._bsontype === 'Double') {
10149
+ index = serializeDouble(buffer, key, value, index);
10150
+ }
10151
+ else if (value._bsontype === 'Code') {
10152
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
10153
+ }
10154
+ else if (value._bsontype === 'Binary') {
10155
+ index = serializeBinary(buffer, key, value, index);
10156
+ }
10157
+ else if (value._bsontype === 'BSONSymbol') {
10158
+ index = serializeSymbol(buffer, key, value, index);
10159
+ }
10160
+ else if (value._bsontype === 'DBRef') {
10161
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
10162
+ }
10163
+ else if (value._bsontype === 'BSONRegExp') {
10164
+ index = serializeBSONRegExp(buffer, key, value, index);
10165
+ }
10166
+ else if (value._bsontype === 'Int32') {
10167
+ index = serializeInt32(buffer, key, value, index);
10168
+ }
10169
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
10170
+ index = serializeMinMax(buffer, key, value, index);
10171
+ }
10172
+ else if (typeof value._bsontype !== 'undefined') {
10173
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
10174
+ }
9965
10175
  }
9966
- else if (typeof value === 'function' && serializeFunctions) {
10176
+ else if (type === 'function' && serializeFunctions) {
9967
10177
  index = serializeFunction(buffer, key, value, index);
9968
10178
  }
9969
- else if (value._bsontype === 'Binary') {
9970
- index = serializeBinary(buffer, key, value, index);
9971
- }
9972
- else if (value._bsontype === 'BSONSymbol') {
9973
- index = serializeSymbol(buffer, key, value, index);
9974
- }
9975
- else if (value._bsontype === 'DBRef') {
9976
- index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
9977
- }
9978
- else if (value._bsontype === 'BSONRegExp') {
9979
- index = serializeBSONRegExp(buffer, key, value, index);
9980
- }
9981
- else if (value._bsontype === 'Int32') {
9982
- index = serializeInt32(buffer, key, value, index);
9983
- }
9984
- else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
9985
- index = serializeMinMax(buffer, key, value, index);
9986
- }
9987
- else if (typeof value._bsontype !== 'undefined') {
9988
- throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
9989
- }
9990
10179
  }
9991
10180
  }
9992
10181
  path.delete(object);
@@ -10238,7 +10427,7 @@ function serializeDocument(doc, options) {
10238
10427
  else if (doc != null &&
10239
10428
  typeof doc === 'object' &&
10240
10429
  typeof doc._bsontype === 'string' &&
10241
- doc[Symbol.for('@@mdb.bson.version')] !== BSON_MAJOR_VERSION) {
10430
+ doc[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
10242
10431
  throw new BSONVersionError();
10243
10432
  }
10244
10433
  else if (isBSONType(doc)) {
@@ -10571,7 +10760,7 @@ exports.setInternalBufferSize = setInternalBufferSize;
10571
10760
  /******/
10572
10761
  /************************************************************************/
10573
10762
  var __webpack_exports__ = {};
10574
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
10763
+ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
10575
10764
  (() => {
10576
10765
  "use strict";
10577
10766
  /*!*******************************!*\
@@ -10632,7 +10821,7 @@ app.component('app-component', {
10632
10821
  `,
10633
10822
  errorCaptured(err) {
10634
10823
  vanillatoasts.create({
10635
- title: `Error: ${err.message}`,
10824
+ title: `Error: ${err?.response?.data?.message || err.message}`,
10636
10825
  icon: 'images/failure.jpg',
10637
10826
  timeout: 10000,
10638
10827
  positionClass: 'bottomRight'