@routier/core 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/LICENSE +21 -0
  2. package/{readme.md → README.md} +1 -1
  3. package/dist/assertions/index.cjs +191 -0
  4. package/dist/assertions/index.cjs.map +1 -0
  5. package/dist/assertions/index.js +43 -63
  6. package/dist/assertions/index.js.map +1 -1
  7. package/dist/capabilities/index.cjs +820 -0
  8. package/dist/capabilities/index.cjs.map +1 -0
  9. package/dist/capabilities/index.js +584 -558
  10. package/dist/capabilities/index.js.map +1 -1
  11. package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
  12. package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
  13. package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
  14. package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
  15. package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
  16. package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
  17. package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
  18. package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
  19. package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
  20. package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
  21. package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
  22. package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
  23. package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
  24. package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
  25. package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
  26. package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
  27. package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
  28. package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
  29. package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
  30. package/dist/codegen/handlers/types.d.ts +55 -1
  31. package/dist/codegen/index.cjs +618 -0
  32. package/dist/codegen/index.cjs.map +1 -0
  33. package/dist/codegen/index.js +99 -127
  34. package/dist/codegen/index.js.map +1 -1
  35. package/dist/collections/MemoryDataCollection.d.ts +15 -1
  36. package/dist/collections/TagCollection.d.ts +0 -1
  37. package/dist/collections/index.cjs +702 -0
  38. package/dist/collections/index.cjs.map +1 -0
  39. package/dist/collections/index.js +282 -276
  40. package/dist/collections/index.js.map +1 -1
  41. package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
  42. package/dist/errors/PluginDestroyedError.d.ts +10 -0
  43. package/dist/errors/index.cjs +132 -0
  44. package/dist/errors/index.cjs.map +1 -0
  45. package/dist/errors/index.d.ts +2 -0
  46. package/dist/errors/index.js +61 -19
  47. package/dist/errors/index.js.map +1 -1
  48. package/dist/expressions/evaluate.d.ts +53 -0
  49. package/dist/expressions/index.cjs +2087 -0
  50. package/dist/expressions/index.cjs.map +1 -0
  51. package/dist/expressions/index.d.ts +1 -1
  52. package/dist/expressions/index.js +1727 -1082
  53. package/dist/expressions/index.js.map +1 -1
  54. package/dist/expressions/parser.d.ts +19 -0
  55. package/dist/expressions/types.d.ts +87 -2
  56. package/dist/index.cjs +13925 -0
  57. package/dist/index.cjs.map +1 -0
  58. package/dist/index.js +11936 -7950
  59. package/dist/index.js.map +1 -1
  60. package/dist/performance/index.cjs +217 -0
  61. package/dist/performance/index.cjs.map +1 -0
  62. package/dist/performance/index.js +120 -55
  63. package/dist/performance/index.js.map +1 -1
  64. package/dist/pipeline/index.cjs +576 -0
  65. package/dist/pipeline/index.cjs.map +1 -0
  66. package/dist/pipeline/index.js +223 -161
  67. package/dist/pipeline/index.js.map +1 -1
  68. package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
  69. package/dist/plugins/CacheDbPlugin.d.ts +70 -0
  70. package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
  71. package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
  72. package/dist/plugins/RetryDbPlugin.d.ts +77 -0
  73. package/dist/plugins/index.cjs +6104 -0
  74. package/dist/plugins/index.cjs.map +1 -0
  75. package/dist/plugins/index.d.ts +5 -0
  76. package/dist/plugins/index.js +5821 -1172
  77. package/dist/plugins/index.js.map +1 -1
  78. package/dist/plugins/query/QueryOptionsCollection.d.ts +21 -0
  79. package/dist/plugins/query/index.d.ts +2 -0
  80. package/dist/plugins/query/join.d.ts +210 -0
  81. package/dist/plugins/query/similarity.d.ts +38 -0
  82. package/dist/plugins/query/types.d.ts +64 -1
  83. package/dist/plugins/translators/DataTranslator.d.ts +28 -0
  84. package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
  85. package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
  86. package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
  87. package/dist/plugins/translators/index.d.ts +1 -0
  88. package/dist/plugins/types.d.ts +82 -2
  89. package/dist/plugins/wire/handler.d.ts +122 -0
  90. package/dist/plugins/wire/index.d.ts +4 -0
  91. package/dist/plugins/wire/persist.d.ts +43 -0
  92. package/dist/plugins/wire/query.d.ts +49 -0
  93. package/dist/plugins/wire/types.d.ts +123 -0
  94. package/dist/results/index.cjs +174 -0
  95. package/dist/results/index.cjs.map +1 -0
  96. package/dist/results/index.js +29 -44
  97. package/dist/results/index.js.map +1 -1
  98. package/dist/schema/PropertyInfo.d.ts +31 -2
  99. package/dist/schema/SchemaDefinition.d.ts +23 -1
  100. package/dist/schema/builder.d.ts +35 -1
  101. package/dist/schema/communication/broadcast.d.ts +17 -1
  102. package/dist/schema/index.cjs +6911 -0
  103. package/dist/schema/index.cjs.map +1 -0
  104. package/dist/schema/index.d.ts +2 -0
  105. package/dist/schema/index.js +5330 -4541
  106. package/dist/schema/index.js.map +1 -1
  107. package/dist/schema/property/base/SchemaBase.d.ts +48 -2
  108. package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
  109. package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
  110. package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
  111. package/dist/schema/property/modifiers/index.d.ts +1 -0
  112. package/dist/schema/property/types/SchemaFile.d.ts +60 -0
  113. package/dist/schema/property/types/SchemaString.d.ts +21 -1
  114. package/dist/schema/property/types/SchemaVector.d.ts +61 -0
  115. package/dist/schema/property/types/index.d.ts +2 -0
  116. package/dist/schema/table/SchemaTransform.d.ts +40 -0
  117. package/dist/schema/table/index.d.ts +1 -0
  118. package/dist/schema/types.d.ts +166 -8
  119. package/dist/schema/utils/propertyKind.d.ts +4 -0
  120. package/dist/types/index.cjs +23 -0
  121. package/dist/types/index.cjs.map +1 -0
  122. package/dist/types/index.js +0 -14
  123. package/dist/types/index.js.map +1 -1
  124. package/dist/utilities/index.cjs +982 -0
  125. package/dist/utilities/index.cjs.map +1 -0
  126. package/dist/utilities/index.js +506 -375
  127. package/dist/utilities/index.js.map +1 -1
  128. package/dist/utilities/logger.d.ts +48 -0
  129. package/package.json +152 -98
  130. package/dist/codegen/SlotPath.test.d.ts +0 -1
  131. package/dist/codegen/blocks.test.d.ts +0 -1
  132. package/dist/codegen/utils.test.d.ts +0 -1
  133. package/dist/collections/Changes.test.d.ts +0 -1
  134. package/dist/collections/IdSet.test.d.ts +0 -1
  135. package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
  136. package/dist/collections/TagCollection.contract.test.d.ts +0 -1
  137. package/dist/collections/TagCollection.test.d.ts +0 -1
  138. package/dist/expressions/parser.test.d.ts +0 -1
  139. package/dist/expressions/sql.d.ts +0 -28
  140. package/dist/expressions/sql.test.d.ts +0 -1
  141. package/dist/expressions/utils.test.d.ts +0 -1
  142. package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
  143. package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
  144. package/dist/plugins/query/Query.test.d.ts +0 -1
  145. package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
  146. package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
  147. package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
  148. package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
  149. package/dist/results/Result.test.d.ts +0 -1
  150. package/dist/results/utils.test.d.ts +0 -1
  151. package/dist/schema/PropertyInfo.test.d.ts +0 -1
  152. package/dist/schema/communication/broadcast.test.d.ts +0 -1
  153. package/dist/schema/schemaGeneration.test.d.ts +0 -1
  154. package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
  155. package/dist/utilities/arrays.test.d.ts +0 -1
  156. package/dist/utilities/dates.test.d.ts +0 -1
  157. package/dist/utilities/runtime.test.d.ts +0 -1
  158. package/dist/utilities/strings.test.d.ts +0 -1
  159. package/dist/utilities/uuid.test.d.ts +0 -1
@@ -0,0 +1,820 @@
1
+ (() => {
2
+ "use strict";
3
+ var __webpack_modules__ = ({
4
+ 581(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
+ __webpack_require__.d(__webpack_exports__, {
6
+ vF: () => (logger)
7
+ });
8
+ /**
9
+ * Levelled logging, resolved once.
10
+ *
11
+ * Three things about the previous implementation drove this shape:
12
+ *
13
+ * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever
14
+ * compared against `true`, so setting it to `false` did nothing — while
15
+ * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.
16
+ * A documented switch that silently does nothing is worse than no switch.
17
+ * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always
18
+ * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through
19
+ * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also
20
+ * capture console output by snapshotting a stack trace per call, so the cost is far above what
21
+ * writing to a terminal would suggest — and the output buries whatever the failure was.
22
+ * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug
23
+ * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.
24
+ *
25
+ * Levels are compared numerically against a value cached at module load. Measured against a
26
+ * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.
27
+ * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why
28
+ * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —
29
+ * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call
30
+ * site to do it.
31
+ */ /** Ordered from most severe to most verbose. `silent` discards everything. */ const LOG_LEVELS = [
32
+ 'silent',
33
+ 'error',
34
+ 'warn',
35
+ 'info',
36
+ 'debug'
37
+ ];
38
+ /** Numeric rank, so a gate is one integer comparison. */ const RANK = {
39
+ silent: 0,
40
+ error: 1,
41
+ warn: 2,
42
+ info: 3,
43
+ debug: 4
44
+ };
45
+ const isLogLevel = (value)=>typeof value === 'string' && LOG_LEVELS.includes(value);
46
+ /**
47
+ * Resolves the configured level, in precedence order.
48
+ *
49
+ * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an
50
+ * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything
51
+ * unrecognised is ignored rather than treated as an error — a typo'd level should not take down
52
+ * an application, and `silent` is the safe direction to fall back to.
53
+ */ const resolveLevel = ()=>{
54
+ if (typeof globalThis !== 'undefined') {
55
+ const g = globalThis;
56
+ if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {
57
+ return g.__ROUTIER_LOG_LEVEL__;
58
+ }
59
+ // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks
60
+ // below and re-enable the logging it was asked to suppress.
61
+ if (g.__ROUTIER_DEBUG__ === true) return 'debug';
62
+ if (g.__ROUTIER_DEBUG__ === false) return 'silent';
63
+ }
64
+ // There is deliberately no `import.meta.env` branch, although the documentation used to
65
+ // promise one. It could never work: this package is bundled with rspack, which replaces
66
+ // `import.meta` with `undefined`, so the check would read the *library's* build-time
67
+ // environment rather than the application's — and referencing `import.meta` at all is a parse
68
+ // error under a CommonJS build target, which is how the test suite loads this file. Vite and
69
+ // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own
70
+ // `import.meta.env`, which is what the docs now describe.
71
+ if (typeof process !== 'undefined' && process.env != null) {
72
+ if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {
73
+ return process.env.ROUTIER_LOG_LEVEL;
74
+ }
75
+ const debug = process.env.DEBUG;
76
+ if (debug === 'routier' || debug === '*') return 'debug';
77
+ const env = "production"?.toLowerCase();
78
+ // `test` is deliberately absent. It used to be here, which meant no test suite anywhere
79
+ // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test
80
+ // needs the output.
81
+ if (env === 'dev' || env === 'development') return 'debug';
82
+ }
83
+ return 'silent';
84
+ };
85
+ let level = resolveLevel();
86
+ let rank = RANK[level];
87
+ /**
88
+ * Overrides the level for the rest of the process.
89
+ *
90
+ * The configuration above is read once, at import, which is what makes the gate cheap — but it
91
+ * also means an application that decides its verbosity after startup, or a test that wants to
92
+ * assert on output, has no way in. This is that way in.
93
+ */ const setLogLevel = (next)=>{
94
+ if (isLogLevel(next) === false) {
95
+ throw new Error(`Unknown log level "${next}". Expected one of: ${LOG_LEVELS.join(', ')}`);
96
+ }
97
+ level = next;
98
+ rank = RANK[next];
99
+ };
100
+ const getLogLevel = ()=>level;
101
+ /** Re-reads the environment. For tests that change it after this module was imported. */ const resetLogLevel = ()=>{
102
+ level = resolveLevel();
103
+ rank = RANK[level];
104
+ };
105
+ /**
106
+ * Whether a message at this level would be emitted.
107
+ *
108
+ * For the rare call site whose *arguments* are expensive to build — a serialization, a deep
109
+ * clone, a join over a large collection. An ordinary payload object is not worth guarding; see
110
+ * the measurement in the header.
111
+ */ const isLogLevelEnabled = (at)=>rank >= RANK[at];
112
+ const emit = (at, method, args)=>{
113
+ if (rank < RANK[at]) {
114
+ return;
115
+ }
116
+ // Resolved at call time rather than captured once: test harnesses and browser devtools both
117
+ // replace console methods after modules have loaded, and a captured reference would keep
118
+ // writing past the replacement.
119
+ console[method](...args);
120
+ };
121
+ const logger = {
122
+ /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */ log: (...args)=>emit('info', 'log', args),
123
+ info: (...args)=>emit('info', 'info', args),
124
+ warn: (...args)=>emit('warn', 'warn', args),
125
+ error: (...args)=>emit('error', 'error', args),
126
+ debug: (...args)=>emit('debug', 'debug', args),
127
+ /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */ table: (...args)=>emit('debug', 'table', args)
128
+ };
129
+
130
+
131
+ },
132
+ 615(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
133
+ __webpack_require__.d(__webpack_exports__, {
134
+ Zm: () => (stringifyObject)
135
+ });
136
+ const hash = (value, seed = 0)=>{
137
+ // From Stack Overflow
138
+ // https://stackoverflow.com/a/52171480/3329760
139
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
140
+ for(let i = 0, ch; i < value.length; i++){
141
+ ch = value.charCodeAt(i);
142
+ h1 = Math.imul(h1 ^ ch, 2654435761);
143
+ h2 = Math.imul(h2 ^ ch, 1597334677);
144
+ }
145
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
146
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
147
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
148
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
149
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
150
+ };
151
+ /**
152
+ * Fast string hash optimized for comparisons.
153
+ * Uses djb2 algorithm - very fast and good distribution for short to medium strings.
154
+ * Same input always produces same output (deterministic).
155
+ *
156
+ * @param value - The string to hash
157
+ * @param seed - Optional seed value (default: 5381)
158
+ * @returns A positive 32-bit integer hash value
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * fastHash("test") === fastHash("test") // true
163
+ * fastHash("test") !== fastHash("test2") // true
164
+ * ```
165
+ */ const fastHash = (value, seed = 5381)=>{
166
+ let hash = seed;
167
+ for(let i = 0; i < value.length; i++){
168
+ hash = (hash << 5) + hash + value.charCodeAt(i);
169
+ }
170
+ return hash >>> 0; // Convert to unsigned 32-bit integer
171
+ };
172
+ /**
173
+ * Converts any value to a readable string representation.
174
+ * Handles primitives, objects, arrays, classes, dates, errors, and functions.
175
+ * Supports depth limiting to prevent infinite recursion on circular references.
176
+ *
177
+ * @param obj - The value to stringify
178
+ * @param maxDepth - Maximum depth for nested objects (default: 3)
179
+ * @param currentDepth - Current recursion depth (default: 0)
180
+ * @returns String representation of the value
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * stringifyObject({ name: "test", count: 5 }) // '{ name: "test", count: 5 }'
185
+ * stringifyObject([1, 2, 3]) // '[1, 2, 3]'
186
+ * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'
187
+ * ```
188
+ */ function stringifyObject(obj, maxDepth = 3, currentDepth = 0) {
189
+ if (obj === null) return 'null';
190
+ if (obj === undefined) return 'undefined';
191
+ const type = typeof obj;
192
+ switch(type){
193
+ case 'string':
194
+ return `"${obj}"`;
195
+ case 'number':
196
+ case 'boolean':
197
+ return String(obj);
198
+ case 'function':
199
+ return `[Function: ${getFunctionName(obj)}]`;
200
+ case 'object':
201
+ if (currentDepth >= maxDepth) {
202
+ return '[Max Depth Reached]';
203
+ }
204
+ return stringifyObjectValue(obj, maxDepth, currentDepth);
205
+ default:
206
+ return `[${type}]`;
207
+ }
208
+ }
209
+ function getFunctionName(fn) {
210
+ const name = fn.name;
211
+ return name || 'anonymous';
212
+ }
213
+ function getObjectProperties(obj) {
214
+ const properties = {};
215
+ for(const key in obj){
216
+ if (obj.hasOwnProperty(key)) {
217
+ properties[key] = obj[key];
218
+ }
219
+ }
220
+ return properties;
221
+ }
222
+ function stringifyObjectValue(obj, maxDepth, currentDepth) {
223
+ if (obj === null) return 'null';
224
+ if (obj instanceof Date) {
225
+ return `Date(${obj.toISOString()})`;
226
+ }
227
+ if (obj instanceof Error) {
228
+ return `Error(${obj.message})`;
229
+ }
230
+ if (obj instanceof RegExp) {
231
+ return obj.toString();
232
+ }
233
+ if (Array.isArray(obj)) {
234
+ return stringifyArray(obj, maxDepth, currentDepth);
235
+ }
236
+ if (obj.constructor && obj.constructor.name !== 'Object') {
237
+ return stringifyClassInstance(obj, maxDepth, currentDepth);
238
+ }
239
+ return stringifyPlainObject(obj, maxDepth, currentDepth);
240
+ }
241
+ function stringifyArray(arr, maxDepth, currentDepth) {
242
+ if (arr.length === 0) return '[]';
243
+ const items = arr.slice(0, 5).map((item)=>stringifyObject(item, maxDepth, currentDepth + 1));
244
+ const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';
245
+ return `[${items.join(', ')}${suffix}]`;
246
+ }
247
+ function stringifyClassInstance(obj, maxDepth, currentDepth) {
248
+ const className = obj.constructor.name;
249
+ const properties = getObjectProperties(obj);
250
+ if (Object.keys(properties).length === 0) {
251
+ return `${className} {}`;
252
+ }
253
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
254
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
255
+ const depth = isPrimitive ? currentDepth : currentDepth + 1;
256
+ return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
257
+ });
258
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
259
+ return `${className} { ${props.join(', ')}${suffix} }`;
260
+ }
261
+ function stringifyPlainObject(obj, maxDepth, currentDepth) {
262
+ const properties = getObjectProperties(obj);
263
+ if (Object.keys(properties).length === 0) {
264
+ return '{}';
265
+ }
266
+ const props = Object.entries(properties).slice(0, 5).map(([key, value])=>{
267
+ const isPrimitive = value === null || value === undefined || typeof value !== 'object' && typeof value !== 'function';
268
+ const depth = isPrimitive ? currentDepth : currentDepth + 1;
269
+ return `${key}: ${stringifyObject(value, maxDepth, depth)}`;
270
+ });
271
+ const suffix = Object.keys(properties).length > 5 ? `... (+${Object.keys(properties).length - 5} more)` : '';
272
+ return `{ ${props.join(', ')}${suffix} }`;
273
+ }
274
+
275
+
276
+ },
277
+ 618(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
278
+ __webpack_require__.d(__webpack_exports__, {
279
+ u: () => (uuid)
280
+ });
281
+ const uuid = (length = 16)=>{
282
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
283
+ const charLength = chars.length;
284
+ let result = '';
285
+ for(let i = 0; i < length; i++){
286
+ result += chars[Math.random() * charLength | 0];
287
+ }
288
+ return result;
289
+ };
290
+ const HEX_CHARS = '0123456789abcdef';
291
+ const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
292
+ const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
293
+ const hasRandomUUID = typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
294
+ const uuidv4 = ()=>{
295
+ if (hasRandomUUID) {
296
+ return crypto.randomUUID();
297
+ }
298
+ return uuidv4Fallback();
299
+ };
300
+ const uuidv4Fallback = ()=>{
301
+ let randomBytes = null;
302
+ if (hasCrypto) {
303
+ randomBytes = crypto.getRandomValues(new Uint8Array(16));
304
+ }
305
+ let byteIndex = 0;
306
+ let uuid = '';
307
+ for(let i = 0; i < UUID_TEMPLATE.length; i++){
308
+ const c = UUID_TEMPLATE[i];
309
+ if (c === '-') {
310
+ uuid += '-';
311
+ continue;
312
+ }
313
+ let r;
314
+ if (hasCrypto && randomBytes) {
315
+ // Each byte gives two hex digits (nibbles)
316
+ r = i % 2 === 0 ? randomBytes[byteIndex] >> 4 : randomBytes[byteIndex++] & 0x0f;
317
+ } else {
318
+ r = Math.floor(Math.random() * 16);
319
+ }
320
+ if (c === 'x') {
321
+ uuid += HEX_CHARS[r];
322
+ } else if (c === 'y') {
323
+ // Variant bits: 8, 9, A, or B
324
+ uuid += HEX_CHARS[r & 0x3 | 0x8];
325
+ } else if (c === '4') {
326
+ uuid += '4';
327
+ }
328
+ }
329
+ return uuid;
330
+ };
331
+
332
+
333
+ },
334
+
335
+ });
336
+ // The module cache
337
+ var __webpack_module_cache__ = {};
338
+
339
+ // The require function
340
+ function __webpack_require__(moduleId) {
341
+
342
+ // Check if module is in cache
343
+ var cachedModule = __webpack_module_cache__[moduleId];
344
+ if (cachedModule !== undefined) {
345
+ return cachedModule.exports;
346
+ }
347
+ // Create a new module (and put it into the cache)
348
+ var module = (__webpack_module_cache__[moduleId] = {
349
+ exports: {}
350
+ });
351
+ // Execute the module function
352
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
353
+
354
+ // Return the exports of the module
355
+ return module.exports;
356
+
357
+ }
358
+
359
+ // webpack/runtime/define_property_getters
360
+ (() => {
361
+ __webpack_require__.d = (exports, definition) => {
362
+ for(var key in definition) {
363
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
364
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
365
+ }
366
+ }
367
+ };
368
+ })();
369
+ // webpack/runtime/has_own_property
370
+ (() => {
371
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
372
+ })();
373
+ // webpack/runtime/make_namespace_object
374
+ (() => {
375
+ // define __esModule on exports
376
+ __webpack_require__.r = (exports) => {
377
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
378
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
379
+ }
380
+ Object.defineProperty(exports, '__esModule', { value: true });
381
+ };
382
+ })();
383
+ var __webpack_exports__ = {};
384
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
385
+ (() => {
386
+ // ESM COMPAT FLAG
387
+ __webpack_require__.r(__webpack_exports__);
388
+
389
+ // EXPORTS
390
+ __webpack_require__.d(__webpack_exports__, {
391
+ TracingCapability: () => (/* reexport */ TracingCapability),
392
+ Capability: () => (/* reexport */ Capability),
393
+ PerformanceCapability: () => (/* reexport */ PerformanceCapability)
394
+ });
395
+
396
+ ;// CONCATENATED MODULE: ./src/capabilities/Capability.ts
397
+ class Capability {
398
+ excludedNames = new Set([
399
+ "Array",
400
+ "Set",
401
+ "Map",
402
+ "AbortController",
403
+ "AbortSignal",
404
+ "SchemaString",
405
+ "SchemaNumber",
406
+ "SchemaArray",
407
+ "SchemaBoolean",
408
+ "SchemaDate",
409
+ "SchemaObject",
410
+ "SchemaDefault",
411
+ "SchemaDeserialize",
412
+ "SchemaDistinct",
413
+ "SchemaSearchable",
414
+ "SchemaFrom",
415
+ "SchemaIdentity",
416
+ "SchemaIndex",
417
+ "SchemaKey",
418
+ "SchemaNullable",
419
+ "SchemaOptional",
420
+ "SchemaReadonly",
421
+ "SchemaSerialize",
422
+ "SchemaTracked",
423
+ "SchemaComputed",
424
+ "SchemaFunction",
425
+ "SchemaBase",
426
+ "SchemaDefinition"
427
+ ]);
428
+ isValidObject(obj) {
429
+ return typeof obj === "object" && obj !== null;
430
+ }
431
+ isCallableMethod(descriptor, key) {
432
+ return descriptor?.value && typeof descriptor.value === 'function' && key !== 'constructor' && key !== 'undefined';
433
+ }
434
+ canExplore(descriptor) {
435
+ if (typeof descriptor.value !== "object") {
436
+ return false;
437
+ }
438
+ if (descriptor.value == null) {
439
+ return false;
440
+ }
441
+ const name = this.getName(descriptor.value);
442
+ if (name == null) {
443
+ return true;
444
+ }
445
+ return this.excludedNames.has(name) === false;
446
+ }
447
+ getName(value) {
448
+ if (value.constructor != null) {
449
+ return value.constructor.name;
450
+ }
451
+ return null;
452
+ }
453
+ getPath(info, propertyName) {
454
+ let parent = info.parent;
455
+ const path = [
456
+ info.propertyName,
457
+ propertyName
458
+ ];
459
+ while(parent != null){
460
+ path.unshift(parent.propertyName);
461
+ parent = parent.parent;
462
+ }
463
+ return path.join(".");
464
+ }
465
+ explore(instance, onDiscover) {
466
+ if (!this.isValidObject(instance)) {
467
+ return;
468
+ }
469
+ const explore = [
470
+ {
471
+ instance,
472
+ propertyName: this.getName(instance)
473
+ }
474
+ ];
475
+ const visited = new Set();
476
+ for(let i = 0; i < explore.length; i++){
477
+ const info = explore[i];
478
+ const item = info.instance;
479
+ if (visited.has(item)) {
480
+ continue;
481
+ }
482
+ const allKeys = [
483
+ ...Object.getOwnPropertyNames(item),
484
+ ...Object.getOwnPropertySymbols(item)
485
+ ];
486
+ for (const key of allKeys){
487
+ const descriptor = Object.getOwnPropertyDescriptor(item, key);
488
+ const isCallable = this.isCallableMethod(descriptor, key);
489
+ onDiscover(info, {
490
+ name: key,
491
+ isCallable
492
+ });
493
+ if (this.canExplore(descriptor) === false) {
494
+ continue;
495
+ }
496
+ const path = this.getPath(info, key);
497
+ explore.push({
498
+ instance: descriptor.value,
499
+ parent: info,
500
+ propertyName: key,
501
+ path
502
+ });
503
+ }
504
+ visited.add(item);
505
+ }
506
+ }
507
+ }
508
+
509
+ // EXTERNAL MODULE: ./src/utilities/strings.ts
510
+ var strings = __webpack_require__(615);
511
+ ;// CONCATENATED MODULE: ./src/capabilities/performance/PerformanceTracker.ts
512
+ class PerformanceTracker {
513
+ methodTimings = new Map();
514
+ operationStartTimes = new Map();
515
+ startMethodTiming(operationId, methodPath) {
516
+ const startTime = performance.now();
517
+ const key = `${operationId}:${methodPath}`;
518
+ // Track operation start time for delta calculations
519
+ if (!this.operationStartTimes.has(operationId)) {
520
+ this.operationStartTimes.set(operationId, startTime);
521
+ }
522
+ this.methodTimings.set(key, {
523
+ startTime
524
+ });
525
+ return startTime;
526
+ }
527
+ recordNextMethodStart(operationId, methodPath) {
528
+ const key = `${operationId}:${methodPath}`;
529
+ const timing = this.methodTimings.get(key);
530
+ if (timing) {
531
+ timing.nextMethodStartTime = performance.now();
532
+ }
533
+ }
534
+ endMethodTiming(operationId, methodPath) {
535
+ const endTime = performance.now();
536
+ const key = `${operationId}:${methodPath}`;
537
+ const timing = this.methodTimings.get(key);
538
+ if (!timing) {
539
+ return {
540
+ startTime: endTime
541
+ };
542
+ }
543
+ const duration = endTime - timing.startTime;
544
+ const timeToNextCall = timing.nextMethodStartTime ? timing.nextMethodStartTime - timing.startTime : undefined;
545
+ // Clean up
546
+ this.methodTimings.delete(key);
547
+ return {
548
+ startTime: timing.startTime,
549
+ endTime,
550
+ duration,
551
+ nextMethodStartTime: timing.nextMethodStartTime,
552
+ timeToNextCall
553
+ };
554
+ }
555
+ formatDuration(milliseconds) {
556
+ if (milliseconds < 1) {
557
+ return `${(milliseconds * 1000).toFixed(1)}μs`;
558
+ } else if (milliseconds < 1000) {
559
+ return `${milliseconds.toFixed(2)}ms`;
560
+ } else {
561
+ return `${(milliseconds / 1000).toFixed(2)}s`;
562
+ }
563
+ }
564
+ getDeltaFromOperationStart(operationId, currentTime) {
565
+ const operationStartTime = this.operationStartTimes.get(operationId);
566
+ return operationStartTime ? currentTime - operationStartTime : 0;
567
+ }
568
+ cleanupOperation(operationId) {
569
+ this.operationStartTimes.delete(operationId);
570
+ }
571
+ }
572
+
573
+ // EXTERNAL MODULE: ./src/utilities/uuid.ts
574
+ var uuid = __webpack_require__(618);
575
+ ;// CONCATENATED MODULE: ./src/capabilities/tracing/CallTraceManager.ts
576
+
577
+ class CallTraceManager {
578
+ activeOperationId = null;
579
+ activeCallStack = [];
580
+ startNewOperation() {
581
+ const operationId = (0,uuid/* .uuid */.u)(8);
582
+ this.activeOperationId = operationId;
583
+ this.activeCallStack = [];
584
+ return operationId;
585
+ }
586
+ isNewOperation() {
587
+ return this.activeOperationId === null;
588
+ }
589
+ getActiveOperationId() {
590
+ if (!this.activeOperationId) {
591
+ throw new Error('No active operation context');
592
+ }
593
+ return this.activeOperationId;
594
+ }
595
+ addMethodToTrace(methodPath) {
596
+ if (this.isNewOperation()) {
597
+ this.activeCallStack = [
598
+ methodPath
599
+ ];
600
+ } else {
601
+ this.activeCallStack.push(methodPath);
602
+ }
603
+ return [
604
+ ...this.activeCallStack
605
+ ];
606
+ }
607
+ removeMethodFromTrace() {
608
+ if (!this.isNewOperation()) {
609
+ this.activeCallStack.pop();
610
+ }
611
+ }
612
+ endOperation() {
613
+ this.activeOperationId = null;
614
+ this.activeCallStack = [];
615
+ }
616
+ formatMethodPaths(methodPaths) {
617
+ return methodPaths.map((path)=>path.replace(/ → /g, '.'));
618
+ }
619
+ getCurrentTrace() {
620
+ return [
621
+ ...this.activeCallStack
622
+ ];
623
+ }
624
+ }
625
+
626
+ // EXTERNAL MODULE: ./src/utilities/logger.ts
627
+ var logger = __webpack_require__(581);
628
+ ;// CONCATENATED MODULE: ./src/capabilities/PerformanceCapability.ts
629
+
630
+
631
+
632
+
633
+
634
+ class PerformanceCapability extends Capability {
635
+ callTraceManager;
636
+ performanceTracker;
637
+ filter;
638
+ childDurations = new Map();
639
+ constructor(options){
640
+ super();
641
+ this.filter = options?.filter ?? (()=>true);
642
+ this.callTraceManager = new CallTraceManager();
643
+ this.performanceTracker = new PerformanceTracker();
644
+ }
645
+ apply(instance) {
646
+ this.explore(instance, (meta, info)=>{
647
+ if (info.isCallable) {
648
+ const originalMethod = meta.instance[info.name].bind(meta.instance);
649
+ meta.instance[info.name] = (...args)=>{
650
+ const path = `${meta.path}.${String(info.name)}()`;
651
+ if (this.filter(path, info, meta) === false) {
652
+ return originalMethod(...args);
653
+ }
654
+ const isNewOperation = this.callTraceManager.isNewOperation();
655
+ let operationId;
656
+ let callTrace;
657
+ let depth;
658
+ if (isNewOperation) {
659
+ operationId = this.callTraceManager.startNewOperation();
660
+ this.childDurations.set(operationId, []);
661
+ callTrace = this.callTraceManager.addMethodToTrace(path);
662
+ depth = callTrace.length - 1;
663
+ const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
664
+ this.performanceTracker.startMethodTiming(operationId, path);
665
+ logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
666
+ logger/* .logger.log */.vF.log(`▶ ORIGIN [${operationId}] ${path}`);
667
+ if (args.length > 0) {
668
+ logger/* .logger.log */.vF.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
669
+ }
670
+ logger/* .logger.log */.vF.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
671
+ } else {
672
+ operationId = this.callTraceManager.getActiveOperationId();
673
+ callTrace = this.callTraceManager.addMethodToTrace(path);
674
+ depth = callTrace.length - 1;
675
+ const indent = ' '.repeat(Math.min(depth, 4));
676
+ // Track children for this child method too
677
+ const childMethodKey = `${operationId}:${path}`;
678
+ this.childDurations.set(childMethodKey, []);
679
+ this.performanceTracker.startMethodTiming(operationId, path);
680
+ logger/* .logger.log */.vF.log(`${indent}└─ CHILD [${operationId}] ${path}`);
681
+ if (args.length > 0) {
682
+ logger/* .logger.log */.vF.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
683
+ }
684
+ }
685
+ try {
686
+ return originalMethod(...args);
687
+ } finally{
688
+ const metrics = this.performanceTracker.endMethodTiming(operationId, path);
689
+ const duration = metrics.duration ?? 0;
690
+ const formattedDuration = this.performanceTracker.formatDuration(duration);
691
+ if (isNewOperation) {
692
+ const childDurations = this.childDurations.get(operationId) ?? [];
693
+ const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
694
+ const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
695
+ const overhead = duration - totalChildTime;
696
+ const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
697
+ logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
698
+ logger/* .logger.log */.vF.log(`◀ COMPLETE [${operationId}] ${path}`);
699
+ logger/* .logger.log */.vF.log(` Total Duration: ${formattedDuration}`);
700
+ if (childDurations.length > 0) {
701
+ logger/* .logger.log */.vF.log(` Children Duration: ${formattedTotalChildTime} (${childDurations.length} calls)`);
702
+ logger/* .logger.log */.vF.log(` Overhead: ${formattedOverhead}`);
703
+ }
704
+ logger/* .logger.log */.vF.log(`${'═'.repeat(60)}\n`);
705
+ this.childDurations.delete(operationId);
706
+ this.performanceTracker.cleanupOperation(operationId);
707
+ this.callTraceManager.endOperation();
708
+ } else {
709
+ const indent = ' '.repeat(Math.min(depth, 4));
710
+ const childMethodKey = `${operationId}:${path}`;
711
+ const childDurations = this.childDurations.get(childMethodKey) ?? [];
712
+ const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
713
+ const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
714
+ const overhead = duration - totalChildTime;
715
+ const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
716
+ logger/* .logger.log */.vF.log(`${indent} ✓ ${formattedDuration}`);
717
+ if (childDurations.length > 0) {
718
+ logger/* .logger.log */.vF.log(`${indent} Children: ${formattedTotalChildTime} (${childDurations.length} calls), Overhead: ${formattedOverhead}`);
719
+ }
720
+ // Clean up child method tracking
721
+ this.childDurations.delete(childMethodKey);
722
+ // Find the parent method and add this duration to its children list
723
+ // The parent is the method one level up in the call trace
724
+ const currentTrace = this.callTraceManager.getCurrentTrace();
725
+ if (currentTrace.length > 1) {
726
+ // Parent is the second-to-last item in the trace (before we remove current)
727
+ const parentPath = currentTrace[currentTrace.length - 2];
728
+ // Check if parent is the root operation (trace length 2 means root + this child)
729
+ if (currentTrace.length === 2) {
730
+ // Direct child of root - add to root's children list
731
+ const rootChildDurations = this.childDurations.get(operationId);
732
+ if (rootChildDurations) {
733
+ rootChildDurations.push(duration);
734
+ }
735
+ } else {
736
+ // Nested child - add to parent method's children list
737
+ const parentMethodKey = `${operationId}:${parentPath}`;
738
+ const parentChildDurations = this.childDurations.get(parentMethodKey);
739
+ if (parentChildDurations) {
740
+ parentChildDurations.push(duration);
741
+ }
742
+ }
743
+ }
744
+ }
745
+ this.callTraceManager.removeMethodFromTrace();
746
+ }
747
+ };
748
+ }
749
+ });
750
+ }
751
+ }
752
+
753
+ ;// CONCATENATED MODULE: ./src/capabilities/TracingCapability.ts
754
+
755
+
756
+
757
+ class TracingCapability extends Capability {
758
+ callTraceManager;
759
+ filter;
760
+ constructor(options){
761
+ super();
762
+ this.filter = options?.filter ?? (()=>true);
763
+ this.callTraceManager = new CallTraceManager();
764
+ }
765
+ apply(instance) {
766
+ this.explore(instance, (meta, info)=>{
767
+ if (info.isCallable) {
768
+ const originalMethod = meta.instance[info.name].bind(meta.instance);
769
+ meta.instance[info.name] = (...args)=>{
770
+ const path = `${meta.path}.${String(info.name)}()`;
771
+ if (this.filter(path, info, meta) === false) {
772
+ return originalMethod(...args);
773
+ }
774
+ const isNewOperation = this.callTraceManager.isNewOperation();
775
+ let operationId;
776
+ if (isNewOperation) {
777
+ operationId = this.callTraceManager.startNewOperation();
778
+ const callTrace = this.callTraceManager.addMethodToTrace(path);
779
+ const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
780
+ console.log(`\n${'═'.repeat(60)}`);
781
+ console.log(`▶ ORIGIN [${operationId}] ${path}`);
782
+ if (args.length > 0) {
783
+ console.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
784
+ }
785
+ console.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
786
+ } else {
787
+ operationId = this.callTraceManager.getActiveOperationId();
788
+ const callTrace = this.callTraceManager.addMethodToTrace(path);
789
+ const indent = ' '.repeat(Math.min(callTrace.length - 1, 4));
790
+ console.log(`${indent}└─ CHILD [${operationId}] ${path}`);
791
+ if (args.length > 0) {
792
+ console.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
793
+ }
794
+ }
795
+ try {
796
+ return originalMethod(...args);
797
+ } finally{
798
+ this.callTraceManager.removeMethodFromTrace();
799
+ if (isNewOperation) {
800
+ this.callTraceManager.endOperation();
801
+ }
802
+ }
803
+ };
804
+ }
805
+ });
806
+ }
807
+ }
808
+
809
+ ;// CONCATENATED MODULE: ./src/capabilities/index.ts
810
+
811
+
812
+
813
+
814
+
815
+ })();
816
+
817
+ module.exports = __webpack_exports__;
818
+ })()
819
+ ;
820
+ //# sourceMappingURL=index.cjs.map