@rainbow-o23/n1 1.0.50 → 1.0.51
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/index.cjs +10 -579
- package/index.js +9 -539
- package/lib/envs.d.ts +1 -1
- package/lib/pipeline/index.d.ts +0 -2
- package/lib/pipeline/step-helpers-utils.d.ts +1 -1
- package/package.json +2 -1
- package/rollup.config.base.js +4 -1
- package/src/lib/envs.ts +2 -20
- package/src/lib/pipeline/index.ts +0 -2
- package/src/lib/pipeline/step-helpers-utils.ts +7 -11
- package/lib/pipeline/step-helpers-value-operator.d.ts +0 -34
- package/lib/pipeline/value-operators/action-types.d.ts +0 -18
- package/lib/pipeline/value-operators/index.d.ts +0 -8
- package/lib/pipeline/value-operators/test-any-actions.d.ts +0 -10
- package/lib/pipeline/value-operators/test-decimal-actions.d.ts +0 -25
- package/lib/pipeline/value-operators/test-string-actions.d.ts +0 -2
- package/lib/pipeline/value-operators/testers.d.ts +0 -36
- package/lib/pipeline/value-operators/transform-decimal-actions.d.ts +0 -21
- package/lib/pipeline/value-operators/transform-string-actions.d.ts +0 -10
- package/lib/pipeline/value-operators/transformers.d.ts +0 -31
- package/src/lib/pipeline/step-helpers-value-operator.ts +0 -307
- package/src/lib/pipeline/value-operators/action-types.ts +0 -8
- package/src/lib/pipeline/value-operators/index.ts +0 -10
- package/src/lib/pipeline/value-operators/test-any-actions.ts +0 -58
- package/src/lib/pipeline/value-operators/test-decimal-actions.ts +0 -85
- package/src/lib/pipeline/value-operators/test-string-actions.ts +0 -15
- package/src/lib/pipeline/value-operators/testers.ts +0 -59
- package/src/lib/pipeline/value-operators/transform-decimal-actions.ts +0 -88
- package/src/lib/pipeline/value-operators/transform-string-actions.ts +0 -49
- package/src/lib/pipeline/value-operators/transformers.ts +0 -34
package/index.cjs
CHANGED
|
@@ -1,29 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var ArraySupport = require('dayjs/plugin/arraySupport.js');
|
|
5
|
-
var CustomParseFormat = require('dayjs/plugin/customParseFormat.js');
|
|
6
|
-
var Duration = require('dayjs/plugin/duration.js');
|
|
7
|
-
var IsToday = require('dayjs/plugin/isToday.js');
|
|
8
|
-
var ObjectSupport = require('dayjs/plugin/objectSupport.js');
|
|
9
|
-
var QuarterOfYear = require('dayjs/plugin/quarterOfYear.js');
|
|
10
|
-
var RelativeTime = require('dayjs/plugin/relativeTime.js');
|
|
11
|
-
var UTC = require('dayjs/plugin/utc.js');
|
|
12
|
-
var WeekOfYear = require('dayjs/plugin/weekOfYear.js');
|
|
3
|
+
var n1 = require('@rainbow-n19/n1');
|
|
13
4
|
var nanoid = require('nanoid');
|
|
5
|
+
var dayjs = require('dayjs');
|
|
14
6
|
var Decimal = require('decimal.js');
|
|
15
7
|
var mathjs$1 = require('mathjs');
|
|
16
8
|
|
|
17
|
-
dayjs.extend(WeekOfYear);
|
|
18
|
-
dayjs.extend(QuarterOfYear);
|
|
19
|
-
dayjs.extend(Duration);
|
|
20
|
-
dayjs.extend(IsToday);
|
|
21
|
-
dayjs.extend(RelativeTime);
|
|
22
|
-
dayjs.extend(ArraySupport);
|
|
23
|
-
dayjs.extend(ObjectSupport);
|
|
24
|
-
dayjs.extend(CustomParseFormat);
|
|
25
|
-
dayjs.extend(UTC);
|
|
26
|
-
|
|
27
9
|
const ERR_PIPELINE_NOT_FOUND = 'O01-00001';
|
|
28
10
|
const ERR_TRIM_NON_STRING = 'O01-00002';
|
|
29
11
|
const ERR_DUPLICATED_ERROR_CODE = 'O01-00002';
|
|
@@ -436,516 +418,6 @@ const StaticImplements = () => {
|
|
|
436
418
|
};
|
|
437
419
|
};
|
|
438
420
|
|
|
439
|
-
const OBJECT_PROTOTYPE = Object.prototype;
|
|
440
|
-
|
|
441
|
-
const isLength = (value) => {
|
|
442
|
-
return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= Number.MAX_SAFE_INTEGER;
|
|
443
|
-
};
|
|
444
|
-
const isArrayLike = (value) => {
|
|
445
|
-
return value != null && typeof value !== 'function' && isLength(value.length);
|
|
446
|
-
};
|
|
447
|
-
const isPrototype = (value) => {
|
|
448
|
-
const Ctor = value && value.constructor;
|
|
449
|
-
const proto = (typeof Ctor === 'function' && Ctor.prototype) || OBJECT_PROTOTYPE;
|
|
450
|
-
return value === proto;
|
|
451
|
-
};
|
|
452
|
-
const isNull = (value) => {
|
|
453
|
-
return value == null
|
|
454
|
-
? { test: true, value: value }
|
|
455
|
-
: { test: false, value };
|
|
456
|
-
};
|
|
457
|
-
const isNotNull = (value) => ({ test: !isNull(value).test, value });
|
|
458
|
-
const isEmpty = (value) => {
|
|
459
|
-
if (value == null) {
|
|
460
|
-
return { test: true, value: value };
|
|
461
|
-
}
|
|
462
|
-
let length = null;
|
|
463
|
-
if (isArrayLike(value) && (Array.isArray(value) || typeof value === 'string')) {
|
|
464
|
-
length = value.length;
|
|
465
|
-
}
|
|
466
|
-
else if (value instanceof Map) {
|
|
467
|
-
length = value.size;
|
|
468
|
-
}
|
|
469
|
-
else if (value instanceof Set) {
|
|
470
|
-
length = value.size;
|
|
471
|
-
}
|
|
472
|
-
else if (isPrototype(value)) {
|
|
473
|
-
length = Object.keys(value).length;
|
|
474
|
-
}
|
|
475
|
-
return { test: length === 0, value };
|
|
476
|
-
};
|
|
477
|
-
const isNotEmpty = (value) => ({ test: !isEmpty(value).test, value });
|
|
478
|
-
const isBlank = (value) => {
|
|
479
|
-
switch (true) {
|
|
480
|
-
case (value == null):
|
|
481
|
-
return { test: true, value: value };
|
|
482
|
-
case (typeof value === 'string' && value.trim().length === 0):
|
|
483
|
-
return { test: true, value: value };
|
|
484
|
-
default:
|
|
485
|
-
return { test: false, value };
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
const isNotBlank = (value) => ({ test: !isBlank(value).test, value });
|
|
489
|
-
|
|
490
|
-
const regexp = (regexp) => {
|
|
491
|
-
return (value) => {
|
|
492
|
-
if (value == null) {
|
|
493
|
-
return { test: false, value };
|
|
494
|
-
}
|
|
495
|
-
const type = typeof value;
|
|
496
|
-
if (['string', 'number', 'bigint'].includes(type)) {
|
|
497
|
-
return { test: regexp.test(value), value };
|
|
498
|
-
}
|
|
499
|
-
return { test: false, value };
|
|
500
|
-
};
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
exports.Rounding = void 0;
|
|
504
|
-
(function (Rounding) {
|
|
505
|
-
Rounding["ROUND_UP"] = "up";
|
|
506
|
-
Rounding["ROUND_DOWN"] = "down";
|
|
507
|
-
Rounding["ROUND_CEIL"] = "ceil";
|
|
508
|
-
Rounding["ROUND_FLOOR"] = "floor";
|
|
509
|
-
Rounding["ROUND_HALF_UP"] = "half-up";
|
|
510
|
-
Rounding["ROUND_HALF_DOWN"] = "half-down";
|
|
511
|
-
Rounding["ROUND_HALF_EVEN"] = "half-even";
|
|
512
|
-
Rounding["ROUND_HALF_CEIL"] = "half-ceil";
|
|
513
|
-
Rounding["ROUND_HALF_FLOOR"] = "half-floor";
|
|
514
|
-
})(exports.Rounding || (exports.Rounding = {}));
|
|
515
|
-
const ToDecimalJsRounding = {
|
|
516
|
-
[exports.Rounding.ROUND_UP]: Decimal.ROUND_UP,
|
|
517
|
-
[exports.Rounding.ROUND_DOWN]: Decimal.ROUND_DOWN,
|
|
518
|
-
[exports.Rounding.ROUND_CEIL]: Decimal.ROUND_CEIL,
|
|
519
|
-
[exports.Rounding.ROUND_FLOOR]: Decimal.ROUND_FLOOR,
|
|
520
|
-
[exports.Rounding.ROUND_HALF_UP]: Decimal.ROUND_HALF_UP,
|
|
521
|
-
[exports.Rounding.ROUND_HALF_DOWN]: Decimal.ROUND_HALF_DOWN,
|
|
522
|
-
[exports.Rounding.ROUND_HALF_EVEN]: Decimal.ROUND_HALF_EVEN,
|
|
523
|
-
[exports.Rounding.ROUND_HALF_CEIL]: Decimal.ROUND_HALF_CEIL,
|
|
524
|
-
[exports.Rounding.ROUND_HALF_FLOOR]: Decimal.ROUND_HALF_FLOOR
|
|
525
|
-
};
|
|
526
|
-
const toDecimal = (value) => {
|
|
527
|
-
if (value == null) {
|
|
528
|
-
return { test: false, value };
|
|
529
|
-
}
|
|
530
|
-
else if (value instanceof Decimal) {
|
|
531
|
-
return { test: true, value };
|
|
532
|
-
}
|
|
533
|
-
else if (['string', 'number'].includes(typeof value)) {
|
|
534
|
-
try {
|
|
535
|
-
return { test: true, value: new Decimal(value) };
|
|
536
|
-
}
|
|
537
|
-
catch {
|
|
538
|
-
return { test: false, value };
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
return { test: false, value };
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
const toNumber = (value) => {
|
|
546
|
-
const { test, value: parsed } = toDecimal(value);
|
|
547
|
-
if (!test) {
|
|
548
|
-
return { test: false, value };
|
|
549
|
-
}
|
|
550
|
-
return { test: true, value: parsed.toNumber() };
|
|
551
|
-
};
|
|
552
|
-
const toFixed = (fractionDigits, rounding = exports.Rounding.ROUND_HALF_UP) => {
|
|
553
|
-
return (value) => {
|
|
554
|
-
const { test, value: parsed } = toDecimal(value);
|
|
555
|
-
if (!test) {
|
|
556
|
-
return { test: false, value };
|
|
557
|
-
}
|
|
558
|
-
return { test: true, value: parsed.toFixed(fractionDigits, ToDecimalJsRounding[rounding]) };
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
const baseRound = (rounding = exports.Rounding.ROUND_HALF_UP) => {
|
|
562
|
-
return (fractionDigits) => {
|
|
563
|
-
return (value) => {
|
|
564
|
-
const { test, value: parsed } = toDecimal(value);
|
|
565
|
-
if (!test) {
|
|
566
|
-
return { test: false, value };
|
|
567
|
-
}
|
|
568
|
-
return { test: true, value: parsed.toDecimalPlaces(fractionDigits, ToDecimalJsRounding[rounding]) };
|
|
569
|
-
};
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
const roundUp = baseRound(exports.Rounding.ROUND_HALF_UP);
|
|
573
|
-
const roundDown = baseRound(exports.Rounding.ROUND_HALF_DOWN);
|
|
574
|
-
const floor = baseRound(exports.Rounding.ROUND_FLOOR);
|
|
575
|
-
const ceil = baseRound(exports.Rounding.ROUND_CEIL);
|
|
576
|
-
const roundBy = (fractionDigits, rounding = exports.Rounding.ROUND_HALF_UP) => {
|
|
577
|
-
return baseRound(rounding)(fractionDigits);
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
const isDecimal = (value) => {
|
|
581
|
-
const { test, value: decimal } = toDecimal(value);
|
|
582
|
-
return { test, value: test ? decimal : value };
|
|
583
|
-
};
|
|
584
|
-
const isInteger = (value) => {
|
|
585
|
-
const { test, value: decimal } = toDecimal(value);
|
|
586
|
-
return (test && decimal.isInteger()) ? { test: true, value: decimal } : { test: false, value };
|
|
587
|
-
};
|
|
588
|
-
const isInRange = (options) => {
|
|
589
|
-
const { min, max, interval = 'closed' } = options;
|
|
590
|
-
return (value) => {
|
|
591
|
-
const { test, value: decimal } = toDecimal(value);
|
|
592
|
-
if (!test) {
|
|
593
|
-
return { test: false, value };
|
|
594
|
-
}
|
|
595
|
-
let pass = false;
|
|
596
|
-
switch (interval) {
|
|
597
|
-
case 'open':
|
|
598
|
-
case 'o':
|
|
599
|
-
pass = (min == null || decimal.gt(min)) && (max == null || decimal.lt(max));
|
|
600
|
-
break;
|
|
601
|
-
case 'left-open':
|
|
602
|
-
case 'lo':
|
|
603
|
-
pass = (min == null || decimal.gt(min)) && (max == null || decimal.lte(max));
|
|
604
|
-
break;
|
|
605
|
-
case 'right-open':
|
|
606
|
-
case 'ro':
|
|
607
|
-
pass = (min == null || decimal.gte(min)) && (max == null || decimal.lt(max));
|
|
608
|
-
break;
|
|
609
|
-
case 'closed':
|
|
610
|
-
case 'c':
|
|
611
|
-
default:
|
|
612
|
-
pass = (min == null || decimal.gte(min)) && (max == null || decimal.lte(max));
|
|
613
|
-
break;
|
|
614
|
-
}
|
|
615
|
-
return pass ? { test: true, value: decimal } : { test: false, value };
|
|
616
|
-
};
|
|
617
|
-
};
|
|
618
|
-
const isPositive = isInRange({ min: 0, interval: 'left-open' });
|
|
619
|
-
const isNotPositive = isInRange({ max: 0 });
|
|
620
|
-
const isNegative = isInRange({ max: 0, interval: 'right-open' });
|
|
621
|
-
const isNotNegative = isInRange({ min: 0 });
|
|
622
|
-
const isZero = (value) => {
|
|
623
|
-
const { test, value: decimal } = toDecimal(value);
|
|
624
|
-
return (test && decimal.isZero()) ? { test: true, value: decimal } : { test: false, value };
|
|
625
|
-
};
|
|
626
|
-
const isNotZero = (value) => {
|
|
627
|
-
const { test, value: decimal } = toDecimal(value);
|
|
628
|
-
return (test && !decimal.isZero()) ? { test: true, value: decimal } : { test: false, value };
|
|
629
|
-
};
|
|
630
|
-
const isGreaterThan = (compare) => {
|
|
631
|
-
return isInRange({ min: compare, interval: 'left-open' });
|
|
632
|
-
};
|
|
633
|
-
const isGreaterThanOrEqual = (compare) => {
|
|
634
|
-
return isInRange({ min: compare });
|
|
635
|
-
};
|
|
636
|
-
const isLessThan = (compare) => {
|
|
637
|
-
return isInRange({ max: compare, interval: 'right-open' });
|
|
638
|
-
};
|
|
639
|
-
const isLessThanOrEqual = (compare) => {
|
|
640
|
-
return isInRange({ max: compare });
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
const testers = {
|
|
644
|
-
isNull: { type: 'func', func: isNull },
|
|
645
|
-
isNotNull: { type: 'func', func: isNotNull },
|
|
646
|
-
isEmpty: { type: 'func', func: isEmpty },
|
|
647
|
-
isNotEmpty: { type: 'func', func: isNotEmpty },
|
|
648
|
-
isBlank: { type: 'func', func: isBlank },
|
|
649
|
-
isNotBlank: { type: 'func', func: isNotBlank },
|
|
650
|
-
regexp: { type: 'param', func: regexp },
|
|
651
|
-
regex: { type: 'param', func: regexp },
|
|
652
|
-
matches: { type: 'param', func: regexp },
|
|
653
|
-
isNumber: { type: 'func', func: isDecimal },
|
|
654
|
-
isDecimal: { type: 'func', func: isDecimal },
|
|
655
|
-
isInteger: { type: 'func', func: isInteger },
|
|
656
|
-
isInt: { type: 'func', func: isInteger },
|
|
657
|
-
isPositive: { type: 'func', func: isPositive },
|
|
658
|
-
isNotPositive: { type: 'func', func: isNotPositive },
|
|
659
|
-
isNegative: { type: 'func', func: isNegative },
|
|
660
|
-
isNotNegative: { type: 'func', func: isNotNegative },
|
|
661
|
-
isZero: { type: 'func', func: isZero },
|
|
662
|
-
isNotZero: { type: 'func', func: isNotZero },
|
|
663
|
-
isGreaterThan: { type: 'param', func: isGreaterThan },
|
|
664
|
-
gt: { type: 'param', func: isGreaterThan },
|
|
665
|
-
isGreaterThanOrEqual: {
|
|
666
|
-
type: 'param', func: isGreaterThanOrEqual
|
|
667
|
-
},
|
|
668
|
-
gte: { type: 'param', func: isGreaterThanOrEqual },
|
|
669
|
-
isLessThan: { type: 'param', func: isLessThan },
|
|
670
|
-
lt: { type: 'param', func: isLessThan },
|
|
671
|
-
isLessThanOrEqual: {
|
|
672
|
-
type: 'param', func: isLessThanOrEqual
|
|
673
|
-
},
|
|
674
|
-
lte: { type: 'param', func: isLessThanOrEqual },
|
|
675
|
-
isInRange: { type: 'param', func: isInRange },
|
|
676
|
-
within: { type: 'param', func: isInRange }
|
|
677
|
-
};
|
|
678
|
-
const AllTesters = testers;
|
|
679
|
-
|
|
680
|
-
const trim = (value) => {
|
|
681
|
-
if (value == null) {
|
|
682
|
-
return { test: true, value };
|
|
683
|
-
}
|
|
684
|
-
else if (typeof value === 'string') {
|
|
685
|
-
return { test: true, value: value.trim() };
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
688
|
-
return { test: true, value };
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
const pad = (options) => {
|
|
692
|
-
const { length, char = ' ', direction = 'right' } = options;
|
|
693
|
-
return (value) => {
|
|
694
|
-
if (value == null) {
|
|
695
|
-
return { test: false, value };
|
|
696
|
-
}
|
|
697
|
-
const type = typeof value;
|
|
698
|
-
if (['string', 'number', 'bigint', 'boolean'].includes(type)) {
|
|
699
|
-
const stringified = `${value}`;
|
|
700
|
-
const len = stringified.length;
|
|
701
|
-
if (len >= length) {
|
|
702
|
-
return { test: true, value: stringified };
|
|
703
|
-
}
|
|
704
|
-
return {
|
|
705
|
-
test: true,
|
|
706
|
-
value: direction === 'left' ? stringified.padStart(length, char) : stringified.padEnd(length, char)
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
return { test: false, value };
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
};
|
|
714
|
-
const padStart = (options) => pad({ ...options, direction: 'left' });
|
|
715
|
-
const padEnd = (options) => pad({ ...options, direction: 'right' });
|
|
716
|
-
|
|
717
|
-
const transformers = {
|
|
718
|
-
trim: { type: 'func', func: trim },
|
|
719
|
-
pad: { type: 'param', func: pad },
|
|
720
|
-
padStart: { type: 'param', func: padStart },
|
|
721
|
-
padLeft: { type: 'param', func: padStart },
|
|
722
|
-
lpad: { type: 'param', func: padStart },
|
|
723
|
-
padEnd: { type: 'param', func: padEnd },
|
|
724
|
-
padRight: { type: 'param', func: padEnd },
|
|
725
|
-
rpad: { type: 'param', func: padEnd },
|
|
726
|
-
toDecimal: { type: 'func', func: toDecimal },
|
|
727
|
-
toNumber: { type: 'func', func: toNumber },
|
|
728
|
-
toFixed0: { type: 'func', func: toFixed(0) },
|
|
729
|
-
toFixed1: { type: 'func', func: toFixed(1) },
|
|
730
|
-
toFixed2: { type: 'func', func: toFixed(2) },
|
|
731
|
-
toFixed3: { type: 'func', func: toFixed(3) },
|
|
732
|
-
toFixed4: { type: 'func', func: toFixed(4) },
|
|
733
|
-
toFixed5: { type: 'func', func: toFixed(5) },
|
|
734
|
-
toFixed6: { type: 'func', func: toFixed(6) },
|
|
735
|
-
toFixed: { type: 'param', func: toFixed },
|
|
736
|
-
round: { type: 'param', func: roundUp },
|
|
737
|
-
roundUp: { type: 'param', func: roundUp },
|
|
738
|
-
roundDown: { type: 'param', func: roundDown },
|
|
739
|
-
floor: { type: 'param', func: floor },
|
|
740
|
-
ceil: { type: 'param', func: ceil },
|
|
741
|
-
roundBy: { type: 'param', func: roundBy }
|
|
742
|
-
};
|
|
743
|
-
const AllTransformers = transformers;
|
|
744
|
-
|
|
745
|
-
var ValueOperatorBootstrap_1;
|
|
746
|
-
const applyOperator = (operator, base) => {
|
|
747
|
-
if (base.$allowNoParamFuncCall) {
|
|
748
|
-
base.$allowNoParamFuncCall = false;
|
|
749
|
-
return operator;
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
throw new Error(`Function call is not allowed from: ${operator}.`);
|
|
753
|
-
}
|
|
754
|
-
};
|
|
755
|
-
const NOT_FOUND = Symbol('not found');
|
|
756
|
-
const findValueAction = (actions) => {
|
|
757
|
-
return (operator, base, prop) => {
|
|
758
|
-
const tester = actions[prop];
|
|
759
|
-
if (tester == null) {
|
|
760
|
-
return NOT_FOUND;
|
|
761
|
-
}
|
|
762
|
-
base.$allowUseDefault = true;
|
|
763
|
-
if (base.$actions == null) {
|
|
764
|
-
base.$actions = [];
|
|
765
|
-
}
|
|
766
|
-
if (tester.type === 'func') {
|
|
767
|
-
base.$actions.push(tester.func);
|
|
768
|
-
base.$allowNoParamFuncCall = true;
|
|
769
|
-
return operator;
|
|
770
|
-
}
|
|
771
|
-
else if (tester.type === 'param') {
|
|
772
|
-
return (...args) => {
|
|
773
|
-
base.$actions.push(tester.func(...args));
|
|
774
|
-
return operator;
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
else {
|
|
778
|
-
throw new Error(`Unknown tester type: ${tester}.`);
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
};
|
|
782
|
-
const findTester = findValueAction(AllTesters);
|
|
783
|
-
const findTransformer = findValueAction(AllTransformers);
|
|
784
|
-
const findUseDefault = (operator, base, prop) => {
|
|
785
|
-
if (!base.$allowUseDefault || !['orUseDefault', 'useDefault', 'withDefault', 'orElse', 'else'].includes(prop)) {
|
|
786
|
-
return NOT_FOUND;
|
|
787
|
-
}
|
|
788
|
-
if ((base.$actions == null || base.$actions.length === 0)) {
|
|
789
|
-
return (void 0);
|
|
790
|
-
}
|
|
791
|
-
base.$allowMoreAction = false;
|
|
792
|
-
base.$allowUseDefault = false;
|
|
793
|
-
return (defaultValue) => {
|
|
794
|
-
base.$defaultUsed = true;
|
|
795
|
-
base.$defaultValue = defaultValue;
|
|
796
|
-
return operator;
|
|
797
|
-
};
|
|
798
|
-
};
|
|
799
|
-
const createValueRetrieveFunc = (base) => {
|
|
800
|
-
return () => {
|
|
801
|
-
const tested = { test: true, value: base.$value };
|
|
802
|
-
for (const action of (base.$actions ?? [])) {
|
|
803
|
-
const result = action(tested.value);
|
|
804
|
-
if (!result.test) {
|
|
805
|
-
tested.test = false;
|
|
806
|
-
tested.value = base.$value;
|
|
807
|
-
break;
|
|
808
|
-
}
|
|
809
|
-
else {
|
|
810
|
-
tested.value = result.value;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
if (tested.test) ;
|
|
814
|
-
else if (base.$defaultUsed) {
|
|
815
|
-
tested.test = true;
|
|
816
|
-
tested.value = base.$defaultValue;
|
|
817
|
-
}
|
|
818
|
-
else {
|
|
819
|
-
tested.value = base.$value;
|
|
820
|
-
}
|
|
821
|
-
return tested;
|
|
822
|
-
};
|
|
823
|
-
};
|
|
824
|
-
const findValue = (_operator, base, prop) => {
|
|
825
|
-
if (prop !== 'value') {
|
|
826
|
-
return NOT_FOUND;
|
|
827
|
-
}
|
|
828
|
-
if ((base.$actions == null || base.$actions.length === 0)) {
|
|
829
|
-
return (void 0);
|
|
830
|
-
}
|
|
831
|
-
return () => createValueRetrieveFunc(base)().value;
|
|
832
|
-
};
|
|
833
|
-
const findSuccessOrFailureCallback = (_operator, base, prop) => {
|
|
834
|
-
if (prop !== 'success' && prop !== 'failure') {
|
|
835
|
-
return NOT_FOUND;
|
|
836
|
-
}
|
|
837
|
-
if ((base.$actions == null || base.$actions.length === 0)) {
|
|
838
|
-
return (void 0);
|
|
839
|
-
}
|
|
840
|
-
switch (prop) {
|
|
841
|
-
case 'success':
|
|
842
|
-
return (callback) => {
|
|
843
|
-
const tested = createValueRetrieveFunc(base)();
|
|
844
|
-
if (tested.test) {
|
|
845
|
-
callback(tested.value);
|
|
846
|
-
}
|
|
847
|
-
return {
|
|
848
|
-
failure: (callback) => {
|
|
849
|
-
if (!tested.test) {
|
|
850
|
-
callback(tested.value);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
};
|
|
855
|
-
case 'failure':
|
|
856
|
-
return (callback) => {
|
|
857
|
-
const tested = createValueRetrieveFunc(base)();
|
|
858
|
-
if (!tested.test) {
|
|
859
|
-
callback(tested.value);
|
|
860
|
-
}
|
|
861
|
-
return {
|
|
862
|
-
success: (callback) => {
|
|
863
|
-
if (tested.test) {
|
|
864
|
-
callback(tested.value);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
};
|
|
869
|
-
default:
|
|
870
|
-
throw new Error(`Unknown callback type: ${prop}.`);
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
const findOK = (operator, base, prop) => {
|
|
874
|
-
if (prop !== 'ok') {
|
|
875
|
-
return NOT_FOUND;
|
|
876
|
-
}
|
|
877
|
-
if ((base.$actions == null || base.$actions.length === 0)) {
|
|
878
|
-
return (void 0);
|
|
879
|
-
}
|
|
880
|
-
return () => createValueRetrieveFunc(base)().test;
|
|
881
|
-
};
|
|
882
|
-
const findPromise = (_operator, base, prop) => {
|
|
883
|
-
if (prop !== 'promise') {
|
|
884
|
-
return NOT_FOUND;
|
|
885
|
-
}
|
|
886
|
-
if ((base.$actions == null || base.$actions.length === 0)) {
|
|
887
|
-
return (void 0);
|
|
888
|
-
}
|
|
889
|
-
return async () => {
|
|
890
|
-
const tested = createValueRetrieveFunc(base)();
|
|
891
|
-
if (tested.test) {
|
|
892
|
-
return Promise.resolve(tested.value);
|
|
893
|
-
}
|
|
894
|
-
else {
|
|
895
|
-
return Promise.reject(tested.value);
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
};
|
|
899
|
-
const getFromOperator = (operator, base, prop) => {
|
|
900
|
-
base.$allowNoParamFuncCall = false;
|
|
901
|
-
const finds = [
|
|
902
|
-
findTester, findTransformer, findUseDefault,
|
|
903
|
-
findValue, findSuccessOrFailureCallback, findOK, findPromise
|
|
904
|
-
];
|
|
905
|
-
for (const find of finds) {
|
|
906
|
-
const result = find(operator, base, prop);
|
|
907
|
-
if (result !== NOT_FOUND) {
|
|
908
|
-
return result;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
return (void 0);
|
|
912
|
-
};
|
|
913
|
-
const createOperator = (base) => {
|
|
914
|
-
const operatorBase = () => {
|
|
915
|
-
};
|
|
916
|
-
operatorBase.$base = base;
|
|
917
|
-
const operator = new Proxy(operatorBase, {
|
|
918
|
-
apply(base, _thisArg, _argArray) {
|
|
919
|
-
return applyOperator(operator, base.$base);
|
|
920
|
-
},
|
|
921
|
-
get(base, p, _receiver) {
|
|
922
|
-
return getFromOperator(operator, base.$base, p);
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
return operator;
|
|
926
|
-
};
|
|
927
|
-
let ValueOperatorBootstrap = ValueOperatorBootstrap_1 = class ValueOperatorBootstrap {
|
|
928
|
-
constructor() {
|
|
929
|
-
}
|
|
930
|
-
static of(value) {
|
|
931
|
-
return createOperator({
|
|
932
|
-
$value: value,
|
|
933
|
-
$allowMoreAction: true, $allowUseDefault: false, $defaultUsed: false,
|
|
934
|
-
$allowNoParamFuncCall: false
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
static from(value) {
|
|
938
|
-
return ValueOperatorBootstrap_1.of(value);
|
|
939
|
-
}
|
|
940
|
-
static with(value) {
|
|
941
|
-
return ValueOperatorBootstrap_1.of(value);
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
ValueOperatorBootstrap = ValueOperatorBootstrap_1 = __decorate([
|
|
945
|
-
StaticImplements()
|
|
946
|
-
], ValueOperatorBootstrap);
|
|
947
|
-
const ValueOperator = ValueOperatorBootstrap;
|
|
948
|
-
|
|
949
421
|
var StepHelpersUtils_1;
|
|
950
422
|
const PIPELINE_STEP_FILE_SYMBOL = Symbol();
|
|
951
423
|
const PIPELINE_STEP_RETURN_NULL = Symbol();
|
|
@@ -997,27 +469,25 @@ exports.StepHelpersUtils = class StepHelpersUtils {
|
|
|
997
469
|
return PIPELINE_STEP_RETURN_NULL;
|
|
998
470
|
}
|
|
999
471
|
static isPrototype(value) {
|
|
1000
|
-
|
|
1001
|
-
const proto = (typeof Ctor === 'function' && Ctor.prototype) || OBJECT_PROTOTYPE;
|
|
1002
|
-
return value === proto;
|
|
472
|
+
return n1.isPrototype(value);
|
|
1003
473
|
}
|
|
1004
474
|
static isLength(value) {
|
|
1005
|
-
return isLength(value);
|
|
475
|
+
return n1.isLength(value);
|
|
1006
476
|
}
|
|
1007
477
|
static isArrayLike(value) {
|
|
1008
|
-
return isArrayLike(value);
|
|
478
|
+
return n1.isArrayLike(value);
|
|
1009
479
|
}
|
|
1010
480
|
static isEmpty(value) {
|
|
1011
|
-
return
|
|
481
|
+
return n1.ValueOperator.of(value).isEmpty().ok();
|
|
1012
482
|
}
|
|
1013
483
|
static isNotEmpty(value) {
|
|
1014
|
-
return
|
|
484
|
+
return n1.ValueOperator.of(value).isNotEmpty().ok();
|
|
1015
485
|
}
|
|
1016
486
|
static isBlank(value) {
|
|
1017
|
-
return
|
|
487
|
+
return n1.ValueOperator.of(value).isBlank().ok();
|
|
1018
488
|
}
|
|
1019
489
|
static isNotBlank(value) {
|
|
1020
|
-
return
|
|
490
|
+
return n1.ValueOperator.of(value).isNotBlank().ok();
|
|
1021
491
|
}
|
|
1022
492
|
static trim(value) {
|
|
1023
493
|
if (value == null) {
|
|
@@ -1029,7 +499,7 @@ exports.StepHelpersUtils = class StepHelpersUtils {
|
|
|
1029
499
|
throw new UncatchableError(ERR_TRIM_NON_STRING, `Cannot apply trim to non-string object[type=${typeof value}, value=${value}].`);
|
|
1030
500
|
}
|
|
1031
501
|
static touch(value) {
|
|
1032
|
-
return ValueOperator.
|
|
502
|
+
return n1.ValueOperator.of(value);
|
|
1033
503
|
}
|
|
1034
504
|
static noop() {
|
|
1035
505
|
}
|
|
@@ -1317,8 +787,6 @@ exports.AbstractPipeline = AbstractPipeline;
|
|
|
1317
787
|
exports.AbstractPipelineExecution = AbstractPipelineExecution;
|
|
1318
788
|
exports.AbstractPipelineStep = AbstractPipelineStep;
|
|
1319
789
|
exports.AbstractStaticPipeline = AbstractStaticPipeline;
|
|
1320
|
-
exports.AllTesters = AllTesters;
|
|
1321
|
-
exports.AllTransformers = AllTransformers;
|
|
1322
790
|
exports.CatchableError = CatchableError;
|
|
1323
791
|
exports.Config = Config;
|
|
1324
792
|
exports.ConsoleLogger = ConsoleLogger;
|
|
@@ -1333,51 +801,14 @@ exports.ErrorCodes = ErrorCodes;
|
|
|
1333
801
|
exports.ExposedUncatchableError = ExposedUncatchableError;
|
|
1334
802
|
exports.LoggerPerformanceSaver = LoggerPerformanceSaver;
|
|
1335
803
|
exports.LoggerUtils = LoggerUtils;
|
|
1336
|
-
exports.OBJECT_PROTOTYPE = OBJECT_PROTOTYPE;
|
|
1337
804
|
exports.PIPELINE_STEP_FILE_SYMBOL = PIPELINE_STEP_FILE_SYMBOL;
|
|
1338
805
|
exports.PIPELINE_STEP_RETURN_NULL = PIPELINE_STEP_RETURN_NULL;
|
|
1339
806
|
exports.PerformanceExecution = PerformanceExecution;
|
|
1340
807
|
exports.PipelineRepository = PipelineRepository;
|
|
1341
808
|
exports.PipelineStepDateHelper = PipelineStepDateHelper;
|
|
1342
809
|
exports.UncatchableError = UncatchableError;
|
|
1343
|
-
exports.ValueOperator = ValueOperator;
|
|
1344
|
-
exports.ceil = ceil;
|
|
1345
810
|
exports.createConfig = createConfig;
|
|
1346
811
|
exports.createLogger = createLogger;
|
|
1347
812
|
exports.createStepHelpers = createStepHelpers;
|
|
1348
|
-
exports.floor = floor;
|
|
1349
|
-
exports.isArrayLike = isArrayLike;
|
|
1350
|
-
exports.isBlank = isBlank;
|
|
1351
|
-
exports.isDecimal = isDecimal;
|
|
1352
|
-
exports.isEmpty = isEmpty;
|
|
1353
|
-
exports.isGreaterThan = isGreaterThan;
|
|
1354
|
-
exports.isGreaterThanOrEqual = isGreaterThanOrEqual;
|
|
1355
|
-
exports.isInRange = isInRange;
|
|
1356
|
-
exports.isInteger = isInteger;
|
|
1357
|
-
exports.isLength = isLength;
|
|
1358
|
-
exports.isLessThan = isLessThan;
|
|
1359
|
-
exports.isLessThanOrEqual = isLessThanOrEqual;
|
|
1360
|
-
exports.isNegative = isNegative;
|
|
1361
|
-
exports.isNotBlank = isNotBlank;
|
|
1362
|
-
exports.isNotEmpty = isNotEmpty;
|
|
1363
|
-
exports.isNotNegative = isNotNegative;
|
|
1364
|
-
exports.isNotNull = isNotNull;
|
|
1365
|
-
exports.isNotPositive = isNotPositive;
|
|
1366
|
-
exports.isNotZero = isNotZero;
|
|
1367
|
-
exports.isNull = isNull;
|
|
1368
|
-
exports.isPositive = isPositive;
|
|
1369
|
-
exports.isPrototype = isPrototype;
|
|
1370
|
-
exports.isZero = isZero;
|
|
1371
|
-
exports.pad = pad;
|
|
1372
|
-
exports.padEnd = padEnd;
|
|
1373
|
-
exports.padStart = padStart;
|
|
1374
|
-
exports.regexp = regexp;
|
|
1375
813
|
exports.registerToStepHelpers = registerToStepHelpers;
|
|
1376
|
-
exports.roundBy = roundBy;
|
|
1377
|
-
exports.roundDown = roundDown;
|
|
1378
|
-
exports.roundUp = roundUp;
|
|
1379
814
|
exports.saveLoggerPerformance = saveLoggerPerformance;
|
|
1380
|
-
exports.toDecimal = toDecimal;
|
|
1381
|
-
exports.toFixed = toFixed;
|
|
1382
|
-
exports.toNumber = toNumber;
|
|
1383
|
-
exports.trim = trim;
|