@routier/core 0.2.1 → 0.4.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 (161) hide show
  1. package/LICENSE +21 -0
  2. package/{readme.md → README.md} +3 -3
  3. package/dist/assertions/index.cjs +191 -0
  4. package/dist/assertions/index.cjs.map +1 -0
  5. package/dist/assertions/index.js +43 -63
  6. package/dist/assertions/index.js.map +1 -1
  7. package/dist/capabilities/index.cjs +820 -0
  8. package/dist/capabilities/index.cjs.map +1 -0
  9. package/dist/capabilities/index.js +584 -558
  10. package/dist/capabilities/index.js.map +1 -1
  11. package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
  12. package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
  13. package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
  14. package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
  15. package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
  16. package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
  17. package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
  18. package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
  19. package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
  20. package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
  21. package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
  22. package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
  23. package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
  24. package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
  25. package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
  26. package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
  27. package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
  28. package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
  29. package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
  30. package/dist/codegen/handlers/types.d.ts +55 -1
  31. package/dist/codegen/index.cjs +618 -0
  32. package/dist/codegen/index.cjs.map +1 -0
  33. package/dist/codegen/index.js +99 -127
  34. package/dist/codegen/index.js.map +1 -1
  35. package/dist/collections/MemoryDataCollection.d.ts +15 -1
  36. package/dist/collections/TagCollection.d.ts +0 -1
  37. package/dist/collections/index.cjs +702 -0
  38. package/dist/collections/index.cjs.map +1 -0
  39. package/dist/collections/index.js +282 -276
  40. package/dist/collections/index.js.map +1 -1
  41. package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
  42. package/dist/errors/PluginDestroyedError.d.ts +10 -0
  43. package/dist/errors/index.cjs +132 -0
  44. package/dist/errors/index.cjs.map +1 -0
  45. package/dist/errors/index.d.ts +2 -0
  46. package/dist/errors/index.js +61 -19
  47. package/dist/errors/index.js.map +1 -1
  48. package/dist/expressions/evaluate.d.ts +53 -0
  49. package/dist/expressions/index.cjs +2087 -0
  50. package/dist/expressions/index.cjs.map +1 -0
  51. package/dist/expressions/index.d.ts +1 -1
  52. package/dist/expressions/index.js +1727 -1082
  53. package/dist/expressions/index.js.map +1 -1
  54. package/dist/expressions/parser.d.ts +19 -0
  55. package/dist/expressions/types.d.ts +87 -2
  56. package/dist/index.cjs +14377 -0
  57. package/dist/index.cjs.map +1 -0
  58. package/dist/index.js +12374 -7931
  59. package/dist/index.js.map +1 -1
  60. package/dist/performance/index.cjs +217 -0
  61. package/dist/performance/index.cjs.map +1 -0
  62. package/dist/performance/index.js +120 -55
  63. package/dist/performance/index.js.map +1 -1
  64. package/dist/pipeline/index.cjs +576 -0
  65. package/dist/pipeline/index.cjs.map +1 -0
  66. package/dist/pipeline/index.js +223 -161
  67. package/dist/pipeline/index.js.map +1 -1
  68. package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
  69. package/dist/plugins/CacheDbPlugin.d.ts +70 -0
  70. package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
  71. package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
  72. package/dist/plugins/RetryDbPlugin.d.ts +77 -0
  73. package/dist/plugins/index.cjs +6551 -0
  74. package/dist/plugins/index.cjs.map +1 -0
  75. package/dist/plugins/index.d.ts +5 -0
  76. package/dist/plugins/index.js +6271 -1170
  77. package/dist/plugins/index.js.map +1 -1
  78. package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
  79. package/dist/plugins/query/explain.d.ts +82 -0
  80. package/dist/plugins/query/formatExplanation.d.ts +9 -0
  81. package/dist/plugins/query/index.d.ts +4 -0
  82. package/dist/plugins/query/join.d.ts +210 -0
  83. package/dist/plugins/query/similarity.d.ts +38 -0
  84. package/dist/plugins/query/types.d.ts +75 -1
  85. package/dist/plugins/translators/DataTranslator.d.ts +28 -0
  86. package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
  87. package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
  88. package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
  89. package/dist/plugins/translators/index.d.ts +1 -0
  90. package/dist/plugins/types.d.ts +125 -3
  91. package/dist/plugins/wire/handler.d.ts +122 -0
  92. package/dist/plugins/wire/index.d.ts +4 -0
  93. package/dist/plugins/wire/persist.d.ts +43 -0
  94. package/dist/plugins/wire/query.d.ts +49 -0
  95. package/dist/plugins/wire/types.d.ts +139 -0
  96. package/dist/results/index.cjs +174 -0
  97. package/dist/results/index.cjs.map +1 -0
  98. package/dist/results/index.js +29 -44
  99. package/dist/results/index.js.map +1 -1
  100. package/dist/schema/PropertyInfo.d.ts +31 -2
  101. package/dist/schema/SchemaDefinition.d.ts +23 -1
  102. package/dist/schema/builder.d.ts +35 -1
  103. package/dist/schema/communication/broadcast.d.ts +17 -1
  104. package/dist/schema/index.cjs +6911 -0
  105. package/dist/schema/index.cjs.map +1 -0
  106. package/dist/schema/index.d.ts +2 -0
  107. package/dist/schema/index.js +5330 -4541
  108. package/dist/schema/index.js.map +1 -1
  109. package/dist/schema/property/base/SchemaBase.d.ts +48 -2
  110. package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
  111. package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
  112. package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
  113. package/dist/schema/property/modifiers/index.d.ts +1 -0
  114. package/dist/schema/property/types/SchemaFile.d.ts +60 -0
  115. package/dist/schema/property/types/SchemaString.d.ts +21 -1
  116. package/dist/schema/property/types/SchemaVector.d.ts +61 -0
  117. package/dist/schema/property/types/index.d.ts +2 -0
  118. package/dist/schema/table/SchemaTransform.d.ts +40 -0
  119. package/dist/schema/table/index.d.ts +1 -0
  120. package/dist/schema/types.d.ts +166 -8
  121. package/dist/schema/utils/propertyKind.d.ts +4 -0
  122. package/dist/types/index.cjs +23 -0
  123. package/dist/types/index.cjs.map +1 -0
  124. package/dist/types/index.js +0 -14
  125. package/dist/types/index.js.map +1 -1
  126. package/dist/utilities/index.cjs +1013 -0
  127. package/dist/utilities/index.cjs.map +1 -0
  128. package/dist/utilities/index.js +541 -379
  129. package/dist/utilities/index.js.map +1 -1
  130. package/dist/utilities/logger.d.ts +48 -0
  131. package/package.json +156 -98
  132. package/dist/codegen/SlotPath.test.d.ts +0 -1
  133. package/dist/codegen/blocks.test.d.ts +0 -1
  134. package/dist/codegen/utils.test.d.ts +0 -1
  135. package/dist/collections/Changes.test.d.ts +0 -1
  136. package/dist/collections/IdSet.test.d.ts +0 -1
  137. package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
  138. package/dist/collections/TagCollection.contract.test.d.ts +0 -1
  139. package/dist/collections/TagCollection.test.d.ts +0 -1
  140. package/dist/expressions/parser.test.d.ts +0 -1
  141. package/dist/expressions/sql.d.ts +0 -28
  142. package/dist/expressions/sql.test.d.ts +0 -1
  143. package/dist/expressions/utils.test.d.ts +0 -1
  144. package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
  145. package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
  146. package/dist/plugins/query/Query.test.d.ts +0 -1
  147. package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
  148. package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
  149. package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
  150. package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
  151. package/dist/results/Result.test.d.ts +0 -1
  152. package/dist/results/utils.test.d.ts +0 -1
  153. package/dist/schema/PropertyInfo.test.d.ts +0 -1
  154. package/dist/schema/communication/broadcast.test.d.ts +0 -1
  155. package/dist/schema/schemaGeneration.test.d.ts +0 -1
  156. package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
  157. package/dist/utilities/arrays.test.d.ts +0 -1
  158. package/dist/utilities/dates.test.d.ts +0 -1
  159. package/dist/utilities/runtime.test.d.ts +0 -1
  160. package/dist/utilities/strings.test.d.ts +0 -1
  161. package/dist/utilities/uuid.test.d.ts +0 -1
@@ -1,13 +1,12 @@
1
1
  var __webpack_modules__ = ({
2
- "./src/collections/Changes.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
- __webpack_require__.r(__webpack_exports__);
2
+ 533(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
3
  __webpack_require__.d(__webpack_exports__, {
5
- BulkPersistChanges: () => (BulkPersistChanges),
6
- BulkPersistResult: () => (BulkPersistResult),
7
- SchemaPersistChanges: () => (SchemaPersistChanges),
8
- SchemaPersistResult: () => (SchemaPersistResult)
4
+ $E: () => (SchemaPersistChanges),
5
+ R7: () => (SchemaPersistResult),
6
+ om: () => (BulkPersistResult),
7
+ qk: () => (BulkPersistChanges)
9
8
  });
10
- /* import */ var _TagCollection__rspack_import_0 = __webpack_require__("./src/collections/TagCollection.ts");
9
+ /* import */ var _TagCollection__rspack_import_0 = __webpack_require__(356);
11
10
 
12
11
  class BulkPersistResult extends Map {
13
12
  resolve(schemaId) {
@@ -30,28 +29,28 @@ class BulkPersistResult extends Map {
30
29
  }
31
30
  get aggregateSize() {
32
31
  let count = 0;
33
- for (const [, result] of this) {
32
+ for (const [, result] of this){
34
33
  count += result.total;
35
34
  }
36
35
  return count;
37
36
  }
38
37
  get aggregateAddsSize() {
39
38
  let count = 0;
40
- for (const [, result] of this) {
39
+ for (const [, result] of this){
41
40
  count += result.adds.length;
42
41
  }
43
42
  return count;
44
43
  }
45
44
  get aggregateUpdatesSize() {
46
45
  let count = 0;
47
- for (const [, result] of this) {
46
+ for (const [, result] of this){
48
47
  count += result.updates.length;
49
48
  }
50
49
  return count;
51
50
  }
52
51
  get aggregateRemovesSize() {
53
52
  let count = 0;
54
- for (const [, result] of this) {
53
+ for (const [, result] of this){
55
54
  count += result.removes.length;
56
55
  }
57
56
  return count;
@@ -78,39 +77,38 @@ class BulkPersistChanges extends Map {
78
77
  }
79
78
  get aggregateSize() {
80
79
  let count = 0;
81
- for (const [, result] of this) {
80
+ for (const [, result] of this){
82
81
  count += result.total;
83
82
  }
84
83
  return count;
85
84
  }
86
85
  get aggregateAddsSize() {
87
86
  let count = 0;
88
- for (const [, result] of this) {
87
+ for (const [, result] of this){
89
88
  count += result.adds.length;
90
89
  }
91
90
  return count;
92
91
  }
93
92
  get aggregateUpdatesSize() {
94
93
  let count = 0;
95
- for (const [, result] of this) {
94
+ for (const [, result] of this){
96
95
  count += result.updates.length;
97
96
  }
98
97
  return count;
99
98
  }
100
99
  get aggregateRemovesSize() {
101
100
  let count = 0;
102
- for (const [, result] of this) {
101
+ for (const [, result] of this){
103
102
  count += result.removes.length;
104
103
  }
105
104
  return count;
106
105
  }
107
106
  /**
108
107
  * Ensures the result has the same result sets as the change sets
109
- * @returns
110
- */
111
- toResult() {
108
+ * @returns
109
+ */ toResult() {
112
110
  const result = new BulkPersistResult();
113
- for (const [schemaId] of this) {
111
+ for (const [schemaId] of this){
114
112
  result.set(schemaId, new SchemaPersistResult());
115
113
  }
116
114
  return result;
@@ -120,7 +118,7 @@ class SchemaPersistChanges {
120
118
  adds = [];
121
119
  updates = [];
122
120
  removes = [];
123
- tags = new _TagCollection__rspack_import_0.TagCollection();
121
+ tags = new _TagCollection__rspack_import_0/* .TagCollection */.r();
124
122
  get hasItems() {
125
123
  return this.total > 0;
126
124
  }
@@ -142,176 +140,15 @@ class SchemaPersistResult {
142
140
 
143
141
 
144
142
  },
145
- "./src/collections/IdSet.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
146
- __webpack_require__.r(__webpack_exports__);
143
+ 995(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
147
144
  __webpack_require__.d(__webpack_exports__, {
148
- IdSet: () => (IdSet)
149
- });
150
- class IdSet {
151
- ids;
152
- constructor(...ids) {
153
- this.ids = Object.freeze(ids);
154
- }
155
- equals(other) {
156
- if (this.ids.length === 1) {
157
- return this.ids[0] === other.ids[0];
158
- }
159
- return this.toString() === other.toString();
160
- }
161
- toString() {
162
- if (this.ids.length === 1) {
163
- return String(this.ids[0]);
164
- }
165
- return this.ids.toString();
166
- }
167
- }
168
-
169
-
170
- },
171
- "./src/collections/MemoryDataCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
172
- __webpack_require__.r(__webpack_exports__);
173
- __webpack_require__.d(__webpack_exports__, {
174
- MemoryDataCollection: () => (MemoryDataCollection)
175
- });
176
- /* import */ var _schema__rspack_import_0 = __webpack_require__("./src/schema/types.ts");
177
- /* import */ var _results__rspack_import_3 = __webpack_require__("./src/results/Result.ts");
178
- /* import */ var _utilities__rspack_import_1 = __webpack_require__("./src/utilities/uuid.ts");
179
- /* import */ var _IdSet__rspack_import_2 = __webpack_require__("./src/collections/IdSet.ts");
180
-
181
-
182
-
183
-
184
- class MemoryDataCollection {
185
- nextNumericalIds;
186
- data;
187
- schema;
188
- idProperties;
189
- get size() {
190
- return this.data.size;
191
- }
192
- get records() {
193
- return [...this.data.values()];
194
- }
195
- constructor(schema) {
196
- this.data = new Map();
197
- this.nextNumericalIds = new Map();
198
- this.schema = schema;
199
- this.idProperties = schema.idProperties;
200
- }
201
- _getNextId(property) {
202
- let nextId = 1;
203
- if (this.nextNumericalIds.has(property.id) === true) {
204
- nextId = this.nextNumericalIds.get(property.id) + 1;
205
- }
206
- this.nextNumericalIds.set(property.id, nextId);
207
- return nextId;
208
- }
209
- resolveId(property, value) {
210
- if (typeof value !== "number") {
211
- return;
212
- }
213
- const currentIdForProperty = this.nextNumericalIds.get(property.id);
214
- if (value <= currentIdForProperty) {
215
- return;
216
- }
217
- this.nextNumericalIds.set(property.id, value);
218
- }
219
- getAndSetId(item, property) {
220
- if (item[property.name] != null) {
221
- return item[property.name];
222
- }
223
- if (property.type === _schema__rspack_import_0.SchemaTypes.String) {
224
- const uuid = (0,_utilities__rspack_import_1.uuidv4)();
225
- item[property.name] = uuid;
226
- return uuid;
227
- }
228
- if (property.type === _schema__rspack_import_0.SchemaTypes.Number) {
229
- const id = this._getNextId(property);
230
- item[property.name] = id;
231
- return id;
232
- }
233
- throw new Error(`Id Property '${property.name}' must be string or number, found '${property.type}'`);
234
- }
235
- seed(items) {
236
- for (let i = 0, length = items.length; i < length; i++) {
237
- const id = this.resolveIdSet(items[i]);
238
- this.data.set(id.toString(), items[i]);
239
- }
240
- }
241
- resolveCurrentIdSet(item) {
242
- const idProperties = this.schema.idProperties;
243
- const ids = [];
244
- // ensure keys
245
- for (let j = 0, l = idProperties.length; j < l; j++) {
246
- const property = idProperties[j];
247
- const value = property.getValue(item);
248
- if (value == null) {
249
- throw new Error(`Key cannot be null. Key: ${property.name}`);
250
- }
251
- ids.push(value);
252
- }
253
- return new _IdSet__rspack_import_2.IdSet(...ids);
254
- }
255
- resolveIdSet(item) {
256
- if (this.schema.hasIdentityKeys) {
257
- const idProperties = this.schema.idProperties;
258
- const ids = Array.from({ length: idProperties.length });
259
- // Need to make sure we allow for seeding the collection when we call add vs seed
260
- // There will be an existing id, but the id type could still be identity
261
- if (idProperties.length === 1) {
262
- const value = this.getAndSetId(item, idProperties[0]);
263
- this.resolveId(idProperties[0], value);
264
- ids[0] = value;
265
- }
266
- else {
267
- for (let j = 0, l = idProperties.length; j < l; j++) {
268
- const value = this.getAndSetId(item, idProperties[j]);
269
- this.resolveId(idProperties[j], value);
270
- ids[j] = value;
271
- }
272
- }
273
- return new _IdSet__rspack_import_2.IdSet(...ids);
274
- }
275
- return this.resolveCurrentIdSet(item);
276
- }
277
- add(item) {
278
- const id = this.resolveIdSet(item);
279
- this.data.set(id.toString(), item);
280
- }
281
- remove(item) {
282
- const id = this.resolveCurrentIdSet(item);
283
- this.data.delete(id.toString());
284
- }
285
- update(item) {
286
- const id = this.resolveCurrentIdSet(item);
287
- this.data.set(id.toString(), item);
288
- }
289
- destroy(done) {
290
- this.nextNumericalIds.clear();
291
- this.data.clear();
292
- done(_results__rspack_import_3.Result.success());
293
- }
294
- load(done) {
295
- done(_results__rspack_import_3.Result.success());
296
- }
297
- save(done) {
298
- done(_results__rspack_import_3.Result.success());
299
- }
300
- }
301
-
302
-
303
- },
304
- "./src/collections/ReadonlySchemaCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
305
- __webpack_require__.r(__webpack_exports__);
306
- __webpack_require__.d(__webpack_exports__, {
307
- ReadonlySchemaCollection: () => (ReadonlySchemaCollection)
145
+ g: () => (ReadonlySchemaCollection)
308
146
  });
309
147
  /**
310
148
  * Collection of schemas with generic typing for type-safe schema retrieval
311
- */
312
- class ReadonlySchemaCollection {
149
+ */ class ReadonlySchemaCollection {
313
150
  data;
314
- constructor(data) {
151
+ constructor(data){
315
152
  this.data = new Map(data);
316
153
  }
317
154
  get(schemaId) {
@@ -339,7 +176,9 @@ class ReadonlySchemaCollection {
339
176
  return this.data[Symbol.iterator]();
340
177
  }
341
178
  getByName(collectionName) {
342
- const found = [...this.data].find(x => x[1].collectionName === collectionName);
179
+ const found = [
180
+ ...this.data
181
+ ].find((x)=>x[1].collectionName === collectionName);
343
182
  if (found != null) {
344
183
  return found[1];
345
184
  }
@@ -349,17 +188,15 @@ class ReadonlySchemaCollection {
349
188
 
350
189
 
351
190
  },
352
- "./src/collections/SchemaCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
353
- __webpack_require__.r(__webpack_exports__);
191
+ 393(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
354
192
  __webpack_require__.d(__webpack_exports__, {
355
- SchemaCollection: () => (SchemaCollection)
193
+ w: () => (SchemaCollection)
356
194
  });
357
- /* import */ var _ReadonlySchemaCollection__rspack_import_0 = __webpack_require__("./src/collections/ReadonlySchemaCollection.ts");
195
+ /* import */ var _ReadonlySchemaCollection__rspack_import_0 = __webpack_require__(995);
358
196
 
359
197
  /**
360
198
  * Collection of schemas with generic typing for type-safe schema retrieval
361
- */
362
- class SchemaCollection extends _ReadonlySchemaCollection__rspack_import_0.ReadonlySchemaCollection {
199
+ */ class SchemaCollection extends _ReadonlySchemaCollection__rspack_import_0/* .ReadonlySchemaCollection */.g {
363
200
  set(schemaId, schema) {
364
201
  this.data.set(schemaId, schema);
365
202
  return this;
@@ -374,16 +211,17 @@ class SchemaCollection extends _ReadonlySchemaCollection__rspack_import_0.Readon
374
211
 
375
212
 
376
213
  },
377
- "./src/collections/TagCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
378
- __webpack_require__.r(__webpack_exports__);
214
+ 356(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
379
215
  __webpack_require__.d(__webpack_exports__, {
380
- TagCollection: () => (TagCollection)
216
+ r: () => (TagCollection)
381
217
  });
382
218
  class TagCollection {
383
219
  data = new Map();
384
- _size = 0;
220
+ // Delegated to the map rather than tracked in a counter field: every mutation path
221
+ // (set, setMany, combine, delete, dispose) would otherwise have to maintain it, and
222
+ // a missed path silently reports a size that disagrees with the contents.
385
223
  get size() {
386
- return this._size;
224
+ return this.data.size;
387
225
  }
388
226
  get(key) {
389
227
  return this.data.get(key);
@@ -392,26 +230,20 @@ class TagCollection {
392
230
  return this.data.has(key);
393
231
  }
394
232
  set(key, tag) {
395
- this._size++;
396
233
  return this.data.set(key, tag);
397
234
  }
398
235
  delete(key) {
399
- const result = this.data.delete(key);
400
- if (result) {
401
- this._size--;
402
- }
403
- return result;
236
+ return this.data.delete(key);
404
237
  }
405
238
  setMany(keys, tag) {
406
- this._size += keys.length;
407
- for (let i = 0, length = keys.length; i < length; i++) {
239
+ for(let i = 0, length = keys.length; i < length; i++){
408
240
  const key = keys[i];
409
241
  this.set(key, tag);
410
242
  }
411
243
  }
412
244
  combine(tags) {
413
- for (const [key, value] of tags) {
414
- this.data.set(key, value);
245
+ for (const [key, value] of tags){
246
+ this.set(key, value);
415
247
  }
416
248
  }
417
249
  values() {
@@ -430,11 +262,9 @@ class TagCollection {
430
262
 
431
263
 
432
264
  },
433
- "./src/results/Result.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
434
- __webpack_require__.r(__webpack_exports__);
265
+ 718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
435
266
  __webpack_require__.d(__webpack_exports__, {
436
- PluginEventResult: () => (PluginEventResult),
437
- Result: () => (Result)
267
+ Q: () => (Result)
438
268
  });
439
269
  class BaseResult {
440
270
  static ERROR = "error";
@@ -481,7 +311,7 @@ class Result extends BaseResult {
481
311
  };
482
312
  }
483
313
  }
484
- class PluginEventResult extends BaseResult {
314
+ class PluginEventResult extends (/* unused pure expression or super */ null && (BaseResult)) {
485
315
  static success(id, data) {
486
316
  return {
487
317
  id,
@@ -513,14 +343,11 @@ class PluginEventResult extends BaseResult {
513
343
 
514
344
 
515
345
  },
516
- "./src/schema/types.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
517
- __webpack_require__.r(__webpack_exports__);
346
+ 537(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
518
347
  __webpack_require__.d(__webpack_exports__, {
519
- HashType: () => (HashType),
520
- SchemaTypes: () => (SchemaTypes)
348
+ L: () => (SchemaTypes)
521
349
  });
522
- var SchemaTypes;
523
- (function (SchemaTypes) {
350
+ var SchemaTypes = /*#__PURE__*/ function(SchemaTypes) {
524
351
  SchemaTypes["Array"] = "Array";
525
352
  SchemaTypes["Boolean"] = "Boolean";
526
353
  SchemaTypes["Date"] = "Date";
@@ -530,26 +357,36 @@ var SchemaTypes;
530
357
  SchemaTypes["Definition"] = "Definition";
531
358
  SchemaTypes["Function"] = "Function";
532
359
  SchemaTypes["Computed"] = "Computed";
533
- })(SchemaTypes || (SchemaTypes = {}));
534
- var HashType;
535
- (function (HashType) {
360
+ /**
361
+ * Content in, reference out. The only type whose write shape differs from its stored
362
+ * shape, and a leaf on purpose — see `SchemaFile`.
363
+ */ SchemaTypes["File"] = "File";
364
+ /**
365
+ * A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.
366
+ *
367
+ * Value-shaped exactly like `s.array(s.number())`, which is why every array codegen
368
+ * handler accepts it. It is a distinct type only so a backend can recognise it and store
369
+ * it natively; nothing else needs to tell the two apart.
370
+ */ SchemaTypes["Vector"] = "Vector";
371
+ return SchemaTypes;
372
+ }({});
373
+ var HashType = /*#__PURE__*/ (/* unused pure expression or super */ null && (function(HashType) {
536
374
  HashType["Ids"] = "Ids";
537
375
  HashType["Object"] = "Object";
538
- })(HashType || (HashType = {}));
376
+ return HashType;
377
+ }({})));
539
378
 
540
379
 
541
380
  },
542
- "./src/utilities/uuid.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
543
- __webpack_require__.r(__webpack_exports__);
381
+ 618(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
544
382
  __webpack_require__.d(__webpack_exports__, {
545
- uuid: () => (uuid),
546
- uuidv4: () => (uuidv4)
383
+ g: () => (uuidv4)
547
384
  });
548
- const uuid = (length = 16) => {
385
+ const uuid = (length = 16)=>{
549
386
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
550
387
  const charLength = chars.length;
551
388
  let result = '';
552
- for (let i = 0; i < length; i++) {
389
+ for(let i = 0; i < length; i++){
553
390
  result += chars[Math.random() * charLength | 0];
554
391
  }
555
392
  return result;
@@ -557,14 +394,21 @@ const uuid = (length = 16) => {
557
394
  const HEX_CHARS = '0123456789abcdef';
558
395
  const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
559
396
  const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
560
- const uuidv4 = () => {
397
+ const hasRandomUUID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
398
+ const uuidv4 = ()=>{
399
+ if (hasRandomUUID) {
400
+ return crypto.randomUUID();
401
+ }
402
+ return uuidv4Fallback();
403
+ };
404
+ const uuidv4Fallback = ()=>{
561
405
  let randomBytes = null;
562
406
  if (hasCrypto) {
563
407
  randomBytes = crypto.getRandomValues(new Uint8Array(16));
564
408
  }
565
409
  let byteIndex = 0;
566
410
  let uuid = '';
567
- for (let i = 0; i < UUID_TEMPLATE.length; i++) {
411
+ for(let i = 0; i < UUID_TEMPLATE.length; i++){
568
412
  const c = UUID_TEMPLATE[i];
569
413
  if (c === '-') {
570
414
  uuid += '-';
@@ -573,22 +417,16 @@ const uuidv4 = () => {
573
417
  let r;
574
418
  if (hasCrypto && randomBytes) {
575
419
  // Each byte gives two hex digits (nibbles)
576
- r =
577
- (i % 2 === 0
578
- ? randomBytes[byteIndex] >> 4
579
- : randomBytes[byteIndex++] & 0x0f);
580
- }
581
- else {
420
+ r = i % 2 === 0 ? randomBytes[byteIndex] >> 4 : randomBytes[byteIndex++] & 0x0f;
421
+ } else {
582
422
  r = Math.floor(Math.random() * 16);
583
423
  }
584
424
  if (c === 'x') {
585
425
  uuid += HEX_CHARS[r];
586
- }
587
- else if (c === 'y') {
426
+ } else if (c === 'y') {
588
427
  // Variant bits: 8, 9, A, or B
589
- uuid += HEX_CHARS[(r & 0x3) | 0x8];
590
- }
591
- else if (c === '4') {
428
+ uuid += HEX_CHARS[r & 0x3 | 0x8];
429
+ } else if (c === '4') {
592
430
  uuid += '4';
593
431
  }
594
432
  }
@@ -636,37 +474,205 @@ __webpack_require__.d = (exports, definition) => {
636
474
  (() => {
637
475
  __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
638
476
  })();
639
- // webpack/runtime/make_namespace_object
640
- (() => {
641
- // define __esModule on exports
642
- __webpack_require__.r = (exports) => {
643
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
644
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
645
- }
646
- Object.defineProperty(exports, '__esModule', { value: true });
647
- };
648
- })();
649
477
  var __webpack_exports__ = {};
650
478
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
651
479
  (() => {
652
- __webpack_require__.r(__webpack_exports__);
480
+
481
+ // EXPORTS
653
482
  __webpack_require__.d(__webpack_exports__, {
654
- BulkPersistChanges: () => (/* reexport safe */ _Changes__rspack_import_0.BulkPersistChanges),
655
- BulkPersistResult: () => (/* reexport safe */ _Changes__rspack_import_0.BulkPersistResult),
656
- IdSet: () => (/* reexport safe */ _IdSet__rspack_import_2.IdSet),
657
- MemoryDataCollection: () => (/* reexport safe */ _MemoryDataCollection__rspack_import_3.MemoryDataCollection),
658
- ReadonlySchemaCollection: () => (/* reexport safe */ _ReadonlySchemaCollection__rspack_import_5.ReadonlySchemaCollection),
659
- SchemaCollection: () => (/* reexport safe */ _SchemaCollection__rspack_import_4.SchemaCollection),
660
- SchemaPersistChanges: () => (/* reexport safe */ _Changes__rspack_import_0.SchemaPersistChanges),
661
- SchemaPersistResult: () => (/* reexport safe */ _Changes__rspack_import_0.SchemaPersistResult),
662
- TagCollection: () => (/* reexport safe */ _TagCollection__rspack_import_1.TagCollection)
483
+ _v: () => (/* reexport */ MemoryDataCollection),
484
+ r4: () => (/* reexport */ TagCollection/* .TagCollection */.r),
485
+ qk: () => (/* reexport */ Changes/* .BulkPersistChanges */.qk),
486
+ R7: () => (/* reexport */ Changes/* .SchemaPersistResult */.R7),
487
+ om: () => (/* reexport */ Changes/* .BulkPersistResult */.om),
488
+ wp: () => (/* reexport */ IdSet),
489
+ $E: () => (/* reexport */ Changes/* .SchemaPersistChanges */.$E),
490
+ g5: () => (/* reexport */ ReadonlySchemaCollection/* .ReadonlySchemaCollection */.g),
491
+ wM: () => (/* reexport */ SchemaCollection/* .SchemaCollection */.w)
663
492
  });
664
- /* import */ var _Changes__rspack_import_0 = __webpack_require__("./src/collections/Changes.ts");
665
- /* import */ var _TagCollection__rspack_import_1 = __webpack_require__("./src/collections/TagCollection.ts");
666
- /* import */ var _IdSet__rspack_import_2 = __webpack_require__("./src/collections/IdSet.ts");
667
- /* import */ var _MemoryDataCollection__rspack_import_3 = __webpack_require__("./src/collections/MemoryDataCollection.ts");
668
- /* import */ var _SchemaCollection__rspack_import_4 = __webpack_require__("./src/collections/SchemaCollection.ts");
669
- /* import */ var _ReadonlySchemaCollection__rspack_import_5 = __webpack_require__("./src/collections/ReadonlySchemaCollection.ts");
493
+
494
+ // EXTERNAL MODULE: ./src/collections/Changes.ts
495
+ var Changes = __webpack_require__(533);
496
+ // EXTERNAL MODULE: ./src/collections/TagCollection.ts
497
+ var TagCollection = __webpack_require__(356);
498
+ ;// CONCATENATED MODULE: ./src/collections/IdSet.ts
499
+ class IdSet {
500
+ ids;
501
+ constructor(...ids){
502
+ this.ids = Object.freeze(ids);
503
+ }
504
+ equals(other) {
505
+ if (this.ids.length === 1) {
506
+ return this.ids[0] === other.ids[0];
507
+ }
508
+ return this.toString() === other.toString();
509
+ }
510
+ toString() {
511
+ if (this.ids.length === 1) {
512
+ return String(this.ids[0]);
513
+ }
514
+ return this.ids.toString();
515
+ }
516
+ }
517
+
518
+ // EXTERNAL MODULE: ./src/schema/types.ts
519
+ var types = __webpack_require__(537);
520
+ // EXTERNAL MODULE: ./src/results/Result.ts
521
+ var Result = __webpack_require__(718);
522
+ // EXTERNAL MODULE: ./src/utilities/uuid.ts
523
+ var utilities_uuid = __webpack_require__(618);
524
+ ;// CONCATENATED MODULE: ./src/collections/MemoryDataCollection.ts
525
+
526
+
527
+
528
+
529
+ class MemoryDataCollection {
530
+ nextNumericalIds;
531
+ data;
532
+ schema;
533
+ idProperties;
534
+ get size() {
535
+ return this.data.size;
536
+ }
537
+ get records() {
538
+ return [
539
+ ...this.data.values()
540
+ ];
541
+ }
542
+ /** Iterates stored records without materializing them into an array. */ values() {
543
+ return this.data.values();
544
+ }
545
+ constructor(schema){
546
+ this.data = new Map();
547
+ this.nextNumericalIds = new Map();
548
+ this.schema = schema;
549
+ this.idProperties = schema.idProperties;
550
+ }
551
+ _getNextId(property) {
552
+ let nextId = 1;
553
+ if (this.nextNumericalIds.has(property.id) === true) {
554
+ nextId = this.nextNumericalIds.get(property.id) + 1;
555
+ }
556
+ this.nextNumericalIds.set(property.id, nextId);
557
+ return nextId;
558
+ }
559
+ resolveId(property, value) {
560
+ if (typeof value !== "number") {
561
+ return;
562
+ }
563
+ const currentIdForProperty = this.nextNumericalIds.get(property.id);
564
+ if (value <= currentIdForProperty) {
565
+ return;
566
+ }
567
+ this.nextNumericalIds.set(property.id, value);
568
+ }
569
+ getAndSetId(item, property) {
570
+ if (item[property.name] != null) {
571
+ return item[property.name];
572
+ }
573
+ if (property.type === types/* .SchemaTypes.String */.L.String) {
574
+ const uuid = (0,utilities_uuid/* .uuidv4 */.g)();
575
+ item[property.name] = uuid;
576
+ return uuid;
577
+ }
578
+ if (property.type === types/* .SchemaTypes.Number */.L.Number) {
579
+ const id = this._getNextId(property);
580
+ item[property.name] = id;
581
+ return id;
582
+ }
583
+ throw new Error(`Id Property '${property.name}' must be string or number, found '${property.type}'`);
584
+ }
585
+ seed(items) {
586
+ for(let i = 0, length = items.length; i < length; i++){
587
+ const id = this.resolveIdSet(items[i]);
588
+ this.data.set(id.toString(), items[i]);
589
+ }
590
+ }
591
+ resolveCurrentIdSet(item) {
592
+ const idProperties = this.schema.idProperties;
593
+ const ids = [];
594
+ // ensure keys
595
+ for(let j = 0, l = idProperties.length; j < l; j++){
596
+ const property = idProperties[j];
597
+ const value = property.getValue(item);
598
+ if (value == null) {
599
+ throw new Error(`Key cannot be null. Key: ${property.name}`);
600
+ }
601
+ ids.push(value);
602
+ }
603
+ return new IdSet(...ids);
604
+ }
605
+ resolveIdSet(item) {
606
+ if (this.schema.hasIdentityKeys) {
607
+ const idProperties = this.schema.idProperties;
608
+ const ids = Array.from({
609
+ length: idProperties.length
610
+ });
611
+ // Need to make sure we allow for seeding the collection when we call add vs seed
612
+ // There will be an existing id, but the id type could still be identity
613
+ if (idProperties.length === 1) {
614
+ const value = this.getAndSetId(item, idProperties[0]);
615
+ this.resolveId(idProperties[0], value);
616
+ ids[0] = value;
617
+ } else {
618
+ for(let j = 0, l = idProperties.length; j < l; j++){
619
+ const value = this.getAndSetId(item, idProperties[j]);
620
+ this.resolveId(idProperties[j], value);
621
+ ids[j] = value;
622
+ }
623
+ }
624
+ return new IdSet(...ids);
625
+ }
626
+ return this.resolveCurrentIdSet(item);
627
+ }
628
+ add(item) {
629
+ const id = this.resolveIdSet(item);
630
+ this.data.set(id.toString(), item);
631
+ }
632
+ /**
633
+ * Adds a record only when no record with the same key is present. Durable
634
+ * collections use this to hydrate stored records around in-memory mutations
635
+ * without clobbering them.
636
+ */ addIfAbsent(item) {
637
+ const id = this.resolveIdSet(item);
638
+ const key = id.toString();
639
+ if (this.data.has(key) === false) {
640
+ this.data.set(key, item);
641
+ }
642
+ }
643
+ /**
644
+ * Looks up a single record by its key values without scanning the collection.
645
+ * @param ids Key values in schema id property order
646
+ * @returns The matching record or undefined when no record has the given key
647
+ */ getByIds(ids) {
648
+ return this.data.get(new IdSet(...ids).toString());
649
+ }
650
+ remove(item) {
651
+ const id = this.resolveCurrentIdSet(item);
652
+ this.data.delete(id.toString());
653
+ }
654
+ update(item) {
655
+ const id = this.resolveCurrentIdSet(item);
656
+ this.data.set(id.toString(), item);
657
+ }
658
+ destroy(done) {
659
+ this.nextNumericalIds.clear();
660
+ this.data.clear();
661
+ done(Result/* .Result.success */.Q.success());
662
+ }
663
+ load(done) {
664
+ done(Result/* .Result.success */.Q.success());
665
+ }
666
+ save(done) {
667
+ done(Result/* .Result.success */.Q.success());
668
+ }
669
+ }
670
+
671
+ // EXTERNAL MODULE: ./src/collections/SchemaCollection.ts
672
+ var SchemaCollection = __webpack_require__(393);
673
+ // EXTERNAL MODULE: ./src/collections/ReadonlySchemaCollection.ts
674
+ var ReadonlySchemaCollection = __webpack_require__(995);
675
+ ;// CONCATENATED MODULE: ./src/collections/index.ts
670
676
 
671
677
 
672
678
 
@@ -676,15 +682,15 @@ __webpack_require__.d(__webpack_exports__, {
676
682
 
677
683
  })();
678
684
 
679
- var __webpack_exports__BulkPersistChanges = __webpack_exports__.BulkPersistChanges;
680
- var __webpack_exports__BulkPersistResult = __webpack_exports__.BulkPersistResult;
681
- var __webpack_exports__IdSet = __webpack_exports__.IdSet;
682
- var __webpack_exports__MemoryDataCollection = __webpack_exports__.MemoryDataCollection;
683
- var __webpack_exports__ReadonlySchemaCollection = __webpack_exports__.ReadonlySchemaCollection;
684
- var __webpack_exports__SchemaCollection = __webpack_exports__.SchemaCollection;
685
- var __webpack_exports__SchemaPersistChanges = __webpack_exports__.SchemaPersistChanges;
686
- var __webpack_exports__SchemaPersistResult = __webpack_exports__.SchemaPersistResult;
687
- var __webpack_exports__TagCollection = __webpack_exports__.TagCollection;
685
+ var __webpack_exports__BulkPersistChanges = __webpack_exports__.qk;
686
+ var __webpack_exports__BulkPersistResult = __webpack_exports__.om;
687
+ var __webpack_exports__IdSet = __webpack_exports__.wp;
688
+ var __webpack_exports__MemoryDataCollection = __webpack_exports__._v;
689
+ var __webpack_exports__ReadonlySchemaCollection = __webpack_exports__.g5;
690
+ var __webpack_exports__SchemaCollection = __webpack_exports__.wM;
691
+ var __webpack_exports__SchemaPersistChanges = __webpack_exports__.$E;
692
+ var __webpack_exports__SchemaPersistResult = __webpack_exports__.R7;
693
+ var __webpack_exports__TagCollection = __webpack_exports__.r4;
688
694
  export { __webpack_exports__BulkPersistChanges as BulkPersistChanges, __webpack_exports__BulkPersistResult as BulkPersistResult, __webpack_exports__IdSet as IdSet, __webpack_exports__MemoryDataCollection as MemoryDataCollection, __webpack_exports__ReadonlySchemaCollection as ReadonlySchemaCollection, __webpack_exports__SchemaCollection as SchemaCollection, __webpack_exports__SchemaPersistChanges as SchemaPersistChanges, __webpack_exports__SchemaPersistResult as SchemaPersistResult, __webpack_exports__TagCollection as TagCollection };
689
695
 
690
696
  //# sourceMappingURL=index.js.map