@routier/core 0.2.1 → 0.3.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 (159) hide show
  1. package/LICENSE +21 -0
  2. package/{readme.md → README.md} +1 -1
  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 +13925 -0
  57. package/dist/index.cjs.map +1 -0
  58. package/dist/index.js +11936 -7950
  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 +6104 -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 +5821 -1172
  77. package/dist/plugins/index.js.map +1 -1
  78. package/dist/plugins/query/QueryOptionsCollection.d.ts +21 -0
  79. package/dist/plugins/query/index.d.ts +2 -0
  80. package/dist/plugins/query/join.d.ts +210 -0
  81. package/dist/plugins/query/similarity.d.ts +38 -0
  82. package/dist/plugins/query/types.d.ts +64 -1
  83. package/dist/plugins/translators/DataTranslator.d.ts +28 -0
  84. package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
  85. package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
  86. package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
  87. package/dist/plugins/translators/index.d.ts +1 -0
  88. package/dist/plugins/types.d.ts +82 -2
  89. package/dist/plugins/wire/handler.d.ts +122 -0
  90. package/dist/plugins/wire/index.d.ts +4 -0
  91. package/dist/plugins/wire/persist.d.ts +43 -0
  92. package/dist/plugins/wire/query.d.ts +49 -0
  93. package/dist/plugins/wire/types.d.ts +123 -0
  94. package/dist/results/index.cjs +174 -0
  95. package/dist/results/index.cjs.map +1 -0
  96. package/dist/results/index.js +29 -44
  97. package/dist/results/index.js.map +1 -1
  98. package/dist/schema/PropertyInfo.d.ts +31 -2
  99. package/dist/schema/SchemaDefinition.d.ts +23 -1
  100. package/dist/schema/builder.d.ts +35 -1
  101. package/dist/schema/communication/broadcast.d.ts +17 -1
  102. package/dist/schema/index.cjs +6911 -0
  103. package/dist/schema/index.cjs.map +1 -0
  104. package/dist/schema/index.d.ts +2 -0
  105. package/dist/schema/index.js +5330 -4541
  106. package/dist/schema/index.js.map +1 -1
  107. package/dist/schema/property/base/SchemaBase.d.ts +48 -2
  108. package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
  109. package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
  110. package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
  111. package/dist/schema/property/modifiers/index.d.ts +1 -0
  112. package/dist/schema/property/types/SchemaFile.d.ts +60 -0
  113. package/dist/schema/property/types/SchemaString.d.ts +21 -1
  114. package/dist/schema/property/types/SchemaVector.d.ts +61 -0
  115. package/dist/schema/property/types/index.d.ts +2 -0
  116. package/dist/schema/table/SchemaTransform.d.ts +40 -0
  117. package/dist/schema/table/index.d.ts +1 -0
  118. package/dist/schema/types.d.ts +166 -8
  119. package/dist/schema/utils/propertyKind.d.ts +4 -0
  120. package/dist/types/index.cjs +23 -0
  121. package/dist/types/index.cjs.map +1 -0
  122. package/dist/types/index.js +0 -14
  123. package/dist/types/index.js.map +1 -1
  124. package/dist/utilities/index.cjs +982 -0
  125. package/dist/utilities/index.cjs.map +1 -0
  126. package/dist/utilities/index.js +506 -375
  127. package/dist/utilities/index.js.map +1 -1
  128. package/dist/utilities/logger.d.ts +48 -0
  129. package/package.json +152 -98
  130. package/dist/codegen/SlotPath.test.d.ts +0 -1
  131. package/dist/codegen/blocks.test.d.ts +0 -1
  132. package/dist/codegen/utils.test.d.ts +0 -1
  133. package/dist/collections/Changes.test.d.ts +0 -1
  134. package/dist/collections/IdSet.test.d.ts +0 -1
  135. package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
  136. package/dist/collections/TagCollection.contract.test.d.ts +0 -1
  137. package/dist/collections/TagCollection.test.d.ts +0 -1
  138. package/dist/expressions/parser.test.d.ts +0 -1
  139. package/dist/expressions/sql.d.ts +0 -28
  140. package/dist/expressions/sql.test.d.ts +0 -1
  141. package/dist/expressions/utils.test.d.ts +0 -1
  142. package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
  143. package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
  144. package/dist/plugins/query/Query.test.d.ts +0 -1
  145. package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
  146. package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
  147. package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
  148. package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
  149. package/dist/results/Result.test.d.ts +0 -1
  150. package/dist/results/utils.test.d.ts +0 -1
  151. package/dist/schema/PropertyInfo.test.d.ts +0 -1
  152. package/dist/schema/communication/broadcast.test.d.ts +0 -1
  153. package/dist/schema/schemaGeneration.test.d.ts +0 -1
  154. package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
  155. package/dist/utilities/arrays.test.d.ts +0 -1
  156. package/dist/utilities/dates.test.d.ts +0 -1
  157. package/dist/utilities/runtime.test.d.ts +0 -1
  158. package/dist/utilities/strings.test.d.ts +0 -1
  159. package/dist/utilities/uuid.test.d.ts +0 -1
@@ -1,27 +1,12 @@
1
1
  var __webpack_modules__ = ({
2
- "./src/assertions/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
- __webpack_require__.r(__webpack_exports__);
2
+ 126(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
3
  __webpack_require__.d(__webpack_exports__, {
5
- assertDate: () => (assertDate),
6
- assertInstanceOf: () => (assertInstanceOf),
7
- assertIsArray: () => (assertIsArray),
8
- assertIsNotNull: () => (assertIsNotNull),
9
- assertIsNumber: () => (assertIsNumber),
10
- assertString: () => (assertString),
11
- isComparatorExpression: () => (isComparatorExpression),
12
- isEmptyExpression: () => (isEmptyExpression),
13
- isExpression: () => (isExpression),
14
- isNotParsableExpression: () => (isNotParsableExpression),
15
- isOperatorExpression: () => (isOperatorExpression),
16
- isPropertyExpression: () => (isPropertyExpression),
17
- isValueExpression: () => (isValueExpression)
4
+ e3: () => (isPropertyExpression)
18
5
  });
19
- /* import */ var _expressions_constants__rspack_import_1 = __webpack_require__("./src/expressions/constants.ts");
20
- /* import */ var _utilities__rspack_import_0 = __webpack_require__("./src/utilities/dates.ts");
21
6
 
22
7
 
23
8
  function assertDate(data) {
24
- if ((0,_utilities__rspack_import_0.isDate)(data) === false) {
9
+ if (isDate(data) === false) {
25
10
  throw new TypeError('Value is not a Date');
26
11
  }
27
12
  }
@@ -65,77 +50,51 @@ function isObjectWithType(value) {
65
50
  }
66
51
  /**
67
52
  * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.
68
- */
69
- function isExpression(value) {
70
- return isObjectWithType(value) && _expressions_constants__rspack_import_1.EXPRESSION_TYPES.includes(value.type);
53
+ */ function isExpression(value) {
54
+ return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type);
71
55
  }
72
56
  /**
73
57
  * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === "operator"`.
74
- */
75
- function isOperatorExpression(value) {
58
+ */ function isOperatorExpression(value) {
76
59
  return isObjectWithType(value) && value.type === "operator";
77
60
  }
78
61
  /**
79
62
  * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === "comparator"`.
80
- */
81
- function isComparatorExpression(value) {
63
+ */ function isComparatorExpression(value) {
82
64
  return isObjectWithType(value) && value.type === "comparator";
83
65
  }
84
66
  /**
85
67
  * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === "property"`.
86
- */
87
- function isPropertyExpression(value) {
68
+ */ function isPropertyExpression(value) {
88
69
  return isObjectWithType(value) && value.type === "property";
89
70
  }
90
71
  /**
91
72
  * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === "value"`.
92
- */
93
- function isValueExpression(value) {
73
+ */ function isValueExpression(value) {
94
74
  return isObjectWithType(value) && value.type === "value";
95
75
  }
96
76
  /**
97
77
  * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === "empty"`.
98
- */
99
- function isEmptyExpression(value) {
78
+ */ function isEmptyExpression(value) {
100
79
  return isObjectWithType(value) && value.type === "empty";
101
80
  }
102
81
  /**
103
82
  * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === "not-parsable"`.
104
- */
105
- function isNotParsableExpression(value) {
83
+ */ function isNotParsableExpression(value) {
106
84
  return isObjectWithType(value) && value.type === "not-parsable";
107
85
  }
108
86
 
109
87
 
110
88
  },
111
- "./src/expressions/constants.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
112
- __webpack_require__.r(__webpack_exports__);
89
+ 63(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
113
90
  __webpack_require__.d(__webpack_exports__, {
114
- EXPRESSION_TYPES: () => (EXPRESSION_TYPES)
115
- });
116
- const EXPRESSION_TYPES = [
117
- "operator",
118
- "comparator",
119
- "property",
120
- "value",
121
- "empty",
122
- "not-parsable",
123
- ];
124
-
125
-
126
- },
127
- "./src/expressions/utils.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
128
- __webpack_require__.r(__webpack_exports__);
129
- __webpack_require__.d(__webpack_exports__, {
130
- forEach: () => (forEach),
131
- getProperties: () => (getProperties)
91
+ j: () => (forEach)
132
92
  });
133
93
  /**
134
94
  * Extracts all properties referenced in an expression
135
95
  * @param expression The expression to analyze
136
96
  * @returns Array of PropertyInfo objects referenced in the expression
137
- */
138
- function getProperties(expression) {
97
+ */ function getProperties(expression) {
139
98
  const properties = [];
140
99
  function traverse(expr) {
141
100
  // If this is a property expression, add it to our collection
@@ -178,13 +137,12 @@ function forEach(expression, callback) {
178
137
 
179
138
 
180
139
  },
181
- "./src/plugins/query/QueryOptionsCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
182
- __webpack_require__.r(__webpack_exports__);
140
+ 198(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
183
141
  __webpack_require__.d(__webpack_exports__, {
184
- QueryOptionsCollection: () => (QueryOptionsCollection)
142
+ H: () => (QueryOptionsCollection)
185
143
  });
186
- /* import */ var _assertions__rspack_import_1 = __webpack_require__("./src/assertions/index.ts");
187
- /* import */ var _expressions_utils__rspack_import_0 = __webpack_require__("./src/expressions/utils.ts");
144
+ /* import */ var _assertions__rspack_import_1 = __webpack_require__(126);
145
+ /* import */ var _expressions_utils__rspack_import_0 = __webpack_require__(63);
188
146
 
189
147
 
190
148
  class QueryOptionsCollection {
@@ -209,30 +167,74 @@ class QueryOptionsCollection {
209
167
  const mapValue = value;
210
168
  // Evaluate the map value to see if we are renaming properties,
211
169
  // if we are we need to perform everything after in memory
212
- if (mapValue.fields.some(x => x.isRename === true) || mapValue.fields.some(x => x.property?.isUnmapped === true)) {
170
+ if (mapValue.fields.some((x)=>x.isRename === true) || mapValue.fields.some((x)=>x.property?.isUnmapped === true)) {
213
171
  // Cut over to memory execution since we are renaming a property with .map
214
172
  // We do not want to figure out how the new name flows through the entire query
215
173
  this.nextExecutionTarget = "memory";
216
174
  }
217
175
  }
218
176
  if (name === "filter") {
219
- // Need to check for unmapped properties
177
+ // Need to check for unmapped and renamed properties
220
178
  const filterValue = value;
179
+ // A tautology (`x => true`) filters nothing — skip it entirely so
180
+ // plugins never see it
181
+ if (filterValue.expression.type === "empty") {
182
+ return;
183
+ }
221
184
  if (filterValue.expression.type === "not-parsable") {
222
185
  this.nextExecutionTarget = "memory";
223
- }
224
- else {
225
- (0,_expressions_utils__rspack_import_0.forEach)(filterValue.expression, (expression) => {
226
- if ((0,_assertions__rspack_import_1.isPropertyExpression)(expression) && expression.property.isUnmapped) {
186
+ } else {
187
+ (0,_expressions_utils__rspack_import_0/* .forEach */.j)(filterValue.expression, (expression)=>{
188
+ if ((0,_assertions__rspack_import_1/* .isPropertyExpression */.e3)(expression) && expression.property.isUnmapped) {
227
189
  // Cut over to memory execution, unmapped properties are not in the database and
228
190
  // cannot be queried
229
191
  this.nextExecutionTarget = "memory";
230
192
  return false;
231
193
  }
194
+ if ((0,_assertions__rspack_import_1/* .isPropertyExpression */.e3)(expression) && expression.property.hasRenamedSegments) {
195
+ // Cut over to memory execution: the plugin stores data under the
196
+ // `from` (storage) names, but filter selectors reference the
197
+ // in-memory names. Memory execution runs after deserialization,
198
+ // where the in-memory names exist
199
+ this.nextExecutionTarget = "memory";
200
+ return false;
201
+ }
232
202
  return true;
233
203
  });
234
204
  }
235
205
  }
206
+ if (name === "sort") {
207
+ const sortValue = value;
208
+ // Same rule as filters: sort selectors reference in-memory names, which
209
+ // only exist after deserialization when the property is renamed or unmapped
210
+ if (sortValue.property != null && (sortValue.property.isUnmapped || sortValue.property.hasRenamedSegments)) {
211
+ this.nextExecutionTarget = "memory";
212
+ }
213
+ }
214
+ if (name === "nearest") {
215
+ const nearestValue = value;
216
+ // Same rule as sort, and for the same reason: the plugin stores the vector under
217
+ // the `from` name, and an unmapped property is not stored at all. Both are only
218
+ // readable after deserialization, which is where memory execution runs.
219
+ //
220
+ // This is also what lets every translator's in-memory fallback read the column by
221
+ // its resolved name — anything whose storage name differs never reaches them.
222
+ if (nearestValue.property != null && (nearestValue.property.isUnmapped || nearestValue.property.hasRenamedSegments)) {
223
+ this.nextExecutionTarget = "memory";
224
+ }
225
+ }
226
+ if (name === "join") {
227
+ const joinValue = value;
228
+ // A join whose two sides live on different plugins cannot be sent to EITHER of
229
+ // them — neither can read the other's rows — so the option itself belongs to the
230
+ // memory half, where the datastore interprets it.
231
+ //
232
+ // Set BEFORE the item is created, unlike `nearest`'s ratchet below, because this
233
+ // moves the join option itself rather than everything after it.
234
+ if (joinValue.crossPlugin === true) {
235
+ this.nextExecutionTarget = "memory";
236
+ }
237
+ }
236
238
  const item = {
237
239
  index: this.nextIndex,
238
240
  option: {
@@ -243,14 +245,96 @@ class QueryOptionsCollection {
243
245
  };
244
246
  this.nextIndex++;
245
247
  const found = this.options.get(name);
246
- this.options.set(name, [...found ?? [], item]);
248
+ this.options.set(name, [
249
+ ...found ?? [],
250
+ item
251
+ ]);
252
+ if (name === "nearest") {
253
+ // Everything AFTER a similarity search runs in memory, whatever the backend.
254
+ //
255
+ // Whether the search was pushed down is a fact about the plugin, which this
256
+ // collection cannot see — so a later option is only safe if it runs after the
257
+ // scoring definitely happened, and in memory is the only place that is true of.
258
+ //
259
+ // The failure this prevents is silent. `.nearest(x => x.embedding, v, 10).take(3)`
260
+ // sends `LIMIT 3` to a backend that ignored the ordering, so three arbitrary rows
261
+ // come back and get scored — three real rows, in a plausible order, and not the
262
+ // three nearest. Nothing errors.
263
+ //
264
+ // A plugin that DID push the search down loses nothing but the chance to also
265
+ // push down what follows it, which is a limit over ten rows.
266
+ this.nextExecutionTarget = "memory";
267
+ }
268
+ if (name === "join") {
269
+ // Everything AFTER a join runs in memory, for the same reason as `nearest`: this
270
+ // collection cannot see HOW the plugin executed the join, and the rows it produced
271
+ // are TUPLES rather than entities of the root schema.
272
+ //
273
+ // A `take` sent to a backend that hash-joined in its translator would limit the
274
+ // OUTER rows read, not the pairs produced — a plausible-looking result with the
275
+ // wrong number of rows in it. Conjuncts that can safely run earlier are split off
276
+ // by the query builder BEFORE dispatch, which is the only exception.
277
+ this.nextExecutionTarget = "memory";
278
+ }
279
+ }
280
+ /**
281
+ * Splits the collection around the FIRST occurrence of `name`, preserving order.
282
+ *
283
+ * For a join: the options recorded before it operate on entity rows, the option itself
284
+ * produces tuples, and the ones after it operate on tuples. Three different shapes, so the
285
+ * caller has to run them in three steps rather than one pass.
286
+ */ splitAt(name) {
287
+ this.resolveEnumeration();
288
+ const sortedItems = this.enumeratedItems.toSorted((a, b)=>a.index - b.index);
289
+ const before = new QueryOptionsCollection();
290
+ const after = new QueryOptionsCollection();
291
+ let at = null;
292
+ for(let i = 0, length = sortedItems.length; i < length; i++){
293
+ const { option } = sortedItems[i];
294
+ if (at == null && option.name === name) {
295
+ at = option;
296
+ continue;
297
+ }
298
+ const destination = at == null ? before : after;
299
+ destination.add(option.name, option.value);
300
+ }
301
+ return {
302
+ before,
303
+ at,
304
+ after
305
+ };
306
+ }
307
+ /**
308
+ * Captures the collection's current state and returns a function that restores it.
309
+ *
310
+ * Terminal queryable operations (count, first, aggregates, …) record their option on
311
+ * the shared collection before executing. Without restoring, a re-executed terminal —
312
+ * the whole point of a subscribed queryable — stacks its option a second time and
313
+ * runs it over the first execution's scalar result.
314
+ */ snapshot() {
315
+ const options = new Map([
316
+ ...this.options.entries()
317
+ ].map(([key, items])=>[
318
+ key,
319
+ [
320
+ ...items
321
+ ]
322
+ ]));
323
+ const nextExecutionTarget = this.nextExecutionTarget;
324
+ const nextIndex = this.nextIndex;
325
+ return ()=>{
326
+ this.options = new Map(options);
327
+ this.nextExecutionTarget = nextExecutionTarget;
328
+ this.nextIndex = nextIndex;
329
+ this.enumeratedItems = [];
330
+ };
247
331
  }
248
332
  split() {
249
333
  this.resolveEnumeration();
250
- const sortedItems = this.enumeratedItems.toSorted((a, b) => a.index - b.index);
334
+ const sortedItems = this.enumeratedItems.toSorted((a, b)=>a.index - b.index);
251
335
  const memoryQueryOptionsCollection = new QueryOptionsCollection();
252
336
  const databaseQueryOptionsCollection = new QueryOptionsCollection();
253
- for (let i = 0, length = sortedItems.length; i < length; i++) {
337
+ for(let i = 0, length = sortedItems.length; i < length; i++){
254
338
  const sortedItem = sortedItems[i];
255
339
  if (sortedItem.option.target === "database") {
256
340
  databaseQueryOptionsCollection.add(sortedItem.option.name, sortedItem.option.value);
@@ -264,8 +348,15 @@ class QueryOptionsCollection {
264
348
  };
265
349
  }
266
350
  hasTransformations() {
267
- const transformationOptions = ["map", "group", "min", "max", "count", "sum"];
268
- return transformationOptions.some((name) => this.options.has(name));
351
+ const transformationOptions = [
352
+ "map",
353
+ "group",
354
+ "min",
355
+ "max",
356
+ "count",
357
+ "sum"
358
+ ];
359
+ return transformationOptions.some((name)=>this.options.has(name));
269
360
  }
270
361
  has(name) {
271
362
  return this.options.has(name);
@@ -275,7 +366,7 @@ class QueryOptionsCollection {
275
366
  }
276
367
  getLast(name) {
277
368
  this.resolveEnumeration();
278
- for (let i = this.enumeratedItems.length - 1; i >= 0; i--) {
369
+ for(let i = this.enumeratedItems.length - 1; i >= 0; i--){
279
370
  const item = this.enumeratedItems[i];
280
371
  if (item.option.name === name) {
281
372
  return item.option;
@@ -288,10 +379,12 @@ class QueryOptionsCollection {
288
379
  if (found == null) {
289
380
  return [];
290
381
  }
291
- return found.map(w => w.option.value);
382
+ return found.map((w)=>w.option.value);
292
383
  }
293
384
  getEnumeration() {
294
- return [...this.options.values()].flat().toSorted((a, b) => a.index - b.index);
385
+ return [
386
+ ...this.options.values()
387
+ ].flat().toSorted((a, b)=>a.index - b.index);
295
388
  }
296
389
  resolveEnumeration() {
297
390
  if (this.enumeratedItems.length != this.nextIndex) {
@@ -300,7 +393,7 @@ class QueryOptionsCollection {
300
393
  }
301
394
  forEach(iterator) {
302
395
  this.resolveEnumeration();
303
- for (let i = 0, length = this.enumeratedItems.length; i < length; i++) {
396
+ for(let i = 0, length = this.enumeratedItems.length; i < length; i++){
304
397
  iterator(this.enumeratedItems[i].option);
305
398
  }
306
399
  }
@@ -308,29 +401,11 @@ class QueryOptionsCollection {
308
401
 
309
402
 
310
403
  },
311
- "./src/utilities/arrays.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
312
- __webpack_require__.r(__webpack_exports__);
404
+ 76(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
313
405
  __webpack_require__.d(__webpack_exports__, {
314
- toMap: () => (toMap)
406
+ $: () => (isDate)
315
407
  });
316
- const toMap = (data, keySelector) => {
317
- const result = new Map();
318
- for (let i = 0; i < data.length; i++) {
319
- const item = data[i];
320
- const key = keySelector(item);
321
- result.set(key, item);
322
- }
323
- return result;
324
- };
325
-
326
-
327
- },
328
- "./src/utilities/dates.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
329
- __webpack_require__.r(__webpack_exports__);
330
- __webpack_require__.d(__webpack_exports__, {
331
- isDate: () => (isDate)
332
- });
333
- const isDate = (data) => {
408
+ const isDate = (data)=>{
334
409
  if (data == null) {
335
410
  return false;
336
411
  }
@@ -342,211 +417,178 @@ const isDate = (data) => {
342
417
 
343
418
 
344
419
  },
345
- "./src/utilities/dbPluginEventUtils.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
346
- __webpack_require__.r(__webpack_exports__);
420
+ 581(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
347
421
  __webpack_require__.d(__webpack_exports__, {
348
- toEventArray: () => (toEventArray)
422
+ Cg: () => (resetLogLevel),
423
+ He: () => (setLogLevel),
424
+ Mi: () => (isLogLevelEnabled),
425
+ XM: () => (getLogLevel),
426
+ p_: () => (LOG_LEVELS),
427
+ vF: () => (logger)
349
428
  });
350
- const toEventArray = (event) => {
351
- const result = [];
352
- for (const [schemaId, changes] of event.operation) {
353
- if (changes.hasItems === false) {
354
- continue;
355
- }
356
- if (changes.adds.length > 0) {
357
- result.push(...changes.adds.map(add => {
358
- return [schemaId, { data: { ...add }, type: "add" }];
359
- }));
360
- }
361
- if (changes.updates.length > 0) {
362
- result.push(...changes.updates.map(update => {
363
- return [schemaId, { data: { ...update }, type: "update" }];
364
- }));
365
- }
366
- if (changes.removes.length > 0) {
367
- result.push(...changes.removes.map(remove => {
368
- return [schemaId, { data: { ...remove }, type: "remove" }];
369
- }));
370
- }
371
- }
372
- return result;
429
+ /**
430
+ * Levelled logging, resolved once.
431
+ *
432
+ * Three things about the previous implementation drove this shape:
433
+ *
434
+ * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever
435
+ * compared against `true`, so setting it to `false` did nothing — while
436
+ * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.
437
+ * A documented switch that silently does nothing is worse than no switch.
438
+ * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always
439
+ * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through
440
+ * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also
441
+ * capture console output by snapshotting a stack trace per call, so the cost is far above what
442
+ * writing to a terminal would suggest and the output buries whatever the failure was.
443
+ * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug
444
+ * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.
445
+ *
446
+ * Levels are compared numerically against a value cached at module load. Measured against a
447
+ * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.
448
+ * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why
449
+ * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —
450
+ * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call
451
+ * site to do it.
452
+ */ /** Ordered from most severe to most verbose. `silent` discards everything. */ const LOG_LEVELS = [
453
+ 'silent',
454
+ 'error',
455
+ 'warn',
456
+ 'info',
457
+ 'debug'
458
+ ];
459
+ /** Numeric rank, so a gate is one integer comparison. */ const RANK = {
460
+ silent: 0,
461
+ error: 1,
462
+ warn: 2,
463
+ info: 3,
464
+ debug: 4
373
465
  };
374
-
375
-
376
- },
377
- "./src/utilities/functions.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
378
- __webpack_require__.r(__webpack_exports__);
379
- __webpack_require__.d(__webpack_exports__, {
380
- noop: () => (noop)
381
- });
382
- const noop = (..._args) => { };
383
-
384
-
385
- },
386
- "./src/utilities/logger.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
387
- __webpack_require__.r(__webpack_exports__);
388
- __webpack_require__.d(__webpack_exports__, {
389
- logger: () => (logger)
390
- });
466
+ const isLogLevel = (value)=>typeof value === 'string' && LOG_LEVELS.includes(value);
391
467
  /**
392
- * Enable logging by setting `globalThis.__ROUTIER_DEBUG__ = true` before any routier code runs.
393
- */
394
- const shouldLog = () => {
468
+ * Resolves the configured level, in precedence order.
469
+ *
470
+ * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an
471
+ * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything
472
+ * unrecognised is ignored rather than treated as an error — a typo'd level should not take down
473
+ * an application, and `silent` is the safe direction to fall back to.
474
+ */ const resolveLevel = ()=>{
395
475
  if (typeof globalThis !== 'undefined') {
396
476
  const g = globalThis;
397
- if (g.__ROUTIER_DEBUG__ === true)
398
- return true;
399
- }
477
+ if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {
478
+ return g.__ROUTIER_LOG_LEVEL__;
479
+ }
480
+ // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks
481
+ // below and re-enable the logging it was asked to suppress.
482
+ if (g.__ROUTIER_DEBUG__ === true) return 'debug';
483
+ if (g.__ROUTIER_DEBUG__ === false) return 'silent';
484
+ }
485
+ // There is deliberately no `import.meta.env` branch, although the documentation used to
486
+ // promise one. It could never work: this package is bundled with rspack, which replaces
487
+ // `import.meta` with `undefined`, so the check would read the *library's* build-time
488
+ // environment rather than the application's — and referencing `import.meta` at all is a parse
489
+ // error under a CommonJS build target, which is how the test suite loads this file. Vite and
490
+ // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own
491
+ // `import.meta.env`, which is what the docs now describe.
400
492
  if (typeof process !== 'undefined' && process.env != null) {
493
+ if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {
494
+ return process.env.ROUTIER_LOG_LEVEL;
495
+ }
401
496
  const debug = process.env.DEBUG;
402
- if (debug === 'routier' || debug === '*')
403
- return true;
404
- const env = "development"?.toLowerCase();
405
- if (env === 'dev' || env === 'development' || env === 'test')
406
- return true;
407
- }
408
- return false;
497
+ if (debug === 'routier' || debug === '*') return 'debug';
498
+ const env = "production"?.toLowerCase();
499
+ // `test` is deliberately absent. It used to be here, which meant no test suite anywhere
500
+ // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test
501
+ // needs the output.
502
+ if (env === 'dev' || env === 'development') return 'debug';
503
+ }
504
+ return 'silent';
409
505
  };
410
- const tryLog = (type, ...args) => {
411
- if (shouldLog()) {
412
- console[type](...args);
413
- }
414
- };
415
- const logger = {
416
- log: (...args) => {
417
- tryLog("log", ...args);
418
- },
419
- info: (...args) => {
420
- tryLog("info", ...args);
421
- },
422
- warn: (...args) => {
423
- tryLog("warn", ...args);
424
- },
425
- error: (...args) => {
426
- tryLog("error", ...args);
427
- },
428
- debug: (...args) => {
429
- tryLog("debug", ...args);
430
- },
431
- table: (...args) => {
432
- tryLog("table", ...args);
433
- },
506
+ let level = resolveLevel();
507
+ let rank = RANK[level];
508
+ /**
509
+ * Overrides the level for the rest of the process.
510
+ *
511
+ * The configuration above is read once, at import, which is what makes the gate cheap — but it
512
+ * also means an application that decides its verbosity after startup, or a test that wants to
513
+ * assert on output, has no way in. This is that way in.
514
+ */ const setLogLevel = (next)=>{
515
+ if (isLogLevel(next) === false) {
516
+ throw new Error(`Unknown log level "${next}". Expected one of: ${LOG_LEVELS.join(', ')}`);
517
+ }
518
+ level = next;
519
+ rank = RANK[next];
434
520
  };
435
-
436
-
437
- },
438
- "./src/utilities/objects.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
439
- __webpack_require__.r(__webpack_exports__);
440
- __webpack_require__.d(__webpack_exports__, {
441
- cast: () => (cast),
442
- clone: () => (clone)
443
- });
444
- const cast = (item) => {
445
- return item;
521
+ const getLogLevel = ()=>level;
522
+ /** Re-reads the environment. For tests that change it after this module was imported. */ const resetLogLevel = ()=>{
523
+ level = resolveLevel();
524
+ rank = RANK[level];
446
525
  };
447
- function clone(data) {
448
- return JSON.parse(JSON.stringify(data));
449
- }
450
-
451
-
452
- },
453
- "./src/utilities/queryOptionsCollection.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
454
- __webpack_require__.r(__webpack_exports__);
455
- __webpack_require__.d(__webpack_exports__, {
456
- combineQueryOptionsCollections: () => (combineQueryOptionsCollections)
457
- });
458
- /* import */ var _plugins_query__rspack_import_0 = __webpack_require__("./src/plugins/query/QueryOptionsCollection.ts");
459
-
460
- const combineQueryOptionsCollections = (...collections) => {
461
- const result = new _plugins_query__rspack_import_0.QueryOptionsCollection();
462
- for (let i = 0, length = collections.length; i < length; i++) {
463
- const collection = collections[i];
464
- // Add scoped items first
465
- collection.forEach(item => {
466
- result.add(item.name, item.value);
467
- });
526
+ /**
527
+ * Whether a message at this level would be emitted.
528
+ *
529
+ * For the rare call site whose *arguments* are expensive to build — a serialization, a deep
530
+ * clone, a join over a large collection. An ordinary payload object is not worth guarding; see
531
+ * the measurement in the header.
532
+ */ const isLogLevelEnabled = (at)=>rank >= RANK[at];
533
+ const emit = (at, method, args)=>{
534
+ if (rank < RANK[at]) {
535
+ return;
468
536
  }
469
- return result;
537
+ // Resolved at call time rather than captured once: test harnesses and browser devtools both
538
+ // replace console methods after modules have loaded, and a captured reference would keep
539
+ // writing past the replacement.
540
+ console[method](...args);
470
541
  };
471
-
472
-
473
- },
474
- "./src/utilities/replication.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
475
- __webpack_require__.r(__webpack_exports__);
476
- __webpack_require__.d(__webpack_exports__, {
477
- resolveBulkPersistChanges: () => (resolveBulkPersistChanges)
478
- });
479
- const resolveBulkPersistChanges = (event, result, bulkPersistChanges) => {
480
- // make sure we swap the adds here, that way we can make sure other persist events
481
- // don't take their additions and try to change subsequent calls
482
- for (const [schemaId, changes] of event.operation) {
483
- const schemmaBulkPersistResult = result.get(schemaId);
484
- const schemaBulkPersistChanges = bulkPersistChanges.resolve(schemaId);
485
- // Set the original removes
486
- schemaBulkPersistChanges.removes = changes.removes;
487
- // Set the original updates
488
- schemaBulkPersistChanges.updates = changes.updates;
489
- // Take the adds from the result and set them to be persisted
490
- // in the replicated plugins because the id's are set in the
491
- // memory data store
492
- schemaBulkPersistChanges.adds = schemmaBulkPersistResult.adds;
493
- }
542
+ const logger = {
543
+ /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */ log: (...args)=>emit('info', 'log', args),
544
+ info: (...args)=>emit('info', 'info', args),
545
+ warn: (...args)=>emit('warn', 'warn', args),
546
+ error: (...args)=>emit('error', 'error', args),
547
+ debug: (...args)=>emit('debug', 'debug', args),
548
+ /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */ table: (...args)=>emit('debug', 'table', args)
494
549
  };
495
550
 
496
551
 
497
552
  },
498
- "./src/utilities/runtime.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
499
- __webpack_require__.r(__webpack_exports__);
553
+ 615(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
500
554
  __webpack_require__.d(__webpack_exports__, {
501
- isNodeRuntime: () => (isNodeRuntime)
555
+ Nr: () => (fastHash),
556
+ Zm: () => (stringifyObject),
557
+ tW: () => (hash)
502
558
  });
503
- const isNodeRuntime = () => typeof process !== 'undefined' &&
504
- process.versions != null &&
505
- process.versions.node != null;
506
-
507
-
508
- },
509
- "./src/utilities/strings.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
510
- __webpack_require__.r(__webpack_exports__);
511
- __webpack_require__.d(__webpack_exports__, {
512
- fastHash: () => (fastHash),
513
- hash: () => (hash),
514
- stringifyObject: () => (stringifyObject)
515
- });
516
- const hash = (value, seed = 0) => {
559
+ const hash = (value, seed = 0)=>{
517
560
  // From Stack Overflow
518
561
  // https://stackoverflow.com/a/52171480/3329760
519
562
  let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
520
- for (let i = 0, ch; i < value.length; i++) {
563
+ for(let i = 0, ch; i < value.length; i++){
521
564
  ch = value.charCodeAt(i);
522
565
  h1 = Math.imul(h1 ^ ch, 2654435761);
523
566
  h2 = Math.imul(h2 ^ ch, 1597334677);
524
567
  }
525
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
526
- h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
527
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
528
- h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
568
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
569
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
570
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
571
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
529
572
  return 4294967296 * (2097151 & h2) + (h1 >>> 0);
530
573
  };
531
574
  /**
532
575
  * Fast string hash optimized for comparisons.
533
576
  * Uses djb2 algorithm - very fast and good distribution for short to medium strings.
534
577
  * Same input always produces same output (deterministic).
535
- *
578
+ *
536
579
  * @param value - The string to hash
537
580
  * @param seed - Optional seed value (default: 5381)
538
581
  * @returns A positive 32-bit integer hash value
539
- *
582
+ *
540
583
  * @example
541
584
  * ```ts
542
585
  * fastHash("test") === fastHash("test") // true
543
586
  * fastHash("test") !== fastHash("test2") // true
544
587
  * ```
545
- */
546
- const fastHash = (value, seed = 5381) => {
588
+ */ const fastHash = (value, seed = 5381)=>{
547
589
  let hash = seed;
548
- for (let i = 0; i < value.length; i++) {
549
- hash = ((hash << 5) + hash) + value.charCodeAt(i);
590
+ for(let i = 0; i < value.length; i++){
591
+ hash = (hash << 5) + hash + value.charCodeAt(i);
550
592
  }
551
593
  return hash >>> 0; // Convert to unsigned 32-bit integer
552
594
  };
@@ -554,26 +596,23 @@ const fastHash = (value, seed = 5381) => {
554
596
  * Converts any value to a readable string representation.
555
597
  * Handles primitives, objects, arrays, classes, dates, errors, and functions.
556
598
  * Supports depth limiting to prevent infinite recursion on circular references.
557
- *
599
+ *
558
600
  * @param obj - The value to stringify
559
601
  * @param maxDepth - Maximum depth for nested objects (default: 3)
560
602
  * @param currentDepth - Current recursion depth (default: 0)
561
603
  * @returns String representation of the value
562
- *
604
+ *
563
605
  * @example
564
606
  * ```ts
565
607
  * stringifyObject({ name: "test", count: 5 }) // '{ name: "test", count: 5 }'
566
608
  * stringifyObject([1, 2, 3]) // '[1, 2, 3]'
567
609
  * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'
568
610
  * ```
569
- */
570
- function stringifyObject(obj, maxDepth = 3, currentDepth = 0) {
571
- if (obj === null)
572
- return 'null';
573
- if (obj === undefined)
574
- return 'undefined';
611
+ */ function stringifyObject(obj, maxDepth = 3, currentDepth = 0) {
612
+ if (obj === null) return 'null';
613
+ if (obj === undefined) return 'undefined';
575
614
  const type = typeof obj;
576
- switch (type) {
615
+ switch(type){
577
616
  case 'string':
578
617
  return `"${obj}"`;
579
618
  case 'number':
@@ -596,7 +635,7 @@ function getFunctionName(fn) {
596
635
  }
597
636
  function getObjectProperties(obj) {
598
637
  const properties = {};
599
- for (const key in obj) {
638
+ for(const key in obj){
600
639
  if (obj.hasOwnProperty(key)) {
601
640
  properties[key] = obj[key];
602
641
  }
@@ -604,8 +643,7 @@ function getObjectProperties(obj) {
604
643
  return properties;
605
644
  }
606
645
  function stringifyObjectValue(obj, maxDepth, currentDepth) {
607
- if (obj === null)
608
- return 'null';
646
+ if (obj === null) return 'null';
609
647
  if (obj instanceof Date) {
610
648
  return `Date(${obj.toISOString()})`;
611
649
  }
@@ -624,9 +662,8 @@ function stringifyObjectValue(obj, maxDepth, currentDepth) {
624
662
  return stringifyPlainObject(obj, maxDepth, currentDepth);
625
663
  }
626
664
  function stringifyArray(arr, maxDepth, currentDepth) {
627
- if (arr.length === 0)
628
- return '[]';
629
- const items = arr.slice(0, 5).map(item => stringifyObject(item, maxDepth, currentDepth + 1));
665
+ if (arr.length === 0) return '[]';
666
+ const items = arr.slice(0, 5).map((item)=>stringifyObject(item, maxDepth, currentDepth + 1));
630
667
  const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';
631
668
  return `[${items.join(', ')}${suffix}]`;
632
669
  }
@@ -636,16 +673,12 @@ function stringifyClassInstance(obj, maxDepth, currentDepth) {
636
673
  if (Object.keys(properties).length === 0) {
637
674
  return `${className} {}`;
638
675
  }
639
- const props = Object.entries(properties)
640
- .slice(0, 5)
641
- .map(([key, value]) => {
642
- const isPrimitive = value === null || value === undefined ||
643
- (typeof value !== 'object' && typeof value !== 'function');
676
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
677
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
644
678
  const depth = isPrimitive ? currentDepth : currentDepth + 1;
645
679
  return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
646
680
  });
647
- const suffix = Object.keys(properties).length > 5 ?
648
- `... (+${Object.keys(properties).length - 5} more)` : '';
681
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
649
682
  return `${className} { ${props.join(', ')}${suffix} }`;
650
683
  }
651
684
  function stringifyPlainObject(obj, maxDepth, currentDepth) {
@@ -653,43 +686,27 @@ function stringifyPlainObject(obj, maxDepth, currentDepth) {
653
686
  if (Object.keys(properties).length === 0) {
654
687
  return '{}';
655
688
  }
656
- const props = Object.entries(properties)
657
- .slice(0, 5)
658
- .map(([key, value]) => {
659
- const isPrimitive = value === null || value === undefined ||
660
- (typeof value !== 'object' && typeof value !== 'function');
689
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
690
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
661
691
  const depth = isPrimitive ? currentDepth : currentDepth + 1;
662
692
  return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
663
693
  });
664
- const suffix = Object.keys(properties).length > 5 ?
665
- `... (+${Object.keys(properties).length - 5} more)` : '';
694
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
666
695
  return `{ ${props.join(', ')}${suffix} }`;
667
696
  }
668
697
 
669
698
 
670
699
  },
671
- "./src/utilities/unsafeCast.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
672
- __webpack_require__.r(__webpack_exports__);
700
+ 618(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
673
701
  __webpack_require__.d(__webpack_exports__, {
674
- unsafeCast: () => (unsafeCast)
702
+ g: () => (uuidv4),
703
+ u: () => (uuid)
675
704
  });
676
- const unsafeCast = (value) => {
677
- return value;
678
- };
679
-
680
-
681
- },
682
- "./src/utilities/uuid.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
683
- __webpack_require__.r(__webpack_exports__);
684
- __webpack_require__.d(__webpack_exports__, {
685
- uuid: () => (uuid),
686
- uuidv4: () => (uuidv4)
687
- });
688
- const uuid = (length = 16) => {
705
+ const uuid = (length = 16)=>{
689
706
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
690
707
  const charLength = chars.length;
691
708
  let result = '';
692
- for (let i = 0; i < length; i++) {
709
+ for(let i = 0; i < length; i++){
693
710
  result += chars[Math.random() * charLength | 0];
694
711
  }
695
712
  return result;
@@ -697,14 +714,21 @@ const uuid = (length = 16) => {
697
714
  const HEX_CHARS = '0123456789abcdef';
698
715
  const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
699
716
  const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
700
- const uuidv4 = () => {
717
+ const hasRandomUUID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
718
+ const uuidv4 = ()=>{
719
+ if (hasRandomUUID) {
720
+ return crypto.randomUUID();
721
+ }
722
+ return uuidv4Fallback();
723
+ };
724
+ const uuidv4Fallback = ()=>{
701
725
  let randomBytes = null;
702
726
  if (hasCrypto) {
703
727
  randomBytes = crypto.getRandomValues(new Uint8Array(16));
704
728
  }
705
729
  let byteIndex = 0;
706
730
  let uuid = '';
707
- for (let i = 0; i < UUID_TEMPLATE.length; i++) {
731
+ for(let i = 0; i < UUID_TEMPLATE.length; i++){
708
732
  const c = UUID_TEMPLATE[i];
709
733
  if (c === '-') {
710
734
  uuid += '-';
@@ -713,22 +737,16 @@ const uuidv4 = () => {
713
737
  let r;
714
738
  if (hasCrypto && randomBytes) {
715
739
  // Each byte gives two hex digits (nibbles)
716
- r =
717
- (i % 2 === 0
718
- ? randomBytes[byteIndex] >> 4
719
- : randomBytes[byteIndex++] & 0x0f);
720
- }
721
- else {
740
+ r = i % 2 === 0 ? randomBytes[byteIndex] >> 4 : randomBytes[byteIndex++] & 0x0f;
741
+ } else {
722
742
  r = Math.floor(Math.random() * 16);
723
743
  }
724
744
  if (c === 'x') {
725
745
  uuid += HEX_CHARS[r];
726
- }
727
- else if (c === 'y') {
746
+ } else if (c === 'y') {
728
747
  // Variant bits: 8, 9, A, or B
729
- uuid += HEX_CHARS[(r & 0x3) | 0x8];
730
- }
731
- else if (c === '4') {
748
+ uuid += HEX_CHARS[r & 0x3 | 0x8];
749
+ } else if (c === '4') {
732
750
  uuid += '4';
733
751
  }
734
752
  }
@@ -776,50 +794,158 @@ __webpack_require__.d = (exports, definition) => {
776
794
  (() => {
777
795
  __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
778
796
  })();
779
- // webpack/runtime/make_namespace_object
780
- (() => {
781
- // define __esModule on exports
782
- __webpack_require__.r = (exports) => {
783
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
784
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
785
- }
786
- Object.defineProperty(exports, '__esModule', { value: true });
787
- };
788
- })();
789
797
  var __webpack_exports__ = {};
790
798
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
791
799
  (() => {
792
- __webpack_require__.r(__webpack_exports__);
800
+
801
+ // EXPORTS
793
802
  __webpack_require__.d(__webpack_exports__, {
794
- cast: () => (/* reexport safe */ _objects__rspack_import_3.cast),
795
- clone: () => (/* reexport safe */ _objects__rspack_import_3.clone),
796
- combineQueryOptionsCollections: () => (/* reexport safe */ _queryOptionsCollection__rspack_import_7.combineQueryOptionsCollections),
797
- fastHash: () => (/* reexport safe */ _strings__rspack_import_1.fastHash),
798
- hash: () => (/* reexport safe */ _strings__rspack_import_1.hash),
799
- isDate: () => (/* reexport safe */ _dates__rspack_import_2.isDate),
800
- isNodeRuntime: () => (/* reexport safe */ _runtime__rspack_import_4.isNodeRuntime),
801
- logger: () => (/* reexport safe */ _logger__rspack_import_11.logger),
802
- noop: () => (/* reexport safe */ _functions__rspack_import_9.noop),
803
- resolveBulkPersistChanges: () => (/* reexport safe */ _replication__rspack_import_6.resolveBulkPersistChanges),
804
- stringifyObject: () => (/* reexport safe */ _strings__rspack_import_1.stringifyObject),
805
- toEventArray: () => (/* reexport safe */ _dbPluginEventUtils__rspack_import_8.toEventArray),
806
- toMap: () => (/* reexport safe */ _arrays__rspack_import_0.toMap),
807
- unsafeCast: () => (/* reexport safe */ _unsafeCast__rspack_import_10.unsafeCast),
808
- uuid: () => (/* reexport safe */ _uuid__rspack_import_5.uuid),
809
- uuidv4: () => (/* reexport safe */ _uuid__rspack_import_5.uuidv4)
803
+ N8: () => (/* reexport */ combineQueryOptionsCollections),
804
+ tW: () => (/* reexport */ strings/* .hash */.tW),
805
+ vF: () => (/* reexport */ logger/* .logger */.vF),
806
+ lQ: () => (/* reexport */ noop),
807
+ He: () => (/* reexport */ logger/* .setLogLevel */.He),
808
+ Nr: () => (/* reexport */ strings/* .fastHash */.Nr),
809
+ uR: () => (/* reexport */ uuid/* .uuid */.u),
810
+ p_: () => (/* reexport */ logger/* .LOG_LEVELS */.p_),
811
+ XM: () => (/* reexport */ logger/* .getLogLevel */.XM),
812
+ Cg: () => (/* reexport */ logger/* .resetLogLevel */.Cg),
813
+ Zm: () => (/* reexport */ strings/* .stringifyObject */.Zm),
814
+ av: () => (/* reexport */ toMap),
815
+ wg: () => (/* reexport */ cast),
816
+ $P: () => (/* reexport */ dates/* .isDate */.$),
817
+ Vg: () => (/* reexport */ toEventArray),
818
+ sz: () => (/* reexport */ unsafeCast),
819
+ Mi: () => (/* reexport */ logger/* .isLogLevelEnabled */.Mi),
820
+ ap: () => (/* reexport */ resolveBulkPersistChanges),
821
+ tX: () => (/* reexport */ isNodeRuntime),
822
+ gZ: () => (/* reexport */ uuid/* .uuidv4 */.g),
823
+ o8: () => (/* reexport */ clone)
810
824
  });
811
- /* import */ var _arrays__rspack_import_0 = __webpack_require__("./src/utilities/arrays.ts");
812
- /* import */ var _strings__rspack_import_1 = __webpack_require__("./src/utilities/strings.ts");
813
- /* import */ var _dates__rspack_import_2 = __webpack_require__("./src/utilities/dates.ts");
814
- /* import */ var _objects__rspack_import_3 = __webpack_require__("./src/utilities/objects.ts");
815
- /* import */ var _runtime__rspack_import_4 = __webpack_require__("./src/utilities/runtime.ts");
816
- /* import */ var _uuid__rspack_import_5 = __webpack_require__("./src/utilities/uuid.ts");
817
- /* import */ var _replication__rspack_import_6 = __webpack_require__("./src/utilities/replication.ts");
818
- /* import */ var _queryOptionsCollection__rspack_import_7 = __webpack_require__("./src/utilities/queryOptionsCollection.ts");
819
- /* import */ var _dbPluginEventUtils__rspack_import_8 = __webpack_require__("./src/utilities/dbPluginEventUtils.ts");
820
- /* import */ var _functions__rspack_import_9 = __webpack_require__("./src/utilities/functions.ts");
821
- /* import */ var _unsafeCast__rspack_import_10 = __webpack_require__("./src/utilities/unsafeCast.ts");
822
- /* import */ var _logger__rspack_import_11 = __webpack_require__("./src/utilities/logger.ts");
825
+
826
+ ;// CONCATENATED MODULE: ./src/utilities/arrays.ts
827
+ const toMap = (data, keySelector)=>{
828
+ const result = new Map();
829
+ for(let i = 0; i < data.length; i++){
830
+ const item = data[i];
831
+ const key = keySelector(item);
832
+ result.set(key, item);
833
+ }
834
+ return result;
835
+ };
836
+
837
+ // EXTERNAL MODULE: ./src/utilities/strings.ts
838
+ var strings = __webpack_require__(615);
839
+ // EXTERNAL MODULE: ./src/utilities/dates.ts
840
+ var dates = __webpack_require__(76);
841
+ ;// CONCATENATED MODULE: ./src/utilities/objects.ts
842
+ const cast = (item)=>{
843
+ return item;
844
+ };
845
+ function clone(data) {
846
+ return JSON.parse(JSON.stringify(data));
847
+ }
848
+
849
+ ;// CONCATENATED MODULE: ./src/utilities/runtime.ts
850
+ const isNodeRuntime = ()=>typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
851
+
852
+ // EXTERNAL MODULE: ./src/utilities/uuid.ts
853
+ var uuid = __webpack_require__(618);
854
+ ;// CONCATENATED MODULE: ./src/utilities/replication.ts
855
+ const resolveBulkPersistChanges = (event, result, bulkPersistChanges)=>{
856
+ // make sure we swap the adds here, that way we can make sure other persist events
857
+ // don't take their additions and try to change subsequent calls
858
+ for (const [schemaId, changes] of event.operation){
859
+ const schemmaBulkPersistResult = result.get(schemaId);
860
+ const schemaBulkPersistChanges = bulkPersistChanges.resolve(schemaId);
861
+ // Set the original removes
862
+ schemaBulkPersistChanges.removes = changes.removes;
863
+ // Set the original updates
864
+ schemaBulkPersistChanges.updates = changes.updates;
865
+ // Take the adds from the result and set them to be persisted
866
+ // in the replicated plugins because the id's are set in the
867
+ // memory data store
868
+ schemaBulkPersistChanges.adds = schemmaBulkPersistResult.adds;
869
+ }
870
+ };
871
+
872
+ // EXTERNAL MODULE: ./src/plugins/query/QueryOptionsCollection.ts
873
+ var QueryOptionsCollection = __webpack_require__(198);
874
+ ;// CONCATENATED MODULE: ./src/utilities/queryOptionsCollection.ts
875
+
876
+ const combineQueryOptionsCollections = (...collections)=>{
877
+ const result = new QueryOptionsCollection/* .QueryOptionsCollection */.H();
878
+ for(let i = 0, length = collections.length; i < length; i++){
879
+ const collection = collections[i];
880
+ // Add scoped items first
881
+ collection.forEach((item)=>{
882
+ result.add(item.name, item.value);
883
+ });
884
+ }
885
+ return result;
886
+ };
887
+
888
+ ;// CONCATENATED MODULE: ./src/utilities/dbPluginEventUtils.ts
889
+ const toEventArray = (event)=>{
890
+ const result = [];
891
+ for (const [schemaId, changes] of event.operation){
892
+ if (changes.hasItems === false) {
893
+ continue;
894
+ }
895
+ if (changes.adds.length > 0) {
896
+ result.push(...changes.adds.map((add)=>{
897
+ return [
898
+ schemaId,
899
+ {
900
+ data: {
901
+ ...add
902
+ },
903
+ type: "add"
904
+ }
905
+ ];
906
+ }));
907
+ }
908
+ if (changes.updates.length > 0) {
909
+ result.push(...changes.updates.map((update)=>{
910
+ return [
911
+ schemaId,
912
+ {
913
+ data: {
914
+ ...update
915
+ },
916
+ type: "update"
917
+ }
918
+ ];
919
+ }));
920
+ }
921
+ if (changes.removes.length > 0) {
922
+ result.push(...changes.removes.map((remove)=>{
923
+ return [
924
+ schemaId,
925
+ {
926
+ data: {
927
+ ...remove
928
+ },
929
+ type: "remove"
930
+ }
931
+ ];
932
+ }));
933
+ }
934
+ }
935
+ return result;
936
+ };
937
+
938
+ ;// CONCATENATED MODULE: ./src/utilities/functions.ts
939
+ const noop = (..._args)=>{};
940
+
941
+ ;// CONCATENATED MODULE: ./src/utilities/unsafeCast.ts
942
+ const unsafeCast = (value)=>{
943
+ return value;
944
+ };
945
+
946
+ // EXTERNAL MODULE: ./src/utilities/logger.ts
947
+ var logger = __webpack_require__(581);
948
+ ;// CONCATENATED MODULE: ./src/utilities/index.ts
823
949
 
824
950
 
825
951
 
@@ -836,22 +962,27 @@ __webpack_require__.d(__webpack_exports__, {
836
962
 
837
963
  })();
838
964
 
839
- var __webpack_exports__cast = __webpack_exports__.cast;
840
- var __webpack_exports__clone = __webpack_exports__.clone;
841
- var __webpack_exports__combineQueryOptionsCollections = __webpack_exports__.combineQueryOptionsCollections;
842
- var __webpack_exports__fastHash = __webpack_exports__.fastHash;
843
- var __webpack_exports__hash = __webpack_exports__.hash;
844
- var __webpack_exports__isDate = __webpack_exports__.isDate;
845
- var __webpack_exports__isNodeRuntime = __webpack_exports__.isNodeRuntime;
846
- var __webpack_exports__logger = __webpack_exports__.logger;
847
- var __webpack_exports__noop = __webpack_exports__.noop;
848
- var __webpack_exports__resolveBulkPersistChanges = __webpack_exports__.resolveBulkPersistChanges;
849
- var __webpack_exports__stringifyObject = __webpack_exports__.stringifyObject;
850
- var __webpack_exports__toEventArray = __webpack_exports__.toEventArray;
851
- var __webpack_exports__toMap = __webpack_exports__.toMap;
852
- var __webpack_exports__unsafeCast = __webpack_exports__.unsafeCast;
853
- var __webpack_exports__uuid = __webpack_exports__.uuid;
854
- var __webpack_exports__uuidv4 = __webpack_exports__.uuidv4;
855
- export { __webpack_exports__cast as cast, __webpack_exports__clone as clone, __webpack_exports__combineQueryOptionsCollections as combineQueryOptionsCollections, __webpack_exports__fastHash as fastHash, __webpack_exports__hash as hash, __webpack_exports__isDate as isDate, __webpack_exports__isNodeRuntime as isNodeRuntime, __webpack_exports__logger as logger, __webpack_exports__noop as noop, __webpack_exports__resolveBulkPersistChanges as resolveBulkPersistChanges, __webpack_exports__stringifyObject as stringifyObject, __webpack_exports__toEventArray as toEventArray, __webpack_exports__toMap as toMap, __webpack_exports__unsafeCast as unsafeCast, __webpack_exports__uuid as uuid, __webpack_exports__uuidv4 as uuidv4 };
965
+ var __webpack_exports__LOG_LEVELS = __webpack_exports__.p_;
966
+ var __webpack_exports__cast = __webpack_exports__.wg;
967
+ var __webpack_exports__clone = __webpack_exports__.o8;
968
+ var __webpack_exports__combineQueryOptionsCollections = __webpack_exports__.N8;
969
+ var __webpack_exports__fastHash = __webpack_exports__.Nr;
970
+ var __webpack_exports__getLogLevel = __webpack_exports__.XM;
971
+ var __webpack_exports__hash = __webpack_exports__.tW;
972
+ var __webpack_exports__isDate = __webpack_exports__.$P;
973
+ var __webpack_exports__isLogLevelEnabled = __webpack_exports__.Mi;
974
+ var __webpack_exports__isNodeRuntime = __webpack_exports__.tX;
975
+ var __webpack_exports__logger = __webpack_exports__.vF;
976
+ var __webpack_exports__noop = __webpack_exports__.lQ;
977
+ var __webpack_exports__resetLogLevel = __webpack_exports__.Cg;
978
+ var __webpack_exports__resolveBulkPersistChanges = __webpack_exports__.ap;
979
+ var __webpack_exports__setLogLevel = __webpack_exports__.He;
980
+ var __webpack_exports__stringifyObject = __webpack_exports__.Zm;
981
+ var __webpack_exports__toEventArray = __webpack_exports__.Vg;
982
+ var __webpack_exports__toMap = __webpack_exports__.av;
983
+ var __webpack_exports__unsafeCast = __webpack_exports__.sz;
984
+ var __webpack_exports__uuid = __webpack_exports__.uR;
985
+ var __webpack_exports__uuidv4 = __webpack_exports__.gZ;
986
+ export { __webpack_exports__LOG_LEVELS as LOG_LEVELS, __webpack_exports__cast as cast, __webpack_exports__clone as clone, __webpack_exports__combineQueryOptionsCollections as combineQueryOptionsCollections, __webpack_exports__fastHash as fastHash, __webpack_exports__getLogLevel as getLogLevel, __webpack_exports__hash as hash, __webpack_exports__isDate as isDate, __webpack_exports__isLogLevelEnabled as isLogLevelEnabled, __webpack_exports__isNodeRuntime as isNodeRuntime, __webpack_exports__logger as logger, __webpack_exports__noop as noop, __webpack_exports__resetLogLevel as resetLogLevel, __webpack_exports__resolveBulkPersistChanges as resolveBulkPersistChanges, __webpack_exports__setLogLevel as setLogLevel, __webpack_exports__stringifyObject as stringifyObject, __webpack_exports__toEventArray as toEventArray, __webpack_exports__toMap as toMap, __webpack_exports__unsafeCast as unsafeCast, __webpack_exports__uuid as uuid, __webpack_exports__uuidv4 as uuidv4 };
856
987
 
857
988
  //# sourceMappingURL=index.js.map