3xpr 1.15.15 → 1.15.17
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/expressions.d.ts +1 -1
- package/expression/application/expressions.js.map +1 -1
- package/expression/infrastructure/library.js +183 -183
- package/expression/infrastructure/library.js.map +1 -1
- package/model/application/modelService.d.ts +1 -1
- package/model/application/modelService.js +2 -0
- package/model/application/modelService.js.map +1 -1
- package/model/domain/services.d.ts +1 -1
- package/operand/domain/entities.d.ts +4 -2
- package/operand/domain/entities.js.map +1 -1
- package/package.json +1 -1
- package/__tests__/array.test.d.ts +0 -1
- package/__tests__/array.test.js +0 -37
- package/__tests__/array.test.js.map +0 -1
- package/__tests__/auto/access.test.d.ts +0 -1
- package/__tests__/auto/access.test.js +0 -31
- package/__tests__/auto/access.test.js.map +0 -1
- package/__tests__/auto/arithmetic.test.d.ts +0 -1
- package/__tests__/auto/arithmetic.test.js +0 -20
- package/__tests__/auto/arithmetic.test.js.map +0 -1
- package/__tests__/auto/array.test.d.ts +0 -1
- package/__tests__/auto/array.test.js +0 -25
- package/__tests__/auto/array.test.js.map +0 -1
- package/__tests__/auto/arrow.test.d.ts +0 -1
- package/__tests__/auto/arrow.test.js +0 -29
- package/__tests__/auto/arrow.test.js.map +0 -1
- package/__tests__/auto/assignment.test.d.ts +0 -1
- package/__tests__/auto/assignment.test.js +0 -14
- package/__tests__/auto/assignment.test.js.map +0 -1
- package/__tests__/auto/bitwise.test.d.ts +0 -1
- package/__tests__/auto/bitwise.test.js +0 -16
- package/__tests__/auto/bitwise.test.js.map +0 -1
- package/__tests__/auto/comparison.test.d.ts +0 -1
- package/__tests__/auto/comparison.test.js +0 -72
- package/__tests__/auto/comparison.test.js.map +0 -1
- package/__tests__/auto/constants.test.d.ts +0 -1
- package/__tests__/auto/constants.test.js +0 -15
- package/__tests__/auto/constants.test.js.map +0 -1
- package/__tests__/auto/dateTime.test.d.ts +0 -1
- package/__tests__/auto/dateTime.test.js +0 -38
- package/__tests__/auto/dateTime.test.js.map +0 -1
- package/__tests__/auto/flows.test.d.ts +0 -1
- package/__tests__/auto/flows.test.js +0 -78
- package/__tests__/auto/flows.test.js.map +0 -1
- package/__tests__/auto/nullable.test.d.ts +0 -1
- package/__tests__/auto/nullable.test.js +0 -15
- package/__tests__/auto/nullable.test.js.map +0 -1
- package/__tests__/auto/numeric.test.d.ts +0 -1
- package/__tests__/auto/numeric.test.js +0 -32
- package/__tests__/auto/numeric.test.js.map +0 -1
- package/__tests__/auto/parameters.test.d.ts +0 -1
- package/__tests__/auto/parameters.test.js +0 -26
- package/__tests__/auto/parameters.test.js.map +0 -1
- package/__tests__/auto/sets.test.d.ts +0 -1
- package/__tests__/auto/sets.test.js +0 -18
- package/__tests__/auto/sets.test.js.map +0 -1
- package/__tests__/auto/string.test.d.ts +0 -1
- package/__tests__/auto/string.test.js +0 -50
- package/__tests__/auto/string.test.js.map +0 -1
- package/__tests__/auto/type.test.d.ts +0 -1
- package/__tests__/auto/type.test.js +0 -26
- package/__tests__/auto/type.test.js.map +0 -1
- package/__tests__/cache.test.d.ts +0 -1
- package/__tests__/cache.test.js +0 -282
- package/__tests__/cache.test.js.map +0 -1
- package/__tests__/datetime.test.d.ts +0 -1
- package/__tests__/datetime.test.js +0 -38
- package/__tests__/datetime.test.js.map +0 -1
- package/__tests__/enums.test.d.ts +0 -1
- package/__tests__/enums.test.js +0 -12
- package/__tests__/enums.test.js.map +0 -1
- package/__tests__/flows.test.d.ts +0 -1
- package/__tests__/flows.test.js +0 -19
- package/__tests__/flows.test.js.map +0 -1
- package/__tests__/numeric.test.d.ts +0 -1
- package/__tests__/numeric.test.js +0 -55
- package/__tests__/numeric.test.js.map +0 -1
- package/__tests__/pending/conversion.test.d.ts +0 -1
- package/__tests__/pending/conversion.test.js +0 -20
- package/__tests__/pending/conversion.test.js.map +0 -1
- package/__tests__/pending/groups.test.d.ts +0 -1
- package/__tests__/pending/groups.test.js +0 -27
- package/__tests__/pending/groups.test.js.map +0 -1
- package/__tests__/pending/quick.test.d.ts +0 -1
- package/__tests__/pending/quick.test.js +0 -21
- package/__tests__/pending/quick.test.js.map +0 -1
- package/__tests__/string.test.d.ts +0 -1
- package/__tests__/string.test.js +0 -18
- package/__tests__/string.test.js.map +0 -1
|
@@ -45,65 +45,65 @@ class CoreLibrary {
|
|
|
45
45
|
model.addFormat('time', '\\[0-2]\\d:[0-5]\\d:[0-5]\\d');
|
|
46
46
|
}
|
|
47
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 });
|
|
48
|
+
model.addOperator('+(a:T,b:T):T', (a, b) => a + b, { priority: 5, description: 'Addition' });
|
|
49
|
+
model.addOperator('-(a:number,b:number):number', (a, b) => a - b, { priority: 5, description: 'Subtraction' });
|
|
50
|
+
model.addOperator('-(a:number):number', (a) => a * (-1), { priority: 9, description: 'Negation' });
|
|
51
|
+
model.addOperator('*(a:number,b:number):number', (a, b) => a * b, { priority: 6, description: 'Multiplication' });
|
|
52
|
+
model.addOperator('/(a:number,b:number):number', (a, b) => a / b, { priority: 6, description: 'Division' });
|
|
53
|
+
model.addOperator('**(a:number,b:number):number', (a, b) => a ** b, { priority: 7, description: 'Exponentiation' });
|
|
54
|
+
model.addOperator('//(a:number,b:number):number', (a, b) => Math.pow(a, (1 / b)), { priority: 7, description: 'Root' });
|
|
55
|
+
model.addOperator('%(a:number,b:number):number', (a, b) => a % b, { priority: 8, description: 'Modulus' });
|
|
56
|
+
model.addOperator('&(a:number,b:number):number', (a, b) => a & b, { priority: 5, description: 'Bitwise AND' });
|
|
57
|
+
model.addOperator('|(a:number,b:number):number', (a, b) => a | b, { priority: 5, description: 'Bitwise OR' });
|
|
58
|
+
model.addOperator('^(a:number,b:number):number', (a, b) => a ^ b, { priority: 5, description: 'Bitwise XOR' });
|
|
59
|
+
model.addOperator('~(a:number):number', (a) => ~a, { priority: 9, description: 'Bitwise NOT' });
|
|
60
|
+
model.addOperator('<<(a:number,b:number):number', (a, b) => a << b, { priority: 5, description: 'Bitwise Left Shift' });
|
|
61
|
+
model.addOperator('>>(a:number,b:number):number', (a, b) => a >> b, { priority: 5, description: 'Bitwise Right Shift' });
|
|
62
|
+
model.addOperator('==(a:T,b:T):boolean', (a, b) => a === b, { priority: 4, description: 'Equality' });
|
|
63
63
|
model.addOperatorAlias('===', '==');
|
|
64
|
-
model.addOperator('!=(a:T,b:T):boolean', (a, b) => a !== b, { priority: 4 });
|
|
64
|
+
model.addOperator('!=(a:T,b:T):boolean', (a, b) => a !== b, { priority: 4, description: 'Inequality' });
|
|
65
65
|
model.addOperatorAlias('!==', '!=');
|
|
66
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 });
|
|
67
|
+
model.addOperator('>(a:T,b:T):boolean', (a, b) => a > b, { priority: 4, description: 'Greater than' });
|
|
68
|
+
model.addOperator('<(a:T,b:T):boolean', (a, b) => a < b, { priority: 4, description: 'Less than' });
|
|
69
|
+
model.addOperator('>=(a:T,b:T):boolean', (a, b) => a >= b, { priority: 4, description: 'Greater than or equal' });
|
|
70
|
+
model.addOperator('<=(a:T,b:T):boolean', (a, b) => a <= b, { priority: 3, description: 'Less than or equal' });
|
|
71
|
+
model.addOperator('&&(a:boolean,b:boolean):boolean', new And(), { priority: 3, description: 'Logical AND' });
|
|
72
|
+
model.addOperator('||(a:boolean,b:boolean):boolean', new Or(), { priority: 3, description: 'Logical OR' });
|
|
73
|
+
model.addOperator('!(a:boolean):boolean', (a) => !a, { priority: 5, description: 'Logical NOT' });
|
|
74
74
|
// index is any, because it can also be string when used to access a property of an object
|
|
75
75
|
// example: orders[0]["number"]
|
|
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 });
|
|
76
|
+
model.addOperator('[](list:T[],index:any):T', (list, index) => list[index], { priority: 2, description: 'Index' });
|
|
77
|
+
model.addOperator('$(name:string):string', (name) => process.env[name], { priority: 9, description: 'Environment Variable' });
|
|
78
|
+
model.addOperator('=(a:T,b:T):T', new Assignment(), { priority: 1, description: 'Assignment' });
|
|
79
|
+
model.addOperator('+=(a:number,b:number):number', new AssignmentAddition(), { priority: 1, description: 'Assignment Addition' });
|
|
80
|
+
model.addOperator('-=(a:number,b:number):number', new AssignmentSubtraction(), { priority: 1, description: 'Assignment Subtraction' });
|
|
81
|
+
model.addOperator('*=(a:number,b:number):number', new AssignmentMultiplication(), { priority: 1, description: 'Assignment Multiplication' });
|
|
82
|
+
model.addOperator('/=(a:number,b:number):number', new AssignmentDivision(), { priority: 1, description: 'Assignment Division' });
|
|
83
|
+
model.addOperator('**=(a:number,b:number):number', new AssignmentExponentiation(), { priority: 1, description: 'Assignment Exponentiation' });
|
|
84
|
+
model.addOperator('//=(a:number,b:number):number', new AssignmentFloorDivision(), { priority: 1, description: 'Assignment Floor Division' });
|
|
85
|
+
model.addOperator('%=(a:number,b:number):number', new AssignmentMod(), { priority: 1, description: 'Assignment Modulus' });
|
|
86
|
+
model.addOperator('&=(a:number,b:number):number', new AssignmentBitAnd(), { priority: 1, description: 'Assignment Bitwise AND' });
|
|
87
|
+
model.addOperator('|=(a:number,b:number):number', new AssignmentBitOr(), { priority: 1, description: 'Assignment Bitwise OR' });
|
|
88
|
+
model.addOperator('^=(a:number,b:number):number', new AssignmentBitXor(), { priority: 1, description: 'Assignment Bitwise XOR' });
|
|
89
|
+
model.addOperator('<<=(a:number,b:number):number', new AssignmentLeftShift(), { priority: 1, description: 'Assignment Bitwise Left Shift' });
|
|
90
|
+
model.addOperator('>>=(a:number,b:number):number', new AssignmentRightShift(), { priority: 1, description: 'Assignment Bitwise Right Shift' });
|
|
91
91
|
}
|
|
92
92
|
generalFunctions(model) {
|
|
93
93
|
model.addFunction('sleep(ms?: number):void', async (ms = 0) => {
|
|
94
94
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
95
|
-
}, { async: true });
|
|
95
|
+
}, { async: true, description: 'Sleeps for the specified number of milliseconds' });
|
|
96
96
|
model.addFunction('console(value:any):void', (value) => {
|
|
97
97
|
console.log(typeof value === 'object' ? JSON.stringify(value) : value);
|
|
98
|
-
});
|
|
98
|
+
}, { description: 'Prints to console' });
|
|
99
99
|
}
|
|
100
100
|
nullFunctions(model) {
|
|
101
|
-
model.addFunction('nvl(value:T, default:T):T', (value, _default) => this.helper.utils.nvl(value, _default));
|
|
102
|
-
model.addFunction('nvl2(value:any, a:T,b:T):T', (value, a, b) => this.helper.utils.nvl2(value, a, b));
|
|
101
|
+
model.addFunction('nvl(value:T, default:T):T', (value, _default) => this.helper.utils.nvl(value, _default), { description: 'Null value' });
|
|
102
|
+
model.addFunction('nvl2(value:any, a:T,b:T):T', (value, a, b) => this.helper.utils.nvl2(value, a, b), { description: 'Null value' });
|
|
103
103
|
}
|
|
104
104
|
comparisonFunctions(model) {
|
|
105
|
-
model.addFunction('between(value:T,from:T,to:T):boolean', (value, from, to) => this.helper.val.between(value, from, to));
|
|
106
|
-
model.addFunction('includes(source:string|T[],value:string|T):boolean', (source, value) => source && value ? source.includes(value) : false);
|
|
105
|
+
model.addFunction('between(value:T,from:T,to:T):boolean', (value, from, to) => this.helper.val.between(value, from, to), { description: 'Between' });
|
|
106
|
+
model.addFunction('includes(source:string|T[],value:string|T):boolean', (source, value) => source && value ? source.includes(value) : false, { description: 'Includes' });
|
|
107
107
|
model.addFunctionAlias('contains', 'includes');
|
|
108
108
|
model.addFunction('in(source:T,...values:T):boolean', (source, ...values) => {
|
|
109
109
|
if (source === undefined || values === undefined) {
|
|
@@ -115,91 +115,91 @@ class CoreLibrary {
|
|
|
115
115
|
else {
|
|
116
116
|
return values.includes(source);
|
|
117
117
|
}
|
|
118
|
-
});
|
|
119
|
-
model.addFunction('like(value:string,pattern:string):boolean', (value, pattern) => value && pattern ? value.includes(pattern) : false);
|
|
120
|
-
model.addFunction('isNull(value:any):boolean', (value) => this.helper.val.isNull(value));
|
|
121
|
-
model.addFunction('isNotNull(value:any):boolean', (value) => this.helper.val.isNotNull(value));
|
|
122
|
-
model.addFunction('isEmpty(value:string):boolean', (value) => this.helper.val.isEmpty(value));
|
|
123
|
-
model.addFunction('isNotEmpty(value:string):boolean', (value) => this.helper.val.isNotEmpty(value));
|
|
124
|
-
model.addFunction('isBoolean(value:any):boolean', (value) => this.helper.val.isBoolean(value));
|
|
125
|
-
model.addFunction('isNumber(value:any):boolean', (value) => this.helper.val.isNumber(value));
|
|
126
|
-
model.addFunction('isInteger(value:any):boolean', (value) => this.helper.val.isInteger(value));
|
|
127
|
-
model.addFunction('isDecimal(value:any):boolean', (value) => this.helper.val.isDecimal(value));
|
|
128
|
-
model.addFunction('isString(value:any):boolean', (value) => this.helper.val.isString(value));
|
|
129
|
-
model.addFunction('isDate(value:any):boolean', (value) => this.helper.val.isDate(value));
|
|
130
|
-
model.addFunction('isDateTime(value:any):boolean', (value) => this.helper.val.isDateTime(value));
|
|
131
|
-
model.addFunction('isTime(value:any):boolean', (value) => this.helper.val.isTime(value));
|
|
132
|
-
model.addFunction('isObject(value:any):boolean', (value) => this.helper.val.isObject(value));
|
|
133
|
-
model.addFunction('isArray(value:any):boolean', (value) => this.helper.val.isArray(value));
|
|
134
|
-
model.addFunction('isBooleanFormat(value:string):boolean', (value) => this.helper.val.isBooleanFormat(value));
|
|
135
|
-
model.addFunction('isNumberFormat(value:string):boolean', (value) => this.helper.val.isNumberFormat(value));
|
|
136
|
-
model.addFunction('isIntegerFormat(value:string):boolean', (value) => this.helper.val.isIntegerFormat(value));
|
|
137
|
-
model.addFunction('isDecimalFormat(value:string):boolean', (value) => this.helper.val.isDecimalFormat(value));
|
|
138
|
-
model.addFunction('isDateFormat(value:string):boolean', (value) => this.helper.val.isDateFormat(value));
|
|
139
|
-
model.addFunction('isDateTimeFormat(value:string):boolean', (value) => this.helper.val.isDateTimeFormat(value));
|
|
140
|
-
model.addFunction('isTimeFormat(value:string):boolean', (value) => this.helper.val.isTimeFormat(value));
|
|
118
|
+
}, { description: 'In' });
|
|
119
|
+
model.addFunction('like(value:string,pattern:string):boolean', (value, pattern) => value && pattern ? value.includes(pattern) : false, { description: 'String contains pattern' });
|
|
120
|
+
model.addFunction('isNull(value:any):boolean', (value) => this.helper.val.isNull(value), { description: 'Check if value is null' });
|
|
121
|
+
model.addFunction('isNotNull(value:any):boolean', (value) => this.helper.val.isNotNull(value), { description: 'Check if value is not null' });
|
|
122
|
+
model.addFunction('isEmpty(value:string):boolean', (value) => this.helper.val.isEmpty(value), { description: 'Check if value is empty' });
|
|
123
|
+
model.addFunction('isNotEmpty(value:string):boolean', (value) => this.helper.val.isNotEmpty(value), { description: 'Check if value is not empty' });
|
|
124
|
+
model.addFunction('isBoolean(value:any):boolean', (value) => this.helper.val.isBoolean(value), { description: 'Check if value is boolean' });
|
|
125
|
+
model.addFunction('isNumber(value:any):boolean', (value) => this.helper.val.isNumber(value), { description: 'Check if value is number' });
|
|
126
|
+
model.addFunction('isInteger(value:any):boolean', (value) => this.helper.val.isInteger(value), { description: 'Check if value is integer' });
|
|
127
|
+
model.addFunction('isDecimal(value:any):boolean', (value) => this.helper.val.isDecimal(value), { description: 'Check if value is decimal' });
|
|
128
|
+
model.addFunction('isString(value:any):boolean', (value) => this.helper.val.isString(value), { description: 'Check if value is string' });
|
|
129
|
+
model.addFunction('isDate(value:any):boolean', (value) => this.helper.val.isDate(value), { description: 'Check if value is date' });
|
|
130
|
+
model.addFunction('isDateTime(value:any):boolean', (value) => this.helper.val.isDateTime(value), { description: 'Check if value is date time' });
|
|
131
|
+
model.addFunction('isTime(value:any):boolean', (value) => this.helper.val.isTime(value), { description: 'Check if value is time' });
|
|
132
|
+
model.addFunction('isObject(value:any):boolean', (value) => this.helper.val.isObject(value), { description: 'Check if value is object' });
|
|
133
|
+
model.addFunction('isArray(value:any):boolean', (value) => this.helper.val.isArray(value), { description: 'Check if value is array' });
|
|
134
|
+
model.addFunction('isBooleanFormat(value:string):boolean', (value) => this.helper.val.isBooleanFormat(value), { description: 'Check if value is boolean format' });
|
|
135
|
+
model.addFunction('isNumberFormat(value:string):boolean', (value) => this.helper.val.isNumberFormat(value), { description: 'Check if value is number format' });
|
|
136
|
+
model.addFunction('isIntegerFormat(value:string):boolean', (value) => this.helper.val.isIntegerFormat(value), { description: 'Check if value is integer format' });
|
|
137
|
+
model.addFunction('isDecimalFormat(value:string):boolean', (value) => this.helper.val.isDecimalFormat(value), { description: 'Check if value is decimal format' });
|
|
138
|
+
model.addFunction('isDateFormat(value:string):boolean', (value) => this.helper.val.isDateFormat(value), { description: 'Check if value is date format' });
|
|
139
|
+
model.addFunction('isDateTimeFormat(value:string):boolean', (value) => this.helper.val.isDateTimeFormat(value), { description: 'Check if value is date time format' });
|
|
140
|
+
model.addFunction('isTimeFormat(value:string):boolean', (value) => this.helper.val.isTimeFormat(value), { description: 'Check if value is time format' });
|
|
141
141
|
}
|
|
142
142
|
numberFunctions(model) {
|
|
143
|
-
model.addFunction('abs(x:number):number', Math.abs);
|
|
144
|
-
model.addFunction('acos(x:number):number', Math.acos);
|
|
145
|
-
model.addFunction('asin(x:number):number', Math.asin);
|
|
146
|
-
model.addFunction('atan(x:number):number', Math.atan);
|
|
147
|
-
model.addFunction('atan2(x:number):number', Math.atan2);
|
|
148
|
-
model.addFunction('ceil(x:number):number', Math.ceil);
|
|
149
|
-
model.addFunction('cos(x:number):number', Math.cos);
|
|
150
|
-
model.addFunction('cosh(x:number):number', Math.cosh);
|
|
151
|
-
model.addFunction('exp(x:number):number', Math.exp);
|
|
152
|
-
model.addFunction('floor(x:number):number', Math.floor);
|
|
153
|
-
model.addFunction('ln(x:number):number', Math.log);
|
|
154
|
-
model.addFunction('log10(x:number):number', Math.log10);
|
|
155
|
-
model.addFunction('log(x:number):number', Math.log);
|
|
156
|
-
model.addFunction('remainder(n1:number,n2:number):number', (n1, n2) => n1 % n2);
|
|
157
|
-
model.addFunction('round(num:number,decimals=0):number', (num, decimals = 0) => decimals > 0 ? Number(num.toFixed(decimals)) : Math.round(num));
|
|
158
|
-
model.addFunction('sign(x:number):number', Math.sign);
|
|
159
|
-
model.addFunction('sin(x:number):number', Math.sin);
|
|
160
|
-
model.addFunction('sinh(x:number):number', Math.sinh);
|
|
161
|
-
model.addFunction('tan(x:number):number', Math.tan);
|
|
162
|
-
model.addFunction('tanh(x:number):number', Math.tanh);
|
|
163
|
-
model.addFunction('trunc(x:number):number', Math.trunc);
|
|
143
|
+
model.addFunction('abs(x:number):number', Math.abs, { description: 'Absolute value' });
|
|
144
|
+
model.addFunction('acos(x:number):number', Math.acos, { description: 'Arc cosine' });
|
|
145
|
+
model.addFunction('asin(x:number):number', Math.asin, { description: 'Arc sine' });
|
|
146
|
+
model.addFunction('atan(x:number):number', Math.atan, { description: 'Arc tangent' });
|
|
147
|
+
model.addFunction('atan2(x:number):number', Math.atan2, { description: 'Arc tangent of two variables' });
|
|
148
|
+
model.addFunction('ceil(x:number):number', Math.ceil, { description: 'Ceiling' });
|
|
149
|
+
model.addFunction('cos(x:number):number', Math.cos, { description: 'Cosine' });
|
|
150
|
+
model.addFunction('cosh(x:number):number', Math.cosh, { description: 'Hyperbolic cosine' });
|
|
151
|
+
model.addFunction('exp(x:number):number', Math.exp, { description: 'Exponential' });
|
|
152
|
+
model.addFunction('floor(x:number):number', Math.floor, { description: 'Floor' });
|
|
153
|
+
model.addFunction('ln(x:number):number', Math.log, { description: 'Natural logarithm' });
|
|
154
|
+
model.addFunction('log10(x:number):number', Math.log10, { description: 'Base 10 logarithm' });
|
|
155
|
+
model.addFunction('log(x:number):number', Math.log, { description: 'Natural logarithm' });
|
|
156
|
+
model.addFunction('remainder(n1:number,n2:number):number', (n1, n2) => n1 % n2, { description: 'Remainder' });
|
|
157
|
+
model.addFunction('round(num:number,decimals=0):number', (num, decimals = 0) => decimals > 0 ? Number(num.toFixed(decimals)) : Math.round(num), { description: 'Round' });
|
|
158
|
+
model.addFunction('sign(x:number):number', Math.sign, { description: 'Sign' });
|
|
159
|
+
model.addFunction('sin(x:number):number', Math.sin, { description: 'Sine' });
|
|
160
|
+
model.addFunction('sinh(x:number):number', Math.sinh, { description: 'Hyperbolic sine' });
|
|
161
|
+
model.addFunction('tan(x:number):number', Math.tan, { description: 'Tangent' });
|
|
162
|
+
model.addFunction('tanh(x:number):number', Math.tanh, { description: 'Hyperbolic tangent' });
|
|
163
|
+
model.addFunction('trunc(x:number):number', Math.trunc, { description: 'Truncate' });
|
|
164
164
|
}
|
|
165
165
|
conversionFunctions(model) {
|
|
166
|
-
model.addFunction('toString(value:any):string', (value) => this.helper.str.toString(value));
|
|
167
|
-
model.addFunction('toNumber(value:any):number', (value) => this.helper.utils.toNumber(value));
|
|
166
|
+
model.addFunction('toString(value:any):string', (value) => this.helper.str.toString(value), { description: 'Convert to string' });
|
|
167
|
+
model.addFunction('toNumber(value:any):number', (value) => this.helper.utils.toNumber(value), { description: 'Convert to number' });
|
|
168
168
|
model.addFunction('dateToString(date:date):string', (date) => {
|
|
169
169
|
if (typeof date === 'string') {
|
|
170
170
|
return new Date(date).toISOString();
|
|
171
171
|
}
|
|
172
172
|
return date.toISOString();
|
|
173
|
-
});
|
|
174
|
-
model.addFunction('stringify(value:any):string', (value) => JSON.stringify(value));
|
|
175
|
-
model.addFunction('parse(value:string):any', (value) => JSON.parse(value));
|
|
176
|
-
model.addFunction('keys(obj: any):string[]', (obj) => typeof obj === 'object' ? Object.keys(obj) : []);
|
|
177
|
-
model.addFunction('values(obj: any):any[]', (obj) => typeof obj === 'object' ? Object.values(obj) : []);
|
|
178
|
-
model.addFunction('entries(obj: any):[string,any][]', (obj) => typeof obj === 'object' ? Object.entries(obj) : []);
|
|
179
|
-
model.addFunction('fromEntries(entries: [string,any][]): any', (entries) => this.helper.obj.fromEntries(entries));
|
|
173
|
+
}, { description: 'Convert date to string' });
|
|
174
|
+
model.addFunction('stringify(value:any):string', (value) => JSON.stringify(value), { description: 'Convert to JSON string' });
|
|
175
|
+
model.addFunction('parse(value:string):any', (value) => JSON.parse(value), { description: 'Parse JSON string' });
|
|
176
|
+
model.addFunction('keys(obj: any):string[]', (obj) => typeof obj === 'object' ? Object.keys(obj) : [], { description: 'Object keys' });
|
|
177
|
+
model.addFunction('values(obj: any):any[]', (obj) => typeof obj === 'object' ? Object.values(obj) : [], { description: 'Object values' });
|
|
178
|
+
model.addFunction('entries(obj: any):[string,any][]', (obj) => typeof obj === 'object' ? Object.entries(obj) : [], { description: 'Object entries' });
|
|
179
|
+
model.addFunction('fromEntries(entries: [string,any][]): any', (entries) => this.helper.obj.fromEntries(entries), { description: 'Object from entries' });
|
|
180
180
|
}
|
|
181
181
|
stringFunctions(model) {
|
|
182
|
-
model.addFunction('chr(ascii: number):string', (ascii) => String.fromCharCode(ascii));
|
|
183
|
-
model.addFunction('capitalize(value:string):string', (value) => this.helper.str.capitalize(value));
|
|
184
|
-
model.addFunction('endsWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.endsWith(sub, start));
|
|
185
|
-
model.addFunction('strCount(source: string, value: string):number', (source, value) => source.split(value).length - 1);
|
|
186
|
-
model.addFunction('lower(value: string):string', (value) => value.toLowerCase());
|
|
187
|
-
model.addFunction('lpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padStart(len, pad));
|
|
188
|
-
model.addFunction('ltrim(value: string):string', (value) => value.
|
|
189
|
-
model.addFunction('indexOf(value:string, sub:string, start:number):number', (value, sub, start) => value.indexOf(sub, start));
|
|
190
|
-
model.addFunction('join(values:string[],separator:string=","):string', (values, separator = ',') => values.join(separator));
|
|
191
|
-
model.addFunction('replace(value: string, source: string, target: string):string', (value, source, target) => this.helper.str.replace(value, source, target));
|
|
192
|
-
model.addFunction('rpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padEnd(len, pad));
|
|
193
|
-
model.addFunction('rtrim(value: string):string', (value) => value.
|
|
194
|
-
model.addFunction('substring(value: string, from: number, count: number):string', (value, from, count) => value.substring(from, count));
|
|
182
|
+
model.addFunction('chr(ascii: number):string', (ascii) => String.fromCharCode(ascii), { description: 'Character' });
|
|
183
|
+
model.addFunction('capitalize(value:string):string', (value) => this.helper.str.capitalize(value), { description: 'Capitalize' });
|
|
184
|
+
model.addFunction('endsWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.endsWith(sub, start), { description: 'Ends with' });
|
|
185
|
+
model.addFunction('strCount(source: string, value: string):number', (source, value) => source.split(value).length - 1, { description: 'Count' });
|
|
186
|
+
model.addFunction('lower(value: string):string', (value) => value.toLowerCase(), { description: 'Lower case' });
|
|
187
|
+
model.addFunction('lpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padStart(len, pad), { description: 'Left pad' });
|
|
188
|
+
model.addFunction('ltrim(value: string):string', (value) => value.trimStart(), { description: 'Left trim' });
|
|
189
|
+
model.addFunction('indexOf(value:string, sub:string, start:number):number', (value, sub, start) => value.indexOf(sub, start), { description: 'Index of' });
|
|
190
|
+
model.addFunction('join(values:string[],separator:string=","):string', (values, separator = ',') => values.join(separator), { description: 'Join' });
|
|
191
|
+
model.addFunction('replace(value: string, source: string, target: string):string', (value, source, target) => this.helper.str.replace(value, source, target), { description: 'Replace' });
|
|
192
|
+
model.addFunction('rpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padEnd(len, pad), { description: 'Right pad' });
|
|
193
|
+
model.addFunction('rtrim(value: string):string', (value) => value.trimEnd(), { description: 'Right trim' });
|
|
194
|
+
model.addFunction('substring(value: string, from: number, count: number):string', (value, from, count) => value.substring(from, count), { description: 'Substring' });
|
|
195
195
|
model.addFunctionAlias('substr', 'substring');
|
|
196
|
-
model.addFunction('trim(value: string):string', (value) => value.trim());
|
|
197
|
-
model.addFunction('upper(value: string):string', (value) => value.toUpperCase());
|
|
198
|
-
model.addFunction('concat(...values:any):string', (...values) => this.helper.str.concat(values));
|
|
196
|
+
model.addFunction('trim(value: string):string', (value) => value.trim(), { description: 'Trim' });
|
|
197
|
+
model.addFunction('upper(value: string):string', (value) => value.toUpperCase(), { description: 'Upper case' });
|
|
198
|
+
model.addFunction('concat(...values:any):string', (...values) => this.helper.str.concat(values), { description: 'Concatenate' });
|
|
199
199
|
model.addFunctionAlias('concatenate', 'concat');
|
|
200
|
-
model.addFunction('test(value: string, regexp: string):boolean', (value, regexp) => new RegExp(regexp).test(value));
|
|
201
|
-
model.addFunction('title(value:string):string', (value) => this.helper.str.initCap(value));
|
|
202
|
-
model.addFunction('match(value: string, regexp: string):any', (value, regexp) => value ? value.match(regexp) : null);
|
|
200
|
+
model.addFunction('test(value: string, regexp: string):boolean', (value, regexp) => new RegExp(regexp).test(value), { description: 'Test' });
|
|
201
|
+
model.addFunction('title(value:string):string', (value) => this.helper.str.initCap(value), { description: 'Title case' });
|
|
202
|
+
model.addFunction('match(value: string, regexp: string):any', (value, regexp) => value ? value.match(regexp) : null, { description: 'Match' });
|
|
203
203
|
model.addFunction('mask(value: string):string', (value) => {
|
|
204
204
|
if (!value)
|
|
205
205
|
return value;
|
|
@@ -212,89 +212,89 @@ class CoreLibrary {
|
|
|
212
212
|
else {
|
|
213
213
|
return '*';
|
|
214
214
|
}
|
|
215
|
-
});
|
|
216
|
-
model.addFunction('split(value:string,separator:string=","):string[]', (value, separator = ',') => value.split(separator));
|
|
217
|
-
model.addFunction('startWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.startsWith(sub, start));
|
|
215
|
+
}, { description: 'Mask sensitive data' });
|
|
216
|
+
model.addFunction('split(value:string,separator:string=","):string[]', (value, separator = ',') => value.split(separator), { description: 'Split string' });
|
|
217
|
+
model.addFunction('startWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.startsWith(sub, start), { description: 'Starts with' });
|
|
218
218
|
model.addFunctionAlias('startsWith', 'startWith');
|
|
219
219
|
}
|
|
220
220
|
dateTimeFunctions(model) {
|
|
221
221
|
model.addFunction('curTime():time', () => {
|
|
222
222
|
const date = new Date();
|
|
223
223
|
return date.getHours() + ':' + (date.getMinutes() + 1) + ':' + date.getSeconds();
|
|
224
|
-
});
|
|
224
|
+
}, { description: 'Current time' });
|
|
225
225
|
model.addFunction('today():date', () => {
|
|
226
226
|
const date = new Date();
|
|
227
227
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
|
|
228
|
-
});
|
|
229
|
-
model.addFunction('now():dateTime', () => new Date().toISOString());
|
|
228
|
+
}, { description: 'Current date' });
|
|
229
|
+
model.addFunction('now():dateTime', () => new Date().toISOString(), { description: 'Current date time' });
|
|
230
230
|
model.addFunction('time(value: string):time', (value) => {
|
|
231
231
|
const date = new Date(value);
|
|
232
232
|
return date.getHours() + ':' + (date.getMinutes() + 1) + ':' + date.getSeconds();
|
|
233
|
-
});
|
|
233
|
+
}, { description: 'Get time' });
|
|
234
234
|
model.addFunction('date(value: string):date', (value) => {
|
|
235
235
|
const date = new Date(value);
|
|
236
236
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
|
|
237
|
-
});
|
|
238
|
-
model.addFunction('dateTime(value: string):dateTime', (value) => new Date(value).toISOString());
|
|
237
|
+
}, { description: 'Get date' });
|
|
238
|
+
model.addFunction('dateTime(value: string):dateTime', (value) => new Date(value).toISOString(), { description: 'Get date time' });
|
|
239
239
|
model.addFunction('year(value: dateTime):integer', (value) => {
|
|
240
240
|
return new Date(value).getFullYear();
|
|
241
|
-
});
|
|
241
|
+
}, { description: 'Get year' });
|
|
242
242
|
model.addFunction('month(value: dateTime):integer', (value) => {
|
|
243
243
|
return new Date(value).getMonth() + 1;
|
|
244
|
-
});
|
|
244
|
+
}, { description: 'Get month' });
|
|
245
245
|
model.addFunction('day(value: dateTime):integer', (value) => {
|
|
246
246
|
return new Date(value).getDate();
|
|
247
|
-
});
|
|
247
|
+
}, { description: 'Get day' });
|
|
248
248
|
model.addFunction('weekday(value: dateTime):integer', (value) => {
|
|
249
249
|
return new Date(value).getDay();
|
|
250
|
-
});
|
|
250
|
+
}, { description: 'Get day of week' });
|
|
251
251
|
model.addFunction('hour(value: dateTime):integer', (value) => {
|
|
252
252
|
return new Date(value).getHours();
|
|
253
|
-
});
|
|
253
|
+
}, { description: 'Get hours' });
|
|
254
254
|
model.addFunction('minute(value: dateTime):integer', (value) => {
|
|
255
255
|
return new Date(value).getMinutes();
|
|
256
|
-
});
|
|
256
|
+
}, { description: 'Get minutes' });
|
|
257
257
|
model.addFunction('second(value: dateTime):integer', (value) => {
|
|
258
258
|
return new Date(value).getSeconds();
|
|
259
|
-
});
|
|
259
|
+
}, { description: 'Get seconds' });
|
|
260
260
|
model.addFunction('millisecond(value: dateTime):integer', (value) => {
|
|
261
261
|
return new Date(value).getMilliseconds();
|
|
262
|
-
});
|
|
262
|
+
}, { description: 'Get milliseconds' });
|
|
263
263
|
model.addFunction('addYear(date: dateTime, value: number):dateTime', (date, value) => {
|
|
264
264
|
const _date = new Date(date);
|
|
265
265
|
_date.setFullYear(_date.getFullYear() + value);
|
|
266
266
|
return _date.toISOString();
|
|
267
|
-
});
|
|
267
|
+
}, { description: 'Add years' });
|
|
268
268
|
model.addFunction('addMonth(date: dateTime, value: number):dateTime', (date, value) => {
|
|
269
269
|
const _date = new Date(date);
|
|
270
270
|
_date.setMonth(_date.getMonth() + value);
|
|
271
271
|
return _date.toISOString();
|
|
272
|
-
});
|
|
272
|
+
}, { description: 'Add months' });
|
|
273
273
|
model.addFunction('addDay(date: dateTime, value: number):dateTime', (date, value) => {
|
|
274
274
|
const _date = new Date(date);
|
|
275
275
|
_date.setDate(_date.getDate() + value);
|
|
276
276
|
return _date.toISOString();
|
|
277
|
-
});
|
|
277
|
+
}, { description: 'Add days' });
|
|
278
278
|
model.addFunction('addHour(date: dateTime, value: number):dateTime', (date, value) => {
|
|
279
279
|
const _date = new Date(date);
|
|
280
280
|
_date.setHours(_date.getHours() + value);
|
|
281
281
|
return _date.toISOString();
|
|
282
|
-
});
|
|
282
|
+
}, { description: 'Add hours' });
|
|
283
283
|
model.addFunction('addMinute(date: dateTime, value: number):dateTime', (date, value) => {
|
|
284
284
|
const _date = new Date(date);
|
|
285
285
|
_date.setMinutes(_date.getMinutes() + value);
|
|
286
286
|
return _date.toISOString();
|
|
287
|
-
});
|
|
287
|
+
}, { description: 'Add minutes' });
|
|
288
288
|
model.addFunction('addSecond(date: dateTime, value: number):dateTime', (date, value) => {
|
|
289
289
|
const _date = new Date(date);
|
|
290
290
|
_date.setSeconds(_date.getSeconds() + value);
|
|
291
291
|
return _date.toISOString();
|
|
292
|
-
});
|
|
292
|
+
}, { description: 'Add seconds' });
|
|
293
293
|
model.addFunction('addMillisecond(date: dateTime, value: number):dateTime', (date, value) => {
|
|
294
294
|
const _date = new Date(date);
|
|
295
295
|
_date.setMilliseconds(_date.getMilliseconds() + value);
|
|
296
296
|
return _date.toISOString();
|
|
297
|
-
});
|
|
297
|
+
}, { description: 'Add milliseconds' });
|
|
298
298
|
model.addFunction('addTime(date: dateTime, time: time):dateTime', (date, time) => {
|
|
299
299
|
const _time = new Date('2000-01-01T' + time);
|
|
300
300
|
const _date = new Date(date);
|
|
@@ -303,7 +303,7 @@ class CoreLibrary {
|
|
|
303
303
|
_date.setSeconds(_date.getSeconds() + _time.getSeconds());
|
|
304
304
|
_date.setMilliseconds(_date.getSeconds() + _time.getMilliseconds());
|
|
305
305
|
return _date.toISOString();
|
|
306
|
-
});
|
|
306
|
+
}, { description: 'Add time' });
|
|
307
307
|
model.addFunction('subtractTime(date: dateTime, time: time):dateTime', (date, time) => {
|
|
308
308
|
const _time = new Date('2000-01-01T' + time);
|
|
309
309
|
const _date = new Date(date);
|
|
@@ -312,72 +312,72 @@ class CoreLibrary {
|
|
|
312
312
|
_date.setSeconds(_date.getSeconds() - _time.getSeconds());
|
|
313
313
|
_date.setMilliseconds(_date.getSeconds() - _time.getMilliseconds());
|
|
314
314
|
return _date.toISOString();
|
|
315
|
-
});
|
|
315
|
+
}, { description: 'Subtract time' });
|
|
316
316
|
model.addFunction('yearDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
317
317
|
const _date1 = new Date(date1);
|
|
318
318
|
const _date2 = new Date(date2);
|
|
319
319
|
return Math.abs(_date2.getFullYear() - _date1.getFullYear());
|
|
320
|
-
});
|
|
320
|
+
}, { description: 'Year difference' });
|
|
321
321
|
model.addFunction('dayDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
322
322
|
const _date1 = new Date(date1);
|
|
323
323
|
const _date2 = new Date(date2);
|
|
324
324
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (24 * 3600 * 1000));
|
|
325
|
-
});
|
|
325
|
+
}, { description: 'Day difference' });
|
|
326
326
|
model.addFunction('hourDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
327
327
|
const _date1 = new Date(date1);
|
|
328
328
|
const _date2 = new Date(date2);
|
|
329
329
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (3600 * 1000));
|
|
330
|
-
});
|
|
330
|
+
}, { description: 'Hour difference' });
|
|
331
331
|
model.addFunction('secondDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
332
332
|
const _date1 = new Date(date1);
|
|
333
333
|
const _date2 = new Date(date2);
|
|
334
334
|
return Math.floor((_date1.getTime() - _date2.getTime()) / (1000));
|
|
335
|
-
});
|
|
335
|
+
}, { description: 'Second difference' });
|
|
336
336
|
model.addFunction('millisecondDiff(date1: dateTime, date2: dateTime):integer', (date1, date2) => {
|
|
337
337
|
const _date1 = new Date(date1);
|
|
338
338
|
const _date2 = new Date(date2);
|
|
339
339
|
return Math.floor(_date1.getTime() - _date2.getTime());
|
|
340
|
-
});
|
|
340
|
+
}, { description: 'Millisecond difference' });
|
|
341
341
|
model.addFunction('dayToDate(value: number):dateTime', (value) => {
|
|
342
342
|
return new Date(value * 24 * 3600 * 1000).toISOString();
|
|
343
|
-
});
|
|
343
|
+
}, { description: 'Convert days to date time' });
|
|
344
344
|
model.addFunction('hourToDate(value: number):dateTime', (value) => {
|
|
345
345
|
return new Date(value * 3600 * 1000).toISOString();
|
|
346
|
-
});
|
|
346
|
+
}, { description: 'Convert hours to date time' });
|
|
347
347
|
model.addFunction('secondToDate(value: number):dateTime', (value) => {
|
|
348
348
|
return new Date(value * 1000).toISOString();
|
|
349
|
-
});
|
|
349
|
+
}, { description: 'Convert seconds to date time' });
|
|
350
350
|
model.addFunction('millisecondToDate(value: number):dateTime', (value) => {
|
|
351
351
|
return new Date(value).toISOString();
|
|
352
|
-
});
|
|
352
|
+
}, { description: 'Convert milliseconds to date time' });
|
|
353
353
|
}
|
|
354
354
|
arrayFunctions(model) {
|
|
355
|
-
model.addFunction('map(list: any[], predicate: T):T[]', new Map(this.builder, this.cloner, this.helper));
|
|
355
|
+
model.addFunction('map(list: any[], predicate: T):T[]', new Map(this.builder, this.cloner, this.helper), { description: 'Map' });
|
|
356
356
|
model.addFunctionAlias('select', 'map');
|
|
357
|
-
model.addFunction('foreach(list: any[], predicate: any):void', new Foreach());
|
|
357
|
+
model.addFunction('foreach(list: any[], predicate: any):void', new Foreach(), { description: 'Foreach' });
|
|
358
358
|
model.addFunctionAlias('each', 'foreach');
|
|
359
|
-
model.addFunction('filter(list: T[], predicate: boolean):T[]', new Filter());
|
|
359
|
+
model.addFunction('filter(list: T[], predicate: boolean):T[]', new Filter(), { description: 'Filter' });
|
|
360
360
|
model.addFunctionAlias('where', 'filter');
|
|
361
|
-
model.addFunction('reverse(list: T[], predicate: any):T[]', new Reverse());
|
|
362
|
-
model.addFunction('sort(list: T[], predicate: any):T[]', new Sort());
|
|
361
|
+
model.addFunction('reverse(list: T[], predicate: any):T[]', new Reverse(), { description: 'Reverse' });
|
|
362
|
+
model.addFunction('sort(list: T[], predicate: any):T[]', new Sort(), { description: 'Sort' });
|
|
363
363
|
model.addFunctionAlias('order', 'sort');
|
|
364
|
-
model.addFunction('remove(list: T[], predicate: boolean):T[]', new Remove());
|
|
364
|
+
model.addFunction('remove(list: T[], predicate: boolean):T[]', new Remove(), { description: 'Remove' });
|
|
365
365
|
model.addFunctionAlias('delete', 'remove');
|
|
366
366
|
model.addFunction('push(list: T[], value: T):T[]', (list, item) => {
|
|
367
367
|
list.push(item);
|
|
368
368
|
return list;
|
|
369
|
-
});
|
|
369
|
+
}, { description: 'Push' });
|
|
370
370
|
model.addFunctionAlias('insert', 'push');
|
|
371
371
|
model.addFunction('bulkInsert(list: T[], value: T[]):T[]', (list, items) => {
|
|
372
372
|
for (const item of items) {
|
|
373
373
|
list.push(item);
|
|
374
374
|
}
|
|
375
375
|
return list;
|
|
376
|
-
});
|
|
377
|
-
model.addFunction('pop(list: T[]): T', (list) => list.pop());
|
|
378
|
-
model.addFunction('length(source: any[]|string):number', (source) => source.length);
|
|
376
|
+
}, { description: 'Bulk Insert' });
|
|
377
|
+
model.addFunction('pop(list: T[]): T', (list) => list.pop(), { description: 'Pop' });
|
|
378
|
+
model.addFunction('length(source: any[]|string):number', (source) => source.length, { description: 'Length' });
|
|
379
379
|
model.addFunctionAlias('len', 'length');
|
|
380
|
-
model.addFunction('slice(list: T[], from:integer, to:integer):T[]', (list, from, to) => list.slice(from, to));
|
|
380
|
+
model.addFunction('slice(list: T[], from:integer, to:integer):T[]', (list, from, to) => list.slice(from, to), { description: 'Slice' });
|
|
381
381
|
model.addFunction('page(list: T[], page:integer, records:integer):T[]', (list, page, records) => {
|
|
382
382
|
let from = (page - 1) * records;
|
|
383
383
|
if (from < 0) {
|
|
@@ -388,24 +388,24 @@ class CoreLibrary {
|
|
|
388
388
|
to = list.length - 1;
|
|
389
389
|
}
|
|
390
390
|
return list.slice(from, to);
|
|
391
|
-
});
|
|
391
|
+
}, { description: 'Paging' });
|
|
392
392
|
// this.addFunction('update', ArrayFunctions.update, OperatorType.arrow, Update)
|
|
393
393
|
}
|
|
394
394
|
groupFunctions(model) {
|
|
395
|
-
model.addFunction('distinct(list: any[], predicate: any): any[]', new Distinct(this.helper));
|
|
396
|
-
model.addFunction('first(list: T[], predicate: boolean): T', new First(this.helper));
|
|
397
|
-
model.addFunction('last(list: T[], predicate: boolean): T', new Last(this.helper));
|
|
398
|
-
model.addFunction('count(list: T[], predicate: boolean): integer', new Count(this.helper));
|
|
399
|
-
model.addFunction('max(list: T[], predicate: boolean): T', new Max(this.helper));
|
|
400
|
-
model.addFunction('min(list: T[], predicate: boolean): T', new Min(this.helper));
|
|
401
|
-
model.addFunction('avg(list: T[], value: number): number', new Avg(this.helper));
|
|
402
|
-
model.addFunction('sum(list: T[], value: number): number', new Sum(this.helper));
|
|
395
|
+
model.addFunction('distinct(list: any[], predicate: any): any[]', new Distinct(this.helper), { description: 'Distinct' });
|
|
396
|
+
model.addFunction('first(list: T[], predicate: boolean): T', new First(this.helper), { description: 'First' });
|
|
397
|
+
model.addFunction('last(list: T[], predicate: boolean): T', new Last(this.helper), { description: 'Last' });
|
|
398
|
+
model.addFunction('count(list: T[], predicate: boolean): integer', new Count(this.helper), { description: 'Count' });
|
|
399
|
+
model.addFunction('max(list: T[], predicate: boolean): T', new Max(this.helper), { description: 'Max' });
|
|
400
|
+
model.addFunction('min(list: T[], predicate: boolean): T', new Min(this.helper), { description: 'Min' });
|
|
401
|
+
model.addFunction('avg(list: T[], value: number): number', new Avg(this.helper), { description: 'Average' });
|
|
402
|
+
model.addFunction('sum(list: T[], value: number): number', new Sum(this.helper), { description: 'Sum' });
|
|
403
403
|
}
|
|
404
404
|
setsFunctions(model) {
|
|
405
|
-
model.addFunction('union(a: T[], b: T[]): T[]', new Union(this.helper));
|
|
406
|
-
model.addFunction('intersection(a: T[], b: T[]): T[]', new Intersection(this.helper));
|
|
407
|
-
model.addFunction('difference(a: T[], b: T[]): T[]', new Difference(this.helper));
|
|
408
|
-
model.addFunction('symmetricDifference(a: T[], b: T[]): T[]', new SymmetricDifference(this.helper));
|
|
405
|
+
model.addFunction('union(a: T[], b: T[]): T[]', new Union(this.helper), { description: 'Union' });
|
|
406
|
+
model.addFunction('intersection(a: T[], b: T[]): T[]', new Intersection(this.helper), { description: 'Intersection' });
|
|
407
|
+
model.addFunction('difference(a: T[], b: T[]): T[]', new Difference(this.helper), { description: 'Difference' });
|
|
408
|
+
model.addFunction('symmetricDifference(a: T[], b: T[]): T[]', new SymmetricDifference(this.helper), { description: 'Symmetric Difference' });
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
exports.CoreLibrary = CoreLibrary;
|
|
@@ -564,7 +564,7 @@ class AssignmentExponentiation extends domain_2.PrototypeEvaluator {
|
|
|
564
564
|
if (this.operand === undefined) {
|
|
565
565
|
throw new Error('Operand undefined');
|
|
566
566
|
}
|
|
567
|
-
const value = this.operand.children[0].eval(context) ** this.operand.children[1].eval(context);
|
|
567
|
+
const value = (this.operand.children[0].eval(context)) ** (this.operand.children[1].eval(context));
|
|
568
568
|
context.data.set(this.operand.children[0].name, value);
|
|
569
569
|
return value;
|
|
570
570
|
}
|
|
@@ -585,7 +585,7 @@ class AssignmentFloorDivision extends domain_2.PrototypeEvaluator {
|
|
|
585
585
|
if (this.operand === undefined) {
|
|
586
586
|
throw new Error('Operand undefined');
|
|
587
587
|
}
|
|
588
|
-
const value = Math.floor(this.operand.children[0].eval(context) / this.operand.children[1].eval(context));
|
|
588
|
+
const value = Math.floor(this.operand.children[0].eval(context) / (this.operand.children[1].eval(context)));
|
|
589
589
|
context.data.set(this.operand.children[0].name, value);
|
|
590
590
|
return value;
|
|
591
591
|
}
|
|
@@ -606,7 +606,7 @@ class AssignmentMod extends domain_2.PrototypeEvaluator {
|
|
|
606
606
|
if (this.operand === undefined) {
|
|
607
607
|
throw new Error('Operand undefined');
|
|
608
608
|
}
|
|
609
|
-
const value = this.operand.children[0].eval(context) % this.operand.children[1].eval(context);
|
|
609
|
+
const value = this.operand.children[0].eval(context) % (this.operand.children[1].eval(context));
|
|
610
610
|
context.data.set(this.operand.children[0].name, value);
|
|
611
611
|
return value;
|
|
612
612
|
}
|
|
@@ -627,7 +627,7 @@ class AssignmentBitAnd extends domain_2.PrototypeEvaluator {
|
|
|
627
627
|
if (this.operand === undefined) {
|
|
628
628
|
throw new Error('Operand undefined');
|
|
629
629
|
}
|
|
630
|
-
const value = this.operand.children[0].eval(context) & this.operand.children[1].eval(context);
|
|
630
|
+
const value = this.operand.children[0].eval(context) & (this.operand.children[1].eval(context));
|
|
631
631
|
context.data.set(this.operand.children[0].name, value);
|
|
632
632
|
return value;
|
|
633
633
|
}
|
|
@@ -648,7 +648,7 @@ class AssignmentBitOr extends domain_2.PrototypeEvaluator {
|
|
|
648
648
|
if (this.operand === undefined) {
|
|
649
649
|
throw new Error('Operand undefined');
|
|
650
650
|
}
|
|
651
|
-
const value = this.operand.children[0].eval(context) | this.operand.children[1].eval(context);
|
|
651
|
+
const value = (this.operand.children[0].eval(context)) | (this.operand.children[1].eval(context));
|
|
652
652
|
context.data.set(this.operand.children[0].name, value);
|
|
653
653
|
return value;
|
|
654
654
|
}
|
|
@@ -669,7 +669,7 @@ class AssignmentBitXor extends domain_2.PrototypeEvaluator {
|
|
|
669
669
|
if (this.operand === undefined) {
|
|
670
670
|
throw new Error('Operand undefined');
|
|
671
671
|
}
|
|
672
|
-
const value = this.operand.children[0].eval(context) ^ this.operand.children[1].eval(context);
|
|
672
|
+
const value = (this.operand.children[0].eval(context)) ^ (this.operand.children[1].eval(context));
|
|
673
673
|
context.data.set(this.operand.children[0].name, value);
|
|
674
674
|
return value;
|
|
675
675
|
}
|
|
@@ -690,7 +690,7 @@ class AssignmentLeftShift extends domain_2.PrototypeEvaluator {
|
|
|
690
690
|
if (this.operand === undefined) {
|
|
691
691
|
throw new Error('Operand undefined');
|
|
692
692
|
}
|
|
693
|
-
const value = this.operand.children[0].eval(context) << this.operand.children[1].eval(context);
|
|
693
|
+
const value = (this.operand.children[0].eval(context)) << (this.operand.children[1].eval(context));
|
|
694
694
|
context.data.set(this.operand.children[0].name, value);
|
|
695
695
|
return value;
|
|
696
696
|
}
|
|
@@ -711,7 +711,7 @@ class AssignmentRightShift extends domain_2.PrototypeEvaluator {
|
|
|
711
711
|
if (this.operand === undefined) {
|
|
712
712
|
throw new Error('Operand undefined');
|
|
713
713
|
}
|
|
714
|
-
const value = this.operand.children[0].eval(context) >> this.operand.children[1].eval(context);
|
|
714
|
+
const value = (this.operand.children[0].eval(context)) >> (this.operand.children[1].eval(context));
|
|
715
715
|
context.data.set(this.operand.children[0].name, value);
|
|
716
716
|
return value;
|
|
717
717
|
}
|