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