3xpr 1.15.11 → 1.15.13
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/infrastructure/convertFrom/convertFromFunction.d.ts +3 -1
- package/expression/infrastructure/convertFrom/convertFromFunction.js +3 -3
- package/expression/infrastructure/convertFrom/convertFromFunction.js.map +1 -1
- package/expression/infrastructure/expressionsBuilder.d.ts +2 -2
- package/expression/infrastructure/expressionsBuilder.js +2 -2
- package/expression/infrastructure/expressionsBuilder.js.map +1 -1
- package/expression/infrastructure/helper.d.ts +1 -2
- package/expression/infrastructure/helper.js.map +1 -1
- package/expression/infrastructure/helperBuilder.d.ts +0 -4
- package/expression/infrastructure/helperBuilder.js +12 -15
- package/expression/infrastructure/helperBuilder.js.map +1 -1
- package/expression/infrastructure/index.d.ts +1 -2
- package/expression/infrastructure/index.js +1 -2
- package/expression/infrastructure/index.js.map +1 -1
- package/expression/infrastructure/library.d.ts +3 -1
- package/expression/infrastructure/library.js +134 -85
- package/expression/infrastructure/library.js.map +1 -1
- package/index.d.ts +3 -2
- package/index.js +6 -5
- package/index.js.map +1 -1
- package/operand/infrastructure/helper.d.ts +1 -2
- package/operand/infrastructure/helper.js.map +1 -1
- package/package.json +3 -3
- package/shared/infrastructure/helper.d.ts +8 -0
- package/shared/infrastructure/helper.js +16 -0
- package/shared/infrastructure/helper.js.map +1 -0
- package/shared/infrastructure/index.d.ts +1 -0
- package/shared/{application → infrastructure}/index.js +1 -3
- package/shared/infrastructure/index.js.map +1 -0
- package/shared/application/helper/expression.d.ts +0 -3
- package/shared/application/helper/expression.js +0 -3
- package/shared/application/helper/expression.js.map +0 -1
- package/shared/application/helper/helper.d.ts +0 -8
- package/shared/application/helper/helper.js +0 -13
- package/shared/application/helper/helper.js.map +0 -1
- package/shared/application/helper/operand.d.ts +0 -16
- package/shared/application/helper/operand.js +0 -3
- package/shared/application/helper/operand.js.map +0 -1
- package/shared/application/index.d.ts +0 -3
- package/shared/application/index.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoreLibrary = void 0;
|
|
4
|
-
const __1 = require("../..");
|
|
5
4
|
const domain_1 = require("../../shared/domain");
|
|
6
5
|
const domain_2 = require("../../operand/domain");
|
|
7
6
|
class CoreLibrary {
|
|
8
7
|
// eslint-disable-next-line no-useless-constructor
|
|
9
|
-
constructor(builder, cloner) {
|
|
8
|
+
constructor(builder, cloner, helper) {
|
|
10
9
|
this.builder = builder;
|
|
11
10
|
this.cloner = cloner;
|
|
11
|
+
this.helper = helper;
|
|
12
12
|
}
|
|
13
13
|
load(model) {
|
|
14
14
|
this.constants(model);
|
|
@@ -98,11 +98,11 @@ class CoreLibrary {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
nullFunctions(model) {
|
|
101
|
-
model.addFunction('nvl(value:T, default:T):T', (value, _default) =>
|
|
102
|
-
model.addFunction('nvl2(value:any, a:T,b:T):T', (value, a, b) =>
|
|
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));
|
|
103
103
|
}
|
|
104
104
|
comparisonFunctions(model) {
|
|
105
|
-
model.addFunction('between(value:T,from:T,to:T):boolean', (value, from, to) =>
|
|
105
|
+
model.addFunction('between(value:T,from:T,to:T):boolean', (value, from, to) => this.helper.val.between(value, from, to));
|
|
106
106
|
model.addFunction('includes(source:string|T[],value:string|T):boolean', (source, value) => source && value ? source.includes(value) : false);
|
|
107
107
|
model.addFunctionAlias('contains', 'includes');
|
|
108
108
|
model.addFunction('in(source:T,...values:T):boolean', (source, ...values) => {
|
|
@@ -117,27 +117,27 @@ class CoreLibrary {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
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) =>
|
|
121
|
-
model.addFunction('isNotNull(value:any):boolean', (value) =>
|
|
122
|
-
model.addFunction('isEmpty(value:string):boolean', (value) =>
|
|
123
|
-
model.addFunction('isNotEmpty(value:string):boolean', (value) =>
|
|
124
|
-
model.addFunction('isBoolean(value:any):boolean', (value) =>
|
|
125
|
-
model.addFunction('isNumber(value:any):boolean', (value) =>
|
|
126
|
-
model.addFunction('isInteger(value:any):boolean', (value) =>
|
|
127
|
-
model.addFunction('isDecimal(value:any):boolean', (value) =>
|
|
128
|
-
model.addFunction('isString(value:any):boolean', (value) =>
|
|
129
|
-
model.addFunction('isDate(value:any):boolean', (value) =>
|
|
130
|
-
model.addFunction('isDateTime(value:any):boolean', (value) =>
|
|
131
|
-
model.addFunction('isTime(value:any):boolean', (value) =>
|
|
132
|
-
model.addFunction('isObject(value:any):boolean', (value) =>
|
|
133
|
-
model.addFunction('isArray(value:any):boolean', (value) =>
|
|
134
|
-
model.addFunction('isBooleanFormat(value:string):boolean', (value) =>
|
|
135
|
-
model.addFunction('isNumberFormat(value:string):boolean', (value) =>
|
|
136
|
-
model.addFunction('isIntegerFormat(value:string):boolean', (value) =>
|
|
137
|
-
model.addFunction('isDecimalFormat(value:string):boolean', (value) =>
|
|
138
|
-
model.addFunction('isDateFormat(value:string):boolean', (value) =>
|
|
139
|
-
model.addFunction('isDateTimeFormat(value:string):boolean', (value) =>
|
|
140
|
-
model.addFunction('isTimeFormat(value:string):boolean', (value) =>
|
|
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));
|
|
141
141
|
}
|
|
142
142
|
numberFunctions(model) {
|
|
143
143
|
model.addFunction('abs(x:number):number', Math.abs);
|
|
@@ -163,8 +163,8 @@ class CoreLibrary {
|
|
|
163
163
|
model.addFunction('trunc(x:number):number', Math.trunc);
|
|
164
164
|
}
|
|
165
165
|
conversionFunctions(model) {
|
|
166
|
-
model.addFunction('toString(value:any):string', (value) =>
|
|
167
|
-
model.addFunction('toNumber(value:any):number', (value) =>
|
|
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));
|
|
168
168
|
model.addFunction('dateToString(date:date):string', (date) => {
|
|
169
169
|
if (typeof date === 'string') {
|
|
170
170
|
return new Date(date).toISOString();
|
|
@@ -176,11 +176,11 @@ class CoreLibrary {
|
|
|
176
176
|
model.addFunction('keys(obj: any):string[]', (obj) => typeof obj === 'object' ? Object.keys(obj) : []);
|
|
177
177
|
model.addFunction('values(obj: any):any[]', (obj) => typeof obj === 'object' ? Object.values(obj) : []);
|
|
178
178
|
model.addFunction('entries(obj: any):[string,any][]', (obj) => typeof obj === 'object' ? Object.entries(obj) : []);
|
|
179
|
-
model.addFunction('fromEntries(entries: [string,any][]): any', (entries) =>
|
|
179
|
+
model.addFunction('fromEntries(entries: [string,any][]): any', (entries) => this.helper.obj.fromEntries(entries));
|
|
180
180
|
}
|
|
181
181
|
stringFunctions(model) {
|
|
182
182
|
model.addFunction('chr(ascii: number):string', (ascii) => String.fromCharCode(ascii));
|
|
183
|
-
model.addFunction('capitalize(value:string):string', (value) =>
|
|
183
|
+
model.addFunction('capitalize(value:string):string', (value) => this.helper.str.capitalize(value));
|
|
184
184
|
model.addFunction('endsWith(value:string, sub:string, start:number):boolean', (value, sub, start) => value.endsWith(sub, start));
|
|
185
185
|
model.addFunction('strCount(source: string, value: string):number', (source, value) => source.split(value).length - 1);
|
|
186
186
|
model.addFunction('lower(value: string):string', (value) => value.toLowerCase());
|
|
@@ -188,17 +188,17 @@ class CoreLibrary {
|
|
|
188
188
|
model.addFunction('ltrim(value: string):string', (value) => value.trimLeft());
|
|
189
189
|
model.addFunction('indexOf(value:string, sub:string, start:number):number', (value, sub, start) => value.indexOf(sub, start));
|
|
190
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) =>
|
|
191
|
+
model.addFunction('replace(value: string, source: string, target: string):string', (value, source, target) => this.helper.str.replace(value, source, target));
|
|
192
192
|
model.addFunction('rpad(value: string, len: number, pad: string):string', (value, len, pad) => value.padEnd(len, pad));
|
|
193
193
|
model.addFunction('rtrim(value: string):string', (value) => value.trimRight());
|
|
194
194
|
model.addFunction('substring(value: string, from: number, count: number):string', (value, from, count) => value.substring(from, count));
|
|
195
195
|
model.addFunctionAlias('substr', 'substring');
|
|
196
196
|
model.addFunction('trim(value: string):string', (value) => value.trim());
|
|
197
197
|
model.addFunction('upper(value: string):string', (value) => value.toUpperCase());
|
|
198
|
-
model.addFunction('concat(...values:any):string', (...values) =>
|
|
198
|
+
model.addFunction('concat(...values:any):string', (...values) => this.helper.str.concat(values));
|
|
199
199
|
model.addFunctionAlias('concatenate', 'concat');
|
|
200
200
|
model.addFunction('test(value: string, regexp: string):boolean', (value, regexp) => new RegExp(regexp).test(value));
|
|
201
|
-
model.addFunction('title(value:string):string', (value) =>
|
|
201
|
+
model.addFunction('title(value:string):string', (value) => this.helper.str.initCap(value));
|
|
202
202
|
model.addFunction('match(value: string, regexp: string):any', (value, regexp) => value ? value.match(regexp) : null);
|
|
203
203
|
model.addFunction('mask(value: string):string', (value) => {
|
|
204
204
|
if (!value)
|
|
@@ -352,7 +352,7 @@ class CoreLibrary {
|
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
arrayFunctions(model) {
|
|
355
|
-
model.addFunction('map(list: any[], predicate: T):T[]', new Map(this.builder, this.cloner));
|
|
355
|
+
model.addFunction('map(list: any[], predicate: T):T[]', new Map(this.builder, this.cloner, this.helper));
|
|
356
356
|
model.addFunctionAlias('select', 'map');
|
|
357
357
|
model.addFunction('foreach(list: any[], predicate: any):void', new Foreach());
|
|
358
358
|
model.addFunctionAlias('each', 'foreach');
|
|
@@ -392,20 +392,20 @@ class CoreLibrary {
|
|
|
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());
|
|
396
|
-
model.addFunction('first(list: T[], predicate: boolean): T', new First());
|
|
397
|
-
model.addFunction('last(list: T[], predicate: boolean): T', new Last());
|
|
398
|
-
model.addFunction('count(list: T[], predicate: boolean): integer', new Count());
|
|
399
|
-
model.addFunction('max(list: T[], predicate: boolean): T', new Max());
|
|
400
|
-
model.addFunction('min(list: T[], predicate: boolean): T', new Min());
|
|
401
|
-
model.addFunction('avg(list: T[], value: number): number', new Avg());
|
|
402
|
-
model.addFunction('sum(list: T[], value: number): number', new Sum());
|
|
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));
|
|
403
403
|
}
|
|
404
404
|
setsFunctions(model) {
|
|
405
|
-
model.addFunction('union(a: T[], b: T[]): T[]', new Union());
|
|
406
|
-
model.addFunction('intersection(a: T[], b: T[]): T[]', new Intersection());
|
|
407
|
-
model.addFunction('difference(a: T[], b: T[]): T[]', new Difference());
|
|
408
|
-
model.addFunction('symmetricDifference(a: T[], b: T[]): T[]', new SymmetricDifference());
|
|
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));
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
exports.CoreLibrary = CoreLibrary;
|
|
@@ -726,13 +726,14 @@ class AssignmentRightShift extends domain_2.PrototypeEvaluator {
|
|
|
726
726
|
}
|
|
727
727
|
class Map extends domain_2.PrototypeEvaluator {
|
|
728
728
|
// eslint-disable-next-line no-useless-constructor
|
|
729
|
-
constructor(builder, cloner, operand) {
|
|
729
|
+
constructor(builder, cloner, helper, operand) {
|
|
730
730
|
super(operand);
|
|
731
731
|
this.builder = builder;
|
|
732
732
|
this.cloner = cloner;
|
|
733
|
+
this.helper = helper;
|
|
733
734
|
}
|
|
734
735
|
clone(operand) {
|
|
735
|
-
return new Map(this.builder, this.cloner, operand);
|
|
736
|
+
return new Map(this.builder, this.cloner, this.helper, operand);
|
|
736
737
|
}
|
|
737
738
|
eval(context) {
|
|
738
739
|
if (this.operand === undefined) {
|
|
@@ -750,7 +751,7 @@ class Map extends domain_2.PrototypeEvaluator {
|
|
|
750
751
|
// In the case of being an object the value to return, find out if there are fields that are summarized
|
|
751
752
|
const keyValue = child;
|
|
752
753
|
if (keyValue) {
|
|
753
|
-
if (
|
|
754
|
+
if (this.helper.operand.haveAggregates(keyValue.children[0])) {
|
|
754
755
|
aggregates.push(keyValue);
|
|
755
756
|
}
|
|
756
757
|
else {
|
|
@@ -760,13 +761,13 @@ class Map extends domain_2.PrototypeEvaluator {
|
|
|
760
761
|
}
|
|
761
762
|
if (aggregates.length > 0) {
|
|
762
763
|
// case with aggregate functions
|
|
763
|
-
const keys =
|
|
764
|
+
const keys = this.helper.operand.getKeys(this.operand.children[1], groupers, list, context);
|
|
764
765
|
// once you got all the keys you have to calculate the aggregates fields
|
|
765
766
|
const variable = this.operand.children[1];
|
|
766
767
|
for (const key of keys) {
|
|
767
768
|
for (const keyValue of aggregates) {
|
|
768
769
|
const operandCloned = this.cloner.clone(keyValue.children[0], 'expression');
|
|
769
|
-
const operandResolved =
|
|
770
|
+
const operandResolved = this.helper.operand.solveAggregates(key.items, variable, operandCloned, context);
|
|
770
771
|
const value = operandResolved.eval(context);
|
|
771
772
|
key.summarizers.push({ name: keyValue.name, value });
|
|
772
773
|
}
|
|
@@ -814,7 +815,7 @@ class Map extends domain_2.PrototypeEvaluator {
|
|
|
814
815
|
// In the case of being an object the value to return, find out if there are fields that are summarized
|
|
815
816
|
const keyValue = child;
|
|
816
817
|
if (keyValue) {
|
|
817
|
-
if (
|
|
818
|
+
if (this.helper.operand.haveAggregates(keyValue.children[0])) {
|
|
818
819
|
aggregates.push(keyValue);
|
|
819
820
|
}
|
|
820
821
|
else {
|
|
@@ -824,13 +825,13 @@ class Map extends domain_2.PrototypeEvaluator {
|
|
|
824
825
|
}
|
|
825
826
|
if (aggregates.length > 0) {
|
|
826
827
|
// case with aggregate functions
|
|
827
|
-
const keys =
|
|
828
|
+
const keys = this.helper.operand.getKeys(this.operand.children[1], groupers, list, context);
|
|
828
829
|
// once you got all the keys you have to calculate the aggregates fields
|
|
829
830
|
const variable = this.operand.children[1];
|
|
830
831
|
for (const key of keys) {
|
|
831
832
|
for (const keyValue of aggregates) {
|
|
832
833
|
const operandCloned = this.cloner.clone(keyValue.children[0], 'expression');
|
|
833
|
-
const operandResolved =
|
|
834
|
+
const operandResolved = this.helper.operand.solveAggregates(key.items, variable, operandCloned, context);
|
|
834
835
|
const value = await operandResolved.solve(context);
|
|
835
836
|
key.summarizers.push({ name: keyValue.name, value });
|
|
836
837
|
}
|
|
@@ -864,8 +865,12 @@ class Map extends domain_2.PrototypeEvaluator {
|
|
|
864
865
|
}
|
|
865
866
|
}
|
|
866
867
|
class Distinct extends domain_2.PrototypeEvaluator {
|
|
868
|
+
constructor(helper, operand) {
|
|
869
|
+
super(operand);
|
|
870
|
+
this.helper = helper;
|
|
871
|
+
}
|
|
867
872
|
clone(operand) {
|
|
868
|
-
return new Distinct(operand);
|
|
873
|
+
return new Distinct(this.helper, operand);
|
|
869
874
|
}
|
|
870
875
|
eval(context) {
|
|
871
876
|
if (this.operand === undefined) {
|
|
@@ -887,7 +892,7 @@ class Distinct extends domain_2.PrototypeEvaluator {
|
|
|
887
892
|
}
|
|
888
893
|
else if (this.operand.children[2].type === domain_1.OperandType.Obj) {
|
|
889
894
|
// case with aggregate functions
|
|
890
|
-
const keys =
|
|
895
|
+
const keys = this.helper.operand.getKeys(this.operand.children[1], this.operand.children[2].children, list, context.newContext());
|
|
891
896
|
// build the list of results
|
|
892
897
|
for (const key of keys) {
|
|
893
898
|
const row = {};
|
|
@@ -932,7 +937,7 @@ class Distinct extends domain_2.PrototypeEvaluator {
|
|
|
932
937
|
}
|
|
933
938
|
else if (this.operand.children[2].type === domain_1.OperandType.Obj) {
|
|
934
939
|
// case with aggregate functions
|
|
935
|
-
const keys =
|
|
940
|
+
const keys = this.helper.operand.getKeys(this.operand.children[1], this.operand.children[2].children, list, context.newContext());
|
|
936
941
|
// build the list of results
|
|
937
942
|
for (const key of keys) {
|
|
938
943
|
const row = {};
|
|
@@ -1172,8 +1177,12 @@ class Remove extends domain_2.PrototypeEvaluator {
|
|
|
1172
1177
|
}
|
|
1173
1178
|
}
|
|
1174
1179
|
class First extends domain_2.PrototypeEvaluator {
|
|
1180
|
+
constructor(helper, operand) {
|
|
1181
|
+
super(operand);
|
|
1182
|
+
this.helper = helper;
|
|
1183
|
+
}
|
|
1175
1184
|
clone(operand) {
|
|
1176
|
-
return new First(operand);
|
|
1185
|
+
return new First(this.helper, operand);
|
|
1177
1186
|
}
|
|
1178
1187
|
eval(context) {
|
|
1179
1188
|
if (this.operand === undefined) {
|
|
@@ -1197,12 +1206,16 @@ class First extends domain_2.PrototypeEvaluator {
|
|
|
1197
1206
|
if (this.operand.children.length === 1) {
|
|
1198
1207
|
return list && list.length > 0 ? list[0] : null;
|
|
1199
1208
|
}
|
|
1200
|
-
return
|
|
1209
|
+
return this.helper.operand.first(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1201
1210
|
}
|
|
1202
1211
|
}
|
|
1203
1212
|
class Last extends domain_2.PrototypeEvaluator {
|
|
1213
|
+
constructor(helper, operand) {
|
|
1214
|
+
super(operand);
|
|
1215
|
+
this.helper = helper;
|
|
1216
|
+
}
|
|
1204
1217
|
clone(operand) {
|
|
1205
|
-
return new Last(operand);
|
|
1218
|
+
return new Last(this.helper, operand);
|
|
1206
1219
|
}
|
|
1207
1220
|
eval(context) {
|
|
1208
1221
|
if (this.operand === undefined) {
|
|
@@ -1226,12 +1239,16 @@ class Last extends domain_2.PrototypeEvaluator {
|
|
|
1226
1239
|
if (this.operand.children.length === 1) {
|
|
1227
1240
|
return list && list.length > 0 ? list[list.length - 1] : null;
|
|
1228
1241
|
}
|
|
1229
|
-
return
|
|
1242
|
+
return this.helper.operand.last(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1230
1243
|
}
|
|
1231
1244
|
}
|
|
1232
1245
|
class Count extends domain_2.PrototypeEvaluator {
|
|
1246
|
+
constructor(helper, operand) {
|
|
1247
|
+
super(operand);
|
|
1248
|
+
this.helper = helper;
|
|
1249
|
+
}
|
|
1233
1250
|
clone(operand) {
|
|
1234
|
-
return new Count(operand);
|
|
1251
|
+
return new Count(this.helper, operand);
|
|
1235
1252
|
}
|
|
1236
1253
|
eval(context) {
|
|
1237
1254
|
if (this.operand === undefined) {
|
|
@@ -1255,12 +1272,16 @@ class Count extends domain_2.PrototypeEvaluator {
|
|
|
1255
1272
|
if (this.operand.children.length === 1) {
|
|
1256
1273
|
return list.length;
|
|
1257
1274
|
}
|
|
1258
|
-
return
|
|
1275
|
+
return this.helper.operand.count(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1259
1276
|
}
|
|
1260
1277
|
}
|
|
1261
1278
|
class Max extends domain_2.PrototypeEvaluator {
|
|
1279
|
+
constructor(helper, operand) {
|
|
1280
|
+
super(operand);
|
|
1281
|
+
this.helper = helper;
|
|
1282
|
+
}
|
|
1262
1283
|
clone(operand) {
|
|
1263
|
-
return new Max(operand);
|
|
1284
|
+
return new Max(this.helper, operand);
|
|
1264
1285
|
}
|
|
1265
1286
|
eval(context) {
|
|
1266
1287
|
if (this.operand === undefined) {
|
|
@@ -1290,12 +1311,16 @@ class Max extends domain_2.PrototypeEvaluator {
|
|
|
1290
1311
|
}
|
|
1291
1312
|
return max;
|
|
1292
1313
|
}
|
|
1293
|
-
return
|
|
1314
|
+
return this.helper.operand.max(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1294
1315
|
}
|
|
1295
1316
|
}
|
|
1296
1317
|
class Min extends domain_2.PrototypeEvaluator {
|
|
1318
|
+
constructor(helper, operand) {
|
|
1319
|
+
super(operand);
|
|
1320
|
+
this.helper = helper;
|
|
1321
|
+
}
|
|
1297
1322
|
clone(operand) {
|
|
1298
|
-
return new Min(operand);
|
|
1323
|
+
return new Min(this.helper, operand);
|
|
1299
1324
|
}
|
|
1300
1325
|
eval(context) {
|
|
1301
1326
|
if (this.operand === undefined) {
|
|
@@ -1325,12 +1350,16 @@ class Min extends domain_2.PrototypeEvaluator {
|
|
|
1325
1350
|
}
|
|
1326
1351
|
return min;
|
|
1327
1352
|
}
|
|
1328
|
-
return
|
|
1353
|
+
return this.helper.operand.min(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1329
1354
|
}
|
|
1330
1355
|
}
|
|
1331
1356
|
class Avg extends domain_2.PrototypeEvaluator {
|
|
1357
|
+
constructor(helper, operand) {
|
|
1358
|
+
super(operand);
|
|
1359
|
+
this.helper = helper;
|
|
1360
|
+
}
|
|
1332
1361
|
clone(operand) {
|
|
1333
|
-
return new Avg(operand);
|
|
1362
|
+
return new Avg(this.helper, operand);
|
|
1334
1363
|
}
|
|
1335
1364
|
eval(context) {
|
|
1336
1365
|
if (this.operand === undefined) {
|
|
@@ -1357,12 +1386,16 @@ class Avg extends domain_2.PrototypeEvaluator {
|
|
|
1357
1386
|
}
|
|
1358
1387
|
return list.length > 0 ? sum / list.length : 0;
|
|
1359
1388
|
}
|
|
1360
|
-
return
|
|
1389
|
+
return this.helper.operand.avg(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1361
1390
|
}
|
|
1362
1391
|
}
|
|
1363
1392
|
class Sum extends domain_2.PrototypeEvaluator {
|
|
1393
|
+
constructor(helper, operand) {
|
|
1394
|
+
super(operand);
|
|
1395
|
+
this.helper = helper;
|
|
1396
|
+
}
|
|
1364
1397
|
clone(operand) {
|
|
1365
|
-
return new Sum(operand);
|
|
1398
|
+
return new Sum(this.helper, operand);
|
|
1366
1399
|
}
|
|
1367
1400
|
eval(context) {
|
|
1368
1401
|
if (this.operand === undefined) {
|
|
@@ -1392,12 +1425,16 @@ class Sum extends domain_2.PrototypeEvaluator {
|
|
|
1392
1425
|
}
|
|
1393
1426
|
return sum;
|
|
1394
1427
|
}
|
|
1395
|
-
return
|
|
1428
|
+
return this.helper.operand.sum(list, this.operand.children[1], this.operand.children[2], context.newContext());
|
|
1396
1429
|
}
|
|
1397
1430
|
}
|
|
1398
1431
|
class Union extends domain_2.PrototypeEvaluator {
|
|
1432
|
+
constructor(helper, operand) {
|
|
1433
|
+
super(operand);
|
|
1434
|
+
this.helper = helper;
|
|
1435
|
+
}
|
|
1399
1436
|
clone(operand) {
|
|
1400
|
-
return new Union(operand);
|
|
1437
|
+
return new Union(this.helper, operand);
|
|
1401
1438
|
}
|
|
1402
1439
|
eval(context) {
|
|
1403
1440
|
if (this.operand === undefined) {
|
|
@@ -1428,11 +1465,11 @@ class Union extends domain_2.PrototypeEvaluator {
|
|
|
1428
1465
|
}
|
|
1429
1466
|
else if (typeof a[0] === 'object') {
|
|
1430
1467
|
for (const element of a) {
|
|
1431
|
-
const key =
|
|
1468
|
+
const key = this.helper.operand.objectKey(element);
|
|
1432
1469
|
result.push({ key, value: element });
|
|
1433
1470
|
}
|
|
1434
1471
|
for (const element of b) {
|
|
1435
|
-
const key =
|
|
1472
|
+
const key = this.helper.operand.objectKey(element);
|
|
1436
1473
|
if (!result.find((p) => p.key === key)) {
|
|
1437
1474
|
result.push({ key, value: element });
|
|
1438
1475
|
}
|
|
@@ -1449,8 +1486,12 @@ class Union extends domain_2.PrototypeEvaluator {
|
|
|
1449
1486
|
}
|
|
1450
1487
|
}
|
|
1451
1488
|
class Intersection extends domain_2.PrototypeEvaluator {
|
|
1489
|
+
constructor(helper, operand) {
|
|
1490
|
+
super(operand);
|
|
1491
|
+
this.helper = helper;
|
|
1492
|
+
}
|
|
1452
1493
|
clone(operand) {
|
|
1453
|
-
return new Intersection(operand);
|
|
1494
|
+
return new Intersection(this.helper, operand);
|
|
1454
1495
|
}
|
|
1455
1496
|
eval(context) {
|
|
1456
1497
|
if (this.operand === undefined) {
|
|
@@ -1486,9 +1527,9 @@ class Intersection extends domain_2.PrototypeEvaluator {
|
|
|
1486
1527
|
throw new Error('Cannot union arrays of arrays');
|
|
1487
1528
|
}
|
|
1488
1529
|
else if (typeof a[0] === 'object') {
|
|
1489
|
-
const keys = a.map((p) =>
|
|
1530
|
+
const keys = a.map((p) => this.helper.operand.objectKey(p));
|
|
1490
1531
|
for (const element of b) {
|
|
1491
|
-
const key =
|
|
1532
|
+
const key = this.helper.operand.objectKey(element);
|
|
1492
1533
|
if (keys.includes(key)) {
|
|
1493
1534
|
result.push(element);
|
|
1494
1535
|
}
|
|
@@ -1506,8 +1547,12 @@ class Intersection extends domain_2.PrototypeEvaluator {
|
|
|
1506
1547
|
}
|
|
1507
1548
|
}
|
|
1508
1549
|
class Difference extends domain_2.PrototypeEvaluator {
|
|
1550
|
+
constructor(helper, operand) {
|
|
1551
|
+
super(operand);
|
|
1552
|
+
this.helper = helper;
|
|
1553
|
+
}
|
|
1509
1554
|
clone(operand) {
|
|
1510
|
-
return new Difference(operand);
|
|
1555
|
+
return new Difference(this.helper, operand);
|
|
1511
1556
|
}
|
|
1512
1557
|
eval(context) {
|
|
1513
1558
|
if (this.operand === undefined) {
|
|
@@ -1546,9 +1591,9 @@ class Difference extends domain_2.PrototypeEvaluator {
|
|
|
1546
1591
|
throw new Error('Cannot union arrays of arrays');
|
|
1547
1592
|
}
|
|
1548
1593
|
else if (typeof a[0] === 'object') {
|
|
1549
|
-
const keys = b.map((p) =>
|
|
1594
|
+
const keys = b.map((p) => this.helper.operand.objectKey(p));
|
|
1550
1595
|
for (const element of a) {
|
|
1551
|
-
const key =
|
|
1596
|
+
const key = this.helper.operand.objectKey(element);
|
|
1552
1597
|
if (!keys.includes(key)) {
|
|
1553
1598
|
result.push(element);
|
|
1554
1599
|
}
|
|
@@ -1566,8 +1611,12 @@ class Difference extends domain_2.PrototypeEvaluator {
|
|
|
1566
1611
|
}
|
|
1567
1612
|
}
|
|
1568
1613
|
class SymmetricDifference extends domain_2.PrototypeEvaluator {
|
|
1614
|
+
constructor(helper, operand) {
|
|
1615
|
+
super(operand);
|
|
1616
|
+
this.helper = helper;
|
|
1617
|
+
}
|
|
1569
1618
|
clone(operand) {
|
|
1570
|
-
return new SymmetricDifference(operand);
|
|
1619
|
+
return new SymmetricDifference(this.helper, operand);
|
|
1571
1620
|
}
|
|
1572
1621
|
eval(context) {
|
|
1573
1622
|
if (this.operand === undefined) {
|
|
@@ -1606,16 +1655,16 @@ class SymmetricDifference extends domain_2.PrototypeEvaluator {
|
|
|
1606
1655
|
throw new Error('Cannot union arrays of arrays');
|
|
1607
1656
|
}
|
|
1608
1657
|
else if (typeof a[0] === 'object') {
|
|
1609
|
-
const aKeys = a.map((p) =>
|
|
1610
|
-
const bKeys = b.map((p) =>
|
|
1658
|
+
const aKeys = a.map((p) => this.helper.operand.objectKey(p));
|
|
1659
|
+
const bKeys = b.map((p) => this.helper.operand.objectKey(p));
|
|
1611
1660
|
for (const element of a) {
|
|
1612
|
-
const key =
|
|
1661
|
+
const key = this.helper.operand.objectKey(element);
|
|
1613
1662
|
if (!bKeys.includes(key)) {
|
|
1614
1663
|
result.push(element);
|
|
1615
1664
|
}
|
|
1616
1665
|
}
|
|
1617
1666
|
for (const element of b) {
|
|
1618
|
-
const key =
|
|
1667
|
+
const key = this.helper.operand.objectKey(element);
|
|
1619
1668
|
if (!aKeys.includes(key)) {
|
|
1620
1669
|
result.push(element);
|
|
1621
1670
|
}
|