@routier/core 0.1.0-rc.1 → 0.1.0-rc.2
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/capabilities/index.js +71 -22
- package/dist/capabilities/index.js.map +1 -1
- package/dist/expressions/index.js +48 -1
- package/dist/expressions/index.js.map +1 -1
- package/dist/index.js +105 -167
- package/dist/index.js.map +1 -1
- package/dist/performance/index.js +78 -3
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/TrampolinePipeline.d.ts +0 -8
- package/dist/pipeline/index.js +60 -140
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/index.js +64 -140
- package/dist/plugins/index.js.map +1 -1
- package/dist/schema/index.js +54 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/types/SchemaNumber.d.ts +1 -0
- package/dist/schema/property/types/SchemaString.d.ts +1 -0
- package/dist/schema/testSchemas.test.d.ts +24 -3
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +50 -1
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +8 -0
- package/package.json +3 -2
package/dist/plugins/index.js
CHANGED
|
@@ -331,6 +331,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
331
331
|
measure: () => (measure),
|
|
332
332
|
now: () => (now)
|
|
333
333
|
});
|
|
334
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities */ "./src/utilities/logger.ts");
|
|
335
|
+
|
|
334
336
|
const measurements = {};
|
|
335
337
|
const now = () => {
|
|
336
338
|
if (typeof performance !== 'undefined' && performance.now) {
|
|
@@ -348,7 +350,7 @@ const measure = {
|
|
|
348
350
|
const start = measurements[name];
|
|
349
351
|
delete measurements[name];
|
|
350
352
|
const delta = now() - start;
|
|
351
|
-
|
|
353
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
|
|
352
354
|
}
|
|
353
355
|
};
|
|
354
356
|
|
|
@@ -361,11 +363,12 @@ const measure = {
|
|
|
361
363
|
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
362
364
|
__webpack_require__.r(__webpack_exports__);
|
|
363
365
|
__webpack_require__.d(__webpack_exports__, {
|
|
364
|
-
AsyncPipeline: () => (AsyncPipeline),
|
|
365
366
|
TrampolinePipeline: () => (TrampolinePipeline),
|
|
366
367
|
WorkPipeline: () => (WorkPipeline)
|
|
367
368
|
});
|
|
368
|
-
/* ESM import */var
|
|
369
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities */ "./src/utilities/logger.ts");
|
|
370
|
+
/* ESM import */var _results__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../results */ "./src/results/Result.ts");
|
|
371
|
+
|
|
369
372
|
|
|
370
373
|
class TrampolinePipeline {
|
|
371
374
|
_list = [];
|
|
@@ -403,7 +406,7 @@ class TrampolinePipeline {
|
|
|
403
406
|
processor(currentData, (result, error) => {
|
|
404
407
|
// --- Error Handling ---
|
|
405
408
|
if (error) {
|
|
406
|
-
|
|
409
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error reported by processor at index ${idx}:`, error);
|
|
407
410
|
this._hasErrored = true; // Set flag
|
|
408
411
|
// Throw the error to be caught by outer try...catch blocks
|
|
409
412
|
throw error;
|
|
@@ -426,7 +429,7 @@ class TrampolinePipeline {
|
|
|
426
429
|
}
|
|
427
430
|
catch (error) {
|
|
428
431
|
if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
|
|
429
|
-
|
|
432
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
430
433
|
this._hasErrored = true;
|
|
431
434
|
}
|
|
432
435
|
// Rethrow to be caught by the trampoline's catch block
|
|
@@ -461,7 +464,7 @@ class TrampolinePipeline {
|
|
|
461
464
|
catch (trampolineError) {
|
|
462
465
|
// Catch errors propagated from step execution (processor or callback errors)
|
|
463
466
|
if (!this._hasErrored) { // Avoid double logging
|
|
464
|
-
|
|
467
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error during trampoline step execution:", trampolineError);
|
|
465
468
|
this._hasErrored = true;
|
|
466
469
|
}
|
|
467
470
|
currentStep = null; // Stop the loop
|
|
@@ -490,135 +493,11 @@ class TrampolinePipeline {
|
|
|
490
493
|
pipeEach(items, fn, map) {
|
|
491
494
|
for (let i = 0, length = items.length; i < length; i++) {
|
|
492
495
|
this.pipe((previous, done) => {
|
|
493
|
-
fn(map(previous,
|
|
496
|
+
fn(map(previous, _results__WEBPACK_IMPORTED_MODULE_1__.Result.success(items[i])), done);
|
|
494
497
|
});
|
|
495
498
|
}
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
|
-
class AsyncPipeline {
|
|
499
|
-
_list = [];
|
|
500
|
-
_hasErrored = false; // Flag to prevent calling done on error
|
|
501
|
-
filter(done) {
|
|
502
|
-
this._hasErrored = false; // Reset error flag on new execution
|
|
503
|
-
let currentData = [];
|
|
504
|
-
if (this._list.length === 0) {
|
|
505
|
-
queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success()));
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
let index = 0;
|
|
509
|
-
let isRunning = false; // Guard against overlapping trampoline calls
|
|
510
|
-
try {
|
|
511
|
-
// --- Revised Completion Logic --- (Moved up for clarity)
|
|
512
|
-
const finalStepSentinel = () => {
|
|
513
|
-
// Only call done if no error has occurred
|
|
514
|
-
if (!this._hasErrored) {
|
|
515
|
-
queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.success(currentData)));
|
|
516
|
-
}
|
|
517
|
-
return null; // Stop the trampoline
|
|
518
|
-
};
|
|
519
|
-
const createStepRevised = (idx) => {
|
|
520
|
-
return () => {
|
|
521
|
-
if (this._hasErrored)
|
|
522
|
-
return null; // Stop if an error occurred elsewhere
|
|
523
|
-
if (idx >= this._list.length) {
|
|
524
|
-
return finalStepSentinel(); // Execute the dedicated final step
|
|
525
|
-
}
|
|
526
|
-
const [payload, processor] = this._list[idx];
|
|
527
|
-
// Initialize syncCallbackResult to null to satisfy StepResult type
|
|
528
|
-
let syncCallbackResult = null;
|
|
529
|
-
let calledSync = false;
|
|
530
|
-
try {
|
|
531
|
-
processor(payload, (result) => {
|
|
532
|
-
// --- Error Handling ---
|
|
533
|
-
if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
|
|
534
|
-
console.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
|
|
535
|
-
this._hasErrored = true; // Set flag
|
|
536
|
-
// Throw the error to be caught by outer try...catch blocks
|
|
537
|
-
throw result.error;
|
|
538
|
-
}
|
|
539
|
-
// --- /Error Handling ---
|
|
540
|
-
// If no error, proceed as before
|
|
541
|
-
currentData.push(result.data);
|
|
542
|
-
index = idx + 1; // Update index for the next step
|
|
543
|
-
const nextStep = createStepRevised(index); // Use updated index
|
|
544
|
-
if (isRunning) {
|
|
545
|
-
// Callback was synchronous
|
|
546
|
-
syncCallbackResult = nextStep; // Store next step function
|
|
547
|
-
calledSync = true;
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
// Callback was asynchronous, restart trampoline
|
|
551
|
-
trampoline(nextStep);
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
catch (error) {
|
|
556
|
-
if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
|
|
557
|
-
console.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
558
|
-
this._hasErrored = true;
|
|
559
|
-
}
|
|
560
|
-
// Rethrow to be caught by the trampoline's catch block
|
|
561
|
-
throw error;
|
|
562
|
-
}
|
|
563
|
-
if (calledSync) {
|
|
564
|
-
// Return the next step function for the sync loop
|
|
565
|
-
return syncCallbackResult;
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
// Pause trampoline for async, loop will stop as step returns null
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
};
|
|
573
|
-
// The trampoline loop
|
|
574
|
-
const trampoline = (step) => {
|
|
575
|
-
if (isRunning) {
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
isRunning = true;
|
|
579
|
-
let currentStep = step;
|
|
580
|
-
while (typeof currentStep === 'function') {
|
|
581
|
-
try {
|
|
582
|
-
// Stop immediately if an error was flagged elsewhere
|
|
583
|
-
if (this._hasErrored) {
|
|
584
|
-
currentStep = null;
|
|
585
|
-
break;
|
|
586
|
-
}
|
|
587
|
-
currentStep = currentStep(); // Execute step, get next step or null
|
|
588
|
-
}
|
|
589
|
-
catch (trampolineError) {
|
|
590
|
-
// Catch errors propagated from step execution (processor or callback errors)
|
|
591
|
-
if (!this._hasErrored) { // Avoid double logging
|
|
592
|
-
console.error("Error during trampoline step execution:", trampolineError);
|
|
593
|
-
this._hasErrored = true;
|
|
594
|
-
}
|
|
595
|
-
currentStep = null; // Stop the loop
|
|
596
|
-
// We don't call `done` here because an error occurred.
|
|
597
|
-
// The application should handle the uncaught exception if desired.
|
|
598
|
-
break; // Explicitly break loop on error
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
// Loop ends when currentStep is null or loop is broken by error
|
|
602
|
-
isRunning = false;
|
|
603
|
-
// Completion check is now handled by finalStepSentinel ensuring `done` isn't called on error.
|
|
604
|
-
};
|
|
605
|
-
// --- Start the process ---
|
|
606
|
-
index = 0; // Reset index
|
|
607
|
-
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
608
|
-
}
|
|
609
|
-
catch (error) {
|
|
610
|
-
done(_results__WEBPACK_IMPORTED_MODULE_0__.Result.error(error));
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
pipe(data, processor) {
|
|
614
|
-
this._list.push([data, processor]);
|
|
615
|
-
}
|
|
616
|
-
pipeEach(items, processor) {
|
|
617
|
-
for (let i = 0, length = items.length; i < length; i++) {
|
|
618
|
-
this.pipe(items[i], processor);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
501
|
/**
|
|
623
502
|
* Processes functions with callbacks asynchronously.
|
|
624
503
|
*
|
|
@@ -632,7 +511,7 @@ class WorkPipeline {
|
|
|
632
511
|
filter(done) {
|
|
633
512
|
this._hasErrored = false; // Reset error flag on new execution
|
|
634
513
|
if (this.unitsOfWork.length === 0) {
|
|
635
|
-
queueMicrotask(() => done(
|
|
514
|
+
queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.success()));
|
|
636
515
|
return;
|
|
637
516
|
}
|
|
638
517
|
let index = 0;
|
|
@@ -642,7 +521,7 @@ class WorkPipeline {
|
|
|
642
521
|
const finalStepSentinel = () => {
|
|
643
522
|
// Only call done if no error has occurred
|
|
644
523
|
if (!this._hasErrored) {
|
|
645
|
-
queueMicrotask(() => done(
|
|
524
|
+
queueMicrotask(() => done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.success()));
|
|
646
525
|
}
|
|
647
526
|
return null; // Stop the trampoline
|
|
648
527
|
};
|
|
@@ -660,8 +539,8 @@ class WorkPipeline {
|
|
|
660
539
|
try {
|
|
661
540
|
processor((result) => {
|
|
662
541
|
// --- Error Handling ---
|
|
663
|
-
if (result.ok ===
|
|
664
|
-
|
|
542
|
+
if (result.ok === _results__WEBPACK_IMPORTED_MODULE_1__.Result.ERROR) {
|
|
543
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error reported by AsyncPipeline at index ${idx}:`, result.error);
|
|
665
544
|
this._hasErrored = true; // Set flag
|
|
666
545
|
// Throw the error to be caught by outer try...catch blocks
|
|
667
546
|
throw result.error;
|
|
@@ -683,7 +562,7 @@ class WorkPipeline {
|
|
|
683
562
|
}
|
|
684
563
|
catch (error) {
|
|
685
564
|
if (!this._hasErrored) { // Check flag to avoid double logging if error was from callback
|
|
686
|
-
|
|
565
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Error thrown by processor at index ${idx} or its callback:`, error);
|
|
687
566
|
this._hasErrored = true;
|
|
688
567
|
}
|
|
689
568
|
// Rethrow to be caught by the trampoline's catch block
|
|
@@ -718,7 +597,7 @@ class WorkPipeline {
|
|
|
718
597
|
catch (trampolineError) {
|
|
719
598
|
// Catch errors propagated from step execution (processor or callback errors)
|
|
720
599
|
if (!this._hasErrored) { // Avoid double logging
|
|
721
|
-
|
|
600
|
+
_utilities__WEBPACK_IMPORTED_MODULE_0__.logger.error("Error during trampoline step execution:", trampolineError);
|
|
722
601
|
this._hasErrored = true;
|
|
723
602
|
}
|
|
724
603
|
currentStep = null; // Stop the loop
|
|
@@ -736,7 +615,7 @@ class WorkPipeline {
|
|
|
736
615
|
trampoline(createStepRevised(0)); // Start with the revised step creator
|
|
737
616
|
}
|
|
738
617
|
catch (error) {
|
|
739
|
-
done(
|
|
618
|
+
done(_results__WEBPACK_IMPORTED_MODULE_1__.Result.error(error));
|
|
740
619
|
}
|
|
741
620
|
}
|
|
742
621
|
pipe(work) {
|
|
@@ -1370,10 +1249,10 @@ class ReplicationDbPlugin {
|
|
|
1370
1249
|
}
|
|
1371
1250
|
destroy(event, done) {
|
|
1372
1251
|
try {
|
|
1373
|
-
const pipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_1__.
|
|
1252
|
+
const pipeline = new _pipeline__WEBPACK_IMPORTED_MODULE_1__.WorkPipeline();
|
|
1374
1253
|
const plugins = [this.plugins.source, ...this.plugins.replicas];
|
|
1375
1254
|
for (let i = 0, length = plugins.length; i < length; i++) {
|
|
1376
|
-
pipeline.pipe(
|
|
1255
|
+
pipeline.pipe((done) => plugins[i].destroy(event, done));
|
|
1377
1256
|
}
|
|
1378
1257
|
pipeline.filter((result) => {
|
|
1379
1258
|
if (result.ok === _results__WEBPACK_IMPORTED_MODULE_0__.Result.ERROR) {
|
|
@@ -2026,6 +1905,51 @@ const isDate = (data) => {
|
|
|
2026
1905
|
};
|
|
2027
1906
|
|
|
2028
1907
|
|
|
1908
|
+
}),
|
|
1909
|
+
"./src/utilities/logger.ts":
|
|
1910
|
+
/*!*********************************!*\
|
|
1911
|
+
!*** ./src/utilities/logger.ts ***!
|
|
1912
|
+
\*********************************/
|
|
1913
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1914
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1915
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1916
|
+
logger: () => (logger)
|
|
1917
|
+
});
|
|
1918
|
+
const isDevelopment = () => {
|
|
1919
|
+
if (typeof process === 'undefined' || process.env == null) {
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
const env = "development"?.toLowerCase();
|
|
1923
|
+
return env === 'dev' || env === 'development' || env === 'test';
|
|
1924
|
+
};
|
|
1925
|
+
const shouldLog = isDevelopment();
|
|
1926
|
+
const tryLog = (type, ...args) => {
|
|
1927
|
+
if (shouldLog) {
|
|
1928
|
+
console[type](...args);
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
const logger = {
|
|
1932
|
+
log: (...args) => {
|
|
1933
|
+
tryLog("log", ...args);
|
|
1934
|
+
},
|
|
1935
|
+
info: (...args) => {
|
|
1936
|
+
tryLog("info", ...args);
|
|
1937
|
+
},
|
|
1938
|
+
warn: (...args) => {
|
|
1939
|
+
tryLog("warn", ...args);
|
|
1940
|
+
},
|
|
1941
|
+
error: (...args) => {
|
|
1942
|
+
tryLog("error", ...args);
|
|
1943
|
+
},
|
|
1944
|
+
debug: (...args) => {
|
|
1945
|
+
tryLog("debug", ...args);
|
|
1946
|
+
},
|
|
1947
|
+
table: (...args) => {
|
|
1948
|
+
tryLog("table", ...args);
|
|
1949
|
+
},
|
|
1950
|
+
};
|
|
1951
|
+
|
|
1952
|
+
|
|
2029
1953
|
}),
|
|
2030
1954
|
"./src/utilities/replication.ts":
|
|
2031
1955
|
/*!**************************************!*\
|