@revisium/schema-toolkit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/dist/consts/index.cjs +26 -0
  4. package/dist/consts/index.cjs.map +1 -0
  5. package/dist/consts/index.d.cts +17 -0
  6. package/dist/consts/index.d.ts +17 -0
  7. package/dist/consts/index.js +23 -0
  8. package/dist/consts/index.js.map +1 -0
  9. package/dist/index.cjs +1874 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +13 -0
  12. package/dist/index.d.ts +13 -0
  13. package/dist/index.js +1787 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/json-patch.types-DiJBqfxV.d.ts +28 -0
  16. package/dist/json-patch.types-lByaF-OL.d.cts +28 -0
  17. package/dist/json-string.store-O1J0j-a1.d.cts +228 -0
  18. package/dist/json-string.store-S9FXT39Q.d.ts +228 -0
  19. package/dist/json.types-46Cq-WxU.d.cts +8 -0
  20. package/dist/json.types-46Cq-WxU.d.ts +8 -0
  21. package/dist/lib/index.cjs +1346 -0
  22. package/dist/lib/index.cjs.map +1 -0
  23. package/dist/lib/index.d.cts +91 -0
  24. package/dist/lib/index.d.ts +91 -0
  25. package/dist/lib/index.js +1315 -0
  26. package/dist/lib/index.js.map +1 -0
  27. package/dist/mocks/index.cjs +92 -0
  28. package/dist/mocks/index.cjs.map +1 -0
  29. package/dist/mocks/index.d.cts +26 -0
  30. package/dist/mocks/index.d.ts +26 -0
  31. package/dist/mocks/index.js +81 -0
  32. package/dist/mocks/index.js.map +1 -0
  33. package/dist/model/index.cjs +718 -0
  34. package/dist/model/index.cjs.map +1 -0
  35. package/dist/model/index.d.cts +19 -0
  36. package/dist/model/index.d.ts +19 -0
  37. package/dist/model/index.js +697 -0
  38. package/dist/model/index.js.map +1 -0
  39. package/dist/plugins/index.cjs +122 -0
  40. package/dist/plugins/index.cjs.map +1 -0
  41. package/dist/plugins/index.d.cts +21 -0
  42. package/dist/plugins/index.d.ts +21 -0
  43. package/dist/plugins/index.js +112 -0
  44. package/dist/plugins/index.js.map +1 -0
  45. package/dist/schema.types-Q3MYTp8z.d.cts +68 -0
  46. package/dist/schema.types-Q3MYTp8z.d.ts +68 -0
  47. package/dist/types/index.cjs +15 -0
  48. package/dist/types/index.cjs.map +1 -0
  49. package/dist/types/index.d.cts +56 -0
  50. package/dist/types/index.d.ts +56 -0
  51. package/dist/types/index.js +13 -0
  52. package/dist/types/index.js.map +1 -0
  53. package/dist/validation-schemas/index.cjs +380 -0
  54. package/dist/validation-schemas/index.cjs.map +1 -0
  55. package/dist/validation-schemas/index.d.cts +32 -0
  56. package/dist/validation-schemas/index.d.ts +32 -0
  57. package/dist/validation-schemas/index.js +365 -0
  58. package/dist/validation-schemas/index.js.map +1 -0
  59. package/package.json +169 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1874 @@
1
+ 'use strict';
2
+
3
+ var nanoid = require('nanoid');
4
+ var events = require('events');
5
+
6
+ // src/types/schema.types.ts
7
+ var JsonSchemaTypeName = /* @__PURE__ */ ((JsonSchemaTypeName2) => {
8
+ JsonSchemaTypeName2["String"] = "string";
9
+ JsonSchemaTypeName2["Number"] = "number";
10
+ JsonSchemaTypeName2["Boolean"] = "boolean";
11
+ JsonSchemaTypeName2["Object"] = "object";
12
+ JsonSchemaTypeName2["Array"] = "array";
13
+ return JsonSchemaTypeName2;
14
+ })(JsonSchemaTypeName || {});
15
+
16
+ // src/plugins/row-id.schema.ts
17
+ var rowIdSchema = {
18
+ type: "string" /* String */,
19
+ default: "",
20
+ readOnly: true
21
+ };
22
+
23
+ // src/plugins/row-version-id.schema.ts
24
+ var rowVersionIdSchema = {
25
+ type: "string" /* String */,
26
+ default: "",
27
+ readOnly: true
28
+ };
29
+
30
+ // src/plugins/row-created-id.schema.ts
31
+ var rowCreatedIdSchema = {
32
+ type: "string" /* String */,
33
+ default: "",
34
+ readOnly: true
35
+ };
36
+
37
+ // src/plugins/row-created-at.schema.ts
38
+ var rowCreatedAtSchema = {
39
+ type: "string" /* String */,
40
+ default: "",
41
+ readOnly: true
42
+ };
43
+
44
+ // src/plugins/row-published-at.schema.ts
45
+ var rowPublishedAtSchema = {
46
+ type: "string" /* String */,
47
+ default: ""
48
+ };
49
+
50
+ // src/plugins/row-updated-at.schema.ts
51
+ var rowUpdatedAtSchema = {
52
+ type: "string" /* String */,
53
+ default: "",
54
+ readOnly: true
55
+ };
56
+
57
+ // src/plugins/row-hash.schema.ts
58
+ var rowHashSchema = {
59
+ type: "string" /* String */,
60
+ default: "",
61
+ readOnly: true
62
+ };
63
+
64
+ // src/plugins/row-schema-hash.schema.ts
65
+ var rowSchemaHashSchema = {
66
+ type: "string" /* String */,
67
+ default: "",
68
+ readOnly: true
69
+ };
70
+
71
+ // src/plugins/file-schema.ts
72
+ var fileSchema = {
73
+ type: "object" /* Object */,
74
+ properties: {
75
+ status: { type: "string" /* String */, default: "", readOnly: true },
76
+ fileId: { type: "string" /* String */, default: "", readOnly: true },
77
+ url: { type: "string" /* String */, default: "", readOnly: true },
78
+ fileName: { type: "string" /* String */, default: "" },
79
+ hash: {
80
+ type: "string" /* String */,
81
+ default: "",
82
+ readOnly: true
83
+ },
84
+ extension: {
85
+ type: "string" /* String */,
86
+ default: "",
87
+ readOnly: true
88
+ },
89
+ mimeType: {
90
+ type: "string" /* String */,
91
+ default: "",
92
+ readOnly: true
93
+ },
94
+ size: {
95
+ type: "number" /* Number */,
96
+ default: 0,
97
+ readOnly: true
98
+ },
99
+ width: {
100
+ type: "number" /* Number */,
101
+ default: 0,
102
+ readOnly: true
103
+ },
104
+ height: {
105
+ type: "number" /* Number */,
106
+ default: 0,
107
+ readOnly: true
108
+ }
109
+ },
110
+ required: [
111
+ "status",
112
+ "fileId",
113
+ "url",
114
+ "fileName",
115
+ "hash",
116
+ "extension",
117
+ "mimeType",
118
+ "size",
119
+ "width",
120
+ "height"
121
+ ],
122
+ additionalProperties: false
123
+ };
124
+
125
+ // src/mocks/schema.mocks.ts
126
+ var getReplacePatch = ({
127
+ path,
128
+ value
129
+ }) => ({
130
+ op: "replace",
131
+ path,
132
+ value
133
+ });
134
+ var getRemovePatch = ({
135
+ path
136
+ }) => ({
137
+ op: "remove",
138
+ path
139
+ });
140
+ var getAddPatch = ({
141
+ path,
142
+ value
143
+ }) => ({
144
+ op: "add",
145
+ path,
146
+ value
147
+ });
148
+ var getMovePatch = ({
149
+ from,
150
+ path
151
+ }) => ({
152
+ op: "move",
153
+ from,
154
+ path
155
+ });
156
+ var getStringSchema = (params = {}) => {
157
+ const schema = {
158
+ type: "string" /* String */,
159
+ default: params.default ?? ""
160
+ };
161
+ if (params.foreignKey) {
162
+ schema.foreignKey = params.foreignKey;
163
+ }
164
+ if (params.readOnly) {
165
+ schema.readOnly = params.readOnly;
166
+ }
167
+ return schema;
168
+ };
169
+ var getNumberSchema = (defaultValue = 0, readOnly) => {
170
+ const schema = {
171
+ type: "number" /* Number */,
172
+ default: defaultValue
173
+ };
174
+ if (readOnly) {
175
+ schema.readOnly = readOnly;
176
+ }
177
+ return schema;
178
+ };
179
+ var getBooleanSchema = (defaultValue = false, readOnly) => {
180
+ const schema = {
181
+ type: "boolean" /* Boolean */,
182
+ default: defaultValue
183
+ };
184
+ if (readOnly) {
185
+ schema.readOnly = readOnly;
186
+ }
187
+ return schema;
188
+ };
189
+ var getObjectSchema = (properties) => ({
190
+ type: "object" /* Object */,
191
+ additionalProperties: false,
192
+ required: Object.keys(properties).sort((a, b) => a.localeCompare(b)),
193
+ properties
194
+ });
195
+ var getArraySchema = (items) => ({
196
+ type: "array" /* Array */,
197
+ items
198
+ });
199
+ var getRefSchema = ($ref) => ({
200
+ $ref
201
+ });
202
+
203
+ // src/consts/system-schema-ids.ts
204
+ var SystemSchemaIds = /* @__PURE__ */ ((SystemSchemaIds2) => {
205
+ SystemSchemaIds2["RowId"] = "urn:jsonschema:io:revisium:row-id-schema:1.0.0";
206
+ SystemSchemaIds2["RowCreatedId"] = "urn:jsonschema:io:revisium:row-created-id-schema:1.0.0";
207
+ SystemSchemaIds2["RowVersionId"] = "urn:jsonschema:io:revisium:row-version-id-schema:1.0.0";
208
+ SystemSchemaIds2["RowCreatedAt"] = "urn:jsonschema:io:revisium:row-created-at-schema:1.0.0";
209
+ SystemSchemaIds2["RowPublishedAt"] = "urn:jsonschema:io:revisium:row-published-at-schema:1.0.0";
210
+ SystemSchemaIds2["RowUpdatedAt"] = "urn:jsonschema:io:revisium:row-updated-at-schema:1.0.0";
211
+ SystemSchemaIds2["RowHash"] = "urn:jsonschema:io:revisium:row-hash-schema:1.0.0";
212
+ SystemSchemaIds2["RowSchemaHash"] = "urn:jsonschema:io:revisium:row-schema-hash-schema:1.0.0";
213
+ SystemSchemaIds2["File"] = "urn:jsonschema:io:revisium:file-schema:1.0.0";
214
+ return SystemSchemaIds2;
215
+ })(SystemSchemaIds || {});
216
+
217
+ // src/consts/index.ts
218
+ var CustomSchemeKeywords = /* @__PURE__ */ ((CustomSchemeKeywords2) => {
219
+ CustomSchemeKeywords2["ForeignKey"] = "foreignKey";
220
+ return CustomSchemeKeywords2;
221
+ })(CustomSchemeKeywords || {});
222
+
223
+ // src/lib/addSharedFieldsFromStore.ts
224
+ var addSharedFieldsFromState = (schema, state) => {
225
+ if (state.title) {
226
+ schema.title = state.title;
227
+ }
228
+ if (state.description) {
229
+ schema.description = state.description;
230
+ }
231
+ if (state.deprecated) {
232
+ schema.deprecated = state.deprecated;
233
+ }
234
+ return schema;
235
+ };
236
+
237
+ // src/model/schema/json-string.store.ts
238
+ var JsonStringStore = class extends events.EventEmitter {
239
+ constructor(nodeId = nanoid.nanoid()) {
240
+ super();
241
+ this.nodeId = nodeId;
242
+ }
243
+ type = "string" /* String */;
244
+ $ref = "";
245
+ name = "";
246
+ parent = null;
247
+ default = "";
248
+ readOnly;
249
+ title;
250
+ description;
251
+ deprecated;
252
+ foreignKey;
253
+ pattern;
254
+ enum;
255
+ format;
256
+ contentMediaType;
257
+ valuesMap = /* @__PURE__ */ new Map();
258
+ registerValue(value) {
259
+ const length = this.getOrCreateValues(value.rowId).push(value);
260
+ return length - 1;
261
+ }
262
+ getValue(rowId, index = 0) {
263
+ return this.getOrCreateValues(rowId)[index];
264
+ }
265
+ getPlainSchema(options) {
266
+ if (this.$ref && options?.skip$Ref !== true) {
267
+ return addSharedFieldsFromState({ $ref: this.$ref }, this);
268
+ }
269
+ return addSharedFieldsFromState(
270
+ {
271
+ type: this.type,
272
+ default: this.default,
273
+ ...this.foreignKey ? { foreignKey: this.foreignKey } : {},
274
+ ...this.readOnly ? { readOnly: this.readOnly } : {},
275
+ ...this.pattern ? { pattern: this.pattern } : {},
276
+ ...this.enum ? { enum: this.enum } : {},
277
+ ...this.format ? { format: this.format } : {},
278
+ ...this.contentMediaType ? { contentMediaType: this.contentMediaType } : {}
279
+ },
280
+ this
281
+ );
282
+ }
283
+ getOrCreateValues(rowId) {
284
+ let values = this.valuesMap.get(rowId);
285
+ if (!values) {
286
+ values = [];
287
+ this.valuesMap.set(rowId, values);
288
+ }
289
+ return values;
290
+ }
291
+ };
292
+ var JsonNumberStore = class extends events.EventEmitter {
293
+ constructor(nodeId = nanoid.nanoid()) {
294
+ super();
295
+ this.nodeId = nodeId;
296
+ }
297
+ type = "number" /* Number */;
298
+ $ref = "";
299
+ name = "";
300
+ parent = null;
301
+ default = 0;
302
+ readOnly;
303
+ title;
304
+ description;
305
+ deprecated;
306
+ valuesMap = /* @__PURE__ */ new Map();
307
+ registerValue(value) {
308
+ const length = this.getOrCreateValues(value.rowId).push(value);
309
+ return length - 1;
310
+ }
311
+ getValue(rowId, index = 0) {
312
+ return this.getOrCreateValues(rowId)[index];
313
+ }
314
+ getPlainSchema(options) {
315
+ if (this.$ref && options?.skip$Ref !== true) {
316
+ return addSharedFieldsFromState({ $ref: this.$ref }, this);
317
+ }
318
+ return addSharedFieldsFromState(
319
+ {
320
+ type: this.type,
321
+ default: this.default,
322
+ ...this.readOnly ? { readOnly: this.readOnly } : {}
323
+ },
324
+ this
325
+ );
326
+ }
327
+ getOrCreateValues(rowId) {
328
+ let values = this.valuesMap.get(rowId);
329
+ if (!values) {
330
+ values = [];
331
+ this.valuesMap.set(rowId, values);
332
+ }
333
+ return values;
334
+ }
335
+ };
336
+ var JsonBooleanStore = class extends events.EventEmitter {
337
+ constructor(nodeId = nanoid.nanoid()) {
338
+ super();
339
+ this.nodeId = nodeId;
340
+ }
341
+ type = "boolean" /* Boolean */;
342
+ $ref = "";
343
+ name = "";
344
+ parent = null;
345
+ default = false;
346
+ readOnly;
347
+ title;
348
+ description;
349
+ deprecated;
350
+ valuesMap = /* @__PURE__ */ new Map();
351
+ registerValue(value) {
352
+ const length = this.getOrCreateValues(value.rowId).push(value);
353
+ return length - 1;
354
+ }
355
+ getValue(rowId, index = 0) {
356
+ return this.getOrCreateValues(rowId)[index];
357
+ }
358
+ getPlainSchema(options) {
359
+ if (this.$ref && options?.skip$Ref !== true) {
360
+ return addSharedFieldsFromState({ $ref: this.$ref }, this);
361
+ }
362
+ return addSharedFieldsFromState(
363
+ {
364
+ type: this.type,
365
+ default: this.default,
366
+ ...this.readOnly ? { readOnly: this.readOnly } : {}
367
+ },
368
+ this
369
+ );
370
+ }
371
+ getOrCreateValues(rowId) {
372
+ let values = this.valuesMap.get(rowId);
373
+ if (!values) {
374
+ values = [];
375
+ this.valuesMap.set(rowId, values);
376
+ }
377
+ return values;
378
+ }
379
+ };
380
+ var JsonObjectStore = class {
381
+ constructor(nodeId = nanoid.nanoid()) {
382
+ this.nodeId = nodeId;
383
+ }
384
+ type = "object" /* Object */;
385
+ $ref = "";
386
+ name = "";
387
+ parent = null;
388
+ default = {};
389
+ title;
390
+ description;
391
+ deprecated;
392
+ additionalProperties = false;
393
+ required = [];
394
+ properties = {};
395
+ valuesMap = /* @__PURE__ */ new Map();
396
+ get empty() {
397
+ return Object.keys(this.properties).length === 0;
398
+ }
399
+ registerValue(value) {
400
+ const length = this.getOrCreateValues(value.rowId).push(value);
401
+ return length - 1;
402
+ }
403
+ getValue(rowId, index = 0) {
404
+ return this.getOrCreateValues(rowId)[index];
405
+ }
406
+ addPropertyWithStore(name, store) {
407
+ if (this.properties[name] || this.required.includes(name)) {
408
+ throw new Error("this name already exists");
409
+ }
410
+ store.parent = this;
411
+ store.name = name;
412
+ this.required.push(name);
413
+ this.required.sort((a, b) => a.localeCompare(b));
414
+ this.properties[name] = store;
415
+ this.default[name] = store.default;
416
+ const event = { name, property: store };
417
+ for (const value of this.iterValues()) {
418
+ value.addProperty(event);
419
+ }
420
+ return store;
421
+ }
422
+ migratePropertyWithStore(name, store) {
423
+ const item = this.properties[name];
424
+ if (!item) {
425
+ throw new Error("this name does not exist");
426
+ }
427
+ item.parent = null;
428
+ store.parent = this;
429
+ store.name = name;
430
+ this.properties[name] = store;
431
+ this.default[name] = store.default;
432
+ const event = {
433
+ name,
434
+ property: store,
435
+ previousProperty: item
436
+ };
437
+ for (const value of this.iterValues()) {
438
+ value.migrateProperty(event);
439
+ }
440
+ return store;
441
+ }
442
+ changeName(fromName, toName) {
443
+ const item = this.properties[fromName];
444
+ if (!item) {
445
+ throw new Error("this fromName does not exist");
446
+ }
447
+ delete this.properties[fromName];
448
+ delete this.default[fromName];
449
+ const foundRequiredIndex = this.required.findIndex(
450
+ (required) => required === fromName
451
+ );
452
+ if (foundRequiredIndex !== -1) {
453
+ this.required.splice(foundRequiredIndex, 1);
454
+ }
455
+ if (!this.required.includes(toName)) {
456
+ this.required.push(toName);
457
+ this.required.sort((a, b) => a.localeCompare(b));
458
+ }
459
+ this.properties[toName] = item;
460
+ this.default[toName] = item.default;
461
+ const event = {
462
+ fromName,
463
+ toName,
464
+ property: item
465
+ };
466
+ for (const value of this.iterValues()) {
467
+ value.changeName(event);
468
+ }
469
+ }
470
+ removeProperty(name) {
471
+ const item = this.properties[name];
472
+ if (!item) {
473
+ throw new Error("this name does not exist");
474
+ }
475
+ item.parent = null;
476
+ item.name = "";
477
+ delete this.properties[name];
478
+ delete this.default[name];
479
+ const foundRequiredIndex = this.required.findIndex(
480
+ (required) => required === name
481
+ );
482
+ if (foundRequiredIndex !== -1) {
483
+ this.required.splice(foundRequiredIndex, 1);
484
+ }
485
+ const event = {
486
+ name,
487
+ property: item
488
+ };
489
+ for (const value of this.iterValues()) {
490
+ value.removeProperty(event);
491
+ }
492
+ }
493
+ getProperty(name) {
494
+ return this.properties[name];
495
+ }
496
+ getPlainSchema(options) {
497
+ if (this.$ref && options?.skip$Ref !== true) {
498
+ return addSharedFieldsFromState({ $ref: this.$ref }, this);
499
+ }
500
+ return addSharedFieldsFromState(
501
+ {
502
+ type: this.type,
503
+ additionalProperties: this.additionalProperties,
504
+ required: this.required,
505
+ properties: Object.entries(this.properties).reduce((result, [name, store]) => {
506
+ result[name] = store.getPlainSchema(options);
507
+ return result;
508
+ }, {})
509
+ },
510
+ this
511
+ );
512
+ }
513
+ getOrCreateValues(rowId) {
514
+ let values = this.valuesMap.get(rowId);
515
+ if (!values) {
516
+ values = [];
517
+ this.valuesMap.set(rowId, values);
518
+ }
519
+ return values;
520
+ }
521
+ *iterValues() {
522
+ for (const values of this.valuesMap.values()) {
523
+ for (const value of values) {
524
+ yield value;
525
+ }
526
+ }
527
+ }
528
+ };
529
+ var JsonArrayStore = class {
530
+ constructor(_items, nodeId = nanoid.nanoid()) {
531
+ this._items = _items;
532
+ this.nodeId = nodeId;
533
+ this.items.parent = this;
534
+ }
535
+ type = "array" /* Array */;
536
+ $ref = "";
537
+ name = "";
538
+ parent = null;
539
+ default = [];
540
+ title;
541
+ description;
542
+ deprecated;
543
+ valuesMap = /* @__PURE__ */ new Map();
544
+ get items() {
545
+ return this._items;
546
+ }
547
+ registerValue(value) {
548
+ const length = this.getOrCreateValues(value.rowId).push(value);
549
+ return length - 1;
550
+ }
551
+ getValue(rowId, index = 0) {
552
+ return this.getOrCreateValues(rowId)[index];
553
+ }
554
+ migrateItems(items) {
555
+ const previousItems = this._items;
556
+ previousItems.parent = null;
557
+ this._items = items;
558
+ this._items.parent = this;
559
+ const event = { items, previousItems };
560
+ for (const value of this.iterValues()) {
561
+ value.migrateItems(event);
562
+ }
563
+ }
564
+ replaceItems(items) {
565
+ const previousItems = this._items;
566
+ previousItems.parent = null;
567
+ this._items = items;
568
+ this._items.parent = this;
569
+ const event = { items, previousItems };
570
+ for (const value of this.iterValues()) {
571
+ value.replaceItems(event);
572
+ }
573
+ }
574
+ getPlainSchema(options) {
575
+ if (this.$ref && options?.skip$Ref !== true) {
576
+ return addSharedFieldsFromState({ $ref: this.$ref }, this);
577
+ }
578
+ return addSharedFieldsFromState(
579
+ {
580
+ type: this.type,
581
+ items: this.items.getPlainSchema(options)
582
+ },
583
+ this
584
+ );
585
+ }
586
+ getOrCreateValues(rowId) {
587
+ let values = this.valuesMap.get(rowId);
588
+ if (!values) {
589
+ values = [];
590
+ this.valuesMap.set(rowId, values);
591
+ }
592
+ return values;
593
+ }
594
+ *iterValues() {
595
+ for (const values of this.valuesMap.values()) {
596
+ for (const value of values) {
597
+ yield value;
598
+ }
599
+ }
600
+ }
601
+ };
602
+
603
+ // src/model/value/json-string-value.store.ts
604
+ var JsonStringValueStore = class {
605
+ constructor(schema, rowId, value = null) {
606
+ this.schema = schema;
607
+ this.rowId = rowId;
608
+ this.value = value;
609
+ this.index = this.schema.registerValue(this);
610
+ }
611
+ type = "string" /* String */;
612
+ index;
613
+ parent = null;
614
+ get foreignKey() {
615
+ return this.schema.foreignKey;
616
+ }
617
+ getPlainValue() {
618
+ return this.value ?? this.schema.default;
619
+ }
620
+ };
621
+
622
+ // src/model/value/json-number-value.store.ts
623
+ var JsonNumberValueStore = class {
624
+ constructor(schema, rowId, value = null) {
625
+ this.schema = schema;
626
+ this.rowId = rowId;
627
+ this.value = value;
628
+ this.index = this.schema.registerValue(this);
629
+ }
630
+ type = "number" /* Number */;
631
+ index;
632
+ parent = null;
633
+ getPlainValue() {
634
+ return this.value ?? this.schema.default;
635
+ }
636
+ };
637
+
638
+ // src/model/value/json-boolean-value.store.ts
639
+ var JsonBooleanValueStore = class {
640
+ constructor(schema, rowId, value = null) {
641
+ this.schema = schema;
642
+ this.rowId = rowId;
643
+ this.value = value;
644
+ this.index = this.schema.registerValue(this);
645
+ }
646
+ type = "boolean" /* Boolean */;
647
+ index;
648
+ parent = null;
649
+ getPlainValue() {
650
+ return this.value ?? this.schema.default;
651
+ }
652
+ };
653
+
654
+ // src/model/value/value-transformation.ts
655
+ var equel = (value) => value;
656
+ var fromNumberToString = (value, defaultValue = "") => value.toString() || defaultValue;
657
+ var fromBooleanToString = (value, defaultValue = "") => value.toString() || defaultValue;
658
+ var fromStringToBoolean = (value, defaultValue = false) => {
659
+ if (!value) {
660
+ return defaultValue;
661
+ }
662
+ if (value.toLowerCase() === "false") {
663
+ return false;
664
+ }
665
+ return true;
666
+ };
667
+ var fromStringToNumber = (value, defaultValue = 0) => {
668
+ const number = Number.parseFloat(value);
669
+ if (Number.isNaN(number)) {
670
+ return defaultValue;
671
+ }
672
+ return number;
673
+ };
674
+ var fromBooleanToNumber = (value) => {
675
+ return Number(value);
676
+ };
677
+ var fromNumberToBoolean = (value) => {
678
+ return Boolean(value);
679
+ };
680
+ var toArrayTransformation = (transformation) => (value) => {
681
+ const result = transformation(value);
682
+ return [result];
683
+ };
684
+ var fromArrayTransformation = (transformation) => (value) => {
685
+ if (Array.isArray(value) && value.length) {
686
+ return transformation(value[0]);
687
+ }
688
+ return void 0;
689
+ };
690
+ var replaceTransformationsMapper = [
691
+ {
692
+ fromType: "number" /* Number */,
693
+ toType: "string" /* String */,
694
+ transformation: fromNumberToString
695
+ },
696
+ {
697
+ fromType: "string" /* String */,
698
+ toType: "number" /* Number */,
699
+ transformation: fromStringToNumber
700
+ },
701
+ {
702
+ fromType: "boolean" /* Boolean */,
703
+ toType: "string" /* String */,
704
+ transformation: fromBooleanToString
705
+ },
706
+ {
707
+ fromType: "string" /* String */,
708
+ toType: "boolean" /* Boolean */,
709
+ transformation: fromStringToBoolean
710
+ },
711
+ {
712
+ fromType: "boolean" /* Boolean */,
713
+ toType: "number" /* Number */,
714
+ transformation: fromBooleanToNumber
715
+ },
716
+ {
717
+ fromType: "number" /* Number */,
718
+ toType: "boolean" /* Boolean */,
719
+ transformation: fromNumberToBoolean
720
+ }
721
+ ];
722
+ var getTransformation = (from, to) => {
723
+ if (to instanceof JsonArrayStore) {
724
+ const transformation = findTransformation(from.type, to.items.type);
725
+ if (!transformation) {
726
+ return;
727
+ }
728
+ return toArrayTransformation(transformation);
729
+ } else if (from instanceof JsonArrayStore) {
730
+ const transformation = findTransformation(from.items.type, to.type);
731
+ if (!transformation) {
732
+ return;
733
+ }
734
+ return fromArrayTransformation(transformation);
735
+ }
736
+ return findTransformation(from.type, to.type);
737
+ };
738
+ var findTransformation = (from, to) => {
739
+ if (from === to) {
740
+ return equel;
741
+ }
742
+ for (const item of replaceTransformationsMapper) {
743
+ if (item.fromType === from && item.toType === to) {
744
+ return item.transformation;
745
+ }
746
+ }
747
+ return void 0;
748
+ };
749
+
750
+ // src/model/value/json-array-value.store.ts
751
+ var JsonArrayValueStore = class {
752
+ constructor(schema, rowId, value) {
753
+ this.schema = schema;
754
+ this.rowId = rowId;
755
+ this.value = value;
756
+ this.index = this.schema.registerValue(this);
757
+ this.init();
758
+ }
759
+ type = "array" /* Array */;
760
+ index;
761
+ parent = null;
762
+ getPlainValue() {
763
+ return this.value.map((item) => item.getPlainValue());
764
+ }
765
+ migrateItems(event) {
766
+ const transformation = getTransformation(event.previousItems, event.items);
767
+ this.value = this.value.map((valueItem) => {
768
+ const rawValue = transformation ? transformation(
769
+ valueItem.getPlainValue(),
770
+ event.items.default
771
+ ) : event.items.default;
772
+ return createJsonValueStore(event.items, this.rowId, rawValue);
773
+ });
774
+ }
775
+ replaceItems(event) {
776
+ this.value = this.value.map(() => {
777
+ const rawValue = this.getReplacedValue(event);
778
+ return createJsonValueStore(event.items, this.rowId, rawValue);
779
+ });
780
+ }
781
+ getReplacedValue(event) {
782
+ const previousValue = event.items.getValue(this.rowId);
783
+ if (previousValue) {
784
+ return previousValue.getPlainValue();
785
+ }
786
+ return event.items.default;
787
+ }
788
+ init() {
789
+ for (const value of this.value) {
790
+ value.parent = this;
791
+ }
792
+ }
793
+ };
794
+
795
+ // src/lib/createJsonValueStore.ts
796
+ var createJsonValueStore = (schema, rowId, rawValue) => {
797
+ if (schema.type === "object" /* Object */) {
798
+ return createJsonObjectValueStore(schema, rowId, rawValue);
799
+ } else if (schema.type === "array" /* Array */) {
800
+ return createJsonArrayValueStore(schema, rowId, rawValue);
801
+ } else {
802
+ return createPrimitiveValueStore(schema, rowId, rawValue);
803
+ }
804
+ };
805
+ var createJsonObjectValueStore = (schema, rowId, rawValue) => {
806
+ const value = Object.entries(rawValue).reduce(
807
+ (reduceValue, [key, itemValue]) => {
808
+ const itemSchema = schema.getProperty(key);
809
+ if (itemSchema === void 0 || itemValue === void 0) {
810
+ throw new Error("Invalid item");
811
+ }
812
+ reduceValue[key] = createJsonValueStore(itemSchema, rowId, itemValue);
813
+ return reduceValue;
814
+ },
815
+ {}
816
+ );
817
+ return new JsonObjectValueStore(schema, rowId, value);
818
+ };
819
+ var createJsonArrayValueStore = (schema, rowId, rawValue) => {
820
+ const value = rawValue.map(
821
+ (value2) => createJsonValueStore(schema.items, rowId, value2)
822
+ );
823
+ return new JsonArrayValueStore(schema, rowId, value);
824
+ };
825
+ var createPrimitiveValueStore = (schema, rowId, rawValue) => {
826
+ if (schema.type === "string" /* String */) {
827
+ return new JsonStringValueStore(schema, rowId, rawValue);
828
+ } else if (schema.type === "number" /* Number */) {
829
+ return new JsonNumberValueStore(schema, rowId, rawValue);
830
+ } else if (schema.type === "boolean" /* Boolean */) {
831
+ return new JsonBooleanValueStore(schema, rowId, rawValue);
832
+ } else {
833
+ throw new Error("this type is not allowed");
834
+ }
835
+ };
836
+
837
+ // src/model/value/json-object-value.store.ts
838
+ var JsonObjectValueStore = class {
839
+ constructor(schema, rowId, value) {
840
+ this.schema = schema;
841
+ this.rowId = rowId;
842
+ this.value = value;
843
+ this.index = this.schema.registerValue(this);
844
+ this.init();
845
+ }
846
+ type = "object" /* Object */;
847
+ index;
848
+ parent = null;
849
+ getPlainValue() {
850
+ return Object.entries(this.value).reduce(
851
+ (result, [name, store]) => {
852
+ result[name] = store.getPlainValue();
853
+ return result;
854
+ },
855
+ {}
856
+ );
857
+ }
858
+ migrateProperty(event) {
859
+ const rawValue = this.getMigratedValue(event);
860
+ this.value[event.name] = createJsonValueStore(
861
+ event.property,
862
+ this.rowId,
863
+ rawValue
864
+ );
865
+ }
866
+ addProperty(event) {
867
+ const rawValue = this.getAddedValue(event);
868
+ this.value[event.name] = createJsonValueStore(
869
+ event.property,
870
+ this.rowId,
871
+ rawValue
872
+ );
873
+ }
874
+ removeProperty(event) {
875
+ delete this.value[event.name];
876
+ }
877
+ changeName(event) {
878
+ const itemValue = this.value[event.fromName];
879
+ if (itemValue !== void 0) {
880
+ delete this.value[event.fromName];
881
+ this.value[event.toName] = itemValue;
882
+ }
883
+ }
884
+ getAddedValue(event) {
885
+ const previousValue = event.property.getValue(this.rowId, this.index);
886
+ if (previousValue) {
887
+ return previousValue.getPlainValue();
888
+ }
889
+ return event.property.default;
890
+ }
891
+ getMigratedValue(event) {
892
+ const transformation = getTransformation(
893
+ event.previousProperty,
894
+ event.property
895
+ );
896
+ const valueStore = this.value[event.name];
897
+ if (transformation && valueStore) {
898
+ return transformation(
899
+ valueStore.getPlainValue(),
900
+ event.property.default
901
+ );
902
+ }
903
+ return event.property.default;
904
+ }
905
+ init() {
906
+ for (const value of Object.values(this.value)) {
907
+ value.parent = this;
908
+ }
909
+ }
910
+ };
911
+
912
+ // src/lib/createJsonSchemaStore.ts
913
+ var createJsonSchemaStore = (schema, refs = {}) => {
914
+ if ("$ref" in schema) {
915
+ const refSchema = refs[schema.$ref];
916
+ if (!refSchema) {
917
+ throw new Error(`Not found schema for $ref="${schema.$ref}"`);
918
+ }
919
+ const refStore = createJsonSchemaStore(refSchema, refs);
920
+ saveSharedFields(refStore, schema);
921
+ refStore.$ref = schema.$ref;
922
+ return refStore;
923
+ } else if (schema.type === "object" /* Object */) {
924
+ const objectStore = createJsonObjectSchemaStore(schema, refs);
925
+ saveSharedFields(objectStore, schema);
926
+ return objectStore;
927
+ } else if (schema.type === "array" /* Array */) {
928
+ const itemsStore = createJsonSchemaStore(schema.items, refs);
929
+ const arrayStore = new JsonArrayStore(itemsStore);
930
+ saveSharedFields(arrayStore, schema);
931
+ return arrayStore;
932
+ } else {
933
+ const primitivesStore = createPrimitiveStoreBySchema(schema);
934
+ saveSharedFields(primitivesStore, schema);
935
+ primitivesStore.readOnly = schema.readOnly;
936
+ return primitivesStore;
937
+ }
938
+ };
939
+ var createJsonObjectSchemaStore = (value, refs) => {
940
+ const store = new JsonObjectStore();
941
+ for (const requiredField of value.required) {
942
+ if (!value.properties[requiredField]) {
943
+ throw new Error(
944
+ `Not found required field "${requiredField}" in "properties"`
945
+ );
946
+ }
947
+ }
948
+ Object.entries(value.properties).forEach(([name, item]) => {
949
+ store.addPropertyWithStore(name, createJsonSchemaStore(item, refs));
950
+ });
951
+ return store;
952
+ };
953
+ var createPrimitiveStoreBySchema = (schema) => {
954
+ if (schema.type === "string" /* String */) {
955
+ const stringStore = new JsonStringStore();
956
+ stringStore.foreignKey = schema.foreignKey;
957
+ stringStore.format = schema.format;
958
+ stringStore.enum = schema.enum;
959
+ stringStore.contentMediaType = schema.contentMediaType;
960
+ stringStore.pattern = schema.pattern;
961
+ return stringStore;
962
+ } else if (schema.type === "number" /* Number */) {
963
+ return new JsonNumberStore();
964
+ } else if (schema.type === "boolean" /* Boolean */) {
965
+ return new JsonBooleanStore();
966
+ } else {
967
+ throw new Error("this type is not allowed");
968
+ }
969
+ };
970
+ var saveSharedFields = (store, schema) => {
971
+ store.title = schema.title;
972
+ store.description = schema.description;
973
+ store.deprecated = schema.deprecated;
974
+ };
975
+
976
+ // src/lib/getJsonSchemaStoreByPath.ts
977
+ var getJsonSchemaStoreByPath = (store, path) => {
978
+ if (path === "") {
979
+ return store;
980
+ }
981
+ if (path === "/") {
982
+ throw new Error(
983
+ 'invalid root path, need to use path="" instead of path="/"'
984
+ );
985
+ }
986
+ const tokens = path.split("/");
987
+ tokens.shift();
988
+ let currentStore = store;
989
+ let currentToken = tokens.shift();
990
+ let currentPath = "";
991
+ while (currentToken) {
992
+ if (currentStore.type === "object" /* Object */) {
993
+ if (currentToken !== "properties") {
994
+ throw new Error(
995
+ `Expected "${currentPath}/properties/*" instead of ${currentPath}/${currentToken}/*`
996
+ );
997
+ }
998
+ currentPath = `${currentPath}/${currentToken}`;
999
+ currentToken = tokens.shift();
1000
+ if (!currentToken) {
1001
+ throw new Error(`Expected property name after "${currentPath}"`);
1002
+ }
1003
+ const foundCurrentStore = currentStore.getProperty(currentToken);
1004
+ if (!foundCurrentStore) {
1005
+ throw new Error(`Not found "${currentToken}" in "${currentPath}"`);
1006
+ }
1007
+ currentStore = foundCurrentStore;
1008
+ currentPath = `${currentPath}/${currentToken}`;
1009
+ currentToken = tokens.shift();
1010
+ } else if (currentStore.type === "array" /* Array */) {
1011
+ if (currentToken !== "items") {
1012
+ throw new Error(
1013
+ `Expected "${currentPath}/items/*" instead of ${currentPath}/${currentToken}/*`
1014
+ );
1015
+ }
1016
+ currentPath = `${currentPath}/${currentToken}`;
1017
+ currentStore = currentStore.items;
1018
+ currentToken = tokens.shift();
1019
+ } else {
1020
+ throw new Error(`Unexpected "${currentToken}" in "${currentPath}"`);
1021
+ }
1022
+ }
1023
+ return currentStore;
1024
+ };
1025
+
1026
+ // src/lib/getParentForPath.ts
1027
+ var getParentForPath = (path) => {
1028
+ if (path === "" || path === "/") {
1029
+ throw new Error("Invalid path");
1030
+ }
1031
+ const tokens = path.split("/");
1032
+ tokens.shift();
1033
+ let currentToken = tokens.shift();
1034
+ let parentPath = "";
1035
+ let field = "";
1036
+ while (currentToken) {
1037
+ if (currentToken === "properties") {
1038
+ currentToken = tokens.shift();
1039
+ if (!currentToken) {
1040
+ throw new Error("Invalid path");
1041
+ }
1042
+ field = currentToken;
1043
+ currentToken = tokens.shift();
1044
+ if (currentToken) {
1045
+ parentPath = `${parentPath}/properties/${field}`;
1046
+ }
1047
+ } else if (currentToken === "items") {
1048
+ field = currentToken;
1049
+ currentToken = tokens.shift();
1050
+ if (currentToken && !["items", "properties"].includes(currentToken)) {
1051
+ throw new Error("Invalid path");
1052
+ } else if (currentToken) {
1053
+ parentPath = `${parentPath}/items`;
1054
+ }
1055
+ } else {
1056
+ throw new Error("Invalid path");
1057
+ }
1058
+ }
1059
+ return {
1060
+ parentPath,
1061
+ field
1062
+ };
1063
+ };
1064
+
1065
+ // src/lib/validateJsonFieldName.ts
1066
+ var maxLength = 64;
1067
+ var VALIDATE_JSON_FIELD_NAME_ERROR_MESSAGE = `It must contain between 1 and ${maxLength} characters, start with a letter or underscore (_), cannot start with two underscores (__), and can only include letters (a-z, A-Z), numbers (0-9), hyphens (-), and underscores (_).`;
1068
+ var validPattern = /^(?!__)[a-zA-Z_][a-zA-Z0-9-_]*$/;
1069
+ var validateJsonFieldName = (id) => {
1070
+ const isInvalid = id.length < 1 || id.length > maxLength || !validPattern.test(id);
1071
+ return !isInvalid;
1072
+ };
1073
+
1074
+ // src/lib/applyPatches.ts
1075
+ var applyReplacePatch = (store, patch, refs = {}) => {
1076
+ const patchStore = createJsonSchemaStore(patch.value, refs);
1077
+ const foundStore = getJsonSchemaStoreByPath(store, patch.path);
1078
+ const parent = foundStore.parent;
1079
+ if (!parent) {
1080
+ return patchStore;
1081
+ }
1082
+ if (parent.type === "object" /* Object */) {
1083
+ parent.migratePropertyWithStore(foundStore.name, patchStore);
1084
+ } else if (parent.type === "array" /* Array */) {
1085
+ parent.migrateItems(patchStore);
1086
+ } else {
1087
+ throw new Error("Invalid parent");
1088
+ }
1089
+ return store;
1090
+ };
1091
+ var applyRemovePatch = (rootStore, patch) => {
1092
+ const foundStore = getJsonSchemaStoreByPath(rootStore, patch.path);
1093
+ const parent = foundStore.parent;
1094
+ if (!parent) {
1095
+ throw new Error("Parent does not exist");
1096
+ }
1097
+ if (parent.type !== "object" /* Object */) {
1098
+ throw new Error("Cannot remove from non-object");
1099
+ }
1100
+ parent.removeProperty(foundStore.name);
1101
+ };
1102
+ var applyAddPatch = (rootStore, patch, refs = {}) => {
1103
+ const patchStore = createJsonSchemaStore(patch.value, refs);
1104
+ const { parentPath, field } = getParentForPath(patch.path);
1105
+ const foundParent = getJsonSchemaStoreByPath(rootStore, parentPath);
1106
+ if (!foundParent) {
1107
+ throw new Error("Parent does not exist");
1108
+ }
1109
+ if (foundParent.type !== "object" /* Object */) {
1110
+ throw new Error("Cannot add to non-object");
1111
+ }
1112
+ if (foundParent.getProperty(field)) {
1113
+ throw new Error(`Field "${field}" already exists in parent`);
1114
+ }
1115
+ foundParent.addPropertyWithStore(field, patchStore);
1116
+ };
1117
+ var applyMovePatch = (store, patch) => {
1118
+ const { parentPath: fromParentPath, field: fromField } = getParentForPath(
1119
+ patch.from
1120
+ );
1121
+ const { parentPath: toParentPath, field: toField } = getParentForPath(
1122
+ patch.path
1123
+ );
1124
+ const foundFromParent = getJsonSchemaStoreByPath(store, fromParentPath);
1125
+ const foundToParent = getJsonSchemaStoreByPath(store, toParentPath);
1126
+ const isValidToField = validateJsonFieldName(toField);
1127
+ if (!isValidToField) {
1128
+ throw new Error(
1129
+ `Invalid name: ${toField}. ${VALIDATE_JSON_FIELD_NAME_ERROR_MESSAGE}`
1130
+ );
1131
+ }
1132
+ if (!foundFromParent || !foundToParent) {
1133
+ throw new Error("Cannot move from or to non-existent parent");
1134
+ }
1135
+ if (foundFromParent.type !== "object" /* Object */) {
1136
+ throw new Error("Cannot move from non-object parent");
1137
+ }
1138
+ const foundFromField = getJsonSchemaStoreByPath(store, patch.from);
1139
+ const isMovedPropertyInSameParentPatch = foundFromParent === foundToParent && foundFromParent.type === "object" /* Object */ && foundFromParent.getProperty(fromField);
1140
+ if (isMovedPropertyInSameParentPatch) {
1141
+ return foundFromParent.changeName(fromField, toField);
1142
+ }
1143
+ if (foundToParent.type === "object" /* Object */) {
1144
+ foundFromParent.removeProperty(fromField);
1145
+ if (foundToParent.getProperty(toField)) {
1146
+ foundToParent.removeProperty(toField);
1147
+ }
1148
+ foundToParent.addPropertyWithStore(toField, foundFromField);
1149
+ return;
1150
+ }
1151
+ if (foundToParent.type === "array" /* Array */) {
1152
+ foundFromParent.removeProperty(fromField);
1153
+ foundToParent.replaceItems(foundFromField);
1154
+ return;
1155
+ }
1156
+ throw new Error('Invalid type of "to" parent');
1157
+ };
1158
+
1159
+ // src/lib/getDBJsonPathByJsonSchemaStore.ts
1160
+ var getDBJsonPathByJsonSchemaStore = (store) => {
1161
+ let node = store;
1162
+ let path = "";
1163
+ while (node.parent) {
1164
+ if (node.parent.type === "object" /* Object */) {
1165
+ path = `.${node.name}${path}`;
1166
+ } else if (node.parent.type === "array" /* Array */) {
1167
+ path = `[*]${path}`;
1168
+ }
1169
+ node = node.parent;
1170
+ }
1171
+ if (!path) {
1172
+ return "$";
1173
+ }
1174
+ return `$${path}`;
1175
+ };
1176
+
1177
+ // src/lib/getPathByStore.ts
1178
+ var getPathByStore = (store) => {
1179
+ let node = store;
1180
+ let path = "";
1181
+ while (node.parent) {
1182
+ if (node.parent.type === "object" /* Object */) {
1183
+ path = `/properties/${node.name}${path}`;
1184
+ } else if (node.parent.type === "array" /* Array */) {
1185
+ path = `/items${path}`;
1186
+ }
1187
+ node = node.parent;
1188
+ }
1189
+ if (!path) {
1190
+ return "/";
1191
+ }
1192
+ return `${path}`;
1193
+ };
1194
+
1195
+ // src/lib/traverseStore.ts
1196
+ var traverseStore = (store, callback) => {
1197
+ callback(store);
1198
+ if (store.type === "object" /* Object */) {
1199
+ Object.values(store.properties).forEach((item) => {
1200
+ traverseStore(item, callback);
1201
+ });
1202
+ } else if (store.type === "array" /* Array */) {
1203
+ traverseStore(store.items, callback);
1204
+ }
1205
+ };
1206
+
1207
+ // src/lib/getForeignKeyPatchesFromSchema.ts
1208
+ var getForeignKeyPatchesFromSchema = (store, options) => {
1209
+ const stores = [];
1210
+ traverseStore(store, (item) => {
1211
+ if (item.type === "string" /* String */ && item.foreignKey === options.tableId) {
1212
+ item.foreignKey = options.nextTableId;
1213
+ const patch = {
1214
+ op: "replace",
1215
+ path: getPathByStore(item),
1216
+ value: item.getPlainSchema()
1217
+ };
1218
+ stores.push(patch);
1219
+ }
1220
+ });
1221
+ return stores;
1222
+ };
1223
+
1224
+ // src/lib/getForeignKeysFromSchema.ts
1225
+ var getForeignKeysFromSchema = (store) => {
1226
+ const foreignKeys = /* @__PURE__ */ new Set();
1227
+ traverseStore(store, (item) => {
1228
+ if (item.type === "string" /* String */ && item.foreignKey) {
1229
+ foreignKeys.add(item.foreignKey);
1230
+ }
1231
+ });
1232
+ return [...foreignKeys].sort((a, b) => a.localeCompare(b));
1233
+ };
1234
+
1235
+ // src/lib/traverseValue.ts
1236
+ var traverseValue = (store, callback) => {
1237
+ callback(store);
1238
+ if (store.type === "object" /* Object */) {
1239
+ Object.values(store.value).forEach((item) => {
1240
+ traverseValue(item, callback);
1241
+ });
1242
+ } else if (store.type === "array" /* Array */) {
1243
+ store.value.forEach((itemValue) => {
1244
+ traverseValue(itemValue, callback);
1245
+ });
1246
+ }
1247
+ };
1248
+
1249
+ // src/lib/getForeignKeysFromValue.ts
1250
+ var getForeignKeysFromValue = (value) => {
1251
+ const foreignKeys = /* @__PURE__ */ new Map();
1252
+ traverseValue(value, (item) => {
1253
+ if (item.type === "string" /* String */ && item.foreignKey) {
1254
+ let tableForeignKey = foreignKeys.get(item.foreignKey);
1255
+ if (!tableForeignKey) {
1256
+ tableForeignKey = /* @__PURE__ */ new Set();
1257
+ foreignKeys.set(item.foreignKey, tableForeignKey);
1258
+ }
1259
+ tableForeignKey.add(item.getPlainValue());
1260
+ }
1261
+ });
1262
+ return [...foreignKeys].map(([tableId, rowIds]) => ({
1263
+ tableId,
1264
+ rowIds: [...rowIds].sort((a, b) => a.localeCompare(b))
1265
+ }));
1266
+ };
1267
+
1268
+ // src/lib/getInvalidFieldNamesInSchema.ts
1269
+ var getInvalidFieldNamesInSchema = (schema, refs = {}) => {
1270
+ const schemaStore = createJsonSchemaStore(schema, refs);
1271
+ const invalidFields = [];
1272
+ traverseStore(schemaStore, (item) => {
1273
+ if (item.parent?.type === "object" /* Object */) {
1274
+ if (!validateJsonFieldName(item.name)) {
1275
+ invalidFields.push(item);
1276
+ }
1277
+ }
1278
+ });
1279
+ return invalidFields;
1280
+ };
1281
+
1282
+ // src/lib/getJsonValueByPath.ts
1283
+ var getJsonValueStoreByPath = (root, path) => {
1284
+ if (!path) {
1285
+ return root;
1286
+ }
1287
+ const segments = getSegments(path);
1288
+ let current = root;
1289
+ for (const seg of segments) {
1290
+ if (current instanceof JsonObjectValueStore) {
1291
+ const next = current.value[String(seg)];
1292
+ if (!next) {
1293
+ throw new Error(`Path not found at segment "${seg}"`);
1294
+ }
1295
+ current = next;
1296
+ } else if (current instanceof JsonArrayValueStore) {
1297
+ if (typeof seg !== "number") {
1298
+ throw new Error(`Invalid array index "${seg}"`);
1299
+ }
1300
+ const next = current.value[seg];
1301
+ if (!next) {
1302
+ throw new Error(`Path not found at segment "${seg}"`);
1303
+ }
1304
+ current = next;
1305
+ } else {
1306
+ throw new Error(`Cannot navigate into primitive at segment "${seg}"`);
1307
+ }
1308
+ }
1309
+ return current;
1310
+ };
1311
+ var regex = /([^.[\]]+)|\[(\d+)]/g;
1312
+ var getSegments = (path) => {
1313
+ const segments = [];
1314
+ let match;
1315
+ while (match = regex.exec(path)) {
1316
+ if (match[1] !== void 0) {
1317
+ segments.push(match[1]);
1318
+ } else if (match[2] !== void 0) {
1319
+ segments.push(Number(match[2]));
1320
+ }
1321
+ }
1322
+ return segments;
1323
+ };
1324
+
1325
+ // src/lib/replaceForeignKeyValue.ts
1326
+ var replaceForeignKeyValue = (options) => {
1327
+ let wasUpdated = false;
1328
+ traverseValue(options.valueStore, (item) => {
1329
+ if (item.type === "string" /* String */ && item.foreignKey === options.foreignKey && item.value === options.value) {
1330
+ item.value = options.nextValue;
1331
+ wasUpdated = true;
1332
+ }
1333
+ });
1334
+ return wasUpdated;
1335
+ };
1336
+
1337
+ // src/lib/resolveRefs.ts
1338
+ var pluginRefs = {
1339
+ ["urn:jsonschema:io:revisium:row-id-schema:1.0.0" /* RowId */]: rowIdSchema,
1340
+ ["urn:jsonschema:io:revisium:row-version-id-schema:1.0.0" /* RowVersionId */]: rowVersionIdSchema,
1341
+ ["urn:jsonschema:io:revisium:row-created-id-schema:1.0.0" /* RowCreatedId */]: rowCreatedIdSchema,
1342
+ ["urn:jsonschema:io:revisium:row-created-at-schema:1.0.0" /* RowCreatedAt */]: rowCreatedAtSchema,
1343
+ ["urn:jsonschema:io:revisium:row-published-at-schema:1.0.0" /* RowPublishedAt */]: rowPublishedAtSchema,
1344
+ ["urn:jsonschema:io:revisium:row-updated-at-schema:1.0.0" /* RowUpdatedAt */]: rowUpdatedAtSchema,
1345
+ ["urn:jsonschema:io:revisium:row-hash-schema:1.0.0" /* RowHash */]: rowHashSchema,
1346
+ ["urn:jsonschema:io:revisium:row-schema-hash-schema:1.0.0" /* RowSchemaHash */]: rowSchemaHashSchema,
1347
+ ["urn:jsonschema:io:revisium:file-schema:1.0.0" /* File */]: fileSchema
1348
+ };
1349
+ var resolveRefs = (schema) => {
1350
+ const store = createJsonSchemaStore(schema, pluginRefs);
1351
+ return store.getPlainSchema({ skip$Ref: true });
1352
+ };
1353
+
1354
+ // src/lib/schema-table.ts
1355
+ var SchemaTable = class {
1356
+ constructor(schema, refs = {}) {
1357
+ this.refs = refs;
1358
+ this.store = createJsonSchemaStore(schema, refs);
1359
+ }
1360
+ rows = /* @__PURE__ */ new Map();
1361
+ store;
1362
+ applyPatches(patches) {
1363
+ patches.forEach((patch) => {
1364
+ switch (patch.op) {
1365
+ case "replace": {
1366
+ const nextStore = applyReplacePatch(this.store, patch, this.refs);
1367
+ if (nextStore !== this.store) {
1368
+ this.migrateRows(nextStore);
1369
+ }
1370
+ break;
1371
+ }
1372
+ case "remove": {
1373
+ applyRemovePatch(this.store, patch);
1374
+ break;
1375
+ }
1376
+ case "add": {
1377
+ applyAddPatch(this.store, patch, this.refs);
1378
+ break;
1379
+ }
1380
+ case "move": {
1381
+ applyMovePatch(this.store, patch);
1382
+ break;
1383
+ }
1384
+ default:
1385
+ throw new Error(`Unsupported patch operation`);
1386
+ }
1387
+ });
1388
+ }
1389
+ getSchema() {
1390
+ return this.store.getPlainSchema();
1391
+ }
1392
+ addRow(rowId, data) {
1393
+ const row = createJsonValueStore(this.store, rowId, data);
1394
+ this.rows.set(rowId, row);
1395
+ }
1396
+ getRow(id) {
1397
+ const row = this.rows.get(id);
1398
+ if (!row) {
1399
+ throw new Error("Invalid id");
1400
+ }
1401
+ return row.getPlainValue();
1402
+ }
1403
+ getRows() {
1404
+ return [...this.rows].map(([id, data]) => ({
1405
+ id,
1406
+ data: data.getPlainValue()
1407
+ }));
1408
+ }
1409
+ migrateRows(nextStore) {
1410
+ const transformation = getTransformation(this.store, nextStore);
1411
+ if (transformation) {
1412
+ for (const [rowId, row] of this.rows) {
1413
+ const rawNextValue = transformation(
1414
+ row.getPlainValue(),
1415
+ nextStore.default
1416
+ );
1417
+ const nextRow = createJsonValueStore(nextStore, rowId, rawNextValue);
1418
+ this.rows.set(rowId, nextRow);
1419
+ }
1420
+ }
1421
+ this.store = nextStore;
1422
+ }
1423
+ };
1424
+
1425
+ // src/validation-schemas/shared-fields.ts
1426
+ var sharedFields = {
1427
+ deprecated: {
1428
+ type: "boolean"
1429
+ },
1430
+ title: {
1431
+ type: "string"
1432
+ },
1433
+ description: {
1434
+ type: "string"
1435
+ }
1436
+ };
1437
+
1438
+ // src/validation-schemas/meta-schema.ts
1439
+ var refMetaSchema = {
1440
+ type: "object",
1441
+ properties: {
1442
+ ...sharedFields,
1443
+ $ref: {
1444
+ type: "string"
1445
+ }
1446
+ },
1447
+ additionalProperties: false,
1448
+ required: ["$ref"]
1449
+ };
1450
+ var baseStringFields = {
1451
+ type: {
1452
+ const: "string"
1453
+ },
1454
+ default: {
1455
+ type: "string"
1456
+ },
1457
+ readOnly: {
1458
+ type: "boolean"
1459
+ },
1460
+ pattern: {
1461
+ type: "string",
1462
+ format: "regex"
1463
+ },
1464
+ enum: {
1465
+ type: "array",
1466
+ items: { type: "string" },
1467
+ minItems: 1,
1468
+ uniqueItems: true
1469
+ },
1470
+ format: {
1471
+ type: "string",
1472
+ enum: ["date-time", "date", "time", "email", "regex"]
1473
+ },
1474
+ contentMediaType: {
1475
+ type: "string",
1476
+ enum: [
1477
+ "text/plain",
1478
+ "text/markdown",
1479
+ "text/html",
1480
+ "application/json",
1481
+ "application/schema+json",
1482
+ "application/yaml"
1483
+ ]
1484
+ },
1485
+ ...sharedFields
1486
+ };
1487
+ var stringMetaSchema = {
1488
+ type: "object",
1489
+ properties: {
1490
+ ...baseStringFields,
1491
+ foreignKey: {
1492
+ type: "string"
1493
+ }
1494
+ },
1495
+ additionalProperties: false,
1496
+ required: ["type", "default"]
1497
+ };
1498
+ var noForeignKeyStringMetaSchema = {
1499
+ type: "object",
1500
+ properties: {
1501
+ ...baseStringFields
1502
+ },
1503
+ additionalProperties: false,
1504
+ required: ["type", "default"]
1505
+ };
1506
+ var numberMetaSchema = {
1507
+ type: "object",
1508
+ properties: {
1509
+ type: {
1510
+ const: "number"
1511
+ },
1512
+ default: {
1513
+ type: "number"
1514
+ },
1515
+ readOnly: {
1516
+ type: "boolean"
1517
+ },
1518
+ ...sharedFields
1519
+ },
1520
+ additionalProperties: false,
1521
+ required: ["type", "default"]
1522
+ };
1523
+ var booleanMetaSchema = {
1524
+ type: "object",
1525
+ properties: {
1526
+ type: {
1527
+ const: "boolean"
1528
+ },
1529
+ default: {
1530
+ type: "boolean"
1531
+ },
1532
+ readOnly: {
1533
+ type: "boolean"
1534
+ },
1535
+ ...sharedFields
1536
+ },
1537
+ additionalProperties: false,
1538
+ required: ["type", "default"]
1539
+ };
1540
+ var objectMetaSchema = {
1541
+ type: "object",
1542
+ properties: {
1543
+ type: {
1544
+ const: "object"
1545
+ },
1546
+ ...sharedFields,
1547
+ properties: {
1548
+ type: "object",
1549
+ additionalProperties: { $dynamicRef: "#meta" },
1550
+ default: {}
1551
+ },
1552
+ additionalProperties: { const: false },
1553
+ required: { $ref: "#/$defs/stringArray" }
1554
+ },
1555
+ additionalProperties: false,
1556
+ required: ["type", "properties", "additionalProperties", "required"]
1557
+ };
1558
+ var arrayMetaSchema = {
1559
+ type: "object",
1560
+ properties: {
1561
+ type: {
1562
+ const: "array"
1563
+ },
1564
+ ...sharedFields,
1565
+ items: {
1566
+ oneOf: [
1567
+ { $ref: "#/$defs/refSchema" },
1568
+ { $ref: "#/$defs/objectSchema" },
1569
+ { $ref: "#/$defs/arraySchema" },
1570
+ { $ref: "#/$defs/stringSchema" },
1571
+ { $ref: "#/$defs/numberSchema" },
1572
+ { $ref: "#/$defs/booleanSchema" }
1573
+ ]
1574
+ }
1575
+ },
1576
+ additionalProperties: false,
1577
+ required: ["type", "items"]
1578
+ };
1579
+ var metaSchema = {
1580
+ $id: "meta-schema.json",
1581
+ type: "object",
1582
+ $dynamicAnchor: "meta",
1583
+ oneOf: [
1584
+ { $ref: "#/$defs/refSchema" },
1585
+ { $ref: "#/$defs/objectSchema" },
1586
+ { $ref: "#/$defs/arraySchema" },
1587
+ { $ref: "#/$defs/stringSchema" },
1588
+ { $ref: "#/$defs/numberSchema" },
1589
+ { $ref: "#/$defs/booleanSchema" }
1590
+ ],
1591
+ $defs: {
1592
+ stringArray: {
1593
+ type: "array",
1594
+ items: { type: "string" },
1595
+ uniqueItems: true,
1596
+ default: []
1597
+ },
1598
+ refSchema: refMetaSchema,
1599
+ objectSchema: objectMetaSchema,
1600
+ stringSchema: stringMetaSchema,
1601
+ numberSchema: numberMetaSchema,
1602
+ booleanSchema: booleanMetaSchema,
1603
+ arraySchema: arrayMetaSchema
1604
+ }
1605
+ };
1606
+ var notForeignKeyMetaSchema = {
1607
+ type: "object",
1608
+ $dynamicAnchor: "meta",
1609
+ oneOf: [
1610
+ { $ref: "#/$defs/refSchema" },
1611
+ { $ref: "#/$defs/objectSchema" },
1612
+ { $ref: "#/$defs/arraySchema" },
1613
+ { $ref: "#/$defs/stringSchema" },
1614
+ { $ref: "#/$defs/numberSchema" },
1615
+ { $ref: "#/$defs/booleanSchema" }
1616
+ ],
1617
+ $defs: {
1618
+ stringArray: {
1619
+ type: "array",
1620
+ items: { type: "string" },
1621
+ uniqueItems: true,
1622
+ default: []
1623
+ },
1624
+ refSchema: refMetaSchema,
1625
+ objectSchema: objectMetaSchema,
1626
+ stringSchema: noForeignKeyStringMetaSchema,
1627
+ numberSchema: numberMetaSchema,
1628
+ booleanSchema: booleanMetaSchema,
1629
+ arraySchema: arrayMetaSchema
1630
+ }
1631
+ };
1632
+
1633
+ // src/validation-schemas/json-patch-schema.ts
1634
+ var jsonPatchSchema = {
1635
+ $id: "json-patch-schema.json",
1636
+ definitions: {
1637
+ path: {
1638
+ description: "A JSON Pointer path.",
1639
+ type: "string"
1640
+ },
1641
+ objectSchema: objectMetaSchema,
1642
+ stringSchema: stringMetaSchema,
1643
+ numberSchema: numberMetaSchema,
1644
+ booleanSchema: booleanMetaSchema,
1645
+ arraySchema: arrayMetaSchema
1646
+ },
1647
+ minItems: 1,
1648
+ items: {
1649
+ oneOf: [
1650
+ {
1651
+ type: "object",
1652
+ additionalProperties: false,
1653
+ required: ["value", "op", "path"],
1654
+ properties: {
1655
+ path: {
1656
+ $ref: "#/definitions/path"
1657
+ },
1658
+ op: {
1659
+ description: "The operation to perform.",
1660
+ type: "string",
1661
+ enum: ["add", "replace"]
1662
+ },
1663
+ value: {
1664
+ $ref: "meta-schema.json",
1665
+ description: "The value to add, replace or test."
1666
+ }
1667
+ }
1668
+ },
1669
+ {
1670
+ type: "object",
1671
+ additionalProperties: false,
1672
+ required: ["op", "path"],
1673
+ properties: {
1674
+ path: {
1675
+ $ref: "#/definitions/path"
1676
+ },
1677
+ op: {
1678
+ description: "The operation to perform.",
1679
+ type: "string",
1680
+ enum: ["remove"]
1681
+ }
1682
+ }
1683
+ },
1684
+ {
1685
+ type: "object",
1686
+ additionalProperties: false,
1687
+ required: ["from", "op", "path"],
1688
+ properties: {
1689
+ path: {
1690
+ $ref: "#/definitions/path"
1691
+ },
1692
+ op: {
1693
+ description: "The operation to perform.",
1694
+ type: "string",
1695
+ enum: ["move", "copy"]
1696
+ },
1697
+ from: {
1698
+ $ref: "#/definitions/path",
1699
+ description: "A JSON Pointer path pointing to the location to move/copy from."
1700
+ }
1701
+ }
1702
+ }
1703
+ ]
1704
+ },
1705
+ title: "JSON schema for JSONPatch files",
1706
+ type: "array"
1707
+ };
1708
+
1709
+ // src/validation-schemas/history-patches-schema.ts
1710
+ var historyPatchesSchema = {
1711
+ $id: "history-patches-schema.json",
1712
+ type: "array",
1713
+ minItems: 1,
1714
+ items: {
1715
+ type: "object",
1716
+ properties: {
1717
+ patches: {
1718
+ $ref: "json-patch-schema.json"
1719
+ },
1720
+ hash: {
1721
+ type: "string"
1722
+ }
1723
+ },
1724
+ required: ["patches", "hash"]
1725
+ }
1726
+ };
1727
+
1728
+ // src/validation-schemas/table-migrations-schema.ts
1729
+ var tableMigrationsSchema = {
1730
+ $id: "table-migrations-schema.json",
1731
+ oneOf: [
1732
+ { $ref: "#/definitions/InitMigration" },
1733
+ { $ref: "#/definitions/UpdateMigration" },
1734
+ { $ref: "#/definitions/RenameMigration" },
1735
+ { $ref: "#/definitions/RemoveMigration" }
1736
+ ],
1737
+ definitions: {
1738
+ InitMigration: {
1739
+ type: "object",
1740
+ additionalProperties: false,
1741
+ required: ["changeType", "tableId", "hash", "id", "schema"],
1742
+ properties: {
1743
+ changeType: { type: "string", const: "init" },
1744
+ tableId: { type: "string" },
1745
+ hash: { type: "string" },
1746
+ id: { type: "string" },
1747
+ schema: { $ref: "meta-schema.json" }
1748
+ }
1749
+ },
1750
+ UpdateMigration: {
1751
+ type: "object",
1752
+ additionalProperties: false,
1753
+ required: ["changeType", "tableId", "hash", "id", "patches"],
1754
+ properties: {
1755
+ changeType: { type: "string", const: "update" },
1756
+ tableId: { type: "string" },
1757
+ hash: { type: "string" },
1758
+ id: { type: "string" },
1759
+ patches: { $ref: "json-patch-schema.json" }
1760
+ }
1761
+ },
1762
+ RenameMigration: {
1763
+ type: "object",
1764
+ additionalProperties: false,
1765
+ required: ["changeType", "id", "tableId", "nextTableId"],
1766
+ properties: {
1767
+ changeType: { type: "string", const: "rename" },
1768
+ id: { type: "string" },
1769
+ tableId: { type: "string" },
1770
+ nextTableId: { type: "string" }
1771
+ }
1772
+ },
1773
+ RemoveMigration: {
1774
+ type: "object",
1775
+ additionalProperties: false,
1776
+ required: ["changeType", "id", "tableId"],
1777
+ properties: {
1778
+ changeType: { type: "string", const: "remove" },
1779
+ id: { type: "string" },
1780
+ tableId: { type: "string" }
1781
+ }
1782
+ }
1783
+ },
1784
+ title: "JSON Schema for a Single Migration"
1785
+ };
1786
+
1787
+ exports.CustomSchemeKeywords = CustomSchemeKeywords;
1788
+ exports.JsonArrayStore = JsonArrayStore;
1789
+ exports.JsonArrayValueStore = JsonArrayValueStore;
1790
+ exports.JsonBooleanStore = JsonBooleanStore;
1791
+ exports.JsonBooleanValueStore = JsonBooleanValueStore;
1792
+ exports.JsonNumberStore = JsonNumberStore;
1793
+ exports.JsonNumberValueStore = JsonNumberValueStore;
1794
+ exports.JsonObjectStore = JsonObjectStore;
1795
+ exports.JsonObjectValueStore = JsonObjectValueStore;
1796
+ exports.JsonSchemaTypeName = JsonSchemaTypeName;
1797
+ exports.JsonStringStore = JsonStringStore;
1798
+ exports.JsonStringValueStore = JsonStringValueStore;
1799
+ exports.SchemaTable = SchemaTable;
1800
+ exports.SystemSchemaIds = SystemSchemaIds;
1801
+ exports.VALIDATE_JSON_FIELD_NAME_ERROR_MESSAGE = VALIDATE_JSON_FIELD_NAME_ERROR_MESSAGE;
1802
+ exports.addSharedFieldsFromState = addSharedFieldsFromState;
1803
+ exports.applyAddPatch = applyAddPatch;
1804
+ exports.applyMovePatch = applyMovePatch;
1805
+ exports.applyRemovePatch = applyRemovePatch;
1806
+ exports.applyReplacePatch = applyReplacePatch;
1807
+ exports.arrayMetaSchema = arrayMetaSchema;
1808
+ exports.baseStringFields = baseStringFields;
1809
+ exports.booleanMetaSchema = booleanMetaSchema;
1810
+ exports.createJsonArrayValueStore = createJsonArrayValueStore;
1811
+ exports.createJsonObjectSchemaStore = createJsonObjectSchemaStore;
1812
+ exports.createJsonObjectValueStore = createJsonObjectValueStore;
1813
+ exports.createJsonSchemaStore = createJsonSchemaStore;
1814
+ exports.createJsonValueStore = createJsonValueStore;
1815
+ exports.createPrimitiveStoreBySchema = createPrimitiveStoreBySchema;
1816
+ exports.createPrimitiveValueStore = createPrimitiveValueStore;
1817
+ exports.equel = equel;
1818
+ exports.fileSchema = fileSchema;
1819
+ exports.fromArrayTransformation = fromArrayTransformation;
1820
+ exports.fromBooleanToNumber = fromBooleanToNumber;
1821
+ exports.fromBooleanToString = fromBooleanToString;
1822
+ exports.fromNumberToBoolean = fromNumberToBoolean;
1823
+ exports.fromNumberToString = fromNumberToString;
1824
+ exports.fromStringToBoolean = fromStringToBoolean;
1825
+ exports.fromStringToNumber = fromStringToNumber;
1826
+ exports.getAddPatch = getAddPatch;
1827
+ exports.getArraySchema = getArraySchema;
1828
+ exports.getBooleanSchema = getBooleanSchema;
1829
+ exports.getDBJsonPathByJsonSchemaStore = getDBJsonPathByJsonSchemaStore;
1830
+ exports.getForeignKeyPatchesFromSchema = getForeignKeyPatchesFromSchema;
1831
+ exports.getForeignKeysFromSchema = getForeignKeysFromSchema;
1832
+ exports.getForeignKeysFromValue = getForeignKeysFromValue;
1833
+ exports.getInvalidFieldNamesInSchema = getInvalidFieldNamesInSchema;
1834
+ exports.getJsonSchemaStoreByPath = getJsonSchemaStoreByPath;
1835
+ exports.getJsonValueStoreByPath = getJsonValueStoreByPath;
1836
+ exports.getMovePatch = getMovePatch;
1837
+ exports.getNumberSchema = getNumberSchema;
1838
+ exports.getObjectSchema = getObjectSchema;
1839
+ exports.getParentForPath = getParentForPath;
1840
+ exports.getPathByStore = getPathByStore;
1841
+ exports.getRefSchema = getRefSchema;
1842
+ exports.getRemovePatch = getRemovePatch;
1843
+ exports.getReplacePatch = getReplacePatch;
1844
+ exports.getStringSchema = getStringSchema;
1845
+ exports.getTransformation = getTransformation;
1846
+ exports.historyPatchesSchema = historyPatchesSchema;
1847
+ exports.jsonPatchSchema = jsonPatchSchema;
1848
+ exports.metaSchema = metaSchema;
1849
+ exports.noForeignKeyStringMetaSchema = noForeignKeyStringMetaSchema;
1850
+ exports.notForeignKeyMetaSchema = notForeignKeyMetaSchema;
1851
+ exports.numberMetaSchema = numberMetaSchema;
1852
+ exports.objectMetaSchema = objectMetaSchema;
1853
+ exports.pluginRefs = pluginRefs;
1854
+ exports.refMetaSchema = refMetaSchema;
1855
+ exports.replaceForeignKeyValue = replaceForeignKeyValue;
1856
+ exports.resolveRefs = resolveRefs;
1857
+ exports.rowCreatedAtSchema = rowCreatedAtSchema;
1858
+ exports.rowCreatedIdSchema = rowCreatedIdSchema;
1859
+ exports.rowHashSchema = rowHashSchema;
1860
+ exports.rowIdSchema = rowIdSchema;
1861
+ exports.rowPublishedAtSchema = rowPublishedAtSchema;
1862
+ exports.rowSchemaHashSchema = rowSchemaHashSchema;
1863
+ exports.rowUpdatedAtSchema = rowUpdatedAtSchema;
1864
+ exports.rowVersionIdSchema = rowVersionIdSchema;
1865
+ exports.saveSharedFields = saveSharedFields;
1866
+ exports.sharedFields = sharedFields;
1867
+ exports.stringMetaSchema = stringMetaSchema;
1868
+ exports.tableMigrationsSchema = tableMigrationsSchema;
1869
+ exports.toArrayTransformation = toArrayTransformation;
1870
+ exports.traverseStore = traverseStore;
1871
+ exports.traverseValue = traverseValue;
1872
+ exports.validateJsonFieldName = validateJsonFieldName;
1873
+ //# sourceMappingURL=index.cjs.map
1874
+ //# sourceMappingURL=index.cjs.map