@mongoosejs/studio 0.5.8 → 0.5.9
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/backend/integrations/streamLLM.js +1 -1
- package/eslint.config.js +3 -1
- package/frontend/public/app.js +502 -465
- package/frontend/src/index.js +1 -1
- package/frontend/src/models/models.js +46 -10
- package/frontend/src/routes.js +2 -1
- package/package.json +1 -1
package/frontend/public/app.js
CHANGED
|
@@ -7928,7 +7928,7 @@ app.component('app-component', {
|
|
|
7928
7928
|
<div v-else-if="!hasAPIKey || user">
|
|
7929
7929
|
<navbar :user="user" :roles="roles" />
|
|
7930
7930
|
<div class="view">
|
|
7931
|
-
<router-view :key="$route.fullPath" :user="user" :roles="roles" :hasAPIKey="hasAPIKey" />
|
|
7931
|
+
<router-view :key="$route.meta.preserveStateKey || $route.fullPath" :user="user" :roles="roles" :hasAPIKey="hasAPIKey" />
|
|
7932
7932
|
</div>
|
|
7933
7933
|
</div>
|
|
7934
7934
|
</div>
|
|
@@ -9513,6 +9513,7 @@ module.exports = app => app.component('models', {
|
|
|
9513
9513
|
currentModel: null,
|
|
9514
9514
|
modelDocumentCounts: {},
|
|
9515
9515
|
documents: [],
|
|
9516
|
+
allSchemaPaths: null,
|
|
9516
9517
|
schemaPaths: [],
|
|
9517
9518
|
filteredPaths: [],
|
|
9518
9519
|
selectedPaths: [],
|
|
@@ -9630,8 +9631,9 @@ module.exports = app => app.component('models', {
|
|
|
9630
9631
|
this.query = Object.assign({}, this.$route.query);
|
|
9631
9632
|
// Keep UI mode in sync with the URL on remounts.
|
|
9632
9633
|
this.isProjectionMenuSelected = this.$route?.query?.[PROJECTION_MODE_QUERY_KEY] === '1';
|
|
9633
|
-
const { models, readyState } = await api.Model.listModels();
|
|
9634
|
+
const { models, modelSchemaPaths, readyState } = await api.Model.listModels();
|
|
9634
9635
|
this.models = models;
|
|
9636
|
+
this.allSchemaPaths = modelSchemaPaths;
|
|
9635
9637
|
await this.loadModelCounts();
|
|
9636
9638
|
if (this.currentModel == null && this.models.length > 0) {
|
|
9637
9639
|
this.currentModel = this.models[0];
|
|
@@ -9642,6 +9644,29 @@ module.exports = app => app.component('models', {
|
|
|
9642
9644
|
if (readyState === 0) {
|
|
9643
9645
|
this.error = 'No models found and Mongoose is not connected. Check our documentation for more information.';
|
|
9644
9646
|
}
|
|
9647
|
+
} else {
|
|
9648
|
+
this._refreshSidebar = setInterval(async() => {
|
|
9649
|
+
try {
|
|
9650
|
+
const { models, modelSchemaPaths, readyState } = await api.Model.listModels();
|
|
9651
|
+
this.models = models;
|
|
9652
|
+
this.allSchemaPaths = modelSchemaPaths;
|
|
9653
|
+
await this.loadModelCounts();
|
|
9654
|
+
if (this.currentModel) {
|
|
9655
|
+
const schemaPaths = this.allSchemaPaths?.[this.currentModel] ?? {};
|
|
9656
|
+
this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
|
|
9657
|
+
if (k1 === '_id' && k2 !== '_id') {
|
|
9658
|
+
return -1;
|
|
9659
|
+
}
|
|
9660
|
+
if (k1 !== '_id' && k2 === '_id') {
|
|
9661
|
+
return 1;
|
|
9662
|
+
}
|
|
9663
|
+
return 0;
|
|
9664
|
+
}).map(key => schemaPaths[key]);
|
|
9665
|
+
}
|
|
9666
|
+
} catch (e) {
|
|
9667
|
+
console.error(e);
|
|
9668
|
+
}
|
|
9669
|
+
}, 20000);
|
|
9645
9670
|
}
|
|
9646
9671
|
|
|
9647
9672
|
await this.initSearchFromUrl();
|
|
@@ -9652,25 +9677,33 @@ module.exports = app => app.component('models', {
|
|
|
9652
9677
|
this.$nextTick(() => {
|
|
9653
9678
|
const focusIntent = takeModelsRemountFocusIntent();
|
|
9654
9679
|
if (focusIntent === 'documentSearch') {
|
|
9655
|
-
|
|
9656
|
-
if (ds && typeof ds.focusInput === 'function') {
|
|
9657
|
-
ds.focusInput();
|
|
9658
|
-
}
|
|
9680
|
+
this.$refs.documentSearch?.focusInput();
|
|
9659
9681
|
return;
|
|
9660
9682
|
}
|
|
9661
9683
|
if (focusIntent === 'projection' && this.isProjectionMenuSelected) {
|
|
9662
|
-
|
|
9663
|
-
if (projectionSearch && typeof projectionSearch.focusInput === 'function') {
|
|
9664
|
-
projectionSearch.focusInput();
|
|
9665
|
-
}
|
|
9684
|
+
this.$refs.projectionSearch?.focusInput();
|
|
9666
9685
|
}
|
|
9667
9686
|
});
|
|
9668
9687
|
},
|
|
9688
|
+
unmounted() {
|
|
9689
|
+
clearInterval(this._refreshSidebar);
|
|
9690
|
+
},
|
|
9669
9691
|
watch: {
|
|
9670
9692
|
model(newModel) {
|
|
9671
9693
|
if (newModel !== this.currentModel) {
|
|
9672
9694
|
this.currentModel = newModel;
|
|
9673
9695
|
if (this.currentModel != null) {
|
|
9696
|
+
this.$refs.documentSearch?.focusInput();
|
|
9697
|
+
const schemaPaths = this.allSchemaPaths?.[newModel] ?? {};
|
|
9698
|
+
this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
|
|
9699
|
+
if (k1 === '_id' && k2 !== '_id') {
|
|
9700
|
+
return -1;
|
|
9701
|
+
}
|
|
9702
|
+
if (k1 !== '_id' && k2 === '_id') {
|
|
9703
|
+
return 1;
|
|
9704
|
+
}
|
|
9705
|
+
return 0;
|
|
9706
|
+
}).map(key => schemaPaths[key]);
|
|
9674
9707
|
this.initSearchFromUrl();
|
|
9675
9708
|
}
|
|
9676
9709
|
}
|
|
@@ -10114,6 +10147,8 @@ module.exports = app => app.component('models', {
|
|
|
10114
10147
|
this.query.sortKey = sortKey;
|
|
10115
10148
|
this.query.sortDirection = sortDirection;
|
|
10116
10149
|
delete this.query.sort;
|
|
10150
|
+
} else {
|
|
10151
|
+
this.sortBy = {};
|
|
10117
10152
|
}
|
|
10118
10153
|
if (this.currentModel != null) {
|
|
10119
10154
|
await this.getDocuments();
|
|
@@ -10129,6 +10164,8 @@ module.exports = app => app.component('models', {
|
|
|
10129
10164
|
this.selectedPaths = [...this.filteredPaths];
|
|
10130
10165
|
this.syncProjectionInputFromQueryOrPaths();
|
|
10131
10166
|
}
|
|
10167
|
+
} else {
|
|
10168
|
+
this.selectedPaths = [];
|
|
10132
10169
|
}
|
|
10133
10170
|
this.status = 'loaded';
|
|
10134
10171
|
|
|
@@ -10410,7 +10447,6 @@ module.exports = app => app.component('models', {
|
|
|
10410
10447
|
|
|
10411
10448
|
// Clear previous data
|
|
10412
10449
|
this.documents = [];
|
|
10413
|
-
this.schemaPaths = [];
|
|
10414
10450
|
this.numDocuments = null;
|
|
10415
10451
|
this.loadedAllDocs = false;
|
|
10416
10452
|
this.lastSelectedIndex = null;
|
|
@@ -11731,7 +11767,8 @@ module.exports = {
|
|
|
11731
11767
|
name: 'model',
|
|
11732
11768
|
component: 'models',
|
|
11733
11769
|
meta: {
|
|
11734
|
-
authorized: false
|
|
11770
|
+
authorized: false,
|
|
11771
|
+
preserveStateKey: 'model'
|
|
11735
11772
|
}
|
|
11736
11773
|
},
|
|
11737
11774
|
{
|
|
@@ -60598,7 +60635,7 @@ class Binary extends BSONValue {
|
|
|
60598
60635
|
!Array.isArray(buffer)) {
|
|
60599
60636
|
throw new BSONError('Binary can only be constructed from Uint8Array or number[]');
|
|
60600
60637
|
}
|
|
60601
|
-
this.sub_type = subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT;
|
|
60638
|
+
this.sub_type = (subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT) & 0xff;
|
|
60602
60639
|
if (buffer == null) {
|
|
60603
60640
|
this.buffer = ByteUtils.allocate(Binary.BUFFER_SIZE);
|
|
60604
60641
|
this.position = 0;
|
|
@@ -60704,7 +60741,7 @@ class Binary extends BSONValue {
|
|
|
60704
60741
|
if (this.sub_type === Binary.SUBTYPE_UUID) {
|
|
60705
60742
|
return new UUID(this.buffer.subarray(0, this.position));
|
|
60706
60743
|
}
|
|
60707
|
-
throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only
|
|
60744
|
+
throw new BSONError(`Binary sub_type "${this.sub_type}" (${typeof this.sub_type}) is not supported for converting to UUID. Only 0x${Binary.SUBTYPE_UUID.toString(16).padStart(2, '0')} is currently supported.`);
|
|
60708
60745
|
}
|
|
60709
60746
|
static createFromHexString(hex, subType) {
|
|
60710
60747
|
return new Binary(ByteUtils.fromHex(hex), subType);
|
|
@@ -62493,13 +62530,24 @@ class MinKey extends BSONValue {
|
|
|
62493
62530
|
}
|
|
62494
62531
|
}
|
|
62495
62532
|
|
|
62496
|
-
let PROCESS_UNIQUE = null;
|
|
62497
62533
|
const __idCache = new WeakMap();
|
|
62498
62534
|
class ObjectId extends BSONValue {
|
|
62499
62535
|
get _bsontype() {
|
|
62500
62536
|
return 'ObjectId';
|
|
62501
62537
|
}
|
|
62502
|
-
static index =
|
|
62538
|
+
static index = 0;
|
|
62539
|
+
static PROCESS_UNIQUE = null;
|
|
62540
|
+
static resetState = () => {
|
|
62541
|
+
this.index = Math.floor(Math.random() * 0x1000000);
|
|
62542
|
+
this.PROCESS_UNIQUE = ByteUtils.randomBytes(5);
|
|
62543
|
+
};
|
|
62544
|
+
static {
|
|
62545
|
+
this.resetState();
|
|
62546
|
+
const { startupSnapshot } = globalThis?.process?.getBuiltinModule('v8') ?? {};
|
|
62547
|
+
if (startupSnapshot?.isBuildingSnapshot()) {
|
|
62548
|
+
startupSnapshot?.addDeserializeCallback(this.resetState);
|
|
62549
|
+
}
|
|
62550
|
+
}
|
|
62503
62551
|
static cacheHexString;
|
|
62504
62552
|
buffer;
|
|
62505
62553
|
constructor(inputId) {
|
|
@@ -62576,7 +62624,7 @@ class ObjectId extends BSONValue {
|
|
|
62576
62624
|
return hexString;
|
|
62577
62625
|
}
|
|
62578
62626
|
static getInc() {
|
|
62579
|
-
return (ObjectId.index = (ObjectId.index + 1) %
|
|
62627
|
+
return (ObjectId.index = (ObjectId.index + 1) % 0x1000000);
|
|
62580
62628
|
}
|
|
62581
62629
|
static generate(time) {
|
|
62582
62630
|
if ('number' !== typeof time) {
|
|
@@ -62585,9 +62633,7 @@ class ObjectId extends BSONValue {
|
|
|
62585
62633
|
const inc = ObjectId.getInc();
|
|
62586
62634
|
const buffer = ByteUtils.allocateUnsafe(12);
|
|
62587
62635
|
NumberUtils.setInt32BE(buffer, 0, time);
|
|
62588
|
-
|
|
62589
|
-
PROCESS_UNIQUE = ByteUtils.randomBytes(5);
|
|
62590
|
-
}
|
|
62636
|
+
const PROCESS_UNIQUE = this.PROCESS_UNIQUE;
|
|
62591
62637
|
buffer[4] = PROCESS_UNIQUE[0];
|
|
62592
62638
|
buffer[5] = PROCESS_UNIQUE[1];
|
|
62593
62639
|
buffer[6] = PROCESS_UNIQUE[2];
|
|
@@ -62705,23 +62751,33 @@ class ObjectId extends BSONValue {
|
|
|
62705
62751
|
}
|
|
62706
62752
|
|
|
62707
62753
|
function internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined) {
|
|
62708
|
-
|
|
62709
|
-
|
|
62710
|
-
|
|
62711
|
-
|
|
62754
|
+
const objectStack = [
|
|
62755
|
+
{ obj: object, ignoreUndefined: ignoreUndefined ?? false }
|
|
62756
|
+
];
|
|
62757
|
+
let total = 0;
|
|
62758
|
+
while (objectStack.length > 0) {
|
|
62759
|
+
const { obj, ignoreUndefined: frameIgnoreUndefined } = objectStack.pop();
|
|
62760
|
+
total += 5;
|
|
62761
|
+
const isObjArray = Array.isArray(obj);
|
|
62762
|
+
let target = obj;
|
|
62763
|
+
if (!isObjArray && typeof obj?.toBSON === 'function') {
|
|
62764
|
+
target = obj.toBSON();
|
|
62712
62765
|
}
|
|
62713
|
-
|
|
62714
|
-
|
|
62715
|
-
|
|
62716
|
-
|
|
62766
|
+
if (isObjArray) {
|
|
62767
|
+
const array = target;
|
|
62768
|
+
for (let i = 0; i < array.length; i++) {
|
|
62769
|
+
total += calculateElementSize(i.toString(), array[i], serializeFunctions, true, frameIgnoreUndefined, objectStack);
|
|
62770
|
+
}
|
|
62717
62771
|
}
|
|
62718
|
-
|
|
62719
|
-
|
|
62772
|
+
else {
|
|
62773
|
+
for (const key of Object.keys(target)) {
|
|
62774
|
+
total += calculateElementSize(key, target[key], serializeFunctions, false, frameIgnoreUndefined, objectStack);
|
|
62775
|
+
}
|
|
62720
62776
|
}
|
|
62721
62777
|
}
|
|
62722
|
-
return
|
|
62778
|
+
return total;
|
|
62723
62779
|
}
|
|
62724
|
-
function
|
|
62780
|
+
function calculateElementSize(name, value, serializeFunctions = false, isArray = false, ignoreUndefined = false, objectStack) {
|
|
62725
62781
|
if (typeof value?.toBSON === 'function') {
|
|
62726
62782
|
value = value.toBSON();
|
|
62727
62783
|
}
|
|
@@ -62733,21 +62789,21 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62733
62789
|
value >= JS_INT_MIN &&
|
|
62734
62790
|
value <= JS_INT_MAX) {
|
|
62735
62791
|
if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
|
|
62736
|
-
return
|
|
62792
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (4 + 1);
|
|
62737
62793
|
}
|
|
62738
62794
|
else {
|
|
62739
|
-
return
|
|
62795
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (8 + 1);
|
|
62740
62796
|
}
|
|
62741
62797
|
}
|
|
62742
62798
|
else {
|
|
62743
|
-
return
|
|
62799
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (8 + 1);
|
|
62744
62800
|
}
|
|
62745
62801
|
case 'undefined':
|
|
62746
62802
|
if (isArray || !ignoreUndefined)
|
|
62747
|
-
return
|
|
62803
|
+
return ByteUtils.utf8ByteLength(name) + 1 + 1;
|
|
62748
62804
|
return 0;
|
|
62749
62805
|
case 'boolean':
|
|
62750
|
-
return
|
|
62806
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (1 + 1);
|
|
62751
62807
|
case 'object':
|
|
62752
62808
|
if (value != null &&
|
|
62753
62809
|
typeof value._bsontype === 'string' &&
|
|
@@ -62755,39 +62811,41 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62755
62811
|
throw new BSONVersionError();
|
|
62756
62812
|
}
|
|
62757
62813
|
else if (value == null || value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
62758
|
-
return
|
|
62814
|
+
return ByteUtils.utf8ByteLength(name) + 1 + 1;
|
|
62759
62815
|
}
|
|
62760
62816
|
else if (value._bsontype === 'ObjectId') {
|
|
62761
|
-
return
|
|
62817
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (12 + 1);
|
|
62762
62818
|
}
|
|
62763
62819
|
else if (value instanceof Date || isDate(value)) {
|
|
62764
|
-
return
|
|
62820
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (8 + 1);
|
|
62765
62821
|
}
|
|
62766
62822
|
else if (ArrayBuffer.isView(value) ||
|
|
62767
62823
|
value instanceof ArrayBuffer ||
|
|
62768
62824
|
isAnyArrayBuffer(value)) {
|
|
62769
|
-
return
|
|
62825
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (1 + 4 + 1) + value.byteLength;
|
|
62770
62826
|
}
|
|
62771
62827
|
else if (value._bsontype === 'Long' ||
|
|
62772
62828
|
value._bsontype === 'Double' ||
|
|
62773
62829
|
value._bsontype === 'Timestamp') {
|
|
62774
|
-
return
|
|
62830
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (8 + 1);
|
|
62775
62831
|
}
|
|
62776
62832
|
else if (value._bsontype === 'Decimal128') {
|
|
62777
|
-
return
|
|
62833
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (16 + 1);
|
|
62778
62834
|
}
|
|
62779
62835
|
else if (value._bsontype === 'Code') {
|
|
62780
62836
|
if (value.scope != null && Object.keys(value.scope).length > 0) {
|
|
62781
|
-
|
|
62837
|
+
objectStack.push({ obj: value.scope, ignoreUndefined });
|
|
62838
|
+
return (ByteUtils.utf8ByteLength(name) +
|
|
62839
|
+
1 +
|
|
62782
62840
|
1 +
|
|
62783
62841
|
4 +
|
|
62784
62842
|
4 +
|
|
62785
62843
|
ByteUtils.utf8ByteLength(value.code.toString()) +
|
|
62786
|
-
1
|
|
62787
|
-
internalCalculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
|
|
62844
|
+
1);
|
|
62788
62845
|
}
|
|
62789
62846
|
else {
|
|
62790
|
-
return (
|
|
62847
|
+
return (ByteUtils.utf8ByteLength(name) +
|
|
62848
|
+
1 +
|
|
62791
62849
|
1 +
|
|
62792
62850
|
4 +
|
|
62793
62851
|
ByteUtils.utf8ByteLength(value.code.toString()) +
|
|
@@ -62797,19 +62855,14 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62797
62855
|
else if (value._bsontype === 'Binary') {
|
|
62798
62856
|
const binary = value;
|
|
62799
62857
|
if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
|
|
62800
|
-
return (
|
|
62801
|
-
(binary.position + 1 + 4 + 1 + 4));
|
|
62858
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (binary.position + 1 + 4 + 1 + 4);
|
|
62802
62859
|
}
|
|
62803
62860
|
else {
|
|
62804
|
-
return
|
|
62861
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (binary.position + 1 + 4 + 1);
|
|
62805
62862
|
}
|
|
62806
62863
|
}
|
|
62807
62864
|
else if (value._bsontype === 'Symbol') {
|
|
62808
|
-
return ((name
|
|
62809
|
-
ByteUtils.utf8ByteLength(value.value) +
|
|
62810
|
-
4 +
|
|
62811
|
-
1 +
|
|
62812
|
-
1);
|
|
62865
|
+
return (ByteUtils.utf8ByteLength(name) + 1 + ByteUtils.utf8ByteLength(value.value) + 4 + 1 + 1);
|
|
62813
62866
|
}
|
|
62814
62867
|
else if (value._bsontype === 'DBRef') {
|
|
62815
62868
|
const ordered_values = Object.assign({
|
|
@@ -62819,12 +62872,12 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62819
62872
|
if (value.db != null) {
|
|
62820
62873
|
ordered_values['$db'] = value.db;
|
|
62821
62874
|
}
|
|
62822
|
-
|
|
62823
|
-
|
|
62824
|
-
internalCalculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined));
|
|
62875
|
+
objectStack.push({ obj: ordered_values, ignoreUndefined: true });
|
|
62876
|
+
return ByteUtils.utf8ByteLength(name) + 1 + 1;
|
|
62825
62877
|
}
|
|
62826
62878
|
else if (value instanceof RegExp || isRegExp(value)) {
|
|
62827
|
-
return (
|
|
62879
|
+
return (ByteUtils.utf8ByteLength(name) +
|
|
62880
|
+
1 +
|
|
62828
62881
|
1 +
|
|
62829
62882
|
ByteUtils.utf8ByteLength(value.source) +
|
|
62830
62883
|
1 +
|
|
@@ -62834,7 +62887,8 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62834
62887
|
1);
|
|
62835
62888
|
}
|
|
62836
62889
|
else if (value._bsontype === 'BSONRegExp') {
|
|
62837
|
-
return (
|
|
62890
|
+
return (ByteUtils.utf8ByteLength(name) +
|
|
62891
|
+
1 +
|
|
62838
62892
|
1 +
|
|
62839
62893
|
ByteUtils.utf8ByteLength(value.pattern) +
|
|
62840
62894
|
1 +
|
|
@@ -62842,13 +62896,13 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62842
62896
|
1);
|
|
62843
62897
|
}
|
|
62844
62898
|
else {
|
|
62845
|
-
|
|
62846
|
-
|
|
62847
|
-
1);
|
|
62899
|
+
objectStack.push({ obj: value, ignoreUndefined });
|
|
62900
|
+
return ByteUtils.utf8ByteLength(name) + 1 + 1;
|
|
62848
62901
|
}
|
|
62849
62902
|
case 'function':
|
|
62850
62903
|
if (serializeFunctions) {
|
|
62851
|
-
return (
|
|
62904
|
+
return (ByteUtils.utf8ByteLength(name) +
|
|
62905
|
+
1 +
|
|
62852
62906
|
1 +
|
|
62853
62907
|
4 +
|
|
62854
62908
|
ByteUtils.utf8ByteLength(value.toString()) +
|
|
@@ -62856,7 +62910,7 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
62856
62910
|
}
|
|
62857
62911
|
return 0;
|
|
62858
62912
|
case 'bigint':
|
|
62859
|
-
return
|
|
62913
|
+
return ByteUtils.utf8ByteLength(name) + 1 + (8 + 1);
|
|
62860
62914
|
case 'symbol':
|
|
62861
62915
|
return 0;
|
|
62862
62916
|
default:
|
|
@@ -63072,7 +63126,28 @@ function internalDeserialize(buffer, options, isArray) {
|
|
|
63072
63126
|
return deserializeObject(buffer, index, options, isArray);
|
|
63073
63127
|
}
|
|
63074
63128
|
const allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
|
|
63129
|
+
function assignValue(dest, name, value) {
|
|
63130
|
+
if (name === '__proto__') {
|
|
63131
|
+
Object.defineProperty(dest, name, {
|
|
63132
|
+
value,
|
|
63133
|
+
writable: true,
|
|
63134
|
+
enumerable: true,
|
|
63135
|
+
configurable: true
|
|
63136
|
+
});
|
|
63137
|
+
}
|
|
63138
|
+
else {
|
|
63139
|
+
dest[name] = value;
|
|
63140
|
+
}
|
|
63141
|
+
}
|
|
63142
|
+
function toPotentialDbRef(doc) {
|
|
63143
|
+
if (isDBRefLike(doc)) {
|
|
63144
|
+
const { $ref, $id, $db, ...fields } = doc;
|
|
63145
|
+
return new DBRef($ref, $id, $db, fields);
|
|
63146
|
+
}
|
|
63147
|
+
return doc;
|
|
63148
|
+
}
|
|
63075
63149
|
function deserializeObject(buffer, index, options, isArray = false) {
|
|
63150
|
+
options = { ...options };
|
|
63076
63151
|
const fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw'];
|
|
63077
63152
|
const raw = options['raw'] == null ? false : options['raw'];
|
|
63078
63153
|
const bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false;
|
|
@@ -63123,31 +63198,87 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
63123
63198
|
index += 4;
|
|
63124
63199
|
if (size < 5 || size > buffer.length)
|
|
63125
63200
|
throw new BSONError('corrupt bson message');
|
|
63126
|
-
const
|
|
63201
|
+
const rootObject = isArray ? [] : {};
|
|
63127
63202
|
let arrayIndex = 0;
|
|
63128
63203
|
let isPossibleDBRef = isArray ? false : null;
|
|
63204
|
+
let currentFrame = null;
|
|
63205
|
+
let currentDest = rootObject;
|
|
63206
|
+
let currentIsArray = isArray;
|
|
63129
63207
|
while (true) {
|
|
63130
63208
|
const elementType = buffer[index++];
|
|
63131
|
-
if (elementType === 0)
|
|
63132
|
-
|
|
63209
|
+
if (elementType === 0) {
|
|
63210
|
+
if (currentFrame) {
|
|
63211
|
+
if (index === currentFrame.lastIndex) {
|
|
63212
|
+
const completedFrame = currentFrame;
|
|
63213
|
+
currentFrame = completedFrame.prev;
|
|
63214
|
+
if (currentFrame === null) {
|
|
63215
|
+
currentDest = rootObject;
|
|
63216
|
+
currentIsArray = isArray;
|
|
63217
|
+
}
|
|
63218
|
+
else {
|
|
63219
|
+
currentDest = currentFrame.holdingDocument;
|
|
63220
|
+
currentIsArray = currentFrame.isArray;
|
|
63221
|
+
}
|
|
63222
|
+
let result = completedFrame.holdingDocument;
|
|
63223
|
+
switch (completedFrame.elementType) {
|
|
63224
|
+
case BSON_DATA_OBJECT:
|
|
63225
|
+
if (completedFrame.isPossibleDBRef) {
|
|
63226
|
+
result = toPotentialDbRef(result);
|
|
63227
|
+
}
|
|
63228
|
+
break;
|
|
63229
|
+
case BSON_DATA_ARRAY:
|
|
63230
|
+
break;
|
|
63231
|
+
case BSON_DATA_CODE_W_SCOPE:
|
|
63232
|
+
result = new Code(completedFrame.functionString, completedFrame.holdingDocument);
|
|
63233
|
+
break;
|
|
63234
|
+
default:
|
|
63235
|
+
throw new BSONError('Unexpected element type in frame stack');
|
|
63236
|
+
}
|
|
63237
|
+
assignValue(currentDest, completedFrame.propertyName, result);
|
|
63238
|
+
continue;
|
|
63239
|
+
}
|
|
63240
|
+
else {
|
|
63241
|
+
if (currentFrame.elementType === BSON_DATA_ARRAY) {
|
|
63242
|
+
throw new BSONError('corrupted array bson');
|
|
63243
|
+
}
|
|
63244
|
+
throw new BSONError('Bad BSON Document: object not properly terminated');
|
|
63245
|
+
}
|
|
63246
|
+
}
|
|
63247
|
+
else {
|
|
63248
|
+
break;
|
|
63249
|
+
}
|
|
63250
|
+
}
|
|
63133
63251
|
let i = index;
|
|
63134
63252
|
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
63135
63253
|
i++;
|
|
63136
63254
|
}
|
|
63137
63255
|
if (i >= buffer.byteLength)
|
|
63138
63256
|
throw new BSONError('Bad BSON Document: illegal CString');
|
|
63139
|
-
const name =
|
|
63140
|
-
|
|
63141
|
-
|
|
63257
|
+
const name = currentIsArray
|
|
63258
|
+
? currentFrame !== null
|
|
63259
|
+
? currentFrame.arrayIndex++
|
|
63260
|
+
: arrayIndex++
|
|
63261
|
+
: ByteUtils.toUTF8(buffer, index, i, false);
|
|
63262
|
+
let shouldValidateKey;
|
|
63263
|
+
if (currentFrame !== null) {
|
|
63264
|
+
shouldValidateKey = currentFrame.validationSetting;
|
|
63265
|
+
}
|
|
63266
|
+
else if (globalUTFValidation || utf8KeysSet?.has(name)) {
|
|
63142
63267
|
shouldValidateKey = validationSetting;
|
|
63143
63268
|
}
|
|
63144
63269
|
else {
|
|
63145
63270
|
shouldValidateKey = !validationSetting;
|
|
63146
63271
|
}
|
|
63147
|
-
if (
|
|
63272
|
+
if (currentFrame !== null) {
|
|
63273
|
+
if (currentFrame.isPossibleDBRef !== false && typeof name === 'string' && name[0] === '$') {
|
|
63274
|
+
currentFrame.isPossibleDBRef = allowedDBRefKeys.test(name);
|
|
63275
|
+
}
|
|
63276
|
+
}
|
|
63277
|
+
else if (isPossibleDBRef !== false && name[0] === '$') {
|
|
63148
63278
|
isPossibleDBRef = allowedDBRefKeys.test(name);
|
|
63149
63279
|
}
|
|
63150
63280
|
let value;
|
|
63281
|
+
let isDeferredValue = false;
|
|
63151
63282
|
index = i + 1;
|
|
63152
63283
|
if (elementType === BSON_DATA_STRING) {
|
|
63153
63284
|
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
@@ -63193,39 +63324,58 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
63193
63324
|
value = buffer[index++] === 1;
|
|
63194
63325
|
}
|
|
63195
63326
|
else if (elementType === BSON_DATA_OBJECT) {
|
|
63196
|
-
const _index = index;
|
|
63197
63327
|
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
63198
|
-
if (objectSize
|
|
63328
|
+
if (objectSize < 5 || objectSize > buffer.length - index)
|
|
63199
63329
|
throw new BSONError('bad embedded document length in bson');
|
|
63200
|
-
if (raw) {
|
|
63330
|
+
if (raw || (currentFrame?.raw ?? false)) {
|
|
63201
63331
|
value = buffer.subarray(index, index + objectSize);
|
|
63332
|
+
index = index + objectSize;
|
|
63202
63333
|
}
|
|
63203
63334
|
else {
|
|
63204
|
-
|
|
63205
|
-
|
|
63206
|
-
|
|
63207
|
-
|
|
63208
|
-
|
|
63335
|
+
isDeferredValue = true;
|
|
63336
|
+
const objectFrame = {
|
|
63337
|
+
holdingDocument: {},
|
|
63338
|
+
elementType: BSON_DATA_OBJECT,
|
|
63339
|
+
propertyName: name,
|
|
63340
|
+
functionString: null,
|
|
63341
|
+
lastIndex: index + objectSize,
|
|
63342
|
+
isArray: false,
|
|
63343
|
+
arrayIndex: 0,
|
|
63344
|
+
raw: false,
|
|
63345
|
+
isPossibleDBRef: null,
|
|
63346
|
+
validationSetting: shouldValidateKey,
|
|
63347
|
+
prev: currentFrame
|
|
63348
|
+
};
|
|
63349
|
+
currentFrame = objectFrame;
|
|
63350
|
+
currentDest = objectFrame.holdingDocument;
|
|
63351
|
+
currentIsArray = false;
|
|
63352
|
+
index = index + 4;
|
|
63209
63353
|
}
|
|
63210
|
-
index = index + objectSize;
|
|
63211
63354
|
}
|
|
63212
63355
|
else if (elementType === BSON_DATA_ARRAY) {
|
|
63213
|
-
const _index = index;
|
|
63214
63356
|
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
63215
|
-
|
|
63357
|
+
if (objectSize < 5 || objectSize > buffer.length - index)
|
|
63358
|
+
throw new BSONError('bad embedded array length in bson');
|
|
63216
63359
|
const stopIndex = index + objectSize;
|
|
63217
|
-
|
|
63218
|
-
|
|
63219
|
-
|
|
63220
|
-
|
|
63221
|
-
|
|
63222
|
-
|
|
63223
|
-
|
|
63224
|
-
|
|
63225
|
-
|
|
63226
|
-
|
|
63227
|
-
|
|
63228
|
-
|
|
63360
|
+
const arrayRaw = !!(fieldsAsRaw && fieldsAsRaw[name]) || (currentFrame?.raw ?? false);
|
|
63361
|
+
isDeferredValue = true;
|
|
63362
|
+
const arrayFrame = {
|
|
63363
|
+
holdingDocument: [],
|
|
63364
|
+
elementType: BSON_DATA_ARRAY,
|
|
63365
|
+
propertyName: name,
|
|
63366
|
+
functionString: null,
|
|
63367
|
+
lastIndex: stopIndex,
|
|
63368
|
+
isArray: true,
|
|
63369
|
+
arrayIndex: 0,
|
|
63370
|
+
raw: arrayRaw,
|
|
63371
|
+
isPossibleDBRef: false,
|
|
63372
|
+
validationSetting: shouldValidateKey,
|
|
63373
|
+
prev: currentFrame
|
|
63374
|
+
};
|
|
63375
|
+
currentFrame = arrayFrame;
|
|
63376
|
+
currentDest = arrayFrame.holdingDocument;
|
|
63377
|
+
currentIsArray = true;
|
|
63378
|
+
index = index + 4;
|
|
63229
63379
|
}
|
|
63230
63380
|
else if (elementType === BSON_DATA_UNDEFINED) {
|
|
63231
63381
|
value = undefined;
|
|
@@ -63397,15 +63547,32 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
63397
63547
|
index = index + stringSize;
|
|
63398
63548
|
const _index = index;
|
|
63399
63549
|
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
63400
|
-
|
|
63401
|
-
|
|
63550
|
+
if (objectSize < 5 || objectSize > buffer.length - index)
|
|
63551
|
+
throw new BSONError('bad scope document size in code_w_scope');
|
|
63402
63552
|
if (totalSize < 4 + 4 + objectSize + stringSize) {
|
|
63403
63553
|
throw new BSONError('code_w_scope total size is too short, truncating scope');
|
|
63404
63554
|
}
|
|
63405
63555
|
if (totalSize > 4 + 4 + objectSize + stringSize) {
|
|
63406
63556
|
throw new BSONError('code_w_scope total size is too long, clips outer document');
|
|
63407
63557
|
}
|
|
63408
|
-
|
|
63558
|
+
isDeferredValue = true;
|
|
63559
|
+
const scopeFrame = {
|
|
63560
|
+
holdingDocument: {},
|
|
63561
|
+
elementType: BSON_DATA_CODE_W_SCOPE,
|
|
63562
|
+
propertyName: name,
|
|
63563
|
+
functionString: functionString,
|
|
63564
|
+
lastIndex: _index + objectSize,
|
|
63565
|
+
isArray: false,
|
|
63566
|
+
arrayIndex: 0,
|
|
63567
|
+
raw: false,
|
|
63568
|
+
isPossibleDBRef: null,
|
|
63569
|
+
validationSetting: shouldValidateKey,
|
|
63570
|
+
prev: currentFrame
|
|
63571
|
+
};
|
|
63572
|
+
currentFrame = scopeFrame;
|
|
63573
|
+
currentDest = scopeFrame.holdingDocument;
|
|
63574
|
+
currentIsArray = false;
|
|
63575
|
+
index = index + 4;
|
|
63409
63576
|
}
|
|
63410
63577
|
else if (elementType === BSON_DATA_DBPOINTER) {
|
|
63411
63578
|
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
@@ -63426,18 +63593,14 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
63426
63593
|
else {
|
|
63427
63594
|
throw new BSONError(`Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"`);
|
|
63428
63595
|
}
|
|
63429
|
-
if (
|
|
63430
|
-
|
|
63431
|
-
value,
|
|
63432
|
-
writable: true,
|
|
63433
|
-
enumerable: true,
|
|
63434
|
-
configurable: true
|
|
63435
|
-
});
|
|
63436
|
-
}
|
|
63437
|
-
else {
|
|
63438
|
-
object[name] = value;
|
|
63596
|
+
if (!isDeferredValue) {
|
|
63597
|
+
assignValue(currentDest, name, value);
|
|
63439
63598
|
}
|
|
63440
63599
|
}
|
|
63600
|
+
if (currentFrame !== null) {
|
|
63601
|
+
throw new BSONError('corrupted bson, more objects expected based on the current document size');
|
|
63602
|
+
}
|
|
63603
|
+
const object = rootObject;
|
|
63441
63604
|
if (size !== index - startIndex) {
|
|
63442
63605
|
if (isArray)
|
|
63443
63606
|
throw new BSONError('corrupt array bson');
|
|
@@ -63445,14 +63608,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
63445
63608
|
}
|
|
63446
63609
|
if (!isPossibleDBRef)
|
|
63447
63610
|
return object;
|
|
63448
|
-
|
|
63449
|
-
const copy = Object.assign({}, object);
|
|
63450
|
-
delete copy.$ref;
|
|
63451
|
-
delete copy.$id;
|
|
63452
|
-
delete copy.$db;
|
|
63453
|
-
return new DBRef(object.$ref, object.$id, object.$db, copy);
|
|
63454
|
-
}
|
|
63455
|
-
return object;
|
|
63611
|
+
return toPotentialDbRef(object);
|
|
63456
63612
|
}
|
|
63457
63613
|
|
|
63458
63614
|
const regexp = /\x00/;
|
|
@@ -63561,7 +63717,7 @@ function serializeMinMax(buffer, key, value, index) {
|
|
|
63561
63717
|
if (value === null) {
|
|
63562
63718
|
buffer[index++] = BSON_DATA_NULL;
|
|
63563
63719
|
}
|
|
63564
|
-
else if (value
|
|
63720
|
+
else if (value[bsonType] === 'MinKey') {
|
|
63565
63721
|
buffer[index++] = BSON_DATA_MIN_KEY;
|
|
63566
63722
|
}
|
|
63567
63723
|
else {
|
|
@@ -63598,19 +63754,6 @@ function serializeBuffer(buffer, key, value, index) {
|
|
|
63598
63754
|
index = index + size;
|
|
63599
63755
|
return index;
|
|
63600
63756
|
}
|
|
63601
|
-
function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path) {
|
|
63602
|
-
if (path.has(value)) {
|
|
63603
|
-
throw new BSONError('Cannot convert circular structure to BSON');
|
|
63604
|
-
}
|
|
63605
|
-
path.add(value);
|
|
63606
|
-
buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
|
|
63607
|
-
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
63608
|
-
index = index + numberOfWrittenBytes;
|
|
63609
|
-
buffer[index++] = 0;
|
|
63610
|
-
const endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
|
|
63611
|
-
path.delete(value);
|
|
63612
|
-
return endIndex;
|
|
63613
|
-
}
|
|
63614
63757
|
function serializeDecimal128(buffer, key, value, index) {
|
|
63615
63758
|
buffer[index++] = BSON_DATA_DECIMAL128;
|
|
63616
63759
|
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
@@ -63622,7 +63765,7 @@ function serializeDecimal128(buffer, key, value, index) {
|
|
|
63622
63765
|
}
|
|
63623
63766
|
function serializeLong(buffer, key, value, index) {
|
|
63624
63767
|
buffer[index++] =
|
|
63625
|
-
value
|
|
63768
|
+
value[bsonType] === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
|
|
63626
63769
|
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
63627
63770
|
index = index + numberOfWrittenBytes;
|
|
63628
63771
|
buffer[index++] = 0;
|
|
@@ -63661,38 +63804,6 @@ function serializeFunction(buffer, key, value, index) {
|
|
|
63661
63804
|
buffer[index++] = 0;
|
|
63662
63805
|
return index;
|
|
63663
63806
|
}
|
|
63664
|
-
function serializeCode(buffer, key, value, index, checkKeys = false, depth = 0, serializeFunctions = false, ignoreUndefined = true, path) {
|
|
63665
|
-
if (value.scope && typeof value.scope === 'object') {
|
|
63666
|
-
buffer[index++] = BSON_DATA_CODE_W_SCOPE;
|
|
63667
|
-
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
63668
|
-
index = index + numberOfWrittenBytes;
|
|
63669
|
-
buffer[index++] = 0;
|
|
63670
|
-
let startIndex = index;
|
|
63671
|
-
const functionString = value.code;
|
|
63672
|
-
index = index + 4;
|
|
63673
|
-
const codeSize = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
63674
|
-
NumberUtils.setInt32LE(buffer, index, codeSize);
|
|
63675
|
-
buffer[index + 4 + codeSize - 1] = 0;
|
|
63676
|
-
index = index + codeSize + 4;
|
|
63677
|
-
const endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
|
|
63678
|
-
index = endIndex - 1;
|
|
63679
|
-
const totalSize = endIndex - startIndex;
|
|
63680
|
-
startIndex += NumberUtils.setInt32LE(buffer, startIndex, totalSize);
|
|
63681
|
-
buffer[index++] = 0;
|
|
63682
|
-
}
|
|
63683
|
-
else {
|
|
63684
|
-
buffer[index++] = BSON_DATA_CODE;
|
|
63685
|
-
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
63686
|
-
index = index + numberOfWrittenBytes;
|
|
63687
|
-
buffer[index++] = 0;
|
|
63688
|
-
const functionString = value.code.toString();
|
|
63689
|
-
const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
63690
|
-
NumberUtils.setInt32LE(buffer, index, size);
|
|
63691
|
-
index = index + 4 + size - 1;
|
|
63692
|
-
buffer[index++] = 0;
|
|
63693
|
-
}
|
|
63694
|
-
return index;
|
|
63695
|
-
}
|
|
63696
63807
|
function serializeBinary(buffer, key, value, index) {
|
|
63697
63808
|
buffer[index++] = BSON_DATA_BINARY;
|
|
63698
63809
|
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
@@ -63732,26 +63843,59 @@ function serializeSymbol(buffer, key, value, index) {
|
|
|
63732
63843
|
buffer[index++] = 0;
|
|
63733
63844
|
return index;
|
|
63734
63845
|
}
|
|
63735
|
-
function
|
|
63736
|
-
|
|
63737
|
-
|
|
63738
|
-
|
|
63739
|
-
|
|
63740
|
-
|
|
63741
|
-
|
|
63742
|
-
|
|
63743
|
-
|
|
63744
|
-
|
|
63745
|
-
|
|
63746
|
-
|
|
63846
|
+
function makeFrame(sourceObject, objectSizeIndex, codeSizeIndex, prev, checkKeys, ignoreUndefined) {
|
|
63847
|
+
if (Array.isArray(sourceObject)) {
|
|
63848
|
+
return {
|
|
63849
|
+
sourceObject,
|
|
63850
|
+
isArray: true,
|
|
63851
|
+
objectSizeIndex,
|
|
63852
|
+
codeSizeIndex,
|
|
63853
|
+
iterTarget: sourceObject,
|
|
63854
|
+
keys: null,
|
|
63855
|
+
keyIndex: 0,
|
|
63856
|
+
mapIterator: null,
|
|
63857
|
+
prev,
|
|
63858
|
+
checkKeys,
|
|
63859
|
+
ignoreUndefined
|
|
63860
|
+
};
|
|
63747
63861
|
}
|
|
63748
|
-
|
|
63749
|
-
|
|
63750
|
-
|
|
63751
|
-
|
|
63752
|
-
|
|
63753
|
-
|
|
63754
|
-
|
|
63862
|
+
if (sourceObject instanceof Map || isMap(sourceObject)) {
|
|
63863
|
+
return {
|
|
63864
|
+
sourceObject,
|
|
63865
|
+
isArray: false,
|
|
63866
|
+
objectSizeIndex,
|
|
63867
|
+
codeSizeIndex,
|
|
63868
|
+
iterTarget: sourceObject,
|
|
63869
|
+
keys: null,
|
|
63870
|
+
keyIndex: 0,
|
|
63871
|
+
mapIterator: sourceObject.entries(),
|
|
63872
|
+
prev,
|
|
63873
|
+
checkKeys,
|
|
63874
|
+
ignoreUndefined
|
|
63875
|
+
};
|
|
63876
|
+
}
|
|
63877
|
+
let target = sourceObject;
|
|
63878
|
+
if (typeof target?.toBSON === 'function') {
|
|
63879
|
+
target = target.toBSON();
|
|
63880
|
+
if (target != null && typeof target !== 'object') {
|
|
63881
|
+
throw new BSONError('toBSON function did not return an object');
|
|
63882
|
+
}
|
|
63883
|
+
}
|
|
63884
|
+
return {
|
|
63885
|
+
sourceObject,
|
|
63886
|
+
isArray: false,
|
|
63887
|
+
objectSizeIndex,
|
|
63888
|
+
codeSizeIndex,
|
|
63889
|
+
iterTarget: target,
|
|
63890
|
+
keys: Object.keys(target),
|
|
63891
|
+
keyIndex: 0,
|
|
63892
|
+
mapIterator: null,
|
|
63893
|
+
prev,
|
|
63894
|
+
checkKeys,
|
|
63895
|
+
ignoreUndefined
|
|
63896
|
+
};
|
|
63897
|
+
}
|
|
63898
|
+
function serializeInto(buffer, object, checkKeys, startingIndex, serializeFunctions, ignoreUndefined, path) {
|
|
63755
63899
|
if (path == null) {
|
|
63756
63900
|
if (object == null) {
|
|
63757
63901
|
buffer[0] = 0x05;
|
|
@@ -63779,308 +63923,200 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
63779
63923
|
path = new Set();
|
|
63780
63924
|
}
|
|
63781
63925
|
path.add(object);
|
|
63926
|
+
let currentFrame = makeFrame(object, startingIndex, null, null, checkKeys, ignoreUndefined);
|
|
63782
63927
|
let index = startingIndex + 4;
|
|
63783
|
-
|
|
63784
|
-
|
|
63785
|
-
|
|
63786
|
-
|
|
63787
|
-
|
|
63788
|
-
|
|
63789
|
-
|
|
63790
|
-
|
|
63791
|
-
|
|
63792
|
-
|
|
63793
|
-
|
|
63794
|
-
else if (value === null) {
|
|
63795
|
-
index = serializeNull(buffer, key, value, index);
|
|
63796
|
-
}
|
|
63797
|
-
else if (type === 'string') {
|
|
63798
|
-
index = serializeString(buffer, key, value, index);
|
|
63799
|
-
}
|
|
63800
|
-
else if (type === 'number') {
|
|
63801
|
-
index = serializeNumber(buffer, key, value, index);
|
|
63802
|
-
}
|
|
63803
|
-
else if (type === 'bigint') {
|
|
63804
|
-
index = serializeBigInt(buffer, key, value, index);
|
|
63805
|
-
}
|
|
63806
|
-
else if (type === 'boolean') {
|
|
63807
|
-
index = serializeBoolean(buffer, key, value, index);
|
|
63808
|
-
}
|
|
63809
|
-
else if (type === 'object' && value._bsontype == null) {
|
|
63810
|
-
if (value instanceof Date || isDate(value)) {
|
|
63811
|
-
index = serializeDate(buffer, key, value, index);
|
|
63812
|
-
}
|
|
63813
|
-
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
63814
|
-
index = serializeBuffer(buffer, key, value, index);
|
|
63815
|
-
}
|
|
63816
|
-
else if (value instanceof RegExp || isRegExp(value)) {
|
|
63817
|
-
index = serializeRegExp(buffer, key, value, index);
|
|
63818
|
-
}
|
|
63819
|
-
else {
|
|
63820
|
-
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
63928
|
+
while (currentFrame !== null) {
|
|
63929
|
+
const frame = currentFrame;
|
|
63930
|
+
let key;
|
|
63931
|
+
let value;
|
|
63932
|
+
if (frame.mapIterator !== null) {
|
|
63933
|
+
const next = frame.mapIterator.next();
|
|
63934
|
+
if (next.done) {
|
|
63935
|
+
buffer[index++] = 0x00;
|
|
63936
|
+
NumberUtils.setInt32LE(buffer, frame.objectSizeIndex, index - frame.objectSizeIndex);
|
|
63937
|
+
if (frame.codeSizeIndex !== null) {
|
|
63938
|
+
NumberUtils.setInt32LE(buffer, frame.codeSizeIndex, index - frame.codeSizeIndex);
|
|
63821
63939
|
}
|
|
63940
|
+
path.delete(frame.sourceObject);
|
|
63941
|
+
currentFrame = frame.prev;
|
|
63942
|
+
continue;
|
|
63822
63943
|
}
|
|
63823
|
-
|
|
63824
|
-
|
|
63825
|
-
|
|
63826
|
-
|
|
63827
|
-
|
|
63828
|
-
|
|
63829
|
-
|
|
63830
|
-
|
|
63831
|
-
|
|
63832
|
-
}
|
|
63833
|
-
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
63834
|
-
index = serializeLong(buffer, key, value, index);
|
|
63835
|
-
}
|
|
63836
|
-
else if (value._bsontype === 'Double') {
|
|
63837
|
-
index = serializeDouble(buffer, key, value, index);
|
|
63838
|
-
}
|
|
63839
|
-
else if (value._bsontype === 'Code') {
|
|
63840
|
-
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
63841
|
-
}
|
|
63842
|
-
else if (value._bsontype === 'Binary') {
|
|
63843
|
-
index = serializeBinary(buffer, key, value, index);
|
|
63844
|
-
}
|
|
63845
|
-
else if (value._bsontype === 'BSONSymbol') {
|
|
63846
|
-
index = serializeSymbol(buffer, key, value, index);
|
|
63847
|
-
}
|
|
63848
|
-
else if (value._bsontype === 'DBRef') {
|
|
63849
|
-
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
63850
|
-
}
|
|
63851
|
-
else if (value._bsontype === 'BSONRegExp') {
|
|
63852
|
-
index = serializeBSONRegExp(buffer, key, value, index);
|
|
63853
|
-
}
|
|
63854
|
-
else if (value._bsontype === 'Int32') {
|
|
63855
|
-
index = serializeInt32(buffer, key, value, index);
|
|
63856
|
-
}
|
|
63857
|
-
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
63858
|
-
index = serializeMinMax(buffer, key, value, index);
|
|
63859
|
-
}
|
|
63860
|
-
else if (typeof value._bsontype !== 'undefined') {
|
|
63861
|
-
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
63944
|
+
key = next.value[0];
|
|
63945
|
+
value = next.value[1];
|
|
63946
|
+
}
|
|
63947
|
+
else if (frame.keys !== null) {
|
|
63948
|
+
if (frame.keyIndex >= frame.keys.length) {
|
|
63949
|
+
buffer[index++] = 0x00;
|
|
63950
|
+
NumberUtils.setInt32LE(buffer, frame.objectSizeIndex, index - frame.objectSizeIndex);
|
|
63951
|
+
if (frame.codeSizeIndex !== null) {
|
|
63952
|
+
NumberUtils.setInt32LE(buffer, frame.codeSizeIndex, index - frame.codeSizeIndex);
|
|
63862
63953
|
}
|
|
63954
|
+
path.delete(frame.sourceObject);
|
|
63955
|
+
currentFrame = frame.prev;
|
|
63956
|
+
continue;
|
|
63863
63957
|
}
|
|
63864
|
-
|
|
63865
|
-
|
|
63866
|
-
}
|
|
63958
|
+
key = frame.keys[frame.keyIndex++];
|
|
63959
|
+
value = frame.iterTarget[key];
|
|
63867
63960
|
}
|
|
63868
|
-
|
|
63869
|
-
|
|
63870
|
-
|
|
63871
|
-
|
|
63872
|
-
|
|
63873
|
-
|
|
63874
|
-
|
|
63875
|
-
|
|
63961
|
+
else {
|
|
63962
|
+
const arr = frame.iterTarget;
|
|
63963
|
+
if (frame.keyIndex >= arr.length) {
|
|
63964
|
+
buffer[index++] = 0x00;
|
|
63965
|
+
NumberUtils.setInt32LE(buffer, frame.objectSizeIndex, index - frame.objectSizeIndex);
|
|
63966
|
+
if (frame.codeSizeIndex !== null) {
|
|
63967
|
+
NumberUtils.setInt32LE(buffer, frame.codeSizeIndex, index - frame.codeSizeIndex);
|
|
63968
|
+
}
|
|
63969
|
+
path.delete(frame.sourceObject);
|
|
63970
|
+
currentFrame = frame.prev;
|
|
63876
63971
|
continue;
|
|
63877
|
-
|
|
63878
|
-
|
|
63879
|
-
|
|
63880
|
-
|
|
63881
|
-
|
|
63882
|
-
|
|
63883
|
-
|
|
63884
|
-
|
|
63885
|
-
|
|
63972
|
+
}
|
|
63973
|
+
const i = frame.keyIndex++;
|
|
63974
|
+
key = String(i);
|
|
63975
|
+
value = arr[i];
|
|
63976
|
+
}
|
|
63977
|
+
if (typeof value?.toBSON === 'function') {
|
|
63978
|
+
value = value.toBSON();
|
|
63979
|
+
}
|
|
63980
|
+
if (!frame.isArray && typeof key === 'string' && !(key[0] === '$' && ignoreKeys.has(key))) {
|
|
63981
|
+
if (regexp.test(key)) {
|
|
63982
|
+
throw new BSONError('key ' + key + ' must not contain null bytes');
|
|
63983
|
+
}
|
|
63984
|
+
if (frame.checkKeys) {
|
|
63985
|
+
if ('$' === key[0]) {
|
|
63986
|
+
throw new BSONError('key ' + key + " must not start with '$'");
|
|
63886
63987
|
}
|
|
63887
|
-
if (
|
|
63888
|
-
|
|
63889
|
-
throw new BSONError('key ' + key + " must not start with '$'");
|
|
63890
|
-
}
|
|
63891
|
-
else if (key.includes('.')) {
|
|
63892
|
-
throw new BSONError('key ' + key + " must not contain '.'");
|
|
63893
|
-
}
|
|
63988
|
+
else if (key.includes('.')) {
|
|
63989
|
+
throw new BSONError('key ' + key + " must not contain '.'");
|
|
63894
63990
|
}
|
|
63895
63991
|
}
|
|
63896
|
-
|
|
63897
|
-
|
|
63898
|
-
|
|
63899
|
-
|
|
63900
|
-
else if (value === null) {
|
|
63992
|
+
}
|
|
63993
|
+
const type = typeof value;
|
|
63994
|
+
if (value === undefined) {
|
|
63995
|
+
if (frame.isArray || frame.ignoreUndefined === false) {
|
|
63901
63996
|
index = serializeNull(buffer, key, value, index);
|
|
63902
63997
|
}
|
|
63903
|
-
|
|
63904
|
-
|
|
63905
|
-
|
|
63906
|
-
|
|
63907
|
-
|
|
63908
|
-
|
|
63909
|
-
|
|
63910
|
-
|
|
63998
|
+
}
|
|
63999
|
+
else if (value === null) {
|
|
64000
|
+
index = serializeNull(buffer, key, value, index);
|
|
64001
|
+
}
|
|
64002
|
+
else if (type === 'string') {
|
|
64003
|
+
index = serializeString(buffer, key, value, index);
|
|
64004
|
+
}
|
|
64005
|
+
else if (type === 'number') {
|
|
64006
|
+
index = serializeNumber(buffer, key, value, index);
|
|
64007
|
+
}
|
|
64008
|
+
else if (type === 'bigint') {
|
|
64009
|
+
index = serializeBigInt(buffer, key, value, index);
|
|
64010
|
+
}
|
|
64011
|
+
else if (type === 'boolean') {
|
|
64012
|
+
index = serializeBoolean(buffer, key, value, index);
|
|
64013
|
+
}
|
|
64014
|
+
else if (type === 'object' && value._bsontype == null) {
|
|
64015
|
+
if (value instanceof Date || isDate(value)) {
|
|
64016
|
+
index = serializeDate(buffer, key, value, index);
|
|
63911
64017
|
}
|
|
63912
|
-
else if (
|
|
63913
|
-
index =
|
|
64018
|
+
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
64019
|
+
index = serializeBuffer(buffer, key, value, index);
|
|
63914
64020
|
}
|
|
63915
|
-
else if (
|
|
63916
|
-
|
|
63917
|
-
index = serializeDate(buffer, key, value, index);
|
|
63918
|
-
}
|
|
63919
|
-
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
63920
|
-
index = serializeBuffer(buffer, key, value, index);
|
|
63921
|
-
}
|
|
63922
|
-
else if (value instanceof RegExp || isRegExp(value)) {
|
|
63923
|
-
index = serializeRegExp(buffer, key, value, index);
|
|
63924
|
-
}
|
|
63925
|
-
else {
|
|
63926
|
-
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
63927
|
-
}
|
|
64021
|
+
else if (value instanceof RegExp || isRegExp(value)) {
|
|
64022
|
+
index = serializeRegExp(buffer, key, value, index);
|
|
63928
64023
|
}
|
|
63929
|
-
else
|
|
63930
|
-
if (value
|
|
63931
|
-
throw new
|
|
63932
|
-
}
|
|
63933
|
-
else if (value._bsontype === 'ObjectId') {
|
|
63934
|
-
index = serializeObjectId(buffer, key, value, index);
|
|
63935
|
-
}
|
|
63936
|
-
else if (value._bsontype === 'Decimal128') {
|
|
63937
|
-
index = serializeDecimal128(buffer, key, value, index);
|
|
63938
|
-
}
|
|
63939
|
-
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
63940
|
-
index = serializeLong(buffer, key, value, index);
|
|
63941
|
-
}
|
|
63942
|
-
else if (value._bsontype === 'Double') {
|
|
63943
|
-
index = serializeDouble(buffer, key, value, index);
|
|
63944
|
-
}
|
|
63945
|
-
else if (value._bsontype === 'Code') {
|
|
63946
|
-
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
63947
|
-
}
|
|
63948
|
-
else if (value._bsontype === 'Binary') {
|
|
63949
|
-
index = serializeBinary(buffer, key, value, index);
|
|
63950
|
-
}
|
|
63951
|
-
else if (value._bsontype === 'BSONSymbol') {
|
|
63952
|
-
index = serializeSymbol(buffer, key, value, index);
|
|
63953
|
-
}
|
|
63954
|
-
else if (value._bsontype === 'DBRef') {
|
|
63955
|
-
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
63956
|
-
}
|
|
63957
|
-
else if (value._bsontype === 'BSONRegExp') {
|
|
63958
|
-
index = serializeBSONRegExp(buffer, key, value, index);
|
|
63959
|
-
}
|
|
63960
|
-
else if (value._bsontype === 'Int32') {
|
|
63961
|
-
index = serializeInt32(buffer, key, value, index);
|
|
63962
|
-
}
|
|
63963
|
-
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
63964
|
-
index = serializeMinMax(buffer, key, value, index);
|
|
63965
|
-
}
|
|
63966
|
-
else if (typeof value._bsontype !== 'undefined') {
|
|
63967
|
-
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
64024
|
+
else {
|
|
64025
|
+
if (path.has(value)) {
|
|
64026
|
+
throw new BSONError('Cannot convert circular structure to BSON');
|
|
63968
64027
|
}
|
|
63969
|
-
|
|
63970
|
-
|
|
63971
|
-
index
|
|
63972
|
-
|
|
63973
|
-
|
|
63974
|
-
|
|
63975
|
-
|
|
63976
|
-
|
|
63977
|
-
object = object.toBSON();
|
|
63978
|
-
if (object != null && typeof object !== 'object') {
|
|
63979
|
-
throw new BSONError('toBSON function did not return an object');
|
|
64028
|
+
const nestedIsArray = Array.isArray(value);
|
|
64029
|
+
buffer[index++] = nestedIsArray ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
|
|
64030
|
+
index += ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
64031
|
+
buffer[index++] = 0x00;
|
|
64032
|
+
const nestedStartIndex = index;
|
|
64033
|
+
path.add(value);
|
|
64034
|
+
currentFrame = makeFrame(value, nestedStartIndex, null, frame, frame.checkKeys, frame.ignoreUndefined);
|
|
64035
|
+
index += 4;
|
|
63980
64036
|
}
|
|
63981
64037
|
}
|
|
63982
|
-
|
|
63983
|
-
|
|
63984
|
-
|
|
63985
|
-
value = value.toBSON();
|
|
64038
|
+
else if (type === 'object') {
|
|
64039
|
+
if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
64040
|
+
throw new BSONVersionError();
|
|
63986
64041
|
}
|
|
63987
|
-
const
|
|
63988
|
-
if (
|
|
63989
|
-
|
|
63990
|
-
|
|
63991
|
-
|
|
63992
|
-
|
|
63993
|
-
|
|
63994
|
-
|
|
63995
|
-
|
|
63996
|
-
|
|
63997
|
-
|
|
64042
|
+
const tag = value[bsonType];
|
|
64043
|
+
if (tag === 'ObjectId') {
|
|
64044
|
+
index = serializeObjectId(buffer, key, value, index);
|
|
64045
|
+
}
|
|
64046
|
+
else if (tag === 'Decimal128') {
|
|
64047
|
+
index = serializeDecimal128(buffer, key, value, index);
|
|
64048
|
+
}
|
|
64049
|
+
else if (tag === 'Long' || tag === 'Timestamp') {
|
|
64050
|
+
index = serializeLong(buffer, key, value, index);
|
|
64051
|
+
}
|
|
64052
|
+
else if (tag === 'Double') {
|
|
64053
|
+
index = serializeDouble(buffer, key, value, index);
|
|
64054
|
+
}
|
|
64055
|
+
else if (tag === 'Code') {
|
|
64056
|
+
const codeValue = value;
|
|
64057
|
+
if (codeValue.scope && typeof codeValue.scope === 'object') {
|
|
64058
|
+
buffer[index++] = BSON_DATA_CODE_W_SCOPE;
|
|
64059
|
+
index += ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
64060
|
+
buffer[index++] = 0x00;
|
|
64061
|
+
const codeTotalSizeIndex = index;
|
|
64062
|
+
index += 4;
|
|
64063
|
+
const functionString = codeValue.code;
|
|
64064
|
+
const codeSize = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
64065
|
+
NumberUtils.setInt32LE(buffer, index, codeSize);
|
|
64066
|
+
buffer[index + 4 + codeSize - 1] = 0;
|
|
64067
|
+
index = index + codeSize + 4;
|
|
64068
|
+
const scope = codeValue.scope;
|
|
64069
|
+
if (path.has(scope)) {
|
|
64070
|
+
throw new BSONError('Cannot convert circular structure to BSON');
|
|
63998
64071
|
}
|
|
64072
|
+
path.add(scope);
|
|
64073
|
+
currentFrame = makeFrame(scope, index, codeTotalSizeIndex, frame, frame.checkKeys, frame.ignoreUndefined);
|
|
64074
|
+
index += 4;
|
|
64075
|
+
}
|
|
64076
|
+
else {
|
|
64077
|
+
buffer[index++] = BSON_DATA_CODE;
|
|
64078
|
+
index += ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
64079
|
+
buffer[index++] = 0x00;
|
|
64080
|
+
const functionString = codeValue.code.toString();
|
|
64081
|
+
const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
64082
|
+
NumberUtils.setInt32LE(buffer, index, size);
|
|
64083
|
+
index = index + 4 + size - 1;
|
|
64084
|
+
buffer[index++] = 0;
|
|
63999
64085
|
}
|
|
64000
64086
|
}
|
|
64001
|
-
if (
|
|
64002
|
-
|
|
64003
|
-
index = serializeNull(buffer, key, value, index);
|
|
64087
|
+
else if (tag === 'Binary') {
|
|
64088
|
+
index = serializeBinary(buffer, key, value, index);
|
|
64004
64089
|
}
|
|
64005
|
-
else if (
|
|
64006
|
-
index =
|
|
64090
|
+
else if (tag === 'BSONSymbol') {
|
|
64091
|
+
index = serializeSymbol(buffer, key, value, index);
|
|
64007
64092
|
}
|
|
64008
|
-
else if (
|
|
64009
|
-
|
|
64093
|
+
else if (tag === 'DBRef') {
|
|
64094
|
+
const dbref = value;
|
|
64095
|
+
const orderedValues = Object.assign({ $ref: dbref.collection, $id: dbref.oid }, dbref.db != null ? { $db: dbref.db } : null, dbref.fields);
|
|
64096
|
+
buffer[index++] = BSON_DATA_OBJECT;
|
|
64097
|
+
index += ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
64098
|
+
buffer[index++] = 0x00;
|
|
64099
|
+
path.add(orderedValues);
|
|
64100
|
+
currentFrame = makeFrame(orderedValues, index, null, frame, false, true);
|
|
64101
|
+
index += 4;
|
|
64010
64102
|
}
|
|
64011
|
-
else if (
|
|
64012
|
-
index =
|
|
64103
|
+
else if (tag === 'BSONRegExp') {
|
|
64104
|
+
index = serializeBSONRegExp(buffer, key, value, index);
|
|
64013
64105
|
}
|
|
64014
|
-
else if (
|
|
64015
|
-
index =
|
|
64106
|
+
else if (tag === 'Int32') {
|
|
64107
|
+
index = serializeInt32(buffer, key, value, index);
|
|
64016
64108
|
}
|
|
64017
|
-
else if (
|
|
64018
|
-
index =
|
|
64109
|
+
else if (tag === 'MinKey' || tag === 'MaxKey') {
|
|
64110
|
+
index = serializeMinMax(buffer, key, value, index);
|
|
64019
64111
|
}
|
|
64020
|
-
else if (
|
|
64021
|
-
|
|
64022
|
-
index = serializeDate(buffer, key, value, index);
|
|
64023
|
-
}
|
|
64024
|
-
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
64025
|
-
index = serializeBuffer(buffer, key, value, index);
|
|
64026
|
-
}
|
|
64027
|
-
else if (value instanceof RegExp || isRegExp(value)) {
|
|
64028
|
-
index = serializeRegExp(buffer, key, value, index);
|
|
64029
|
-
}
|
|
64030
|
-
else {
|
|
64031
|
-
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
64032
|
-
}
|
|
64033
|
-
}
|
|
64034
|
-
else if (type === 'object') {
|
|
64035
|
-
if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
64036
|
-
throw new BSONVersionError();
|
|
64037
|
-
}
|
|
64038
|
-
else if (value._bsontype === 'ObjectId') {
|
|
64039
|
-
index = serializeObjectId(buffer, key, value, index);
|
|
64040
|
-
}
|
|
64041
|
-
else if (value._bsontype === 'Decimal128') {
|
|
64042
|
-
index = serializeDecimal128(buffer, key, value, index);
|
|
64043
|
-
}
|
|
64044
|
-
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
64045
|
-
index = serializeLong(buffer, key, value, index);
|
|
64046
|
-
}
|
|
64047
|
-
else if (value._bsontype === 'Double') {
|
|
64048
|
-
index = serializeDouble(buffer, key, value, index);
|
|
64049
|
-
}
|
|
64050
|
-
else if (value._bsontype === 'Code') {
|
|
64051
|
-
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
64052
|
-
}
|
|
64053
|
-
else if (value._bsontype === 'Binary') {
|
|
64054
|
-
index = serializeBinary(buffer, key, value, index);
|
|
64055
|
-
}
|
|
64056
|
-
else if (value._bsontype === 'BSONSymbol') {
|
|
64057
|
-
index = serializeSymbol(buffer, key, value, index);
|
|
64058
|
-
}
|
|
64059
|
-
else if (value._bsontype === 'DBRef') {
|
|
64060
|
-
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
64061
|
-
}
|
|
64062
|
-
else if (value._bsontype === 'BSONRegExp') {
|
|
64063
|
-
index = serializeBSONRegExp(buffer, key, value, index);
|
|
64064
|
-
}
|
|
64065
|
-
else if (value._bsontype === 'Int32') {
|
|
64066
|
-
index = serializeInt32(buffer, key, value, index);
|
|
64067
|
-
}
|
|
64068
|
-
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
64069
|
-
index = serializeMinMax(buffer, key, value, index);
|
|
64070
|
-
}
|
|
64071
|
-
else if (typeof value._bsontype !== 'undefined') {
|
|
64072
|
-
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
64073
|
-
}
|
|
64074
|
-
}
|
|
64075
|
-
else if (type === 'function' && serializeFunctions) {
|
|
64076
|
-
index = serializeFunction(buffer, key, value, index);
|
|
64112
|
+
else if (typeof value._bsontype !== 'undefined') {
|
|
64113
|
+
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
64077
64114
|
}
|
|
64078
64115
|
}
|
|
64116
|
+
else if (type === 'function' && serializeFunctions) {
|
|
64117
|
+
index = serializeFunction(buffer, key, value, index);
|
|
64118
|
+
}
|
|
64079
64119
|
}
|
|
64080
|
-
path.delete(object);
|
|
64081
|
-
buffer[index++] = 0x00;
|
|
64082
|
-
const size = index - startingIndex;
|
|
64083
|
-
startingIndex += NumberUtils.setInt32LE(buffer, startingIndex, size);
|
|
64084
64120
|
return index;
|
|
64085
64121
|
}
|
|
64086
64122
|
|
|
@@ -64363,21 +64399,22 @@ function parse(text, options) {
|
|
|
64363
64399
|
return deserializeValue(value, ejsonOptions);
|
|
64364
64400
|
});
|
|
64365
64401
|
}
|
|
64366
|
-
function stringify(value,
|
|
64367
|
-
if (
|
|
64368
|
-
options =
|
|
64369
|
-
|
|
64402
|
+
function stringify(value, replacerOrOptions, spaceOrOptions, options) {
|
|
64403
|
+
if (spaceOrOptions != null && typeof spaceOrOptions === 'object') {
|
|
64404
|
+
options = spaceOrOptions;
|
|
64405
|
+
spaceOrOptions = undefined;
|
|
64370
64406
|
}
|
|
64371
|
-
if (
|
|
64372
|
-
|
|
64373
|
-
|
|
64374
|
-
|
|
64407
|
+
if (replacerOrOptions != null &&
|
|
64408
|
+
typeof replacerOrOptions === 'object' &&
|
|
64409
|
+
!Array.isArray(replacerOrOptions)) {
|
|
64410
|
+
options = replacerOrOptions;
|
|
64411
|
+
replacerOrOptions = undefined;
|
|
64375
64412
|
}
|
|
64376
64413
|
const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, {
|
|
64377
64414
|
seenObjects: [{ propertyName: '(root)', obj: null }]
|
|
64378
64415
|
});
|
|
64379
64416
|
const doc = serializeValue(value, serializeOptions);
|
|
64380
|
-
return JSON.stringify(doc,
|
|
64417
|
+
return JSON.stringify(doc, replacerOrOptions, spaceOrOptions);
|
|
64381
64418
|
}
|
|
64382
64419
|
function EJSONserialize(value, options) {
|
|
64383
64420
|
options = options || {};
|
|
@@ -64539,7 +64576,7 @@ function serialize(object, options = {}) {
|
|
|
64539
64576
|
if (buffer.length < minInternalBufferSize) {
|
|
64540
64577
|
buffer = ByteUtils.allocate(minInternalBufferSize);
|
|
64541
64578
|
}
|
|
64542
|
-
const serializationIndex = serializeInto(buffer, object, checkKeys, 0,
|
|
64579
|
+
const serializationIndex = serializeInto(buffer, object, checkKeys, 0, serializeFunctions, ignoreUndefined, null);
|
|
64543
64580
|
const finishedBuffer = ByteUtils.allocateUnsafe(serializationIndex);
|
|
64544
64581
|
finishedBuffer.set(buffer.subarray(0, serializationIndex), 0);
|
|
64545
64582
|
return finishedBuffer;
|
|
@@ -64549,7 +64586,7 @@ function serializeWithBufferAndIndex(object, finalBuffer, options = {}) {
|
|
|
64549
64586
|
const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
64550
64587
|
const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
64551
64588
|
const startIndex = typeof options.index === 'number' ? options.index : 0;
|
|
64552
|
-
const serializationIndex = serializeInto(buffer, object, checkKeys, 0,
|
|
64589
|
+
const serializationIndex = serializeInto(buffer, object, checkKeys, 0, serializeFunctions, ignoreUndefined, null);
|
|
64553
64590
|
finalBuffer.set(buffer.subarray(0, serializationIndex), startIndex);
|
|
64554
64591
|
return startIndex + serializationIndex - 1;
|
|
64555
64592
|
}
|
|
@@ -65725,7 +65762,7 @@ var src_default = VueToastificationPlugin;
|
|
|
65725
65762
|
(module) {
|
|
65726
65763
|
|
|
65727
65764
|
"use strict";
|
|
65728
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.5.
|
|
65765
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.5.9","description":"AI-Powered Data Workspace for MongoDB: Turn your MongoDB data into dashboards, maps, and interactive workflows - powered by your Mongoose models and AI.","homepage":"https://mongoosestudio.app/","repository":{"type":"git","url":"https://github.com/mongoosejs/studio"},"license":"Apache-2.0","dependencies":{"@ai-sdk/anthropic":"2.x","@ai-sdk/google":"2.x","@ai-sdk/openai":"2.x","ace-builds":"^1.43.6","ai":"5.x","archetype":"0.13.1","csv-stringify":"6.3.0","ejson":"^2.2.3","extrovert":"^0.2.0","marked":"15.0.12","mpath":"^0.9.0","node-inspect-extracted":"3.x","regexp.escape":"^2.0.1","tailwindcss":"3.4.0","time-commando":"1.0.1","typescript":"^6.0.2","vue":"3.x","vue-toastification":"^2.0.0-rc.5","webpack":"5.x","xss":"^1.0.15"},"peerDependencies":{"@nestjs/common":"10.x || 11.x","mongoose":"7.x || 8.x || ^9.0.0"},"peerDependenciesMeta":{"@nestjs/common":{"optional":true}},"optionalPeerDependencies":{"@mongoosejs/task":"0.5.x || 0.6.x"},"devDependencies":{"@masteringjs/eslint-config":"0.1.1","axios":"1.2.2","dedent":"^1.6.0","eslint":"9.30.0","@nestjs/common":"^11.1.9","express":"4.x","mocha":"10.2.0","mongodb-memory-server":"^11.0.1","mongoose":"9.x","sinon":"^21.0.1"},"scripts":{"lint":"eslint .","seed":"node seed/index.js","start":"node ./local.js","tailwind":"tailwindcss -o ./frontend/public/tw.css","tailwind:watch":"tailwindcss -o ./frontend/public/tw.css --watch","test":"mocha test/*.test.js","test:frontend":"mocha test/frontend/*.test.js","eval:agent":"node eval/agent/run.js"}}');
|
|
65729
65766
|
|
|
65730
65767
|
/***/ }
|
|
65731
65768
|
|