@mongoosejs/studio 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/backend/actions/Dashboard/getDashboard.js +18 -0
  2. package/backend/actions/Dashboard/getDashboards.js +10 -0
  3. package/backend/actions/Dashboard/index.js +5 -0
  4. package/backend/actions/Dashboard/updateDashboard.js +25 -0
  5. package/backend/actions/Model/createDocument.js +28 -0
  6. package/backend/actions/Model/getDocuments.js +2 -1
  7. package/backend/actions/Model/index.js +1 -0
  8. package/backend/actions/Model/listModels.js +3 -1
  9. package/backend/actions/Model/updateDocument.js +1 -1
  10. package/backend/actions/index.js +1 -0
  11. package/backend/db/dashboardSchema.js +16 -0
  12. package/backend/index.js +9 -1
  13. package/frontend/public/app.js +1172 -473
  14. package/frontend/public/images/json.svg +2 -0
  15. package/frontend/public/images/table.svg +1 -0
  16. package/frontend/public/index.html +3 -0
  17. package/frontend/public/tw.css +298 -18
  18. package/frontend/src/api.js +28 -0
  19. package/frontend/src/create-document/create-document.css +0 -0
  20. package/frontend/src/create-document/create-document.html +25 -0
  21. package/frontend/src/create-document/create-document.js +61 -0
  22. package/frontend/src/dashboard/dashboard.html +17 -0
  23. package/frontend/src/dashboard/dashboard.js +36 -0
  24. package/frontend/src/dashboard/edit-dashboard/edit-dashboard.html +5 -0
  25. package/frontend/src/dashboard/edit-dashboard/edit-dashboard.js +48 -0
  26. package/frontend/src/dashboards/dashboards.html +5 -0
  27. package/frontend/src/dashboards/dashboards.js +20 -0
  28. package/frontend/src/document/document.html +5 -4
  29. package/frontend/src/document/document.js +7 -1
  30. package/frontend/src/edit-array/edit-array.html +1 -7
  31. package/frontend/src/edit-array/edit-array.js +27 -9
  32. package/frontend/src/edit-date/edit-date.html +18 -1
  33. package/frontend/src/edit-date/edit-date.js +12 -0
  34. package/frontend/src/edit-default/edit-default.html +1 -1
  35. package/frontend/src/index.js +5 -0
  36. package/frontend/src/list-json/list-json.css +3 -0
  37. package/frontend/src/list-json/list-json.html +4 -0
  38. package/frontend/src/list-json/list-json.js +40 -0
  39. package/frontend/src/models/models.css +2 -8
  40. package/frontend/src/models/models.html +42 -10
  41. package/frontend/src/models/models.js +22 -1
  42. package/frontend/src/navbar/navbar.css +9 -0
  43. package/frontend/src/navbar/navbar.html +11 -3
  44. package/frontend/src/navbar/navbar.js +6 -1
  45. package/frontend/src/routes.js +10 -0
  46. package/mongoosejs-studio-0.0.16.tgz +0 -0
  47. package/package.json +2 -2
  48. package/tailwind.config.js +27 -1
  49. package/frontend/dist/app.js +0 -160
  50. package/frontend/dist/tw.css +0 -595
  51. package/logs/COUNT_20230524-154120-151469/operation.log +0 -8
  52. package/logs/COUNT_20230524-154408-077670/operation.log +0 -22
  53. package/logs/COUNT_20230524-154414-431706/operation.log +0 -8
  54. package/logs/COUNT_20230524-155000-297076/operation.log +0 -8
  55. package/logs/LOAD_20230524-155832-351763/checkpoint.csv +0 -1
  56. package/logs/LOAD_20230524-155832-351763/operation.log +0 -23
@@ -29,10 +29,24 @@ if (typeof config__setAuthorizationHeaderFrom === 'string' && config__setAuthori
29
29
  }
30
30
 
31
31
  if (false) {} else {
32
+ exports.Dashboard = {
33
+ getDashboard: function getDashboard(params) {
34
+ return client.get('/Dashboard/getDashboard', params).then(res => res.data);
35
+ },
36
+ getDashboards: function getDashboards(params) {
37
+ return client.get('/Dashboard/getDashboards', params).then(res => res.data);
38
+ },
39
+ updateDashboard: function updateDashboard(params) {
40
+ return client.post('/Dashboard/updateDashboard', params).then(res => res.data);
41
+ }
42
+ }
32
43
  exports.Model = {
33
44
  createChart: function (params) {
34
45
  return client.post('/Model/createChart', params).then(res => res.data);
35
46
  },
47
+ createDocument: function(params) {
48
+ return client.post('/Model/createDocument', params).then(res => res.data);
49
+ },
36
50
  deleteDocument: function (params) {
37
51
  return client.post('/Model/deleteDocument', params).then(res => res.data);
38
52
  },
@@ -162,6 +176,214 @@ module.exports = app => app.component('charts', {
162
176
  }
163
177
  });
164
178
 
179
+ /***/ }),
180
+
181
+ /***/ "./frontend/src/create-document/create-document.js":
182
+ /*!*********************************************************!*\
183
+ !*** ./frontend/src/create-document/create-document.js ***!
184
+ \*********************************************************/
185
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
186
+
187
+ "use strict";
188
+
189
+
190
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
191
+
192
+ const { BSON, EJSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
193
+
194
+ const ObjectId = new Proxy(BSON.ObjectId, {
195
+ apply (target, thisArg, argumentsList) {
196
+ return new target(...argumentsList);
197
+ }
198
+ });
199
+
200
+ const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js");
201
+
202
+ appendCSS(__webpack_require__(/*! ./create-document.css */ "./frontend/src/create-document/create-document.css"));
203
+
204
+ const template = __webpack_require__(/*! ./create-document.html */ "./frontend/src/create-document/create-document.html")
205
+
206
+ module.exports = app => app.component('create-document', {
207
+ props: ['currentModel', 'paths'],
208
+ template,
209
+ data: function() {
210
+ return {
211
+ documentData: '',
212
+ editor: null,
213
+ errors: []
214
+ }
215
+ },
216
+ methods: {
217
+ async createDocument() {
218
+ const data = EJSON.serialize(eval(`(${this.editor.getValue()})`));
219
+ const { doc } = await api.Model.createDocument({ model: this.currentModel, data }).catch(err => {
220
+ if (err.response?.data?.message) {
221
+ console.log(err.response.data);
222
+ const message = err.response.data.message.split(": ").slice(1).join(": ");
223
+ this.errors = message.split(',').map(error => {
224
+ return error.split(': ').slice(1).join(': ').trim();
225
+ })
226
+ throw new Error(err.response?.data?.message);
227
+ }
228
+ throw err;
229
+ });
230
+ this.errors.length = 0;
231
+ this.$emit('close', doc);
232
+ },
233
+ },
234
+ mounted: function() {
235
+ const requiredPaths = this.paths.filter(x => x.required);
236
+ this.documentData = `{\n`;
237
+ for (let i = 0; i < requiredPaths.length; i++) {
238
+ const isLast = i + 1 >= requiredPaths.length;
239
+ this.documentData += ` ${requiredPaths[i].path}: ${isLast ? '': ','}\n`
240
+ }
241
+ this.documentData += '}';
242
+ this.$refs.codeEditor.value = this.documentData;
243
+ this.editor = CodeMirror.fromTextArea(this.$refs.codeEditor, {
244
+ mode: 'javascript',
245
+ lineNumbers: true
246
+ });
247
+ },
248
+ })
249
+
250
+ /***/ }),
251
+
252
+ /***/ "./frontend/src/dashboard/dashboard.js":
253
+ /*!*********************************************!*\
254
+ !*** ./frontend/src/dashboard/dashboard.js ***!
255
+ \*********************************************/
256
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
257
+
258
+ "use strict";
259
+
260
+
261
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
262
+ const template = __webpack_require__(/*! ./dashboard.html */ "./frontend/src/dashboard/dashboard.html");
263
+
264
+ module.exports = app => app.component('dashboard', {
265
+ template: template,
266
+ data: function() {
267
+ return {
268
+ status: 'loading',
269
+ code: '',
270
+ name: '',
271
+ showEditor: false,
272
+ dashboard: null
273
+ }
274
+ },
275
+ methods: {
276
+ toggleEditor() {
277
+ this.showEditor = !this.showEditor;
278
+ },
279
+ async updateCode(update) {
280
+ this.code = update;
281
+ }
282
+ },
283
+ mounted: async function() {
284
+ const dashboardId = this.$route.query.dashboardId;
285
+ const { dashboard } = await api.Dashboard.getDashboard({ params: { dashboardId: dashboardId } });
286
+ if (!dashboard) {
287
+ return;
288
+ }
289
+ this.dashboard = dashboard;
290
+ this.name = this.dashboard.name;
291
+ this.code = this.dashboard.code;
292
+ this.status = 'loaded';
293
+ }
294
+ });
295
+
296
+
297
+ /***/ }),
298
+
299
+ /***/ "./frontend/src/dashboard/edit-dashboard/edit-dashboard.js":
300
+ /*!*****************************************************************!*\
301
+ !*** ./frontend/src/dashboard/edit-dashboard/edit-dashboard.js ***!
302
+ \*****************************************************************/
303
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
304
+
305
+ "use strict";
306
+
307
+
308
+ const api = __webpack_require__(/*! ../../api */ "./frontend/src/api.js");
309
+ const template = __webpack_require__(/*! ./edit-dashboard.html */ "./frontend/src/dashboard/edit-dashboard/edit-dashboard.html");
310
+
311
+ module.exports = app => app.component('edit-dashboard', {
312
+ template: template,
313
+ props: ['dashboardId', 'code'],
314
+ data: function() {
315
+ return {
316
+ status: 'loading',
317
+ editor: null,
318
+ }
319
+ },
320
+ methods: {
321
+ closeEditor() {
322
+ this.$emit('close')
323
+ },
324
+ async updateCode() {
325
+ const { doc } = await api.Dashboard.updateDashboard({ dashboardId: this.dashboardId, code: this.editor.getValue() });
326
+ this.$emit('update', doc.code);
327
+ this.editor.setValue(doc.code);
328
+ this.closeEditor();
329
+ }
330
+ },
331
+ mounted: async function() {
332
+ this.editor = CodeMirror.fromTextArea(this.$refs.codeEditor, {
333
+ mode: 'javascript',
334
+ lineNumbers: true,
335
+ indentUnit: 4,
336
+ smartIndent: true,
337
+ tabsize: 4,
338
+ indentWithTabs: true,
339
+ cursorBlinkRate: 300,
340
+ lineWrapping: true,
341
+ showCursorWhenSelecting: true,
342
+ });
343
+ // this.editor.setValue(this.code);
344
+ // this.editor.setSize(300, 300); // Ensure the editor has a fixed height
345
+
346
+ // this.editor.setCursor(this.editor.lineCount() - 1, this.editor.getLine(this.editor.lineCount() - 1).length);
347
+
348
+ this.editor.focus();
349
+ // this.editor.refresh(); // if anything weird happens on load, this usually fixes it. However, this breaks it in this case.
350
+
351
+
352
+ }
353
+ });
354
+
355
+
356
+ /***/ }),
357
+
358
+ /***/ "./frontend/src/dashboards/dashboards.js":
359
+ /*!***********************************************!*\
360
+ !*** ./frontend/src/dashboards/dashboards.js ***!
361
+ \***********************************************/
362
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
363
+
364
+ "use strict";
365
+
366
+
367
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
368
+ const template = __webpack_require__(/*! ./dashboards.html */ "./frontend/src/dashboards/dashboards.html");
369
+
370
+
371
+ module.exports = app => app.component('dashboards', {
372
+ template: template,
373
+ data: () => ({
374
+ dashboards: [],
375
+ }),
376
+ async mounted() {
377
+ const { dashboards } = await api.Dashboard.getDashboards();
378
+ this.dashboards = dashboards;
379
+ if (!this.$route.query.dashboardId) {
380
+ return;
381
+ }
382
+ this.status = 'loaded';
383
+ },
384
+ });
385
+
386
+
165
387
  /***/ }),
166
388
 
167
389
  /***/ "./frontend/src/detail-array/detail-array.js":
@@ -245,11 +467,14 @@ module.exports = app => app.component('document', {
245
467
  status: 'init',
246
468
  document: null,
247
469
  changes: {},
470
+ invalid: {},
248
471
  editting: false,
249
- virtuals: []
472
+ virtuals: [],
250
473
  }),
251
474
  async mounted() {
475
+ window.pageState = this;
252
476
  const { doc, schemaPaths } = await api.Model.getDocument({ model: this.model, documentId: this.documentId });
477
+ window.doc = doc;
253
478
  this.document = doc;
254
479
  this.schemaPaths = await Object.keys(schemaPaths).sort((k1, k2) => {
255
480
  if (k1 === '_id' && k2 !== '_id') {
@@ -302,6 +527,9 @@ module.exports = app => app.component('document', {
302
527
  this.editting = false;
303
528
  },
304
529
  async save() {
530
+ if (Object.keys(this.invalid).length > 0) {
531
+ throw new Error('Invalid paths: ' + Object.keys(this.invalid).join(', '));
532
+ }
305
533
  const { doc } = await api.Model.updateDocument({
306
534
  model: this.model,
307
535
  _id: this.document._id,
@@ -345,6 +573,14 @@ module.exports = app => app.component('document', {
345
573
 
346
574
  const template = __webpack_require__(/*! ./edit-array.html */ "./frontend/src/edit-array/edit-array.html");
347
575
 
576
+ const { BSON, EJSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
577
+
578
+ const ObjectId = new Proxy(BSON.ObjectId, {
579
+ apply (target, thisArg, argumentsList) {
580
+ return new target(...argumentsList);
581
+ }
582
+ });
583
+
348
584
  const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js");
349
585
  appendCSS(__webpack_require__(/*! ./edit-array.css */ "./frontend/src/edit-array/edit-array.css"));
350
586
 
@@ -353,18 +589,28 @@ module.exports = app => app.component('edit-array', {
353
589
  props: ['value'],
354
590
  data: () => ({ currentValue: null }),
355
591
  mounted() {
356
- this.currentValue = this.value;
592
+ this.currentValue = JSON.stringify(this.value, null, ' ').trim();
593
+ this.$refs.arrayEditor.value = this.currentValue;
594
+ this.editor = CodeMirror.fromTextArea(this.$refs.arrayEditor, {
595
+ mode: 'javascript',
596
+ lineNumbers: true
597
+ });
357
598
  },
358
- methods: {
359
- onUpdate() {
360
- this.$emit('input', this.currentValue);
361
- },
362
- removeValue(i) {
363
- this.currentValue.splice(i, 1);
364
- this.$emit('input', this.currentValue);
599
+ watch: {
600
+ currentValue() {
601
+ try {
602
+ this.$emit('input', eval(this.currentValue));
603
+ } catch (err) {
604
+ this.$emit('error', err);
605
+ }
606
+ }
607
+ },
608
+ beforeDestroy() {
609
+ if (this.editor) {
610
+ this.editor.toTextArea();
365
611
  }
366
612
  },
367
- emits: ['input']
613
+ emits: ['input', 'error']
368
614
  });
369
615
 
370
616
 
@@ -385,6 +631,11 @@ module.exports = app => app.component('edit-date', {
385
631
  template: template,
386
632
  props: ['value'],
387
633
  emits: ['input'],
634
+ data: function() {
635
+ return {
636
+ inputType: 'picker' // picker, iso
637
+ }
638
+ },
388
639
  computed: {
389
640
  valueAsLocalString() {
390
641
  if (this.value == null) {
@@ -402,6 +653,13 @@ module.exports = app => app.component('edit-date', {
402
653
  ':',
403
654
  date.getMinutes().toString().padStart(2, '0')
404
655
  ].join('');
656
+ },
657
+ valueAsISOString() {
658
+ if (this.value == null) {
659
+ return this.value;
660
+ }
661
+ const date = new Date(this.value);
662
+ return date.toISOString();
405
663
  }
406
664
  }
407
665
  });
@@ -604,6 +862,57 @@ module.exports = app => app.component('list-default', {
604
862
  }
605
863
  });
606
864
 
865
+ /***/ }),
866
+
867
+ /***/ "./frontend/src/list-json/list-json.js":
868
+ /*!*********************************************!*\
869
+ !*** ./frontend/src/list-json/list-json.js ***!
870
+ \*********************************************/
871
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
872
+
873
+ "use strict";
874
+
875
+
876
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
877
+ const template = __webpack_require__(/*! ./list-json.html */ "./frontend/src/list-json/list-json.html");
878
+
879
+ const vanillatoast = __webpack_require__(/*! vanillatoasts */ "./node_modules/vanillatoasts/vanillatoasts.js");
880
+
881
+ __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js")(__webpack_require__(/*! ./list-json.css */ "./frontend/src/list-json/list-json.css"));
882
+
883
+ module.exports = app => app.component('list-json', {
884
+ template: template,
885
+ props: ['value'],
886
+ computed: {
887
+ shortenValue() {
888
+ return JSON.stringify(this.value, null, 4);
889
+ }
890
+ },
891
+ methods: {
892
+ copyText(value) {
893
+ const storage = document.createElement('textarea');
894
+ storage.value = JSON.stringify(value);
895
+ const elem = this.$refs.JSONCode;
896
+ elem.appendChild(storage);
897
+ storage.select();
898
+ storage.setSelectionRange(0, 99999);
899
+ document.execCommand('copy');
900
+ elem.removeChild(storage);
901
+ vanillatoast.create({
902
+ title: 'Text copied!',
903
+ type: 'success',
904
+ timeout: 3000,
905
+ icon: 'images/success.png',
906
+ positionClass: 'bottomRight'
907
+ });
908
+ }
909
+ },
910
+ mounted: function() {
911
+ Prism.highlightElement(this.$refs.JSONCode);
912
+ }
913
+ });
914
+
915
+
607
916
  /***/ }),
608
917
 
609
918
  /***/ "./frontend/src/list-mixed/list-mixed.js":
@@ -794,6 +1103,8 @@ const template = __webpack_require__(/*! ./models.html */ "./frontend/src/models
794
1103
  const mpath = __webpack_require__(/*! mpath */ "./node_modules/mpath/index.js");
795
1104
  const { BSON, EJSON } = __webpack_require__(/*! bson */ "./node_modules/bson/lib/bson.cjs");
796
1105
 
1106
+
1107
+
797
1108
  const ObjectId = new Proxy(BSON.ObjectId, {
798
1109
  apply (target, thisArg, argumentsList) {
799
1110
  return new target(...argumentsList);
@@ -802,6 +1113,7 @@ const ObjectId = new Proxy(BSON.ObjectId, {
802
1113
 
803
1114
  const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js");
804
1115
 
1116
+
805
1117
  appendCSS(__webpack_require__(/*! ./models.css */ "./frontend/src/models/models.css"));
806
1118
 
807
1119
  const limit = 50;
@@ -824,12 +1136,14 @@ module.exports = app => app.component('models', {
824
1136
  filter: null,
825
1137
  searchText: '',
826
1138
  shouldShowExportModal: false,
1139
+ shouldShowCreateModal: false,
827
1140
  shouldShowFieldModal: false,
828
1141
  shouldExport: {},
829
1142
  sortBy: {},
830
1143
  query: {},
831
1144
  scrollHeight: 0,
832
- interval: null
1145
+ interval: null,
1146
+ outputType: 'table' // json, table
833
1147
  }),
834
1148
  created() {
835
1149
  this.currentModel = this.model;
@@ -866,9 +1180,25 @@ module.exports = app => app.component('models', {
866
1180
  this.filteredPaths = this.filteredPaths.filter(x => filter.includes(x.path))
867
1181
  }
868
1182
 
1183
+
869
1184
  this.status = 'loaded';
870
1185
  },
871
1186
  methods: {
1187
+ async closeCreationModal() {
1188
+ this.shouldShowCreateModal = false;
1189
+ await this.getDocuments();
1190
+ },
1191
+ initializeDocumentData() {
1192
+ this.shouldShowCreateModal = true;
1193
+ },
1194
+ filterDocument(doc) {
1195
+ const filteredDoc = {};
1196
+ console.log(doc, this.filteredPaths)
1197
+ for (let i = 0; i < this.filteredPaths.length; i++) {
1198
+ filteredDoc[this.filteredPaths[i].path] = doc[this.filteredPaths[i].path];
1199
+ }
1200
+ return filteredDoc;
1201
+ },
872
1202
  async onScroll() {
873
1203
  if (this.status === 'loading' || this.loadedAllDocs) {
874
1204
  return;
@@ -1054,7 +1384,12 @@ const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/append
1054
1384
  appendCSS(__webpack_require__(/*! ./navbar.css */ "./frontend/src/navbar/navbar.css"));
1055
1385
 
1056
1386
  module.exports = app => app.component('navbar', {
1057
- template: template
1387
+ template: template,
1388
+ computed: {
1389
+ routeName() {
1390
+ return this.$route.name;
1391
+ }
1392
+ }
1058
1393
  });
1059
1394
 
1060
1395
  /***/ }),
@@ -1088,6 +1423,16 @@ module.exports = [
1088
1423
  path: '/model/:model/document/:documentId',
1089
1424
  name: 'document',
1090
1425
  component: 'document'
1426
+ },
1427
+ {
1428
+ path: '/dashboards',
1429
+ name: 'dashboards',
1430
+ component: 'dashboards'
1431
+ },
1432
+ {
1433
+ path: '/dashboard',
1434
+ name: 'dashboard',
1435
+ component: 'dashboard'
1091
1436
  }
1092
1437
  ];
1093
1438
 
@@ -1716,6 +2061,61 @@ module.exports = "<div class=\"charts\">\n <h1>Charts</h1>\n <div>\n Descri
1716
2061
 
1717
2062
  /***/ }),
1718
2063
 
2064
+ /***/ "./frontend/src/create-document/create-document.css":
2065
+ /*!**********************************************************!*\
2066
+ !*** ./frontend/src/create-document/create-document.css ***!
2067
+ \**********************************************************/
2068
+ /***/ ((module) => {
2069
+
2070
+ "use strict";
2071
+ module.exports = "";
2072
+
2073
+ /***/ }),
2074
+
2075
+ /***/ "./frontend/src/create-document/create-document.html":
2076
+ /*!***********************************************************!*\
2077
+ !*** ./frontend/src/create-document/create-document.html ***!
2078
+ \***********************************************************/
2079
+ /***/ ((module) => {
2080
+
2081
+ "use strict";
2082
+ module.exports = "<div>\n <div class=\"mb-2\">\n <textarea class=\"border border-gray-200 p-2 h-[300px] w-full\" ref=\"codeEditor\"></textarea>\n </div>\n <button @click=\"createDocument()\" class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">Submit</button>\n <div v-if=\"errors.length > 0\" class=\"rounded-md bg-red-50 p-4 mt-1\">\n <div class=\"flex\">\n <div class=\"flex-shrink-0\">\n <svg class=\"h-5 w-5 text-red-400\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\">\n <path fill-rule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z\" clip-rule=\"evenodd\" />\n </svg>\n </div>\n <div class=\"ml-3\">\n <h3 class=\"text-sm font-medium text-red-800\">There were {{errors.length}} errors with your submission</h3>\n <div class=\"mt-2 text-sm text-red-700\">\n <ul role=\"list\" class=\"list-disc space-y-1 pl-5\">\n <li v-for=\"error in errors\">\n {{error}}\n </li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n</div>";
2083
+
2084
+ /***/ }),
2085
+
2086
+ /***/ "./frontend/src/dashboard/dashboard.html":
2087
+ /*!***********************************************!*\
2088
+ !*** ./frontend/src/dashboard/dashboard.html ***!
2089
+ \***********************************************/
2090
+ /***/ ((module) => {
2091
+
2092
+ "use strict";
2093
+ module.exports = "<div class=\"dashboard\">\n <div v-if=\"dashboard\">\n <div>\n <h2>{{name}}</h2>\n </div>\n <div>\n <pre>{{code}}</pre>\n <button v-if=\"!showEditor\" @click=\"toggleEditor\" style=\"color: black;margin-right: 0.5em\">Edit</button>\n </div>\n <div v-if=\"showEditor\">\n <edit-dashboard :dashboardId=\"dashboard._id\" :code=\"code\" @close=\"showEditor=false;\" @update=\"updateCode\"></edit-dashboard>\n </div>\n </div>\n <div v-if=\"!dashboard && status === 'loaded'\">\n No dashboard with the given id could be found.\n </div>\n</div>";
2094
+
2095
+ /***/ }),
2096
+
2097
+ /***/ "./frontend/src/dashboard/edit-dashboard/edit-dashboard.html":
2098
+ /*!*******************************************************************!*\
2099
+ !*** ./frontend/src/dashboard/edit-dashboard/edit-dashboard.html ***!
2100
+ \*******************************************************************/
2101
+ /***/ ((module) => {
2102
+
2103
+ "use strict";
2104
+ module.exports = "<div>\n <textarea ref=\"codeEditor\">{{code}}</textarea>\n <button @click=\"updateCode\" style=\"color: black;margin-right: 0.5em\">Submit</button>\n <button @click=\"closeEditor\" class=\"gray\" style=\"margin-right: 0.5em\">Cancel</button>\n</div>";
2105
+
2106
+ /***/ }),
2107
+
2108
+ /***/ "./frontend/src/dashboards/dashboards.html":
2109
+ /*!*************************************************!*\
2110
+ !*** ./frontend/src/dashboards/dashboards.html ***!
2111
+ \*************************************************/
2112
+ /***/ ((module) => {
2113
+
2114
+ "use strict";
2115
+ module.exports = "<div class=\"dashboards\">\n <div v-for=\"dashboard in dashboards\" :key=\"dashboard._id\" @click=\"$router.push('dashboard?dashboardId=' + dashboard._id)\">\n {{dashboard.name}}, ID: {{ dashboard._id }}\n </div>\n</div>";
2116
+
2117
+ /***/ }),
2118
+
1719
2119
  /***/ "./frontend/src/detail-array/detail-array.html":
1720
2120
  /*!*****************************************************!*\
1721
2121
  !*** ./frontend/src/detail-array/detail-array.html ***!
@@ -1756,7 +2156,7 @@ module.exports = ".document {\n max-width: 1200px;\n margin-left: auto;\n mar
1756
2156
  /***/ ((module) => {
1757
2157
 
1758
2158
  "use strict";
1759
- module.exports = "<div class=\"document\">\n <div class=\"document-menu\">\n <div class=\"left\">\n <button @click=\"$router.push('/model/' + this.model)\">\n &lsaquo; Back\n </button>\n </div>\n\n <div class=\"right\">\n <button\n v-if=\"!editting\"\n @click=\"editting = true\"\n type=\"button\"\n class=\"rounded-md bg-puerto-rico-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-puerto-rico-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-puerto-rico-600\">\n <img src=\"images/edit.svg\" class=\"inline\" /> Edit\n </button>\n <button\n v-if=\"editting\"\n @click=\"save\"\n type=\"button\"\n class=\"rounded-md bg-slate-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-600\">\n &times; Cancel\n </button>\n <button\n v-if=\"editting\"\n @click=\"save\"\n type=\"button\"\n class=\"rounded-md bg-green-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-green-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-600\">\n <img src=\"images/save.svg\" class=\"inline\" /> Save\n </button>\n <button\n @click=\"remove\"\n type=\"button\"\n class=\"rounded-md bg-red-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600\">\n <img src=\"images/delete.svg\" class=\"inline\" /> Delete\n </button>\n </div>\n </div>\n <div v-if=\"status === 'loaded'\">\n <div v-for=\"path in schemaPaths\" class=\"value\">\n <div class=\"path-key\">\n {{path.path}}\n <span class=\"path-type\">\n ({{(path.instance || 'unknown').toLowerCase()}})\n </span>\n </div>\n <div v-if=\"editting && path.path !== '_id'\">\n <component\n :is=\"getEditComponentForPath(path)\"\n :value=\"getEditValueForPath(path)\"\n @input=\"changes[path.path] = $event;\"\n >\n </component>\n </div>\n <div v-else>\n <component :is=\"getComponentForPath(path)\" :value=\"getValueForPath(path.path)\"></component>\n </div>\n </div>\n <div v-for=\"path in virtuals\" class=\"mb-2\">\n <div class=\"p-1 mb-1 bg-slate-100\">\n {{path.name}}\n <span class=\"path-type\">\n (virtual)\n </span>\n </div>\n <div v-if=\"path.value == null\" class=\"text-sky-800\">\n {{'' + path.value}}\n </div>\n <div v-else>\n {{path.value}}\n </div>\n </div>\n </div>\n</div>\n";
2159
+ module.exports = "<div class=\"document\">\n <div class=\"document-menu\">\n <div class=\"left\">\n <button @click=\"$router.push('/model/' + this.model)\">\n &lsaquo; Back\n </button>\n </div>\n\n <div class=\"right\">\n <button\n v-if=\"!editting\"\n @click=\"editting = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline\" /> Edit\n </button>\n <button\n v-if=\"editting\"\n @click=\"editting = false\"\n type=\"button\"\n class=\"rounded-md bg-slate-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-slate-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-600\">\n &times; Cancel\n </button>\n <button\n v-if=\"editting\"\n @click=\"save\"\n type=\"button\"\n class=\"rounded-md bg-green-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-green-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-600\">\n <img src=\"images/save.svg\" class=\"inline\" /> Save\n </button>\n <button\n @click=\"remove\"\n type=\"button\"\n class=\"rounded-md bg-red-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-600\">\n <img src=\"images/delete.svg\" class=\"inline\" /> Delete\n </button>\n </div>\n </div>\n <div v-if=\"status === 'loaded'\">\n <div v-for=\"path in schemaPaths\" class=\"value\">\n <div class=\"path-key\">\n {{path.path}}\n <span class=\"path-type\">\n ({{(path.instance || 'unknown').toLowerCase()}})\n </span> \n </div>\n <div v-if=\"editting && path.path !== '_id'\">\n <component\n :is=\"getEditComponentForPath(path)\"\n :value=\"getEditValueForPath(path)\"\n @input=\"changes[path.path] = $event; delete invalid[path.path];\"\n @error=\"invalid[path.path] = $event;\"\n >\n </component>\n </div>\n <div v-else>\n <component :is=\"getComponentForPath(path)\" :value=\"getValueForPath(path.path)\"></component>\n </div>\n </div>\n <div v-for=\"path in virtuals\" class=\"mb-2\">\n <div class=\"p-1 mb-1 bg-slate-100\">\n {{path.name}}\n <span class=\"path-type\">\n (virtual)\n </span>\n </div>\n <div v-if=\"path.value == null\" class=\"text-sky-800\">\n {{'' + path.value}}\n </div>\n <div v-else>\n {{path.value}}\n </div>\n </div>\n </div>\n</div>\n";
1760
2160
 
1761
2161
  /***/ }),
1762
2162
 
@@ -1778,7 +2178,7 @@ module.exports = ".edit-array button {\n margin-top: 0.5em;\n}";
1778
2178
  /***/ ((module) => {
1779
2179
 
1780
2180
  "use strict";
1781
- module.exports = "<div class=\"edit-array\">\n <div v-for=\"(el, i) in currentValue\">\n <input type=\"text\" :value=\"el\" @input=\"currentValue[i] = $event.target.value; onUpdate()\">\n <span style=\"cursor: pointer; color: #880000; font-weight: bold;\" @click=\"removeValue(i)\">&times;</span>\n </div>\n <div>\n <button @click=\"currentValue.push(''); onUpdate();\">Add</button>\n </div>\n</div>";
2181
+ module.exports = "<div class=\"edit-array\">\n <textarea ref=\"arrayEditor\" v-model=\"currentValue\" class=\"w-full border border-gray-300 p-1 h-[300px]\"></textarea>\n</div>";
1782
2182
 
1783
2183
  /***/ }),
1784
2184
 
@@ -1789,7 +2189,7 @@ module.exports = "<div class=\"edit-array\">\n <div v-for=\"(el, i) in currentV
1789
2189
  /***/ ((module) => {
1790
2190
 
1791
2191
  "use strict";
1792
- module.exports = "<div>\n <input type=\"datetime-local\" :value=\"valueAsLocalString\" @input=\"$emit('input', $event.target.value)\">\n</div>";
2192
+ module.exports = "<div>\n <div class=\"flex mb-[-1px] w-64 justify-end\">\n <button\n @click=\"inputType = 'picker'\"\n type=\"button\"\n class=\"relative inline-flex items-center rounded-none p-1 rounded-tl-md text-sm text-gray-800 ring-1 ring-inset ring-gray-300 hover:bg-gray-200 focus:z-10\"\n :class=\"inputType === 'picker' ? 'bg-gray-200' : 'bg-white'\">\n Date Picker\n </button>\n <button\n @click=\"inputType = 'iso'\"\n type=\"button\"\n class=\"relative -ml-px inline-flex items-center p-1 rounded-none rounded-tr-md text-sm text-gray-800 ring-1 ring-inset ring-gray-300 hover:bg-gray-200 focus:z-10\"\n :class=\"inputType === 'iso' ? 'bg-gray-200' : 'bg-white'\">\n ISO String Input\n </button>\n </div>\n <input v-if=\"inputType == '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=\"inputType == 'iso'\" type=\"text\" class=\"w-64 h-8 border border-gray-300 outline-0\" :value=\"valueAsISOString\" @input=\"$emit('input', $event.target.value)\">\n</div>";
1793
2193
 
1794
2194
  /***/ }),
1795
2195
 
@@ -1800,7 +2200,7 @@ module.exports = "<div>\n <input type=\"datetime-local\" :value=\"valueAsLocalS
1800
2200
  /***/ ((module) => {
1801
2201
 
1802
2202
  "use strict";
1803
- module.exports = "<div>\n <input type=\"text\" :value=\"value\" @input=\"$emit('input', $event.target.value)\">\n</div>";
2203
+ module.exports = "<div>\n <input type=\"text\" :value=\"value\" @input=\"$emit('input', $event.target.value)\" class=\"w-full p-1 border border-gray-300 outline-0\">\n</div>";
1804
2204
 
1805
2205
  /***/ }),
1806
2206
 
@@ -1881,6 +2281,28 @@ module.exports = "<div class=\"list-default\" ref=\"itemData\" class=\"tooltip\"
1881
2281
 
1882
2282
  /***/ }),
1883
2283
 
2284
+ /***/ "./frontend/src/list-json/list-json.css":
2285
+ /*!**********************************************!*\
2286
+ !*** ./frontend/src/list-json/list-json.css ***!
2287
+ \**********************************************/
2288
+ /***/ ((module) => {
2289
+
2290
+ "use strict";
2291
+ module.exports = ".list-json {\n width: 100%;\n}";
2292
+
2293
+ /***/ }),
2294
+
2295
+ /***/ "./frontend/src/list-json/list-json.html":
2296
+ /*!***********************************************!*\
2297
+ !*** ./frontend/src/list-json/list-json.html ***!
2298
+ \***********************************************/
2299
+ /***/ ((module) => {
2300
+
2301
+ "use strict";
2302
+ module.exports = "<div class=\"list-json tooltip\">\n <pre><code ref=\"JSONCode\" class=\"language-javascript\">{{shortenValue}}</code></pre>\n</div>\n ";
2303
+
2304
+ /***/ }),
2305
+
1884
2306
  /***/ "./frontend/src/list-mixed/list-mixed.css":
1885
2307
  /*!************************************************!*\
1886
2308
  !*** ./frontend/src/list-mixed/list-mixed.css ***!
@@ -1976,7 +2398,7 @@ module.exports = "<transition name=\"modal\">\n <div class=\"modal-mask\">\n
1976
2398
  /***/ ((module) => {
1977
2399
 
1978
2400
  "use strict";
1979
- module.exports = ".models {\n position: relative;\n display: flex;\n flex-direction: row;\n min-height: calc(100% - 56px);\n}\n\n.models button.gray {\n color: black;\n background-color: #eee;\n}\n\n.models .model-selector {\n background-color: #eee;\n flex-grow: 0; \n padding: 15px;\n padding-top: 0px;\n}\n\n.models h1 {\n margin-top: 0px;\n}\n\n.models .documents {\n flex-grow: 1;\n overflow: scroll;\n max-height: calc(100vh - 56px);\n}\n\n.models .documents .documents-container {\n margin-top: 60px;\n}\n\n.models .documents table {\n /* max-width: -moz-fit-content;\n max-width: fit-content; */\n width: 100%;\n table-layout: auto;\n font-size: small;\n padding: 0;\n margin-right: 1em;\n white-space: nowrap;\n z-index: -1;\n border-collapse: collapse;\n line-height: 1.5em;\n}\n\n.models .documents table th {\n position: sticky;\n top: 0px;\n background-color: white;\n z-index: 1;\n}\n\n.models .documents table th:after {\n content: '';\n position: absolute;\n left: 0;\n width: 100%;\n bottom: -1px;\n border-bottom: thin solid rgba(0,0,0,.12);\n}\n\n.models .documents table tr {\n color: black;\n border-spacing: 0px 0px;\n background-color: white;\n cursor: pointer;\n}\n\n.models .documents table tr:nth-child(even) {\n background-color: #f5f5f5;\n}\n\n.models .documents table tr:hover {\n background-color: #55A3D4;\n}\n\n.models .documents table th, td {\n border-bottom: thin solid rgba(0,0,0,.12);\n text-align: left;\n padding: 0 16px;\n height: 48px;\n}\n\n.models textarea {\n width: 100%;\n height: 600px;\n font-size: 1.2em;\n}\n\n.models .path-type {\n color: rgba(0,0,0,.36);\n font-size: 0.8em;\n}\n\n.models .documents-menu {\n display: flex;\n margin: 0.25em;\n position: fixed;\n width: calc(100vw - 220px);\n}\n\n.models .documents-menu .search-input {\n flex-grow: 1;\n}\n\n.models .search-input input {\n padding: 0.25em 0.5em;\n font-size: 1.1em;\n border: 1px solid #ddd;\n border-radius: 3px;\n width: calc(100% - 1em);\n}\n\n.models .sort-arrow {\n padding-left: 10px;\n padding-right: 10px;\n}\n\n.models .loader {\n width: 100%;\n text-align: center;\n}\n\n.models .loader img {\n height: 4em;\n}\n\n.models .documents .buttons {\n display: inline-flex;\n justify-content: space-around;\n align-items: baseline;\n}";
2401
+ module.exports = ".models {\n position: relative;\n display: flex;\n flex-direction: row;\n min-height: calc(100% - 56px);\n}\n\n.models button.gray {\n color: black;\n background-color: #eee;\n}\n\n.models .model-selector {\n background-color: #eee;\n flex-grow: 0; \n padding: 15px;\n padding-top: 0px;\n}\n\n.models h1 {\n margin-top: 0px;\n}\n\n.models .documents {\n flex-grow: 1;\n overflow: scroll;\n max-height: calc(100vh - 56px);\n}\n\n.models .documents table {\n /* max-width: -moz-fit-content;\n max-width: fit-content; */\n width: 100%;\n table-layout: auto;\n font-size: small;\n padding: 0;\n margin-right: 1em;\n white-space: nowrap;\n z-index: -1;\n border-collapse: collapse;\n line-height: 1.5em;\n}\n\n.models .documents table th {\n position: sticky;\n top: 0px;\n background-color: white;\n z-index: 1;\n}\n\n.models .documents table th:after {\n content: '';\n position: absolute;\n left: 0;\n width: 100%;\n bottom: -1px;\n border-bottom: thin solid rgba(0,0,0,.12);\n}\n\n.models .documents table tr {\n color: black;\n border-spacing: 0px 0px;\n background-color: white;\n cursor: pointer;\n}\n\n.models .documents table tr:nth-child(even) {\n background-color: #f5f5f5;\n}\n\n.models .documents table tr:hover {\n background-color: #55A3D4;\n}\n\n.models .documents table th, td {\n border-bottom: thin solid rgba(0,0,0,.12);\n text-align: left;\n padding: 0 16px;\n height: 48px;\n}\n\n.models textarea {\n font-size: 1.2em;\n}\n\n.models .path-type {\n color: rgba(0,0,0,.36);\n font-size: 0.8em;\n}\n\n.models .documents-menu {\n display: flex;\n margin: 0.25em;\n width: calc(100vw - 220px);\n}\n\n.models .documents-menu .search-input {\n flex-grow: 1;\n align-items: center;\n}\n\n.models .search-input input {\n padding: 0.25em 0.5em;\n font-size: 1.1em;\n border: 1px solid #ddd;\n border-radius: 3px;\n width: calc(100% - 1em);\n}\n\n.models .sort-arrow {\n padding-left: 10px;\n padding-right: 10px;\n}\n\n.models .loader {\n width: 100%;\n text-align: center;\n}\n\n.models .loader img {\n height: 4em;\n}\n\n.models .documents .buttons {\n display: inline-flex;\n justify-content: space-around;\n align-items: center;\n}";
1980
2402
 
1981
2403
  /***/ }),
1982
2404
 
@@ -1987,7 +2409,7 @@ module.exports = ".models {\n position: relative;\n display: flex;\n flex-dir
1987
2409
  /***/ ((module) => {
1988
2410
 
1989
2411
  "use strict";
1990
- module.exports = "<div class=\"models\">\n <div>\n <div class=\"flex grow flex-col gap-y-5 overflow-y-auto border-r border-gray-200 bg-white px-2 h-[calc(100vh-55px)]\">\n <div class=\"flex font-bold font-xl mt-4 pl-2\">\n Models\n </div>\n <nav class=\"flex flex-1 flex-col\">\n <ul role=\"list\" class=\"flex flex-1 flex-col gap-y-7\">\n <li>\n <ul role=\"list\">\n <li v-for=\"model in models\">\n <router-link\n :to=\"'/model/' + model\"\n class=\"block rounded-md py-2 pr-2 pl-2 text-sm font-semibold text-gray-700\"\n :class=\"model === currentModel ? 'bg-puerto-rico-100 font-bold' : 'hover:bg-puerto-rico-100'\">\n {{model}}\n </router-link>\n </li>\n </ul>\n </li>\n </ul>\n </nav>\n </div>\n \n </div>\n <div class=\"documents\" ref=\"documentsList\">\n <div>\n <div class=\"documents-menu\">\n <div class=\"search-input\">\n <form @submit.prevent=\"search\">\n <input class=\"search-text\" type=\"text\" placeholder=\"Filter or text\" v-model=\"searchText\" />\n </form>\n </div>\n <div class=\"buttons\">\n <div class=\"mr-2\">\n <span v-if=\"status === 'loading'\">Loading ...</span>\n <span v-if=\"status === 'loaded'\">{{numDocuments === 1 ? numDocuments+ ' document' : numDocuments + ' documents'}}</span>\n </div>\n <button\n @click=\"shouldShowExportModal = true\"\n type=\"button\"\n class=\"mr-2 rounded bg-puerto-rico-600 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-puerto-rico-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-puerto-rico-600\">\n Export\n </button>\n <button\n @click=\"shouldShowFieldModal = true\"\n type=\"button\"\n class=\"rounded bg-puerto-rico-600 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-puerto-rico-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-puerto-rico-600\">\n Fields\n </button>\n </div>\n </div>\n </div>\n <div class=\"documents-container\">\n <table>\n <thead>\n <th v-for=\"path in filteredPaths\">\n {{path.path}}\n <span class=\"path-type\">\n ({{(path.instance || 'unknown')}})\n </span>\n <span class=\"sort-arrow\" @click=\"sortDocs(1, path.path)\">{{sortBy[path.path] == 1 ? 'X' : '↑'}}</span>\n <span class=\"sort-arrow\" @click=\"sortDocs(-1, path.path)\">{{sortBy[path.path] == -1 ? 'X' : '↓'}}</span>\n </th>\n </thead>\n <tbody>\n <tr v-for=\"document in documents\" @click=\"$router.push('/model/' + currentModel + '/document/' + document._id)\" :key=\"document._id\">\n <td v-for=\"schemaPath in filteredPaths\">\n <component\n :is=\"getComponentForPath(schemaPath)\"\n :value=\"getValueForPath(document, schemaPath.path)\"\n :allude=\"getReferenceModel(schemaPath)\">\n </component>\n </td>\n </tr>\n </tbody>\n </table>\n <div v-if=\"status === 'loading'\" class=\"loader\">\n <img src=\"images/loader.gif\">\n </div>\n </div>\n <modal v-if=\"shouldShowExportModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowExportModal = false\">&times;</div>\n <export-query-results\n :schemaPaths=\"schemaPaths\"\n :filter=\"filter\"\n :currentModel=\"currentModel\"\n @done=\"shouldShowExportModal = false\">\n </export-query-results>\n </template>\n </modal>\n <modal v-if=\"shouldShowFieldModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowFieldModal = false; selectedPaths = [...filteredPaths];\">&times;</div>\n <div v-for=\"(path, index) in schemaPaths\" :key=\"index\" style=\"margin-bottom: 0.5em\">\n <input type=\"checkbox\" :id=\"'path.path'+index\" @change=\"addOrRemove(path)\" :value=\"path.path\" :checked=\"isSelected(path.path)\" />\n <label :for=\"'path' + index\">{{path.path}}</label>\n </div>\n <div style=\"margin-top: 1em\">\n <button type=\"submit\" @click=\"filterDocuments()\" style=\"color: black;margin-right: 0.5em\">Filter Selection</button>\n <button type=\"submit\" @click=\"deselectAll()\" class=\"gray\" style=\"margin-right: 0.5em\">Deselect All</button>\n <button type=\"submit\" @click=\"resetDocuments()\" class=\"gray\">Cancel</button>\n \n </div>\n </template>\n </modal>\n </div>\n</div>";
2412
+ module.exports = "<div class=\"models\">\n <div>\n <div class=\"flex grow flex-col gap-y-5 overflow-y-auto border-r border-gray-200 bg-white px-2 h-[calc(100vh-55px)]\">\n <div class=\"flex font-bold font-xl mt-4 pl-2\">\n Models\n </div>\n <nav class=\"flex flex-1 flex-col\">\n <ul role=\"list\" class=\"flex flex-1 flex-col gap-y-7\">\n <li>\n <ul role=\"list\">\n <li v-for=\"model in models\">\n <router-link\n :to=\"'/model/' + model\"\n class=\"block rounded-md py-2 pr-2 pl-2 text-sm font-semibold text-gray-700\"\n :class=\"model === currentModel ? 'bg-teal-100 font-bold' : 'hover:bg-teal-100'\">\n {{model}}\n </router-link>\n </li>\n </ul>\n </li>\n </ul>\n </nav>\n </div>\n \n </div>\n <div class=\"documents\" ref=\"documentsList\">\n <div>\n <div class=\"documents-menu\">\n <div class=\"flex flex-row items-center w-full gap-2\">\n <form @submit.prevent=\"search\" class=\"flex-grow m-0\">\n <input class=\"w-full rounded-md p-1 outline-gray-300 text-lg\" type=\"text\" placeholder=\"Filter or text\" v-model=\"searchText\" />\n </form>\n <div>\n <span v-if=\"status === 'loading'\">Loading ...</span>\n <span v-if=\"status === 'loaded'\">{{numDocuments === 1 ? numDocuments+ ' document' : numDocuments + ' documents'}}</span>\n </div>\n <button\n @click=\"shouldShowExportModal = true\"\n type=\"button\"\n class=\"rounded bg-teal-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n Export\n </button>\n <button\n @click=\"shouldShowCreateModal = true;\"\n type=\"button\"\n class=\"rounded bg-teal-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n Create\n </button>\n <button\n @click=\"shouldShowFieldModal = true\"\n type=\"button\"\n class=\"rounded bg-teal-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n Fields\n </button>\n <span class=\"isolate inline-flex rounded-md shadow-sm\">\n <button\n @click=\"outputType = 'table'\"\n type=\"button\"\n class=\"relative inline-flex items-center rounded-none rounded-l-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10\"\n :class=\"outputType === 'table' ? 'bg-gray-200' : 'bg-white'\">\n <img class=\"h-5 w-5\" src=\"images/table.svg\">\n </button>\n <button\n @click=\"outputType = 'json'\"\n type=\"button\"\n class=\"relative -ml-px inline-flex items-center rounded-none rounded-r-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10\"\n :class=\"outputType === 'json' ? 'bg-gray-200' : 'bg-white'\">\n <img class=\"h-5 w-5\" src=\"images/json.svg\">\n </button>\n </span>\n </div>\n </div>\n </div>\n <div class=\"documents-container\">\n <table v-if=\"outputType === 'table'\">\n <thead>\n <th v-for=\"path in filteredPaths\">\n {{path.path}}\n <span class=\"path-type\">\n ({{(path.instance || 'unknown')}})\n </span>\n <span class=\"sort-arrow\" @click=\"sortDocs(1, path.path)\">{{sortBy[path.path] == 1 ? 'X' : '↑'}}</span>\n <span class=\"sort-arrow\" @click=\"sortDocs(-1, path.path)\">{{sortBy[path.path] == -1 ? 'X' : '↓'}}</span>\n </th>\n </thead>\n <tbody>\n <tr v-for=\"document in documents\" @click=\"$router.push('/model/' + currentModel + '/document/' + document._id)\" :key=\"document._id\">\n <td v-for=\"schemaPath in filteredPaths\">\n <component\n :is=\"getComponentForPath(schemaPath)\"\n :value=\"getValueForPath(document, schemaPath.path)\"\n :allude=\"getReferenceModel(schemaPath)\">\n </component>\n </td>\n </tr>\n </tbody>\n </table>\n <div v-if=\"outputType === 'json'\">\n <div v-for=\"document in documents\" @click=\"$router.push('/model/' + currentModel + '/document/' + document._id)\" :key=\"document._id\">\n <list-json :value=\"filterDocument(document)\">\n </list-json>\n </div>\n </div>\n <div v-if=\"status === 'loading'\" class=\"loader\">\n <img src=\"images/loader.gif\">\n </div>\n </div>\n <modal v-if=\"shouldShowExportModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowExportModal = false\">&times;</div>\n <export-query-results\n :schemaPaths=\"schemaPaths\"\n :filter=\"filter\"\n :currentModel=\"currentModel\"\n @done=\"shouldShowExportModal = false\">\n </export-query-results>\n </template>\n </modal>\n <modal v-if=\"shouldShowFieldModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowFieldModal = false; selectedPaths = [...filteredPaths];\">&times;</div>\n <div v-for=\"(path, index) in schemaPaths\" :key=\"index\" style=\"margin-bottom: 0.5em\">\n <input type=\"checkbox\" :id=\"'path.path'+index\" @change=\"addOrRemove(path)\" :value=\"path.path\" :checked=\"isSelected(path.path)\" />\n <label :for=\"'path' + index\">{{path.path}}</label>\n </div>\n <div style=\"margin-top: 1em\">\n <button type=\"submit\" @click=\"filterDocuments()\" style=\"color: black;margin-right: 0.5em\">Filter Selection</button>\n <button type=\"submit\" @click=\"deselectAll()\" class=\"gray\" style=\"margin-right: 0.5em\">Deselect All</button>\n <button type=\"submit\" @click=\"resetDocuments()\" class=\"gray\">Cancel</button>\n \n </div>\n </template>\n </modal>\n <modal v-if=\"shouldShowCreateModal\">\n <template v-slot:body>\n <div class=\"modal-exit\" @click=\"shouldShowCreateModal = false;\">&times;</div>\n <create-document :currentModel=\"currentModel\" :paths=\"schemaPaths\" @close=\"closeCreationModal\"></create-document>\n </template>\n </modal>\n </div>\n</div>";
1991
2413
 
1992
2414
  /***/ }),
1993
2415
 
@@ -1998,7 +2420,7 @@ module.exports = "<div class=\"models\">\n <div>\n <div class=\"flex grow fl
1998
2420
  /***/ ((module) => {
1999
2421
 
2000
2422
  "use strict";
2001
- module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.navbar .nav-left {\n float: left;\n line-height: 54px;\n font-size: 20px;\n padding-left: 20px;\n}\n\n.navbar .nav-left a {\n color: #232323;\n}\n\n.navbar {\n border-bottom: 1px solid #ddd;\n height: 55px;\n}\n\n.navbar .nav-left img {\n height: 32px;\n vertical-align: middle;\n margin-right: 0.5em;\n margin-top: 8px;\n}\n\n.navbar .nav-right {\n float: right;\n display: flex;\n flex-direction: row;\n font-size: 16px;\n line-height: 54px;\n padding-right: 20px;\n}\n\n.navbar .nav-right .nav-item {\n flex-grow: 1;\n padding: 0px 12px;\n position: relative;\n z-index: 21000;\n}\n\n.navbar .nav-right .nav-item:hover {\n flex-grow: 1;\n padding: 0px 12px;\n border-bottom: 1px solid #E1B9A0;\n}\n\n.navbar .nav-right .nav-item.active {\n border-bottom: 1px solid #E1B9A0;\n}\n\n.navbar .nav-action {\n cursor: pointer;\n color: #E1B9A0;\n}\n\n.navbar .nav-action svg {\n height: 1em;\n vertical-align: middle;\n}\n\n.navbar .nav-right .nav-item .flyout {\n position: absolute;\n top: 55px;\n right: 0px;\n visibility: hidden;\n opacity: 0;\n transition: opacity .25s,visibility .25s,transform .25s;\n width: auto;\n box-shadow: 0 12px 32px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .08);\n background-color: #393944;\n padding-left: 0.5em;\n padding-right: 0.5em;\n z-index: 1000;\n min-width: 192px;\n font-size: 0.9em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout a {\n color: #E1B9A0;\n margin-top: 0.25em;\n margin-bottom: 0.25em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout a:hover {\n color: #E1B9A0;\n}\n\n.navbar .nav-right .nav-item:hover .flyout .nav-action {\n color: #E1B9A0;\n margin-top: 0.25em;\n margin-bottom: 0.25em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout .nav-action:hover {\n color: #E1B9A0;\n}\n\n.navbar .nav-right .nav-item:hover .flyout {\n visibility: visible;\n opacity: 1;\n}\n\n#bar-1 {\n\ttransform: translateY(-4px);\n}\n#bar-3 {\n\ttransform: translateY(4px);\n}\n.menu {\n display: none;\n}\n.menu {\n\twidth: 35px;\n\theight: 30px;\n\tmargin: 18px 2px 0px 0px;\n\tcursor: pointer;\n float: right;\n}\n.bar {\n\theight: 5px;\n\twidth: 100%;\n\tbackground-color: #fff;\n\tdisplay: block;\n\tborder-radius: 5px;\n\ttransition: 0.4s ease;\n}\n.change-icon #bar-1 {\n transform: translateY(4px) rotateZ(-405deg);\n}\n.change-icon #bar-2 {\n opacity: 0;\n}\n.change-icon #bar-3 {\n transform: translateY(-6px) rotateZ(405deg);\n}\n\n@media (max-width: 767px) {\n .menu {\n display: block;\n }\n\n .change-icon ~ div.nav-right {\n left: 0;\n }\n\n .navbar .nav-right {\n\t\tposition: fixed;\n\t\ttop: 55px;\n\t\tleft: -130%;\n\t\tbackground: #111;\n\t\theight: 100vh;\n\t\twidth: 100%;\n\t\ttext-align: center;\n\t\tdisplay: block;\n\t\ttransition: all 0.3s ease;\n z-index: 10000;\n\t}\n}\n";
2423
+ module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.active {\n text-decoration: underline;\n}\n\n.spacing {\n margin-right: 10px;\n}\n\n.navbar .nav-left {\n float: left;\n line-height: 54px;\n font-size: 20px;\n padding-left: 20px;\n}\n\n.navbar .nav-left a {\n color: #232323;\n}\n\n.navbar {\n border-bottom: 1px solid #ddd;\n height: 55px;\n}\n\n.navbar .nav-left img {\n height: 32px;\n vertical-align: middle;\n margin-right: 0.5em;\n margin-top: 8px;\n}\n\n.navbar .nav-right {\n float: right;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n font-size: 16px;\n line-height: 54px;\n padding-right: 20px;\n}\n\n.navbar .nav-right .nav-item {\n flex-grow: 1;\n padding: 0px 12px;\n position: relative;\n z-index: 21000;\n}\n\n.navbar .nav-right .nav-item:hover {\n flex-grow: 1;\n padding: 0px 12px;\n border-bottom: 1px solid #E1B9A0;\n}\n\n.navbar .nav-right .nav-item.active {\n border-bottom: 1px solid #E1B9A0;\n}\n\n.navbar .nav-action {\n cursor: pointer;\n color: #E1B9A0;\n}\n\n.navbar .nav-action svg {\n height: 1em;\n vertical-align: middle;\n}\n\n.navbar .nav-right .nav-item .flyout {\n position: absolute;\n top: 55px;\n right: 0px;\n visibility: hidden;\n opacity: 0;\n transition: opacity .25s,visibility .25s,transform .25s;\n width: auto;\n box-shadow: 0 12px 32px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .08);\n background-color: #393944;\n padding-left: 0.5em;\n padding-right: 0.5em;\n z-index: 1000;\n min-width: 192px;\n font-size: 0.9em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout a {\n color: #E1B9A0;\n margin-top: 0.25em;\n margin-bottom: 0.25em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout a:hover {\n color: #E1B9A0;\n}\n\n.navbar .nav-right .nav-item:hover .flyout .nav-action {\n color: #E1B9A0;\n margin-top: 0.25em;\n margin-bottom: 0.25em;\n}\n\n.navbar .nav-right .nav-item:hover .flyout .nav-action:hover {\n color: #E1B9A0;\n}\n\n.navbar .nav-right .nav-item:hover .flyout {\n visibility: visible;\n opacity: 1;\n}\n\n#bar-1 {\n\ttransform: translateY(-4px);\n}\n#bar-3 {\n\ttransform: translateY(4px);\n}\n.menu {\n display: none;\n}\n.menu {\n\twidth: 35px;\n\theight: 30px;\n\tmargin: 18px 2px 0px 0px;\n\tcursor: pointer;\n float: right;\n}\n.bar {\n\theight: 5px;\n\twidth: 100%;\n\tbackground-color: #fff;\n\tdisplay: block;\n\tborder-radius: 5px;\n\ttransition: 0.4s ease;\n}\n.change-icon #bar-1 {\n transform: translateY(4px) rotateZ(-405deg);\n}\n.change-icon #bar-2 {\n opacity: 0;\n}\n.change-icon #bar-3 {\n transform: translateY(-6px) rotateZ(405deg);\n}\n\n@media (max-width: 767px) {\n .menu {\n display: block;\n }\n\n .change-icon ~ div.nav-right {\n left: 0;\n }\n\n .navbar .nav-right {\n\t\tposition: fixed;\n\t\ttop: 55px;\n\t\tleft: -130%;\n\t\tbackground: #111;\n\t\theight: 100vh;\n\t\twidth: 100%;\n\t\ttext-align: center;\n\t\tdisplay: block;\n\t\ttransition: all 0.3s ease;\n z-index: 10000;\n\t}\n}\n";
2002
2424
 
2003
2425
  /***/ }),
2004
2426
 
@@ -2009,7 +2431,7 @@ module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.na
2009
2431
  /***/ ((module) => {
2010
2432
 
2011
2433
  "use strict";
2012
- module.exports = "<div class=\"navbar\">\n <div class=\"nav-left\">\n <router-link to=\"/\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n </div>\n <div class=\"nav-right\">\n <!--- <router-link to=\"/\">Models</router-link>\n <router-link to=\"/charts\">Charts</router-link> -->\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
2434
+ module.exports = "<div class=\"navbar\">\n <div class=\"nav-left\">\n <router-link to=\"/\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n </div>\n <div class=\"nav-right h-full\">\n <div class=\"sm:ml-6 sm:flex sm:space-x-8 h-full\">\n <a\n href=\"#/\"\n class=\"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium\"\n :class=\"routeName === 'root' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Documents</a>\n <a\n href=\"#/dashboards\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"routeName === 'dashboards' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Dashboards</a>\n </div>\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
2013
2435
 
2014
2436
  /***/ }),
2015
2437
 
@@ -5203,8 +5625,28 @@ function isMap(d) {
5203
5625
  function isDate(d) {
5204
5626
  return Object.prototype.toString.call(d) === '[object Date]';
5205
5627
  }
5628
+ function defaultInspect(x, _options) {
5629
+ return JSON.stringify(x, (k, v) => {
5630
+ if (typeof v === 'bigint') {
5631
+ return { $numberLong: `${v}` };
5632
+ }
5633
+ else if (isMap(v)) {
5634
+ return Object.fromEntries(v);
5635
+ }
5636
+ return v;
5637
+ });
5638
+ }
5639
+ function getStylizeFunction(options) {
5640
+ const stylizeExists = options != null &&
5641
+ typeof options === 'object' &&
5642
+ 'stylize' in options &&
5643
+ typeof options.stylize === 'function';
5644
+ if (stylizeExists) {
5645
+ return options.stylize;
5646
+ }
5647
+ }
5206
5648
 
5207
- const BSON_MAJOR_VERSION = 5;
5649
+ const BSON_MAJOR_VERSION = 6;
5208
5650
  const BSON_INT32_MAX = 0x7fffffff;
5209
5651
  const BSON_INT32_MIN = -0x80000000;
5210
5652
  const BSON_INT64_MAX = Math.pow(2, 63) - 1;
@@ -5265,8 +5707,8 @@ class BSONError extends Error {
5265
5707
  get name() {
5266
5708
  return 'BSONError';
5267
5709
  }
5268
- constructor(message) {
5269
- super(message);
5710
+ constructor(message, options) {
5711
+ super(message, options);
5270
5712
  }
5271
5713
  static isBSONError(value) {
5272
5714
  return (value != null &&
@@ -5294,6 +5736,82 @@ class BSONRuntimeError extends BSONError {
5294
5736
  super(message);
5295
5737
  }
5296
5738
  }
5739
+ class BSONOffsetError extends BSONError {
5740
+ get name() {
5741
+ return 'BSONOffsetError';
5742
+ }
5743
+ constructor(message, offset, options) {
5744
+ super(`${message}. offset: ${offset}`, options);
5745
+ this.offset = offset;
5746
+ }
5747
+ }
5748
+
5749
+ let TextDecoderFatal;
5750
+ let TextDecoderNonFatal;
5751
+ function parseUtf8(buffer, start, end, fatal) {
5752
+ if (fatal) {
5753
+ TextDecoderFatal ??= new TextDecoder('utf8', { fatal: true });
5754
+ try {
5755
+ return TextDecoderFatal.decode(buffer.subarray(start, end));
5756
+ }
5757
+ catch (cause) {
5758
+ throw new BSONError('Invalid UTF-8 string in BSON document', { cause });
5759
+ }
5760
+ }
5761
+ TextDecoderNonFatal ??= new TextDecoder('utf8', { fatal: false });
5762
+ return TextDecoderNonFatal.decode(buffer.subarray(start, end));
5763
+ }
5764
+
5765
+ function tryReadBasicLatin(uint8array, start, end) {
5766
+ if (uint8array.length === 0) {
5767
+ return '';
5768
+ }
5769
+ const stringByteLength = end - start;
5770
+ if (stringByteLength === 0) {
5771
+ return '';
5772
+ }
5773
+ if (stringByteLength > 20) {
5774
+ return null;
5775
+ }
5776
+ if (stringByteLength === 1 && uint8array[start] < 128) {
5777
+ return String.fromCharCode(uint8array[start]);
5778
+ }
5779
+ if (stringByteLength === 2 && uint8array[start] < 128 && uint8array[start + 1] < 128) {
5780
+ return String.fromCharCode(uint8array[start]) + String.fromCharCode(uint8array[start + 1]);
5781
+ }
5782
+ if (stringByteLength === 3 &&
5783
+ uint8array[start] < 128 &&
5784
+ uint8array[start + 1] < 128 &&
5785
+ uint8array[start + 2] < 128) {
5786
+ return (String.fromCharCode(uint8array[start]) +
5787
+ String.fromCharCode(uint8array[start + 1]) +
5788
+ String.fromCharCode(uint8array[start + 2]));
5789
+ }
5790
+ const latinBytes = [];
5791
+ for (let i = start; i < end; i++) {
5792
+ const byte = uint8array[i];
5793
+ if (byte > 127) {
5794
+ return null;
5795
+ }
5796
+ latinBytes.push(byte);
5797
+ }
5798
+ return String.fromCharCode(...latinBytes);
5799
+ }
5800
+ function tryWriteBasicLatin(destination, source, offset) {
5801
+ if (source.length === 0)
5802
+ return 0;
5803
+ if (source.length > 25)
5804
+ return null;
5805
+ if (destination.length - offset < source.length)
5806
+ return null;
5807
+ for (let charOffset = 0, destinationOffset = offset; charOffset < source.length; charOffset++, destinationOffset++) {
5808
+ const char = source.charCodeAt(charOffset);
5809
+ if (char > 127)
5810
+ return null;
5811
+ destination[destinationOffset] = char;
5812
+ }
5813
+ return source.length;
5814
+ }
5297
5815
 
5298
5816
  function nodejsMathRandomBytes(byteLength) {
5299
5817
  return nodeJsByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
@@ -5326,6 +5844,9 @@ const nodeJsByteUtils = {
5326
5844
  allocate(size) {
5327
5845
  return Buffer.alloc(size);
5328
5846
  },
5847
+ allocateUnsafe(size) {
5848
+ return Buffer.allocUnsafe(size);
5849
+ },
5329
5850
  equals(a, b) {
5330
5851
  return nodeJsByteUtils.toLocalBufferType(a).equals(b);
5331
5852
  },
@@ -5350,16 +5871,30 @@ const nodeJsByteUtils = {
5350
5871
  toHex(buffer) {
5351
5872
  return nodeJsByteUtils.toLocalBufferType(buffer).toString('hex');
5352
5873
  },
5353
- fromUTF8(text) {
5354
- return Buffer.from(text, 'utf8');
5355
- },
5356
- toUTF8(buffer, start, end) {
5357
- return nodeJsByteUtils.toLocalBufferType(buffer).toString('utf8', start, end);
5874
+ toUTF8(buffer, start, end, fatal) {
5875
+ const basicLatin = end - start <= 20 ? tryReadBasicLatin(buffer, start, end) : null;
5876
+ if (basicLatin != null) {
5877
+ return basicLatin;
5878
+ }
5879
+ const string = nodeJsByteUtils.toLocalBufferType(buffer).toString('utf8', start, end);
5880
+ if (fatal) {
5881
+ for (let i = 0; i < string.length; i++) {
5882
+ if (string.charCodeAt(i) === 0xfffd) {
5883
+ parseUtf8(buffer, start, end, true);
5884
+ break;
5885
+ }
5886
+ }
5887
+ }
5888
+ return string;
5358
5889
  },
5359
5890
  utf8ByteLength(input) {
5360
5891
  return Buffer.byteLength(input, 'utf8');
5361
5892
  },
5362
5893
  encodeUTF8Into(buffer, source, byteOffset) {
5894
+ const latinBytesWritten = tryWriteBasicLatin(buffer, source, byteOffset);
5895
+ if (latinBytesWritten != null) {
5896
+ return latinBytesWritten;
5897
+ }
5363
5898
  return nodeJsByteUtils.toLocalBufferType(buffer).write(source, byteOffset, undefined, 'utf8');
5364
5899
  },
5365
5900
  randomBytes: nodejsRandomBytes
@@ -5415,6 +5950,9 @@ const webByteUtils = {
5415
5950
  }
5416
5951
  return new Uint8Array(size);
5417
5952
  },
5953
+ allocateUnsafe(size) {
5954
+ return webByteUtils.allocate(size);
5955
+ },
5418
5956
  equals(a, b) {
5419
5957
  if (a.byteLength !== b.byteLength) {
5420
5958
  return false;
@@ -5461,18 +5999,19 @@ const webByteUtils = {
5461
5999
  toHex(uint8array) {
5462
6000
  return Array.from(uint8array, byte => byte.toString(16).padStart(2, '0')).join('');
5463
6001
  },
5464
- fromUTF8(text) {
5465
- return new TextEncoder().encode(text);
5466
- },
5467
- toUTF8(uint8array, start, end) {
5468
- return new TextDecoder('utf8', { fatal: false }).decode(uint8array.slice(start, end));
6002
+ toUTF8(uint8array, start, end, fatal) {
6003
+ const basicLatin = end - start <= 20 ? tryReadBasicLatin(uint8array, start, end) : null;
6004
+ if (basicLatin != null) {
6005
+ return basicLatin;
6006
+ }
6007
+ return parseUtf8(uint8array, start, end, fatal);
5469
6008
  },
5470
6009
  utf8ByteLength(input) {
5471
- return webByteUtils.fromUTF8(input).byteLength;
6010
+ return new TextEncoder().encode(input).byteLength;
5472
6011
  },
5473
- encodeUTF8Into(buffer, source, byteOffset) {
5474
- const bytes = webByteUtils.fromUTF8(source);
5475
- buffer.set(bytes, byteOffset);
6012
+ encodeUTF8Into(uint8array, source, byteOffset) {
6013
+ const bytes = new TextEncoder().encode(source);
6014
+ uint8array.set(bytes, byteOffset);
5476
6015
  return bytes.byteLength;
5477
6016
  },
5478
6017
  randomBytes: webRandomBytes
@@ -5480,16 +6019,14 @@ const webByteUtils = {
5480
6019
 
5481
6020
  const hasGlobalBuffer = typeof Buffer === 'function' && Buffer.prototype?._isBuffer !== true;
5482
6021
  const ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils;
5483
- class BSONDataView extends DataView {
5484
- static fromUint8Array(input) {
5485
- return new DataView(input.buffer, input.byteOffset, input.byteLength);
5486
- }
5487
- }
5488
6022
 
5489
6023
  class BSONValue {
5490
6024
  get [Symbol.for('@@mdb.bson.version')]() {
5491
6025
  return BSON_MAJOR_VERSION;
5492
6026
  }
6027
+ [Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
6028
+ return this.inspect(depth, options, inspect);
6029
+ }
5493
6030
  }
5494
6031
 
5495
6032
  class Binary extends BSONValue {
@@ -5499,11 +6036,11 @@ class Binary extends BSONValue {
5499
6036
  constructor(buffer, subType) {
5500
6037
  super();
5501
6038
  if (!(buffer == null) &&
5502
- !(typeof buffer === 'string') &&
6039
+ typeof buffer === 'string' &&
5503
6040
  !ArrayBuffer.isView(buffer) &&
5504
- !(buffer instanceof ArrayBuffer) &&
6041
+ !isAnyArrayBuffer(buffer) &&
5505
6042
  !Array.isArray(buffer)) {
5506
- throw new BSONError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
6043
+ throw new BSONError('Binary can only be constructed from Uint8Array or number[]');
5507
6044
  }
5508
6045
  this.sub_type = subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT;
5509
6046
  if (buffer == null) {
@@ -5511,15 +6048,9 @@ class Binary extends BSONValue {
5511
6048
  this.position = 0;
5512
6049
  }
5513
6050
  else {
5514
- if (typeof buffer === 'string') {
5515
- this.buffer = ByteUtils.fromISO88591(buffer);
5516
- }
5517
- else if (Array.isArray(buffer)) {
5518
- this.buffer = ByteUtils.fromNumberArray(buffer);
5519
- }
5520
- else {
5521
- this.buffer = ByteUtils.toLocalBufferType(buffer);
5522
- }
6051
+ this.buffer = Array.isArray(buffer)
6052
+ ? ByteUtils.fromNumberArray(buffer)
6053
+ : ByteUtils.toLocalBufferType(buffer);
5523
6054
  this.position = this.buffer.byteLength;
5524
6055
  }
5525
6056
  }
@@ -5565,40 +6096,32 @@ class Binary extends BSONValue {
5565
6096
  offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
5566
6097
  }
5567
6098
  else if (typeof sequence === 'string') {
5568
- const bytes = ByteUtils.fromISO88591(sequence);
5569
- this.buffer.set(bytes, offset);
5570
- this.position =
5571
- offset + sequence.length > this.position ? offset + sequence.length : this.position;
6099
+ throw new BSONError('input cannot be string');
5572
6100
  }
5573
6101
  }
5574
6102
  read(position, length) {
5575
6103
  length = length && length > 0 ? length : this.position;
5576
6104
  return this.buffer.slice(position, position + length);
5577
6105
  }
5578
- value(asRaw) {
5579
- asRaw = !!asRaw;
5580
- if (asRaw && this.buffer.length === this.position) {
5581
- return this.buffer;
5582
- }
5583
- if (asRaw) {
5584
- return this.buffer.slice(0, this.position);
5585
- }
5586
- return ByteUtils.toISO88591(this.buffer.subarray(0, this.position));
6106
+ value() {
6107
+ return this.buffer.length === this.position
6108
+ ? this.buffer
6109
+ : this.buffer.subarray(0, this.position);
5587
6110
  }
5588
6111
  length() {
5589
6112
  return this.position;
5590
6113
  }
5591
6114
  toJSON() {
5592
- return ByteUtils.toBase64(this.buffer);
6115
+ return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
5593
6116
  }
5594
6117
  toString(encoding) {
5595
6118
  if (encoding === 'hex')
5596
- return ByteUtils.toHex(this.buffer);
6119
+ return ByteUtils.toHex(this.buffer.subarray(0, this.position));
5597
6120
  if (encoding === 'base64')
5598
- return ByteUtils.toBase64(this.buffer);
6121
+ return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
5599
6122
  if (encoding === 'utf8' || encoding === 'utf-8')
5600
- return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength);
5601
- return ByteUtils.toUTF8(this.buffer, 0, this.buffer.byteLength);
6123
+ return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
6124
+ return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
5602
6125
  }
5603
6126
  toExtendedJSON(options) {
5604
6127
  options = options || {};
@@ -5654,12 +6177,12 @@ class Binary extends BSONValue {
5654
6177
  }
5655
6178
  return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type);
5656
6179
  }
5657
- [Symbol.for('nodejs.util.inspect.custom')]() {
5658
- return this.inspect();
5659
- }
5660
- inspect() {
6180
+ inspect(depth, options, inspect) {
6181
+ inspect ??= defaultInspect;
5661
6182
  const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position));
5662
- return `Binary.createFromBase64("${base64}", ${this.sub_type})`;
6183
+ const base64Arg = inspect(base64, options);
6184
+ const subTypeArg = inspect(this.sub_type, options);
6185
+ return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`;
5663
6186
  }
5664
6187
  }
5665
6188
  Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0;
@@ -5672,6 +6195,7 @@ Binary.SUBTYPE_UUID = 4;
5672
6195
  Binary.SUBTYPE_MD5 = 5;
5673
6196
  Binary.SUBTYPE_ENCRYPTED = 6;
5674
6197
  Binary.SUBTYPE_COLUMN = 7;
6198
+ Binary.SUBTYPE_SENSITIVE = 8;
5675
6199
  Binary.SUBTYPE_USER_DEFINED = 128;
5676
6200
  const UUID_BYTE_LENGTH = 16;
5677
6201
  const UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
@@ -5777,14 +6301,11 @@ class UUID extends Binary {
5777
6301
  static isValidUUIDString(representation) {
5778
6302
  return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation);
5779
6303
  }
5780
- [Symbol.for('nodejs.util.inspect.custom')]() {
5781
- return this.inspect();
5782
- }
5783
- inspect() {
5784
- return `new UUID("${this.toHexString()}")`;
6304
+ inspect(depth, options, inspect) {
6305
+ inspect ??= defaultInspect;
6306
+ return `new UUID(${inspect(this.toHexString(), options)})`;
5785
6307
  }
5786
6308
  }
5787
- UUID.cacheHexString = false;
5788
6309
 
5789
6310
  class Code extends BSONValue {
5790
6311
  get _bsontype() {
@@ -5810,12 +6331,15 @@ class Code extends BSONValue {
5810
6331
  static fromExtendedJSON(doc) {
5811
6332
  return new Code(doc.$code, doc.$scope);
5812
6333
  }
5813
- [Symbol.for('nodejs.util.inspect.custom')]() {
5814
- return this.inspect();
5815
- }
5816
- inspect() {
5817
- const codeJson = this.toJSON();
5818
- return `new Code("${String(codeJson.code)}"${codeJson.scope != null ? `, ${JSON.stringify(codeJson.scope)}` : ''})`;
6334
+ inspect(depth, options, inspect) {
6335
+ inspect ??= defaultInspect;
6336
+ let parametersString = inspect(this.code, options);
6337
+ const multiLineFn = parametersString.includes('\n');
6338
+ if (this.scope != null) {
6339
+ parametersString += `,${multiLineFn ? '\n' : ' '}${inspect(this.scope, options)}`;
6340
+ }
6341
+ const endingNewline = multiLineFn && this.scope === null;
6342
+ return `new Code(${multiLineFn ? '\n' : ''}${parametersString}${endingNewline ? '\n' : ''})`;
5819
6343
  }
5820
6344
  }
5821
6345
 
@@ -5880,13 +6404,43 @@ class DBRef extends BSONValue {
5880
6404
  delete copy.$db;
5881
6405
  return new DBRef(doc.$ref, doc.$id, doc.$db, copy);
5882
6406
  }
5883
- [Symbol.for('nodejs.util.inspect.custom')]() {
5884
- return this.inspect();
6407
+ inspect(depth, options, inspect) {
6408
+ inspect ??= defaultInspect;
6409
+ const args = [
6410
+ inspect(this.namespace, options),
6411
+ inspect(this.oid, options),
6412
+ ...(this.db ? [inspect(this.db, options)] : []),
6413
+ ...(Object.keys(this.fields).length > 0 ? [inspect(this.fields, options)] : [])
6414
+ ];
6415
+ args[1] = inspect === defaultInspect ? `new ObjectId(${args[1]})` : args[1];
6416
+ return `new DBRef(${args.join(', ')})`;
6417
+ }
6418
+ }
6419
+
6420
+ function removeLeadingZerosAndExplicitPlus(str) {
6421
+ if (str === '') {
6422
+ return str;
5885
6423
  }
5886
- inspect() {
5887
- const oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString();
5888
- return `new DBRef("${this.namespace}", new ObjectId("${String(oid)}")${this.db ? `, "${this.db}"` : ''})`;
6424
+ let startIndex = 0;
6425
+ const isNegative = str[startIndex] === '-';
6426
+ const isExplicitlyPositive = str[startIndex] === '+';
6427
+ if (isExplicitlyPositive || isNegative) {
6428
+ startIndex += 1;
5889
6429
  }
6430
+ let foundInsignificantZero = false;
6431
+ for (; startIndex < str.length && str[startIndex] === '0'; ++startIndex) {
6432
+ foundInsignificantZero = true;
6433
+ }
6434
+ if (!foundInsignificantZero) {
6435
+ return isExplicitlyPositive ? str.slice(1) : str;
6436
+ }
6437
+ return `${isNegative ? '-' : ''}${str.length === startIndex ? '0' : str.slice(startIndex)}`;
6438
+ }
6439
+ function validateStringCharacters(str, radix) {
6440
+ radix = radix ?? 10;
6441
+ const validCharacters = '0123456789abcdefghijklmnopqrstuvwxyz'.slice(0, radix);
6442
+ const regex = new RegExp(`[^-+${validCharacters}]`, 'i');
6443
+ return regex.test(str) ? false : str;
5890
6444
  }
5891
6445
 
5892
6446
  let wasm = undefined;
@@ -5977,25 +6531,16 @@ class Long extends BSONValue {
5977
6531
  static fromBigInt(value, unsigned) {
5978
6532
  return Long.fromString(value.toString(), unsigned);
5979
6533
  }
5980
- static fromString(str, unsigned, radix) {
6534
+ static _fromString(str, unsigned, radix) {
5981
6535
  if (str.length === 0)
5982
6536
  throw new BSONError('empty string');
5983
- if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity')
5984
- return Long.ZERO;
5985
- if (typeof unsigned === 'number') {
5986
- (radix = unsigned), (unsigned = false);
5987
- }
5988
- else {
5989
- unsigned = !!unsigned;
5990
- }
5991
- radix = radix || 10;
5992
6537
  if (radix < 2 || 36 < radix)
5993
6538
  throw new BSONError('radix');
5994
6539
  let p;
5995
6540
  if ((p = str.indexOf('-')) > 0)
5996
6541
  throw new BSONError('interior hyphen');
5997
6542
  else if (p === 0) {
5998
- return Long.fromString(str.substring(1), unsigned, radix).neg();
6543
+ return Long._fromString(str.substring(1), unsigned, radix).neg();
5999
6544
  }
6000
6545
  const radixToPower = Long.fromNumber(Math.pow(radix, 8));
6001
6546
  let result = Long.ZERO;
@@ -6013,6 +6558,45 @@ class Long extends BSONValue {
6013
6558
  result.unsigned = unsigned;
6014
6559
  return result;
6015
6560
  }
6561
+ static fromStringStrict(str, unsignedOrRadix, radix) {
6562
+ let unsigned = false;
6563
+ if (typeof unsignedOrRadix === 'number') {
6564
+ (radix = unsignedOrRadix), (unsignedOrRadix = false);
6565
+ }
6566
+ else {
6567
+ unsigned = !!unsignedOrRadix;
6568
+ }
6569
+ radix ??= 10;
6570
+ if (str.trim() !== str) {
6571
+ throw new BSONError(`Input: '${str}' contains leading and/or trailing whitespace`);
6572
+ }
6573
+ if (!validateStringCharacters(str, radix)) {
6574
+ throw new BSONError(`Input: '${str}' contains invalid characters for radix: ${radix}`);
6575
+ }
6576
+ const cleanedStr = removeLeadingZerosAndExplicitPlus(str);
6577
+ const result = Long._fromString(cleanedStr, unsigned, radix);
6578
+ if (result.toString(radix).toLowerCase() !== cleanedStr.toLowerCase()) {
6579
+ throw new BSONError(`Input: ${str} is not representable as ${result.unsigned ? 'an unsigned' : 'a signed'} 64-bit Long ${radix != null ? `with radix: ${radix}` : ''}`);
6580
+ }
6581
+ return result;
6582
+ }
6583
+ static fromString(str, unsignedOrRadix, radix) {
6584
+ let unsigned = false;
6585
+ if (typeof unsignedOrRadix === 'number') {
6586
+ (radix = unsignedOrRadix), (unsignedOrRadix = false);
6587
+ }
6588
+ else {
6589
+ unsigned = !!unsignedOrRadix;
6590
+ }
6591
+ radix ??= 10;
6592
+ if (str === 'NaN' && radix < 24) {
6593
+ return Long.ZERO;
6594
+ }
6595
+ else if ((str === 'Infinity' || str === '+Infinity' || str === '-Infinity') && radix < 35) {
6596
+ return Long.ZERO;
6597
+ }
6598
+ return Long._fromString(str, unsigned, radix);
6599
+ }
6016
6600
  static fromBytes(bytes, unsigned, le) {
6017
6601
  return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
6018
6602
  }
@@ -6512,11 +7096,11 @@ class Long extends BSONValue {
6512
7096
  }
6513
7097
  return longResult;
6514
7098
  }
6515
- [Symbol.for('nodejs.util.inspect.custom')]() {
6516
- return this.inspect();
6517
- }
6518
- inspect() {
6519
- return `new Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
7099
+ inspect(depth, options, inspect) {
7100
+ inspect ??= defaultInspect;
7101
+ const longVal = inspect(this.toString(), options);
7102
+ const unsignedVal = this.unsigned ? `, ${inspect(this.unsigned, options)}` : '';
7103
+ return `new Long(${longVal}${unsignedVal})`;
6520
7104
  }
6521
7105
  }
6522
7106
  Long.TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL);
@@ -6911,7 +7495,7 @@ class Decimal128 extends BSONValue {
6911
7495
  if (isNegative) {
6912
7496
  dec.high = dec.high.or(Long.fromString('9223372036854775808'));
6913
7497
  }
6914
- const buffer = ByteUtils.allocate(16);
7498
+ const buffer = ByteUtils.allocateUnsafe(16);
6915
7499
  index = 0;
6916
7500
  buffer[index++] = dec.low.low & 0xff;
6917
7501
  buffer[index++] = (dec.low.low >> 8) & 0xff;
@@ -7072,11 +7656,10 @@ class Decimal128 extends BSONValue {
7072
7656
  static fromExtendedJSON(doc) {
7073
7657
  return Decimal128.fromString(doc.$numberDecimal);
7074
7658
  }
7075
- [Symbol.for('nodejs.util.inspect.custom')]() {
7076
- return this.inspect();
7077
- }
7078
- inspect() {
7079
- return `new Decimal128("${this.toString()}")`;
7659
+ inspect(depth, options, inspect) {
7660
+ inspect ??= defaultInspect;
7661
+ const d128string = inspect(this.toString(), options);
7662
+ return `new Decimal128(${d128string})`;
7080
7663
  }
7081
7664
  }
7082
7665
 
@@ -7091,6 +7674,28 @@ class Double extends BSONValue {
7091
7674
  }
7092
7675
  this.value = +value;
7093
7676
  }
7677
+ static fromString(value) {
7678
+ const coercedValue = Number(value);
7679
+ if (value === 'NaN')
7680
+ return new Double(NaN);
7681
+ if (value === 'Infinity')
7682
+ return new Double(Infinity);
7683
+ if (value === '-Infinity')
7684
+ return new Double(-Infinity);
7685
+ if (!Number.isFinite(coercedValue)) {
7686
+ throw new BSONError(`Input: ${value} is not representable as a Double`);
7687
+ }
7688
+ if (value.trim() !== value) {
7689
+ throw new BSONError(`Input: '${value}' contains whitespace`);
7690
+ }
7691
+ if (value === '') {
7692
+ throw new BSONError(`Input is an empty string`);
7693
+ }
7694
+ if (/[^-0-9.+eE]/.test(value)) {
7695
+ throw new BSONError(`Input: '${value}' is not in decimal or exponential notation`);
7696
+ }
7697
+ return new Double(coercedValue);
7698
+ }
7094
7699
  valueOf() {
7095
7700
  return this.value;
7096
7701
  }
@@ -7115,12 +7720,9 @@ class Double extends BSONValue {
7115
7720
  const doubleValue = parseFloat(doc.$numberDouble);
7116
7721
  return options && options.relaxed ? doubleValue : new Double(doubleValue);
7117
7722
  }
7118
- [Symbol.for('nodejs.util.inspect.custom')]() {
7119
- return this.inspect();
7120
- }
7121
- inspect() {
7122
- const eJSON = this.toExtendedJSON();
7123
- return `new Double(${eJSON.$numberDouble})`;
7723
+ inspect(depth, options, inspect) {
7724
+ inspect ??= defaultInspect;
7725
+ return `new Double(${inspect(this.value, options)})`;
7124
7726
  }
7125
7727
  }
7126
7728
 
@@ -7135,6 +7737,23 @@ class Int32 extends BSONValue {
7135
7737
  }
7136
7738
  this.value = +value | 0;
7137
7739
  }
7740
+ static fromString(value) {
7741
+ const cleanedValue = removeLeadingZerosAndExplicitPlus(value);
7742
+ const coercedValue = Number(value);
7743
+ if (BSON_INT32_MAX < coercedValue) {
7744
+ throw new BSONError(`Input: '${value}' is larger than the maximum value for Int32`);
7745
+ }
7746
+ else if (BSON_INT32_MIN > coercedValue) {
7747
+ throw new BSONError(`Input: '${value}' is smaller than the minimum value for Int32`);
7748
+ }
7749
+ else if (!Number.isSafeInteger(coercedValue)) {
7750
+ throw new BSONError(`Input: '${value}' is not a safe integer`);
7751
+ }
7752
+ else if (coercedValue.toString() !== cleanedValue) {
7753
+ throw new BSONError(`Input: '${value}' is not a valid Int32 string`);
7754
+ }
7755
+ return new Int32(coercedValue);
7756
+ }
7138
7757
  valueOf() {
7139
7758
  return this.value;
7140
7759
  }
@@ -7152,11 +7771,9 @@ class Int32 extends BSONValue {
7152
7771
  static fromExtendedJSON(doc, options) {
7153
7772
  return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt);
7154
7773
  }
7155
- [Symbol.for('nodejs.util.inspect.custom')]() {
7156
- return this.inspect();
7157
- }
7158
- inspect() {
7159
- return `new Int32(${this.valueOf()})`;
7774
+ inspect(depth, options, inspect) {
7775
+ inspect ??= defaultInspect;
7776
+ return `new Int32(${inspect(this.value, options)})`;
7160
7777
  }
7161
7778
  }
7162
7779
 
@@ -7170,9 +7787,6 @@ class MaxKey extends BSONValue {
7170
7787
  static fromExtendedJSON() {
7171
7788
  return new MaxKey();
7172
7789
  }
7173
- [Symbol.for('nodejs.util.inspect.custom')]() {
7174
- return this.inspect();
7175
- }
7176
7790
  inspect() {
7177
7791
  return 'new MaxKey()';
7178
7792
  }
@@ -7188,17 +7802,140 @@ class MinKey extends BSONValue {
7188
7802
  static fromExtendedJSON() {
7189
7803
  return new MinKey();
7190
7804
  }
7191
- [Symbol.for('nodejs.util.inspect.custom')]() {
7192
- return this.inspect();
7193
- }
7194
7805
  inspect() {
7195
7806
  return 'new MinKey()';
7196
7807
  }
7197
7808
  }
7198
7809
 
7810
+ const FLOAT = new Float64Array(1);
7811
+ const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
7812
+ FLOAT[0] = -1;
7813
+ const isBigEndian = FLOAT_BYTES[7] === 0;
7814
+ const NumberUtils = {
7815
+ getNonnegativeInt32LE(source, offset) {
7816
+ if (source[offset + 3] > 127) {
7817
+ throw new RangeError(`Size cannot be negative at offset: ${offset}`);
7818
+ }
7819
+ return (source[offset] |
7820
+ (source[offset + 1] << 8) |
7821
+ (source[offset + 2] << 16) |
7822
+ (source[offset + 3] << 24));
7823
+ },
7824
+ getInt32LE(source, offset) {
7825
+ return (source[offset] |
7826
+ (source[offset + 1] << 8) |
7827
+ (source[offset + 2] << 16) |
7828
+ (source[offset + 3] << 24));
7829
+ },
7830
+ getUint32LE(source, offset) {
7831
+ return (source[offset] +
7832
+ source[offset + 1] * 256 +
7833
+ source[offset + 2] * 65536 +
7834
+ source[offset + 3] * 16777216);
7835
+ },
7836
+ getUint32BE(source, offset) {
7837
+ return (source[offset + 3] +
7838
+ source[offset + 2] * 256 +
7839
+ source[offset + 1] * 65536 +
7840
+ source[offset] * 16777216);
7841
+ },
7842
+ getBigInt64LE(source, offset) {
7843
+ const lo = NumberUtils.getUint32LE(source, offset);
7844
+ const hi = NumberUtils.getUint32LE(source, offset + 4);
7845
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
7846
+ },
7847
+ getFloat64LE: isBigEndian
7848
+ ? (source, offset) => {
7849
+ FLOAT_BYTES[7] = source[offset];
7850
+ FLOAT_BYTES[6] = source[offset + 1];
7851
+ FLOAT_BYTES[5] = source[offset + 2];
7852
+ FLOAT_BYTES[4] = source[offset + 3];
7853
+ FLOAT_BYTES[3] = source[offset + 4];
7854
+ FLOAT_BYTES[2] = source[offset + 5];
7855
+ FLOAT_BYTES[1] = source[offset + 6];
7856
+ FLOAT_BYTES[0] = source[offset + 7];
7857
+ return FLOAT[0];
7858
+ }
7859
+ : (source, offset) => {
7860
+ FLOAT_BYTES[0] = source[offset];
7861
+ FLOAT_BYTES[1] = source[offset + 1];
7862
+ FLOAT_BYTES[2] = source[offset + 2];
7863
+ FLOAT_BYTES[3] = source[offset + 3];
7864
+ FLOAT_BYTES[4] = source[offset + 4];
7865
+ FLOAT_BYTES[5] = source[offset + 5];
7866
+ FLOAT_BYTES[6] = source[offset + 6];
7867
+ FLOAT_BYTES[7] = source[offset + 7];
7868
+ return FLOAT[0];
7869
+ },
7870
+ setInt32BE(destination, offset, value) {
7871
+ destination[offset + 3] = value;
7872
+ value >>>= 8;
7873
+ destination[offset + 2] = value;
7874
+ value >>>= 8;
7875
+ destination[offset + 1] = value;
7876
+ value >>>= 8;
7877
+ destination[offset] = value;
7878
+ return 4;
7879
+ },
7880
+ setInt32LE(destination, offset, value) {
7881
+ destination[offset] = value;
7882
+ value >>>= 8;
7883
+ destination[offset + 1] = value;
7884
+ value >>>= 8;
7885
+ destination[offset + 2] = value;
7886
+ value >>>= 8;
7887
+ destination[offset + 3] = value;
7888
+ return 4;
7889
+ },
7890
+ setBigInt64LE(destination, offset, value) {
7891
+ const mask32bits = BigInt(4294967295);
7892
+ let lo = Number(value & mask32bits);
7893
+ destination[offset] = lo;
7894
+ lo >>= 8;
7895
+ destination[offset + 1] = lo;
7896
+ lo >>= 8;
7897
+ destination[offset + 2] = lo;
7898
+ lo >>= 8;
7899
+ destination[offset + 3] = lo;
7900
+ let hi = Number((value >> BigInt(32)) & mask32bits);
7901
+ destination[offset + 4] = hi;
7902
+ hi >>= 8;
7903
+ destination[offset + 5] = hi;
7904
+ hi >>= 8;
7905
+ destination[offset + 6] = hi;
7906
+ hi >>= 8;
7907
+ destination[offset + 7] = hi;
7908
+ return 8;
7909
+ },
7910
+ setFloat64LE: isBigEndian
7911
+ ? (destination, offset, value) => {
7912
+ FLOAT[0] = value;
7913
+ destination[offset] = FLOAT_BYTES[7];
7914
+ destination[offset + 1] = FLOAT_BYTES[6];
7915
+ destination[offset + 2] = FLOAT_BYTES[5];
7916
+ destination[offset + 3] = FLOAT_BYTES[4];
7917
+ destination[offset + 4] = FLOAT_BYTES[3];
7918
+ destination[offset + 5] = FLOAT_BYTES[2];
7919
+ destination[offset + 6] = FLOAT_BYTES[1];
7920
+ destination[offset + 7] = FLOAT_BYTES[0];
7921
+ return 8;
7922
+ }
7923
+ : (destination, offset, value) => {
7924
+ FLOAT[0] = value;
7925
+ destination[offset] = FLOAT_BYTES[0];
7926
+ destination[offset + 1] = FLOAT_BYTES[1];
7927
+ destination[offset + 2] = FLOAT_BYTES[2];
7928
+ destination[offset + 3] = FLOAT_BYTES[3];
7929
+ destination[offset + 4] = FLOAT_BYTES[4];
7930
+ destination[offset + 5] = FLOAT_BYTES[5];
7931
+ destination[offset + 6] = FLOAT_BYTES[6];
7932
+ destination[offset + 7] = FLOAT_BYTES[7];
7933
+ return 8;
7934
+ }
7935
+ };
7936
+
7199
7937
  const checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');
7200
7938
  let PROCESS_UNIQUE = null;
7201
- const kId = Symbol('id');
7202
7939
  class ObjectId extends BSONValue {
7203
7940
  get _bsontype() {
7204
7941
  return 'ObjectId';
@@ -7221,26 +7958,17 @@ class ObjectId extends BSONValue {
7221
7958
  workingId = inputId;
7222
7959
  }
7223
7960
  if (workingId == null || typeof workingId === 'number') {
7224
- this[kId] = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined);
7961
+ this.buffer = ObjectId.generate(typeof workingId === 'number' ? workingId : undefined);
7225
7962
  }
7226
7963
  else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
7227
- this[kId] = ByteUtils.toLocalBufferType(workingId);
7964
+ this.buffer = ByteUtils.toLocalBufferType(workingId);
7228
7965
  }
7229
7966
  else if (typeof workingId === 'string') {
7230
- if (workingId.length === 12) {
7231
- const bytes = ByteUtils.fromUTF8(workingId);
7232
- if (bytes.byteLength === 12) {
7233
- this[kId] = bytes;
7234
- }
7235
- else {
7236
- throw new BSONError('Argument passed in must be a string of 12 bytes');
7237
- }
7238
- }
7239
- else if (workingId.length === 24 && checkForHexRegExp.test(workingId)) {
7240
- this[kId] = ByteUtils.fromHex(workingId);
7967
+ if (workingId.length === 24 && checkForHexRegExp.test(workingId)) {
7968
+ this.buffer = ByteUtils.fromHex(workingId);
7241
7969
  }
7242
7970
  else {
7243
- throw new BSONError('Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer');
7971
+ throw new BSONError('input must be a 24 character hex string, 12 byte Uint8Array, or an integer');
7244
7972
  }
7245
7973
  }
7246
7974
  else {
@@ -7251,10 +7979,10 @@ class ObjectId extends BSONValue {
7251
7979
  }
7252
7980
  }
7253
7981
  get id() {
7254
- return this[kId];
7982
+ return this.buffer;
7255
7983
  }
7256
7984
  set id(value) {
7257
- this[kId] = value;
7985
+ this.buffer = value;
7258
7986
  if (ObjectId.cacheHexString) {
7259
7987
  this.__id = ByteUtils.toHex(value);
7260
7988
  }
@@ -7277,8 +8005,8 @@ class ObjectId extends BSONValue {
7277
8005
  time = Math.floor(Date.now() / 1000);
7278
8006
  }
7279
8007
  const inc = ObjectId.getInc();
7280
- const buffer = ByteUtils.allocate(12);
7281
- BSONDataView.fromUint8Array(buffer).setUint32(0, time, false);
8008
+ const buffer = ByteUtils.allocateUnsafe(12);
8009
+ NumberUtils.setInt32BE(buffer, 0, time);
7282
8010
  if (PROCESS_UNIQUE === null) {
7283
8011
  PROCESS_UNIQUE = ByteUtils.randomBytes(5);
7284
8012
  }
@@ -7302,46 +8030,58 @@ class ObjectId extends BSONValue {
7302
8030
  toJSON() {
7303
8031
  return this.toHexString();
7304
8032
  }
8033
+ static is(variable) {
8034
+ return (variable != null &&
8035
+ typeof variable === 'object' &&
8036
+ '_bsontype' in variable &&
8037
+ variable._bsontype === 'ObjectId');
8038
+ }
7305
8039
  equals(otherId) {
7306
8040
  if (otherId === undefined || otherId === null) {
7307
8041
  return false;
7308
8042
  }
7309
- if (otherId instanceof ObjectId) {
7310
- return this[kId][11] === otherId[kId][11] && ByteUtils.equals(this[kId], otherId[kId]);
8043
+ if (ObjectId.is(otherId)) {
8044
+ return (this.buffer[11] === otherId.buffer[11] && ByteUtils.equals(this.buffer, otherId.buffer));
7311
8045
  }
7312
- if (typeof otherId === 'string' &&
7313
- ObjectId.isValid(otherId) &&
7314
- otherId.length === 12 &&
7315
- isUint8Array(this.id)) {
7316
- return ByteUtils.equals(this.id, ByteUtils.fromISO88591(otherId));
7317
- }
7318
- if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 24) {
8046
+ if (typeof otherId === 'string') {
7319
8047
  return otherId.toLowerCase() === this.toHexString();
7320
8048
  }
7321
- if (typeof otherId === 'string' && ObjectId.isValid(otherId) && otherId.length === 12) {
7322
- return ByteUtils.equals(ByteUtils.fromUTF8(otherId), this.id);
7323
- }
7324
- if (typeof otherId === 'object' &&
7325
- 'toHexString' in otherId &&
7326
- typeof otherId.toHexString === 'function') {
8049
+ if (typeof otherId === 'object' && typeof otherId.toHexString === 'function') {
7327
8050
  const otherIdString = otherId.toHexString();
7328
- const thisIdString = this.toHexString().toLowerCase();
8051
+ const thisIdString = this.toHexString();
7329
8052
  return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
7330
8053
  }
7331
8054
  return false;
7332
8055
  }
7333
8056
  getTimestamp() {
7334
8057
  const timestamp = new Date();
7335
- const time = BSONDataView.fromUint8Array(this.id).getUint32(0, false);
8058
+ const time = NumberUtils.getUint32BE(this.buffer, 0);
7336
8059
  timestamp.setTime(Math.floor(time) * 1000);
7337
8060
  return timestamp;
7338
8061
  }
7339
8062
  static createPk() {
7340
8063
  return new ObjectId();
7341
8064
  }
8065
+ serializeInto(uint8array, index) {
8066
+ uint8array[index] = this.buffer[0];
8067
+ uint8array[index + 1] = this.buffer[1];
8068
+ uint8array[index + 2] = this.buffer[2];
8069
+ uint8array[index + 3] = this.buffer[3];
8070
+ uint8array[index + 4] = this.buffer[4];
8071
+ uint8array[index + 5] = this.buffer[5];
8072
+ uint8array[index + 6] = this.buffer[6];
8073
+ uint8array[index + 7] = this.buffer[7];
8074
+ uint8array[index + 8] = this.buffer[8];
8075
+ uint8array[index + 9] = this.buffer[9];
8076
+ uint8array[index + 10] = this.buffer[10];
8077
+ uint8array[index + 11] = this.buffer[11];
8078
+ return 12;
8079
+ }
7342
8080
  static createFromTime(time) {
7343
- const buffer = ByteUtils.fromNumberArray([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
7344
- BSONDataView.fromUint8Array(buffer).setUint32(0, time, false);
8081
+ const buffer = ByteUtils.allocate(12);
8082
+ for (let i = 11; i >= 4; i--)
8083
+ buffer[i] = 0;
8084
+ NumberUtils.setInt32BE(buffer, 0, time);
7345
8085
  return new ObjectId(buffer);
7346
8086
  }
7347
8087
  static createFromHexString(hexString) {
@@ -7375,11 +8115,9 @@ class ObjectId extends BSONValue {
7375
8115
  static fromExtendedJSON(doc) {
7376
8116
  return new ObjectId(doc.$oid);
7377
8117
  }
7378
- [Symbol.for('nodejs.util.inspect.custom')]() {
7379
- return this.inspect();
7380
- }
7381
- inspect() {
7382
- return `new ObjectId("${this.toHexString()}")`;
8118
+ inspect(depth, options, inspect) {
8119
+ inspect ??= defaultInspect;
8120
+ return `new ObjectId(${inspect(this.toHexString(), options)})`;
7383
8121
  }
7384
8122
  }
7385
8123
  ObjectId.index = Math.floor(Math.random() * 0xffffff);
@@ -7592,11 +8330,12 @@ class BSONRegExp extends BSONValue {
7592
8330
  }
7593
8331
  throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`);
7594
8332
  }
7595
- [Symbol.for('nodejs.util.inspect.custom')]() {
7596
- return this.inspect();
7597
- }
7598
- inspect() {
7599
- return `new BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
8333
+ inspect(depth, options, inspect) {
8334
+ const stylize = getStylizeFunction(options) ?? (v => v);
8335
+ inspect ??= defaultInspect;
8336
+ const pattern = stylize(inspect(this.pattern), 'regexp');
8337
+ const flags = stylize(inspect(this.options), 'regexp');
8338
+ return `new BSONRegExp(${pattern}, ${flags})`;
7600
8339
  }
7601
8340
  }
7602
8341
 
@@ -7614,9 +8353,6 @@ class BSONSymbol extends BSONValue {
7614
8353
  toString() {
7615
8354
  return this.value;
7616
8355
  }
7617
- inspect() {
7618
- return `new BSONSymbol("${this.value}")`;
7619
- }
7620
8356
  toJSON() {
7621
8357
  return this.value;
7622
8358
  }
@@ -7626,8 +8362,9 @@ class BSONSymbol extends BSONValue {
7626
8362
  static fromExtendedJSON(doc) {
7627
8363
  return new BSONSymbol(doc.$symbol);
7628
8364
  }
7629
- [Symbol.for('nodejs.util.inspect.custom')]() {
7630
- return this.inspect();
8365
+ inspect(depth, options, inspect) {
8366
+ inspect ??= defaultInspect;
8367
+ return `new BSONSymbol(${inspect(this.value, options)})`;
7631
8368
  }
7632
8369
  }
7633
8370
 
@@ -7702,61 +8439,21 @@ class Timestamp extends LongWithoutOverridesClass {
7702
8439
  : doc.$timestamp.t;
7703
8440
  return new Timestamp({ t, i });
7704
8441
  }
7705
- [Symbol.for('nodejs.util.inspect.custom')]() {
7706
- return this.inspect();
7707
- }
7708
- inspect() {
7709
- return `new Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
8442
+ inspect(depth, options, inspect) {
8443
+ inspect ??= defaultInspect;
8444
+ const t = inspect(this.high >>> 0, options);
8445
+ const i = inspect(this.low >>> 0, options);
8446
+ return `new Timestamp({ t: ${t}, i: ${i} })`;
7710
8447
  }
7711
8448
  }
7712
8449
  Timestamp.MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
7713
8450
 
7714
- const FIRST_BIT = 0x80;
7715
- const FIRST_TWO_BITS = 0xc0;
7716
- const FIRST_THREE_BITS = 0xe0;
7717
- const FIRST_FOUR_BITS = 0xf0;
7718
- const FIRST_FIVE_BITS = 0xf8;
7719
- const TWO_BIT_CHAR = 0xc0;
7720
- const THREE_BIT_CHAR = 0xe0;
7721
- const FOUR_BIT_CHAR = 0xf0;
7722
- const CONTINUING_CHAR = 0x80;
7723
- function validateUtf8(bytes, start, end) {
7724
- let continuation = 0;
7725
- for (let i = start; i < end; i += 1) {
7726
- const byte = bytes[i];
7727
- if (continuation) {
7728
- if ((byte & FIRST_TWO_BITS) !== CONTINUING_CHAR) {
7729
- return false;
7730
- }
7731
- continuation -= 1;
7732
- }
7733
- else if (byte & FIRST_BIT) {
7734
- if ((byte & FIRST_THREE_BITS) === TWO_BIT_CHAR) {
7735
- continuation = 1;
7736
- }
7737
- else if ((byte & FIRST_FOUR_BITS) === THREE_BIT_CHAR) {
7738
- continuation = 2;
7739
- }
7740
- else if ((byte & FIRST_FIVE_BITS) === FOUR_BIT_CHAR) {
7741
- continuation = 3;
7742
- }
7743
- else {
7744
- return false;
7745
- }
7746
- }
7747
- }
7748
- return !continuation;
7749
- }
7750
-
7751
8451
  const JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
7752
8452
  const JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
7753
8453
  function internalDeserialize(buffer, options, isArray) {
7754
8454
  options = options == null ? {} : options;
7755
8455
  const index = options && options.index ? options.index : 0;
7756
- const size = buffer[index] |
7757
- (buffer[index + 1] << 8) |
7758
- (buffer[index + 2] << 16) |
7759
- (buffer[index + 3] << 24);
8456
+ const size = NumberUtils.getInt32LE(buffer, index);
7760
8457
  if (size < 5) {
7761
8458
  throw new BSONError(`bson size must be >= 5, is ${size}`);
7762
8459
  }
@@ -7792,7 +8489,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
7792
8489
  const validation = options.validation == null ? { utf8: true } : options.validation;
7793
8490
  let globalUTFValidation = true;
7794
8491
  let validationSetting;
7795
- const utf8KeysSet = new Set();
8492
+ let utf8KeysSet;
7796
8493
  const utf8ValidatedKeys = validation.utf8;
7797
8494
  if (typeof utf8ValidatedKeys === 'boolean') {
7798
8495
  validationSetting = utf8ValidatedKeys;
@@ -7814,6 +8511,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
7814
8511
  }
7815
8512
  }
7816
8513
  if (!globalUTFValidation) {
8514
+ utf8KeysSet = new Set();
7817
8515
  for (const key of Object.keys(utf8ValidatedKeys)) {
7818
8516
  utf8KeysSet.add(key);
7819
8517
  }
@@ -7821,14 +8519,14 @@ function deserializeObject(buffer, index, options, isArray = false) {
7821
8519
  const startIndex = index;
7822
8520
  if (buffer.length < 5)
7823
8521
  throw new BSONError('corrupt bson message < 5 bytes long');
7824
- const size = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
8522
+ const size = NumberUtils.getInt32LE(buffer, index);
8523
+ index += 4;
7825
8524
  if (size < 5 || size > buffer.length)
7826
8525
  throw new BSONError('corrupt bson message');
7827
8526
  const object = isArray ? [] : {};
7828
8527
  let arrayIndex = 0;
7829
8528
  const done = false;
7830
8529
  let isPossibleDBRef = isArray ? false : null;
7831
- const dataview = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
7832
8530
  while (!done) {
7833
8531
  const elementType = buffer[index++];
7834
8532
  if (elementType === 0)
@@ -7839,9 +8537,9 @@ function deserializeObject(buffer, index, options, isArray = false) {
7839
8537
  }
7840
8538
  if (i >= buffer.byteLength)
7841
8539
  throw new BSONError('Bad BSON Document: illegal CString');
7842
- const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer, index, i);
8540
+ const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer, index, i, false);
7843
8541
  let shouldValidateKey = true;
7844
- if (globalUTFValidation || utf8KeysSet.has(name)) {
8542
+ if (globalUTFValidation || utf8KeysSet?.has(name)) {
7845
8543
  shouldValidateKey = validationSetting;
7846
8544
  }
7847
8545
  else {
@@ -7853,51 +8551,41 @@ function deserializeObject(buffer, index, options, isArray = false) {
7853
8551
  let value;
7854
8552
  index = i + 1;
7855
8553
  if (elementType === BSON_DATA_STRING) {
7856
- const stringSize = buffer[index++] |
7857
- (buffer[index++] << 8) |
7858
- (buffer[index++] << 16) |
7859
- (buffer[index++] << 24);
8554
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
8555
+ index += 4;
7860
8556
  if (stringSize <= 0 ||
7861
8557
  stringSize > buffer.length - index ||
7862
8558
  buffer[index + stringSize - 1] !== 0) {
7863
8559
  throw new BSONError('bad string length in bson');
7864
8560
  }
7865
- value = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey);
8561
+ value = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
7866
8562
  index = index + stringSize;
7867
8563
  }
7868
8564
  else if (elementType === BSON_DATA_OID) {
7869
- const oid = ByteUtils.allocate(12);
7870
- oid.set(buffer.subarray(index, index + 12));
8565
+ const oid = ByteUtils.allocateUnsafe(12);
8566
+ for (let i = 0; i < 12; i++)
8567
+ oid[i] = buffer[index + i];
7871
8568
  value = new ObjectId(oid);
7872
8569
  index = index + 12;
7873
8570
  }
7874
8571
  else if (elementType === BSON_DATA_INT && promoteValues === false) {
7875
- value = new Int32(buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24));
8572
+ value = new Int32(NumberUtils.getInt32LE(buffer, index));
8573
+ index += 4;
7876
8574
  }
7877
8575
  else if (elementType === BSON_DATA_INT) {
7878
- value =
7879
- buffer[index++] |
7880
- (buffer[index++] << 8) |
7881
- (buffer[index++] << 16) |
7882
- (buffer[index++] << 24);
7883
- }
7884
- else if (elementType === BSON_DATA_NUMBER && promoteValues === false) {
7885
- value = new Double(dataview.getFloat64(index, true));
7886
- index = index + 8;
8576
+ value = NumberUtils.getInt32LE(buffer, index);
8577
+ index += 4;
7887
8578
  }
7888
8579
  else if (elementType === BSON_DATA_NUMBER) {
7889
- value = dataview.getFloat64(index, true);
7890
- index = index + 8;
8580
+ value = NumberUtils.getFloat64LE(buffer, index);
8581
+ index += 8;
8582
+ if (promoteValues === false)
8583
+ value = new Double(value);
7891
8584
  }
7892
8585
  else if (elementType === BSON_DATA_DATE) {
7893
- const lowBits = buffer[index++] |
7894
- (buffer[index++] << 8) |
7895
- (buffer[index++] << 16) |
7896
- (buffer[index++] << 24);
7897
- const highBits = buffer[index++] |
7898
- (buffer[index++] << 8) |
7899
- (buffer[index++] << 16) |
7900
- (buffer[index++] << 24);
8586
+ const lowBits = NumberUtils.getInt32LE(buffer, index);
8587
+ const highBits = NumberUtils.getInt32LE(buffer, index + 4);
8588
+ index += 8;
7901
8589
  value = new Date(new Long(lowBits, highBits).toNumber());
7902
8590
  }
7903
8591
  else if (elementType === BSON_DATA_BOOLEAN) {
@@ -7907,10 +8595,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
7907
8595
  }
7908
8596
  else if (elementType === BSON_DATA_OBJECT) {
7909
8597
  const _index = index;
7910
- const objectSize = buffer[index] |
7911
- (buffer[index + 1] << 8) |
7912
- (buffer[index + 2] << 16) |
7913
- (buffer[index + 3] << 24);
8598
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
7914
8599
  if (objectSize <= 0 || objectSize > buffer.length - index)
7915
8600
  throw new BSONError('bad embedded document length in bson');
7916
8601
  if (raw) {
@@ -7927,10 +8612,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
7927
8612
  }
7928
8613
  else if (elementType === BSON_DATA_ARRAY) {
7929
8614
  const _index = index;
7930
- const objectSize = buffer[index] |
7931
- (buffer[index + 1] << 8) |
7932
- (buffer[index + 2] << 16) |
7933
- (buffer[index + 3] << 24);
8615
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
7934
8616
  let arrayOptions = options;
7935
8617
  const stopIndex = index + objectSize;
7936
8618
  if (fieldsAsRaw && fieldsAsRaw[name]) {
@@ -7953,40 +8635,36 @@ function deserializeObject(buffer, index, options, isArray = false) {
7953
8635
  value = null;
7954
8636
  }
7955
8637
  else if (elementType === BSON_DATA_LONG) {
7956
- const dataview = BSONDataView.fromUint8Array(buffer.subarray(index, index + 8));
7957
- const lowBits = buffer[index++] |
7958
- (buffer[index++] << 8) |
7959
- (buffer[index++] << 16) |
7960
- (buffer[index++] << 24);
7961
- const highBits = buffer[index++] |
7962
- (buffer[index++] << 8) |
7963
- (buffer[index++] << 16) |
7964
- (buffer[index++] << 24);
7965
- const long = new Long(lowBits, highBits);
7966
8638
  if (useBigInt64) {
7967
- value = dataview.getBigInt64(0, true);
7968
- }
7969
- else if (promoteLongs && promoteValues === true) {
7970
- value =
7971
- long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG)
7972
- ? long.toNumber()
7973
- : long;
8639
+ value = NumberUtils.getBigInt64LE(buffer, index);
8640
+ index += 8;
7974
8641
  }
7975
8642
  else {
7976
- value = long;
8643
+ const lowBits = NumberUtils.getInt32LE(buffer, index);
8644
+ const highBits = NumberUtils.getInt32LE(buffer, index + 4);
8645
+ index += 8;
8646
+ const long = new Long(lowBits, highBits);
8647
+ if (promoteLongs && promoteValues === true) {
8648
+ value =
8649
+ long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG)
8650
+ ? long.toNumber()
8651
+ : long;
8652
+ }
8653
+ else {
8654
+ value = long;
8655
+ }
7977
8656
  }
7978
8657
  }
7979
8658
  else if (elementType === BSON_DATA_DECIMAL128) {
7980
- const bytes = ByteUtils.allocate(16);
7981
- bytes.set(buffer.subarray(index, index + 16), 0);
8659
+ const bytes = ByteUtils.allocateUnsafe(16);
8660
+ for (let i = 0; i < 16; i++)
8661
+ bytes[i] = buffer[index + i];
7982
8662
  index = index + 16;
7983
8663
  value = new Decimal128(bytes);
7984
8664
  }
7985
8665
  else if (elementType === BSON_DATA_BINARY) {
7986
- let binarySize = buffer[index++] |
7987
- (buffer[index++] << 8) |
7988
- (buffer[index++] << 16) |
7989
- (buffer[index++] << 24);
8666
+ let binarySize = NumberUtils.getInt32LE(buffer, index);
8667
+ index += 4;
7990
8668
  const totalBinarySize = binarySize;
7991
8669
  const subType = buffer[index++];
7992
8670
  if (binarySize < 0)
@@ -7995,11 +8673,8 @@ function deserializeObject(buffer, index, options, isArray = false) {
7995
8673
  throw new BSONError('Binary type size larger than document size');
7996
8674
  if (buffer['slice'] != null) {
7997
8675
  if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
7998
- binarySize =
7999
- buffer[index++] |
8000
- (buffer[index++] << 8) |
8001
- (buffer[index++] << 16) |
8002
- (buffer[index++] << 24);
8676
+ binarySize = NumberUtils.getInt32LE(buffer, index);
8677
+ index += 4;
8003
8678
  if (binarySize < 0)
8004
8679
  throw new BSONError('Negative binary type element size found for subtype 0x02');
8005
8680
  if (binarySize > totalBinarySize - 4)
@@ -8018,13 +8693,9 @@ function deserializeObject(buffer, index, options, isArray = false) {
8018
8693
  }
8019
8694
  }
8020
8695
  else {
8021
- const _buffer = ByteUtils.allocate(binarySize);
8022
8696
  if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
8023
- binarySize =
8024
- buffer[index++] |
8025
- (buffer[index++] << 8) |
8026
- (buffer[index++] << 16) |
8027
- (buffer[index++] << 24);
8697
+ binarySize = NumberUtils.getInt32LE(buffer, index);
8698
+ index += 4;
8028
8699
  if (binarySize < 0)
8029
8700
  throw new BSONError('Negative binary type element size found for subtype 0x02');
8030
8701
  if (binarySize > totalBinarySize - 4)
@@ -8032,11 +8703,11 @@ function deserializeObject(buffer, index, options, isArray = false) {
8032
8703
  if (binarySize < totalBinarySize - 4)
8033
8704
  throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
8034
8705
  }
8035
- for (i = 0; i < binarySize; i++) {
8036
- _buffer[i] = buffer[index + i];
8037
- }
8038
8706
  if (promoteBuffers && promoteValues) {
8039
- value = _buffer;
8707
+ value = ByteUtils.allocateUnsafe(binarySize);
8708
+ for (i = 0; i < binarySize; i++) {
8709
+ value[i] = buffer[index + i];
8710
+ }
8040
8711
  }
8041
8712
  else {
8042
8713
  value = new Binary(buffer.slice(index, index + binarySize), subType);
@@ -8054,7 +8725,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
8054
8725
  }
8055
8726
  if (i >= buffer.length)
8056
8727
  throw new BSONError('Bad BSON Document: illegal CString');
8057
- const source = ByteUtils.toUTF8(buffer, index, i);
8728
+ const source = ByteUtils.toUTF8(buffer, index, i, false);
8058
8729
  index = i + 1;
8059
8730
  i = index;
8060
8731
  while (buffer[i] !== 0x00 && i < buffer.length) {
@@ -8062,7 +8733,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
8062
8733
  }
8063
8734
  if (i >= buffer.length)
8064
8735
  throw new BSONError('Bad BSON Document: illegal CString');
8065
- const regExpOptions = ByteUtils.toUTF8(buffer, index, i);
8736
+ const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
8066
8737
  index = i + 1;
8067
8738
  const optionsArray = new Array(regExpOptions.length);
8068
8739
  for (i = 0; i < regExpOptions.length; i++) {
@@ -8087,7 +8758,7 @@ function deserializeObject(buffer, index, options, isArray = false) {
8087
8758
  }
8088
8759
  if (i >= buffer.length)
8089
8760
  throw new BSONError('Bad BSON Document: illegal CString');
8090
- const source = ByteUtils.toUTF8(buffer, index, i);
8761
+ const source = ByteUtils.toUTF8(buffer, index, i, false);
8091
8762
  index = i + 1;
8092
8763
  i = index;
8093
8764
  while (buffer[i] !== 0x00 && i < buffer.length) {
@@ -8095,34 +8766,28 @@ function deserializeObject(buffer, index, options, isArray = false) {
8095
8766
  }
8096
8767
  if (i >= buffer.length)
8097
8768
  throw new BSONError('Bad BSON Document: illegal CString');
8098
- const regExpOptions = ByteUtils.toUTF8(buffer, index, i);
8769
+ const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
8099
8770
  index = i + 1;
8100
8771
  value = new BSONRegExp(source, regExpOptions);
8101
8772
  }
8102
8773
  else if (elementType === BSON_DATA_SYMBOL) {
8103
- const stringSize = buffer[index++] |
8104
- (buffer[index++] << 8) |
8105
- (buffer[index++] << 16) |
8106
- (buffer[index++] << 24);
8774
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
8775
+ index += 4;
8107
8776
  if (stringSize <= 0 ||
8108
8777
  stringSize > buffer.length - index ||
8109
8778
  buffer[index + stringSize - 1] !== 0) {
8110
8779
  throw new BSONError('bad string length in bson');
8111
8780
  }
8112
- const symbol = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey);
8781
+ const symbol = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
8113
8782
  value = promoteValues ? symbol : new BSONSymbol(symbol);
8114
8783
  index = index + stringSize;
8115
8784
  }
8116
8785
  else if (elementType === BSON_DATA_TIMESTAMP) {
8117
- const i = buffer[index++] +
8118
- buffer[index++] * (1 << 8) +
8119
- buffer[index++] * (1 << 16) +
8120
- buffer[index++] * (1 << 24);
8121
- const t = buffer[index++] +
8122
- buffer[index++] * (1 << 8) +
8123
- buffer[index++] * (1 << 16) +
8124
- buffer[index++] * (1 << 24);
8125
- value = new Timestamp({ i, t });
8786
+ value = new Timestamp({
8787
+ i: NumberUtils.getUint32LE(buffer, index),
8788
+ t: NumberUtils.getUint32LE(buffer, index + 4)
8789
+ });
8790
+ index += 8;
8126
8791
  }
8127
8792
  else if (elementType === BSON_DATA_MIN_KEY) {
8128
8793
  value = new MinKey();
@@ -8131,43 +8796,34 @@ function deserializeObject(buffer, index, options, isArray = false) {
8131
8796
  value = new MaxKey();
8132
8797
  }
8133
8798
  else if (elementType === BSON_DATA_CODE) {
8134
- const stringSize = buffer[index++] |
8135
- (buffer[index++] << 8) |
8136
- (buffer[index++] << 16) |
8137
- (buffer[index++] << 24);
8799
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
8800
+ index += 4;
8138
8801
  if (stringSize <= 0 ||
8139
8802
  stringSize > buffer.length - index ||
8140
8803
  buffer[index + stringSize - 1] !== 0) {
8141
8804
  throw new BSONError('bad string length in bson');
8142
8805
  }
8143
- const functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey);
8806
+ const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
8144
8807
  value = new Code(functionString);
8145
8808
  index = index + stringSize;
8146
8809
  }
8147
8810
  else if (elementType === BSON_DATA_CODE_W_SCOPE) {
8148
- const totalSize = buffer[index++] |
8149
- (buffer[index++] << 8) |
8150
- (buffer[index++] << 16) |
8151
- (buffer[index++] << 24);
8811
+ const totalSize = NumberUtils.getInt32LE(buffer, index);
8812
+ index += 4;
8152
8813
  if (totalSize < 4 + 4 + 4 + 1) {
8153
8814
  throw new BSONError('code_w_scope total size shorter minimum expected length');
8154
8815
  }
8155
- const stringSize = buffer[index++] |
8156
- (buffer[index++] << 8) |
8157
- (buffer[index++] << 16) |
8158
- (buffer[index++] << 24);
8816
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
8817
+ index += 4;
8159
8818
  if (stringSize <= 0 ||
8160
8819
  stringSize > buffer.length - index ||
8161
8820
  buffer[index + stringSize - 1] !== 0) {
8162
8821
  throw new BSONError('bad string length in bson');
8163
8822
  }
8164
- const functionString = getValidatedString(buffer, index, index + stringSize - 1, shouldValidateKey);
8823
+ const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
8165
8824
  index = index + stringSize;
8166
8825
  const _index = index;
8167
- const objectSize = buffer[index] |
8168
- (buffer[index + 1] << 8) |
8169
- (buffer[index + 2] << 16) |
8170
- (buffer[index + 3] << 24);
8826
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
8171
8827
  const scopeObject = deserializeObject(buffer, _index, options, false);
8172
8828
  index = index + objectSize;
8173
8829
  if (totalSize < 4 + 4 + objectSize + stringSize) {
@@ -8179,23 +8835,17 @@ function deserializeObject(buffer, index, options, isArray = false) {
8179
8835
  value = new Code(functionString, scopeObject);
8180
8836
  }
8181
8837
  else if (elementType === BSON_DATA_DBPOINTER) {
8182
- const stringSize = buffer[index++] |
8183
- (buffer[index++] << 8) |
8184
- (buffer[index++] << 16) |
8185
- (buffer[index++] << 24);
8838
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
8839
+ index += 4;
8186
8840
  if (stringSize <= 0 ||
8187
8841
  stringSize > buffer.length - index ||
8188
8842
  buffer[index + stringSize - 1] !== 0)
8189
8843
  throw new BSONError('bad string length in bson');
8190
- if (validation != null && validation.utf8) {
8191
- if (!validateUtf8(buffer, index, index + stringSize - 1)) {
8192
- throw new BSONError('Invalid UTF-8 string in BSON document');
8193
- }
8194
- }
8195
- const namespace = ByteUtils.toUTF8(buffer, index, index + stringSize - 1);
8844
+ const namespace = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
8196
8845
  index = index + stringSize;
8197
- const oidBuffer = ByteUtils.allocate(12);
8198
- oidBuffer.set(buffer.subarray(index, index + 12), 0);
8846
+ const oidBuffer = ByteUtils.allocateUnsafe(12);
8847
+ for (let i = 0; i < 12; i++)
8848
+ oidBuffer[i] = buffer[index + i];
8199
8849
  const oid = new ObjectId(oidBuffer);
8200
8850
  index = index + 12;
8201
8851
  value = new DBRef(namespace, oid);
@@ -8231,20 +8881,6 @@ function deserializeObject(buffer, index, options, isArray = false) {
8231
8881
  }
8232
8882
  return object;
8233
8883
  }
8234
- function getValidatedString(buffer, start, end, shouldValidateUtf8) {
8235
- const value = ByteUtils.toUTF8(buffer, start, end);
8236
- if (shouldValidateUtf8) {
8237
- for (let i = 0; i < value.length; i++) {
8238
- if (value.charCodeAt(i) === 0xfffd) {
8239
- if (!validateUtf8(buffer, start, end)) {
8240
- throw new BSONError('Invalid UTF-8 string in BSON document');
8241
- }
8242
- break;
8243
- }
8244
- }
8245
- }
8246
- return value;
8247
- }
8248
8884
 
8249
8885
  const regexp = /\x00/;
8250
8886
  const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
@@ -8254,17 +8890,11 @@ function serializeString(buffer, key, value, index) {
8254
8890
  index = index + numberOfWrittenBytes + 1;
8255
8891
  buffer[index - 1] = 0;
8256
8892
  const size = ByteUtils.encodeUTF8Into(buffer, value, index + 4);
8257
- buffer[index + 3] = ((size + 1) >> 24) & 0xff;
8258
- buffer[index + 2] = ((size + 1) >> 16) & 0xff;
8259
- buffer[index + 1] = ((size + 1) >> 8) & 0xff;
8260
- buffer[index] = (size + 1) & 0xff;
8893
+ NumberUtils.setInt32LE(buffer, index, size + 1);
8261
8894
  index = index + 4 + size;
8262
8895
  buffer[index++] = 0;
8263
8896
  return index;
8264
8897
  }
8265
- const NUMBER_SPACE = new DataView(new ArrayBuffer(8), 0, 8);
8266
- const FOUR_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 4);
8267
- const EIGHT_BYTE_VIEW_ON_NUMBER = new Uint8Array(NUMBER_SPACE.buffer, 0, 8);
8268
8898
  function serializeNumber(buffer, key, value, index) {
8269
8899
  const isNegativeZero = Object.is(value, -0);
8270
8900
  const type = !isNegativeZero &&
@@ -8273,19 +8903,16 @@ function serializeNumber(buffer, key, value, index) {
8273
8903
  value >= BSON_INT32_MIN
8274
8904
  ? BSON_DATA_INT
8275
8905
  : BSON_DATA_NUMBER;
8276
- if (type === BSON_DATA_INT) {
8277
- NUMBER_SPACE.setInt32(0, value, true);
8278
- }
8279
- else {
8280
- NUMBER_SPACE.setFloat64(0, value, true);
8281
- }
8282
- const bytes = type === BSON_DATA_INT ? FOUR_BYTE_VIEW_ON_NUMBER : EIGHT_BYTE_VIEW_ON_NUMBER;
8283
8906
  buffer[index++] = type;
8284
8907
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8285
8908
  index = index + numberOfWrittenBytes;
8286
8909
  buffer[index++] = 0x00;
8287
- buffer.set(bytes, index);
8288
- index += bytes.byteLength;
8910
+ if (type === BSON_DATA_INT) {
8911
+ index += NumberUtils.setInt32LE(buffer, index, value);
8912
+ }
8913
+ else {
8914
+ index += NumberUtils.setFloat64LE(buffer, index, value);
8915
+ }
8289
8916
  return index;
8290
8917
  }
8291
8918
  function serializeBigInt(buffer, key, value, index) {
@@ -8293,9 +8920,7 @@ function serializeBigInt(buffer, key, value, index) {
8293
8920
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8294
8921
  index += numberOfWrittenBytes;
8295
8922
  buffer[index++] = 0;
8296
- NUMBER_SPACE.setBigInt64(0, value, true);
8297
- buffer.set(EIGHT_BYTE_VIEW_ON_NUMBER, index);
8298
- index += EIGHT_BYTE_VIEW_ON_NUMBER.byteLength;
8923
+ index += NumberUtils.setBigInt64LE(buffer, index, value);
8299
8924
  return index;
8300
8925
  }
8301
8926
  function serializeNull(buffer, key, _, index) {
@@ -8321,14 +8946,8 @@ function serializeDate(buffer, key, value, index) {
8321
8946
  const dateInMilis = Long.fromNumber(value.getTime());
8322
8947
  const lowBits = dateInMilis.getLowBits();
8323
8948
  const highBits = dateInMilis.getHighBits();
8324
- buffer[index++] = lowBits & 0xff;
8325
- buffer[index++] = (lowBits >> 8) & 0xff;
8326
- buffer[index++] = (lowBits >> 16) & 0xff;
8327
- buffer[index++] = (lowBits >> 24) & 0xff;
8328
- buffer[index++] = highBits & 0xff;
8329
- buffer[index++] = (highBits >> 8) & 0xff;
8330
- buffer[index++] = (highBits >> 16) & 0xff;
8331
- buffer[index++] = (highBits >> 24) & 0xff;
8949
+ index += NumberUtils.setInt32LE(buffer, index, lowBits);
8950
+ index += NumberUtils.setInt32LE(buffer, index, highBits);
8332
8951
  return index;
8333
8952
  }
8334
8953
  function serializeRegExp(buffer, key, value, index) {
@@ -8385,13 +9004,8 @@ function serializeObjectId(buffer, key, value, index) {
8385
9004
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8386
9005
  index = index + numberOfWrittenBytes;
8387
9006
  buffer[index++] = 0;
8388
- if (isUint8Array(value.id)) {
8389
- buffer.set(value.id.subarray(0, 12), index);
8390
- }
8391
- else {
8392
- throw new BSONError('object [' + JSON.stringify(value) + '] is not a valid ObjectId');
8393
- }
8394
- return index + 12;
9007
+ index += value.serializeInto(buffer, index);
9008
+ return index;
8395
9009
  }
8396
9010
  function serializeBuffer(buffer, key, value, index) {
8397
9011
  buffer[index++] = BSON_DATA_BINARY;
@@ -8399,12 +9013,15 @@ function serializeBuffer(buffer, key, value, index) {
8399
9013
  index = index + numberOfWrittenBytes;
8400
9014
  buffer[index++] = 0;
8401
9015
  const size = value.length;
8402
- buffer[index++] = size & 0xff;
8403
- buffer[index++] = (size >> 8) & 0xff;
8404
- buffer[index++] = (size >> 16) & 0xff;
8405
- buffer[index++] = (size >> 24) & 0xff;
9016
+ index += NumberUtils.setInt32LE(buffer, index, size);
8406
9017
  buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
8407
- buffer.set(value, index);
9018
+ if (size <= 16) {
9019
+ for (let i = 0; i < size; i++)
9020
+ buffer[index + i] = value[i];
9021
+ }
9022
+ else {
9023
+ buffer.set(value, index);
9024
+ }
8408
9025
  index = index + size;
8409
9026
  return index;
8410
9027
  }
@@ -8426,7 +9043,8 @@ function serializeDecimal128(buffer, key, value, index) {
8426
9043
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8427
9044
  index = index + numberOfWrittenBytes;
8428
9045
  buffer[index++] = 0;
8429
- buffer.set(value.bytes.subarray(0, 16), index);
9046
+ for (let i = 0; i < 16; i++)
9047
+ buffer[index + i] = value.bytes[i];
8430
9048
  return index + 16;
8431
9049
  }
8432
9050
  function serializeLong(buffer, key, value, index) {
@@ -8437,14 +9055,8 @@ function serializeLong(buffer, key, value, index) {
8437
9055
  buffer[index++] = 0;
8438
9056
  const lowBits = value.getLowBits();
8439
9057
  const highBits = value.getHighBits();
8440
- buffer[index++] = lowBits & 0xff;
8441
- buffer[index++] = (lowBits >> 8) & 0xff;
8442
- buffer[index++] = (lowBits >> 16) & 0xff;
8443
- buffer[index++] = (lowBits >> 24) & 0xff;
8444
- buffer[index++] = highBits & 0xff;
8445
- buffer[index++] = (highBits >> 8) & 0xff;
8446
- buffer[index++] = (highBits >> 16) & 0xff;
8447
- buffer[index++] = (highBits >> 24) & 0xff;
9058
+ index += NumberUtils.setInt32LE(buffer, index, lowBits);
9059
+ index += NumberUtils.setInt32LE(buffer, index, highBits);
8448
9060
  return index;
8449
9061
  }
8450
9062
  function serializeInt32(buffer, key, value, index) {
@@ -8453,10 +9065,7 @@ function serializeInt32(buffer, key, value, index) {
8453
9065
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8454
9066
  index = index + numberOfWrittenBytes;
8455
9067
  buffer[index++] = 0;
8456
- buffer[index++] = value & 0xff;
8457
- buffer[index++] = (value >> 8) & 0xff;
8458
- buffer[index++] = (value >> 16) & 0xff;
8459
- buffer[index++] = (value >> 24) & 0xff;
9068
+ index += NumberUtils.setInt32LE(buffer, index, value);
8460
9069
  return index;
8461
9070
  }
8462
9071
  function serializeDouble(buffer, key, value, index) {
@@ -8464,9 +9073,7 @@ function serializeDouble(buffer, key, value, index) {
8464
9073
  const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
8465
9074
  index = index + numberOfWrittenBytes;
8466
9075
  buffer[index++] = 0;
8467
- NUMBER_SPACE.setFloat64(0, value.value, true);
8468
- buffer.set(EIGHT_BYTE_VIEW_ON_NUMBER, index);
8469
- index = index + 8;
9076
+ index += NumberUtils.setFloat64LE(buffer, index, value.value);
8470
9077
  return index;
8471
9078
  }
8472
9079
  function serializeFunction(buffer, key, value, index) {
@@ -8476,10 +9083,7 @@ function serializeFunction(buffer, key, value, index) {
8476
9083
  buffer[index++] = 0;
8477
9084
  const functionString = value.toString();
8478
9085
  const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
8479
- buffer[index] = size & 0xff;
8480
- buffer[index + 1] = (size >> 8) & 0xff;
8481
- buffer[index + 2] = (size >> 16) & 0xff;
8482
- buffer[index + 3] = (size >> 24) & 0xff;
9086
+ NumberUtils.setInt32LE(buffer, index, size);
8483
9087
  index = index + 4 + size - 1;
8484
9088
  buffer[index++] = 0;
8485
9089
  return index;
@@ -8494,19 +9098,13 @@ function serializeCode(buffer, key, value, index, checkKeys = false, depth = 0,
8494
9098
  const functionString = value.code;
8495
9099
  index = index + 4;
8496
9100
  const codeSize = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
8497
- buffer[index] = codeSize & 0xff;
8498
- buffer[index + 1] = (codeSize >> 8) & 0xff;
8499
- buffer[index + 2] = (codeSize >> 16) & 0xff;
8500
- buffer[index + 3] = (codeSize >> 24) & 0xff;
9101
+ NumberUtils.setInt32LE(buffer, index, codeSize);
8501
9102
  buffer[index + 4 + codeSize - 1] = 0;
8502
9103
  index = index + codeSize + 4;
8503
9104
  const endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
8504
9105
  index = endIndex - 1;
8505
9106
  const totalSize = endIndex - startIndex;
8506
- buffer[startIndex++] = totalSize & 0xff;
8507
- buffer[startIndex++] = (totalSize >> 8) & 0xff;
8508
- buffer[startIndex++] = (totalSize >> 16) & 0xff;
8509
- buffer[startIndex++] = (totalSize >> 24) & 0xff;
9107
+ startIndex += NumberUtils.setInt32LE(buffer, startIndex, totalSize);
8510
9108
  buffer[index++] = 0;
8511
9109
  }
8512
9110
  else {
@@ -8516,10 +9114,7 @@ function serializeCode(buffer, key, value, index, checkKeys = false, depth = 0,
8516
9114
  buffer[index++] = 0;
8517
9115
  const functionString = value.code.toString();
8518
9116
  const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
8519
- buffer[index] = size & 0xff;
8520
- buffer[index + 1] = (size >> 8) & 0xff;
8521
- buffer[index + 2] = (size >> 16) & 0xff;
8522
- buffer[index + 3] = (size >> 24) & 0xff;
9117
+ NumberUtils.setInt32LE(buffer, index, size);
8523
9118
  index = index + 4 + size - 1;
8524
9119
  buffer[index++] = 0;
8525
9120
  }
@@ -8534,19 +9129,19 @@ function serializeBinary(buffer, key, value, index) {
8534
9129
  let size = value.position;
8535
9130
  if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
8536
9131
  size = size + 4;
8537
- buffer[index++] = size & 0xff;
8538
- buffer[index++] = (size >> 8) & 0xff;
8539
- buffer[index++] = (size >> 16) & 0xff;
8540
- buffer[index++] = (size >> 24) & 0xff;
9132
+ index += NumberUtils.setInt32LE(buffer, index, size);
8541
9133
  buffer[index++] = value.sub_type;
8542
9134
  if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
8543
9135
  size = size - 4;
8544
- buffer[index++] = size & 0xff;
8545
- buffer[index++] = (size >> 8) & 0xff;
8546
- buffer[index++] = (size >> 16) & 0xff;
8547
- buffer[index++] = (size >> 24) & 0xff;
9136
+ index += NumberUtils.setInt32LE(buffer, index, size);
9137
+ }
9138
+ if (size <= 16) {
9139
+ for (let i = 0; i < size; i++)
9140
+ buffer[index + i] = data[i];
9141
+ }
9142
+ else {
9143
+ buffer.set(data, index);
8548
9144
  }
8549
- buffer.set(data, index);
8550
9145
  index = index + value.position;
8551
9146
  return index;
8552
9147
  }
@@ -8556,12 +9151,9 @@ function serializeSymbol(buffer, key, value, index) {
8556
9151
  index = index + numberOfWrittenBytes;
8557
9152
  buffer[index++] = 0;
8558
9153
  const size = ByteUtils.encodeUTF8Into(buffer, value.value, index + 4) + 1;
8559
- buffer[index] = size & 0xff;
8560
- buffer[index + 1] = (size >> 8) & 0xff;
8561
- buffer[index + 2] = (size >> 16) & 0xff;
8562
- buffer[index + 3] = (size >> 24) & 0xff;
9154
+ NumberUtils.setInt32LE(buffer, index, size);
8563
9155
  index = index + 4 + size - 1;
8564
- buffer[index++] = 0x00;
9156
+ buffer[index++] = 0;
8565
9157
  return index;
8566
9158
  }
8567
9159
  function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path) {
@@ -8580,10 +9172,7 @@ function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, pa
8580
9172
  output = Object.assign(output, value.fields);
8581
9173
  const endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions, true, path);
8582
9174
  const size = endIndex - startIndex;
8583
- buffer[startIndex++] = size & 0xff;
8584
- buffer[startIndex++] = (size >> 8) & 0xff;
8585
- buffer[startIndex++] = (size >> 16) & 0xff;
8586
- buffer[startIndex++] = (size >> 24) & 0xff;
9175
+ startIndex += NumberUtils.setInt32LE(buffer, index, size);
8587
9176
  return endIndex;
8588
9177
  }
8589
9178
  function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) {
@@ -8719,7 +9308,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
8719
9308
  if ('$' === key[0]) {
8720
9309
  throw new BSONError('key ' + key + " must not start with '$'");
8721
9310
  }
8722
- else if (~key.indexOf('.')) {
9311
+ else if (key.includes('.')) {
8723
9312
  throw new BSONError('key ' + key + " must not contain '.'");
8724
9313
  }
8725
9314
  }
@@ -8817,7 +9406,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
8817
9406
  if ('$' === key[0]) {
8818
9407
  throw new BSONError('key ' + key + " must not start with '$'");
8819
9408
  }
8820
- else if (~key.indexOf('.')) {
9409
+ else if (key.includes('.')) {
8821
9410
  throw new BSONError('key ' + key + " must not contain '.'");
8822
9411
  }
8823
9412
  }
@@ -8901,10 +9490,7 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
8901
9490
  path.delete(object);
8902
9491
  buffer[index++] = 0x00;
8903
9492
  const size = index - startingIndex;
8904
- buffer[startingIndex++] = size & 0xff;
8905
- buffer[startingIndex++] = (size >> 8) & 0xff;
8906
- buffer[startingIndex++] = (size >> 16) & 0xff;
8907
- buffer[startingIndex++] = (size >> 24) & 0xff;
9493
+ startingIndex += NumberUtils.setInt32LE(buffer, startingIndex, size);
8908
9494
  return index;
8909
9495
  }
8910
9496
 
@@ -9218,6 +9804,113 @@ EJSON.serialize = EJSONserialize;
9218
9804
  EJSON.deserialize = EJSONdeserialize;
9219
9805
  Object.freeze(EJSON);
9220
9806
 
9807
+ function getSize(source, offset) {
9808
+ try {
9809
+ return NumberUtils.getNonnegativeInt32LE(source, offset);
9810
+ }
9811
+ catch (cause) {
9812
+ throw new BSONOffsetError('BSON size cannot be negative', offset, { cause });
9813
+ }
9814
+ }
9815
+ function findNull(bytes, offset) {
9816
+ let nullTerminatorOffset = offset;
9817
+ for (; bytes[nullTerminatorOffset] !== 0x00; nullTerminatorOffset++)
9818
+ ;
9819
+ if (nullTerminatorOffset === bytes.length - 1) {
9820
+ throw new BSONOffsetError('Null terminator not found', offset);
9821
+ }
9822
+ return nullTerminatorOffset;
9823
+ }
9824
+ function parseToElements(bytes, startOffset = 0) {
9825
+ startOffset ??= 0;
9826
+ if (bytes.length < 5) {
9827
+ throw new BSONOffsetError(`Input must be at least 5 bytes, got ${bytes.length} bytes`, startOffset);
9828
+ }
9829
+ const documentSize = getSize(bytes, startOffset);
9830
+ if (documentSize > bytes.length - startOffset) {
9831
+ throw new BSONOffsetError(`Parsed documentSize (${documentSize} bytes) does not match input length (${bytes.length} bytes)`, startOffset);
9832
+ }
9833
+ if (bytes[startOffset + documentSize - 1] !== 0x00) {
9834
+ throw new BSONOffsetError('BSON documents must end in 0x00', startOffset + documentSize);
9835
+ }
9836
+ const elements = [];
9837
+ let offset = startOffset + 4;
9838
+ while (offset <= documentSize + startOffset) {
9839
+ const type = bytes[offset];
9840
+ offset += 1;
9841
+ if (type === 0) {
9842
+ if (offset - startOffset !== documentSize) {
9843
+ throw new BSONOffsetError(`Invalid 0x00 type byte`, offset);
9844
+ }
9845
+ break;
9846
+ }
9847
+ const nameOffset = offset;
9848
+ const nameLength = findNull(bytes, offset) - nameOffset;
9849
+ offset += nameLength + 1;
9850
+ let length;
9851
+ if (type === 1 ||
9852
+ type === 18 ||
9853
+ type === 9 ||
9854
+ type === 17) {
9855
+ length = 8;
9856
+ }
9857
+ else if (type === 16) {
9858
+ length = 4;
9859
+ }
9860
+ else if (type === 7) {
9861
+ length = 12;
9862
+ }
9863
+ else if (type === 19) {
9864
+ length = 16;
9865
+ }
9866
+ else if (type === 8) {
9867
+ length = 1;
9868
+ }
9869
+ else if (type === 10 ||
9870
+ type === 6 ||
9871
+ type === 127 ||
9872
+ type === 255) {
9873
+ length = 0;
9874
+ }
9875
+ else if (type === 11) {
9876
+ length = findNull(bytes, findNull(bytes, offset) + 1) + 1 - offset;
9877
+ }
9878
+ else if (type === 3 ||
9879
+ type === 4 ||
9880
+ type === 15) {
9881
+ length = getSize(bytes, offset);
9882
+ }
9883
+ else if (type === 2 ||
9884
+ type === 5 ||
9885
+ type === 12 ||
9886
+ type === 13 ||
9887
+ type === 14) {
9888
+ length = getSize(bytes, offset) + 4;
9889
+ if (type === 5) {
9890
+ length += 1;
9891
+ }
9892
+ if (type === 12) {
9893
+ length += 12;
9894
+ }
9895
+ }
9896
+ else {
9897
+ throw new BSONOffsetError(`Invalid 0x${type.toString(16).padStart(2, '0')} type byte`, offset);
9898
+ }
9899
+ if (length > documentSize) {
9900
+ throw new BSONOffsetError('value reports length larger than document', offset);
9901
+ }
9902
+ elements.push([type, nameOffset, nameLength, offset, length]);
9903
+ offset += length;
9904
+ }
9905
+ return elements;
9906
+ }
9907
+
9908
+ const onDemand = Object.create(null);
9909
+ onDemand.parseToElements = parseToElements;
9910
+ onDemand.ByteUtils = ByteUtils;
9911
+ onDemand.NumberUtils = NumberUtils;
9912
+ Object.freeze(onDemand);
9913
+
9221
9914
  const MAXSIZE = 1024 * 1024 * 17;
9222
9915
  let buffer = ByteUtils.allocate(MAXSIZE);
9223
9916
  function setInternalBufferSize(size) {
@@ -9234,7 +9927,7 @@ function serialize(object, options = {}) {
9234
9927
  buffer = ByteUtils.allocate(minInternalBufferSize);
9235
9928
  }
9236
9929
  const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
9237
- const finishedBuffer = ByteUtils.allocate(serializationIndex);
9930
+ const finishedBuffer = ByteUtils.allocateUnsafe(serializationIndex);
9238
9931
  finishedBuffer.set(buffer.subarray(0, serializationIndex), 0);
9239
9932
  return finishedBuffer;
9240
9933
  }
@@ -9261,10 +9954,7 @@ function deserializeStream(data, startIndex, numberOfDocuments, documents, docSt
9261
9954
  const bufferData = ByteUtils.toLocalBufferType(data);
9262
9955
  let index = startIndex;
9263
9956
  for (let i = 0; i < numberOfDocuments; i++) {
9264
- const size = bufferData[index] |
9265
- (bufferData[index + 1] << 8) |
9266
- (bufferData[index + 2] << 16) |
9267
- (bufferData[index + 3] << 24);
9957
+ const size = NumberUtils.getInt32LE(bufferData, index);
9268
9958
  internalOptions.index = index;
9269
9959
  documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions);
9270
9960
  index = index + size;
@@ -9275,6 +9965,7 @@ function deserializeStream(data, startIndex, numberOfDocuments, documents, docSt
9275
9965
  var bson = /*#__PURE__*/Object.freeze({
9276
9966
  __proto__: null,
9277
9967
  BSONError: BSONError,
9968
+ BSONOffsetError: BSONOffsetError,
9278
9969
  BSONRegExp: BSONRegExp,
9279
9970
  BSONRuntimeError: BSONRuntimeError,
9280
9971
  BSONSymbol: BSONSymbol,
@@ -9297,6 +9988,7 @@ var bson = /*#__PURE__*/Object.freeze({
9297
9988
  calculateObjectSize: calculateObjectSize,
9298
9989
  deserialize: deserialize,
9299
9990
  deserializeStream: deserializeStream,
9991
+ onDemand: onDemand,
9300
9992
  serialize: serialize,
9301
9993
  serializeWithBufferAndIndex: serializeWithBufferAndIndex,
9302
9994
  setInternalBufferSize: setInternalBufferSize
@@ -9304,6 +9996,7 @@ var bson = /*#__PURE__*/Object.freeze({
9304
9996
 
9305
9997
  exports.BSON = bson;
9306
9998
  exports.BSONError = BSONError;
9999
+ exports.BSONOffsetError = BSONOffsetError;
9307
10000
  exports.BSONRegExp = BSONRegExp;
9308
10001
  exports.BSONRuntimeError = BSONRuntimeError;
9309
10002
  exports.BSONSymbol = BSONSymbol;
@@ -9326,6 +10019,7 @@ exports.UUID = UUID;
9326
10019
  exports.calculateObjectSize = calculateObjectSize;
9327
10020
  exports.deserialize = deserialize;
9328
10021
  exports.deserializeStream = deserializeStream;
10022
+ exports.onDemand = onDemand;
9329
10023
  exports.serialize = serialize;
9330
10024
  exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
9331
10025
  exports.setInternalBufferSize = setInternalBufferSize;
@@ -9391,6 +10085,10 @@ const app = Vue.createApp({
9391
10085
 
9392
10086
  __webpack_require__(/*! ./async-button/async-button */ "./frontend/src/async-button/async-button.js")(app);
9393
10087
  __webpack_require__(/*! ./charts/charts */ "./frontend/src/charts/charts.js")(app);
10088
+ __webpack_require__(/*! ./create-document/create-document */ "./frontend/src/create-document/create-document.js")(app);
10089
+ __webpack_require__(/*! ./dashboards/dashboards */ "./frontend/src/dashboards/dashboards.js")(app);
10090
+ __webpack_require__(/*! ./dashboard/dashboard */ "./frontend/src/dashboard/dashboard.js")(app);
10091
+ __webpack_require__(/*! ./dashboard/edit-dashboard/edit-dashboard */ "./frontend/src/dashboard/edit-dashboard/edit-dashboard.js")(app)
9394
10092
  __webpack_require__(/*! ./detail-array/detail-array */ "./frontend/src/detail-array/detail-array.js")(app);
9395
10093
  __webpack_require__(/*! ./detail-default/detail-default */ "./frontend/src/detail-default/detail-default.js")(app);
9396
10094
  __webpack_require__(/*! ./document/document */ "./frontend/src/document/document.js")(app);
@@ -9401,6 +10099,7 @@ __webpack_require__(/*! ./edit-date/edit-date */ "./frontend/src/edit-date/edit-
9401
10099
  __webpack_require__(/*! ./export-query-results/export-query-results */ "./frontend/src/export-query-results/export-query-results.js")(app);
9402
10100
  __webpack_require__(/*! ./list-array/list-array */ "./frontend/src/list-array/list-array.js")(app);
9403
10101
  __webpack_require__(/*! ./list-default/list-default */ "./frontend/src/list-default/list-default.js")(app);
10102
+ __webpack_require__(/*! ./list-json/list-json */ "./frontend/src/list-json/list-json.js")(app)
9404
10103
  __webpack_require__(/*! ./list-mixed/list-mixed */ "./frontend/src/list-mixed/list-mixed.js")(app);
9405
10104
  __webpack_require__(/*! ./list-string/list-string */ "./frontend/src/list-string/list-string.js")(app);
9406
10105
  __webpack_require__(/*! ./list-subdocument/list-subdocument */ "./frontend/src/list-subdocument/list-subdocument.js")(app);