3xpr 1.11.5 → 1.12.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/expression/application/index.d.ts +3 -1
- package/expression/application/index.js +3 -1
- package/expression/application/index.js.map +1 -1
- package/expression/application/services/builder.d.ts +8 -4
- package/expression/application/services/builder.js +13 -12
- package/expression/application/services/builder.js.map +1 -1
- package/expression/application/services/builderCacheDecorator.d.ts +14 -0
- package/expression/application/services/builderCacheDecorator.js +40 -0
- package/expression/application/services/builderCacheDecorator.js.map +1 -0
- package/expression/application/services/expressionEvaluator.d.ts +9 -0
- package/expression/application/services/expressionEvaluator.js +19 -0
- package/expression/application/services/expressionEvaluator.js.map +1 -0
- package/expression/application/services/expressionEvaluatorObserveDecorator.d.ts +14 -0
- package/expression/application/services/expressionEvaluatorObserveDecorator.js +86 -0
- package/expression/application/services/expressionEvaluatorObserveDecorator.js.map +1 -0
- package/expression/application/services/parser.d.ts +4 -3
- package/expression/application/services/parser.js +4 -13
- package/expression/application/services/parser.js.map +1 -1
- package/expression/application/useCases/build.d.ts +5 -4
- package/expression/application/useCases/build.js +11 -36
- package/expression/application/useCases/build.js.map +1 -1
- package/expression/application/useCases/convert.d.ts +3 -1
- package/expression/application/useCases/convert.js +9 -16
- package/expression/application/useCases/convert.js.map +1 -1
- package/expression/domain/expressions.d.ts +8 -3
- package/expression/infrastructure/{convertFromFunction.d.ts → convertFrom/convertFromFunction.d.ts} +4 -2
- package/expression/infrastructure/{convertFromFunction.js → convertFrom/convertFromFunction.js} +8 -21
- package/expression/infrastructure/convertFrom/convertFromFunction.js.map +1 -0
- package/expression/infrastructure/{convertFromGraphql.d.ts → convertFrom/convertFromGraphql.d.ts} +1 -1
- package/expression/infrastructure/{convertFromGraphql.js → convertFrom/convertFromGraphql.js} +2 -11
- package/expression/infrastructure/convertFrom/convertFromGraphql.js.map +1 -0
- package/expression/{application → infrastructure}/expressions.d.ts +6 -8
- package/expression/infrastructure/expressions.js +123 -0
- package/expression/infrastructure/expressions.js.map +1 -0
- package/expression/infrastructure/index.d.ts +1 -0
- package/expression/infrastructure/index.js +1 -4
- package/expression/infrastructure/index.js.map +1 -1
- package/expression/infrastructure/library.d.ts +6 -4
- package/expression/infrastructure/library.js +241 -255
- package/expression/infrastructure/library.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +4 -7
- package/index.js.map +1 -1
- package/model/application/modelService.d.ts +2 -2
- package/model/application/modelService.js +3 -3
- package/model/application/modelService.js.map +1 -1
- package/model/domain/index.d.ts +1 -0
- package/model/domain/index.js +1 -0
- package/model/domain/index.js.map +1 -1
- package/model/domain/library.d.ts +4 -0
- package/model/domain/library.js +3 -0
- package/model/domain/library.js.map +1 -0
- package/model/domain/services.d.ts +1 -1
- package/operand/application/index.d.ts +1 -0
- package/operand/application/index.js +1 -0
- package/operand/application/index.js.map +1 -1
- package/operand/application/services/constBuilder.d.ts +1 -1
- package/operand/application/services/factory.d.ts +5 -4
- package/operand/application/services/factory.js +9 -10
- package/operand/application/services/factory.js.map +1 -1
- package/operand/application/services/parameterService.d.ts +2 -2
- package/operand/application/services/parameterService.js +5 -5
- package/operand/application/services/parameterService.js.map +1 -1
- package/operand/application/services/serializer.d.ts +2 -1
- package/operand/application/services/serializer.js +3 -3
- package/operand/application/services/serializer.js.map +1 -1
- package/operand/application/services/typeService.d.ts +5 -3
- package/operand/application/services/typeService.js +11 -10
- package/operand/application/services/typeService.js.map +1 -1
- package/operand/application/useCases/complete.d.ts +4 -3
- package/operand/application/useCases/complete.js +8 -22
- package/operand/application/useCases/complete.js.map +1 -1
- package/operand/application/useCases/normalize.d.ts +3 -1
- package/operand/application/useCases/normalize.js +4 -14
- package/operand/application/useCases/normalize.js.map +1 -1
- package/operand/application/useCases/reduce.d.ts +5 -2
- package/operand/application/useCases/reduce.js +5 -18
- package/operand/application/useCases/reduce.js.map +1 -1
- package/operand/domain/services.d.ts +8 -3
- package/operand/infrastructure/constBuilder.d.ts +2 -1
- package/operand/infrastructure/constBuilder.js +4 -14
- package/operand/infrastructure/constBuilder.js.map +1 -1
- package/operand/infrastructure/evaluators/async.d.ts +6 -118
- package/operand/infrastructure/evaluators/async.js +97 -174
- package/operand/infrastructure/evaluators/async.js.map +1 -1
- package/operand/infrastructure/evaluators/sync.d.ts +8 -94
- package/operand/infrastructure/evaluators/sync.js +107 -193
- package/operand/infrastructure/evaluators/sync.js.map +1 -1
- package/operand/infrastructure/helper.d.ts +3 -1
- package/operand/infrastructure/helper.js +6 -5
- package/operand/infrastructure/helper.js.map +1 -1
- package/operand/infrastructure/index.d.ts +2 -0
- package/operand/infrastructure/index.js +2 -4
- package/operand/infrastructure/index.js.map +1 -1
- package/package.json +1 -1
- package/shared/domain/operand.js +1 -1
- package/shared/domain/operand.js.map +1 -1
- package/expression/application/expressions.js +0 -184
- package/expression/application/expressions.js.map +0 -1
- package/expression/infrastructure/convertFromFunction.js.map +0 -1
- package/expression/infrastructure/convertFromGraphql.js.map +0 -1
|
@@ -1,115 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.CoreLibrary = void 0;
|
|
13
|
-
const __1 = require("
|
|
4
|
+
const __1 = require("../..");
|
|
14
5
|
const domain_1 = require("../../shared/domain");
|
|
15
6
|
const domain_2 = require("../../operand/domain");
|
|
16
7
|
const application_1 = require("../../operand/application");
|
|
17
|
-
const h3lp_1 = require("h3lp");
|
|
18
8
|
class CoreLibrary {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.model
|
|
37
|
-
this.model
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
// eslint-disable-next-line no-useless-constructor
|
|
10
|
+
constructor(builder) {
|
|
11
|
+
this.builder = builder;
|
|
12
|
+
}
|
|
13
|
+
load(model) {
|
|
14
|
+
this.constants(model);
|
|
15
|
+
this.enums(model);
|
|
16
|
+
this.formats(model);
|
|
17
|
+
this.operators(model);
|
|
18
|
+
this.generalFunctions(model);
|
|
19
|
+
this.comparisonFunctions(model);
|
|
20
|
+
this.nullFunctions(model);
|
|
21
|
+
this.numberFunctions(model);
|
|
22
|
+
this.stringFunctions(model);
|
|
23
|
+
this.arrayFunctions(model);
|
|
24
|
+
this.groupFunctions(model);
|
|
25
|
+
this.dateTimeFunctions(model);
|
|
26
|
+
this.conversionFunctions(model);
|
|
27
|
+
this.setsFunctions(model);
|
|
28
|
+
}
|
|
29
|
+
constants(model) {
|
|
30
|
+
model.addConstant('true', true);
|
|
31
|
+
model.addConstant('false', false);
|
|
32
|
+
model.addConstant('null', null);
|
|
33
|
+
}
|
|
34
|
+
enums(model) {
|
|
35
|
+
model.addEnum('DayOfWeek', [['Sunday', 0], ['Monday', 1], ['Tuesday', 2], ['Wednesday', 3], ['Thursday', 4], ['Friday', 5], ['Saturday', 6]]);
|
|
36
|
+
}
|
|
37
|
+
formats(model) {
|
|
38
|
+
model.addFormat('email', '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$');
|
|
39
|
+
model.addFormat('integer', '^\\d+$');
|
|
40
|
+
model.addFormat('decimal', '^\\d+\\.\\d+$');
|
|
41
|
+
model.addFormat('string', '^[a-zA-Z0-9_.]+$');
|
|
48
42
|
// https://stackoverflow.com/questions/3143070/javascript-regex-iso-dateTime
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
operators() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
43
|
+
model.addFormat('date', '^\\d{4}-\\d{2}-\\d{2}$');
|
|
44
|
+
model.addFormat('dateTime', '\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z)');
|
|
45
|
+
model.addFormat('time', '\\[0-2]\\d:[0-5]\\d:[0-5]\\d');
|
|
46
|
+
}
|
|
47
|
+
operators(model) {
|
|
48
|
+
model.addOperator('+(a:T,b:T):T', (a, b) => a + b, { priority: 5 });
|
|
49
|
+
model.addOperator('-(a:number,b:number):number', (a, b) => a - b, { priority: 5 });
|
|
50
|
+
model.addOperator('-(a:number):number', (a) => a * -1, { priority: 9 });
|
|
51
|
+
model.addOperator('*(a:number,b:number):number', (a, b) => a * b, { priority: 6 });
|
|
52
|
+
model.addOperator('/(a:number,b:number):number', (a, b) => a / b, { priority: 6 });
|
|
53
|
+
model.addOperator('**(a:number,b:number):number', (a, b) => a ** b, { priority: 7 });
|
|
54
|
+
model.addOperator('//(a:number,b:number):number', (a, b) => Math.pow(a, 1 / b), { priority: 7 });
|
|
55
|
+
model.addOperator('%(a:number,b:number):number', (a, b) => a % b, { priority: 8 });
|
|
56
|
+
model.addOperator('&(a:number,b:number):number', (a, b) => a & b, { priority: 5 });
|
|
57
|
+
model.addOperator('|(a:number,b:number):number', (a, b) => a | b, { priority: 5 });
|
|
58
|
+
model.addOperator('^(a:number,b:number):number', (a, b) => a ^ b, { priority: 5 });
|
|
59
|
+
model.addOperator('~(a:number):number', (a) => ~a, { priority: 9 });
|
|
60
|
+
model.addOperator('<<(a:number,b:number):number', (a, b) => a << b, { priority: 5 });
|
|
61
|
+
model.addOperator('>>(a:number,b:number):number', (a, b) => a >> b, { priority: 5 });
|
|
62
|
+
model.addOperator('==(a:T,b:T):boolean', (a, b) => a === b, { priority: 4 });
|
|
63
|
+
model.addOperatorAlias('===', '==');
|
|
64
|
+
model.addOperator('!=(a:T,b:T):boolean', (a, b) => a !== b, { priority: 4 });
|
|
65
|
+
model.addOperatorAlias('!==', '!=');
|
|
66
|
+
model.addOperatorAlias('<>', '!=');
|
|
67
|
+
model.addOperator('>(a:T,b:T):boolean', (a, b) => a > b, { priority: 4 });
|
|
68
|
+
model.addOperator('<(a:T,b:T):boolean', (a, b) => a < b, { priority: 4 });
|
|
69
|
+
model.addOperator('>=(a:T,b:T):boolean', (a, b) => a >= b, { priority: 4 });
|
|
70
|
+
model.addOperator('<=(a:T,b:T):boolean', (a, b) => a <= b, { priority: 3 });
|
|
71
|
+
model.addOperator('&&(a:boolean,b:boolean):boolean', new And(), { priority: 3 });
|
|
72
|
+
model.addOperator('||(a:boolean,b:boolean):boolean', new Or(), { priority: 3 });
|
|
73
|
+
model.addOperator('!(a:boolean):boolean', (a) => !a, { priority: 5 });
|
|
80
74
|
// index is any, because it can also be string when used to access a property of an object
|
|
81
75
|
// example: orders[0]["number"]
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
generalFunctions() {
|
|
99
|
-
//
|
|
100
|
-
|
|
76
|
+
model.addOperator('[](list:T[],index:any):T', (list, index) => list[index], { priority: 2 });
|
|
77
|
+
model.addOperator('$(name:string):string', (name) => process.env[name], { priority: 9 });
|
|
78
|
+
model.addOperator('=(a:T,b:T):T', new Assignment(), { priority: 1 });
|
|
79
|
+
model.addOperator('+=(a:number,b:number):number', new AssignmentAddition(), { priority: 1 });
|
|
80
|
+
model.addOperator('-=(a:number,b:number):number', new AssignmentSubtraction(), { priority: 1 });
|
|
81
|
+
model.addOperator('*=(a:number,b:number):number', new AssignmentMultiplication(), { priority: 1 });
|
|
82
|
+
model.addOperator('/=(a:number,b:number):number', new AssignmentDivision(), { priority: 1 });
|
|
83
|
+
model.addOperator('**=(a:number,b:number):number', new AssignmentExponentiation(), { priority: 1 });
|
|
84
|
+
model.addOperator('//=(a:number,b:number):number', new AssignmentFloorDivision(), { priority: 1 });
|
|
85
|
+
model.addOperator('%=(a:number,b:number):number', new AssignmentMod(), { priority: 1 });
|
|
86
|
+
model.addOperator('&=(a:number,b:number):number', new AssignmentBitAnd(), { priority: 1 });
|
|
87
|
+
model.addOperator('|=(a:number,b:number):number', new AssignmentBitOr(), { priority: 1 });
|
|
88
|
+
model.addOperator('^=(a:number,b:number):number', new AssignmentBitXor(), { priority: 1 });
|
|
89
|
+
model.addOperator('<<=(a:number,b:number):number', new AssignmentLeftShift(), { priority: 1 });
|
|
90
|
+
model.addOperator('>>=(a:number,b:number):number', new AssignmentRightShift(), { priority: 1 });
|
|
91
|
+
}
|
|
92
|
+
generalFunctions(model) {
|
|
93
|
+
// model.addFunction('async sleep(ms?: number)', Functions.sleep)
|
|
94
|
+
model.addFunction('console(value:any)', (value) => {
|
|
101
95
|
console.log(typeof value === 'object' ? JSON.stringify(value) : value);
|
|
102
96
|
});
|
|
103
97
|
}
|
|
104
|
-
nullFunctions() {
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
nullFunctions(model) {
|
|
99
|
+
model.addFunction('nvl(value:T, default:T):T', (value, _default) => __1.helper.utils.nvl(value, _default));
|
|
100
|
+
model.addFunction('nvl2(value:any, a:T,b:T):T', (value, a, b) => __1.helper.utils.nvl2(value, a, b));
|
|
107
101
|
}
|
|
108
|
-
comparisonFunctions() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
comparisonFunctions(model) {
|
|
103
|
+
model.addFunction('between(value:T,from:T,to:T):boolean', (value, from, to) => __1.helper.val.between(value, from, to));
|
|
104
|
+
model.addFunction('includes(source:string|T[],value:string|T):boolean', (source, value) => source && value ? source.includes(value) : false);
|
|
105
|
+
model.addFunctionAlias('contains', 'includes');
|
|
106
|
+
model.addFunction('in(source:T,...values:T):boolean', (source, ...values) => {
|
|
113
107
|
if (source === undefined || values === undefined) {
|
|
114
108
|
return false;
|
|
115
109
|
}
|
|
@@ -120,90 +114,90 @@ class CoreLibrary {
|
|
|
120
114
|
return values.includes(source);
|
|
121
115
|
}
|
|
122
116
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
numberFunctions() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
conversionFunctions() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
117
|
+
model.addFunction('isNull(value:any):boolean', (value) => __1.helper.val.isNull(value));
|
|
118
|
+
model.addFunction('isNotNull(value:any):boolean', (value) => __1.helper.val.isNotNull(value));
|
|
119
|
+
model.addFunction('isEmpty(value:string):boolean', (value) => __1.helper.val.isEmpty(value));
|
|
120
|
+
model.addFunction('isNotEmpty(value:string):boolean', (value) => __1.helper.val.isNotEmpty(value));
|
|
121
|
+
model.addFunction('isBoolean(value:any):boolean', (value) => __1.helper.val.isBoolean(value));
|
|
122
|
+
model.addFunction('isNumber(value:any):boolean', (value) => __1.helper.val.isNumber(value));
|
|
123
|
+
model.addFunction('isInteger(value:any):boolean', (value) => __1.helper.val.isInteger(value));
|
|
124
|
+
model.addFunction('isDecimal(value:any):boolean', (value) => __1.helper.val.isDecimal(value));
|
|
125
|
+
model.addFunction('isString(value:any):boolean', (value) => __1.helper.val.isString(value));
|
|
126
|
+
model.addFunction('isDate(value:any):boolean', (value) => __1.helper.val.isDate(value));
|
|
127
|
+
model.addFunction('isDateTime(value:any):boolean', (value) => __1.helper.val.isDateTime(value));
|
|
128
|
+
model.addFunction('isTime(value:any):boolean', (value) => __1.helper.val.isTime(value));
|
|
129
|
+
model.addFunction('isObject(value:any):boolean', (value) => __1.helper.val.isObject(value));
|
|
130
|
+
model.addFunction('isArray(value:any):boolean', (value) => __1.helper.val.isArray(value));
|
|
131
|
+
model.addFunction('isBooleanFormat(value:string):boolean', (value) => __1.helper.val.isBooleanFormat(value));
|
|
132
|
+
model.addFunction('isNumberFormat(value:string):boolean', (value) => __1.helper.val.isNumberFormat(value));
|
|
133
|
+
model.addFunction('isIntegerFormat(value:string):boolean', (value) => __1.helper.val.isIntegerFormat(value));
|
|
134
|
+
model.addFunction('isDecimalFormat(value:string):boolean', (value) => __1.helper.val.isDecimalFormat(value));
|
|
135
|
+
model.addFunction('isDateFormat(value:string):boolean', (value) => __1.helper.val.isDateFormat(value));
|
|
136
|
+
model.addFunction('isDateTimeFormat(value:string):boolean', (value) => __1.helper.val.isDateTimeFormat(value));
|
|
137
|
+
model.addFunction('isTimeFormat(value:string):boolean', (value) => __1.helper.val.isTimeFormat(value));
|
|
138
|
+
}
|
|
139
|
+
numberFunctions(model) {
|
|
140
|
+
model.addFunction('abs(x:number):number', Math.abs);
|
|
141
|
+
model.addFunction('acos(x:number):number', Math.acos);
|
|
142
|
+
model.addFunction('asin(x:number):number', Math.asin);
|
|
143
|
+
model.addFunction('atan(x:number):number', Math.atan);
|
|
144
|
+
model.addFunction('atan2(x:number):number', Math.atan2);
|
|
145
|
+
model.addFunction('ceil(x:number):number', Math.ceil);
|
|
146
|
+
model.addFunction('cos(x:number):number', Math.cos);
|
|
147
|
+
model.addFunction('cosh(x:number):number', Math.cosh);
|
|
148
|
+
model.addFunction('exp(x:number):number', Math.exp);
|
|
149
|
+
model.addFunction('floor(x:number):number', Math.floor);
|
|
150
|
+
model.addFunction('ln(x:number):number', Math.log);
|
|
151
|
+
model.addFunction('log10(x:number):number', Math.log10);
|
|
152
|
+
model.addFunction('log(x:number):number', Math.log);
|
|
153
|
+
model.addFunction('remainder(n1:number,n2:number):number', (n1, n2) => n1 % n2);
|
|
154
|
+
model.addFunction('round(num:number,decimals=0):number', (num, decimals = 0) => decimals > 0 ? Number(num.toFixed(decimals)) : Math.round(num));
|
|
155
|
+
model.addFunction('sign(x:number):number', Math.sign);
|
|
156
|
+
model.addFunction('sin(x:number):number', Math.sin);
|
|
157
|
+
model.addFunction('sinh(x:number):number', Math.sinh);
|
|
158
|
+
model.addFunction('tan(x:number):number', Math.tan);
|
|
159
|
+
model.addFunction('tanh(x:number):number', Math.tanh);
|
|
160
|
+
model.addFunction('trunc(x:number):number', Math.trunc);
|
|
161
|
+
}
|
|
162
|
+
conversionFunctions(model) {
|
|
163
|
+
model.addFunction('toString(value:any):string', (value) => __1.helper.str.toString(value));
|
|
164
|
+
model.addFunction('toNumber(value:any):number', (value) => __1.helper.utils.toNumber(value));
|
|
165
|
+
model.addFunction('dateToString(date:date):string', (date) => {
|
|
172
166
|
if (typeof date === 'string') {
|
|
173
167
|
return new Date(date).toISOString();
|
|
174
168
|
}
|
|
175
169
|
return date.toISOString();
|
|
176
170
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
stringFunctions() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
171
|
+
model.addFunction('stringify(value:any):string', (value) => JSON.stringify(value));
|
|
172
|
+
model.addFunction('parse(value:string):any', (value) => JSON.parse(value));
|
|
173
|
+
model.addFunction('keys(obj: any):string[]', (obj) => typeof obj === 'object' ? Object.keys(obj) : []);
|
|
174
|
+
model.addFunction('values(obj: any):any[]', (obj) => typeof obj === 'object' ? Object.values(obj) : []);
|
|
175
|
+
model.addFunction('entries(obj: any):[string,any][]', (obj) => typeof obj === 'object' ? Object.entries(obj) : []);
|
|
176
|
+
model.addFunction('fromEntries(entries: [string,any][]): any', (entries) => __1.helper.obj.fromEntries(entries));
|
|
177
|
+
}
|
|
178
|
+
stringFunctions(model) {
|
|
179
|
+
model.addFunction('chr(ascii: number):string', (ascii) => String.fromCharCode(ascii));
|
|
180
|
+
model.addFunction('capitalize(value:string):string', (value) => __1.helper.str.capitalize(value));
|
|
181
|
+
model.addFunction('endsWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.endsWith(sub, start));
|
|
182
|
+
model.addFunction('strCount(source: string, value: string):number', (source, value) => source.split(value).length - 1);
|
|
183
|
+
model.addFunction('lower(value: string):string', (value) => value.toLowerCase());
|
|
184
|
+
model.addFunction('lpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padStart(len, pad));
|
|
185
|
+
model.addFunction('ltrim(value: string):string', (value) => value.trimLeft());
|
|
186
|
+
model.addFunction('indexOf(value:string, sub:string, start:number):number', (value, sub, start) => value.indexOf(sub, start));
|
|
187
|
+
model.addFunction('join(values:string[],separator:string=","):string', (values, separator = ',') => values.join(separator));
|
|
188
|
+
model.addFunction('replace(value: string, source: string, target: string):string', (value, source, target) => __1.helper.str.replace(value, source, target));
|
|
189
|
+
model.addFunction('rpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padEnd(len, pad));
|
|
190
|
+
model.addFunction('rtrim(value: string):string', (value) => value.trimRight());
|
|
191
|
+
model.addFunction('substring(value: string, from: number, count: number):string', (value, from, count) => value.substring(from, count));
|
|
192
|
+
model.addFunctionAlias('substr', 'substring');
|
|
193
|
+
model.addFunction('trim(value: string):string', (value) => value.trim());
|
|
194
|
+
model.addFunction('upper(value: string):string', (value) => value.toUpperCase());
|
|
195
|
+
model.addFunction('concat(...values:any):string', (...values) => __1.helper.str.concat(values));
|
|
196
|
+
model.addFunctionAlias('concatenate', 'concat');
|
|
197
|
+
model.addFunction('test(value: string, regexp: string):boolean', (value, regexp) => new RegExp(regexp).test(value));
|
|
198
|
+
model.addFunction('title(value:string):string', (value) => __1.helper.str.initCap(value));
|
|
199
|
+
model.addFunction('match(value: string, regexp: string):any', (value, regexp) => value ? value.match(regexp) : null);
|
|
200
|
+
model.addFunction('mask(value: string):string', (value) => {
|
|
207
201
|
if (!value)
|
|
208
202
|
return value;
|
|
209
203
|
if (value.length > 8) {
|
|
@@ -216,88 +210,88 @@ class CoreLibrary {
|
|
|
216
210
|
return '*';
|
|
217
211
|
}
|
|
218
212
|
});
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
model.addFunction('split(value:string,separator:string=","):string[]', (value, separator = ',') => value.split(separator));
|
|
214
|
+
model.addFunction('startWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.startsWith(sub, start));
|
|
221
215
|
}
|
|
222
|
-
dateTimeFunctions() {
|
|
223
|
-
|
|
216
|
+
dateTimeFunctions(model) {
|
|
217
|
+
model.addFunction('curTime():time', () => {
|
|
224
218
|
const date = new Date();
|
|
225
219
|
return date.getHours() + ':' + (date.getMinutes() + 1) + ':' + date.getSeconds();
|
|
226
220
|
});
|
|
227
|
-
|
|
221
|
+
model.addFunction('today():date', () => {
|
|
228
222
|
const date = new Date();
|
|
229
223
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
|
|
230
224
|
});
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
model.addFunction('now():dateTime', () => new Date().toISOString());
|
|
226
|
+
model.addFunction('time(value: string):time', (value) => {
|
|
233
227
|
const date = new Date(value);
|
|
234
228
|
return date.getHours() + ':' + (date.getMinutes() + 1) + ':' + date.getSeconds();
|
|
235
229
|
});
|
|
236
|
-
|
|
230
|
+
model.addFunction('date(value: string):date', (value) => {
|
|
237
231
|
const date = new Date(value);
|
|
238
232
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
|
|
239
233
|
});
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
model.addFunction('dateTime(value: string):dateTime', (value) => new Date(value).toISOString());
|
|
235
|
+
model.addFunction('year(value: dateTime):integer', (value) => {
|
|
242
236
|
return new Date(value).getFullYear();
|
|
243
237
|
});
|
|
244
|
-
|
|
238
|
+
model.addFunction('month(value: dateTime):integer', (value) => {
|
|
245
239
|
return new Date(value).getMonth() + 1;
|
|
246
240
|
});
|
|
247
|
-
|
|
241
|
+
model.addFunction('day(value: dateTime):integer', (value) => {
|
|
248
242
|
return new Date(value).getDate();
|
|
249
243
|
});
|
|
250
|
-
|
|
244
|
+
model.addFunction('weekday(value: dateTime):integer', (value) => {
|
|
251
245
|
return new Date(value).getDay();
|
|
252
246
|
});
|
|
253
|
-
|
|
247
|
+
model.addFunction('hour(value: dateTime):integer', (value) => {
|
|
254
248
|
return new Date(value).getHours();
|
|
255
249
|
});
|
|
256
|
-
|
|
250
|
+
model.addFunction('minute(value: dateTime):integer', (value) => {
|
|
257
251
|
return new Date(value).getMinutes();
|
|
258
252
|
});
|
|
259
|
-
|
|
253
|
+
model.addFunction('second(value: dateTime):integer', (value) => {
|
|
260
254
|
return new Date(value).getSeconds();
|
|
261
255
|
});
|
|
262
|
-
|
|
256
|
+
model.addFunction('millisecond(value: dateTime):integer', (value) => {
|
|
263
257
|
return new Date(value).getMilliseconds();
|
|
264
258
|
});
|
|
265
|
-
|
|
259
|
+
model.addFunction('addYear(date: dateTime, value: number):dateTime', (date, value) => {
|
|
266
260
|
const _date = new Date(date);
|
|
267
261
|
_date.setFullYear(_date.getFullYear() + value);
|
|
268
262
|
return _date.toISOString();
|
|
269
263
|
});
|
|
270
|
-
|
|
264
|
+
model.addFunction('addMonth(date: dateTime, value: number):dateTime', (date, value) => {
|
|
271
265
|
const _date = new Date(date);
|
|
272
266
|
_date.setMonth(_date.getMonth() + value);
|
|
273
267
|
return _date.toISOString();
|
|
274
268
|
});
|
|
275
|
-
|
|
269
|
+
model.addFunction('addDay(date: dateTime, value: number):dateTime', (date, value) => {
|
|
276
270
|
const _date = new Date(date);
|
|
277
271
|
_date.setDate(_date.getDate() + value);
|
|
278
272
|
return _date.toISOString();
|
|
279
273
|
});
|
|
280
|
-
|
|
274
|
+
model.addFunction('addHour(date: dateTime, value: number):dateTime', (date, value) => {
|
|
281
275
|
const _date = new Date(date);
|
|
282
276
|
_date.setHours(_date.getHours() + value);
|
|
283
277
|
return _date.toISOString();
|
|
284
278
|
});
|
|
285
|
-
|
|
279
|
+
model.addFunction('addMinute(date: dateTime, value: number):dateTime', (date, value) => {
|
|
286
280
|
const _date = new Date(date);
|
|
287
281
|
_date.setMinutes(_date.getMinutes() + value);
|
|
288
282
|
return _date.toISOString();
|
|
289
283
|
});
|
|
290
|
-
|
|
284
|
+
model.addFunction('addSecond(date: dateTime, value: number):dateTime', (date, value) => {
|
|
291
285
|
const _date = new Date(date);
|
|
292
286
|
_date.setSeconds(_date.getSeconds() + value);
|
|
293
287
|
return _date.toISOString();
|
|
294
288
|
});
|
|
295
|
-
|
|
289
|
+
model.addFunction('addMillisecond(date: dateTime, value: number):dateTime', (date, value) => {
|
|
296
290
|
const _date = new Date(date);
|
|
297
291
|
_date.setMilliseconds(_date.getMilliseconds() + value);
|
|
298
292
|
return _date.toISOString();
|
|
299
293
|
});
|
|
300
|
-
|
|
294
|
+
model.addFunction('addTime(date: dateTime, time: time):dateTime', (date, time) => {
|
|
301
295
|
const _time = new Date('2000-01-01T' + time);
|
|
302
296
|
const _date = new Date(date);
|
|
303
297
|
_date.setHours(_date.getHours() + _time.getHours());
|
|
@@ -306,7 +300,7 @@ class CoreLibrary {
|
|
|
306
300
|
_date.setMilliseconds(_date.getSeconds() + _time.getMilliseconds());
|
|
307
301
|
return _date.toISOString();
|
|
308
302
|
});
|
|
309
|
-
|
|
303
|
+
model.addFunction('subtractTime(date: dateTime, time: time):dateTime', (date, time) => {
|
|
310
304
|
const _time = new Date('2000-01-01T' + time);
|
|
311
305
|
const _date = new Date(date);
|
|
312
306
|
_date.setHours(_date.getHours() - _time.getHours());
|
|
@@ -315,72 +309,72 @@ class CoreLibrary {
|
|
|
315
309
|
_date.setMilliseconds(_date.getSeconds() - _time.getMilliseconds());
|
|
316
310
|
return _date.toISOString();
|
|
317
311
|
});
|
|
318
|
-
|
|
312
|
+
model.addFunction('yearDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
319
313
|
const _date1 = new Date(date1);
|
|
320
314
|
const _date2 = new Date(date2);
|
|
321
315
|
return Math.abs(_date2.getFullYear() - _date1.getFullYear());
|
|
322
316
|
});
|
|
323
|
-
|
|
317
|
+
model.addFunction('dayDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
324
318
|
const _date1 = new Date(date1);
|
|
325
319
|
const _date2 = new Date(date2);
|
|
326
320
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (24 * 3600 * 1000));
|
|
327
321
|
});
|
|
328
|
-
|
|
322
|
+
model.addFunction('hourDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
329
323
|
const _date1 = new Date(date1);
|
|
330
324
|
const _date2 = new Date(date2);
|
|
331
325
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (3600 * 1000));
|
|
332
326
|
});
|
|
333
|
-
|
|
327
|
+
model.addFunction('secondDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
334
328
|
const _date1 = new Date(date1);
|
|
335
329
|
const _date2 = new Date(date2);
|
|
336
330
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (1000));
|
|
337
331
|
});
|
|
338
|
-
|
|
332
|
+
model.addFunction('millisecondDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
339
333
|
const _date1 = new Date(date1);
|
|
340
334
|
const _date2 = new Date(date2);
|
|
341
335
|
return Math.floor(_date1.getTime() - _date2.getTime());
|
|
342
336
|
});
|
|
343
|
-
|
|
337
|
+
model.addFunction('dayToDate(value: number):dateTime', (value) => {
|
|
344
338
|
return new Date(value * 24 * 3600 * 1000).toISOString();
|
|
345
339
|
});
|
|
346
|
-
|
|
340
|
+
model.addFunction('hourToDate(value: number):dateTime', (value) => {
|
|
347
341
|
return new Date(value * 3600 * 1000).toISOString();
|
|
348
342
|
});
|
|
349
|
-
|
|
343
|
+
model.addFunction('secondToDate(value: number):dateTime', (value) => {
|
|
350
344
|
return new Date(value * 1000).toISOString();
|
|
351
345
|
});
|
|
352
|
-
|
|
346
|
+
model.addFunction('millisecondToDate(value: number):dateTime', (value) => {
|
|
353
347
|
return new Date(value).toISOString();
|
|
354
348
|
});
|
|
355
349
|
}
|
|
356
|
-
arrayFunctions() {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
350
|
+
arrayFunctions(model) {
|
|
351
|
+
model.addFunction('map(list: any[], predicate: T):T[]', new Map(this.builder));
|
|
352
|
+
model.addFunctionAlias('select', 'map');
|
|
353
|
+
model.addFunction('foreach(list: any[], predicate: any):void', new Foreach());
|
|
354
|
+
model.addFunctionAlias('each', 'foreach');
|
|
355
|
+
model.addFunction('filter(list: T[], predicate: boolean):T[]', new Filter());
|
|
356
|
+
model.addFunctionAlias('where', 'filter');
|
|
357
|
+
model.addFunction('reverse(list: T[], predicate: any):T[]', new Reverse());
|
|
358
|
+
model.addFunction('sort(list: T[], predicate: any):T[]', new Sort());
|
|
359
|
+
model.addFunctionAlias('order', 'sort');
|
|
360
|
+
model.addFunction('remove(list: T[], predicate: boolean):T[]', new Remove());
|
|
361
|
+
model.addFunctionAlias('delete', 'remove');
|
|
362
|
+
model.addFunction('push(list: T[], value: T):T[]', (list, item) => {
|
|
369
363
|
list.push(item);
|
|
370
364
|
return list;
|
|
371
365
|
});
|
|
372
|
-
|
|
373
|
-
|
|
366
|
+
model.addFunctionAlias('insert', 'push');
|
|
367
|
+
model.addFunction('bulkInsert(list: T[], value: T[]):T[]', (list, items) => {
|
|
374
368
|
for (const item of items) {
|
|
375
369
|
list.push(item);
|
|
376
370
|
}
|
|
377
371
|
return list;
|
|
378
372
|
});
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
373
|
+
model.addFunction('pop(list: T[]): T', (list) => list.pop());
|
|
374
|
+
model.addFunction('length(source: any[]|string):number', (source) => source.length);
|
|
375
|
+
model.addFunctionAlias('len', 'length');
|
|
376
|
+
model.addFunction('slice(list: T[], from:integer, to:integer):T[]', (list, from, to) => list.slice(from, to));
|
|
377
|
+
model.addFunction('page(list: T[], page:integer, records:integer):T[]', (list, page, records) => {
|
|
384
378
|
let from = (page - 1) * records;
|
|
385
379
|
if (from < 0) {
|
|
386
380
|
from = 0;
|
|
@@ -393,31 +387,23 @@ class CoreLibrary {
|
|
|
393
387
|
});
|
|
394
388
|
// this.addFunction('update', ArrayFunctions.update, OperatorType.arrow, Update)
|
|
395
389
|
}
|
|
396
|
-
groupFunctions() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
setsFunctions() {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
390
|
+
groupFunctions(model) {
|
|
391
|
+
model.addFunction('distinct(list: any[], predicate: any): any[]', new Distinct());
|
|
392
|
+
model.addFunction('first(list: T[], predicate: boolean): T', new First());
|
|
393
|
+
model.addFunction('last(list: T[], predicate: boolean): T', new Last());
|
|
394
|
+
model.addFunction('count(list: T[], predicate: boolean): integer', new Count());
|
|
395
|
+
model.addFunction('max(list: T[], predicate: boolean): T', new Max());
|
|
396
|
+
model.addFunction('min(list: T[], predicate: boolean): T', new Min());
|
|
397
|
+
model.addFunction('avg(list: T[], value: number): number', new Avg());
|
|
398
|
+
model.addFunction('sum(list: T[], value: number): number', new Sum());
|
|
399
|
+
}
|
|
400
|
+
setsFunctions(model) {
|
|
401
|
+
model.addFunction('union(a: T[], b: T[]): T[]', new Union());
|
|
402
|
+
model.addFunction('intersection(a: T[], b: T[]): T[]', new Intersection());
|
|
403
|
+
model.addFunction('difference(a: T[], b: T[]): T[]', new Difference());
|
|
404
|
+
model.addFunction('symmetricDifference(a: T[], b: T[]): T[]', new SymmetricDifference());
|
|
411
405
|
}
|
|
412
406
|
}
|
|
413
|
-
__decorate([
|
|
414
|
-
(0, h3lp_1.Autowired)('exp.operand.builder.sync'),
|
|
415
|
-
__metadata("design:type", Object)
|
|
416
|
-
], CoreLibrary.prototype, "builder", void 0);
|
|
417
|
-
__decorate([
|
|
418
|
-
(0, h3lp_1.Autowired)('exp.model.service'),
|
|
419
|
-
__metadata("design:type", Object)
|
|
420
|
-
], CoreLibrary.prototype, "model", void 0);
|
|
421
407
|
exports.CoreLibrary = CoreLibrary;
|
|
422
408
|
class And extends domain_2.PrototypeEvaluator {
|
|
423
409
|
clone(operand) {
|