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