@routier/core 0.4.0 → 0.5.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.
- package/dist/index.cjs +73 -438
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +78 -443
- package/dist/index.js.map +1 -1
- package/dist/plugins/TelemetryDbPlugin.d.ts +43 -0
- package/dist/plugins/index.cjs +68 -1
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +73 -3
- package/dist/plugins/index.js.map +1 -1
- package/package.json +1 -9
- package/dist/capabilities/Capability.d.ts +0 -11
- package/dist/capabilities/PerformanceCapability.d.ts +0 -13
- package/dist/capabilities/TracingCapability.d.ts +0 -11
- package/dist/capabilities/index.cjs +0 -820
- package/dist/capabilities/index.cjs.map +0 -1
- package/dist/capabilities/index.d.ts +0 -4
- package/dist/capabilities/index.js +0 -808
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/performance/PerformanceTracker.d.ts +0 -11
- package/dist/capabilities/tracing/CallTraceManager.d.ts +0 -12
- package/dist/capabilities/types.d.ts +0 -17
package/dist/index.cjs
CHANGED
|
@@ -101,436 +101,6 @@ function isObjectWithType(value) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
},
|
|
105
|
-
599(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
106
|
-
|
|
107
|
-
// EXPORTS
|
|
108
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
109
|
-
TracingCapability: () => (/* reexport */ TracingCapability),
|
|
110
|
-
Capability: () => (/* reexport */ Capability),
|
|
111
|
-
PerformanceCapability: () => (/* reexport */ PerformanceCapability)
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
;// CONCATENATED MODULE: ./src/capabilities/Capability.ts
|
|
115
|
-
class Capability {
|
|
116
|
-
excludedNames = new Set([
|
|
117
|
-
"Array",
|
|
118
|
-
"Set",
|
|
119
|
-
"Map",
|
|
120
|
-
"AbortController",
|
|
121
|
-
"AbortSignal",
|
|
122
|
-
"SchemaString",
|
|
123
|
-
"SchemaNumber",
|
|
124
|
-
"SchemaArray",
|
|
125
|
-
"SchemaBoolean",
|
|
126
|
-
"SchemaDate",
|
|
127
|
-
"SchemaObject",
|
|
128
|
-
"SchemaDefault",
|
|
129
|
-
"SchemaDeserialize",
|
|
130
|
-
"SchemaDistinct",
|
|
131
|
-
"SchemaSearchable",
|
|
132
|
-
"SchemaFrom",
|
|
133
|
-
"SchemaIdentity",
|
|
134
|
-
"SchemaIndex",
|
|
135
|
-
"SchemaKey",
|
|
136
|
-
"SchemaNullable",
|
|
137
|
-
"SchemaOptional",
|
|
138
|
-
"SchemaReadonly",
|
|
139
|
-
"SchemaSerialize",
|
|
140
|
-
"SchemaTracked",
|
|
141
|
-
"SchemaComputed",
|
|
142
|
-
"SchemaFunction",
|
|
143
|
-
"SchemaBase",
|
|
144
|
-
"SchemaDefinition"
|
|
145
|
-
]);
|
|
146
|
-
isValidObject(obj) {
|
|
147
|
-
return typeof obj === "object" && obj !== null;
|
|
148
|
-
}
|
|
149
|
-
isCallableMethod(descriptor, key) {
|
|
150
|
-
return descriptor?.value && typeof descriptor.value === 'function' && key !== 'constructor' && key !== 'undefined';
|
|
151
|
-
}
|
|
152
|
-
canExplore(descriptor) {
|
|
153
|
-
if (typeof descriptor.value !== "object") {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
if (descriptor.value == null) {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
const name = this.getName(descriptor.value);
|
|
160
|
-
if (name == null) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
return this.excludedNames.has(name) === false;
|
|
164
|
-
}
|
|
165
|
-
getName(value) {
|
|
166
|
-
if (value.constructor != null) {
|
|
167
|
-
return value.constructor.name;
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
getPath(info, propertyName) {
|
|
172
|
-
let parent = info.parent;
|
|
173
|
-
const path = [
|
|
174
|
-
info.propertyName,
|
|
175
|
-
propertyName
|
|
176
|
-
];
|
|
177
|
-
while(parent != null){
|
|
178
|
-
path.unshift(parent.propertyName);
|
|
179
|
-
parent = parent.parent;
|
|
180
|
-
}
|
|
181
|
-
return path.join(".");
|
|
182
|
-
}
|
|
183
|
-
explore(instance, onDiscover) {
|
|
184
|
-
if (!this.isValidObject(instance)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const explore = [
|
|
188
|
-
{
|
|
189
|
-
instance,
|
|
190
|
-
propertyName: this.getName(instance)
|
|
191
|
-
}
|
|
192
|
-
];
|
|
193
|
-
const visited = new Set();
|
|
194
|
-
for(let i = 0; i < explore.length; i++){
|
|
195
|
-
const info = explore[i];
|
|
196
|
-
const item = info.instance;
|
|
197
|
-
if (visited.has(item)) {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const allKeys = [
|
|
201
|
-
...Object.getOwnPropertyNames(item),
|
|
202
|
-
...Object.getOwnPropertySymbols(item)
|
|
203
|
-
];
|
|
204
|
-
for (const key of allKeys){
|
|
205
|
-
const descriptor = Object.getOwnPropertyDescriptor(item, key);
|
|
206
|
-
const isCallable = this.isCallableMethod(descriptor, key);
|
|
207
|
-
onDiscover(info, {
|
|
208
|
-
name: key,
|
|
209
|
-
isCallable
|
|
210
|
-
});
|
|
211
|
-
if (this.canExplore(descriptor) === false) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const path = this.getPath(info, key);
|
|
215
|
-
explore.push({
|
|
216
|
-
instance: descriptor.value,
|
|
217
|
-
parent: info,
|
|
218
|
-
propertyName: key,
|
|
219
|
-
path
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
visited.add(item);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// EXTERNAL MODULE: ./src/utilities/strings.ts
|
|
228
|
-
var strings = __webpack_require__(615);
|
|
229
|
-
;// CONCATENATED MODULE: ./src/capabilities/performance/PerformanceTracker.ts
|
|
230
|
-
class PerformanceTracker {
|
|
231
|
-
methodTimings = new Map();
|
|
232
|
-
operationStartTimes = new Map();
|
|
233
|
-
startMethodTiming(operationId, methodPath) {
|
|
234
|
-
const startTime = performance.now();
|
|
235
|
-
const key = `${operationId}:${methodPath}`;
|
|
236
|
-
// Track operation start time for delta calculations
|
|
237
|
-
if (!this.operationStartTimes.has(operationId)) {
|
|
238
|
-
this.operationStartTimes.set(operationId, startTime);
|
|
239
|
-
}
|
|
240
|
-
this.methodTimings.set(key, {
|
|
241
|
-
startTime
|
|
242
|
-
});
|
|
243
|
-
return startTime;
|
|
244
|
-
}
|
|
245
|
-
recordNextMethodStart(operationId, methodPath) {
|
|
246
|
-
const key = `${operationId}:${methodPath}`;
|
|
247
|
-
const timing = this.methodTimings.get(key);
|
|
248
|
-
if (timing) {
|
|
249
|
-
timing.nextMethodStartTime = performance.now();
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
endMethodTiming(operationId, methodPath) {
|
|
253
|
-
const endTime = performance.now();
|
|
254
|
-
const key = `${operationId}:${methodPath}`;
|
|
255
|
-
const timing = this.methodTimings.get(key);
|
|
256
|
-
if (!timing) {
|
|
257
|
-
return {
|
|
258
|
-
startTime: endTime
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
const duration = endTime - timing.startTime;
|
|
262
|
-
const timeToNextCall = timing.nextMethodStartTime ? timing.nextMethodStartTime - timing.startTime : undefined;
|
|
263
|
-
// Clean up
|
|
264
|
-
this.methodTimings.delete(key);
|
|
265
|
-
return {
|
|
266
|
-
startTime: timing.startTime,
|
|
267
|
-
endTime,
|
|
268
|
-
duration,
|
|
269
|
-
nextMethodStartTime: timing.nextMethodStartTime,
|
|
270
|
-
timeToNextCall
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
formatDuration(milliseconds) {
|
|
274
|
-
if (milliseconds < 1) {
|
|
275
|
-
return `${(milliseconds * 1000).toFixed(1)}μs`;
|
|
276
|
-
} else if (milliseconds < 1000) {
|
|
277
|
-
return `${milliseconds.toFixed(2)}ms`;
|
|
278
|
-
} else {
|
|
279
|
-
return `${(milliseconds / 1000).toFixed(2)}s`;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
getDeltaFromOperationStart(operationId, currentTime) {
|
|
283
|
-
const operationStartTime = this.operationStartTimes.get(operationId);
|
|
284
|
-
return operationStartTime ? currentTime - operationStartTime : 0;
|
|
285
|
-
}
|
|
286
|
-
cleanupOperation(operationId) {
|
|
287
|
-
this.operationStartTimes.delete(operationId);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// EXTERNAL MODULE: ./src/utilities/uuid.ts
|
|
292
|
-
var uuid = __webpack_require__(618);
|
|
293
|
-
;// CONCATENATED MODULE: ./src/capabilities/tracing/CallTraceManager.ts
|
|
294
|
-
|
|
295
|
-
class CallTraceManager {
|
|
296
|
-
activeOperationId = null;
|
|
297
|
-
activeCallStack = [];
|
|
298
|
-
startNewOperation() {
|
|
299
|
-
const operationId = (0,uuid/* .uuid */.u)(8);
|
|
300
|
-
this.activeOperationId = operationId;
|
|
301
|
-
this.activeCallStack = [];
|
|
302
|
-
return operationId;
|
|
303
|
-
}
|
|
304
|
-
isNewOperation() {
|
|
305
|
-
return this.activeOperationId === null;
|
|
306
|
-
}
|
|
307
|
-
getActiveOperationId() {
|
|
308
|
-
if (!this.activeOperationId) {
|
|
309
|
-
throw new Error('No active operation context');
|
|
310
|
-
}
|
|
311
|
-
return this.activeOperationId;
|
|
312
|
-
}
|
|
313
|
-
addMethodToTrace(methodPath) {
|
|
314
|
-
if (this.isNewOperation()) {
|
|
315
|
-
this.activeCallStack = [
|
|
316
|
-
methodPath
|
|
317
|
-
];
|
|
318
|
-
} else {
|
|
319
|
-
this.activeCallStack.push(methodPath);
|
|
320
|
-
}
|
|
321
|
-
return [
|
|
322
|
-
...this.activeCallStack
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
removeMethodFromTrace() {
|
|
326
|
-
if (!this.isNewOperation()) {
|
|
327
|
-
this.activeCallStack.pop();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
endOperation() {
|
|
331
|
-
this.activeOperationId = null;
|
|
332
|
-
this.activeCallStack = [];
|
|
333
|
-
}
|
|
334
|
-
formatMethodPaths(methodPaths) {
|
|
335
|
-
return methodPaths.map((path)=>path.replace(/ → /g, '.'));
|
|
336
|
-
}
|
|
337
|
-
getCurrentTrace() {
|
|
338
|
-
return [
|
|
339
|
-
...this.activeCallStack
|
|
340
|
-
];
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// EXTERNAL MODULE: ./src/utilities/logger.ts
|
|
345
|
-
var logger = __webpack_require__(581);
|
|
346
|
-
;// CONCATENATED MODULE: ./src/capabilities/PerformanceCapability.ts
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
class PerformanceCapability extends Capability {
|
|
353
|
-
callTraceManager;
|
|
354
|
-
performanceTracker;
|
|
355
|
-
filter;
|
|
356
|
-
childDurations = new Map();
|
|
357
|
-
constructor(options){
|
|
358
|
-
super();
|
|
359
|
-
this.filter = options?.filter ?? (()=>true);
|
|
360
|
-
this.callTraceManager = new CallTraceManager();
|
|
361
|
-
this.performanceTracker = new PerformanceTracker();
|
|
362
|
-
}
|
|
363
|
-
apply(instance) {
|
|
364
|
-
this.explore(instance, (meta, info)=>{
|
|
365
|
-
if (info.isCallable) {
|
|
366
|
-
const originalMethod = meta.instance[info.name].bind(meta.instance);
|
|
367
|
-
meta.instance[info.name] = (...args)=>{
|
|
368
|
-
const path = `${meta.path}.${String(info.name)}()`;
|
|
369
|
-
if (this.filter(path, info, meta) === false) {
|
|
370
|
-
return originalMethod(...args);
|
|
371
|
-
}
|
|
372
|
-
const isNewOperation = this.callTraceManager.isNewOperation();
|
|
373
|
-
let operationId;
|
|
374
|
-
let callTrace;
|
|
375
|
-
let depth;
|
|
376
|
-
if (isNewOperation) {
|
|
377
|
-
operationId = this.callTraceManager.startNewOperation();
|
|
378
|
-
this.childDurations.set(operationId, []);
|
|
379
|
-
callTrace = this.callTraceManager.addMethodToTrace(path);
|
|
380
|
-
depth = callTrace.length - 1;
|
|
381
|
-
const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
|
|
382
|
-
this.performanceTracker.startMethodTiming(operationId, path);
|
|
383
|
-
logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
|
|
384
|
-
logger/* .logger.log */.vF.log(`▶ ORIGIN [${operationId}] ${path}`);
|
|
385
|
-
if (args.length > 0) {
|
|
386
|
-
logger/* .logger.log */.vF.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
|
|
387
|
-
}
|
|
388
|
-
logger/* .logger.log */.vF.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
|
|
389
|
-
} else {
|
|
390
|
-
operationId = this.callTraceManager.getActiveOperationId();
|
|
391
|
-
callTrace = this.callTraceManager.addMethodToTrace(path);
|
|
392
|
-
depth = callTrace.length - 1;
|
|
393
|
-
const indent = ' '.repeat(Math.min(depth, 4));
|
|
394
|
-
// Track children for this child method too
|
|
395
|
-
const childMethodKey = `${operationId}:${path}`;
|
|
396
|
-
this.childDurations.set(childMethodKey, []);
|
|
397
|
-
this.performanceTracker.startMethodTiming(operationId, path);
|
|
398
|
-
logger/* .logger.log */.vF.log(`${indent}└─ CHILD [${operationId}] ${path}`);
|
|
399
|
-
if (args.length > 0) {
|
|
400
|
-
logger/* .logger.log */.vF.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
try {
|
|
404
|
-
return originalMethod(...args);
|
|
405
|
-
} finally{
|
|
406
|
-
const metrics = this.performanceTracker.endMethodTiming(operationId, path);
|
|
407
|
-
const duration = metrics.duration ?? 0;
|
|
408
|
-
const formattedDuration = this.performanceTracker.formatDuration(duration);
|
|
409
|
-
if (isNewOperation) {
|
|
410
|
-
const childDurations = this.childDurations.get(operationId) ?? [];
|
|
411
|
-
const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
|
|
412
|
-
const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
|
|
413
|
-
const overhead = duration - totalChildTime;
|
|
414
|
-
const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
|
|
415
|
-
logger/* .logger.log */.vF.log(`\n${'═'.repeat(60)}`);
|
|
416
|
-
logger/* .logger.log */.vF.log(`◀ COMPLETE [${operationId}] ${path}`);
|
|
417
|
-
logger/* .logger.log */.vF.log(` Total Duration: ${formattedDuration}`);
|
|
418
|
-
if (childDurations.length > 0) {
|
|
419
|
-
logger/* .logger.log */.vF.log(` Children Duration: ${formattedTotalChildTime} (${childDurations.length} calls)`);
|
|
420
|
-
logger/* .logger.log */.vF.log(` Overhead: ${formattedOverhead}`);
|
|
421
|
-
}
|
|
422
|
-
logger/* .logger.log */.vF.log(`${'═'.repeat(60)}\n`);
|
|
423
|
-
this.childDurations.delete(operationId);
|
|
424
|
-
this.performanceTracker.cleanupOperation(operationId);
|
|
425
|
-
this.callTraceManager.endOperation();
|
|
426
|
-
} else {
|
|
427
|
-
const indent = ' '.repeat(Math.min(depth, 4));
|
|
428
|
-
const childMethodKey = `${operationId}:${path}`;
|
|
429
|
-
const childDurations = this.childDurations.get(childMethodKey) ?? [];
|
|
430
|
-
const totalChildTime = childDurations.reduce((sum, d)=>sum + d, 0);
|
|
431
|
-
const formattedTotalChildTime = this.performanceTracker.formatDuration(totalChildTime);
|
|
432
|
-
const overhead = duration - totalChildTime;
|
|
433
|
-
const formattedOverhead = this.performanceTracker.formatDuration(Math.max(0, overhead));
|
|
434
|
-
logger/* .logger.log */.vF.log(`${indent} ✓ ${formattedDuration}`);
|
|
435
|
-
if (childDurations.length > 0) {
|
|
436
|
-
logger/* .logger.log */.vF.log(`${indent} Children: ${formattedTotalChildTime} (${childDurations.length} calls), Overhead: ${formattedOverhead}`);
|
|
437
|
-
}
|
|
438
|
-
// Clean up child method tracking
|
|
439
|
-
this.childDurations.delete(childMethodKey);
|
|
440
|
-
// Find the parent method and add this duration to its children list
|
|
441
|
-
// The parent is the method one level up in the call trace
|
|
442
|
-
const currentTrace = this.callTraceManager.getCurrentTrace();
|
|
443
|
-
if (currentTrace.length > 1) {
|
|
444
|
-
// Parent is the second-to-last item in the trace (before we remove current)
|
|
445
|
-
const parentPath = currentTrace[currentTrace.length - 2];
|
|
446
|
-
// Check if parent is the root operation (trace length 2 means root + this child)
|
|
447
|
-
if (currentTrace.length === 2) {
|
|
448
|
-
// Direct child of root - add to root's children list
|
|
449
|
-
const rootChildDurations = this.childDurations.get(operationId);
|
|
450
|
-
if (rootChildDurations) {
|
|
451
|
-
rootChildDurations.push(duration);
|
|
452
|
-
}
|
|
453
|
-
} else {
|
|
454
|
-
// Nested child - add to parent method's children list
|
|
455
|
-
const parentMethodKey = `${operationId}:${parentPath}`;
|
|
456
|
-
const parentChildDurations = this.childDurations.get(parentMethodKey);
|
|
457
|
-
if (parentChildDurations) {
|
|
458
|
-
parentChildDurations.push(duration);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
this.callTraceManager.removeMethodFromTrace();
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
;// CONCATENATED MODULE: ./src/capabilities/TracingCapability.ts
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
class TracingCapability extends Capability {
|
|
476
|
-
callTraceManager;
|
|
477
|
-
filter;
|
|
478
|
-
constructor(options){
|
|
479
|
-
super();
|
|
480
|
-
this.filter = options?.filter ?? (()=>true);
|
|
481
|
-
this.callTraceManager = new CallTraceManager();
|
|
482
|
-
}
|
|
483
|
-
apply(instance) {
|
|
484
|
-
this.explore(instance, (meta, info)=>{
|
|
485
|
-
if (info.isCallable) {
|
|
486
|
-
const originalMethod = meta.instance[info.name].bind(meta.instance);
|
|
487
|
-
meta.instance[info.name] = (...args)=>{
|
|
488
|
-
const path = `${meta.path}.${String(info.name)}()`;
|
|
489
|
-
if (this.filter(path, info, meta) === false) {
|
|
490
|
-
return originalMethod(...args);
|
|
491
|
-
}
|
|
492
|
-
const isNewOperation = this.callTraceManager.isNewOperation();
|
|
493
|
-
let operationId;
|
|
494
|
-
if (isNewOperation) {
|
|
495
|
-
operationId = this.callTraceManager.startNewOperation();
|
|
496
|
-
const callTrace = this.callTraceManager.addMethodToTrace(path);
|
|
497
|
-
const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
|
|
498
|
-
console.log(`\n${'═'.repeat(60)}`);
|
|
499
|
-
console.log(`▶ ORIGIN [${operationId}] ${path}`);
|
|
500
|
-
if (args.length > 0) {
|
|
501
|
-
console.log(` Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
|
|
502
|
-
}
|
|
503
|
-
console.log(` Call Stack: ${formattedCallTrace.join(' → ')}`);
|
|
504
|
-
} else {
|
|
505
|
-
operationId = this.callTraceManager.getActiveOperationId();
|
|
506
|
-
const callTrace = this.callTraceManager.addMethodToTrace(path);
|
|
507
|
-
const indent = ' '.repeat(Math.min(callTrace.length - 1, 4));
|
|
508
|
-
console.log(`${indent}└─ CHILD [${operationId}] ${path}`);
|
|
509
|
-
if (args.length > 0) {
|
|
510
|
-
console.log(`${indent} Args:`, (0,strings/* .stringifyObject */.Zm)(args, 4, 0));
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
try {
|
|
514
|
-
return originalMethod(...args);
|
|
515
|
-
} finally{
|
|
516
|
-
this.callTraceManager.removeMethodFromTrace();
|
|
517
|
-
if (isNewOperation) {
|
|
518
|
-
this.callTraceManager.endOperation();
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
;// CONCATENATED MODULE: ./src/capabilities/index.ts
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
104
|
},
|
|
535
105
|
980(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
536
106
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -3687,12 +3257,13 @@ var TrampolinePipeline = __webpack_require__(416);
|
|
|
3687
3257
|
|
|
3688
3258
|
|
|
3689
3259
|
},
|
|
3690
|
-
|
|
3260
|
+
454(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3691
3261
|
|
|
3692
3262
|
// EXPORTS
|
|
3693
3263
|
__webpack_require__.d(__webpack_exports__, {
|
|
3694
3264
|
DEFAULT_SEMI_JOIN_KEY_THRESHOLD: () => (/* reexport */ DEFAULT_SEMI_JOIN_KEY_THRESHOLD),
|
|
3695
3265
|
TranslatedArrayValue: () => (/* reexport */ TranslatedArrayValue),
|
|
3266
|
+
collectingSink: () => (/* reexport */ collectingSink),
|
|
3696
3267
|
semiJoinFilter: () => (/* reexport */ semiJoinFilter),
|
|
3697
3268
|
CacheDbPlugin: () => (/* reexport */ CacheDbPlugin),
|
|
3698
3269
|
Query: () => (/* reexport */ Query),
|
|
@@ -3714,16 +3285,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
3714
3285
|
EXECUTED_QUERIES_UNSUPPORTED: () => (/* reexport */ EXECUTED_QUERIES_UNSUPPORTED),
|
|
3715
3286
|
joinInPlugin: () => (/* reexport */ joinInPlugin),
|
|
3716
3287
|
deserializePersistResult: () => (/* reexport */ deserializePersistResult),
|
|
3288
|
+
loggerSink: () => (/* reexport */ loggerSink),
|
|
3717
3289
|
nearestBy: () => (/* reexport */ nearestBy),
|
|
3718
3290
|
readJoinKey: () => (/* reexport */ readJoinKey),
|
|
3719
|
-
serializeBulkPersist: () => (/* reexport */ serializeBulkPersist),
|
|
3720
3291
|
hashJoin: () => (/* reexport */ hashJoin),
|
|
3721
3292
|
EphemeralDataPlugin: () => (/* reexport */ EphemeralDataPlugin),
|
|
3722
3293
|
QueryOptionsCollection: () => (/* reexport */ QueryOptionsCollection/* .QueryOptionsCollection */.H),
|
|
3294
|
+
serializeBulkPersist: () => (/* reexport */ serializeBulkPersist),
|
|
3723
3295
|
toEntityShape: () => (/* reexport */ toEntityShape),
|
|
3724
3296
|
loadJoinInnerSide: () => (/* reexport */ loadJoinInnerSide),
|
|
3725
3297
|
DataTranslator: () => (/* reexport */ DataTranslator),
|
|
3726
3298
|
withExecutedQueries: () => (/* reexport */ withExecutedQueries),
|
|
3299
|
+
TelemetryDbPlugin: () => (/* reexport */ TelemetryDbPlugin),
|
|
3727
3300
|
createRequestHandler: () => (/* reexport */ createRequestHandler),
|
|
3728
3301
|
SqlTranslator: () => (/* reexport */ SqlTranslator),
|
|
3729
3302
|
QueryOrdering: () => (/* reexport */ types_QueryOrdering),
|
|
@@ -6714,6 +6287,69 @@ class RetryDbPlugin {
|
|
|
6714
6287
|
}
|
|
6715
6288
|
}
|
|
6716
6289
|
|
|
6290
|
+
;// CONCATENATED MODULE: ./src/plugins/TelemetryDbPlugin.ts
|
|
6291
|
+
|
|
6292
|
+
/** Default sink: writes through the levelled logger, so ROUTIER_LOG_LEVEL governs it. */ const loggerSink = ()=>(e)=>{
|
|
6293
|
+
const line = `[routier] ${e.operation} ${e.schemas.join(",")} ${e.durationMs.toFixed(1)}ms`;
|
|
6294
|
+
if (e.ok === "error") {
|
|
6295
|
+
logger/* .logger.error */.vF.error(line, e.error);
|
|
6296
|
+
return;
|
|
6297
|
+
}
|
|
6298
|
+
logger/* .logger.info */.vF.info(line);
|
|
6299
|
+
};
|
|
6300
|
+
/** Pushes every event into `into`. For tests and custom buffering. */ const collectingSink = (into)=>(e)=>{
|
|
6301
|
+
into.push(e);
|
|
6302
|
+
};
|
|
6303
|
+
class TelemetryDbPlugin {
|
|
6304
|
+
plugin;
|
|
6305
|
+
onEvent;
|
|
6306
|
+
constructor(plugin, options = {}){
|
|
6307
|
+
this.plugin = plugin;
|
|
6308
|
+
this.onEvent = options.onEvent ?? loggerSink();
|
|
6309
|
+
}
|
|
6310
|
+
get databaseName() {
|
|
6311
|
+
return this.plugin.databaseName;
|
|
6312
|
+
}
|
|
6313
|
+
query(event, done) {
|
|
6314
|
+
const start = performance.now();
|
|
6315
|
+
this.plugin.query(event, (result)=>{
|
|
6316
|
+
this.emit("query", event, result, start);
|
|
6317
|
+
done(result);
|
|
6318
|
+
});
|
|
6319
|
+
}
|
|
6320
|
+
bulkPersist(event, done) {
|
|
6321
|
+
const start = performance.now();
|
|
6322
|
+
this.plugin.bulkPersist(event, (result)=>{
|
|
6323
|
+
this.emit("bulkPersist", event, result, start);
|
|
6324
|
+
done(result);
|
|
6325
|
+
});
|
|
6326
|
+
}
|
|
6327
|
+
destroy(event, done) {
|
|
6328
|
+
const start = performance.now();
|
|
6329
|
+
this.plugin.destroy(event, (result)=>{
|
|
6330
|
+
this.emit("destroy", event, result, start);
|
|
6331
|
+
done(result);
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
emit(operation, event, result, start) {
|
|
6335
|
+
try {
|
|
6336
|
+
this.onEvent({
|
|
6337
|
+
operation,
|
|
6338
|
+
eventId: event.id,
|
|
6339
|
+
source: event.source,
|
|
6340
|
+
schemas: [
|
|
6341
|
+
...event.schemas.values()
|
|
6342
|
+
].map((s)=>s.collectionName),
|
|
6343
|
+
durationMs: performance.now() - start,
|
|
6344
|
+
ok: result.ok,
|
|
6345
|
+
error: result.ok === "success" ? undefined : result.error
|
|
6346
|
+
});
|
|
6347
|
+
} catch {
|
|
6348
|
+
// A broken sink must never fail the data operation.
|
|
6349
|
+
}
|
|
6350
|
+
}
|
|
6351
|
+
}
|
|
6352
|
+
|
|
6717
6353
|
;// CONCATENATED MODULE: ./src/plugins/CacheDbPlugin.ts
|
|
6718
6354
|
|
|
6719
6355
|
/**
|
|
@@ -7178,6 +6814,7 @@ const DEFAULT_MAX_BATCH_SIZE = 100;
|
|
|
7178
6814
|
|
|
7179
6815
|
|
|
7180
6816
|
|
|
6817
|
+
|
|
7181
6818
|
},
|
|
7182
6819
|
198(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
7183
6820
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -14183,7 +13820,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14183
13820
|
BulkPersistChanges: () => (/* reexport safe */ _collections__rspack_import_2.BulkPersistChanges),
|
|
14184
13821
|
BulkPersistResult: () => (/* reexport safe */ _collections__rspack_import_2.BulkPersistResult),
|
|
14185
13822
|
CacheDbPlugin: () => (/* reexport safe */ _plugins__rspack_import_7.CacheDbPlugin),
|
|
14186
|
-
Capability: () => (/* reexport safe */ _capabilities__rspack_import_11.Capability),
|
|
14187
13823
|
CodeBuilder: () => (/* reexport safe */ _codegen__rspack_import_1.CodeBuilder),
|
|
14188
13824
|
ComparatorExpression: () => (/* reexport safe */ _expressions__rspack_import_4.ComparatorExpression),
|
|
14189
13825
|
ConcurrencyDbPlugin: () => (/* reexport safe */ _plugins__rspack_import_7.ConcurrencyDbPlugin),
|
|
@@ -14208,7 +13844,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14208
13844
|
ObjectBuilder: () => (/* reexport safe */ _codegen__rspack_import_1.ObjectBuilder),
|
|
14209
13845
|
OperatorExpression: () => (/* reexport safe */ _expressions__rspack_import_4.OperatorExpression),
|
|
14210
13846
|
OptimisticConcurrencyError: () => (/* reexport safe */ _errors__rspack_import_3.OptimisticConcurrencyError),
|
|
14211
|
-
PerformanceCapability: () => (/* reexport safe */ _capabilities__rspack_import_11.PerformanceCapability),
|
|
14212
13847
|
PluginDestroyedError: () => (/* reexport safe */ _errors__rspack_import_3.PluginDestroyedError),
|
|
14213
13848
|
PluginEventResult: () => (/* reexport safe */ _results__rspack_import_8.PluginEventResult),
|
|
14214
13849
|
PropertyExpression: () => (/* reexport safe */ _expressions__rspack_import_4.PropertyExpression),
|
|
@@ -14258,7 +13893,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14258
13893
|
StringBuilder: () => (/* reexport safe */ _codegen__rspack_import_1.StringBuilder),
|
|
14259
13894
|
SyncronousQueue: () => (/* reexport safe */ _pipeline__rspack_import_6.SyncronousQueue),
|
|
14260
13895
|
TagCollection: () => (/* reexport safe */ _collections__rspack_import_2.TagCollection),
|
|
14261
|
-
|
|
13896
|
+
TelemetryDbPlugin: () => (/* reexport safe */ _plugins__rspack_import_7.TelemetryDbPlugin),
|
|
14262
13897
|
TrampolinePipeline: () => (/* reexport safe */ _pipeline__rspack_import_6.TrampolinePipeline),
|
|
14263
13898
|
TranslatedArrayValue: () => (/* reexport safe */ _plugins__rspack_import_7.TranslatedArrayValue),
|
|
14264
13899
|
TranslatedGroupValue: () => (/* reexport safe */ _plugins__rspack_import_7.TranslatedGroupValue),
|
|
@@ -14276,6 +13911,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14276
13911
|
assertString: () => (/* reexport safe */ _assertions__rspack_import_0.assertString),
|
|
14277
13912
|
cast: () => (/* reexport safe */ _utilities__rspack_import_10.cast),
|
|
14278
13913
|
clone: () => (/* reexport safe */ _utilities__rspack_import_10.clone),
|
|
13914
|
+
collectingSink: () => (/* reexport safe */ _plugins__rspack_import_7.collectingSink),
|
|
14279
13915
|
combineExpressions: () => (/* reexport safe */ _expressions__rspack_import_4.combineExpressions),
|
|
14280
13916
|
combineQueryOptionsCollections: () => (/* reexport safe */ _utilities__rspack_import_10.combineQueryOptionsCollections),
|
|
14281
13917
|
compiledSchemaToJsonSchema: () => (/* reexport safe */ _schema__rspack_import_9.compiledSchemaToJsonSchema),
|
|
@@ -14312,6 +13948,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14312
13948
|
joinInPlugin: () => (/* reexport safe */ _plugins__rspack_import_7.joinInPlugin),
|
|
14313
13949
|
loadJoinInnerSide: () => (/* reexport safe */ _plugins__rspack_import_7.loadJoinInnerSide),
|
|
14314
13950
|
logger: () => (/* reexport safe */ _utilities__rspack_import_10.logger),
|
|
13951
|
+
loggerSink: () => (/* reexport safe */ _plugins__rspack_import_7.loggerSink),
|
|
14315
13952
|
measure: () => (/* reexport safe */ _performance__rspack_import_5.measure),
|
|
14316
13953
|
nearestBy: () => (/* reexport safe */ _plugins__rspack_import_7.nearestBy),
|
|
14317
13954
|
noop: () => (/* reexport safe */ _utilities__rspack_import_10.noop),
|
|
@@ -14350,12 +13987,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14350
13987
|
/* import */ var _expressions__rspack_import_4 = __webpack_require__(138);
|
|
14351
13988
|
/* import */ var _performance__rspack_import_5 = __webpack_require__(971);
|
|
14352
13989
|
/* import */ var _pipeline__rspack_import_6 = __webpack_require__(314);
|
|
14353
|
-
/* import */ var _plugins__rspack_import_7 = __webpack_require__(
|
|
13990
|
+
/* import */ var _plugins__rspack_import_7 = __webpack_require__(454);
|
|
14354
13991
|
/* import */ var _results__rspack_import_8 = __webpack_require__(264);
|
|
14355
13992
|
/* import */ var _schema__rspack_import_9 = __webpack_require__(755);
|
|
14356
13993
|
/* import */ var _utilities__rspack_import_10 = __webpack_require__(222);
|
|
14357
|
-
/* import */ var _capabilities__rspack_import_11 = __webpack_require__(599);
|
|
14358
|
-
|
|
14359
13994
|
|
|
14360
13995
|
|
|
14361
13996
|
|