@allgemein/mango-expressions 1.3.3 → 1.4.1
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/AExpr.d.ts +11 -0
- package/AExpr.js +37 -0
- package/AExpr.js.map +1 -0
- package/Constants.d.ts +1 -0
- package/Constants.js +2 -5
- package/Constants.js.map +1 -1
- package/IWalker.d.ts +19 -0
- package/IWalker.js +2 -0
- package/IWalker.js.map +1 -0
- package/README.md +69 -1
- package/_Expr.d.ts +1 -0
- package/_Expr.js +52 -0
- package/_Expr.js.map +1 -0
- package/ast/AbstractValue.d.ts +7 -0
- package/ast/AbstractValue.js +27 -0
- package/ast/AbstractValue.js.map +1 -0
- package/ast/Bindings.d.ts +1 -2
- package/ast/Bindings.js +1 -5
- package/ast/Bindings.js.map +1 -1
- package/ast/Constan.d.ts +11 -0
- package/ast/Constan.js +2 -0
- package/ast/Constan.js.map +1 -0
- package/ast/Context.js +8 -12
- package/ast/Context.js.map +1 -1
- package/ast/Expr.d.ts +23 -0
- package/ast/Expr.js +90 -0
- package/ast/Expr.js.map +1 -0
- package/ast/IExpr.d.ts +16 -0
- package/ast/IExpr.js +2 -0
- package/ast/IExpr.js.map +1 -0
- package/ast/IParser.d.ts +14 -0
- package/ast/IParser.js +2 -0
- package/ast/IParser.js.map +1 -0
- package/ast/IStackEntry.d.ts +13 -0
- package/ast/IStackEntry.js +2 -0
- package/ast/IStackEntry.js.map +1 -0
- package/ast/JsonParser.d.ts +25 -0
- package/ast/JsonParser.js +60 -0
- package/ast/JsonParser.js.map +1 -0
- package/ast/KeyDesc.d.ts +2 -4
- package/ast/KeyDesc.js +4 -9
- package/ast/KeyDesc.js.map +1 -1
- package/ast/MultiArgs.js +1 -5
- package/ast/MultiArgs.js.map +1 -1
- package/ast/PArray.d.ts +1 -10
- package/ast/PArray.js +67 -53
- package/ast/PArray.js.map +1 -1
- package/ast/PObject.d.ts +1 -17
- package/ast/PObject.js +130 -108
- package/ast/PObject.js.map +1 -1
- package/ast/RefDesc.d.ts +5 -0
- package/ast/RefDesc.js +12 -0
- package/ast/RefDesc.js.map +1 -0
- package/ast/Selector.d.ts +19 -5
- package/ast/Selector.js +31 -9
- package/ast/Selector.js.map +1 -1
- package/ast/StackEntry.d.ts +24 -0
- package/ast/StackEntry.js +121 -0
- package/ast/StackEntry.js.map +1 -0
- package/ast/StringParser.d.ts +16 -0
- package/ast/StringParser.js +301 -0
- package/ast/StringParser.js.map +1 -0
- package/ast/Unset.d.ts +2 -2
- package/ast/Unset.js +2 -6
- package/ast/Unset.js.map +1 -1
- package/ast/ValueDesc.d.ts +4 -0
- package/ast/ValueDesc.js +9 -0
- package/ast/ValueDesc.js.map +1 -0
- package/ast/functions.d.ts +1 -0
- package/ast/functions.js +8 -0
- package/ast/functions.js.map +1 -0
- package/browser.d.ts +52 -55
- package/browser.js +53 -117
- package/browser.js.map +1 -1
- package/errors/InvalidValueError.d.ts +4 -0
- package/errors/InvalidValueError.js +6 -0
- package/errors/InvalidValueError.js.map +1 -0
- package/errors/NotYetImplementedError.d.ts +3 -0
- package/errors/NotYetImplementedError.js +6 -0
- package/errors/NotYetImplementedError.js.map +1 -0
- package/errors/UnsupportedInputError.d.ts +3 -0
- package/errors/UnsupportedInputError.js +6 -0
- package/errors/UnsupportedInputError.js.map +1 -0
- package/functions.d.ts +9 -0
- package/functions.js +107 -0
- package/functions.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +5 -64
- package/index.js.map +1 -1
- package/operators/AbstractCompare.d.ts +23 -0
- package/operators/AbstractCompare.js +100 -0
- package/operators/AbstractCompare.js.map +1 -0
- package/operators/AbstractFunction.d.ts +6 -0
- package/operators/AbstractFunction.js +10 -0
- package/operators/AbstractFunction.js.map +1 -0
- package/operators/AbstractJunctor.d.ts +13 -0
- package/operators/AbstractJunctor.js +31 -0
- package/operators/AbstractJunctor.js.map +1 -0
- package/operators/AbstractJunctorArray.d.ts +18 -0
- package/operators/AbstractJunctorArray.js +63 -0
- package/operators/AbstractJunctorArray.js.map +1 -0
- package/operators/AbstractOperator.d.ts +6 -6
- package/operators/AbstractOperator.js +12 -31
- package/operators/AbstractOperator.js.map +1 -1
- package/operators/Components.d.ts +30 -0
- package/operators/Components.js +140 -0
- package/operators/Components.js.map +1 -0
- package/operators/arithmetic/Avg.d.ts +2 -2
- package/operators/arithmetic/Avg.js +2 -6
- package/operators/arithmetic/Avg.js.map +1 -1
- package/operators/arithmetic/Count.d.ts +2 -2
- package/operators/arithmetic/Count.js +2 -6
- package/operators/arithmetic/Count.js.map +1 -1
- package/operators/arithmetic/Max.d.ts +2 -2
- package/operators/arithmetic/Max.js +2 -6
- package/operators/arithmetic/Max.js.map +1 -1
- package/operators/arithmetic/Min.d.ts +2 -2
- package/operators/arithmetic/Min.js +2 -6
- package/operators/arithmetic/Min.js.map +1 -1
- package/operators/arithmetic/Multiply.d.ts +2 -2
- package/operators/arithmetic/Multiply.js +2 -6
- package/operators/arithmetic/Multiply.js.map +1 -1
- package/operators/arithmetic/Sum.d.ts +2 -2
- package/operators/arithmetic/Sum.js +2 -6
- package/operators/arithmetic/Sum.js.map +1 -1
- package/operators/array/First.d.ts +2 -4
- package/operators/array/First.js +9 -15
- package/operators/array/First.js.map +1 -1
- package/operators/array/Last.d.ts +2 -4
- package/operators/array/Last.js +9 -15
- package/operators/array/Last.js.map +1 -1
- package/operators/array/Map.d.ts +5 -6
- package/operators/array/Map.js +14 -20
- package/operators/array/Map.js.map +1 -1
- package/operators/compare/EqualDesc.d.ts +6 -7
- package/operators/compare/EqualDesc.js +13 -11
- package/operators/compare/EqualDesc.js.map +1 -1
- package/operators/compare/EqualDescLookup.d.ts +2 -2
- package/operators/compare/EqualDescLookup.js +24 -31
- package/operators/compare/EqualDescLookup.js.map +1 -1
- package/operators/compare/GreaterThen.d.ts +3 -4
- package/operators/compare/GreaterThen.js +3 -7
- package/operators/compare/GreaterThen.js.map +1 -1
- package/operators/compare/GreaterThenEqual.d.ts +3 -4
- package/operators/compare/GreaterThenEqual.js +3 -7
- package/operators/compare/GreaterThenEqual.js.map +1 -1
- package/operators/compare/In.d.ts +3 -4
- package/operators/compare/In.js +3 -7
- package/operators/compare/In.js.map +1 -1
- package/operators/compare/IsNotNull.d.ts +3 -3
- package/operators/compare/IsNotNull.js +3 -7
- package/operators/compare/IsNotNull.js.map +1 -1
- package/operators/compare/IsNull.d.ts +3 -3
- package/operators/compare/IsNull.js +3 -7
- package/operators/compare/IsNull.js.map +1 -1
- package/operators/compare/LessThen.d.ts +3 -3
- package/operators/compare/LessThen.js +3 -6
- package/operators/compare/LessThen.js.map +1 -1
- package/operators/compare/LessThenEqual.d.ts +3 -4
- package/operators/compare/LessThenEqual.js +3 -7
- package/operators/compare/LessThenEqual.js.map +1 -1
- package/operators/compare/Like.d.ts +3 -4
- package/operators/compare/Like.js +3 -7
- package/operators/compare/Like.js.map +1 -1
- package/operators/compare/NotEqual.d.ts +3 -4
- package/operators/compare/NotEqual.js +3 -7
- package/operators/compare/NotEqual.js.map +1 -1
- package/operators/compare/NotIn.d.ts +3 -4
- package/operators/compare/NotIn.js +3 -7
- package/operators/compare/NotIn.js.map +1 -1
- package/operators/compare/Regex.d.ts +2 -6
- package/operators/compare/Regex.js +28 -33
- package/operators/compare/Regex.js.map +1 -1
- package/operators/date/Date.d.ts +2 -2
- package/operators/date/Date.js +3 -6
- package/operators/date/Date.js.map +1 -1
- package/operators/date/DateToString.d.ts +4 -5
- package/operators/date/DateToString.js +15 -20
- package/operators/date/DateToString.js.map +1 -1
- package/operators/date/Day.d.ts +2 -2
- package/operators/date/Day.js +2 -6
- package/operators/date/Day.js.map +1 -1
- package/operators/date/Month.d.ts +2 -2
- package/operators/date/Month.js +2 -6
- package/operators/date/Month.js.map +1 -1
- package/operators/date/Year.d.ts +2 -2
- package/operators/date/Year.js +2 -6
- package/operators/date/Year.js.map +1 -1
- package/operators/logic/AndDesc.d.ts +5 -7
- package/operators/logic/AndDesc.js +16 -21
- package/operators/logic/AndDesc.js.map +1 -1
- package/operators/logic/AndDescLookup.d.ts +2 -2
- package/operators/logic/AndDescLookup.js +1 -5
- package/operators/logic/AndDescLookup.js.map +1 -1
- package/operators/logic/NotDesc.d.ts +8 -0
- package/operators/logic/NotDesc.js +21 -0
- package/operators/logic/NotDesc.js.map +1 -0
- package/operators/logic/OrDesc.d.ts +5 -7
- package/operators/logic/OrDesc.js +5 -21
- package/operators/logic/OrDesc.js.map +1 -1
- package/operators/stage/AbstractSection.d.ts +7 -0
- package/operators/stage/AbstractSection.js +11 -0
- package/operators/stage/AbstractSection.js.map +1 -0
- package/operators/stage/Group.d.ts +4 -10
- package/operators/stage/Group.js +33 -39
- package/operators/stage/Group.js.map +1 -1
- package/operators/stage/Limit.d.ts +2 -2
- package/operators/stage/Limit.js +2 -6
- package/operators/stage/Limit.js.map +1 -1
- package/operators/stage/Match.d.ts +2 -8
- package/operators/stage/Match.js +2 -20
- package/operators/stage/Match.js.map +1 -1
- package/operators/stage/Project.d.ts +2 -8
- package/operators/stage/Project.js +17 -21
- package/operators/stage/Project.js.map +1 -1
- package/operators/stage/Query..d.ts +1 -0
- package/operators/stage/Query..js +3 -0
- package/operators/stage/Query..js.map +1 -0
- package/operators/stage/Skip.d.ts +2 -6
- package/operators/stage/Skip.js +6 -11
- package/operators/stage/Skip.js.map +1 -1
- package/operators/stage/Sort.d.ts +2 -6
- package/operators/stage/Sort.js +6 -11
- package/operators/stage/Sort.js.map +1 -1
- package/operators/string/Substr.d.ts +2 -4
- package/operators/string/Substr.js +19 -22
- package/operators/string/Substr.js.map +1 -1
- package/operators/string/ToFloat.d.ts +2 -3
- package/operators/string/ToFloat.js +9 -15
- package/operators/string/ToFloat.js.map +1 -1
- package/operators/string/ToInt.d.ts +2 -3
- package/operators/string/ToInt.js +9 -15
- package/operators/string/ToInt.js.map +1 -1
- package/operators/string/ToLower.d.ts +2 -3
- package/operators/string/ToLower.js +9 -15
- package/operators/string/ToLower.js.map +1 -1
- package/operators/string/ToUpper.d.ts +2 -4
- package/operators/string/ToUpper.js +9 -15
- package/operators/string/ToUpper.js.map +1 -1
- package/package.json +2 -1
- package/walker/lookup/ILookupFn.d.ts +2 -2
- package/walker/lookup/ILookupFn.js +1 -2
- package/walker/lookup/LookupWalker.d.ts +11 -11
- package/walker/lookup/LookupWalker.js +19 -23
- package/walker/lookup/LookupWalker.js.map +1 -1
- package/IMangoWalker.d.ts +0 -19
- package/IMangoWalker.js +0 -3
- package/IMangoWalker.js.map +0 -1
- package/MangoExpression.d.ts +0 -15
- package/MangoExpression.js +0 -88
- package/MangoExpression.js.map +0 -1
- package/ast/PAst.d.ts +0 -42
- package/ast/PAst.js +0 -158
- package/ast/PAst.js.map +0 -1
- package/ast/PValue.d.ts +0 -10
- package/ast/PValue.js +0 -22
- package/ast/PValue.js.map +0 -1
- package/ast/Value.d.ts +0 -3
- package/ast/Value.js +0 -8
- package/ast/Value.js.map +0 -1
- package/ast/ValueRef.d.ts +0 -4
- package/ast/ValueRef.js +0 -11
- package/ast/ValueRef.js.map +0 -1
- package/operators/Operators.d.ts +0 -35
- package/operators/Operators.js +0 -149
- package/operators/Operators.js.map +0 -1
- package/operators/compare/AbstractCompare.d.ts +0 -5
- package/operators/compare/AbstractCompare.js +0 -14
- package/operators/compare/AbstractCompare.js.map +0 -1
- package/operators/logic/AbstractLogic.d.ts +0 -3
- package/operators/logic/AbstractLogic.js +0 -8
- package/operators/logic/AbstractLogic.js.map +0 -1
- package/operators/logic/Not.d.ts +0 -8
- package/operators/logic/Not.js +0 -22
- package/operators/logic/Not.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractOperator } from './AbstractOperator.js';
|
|
2
|
+
import { IStackEntry } from '../ast/IStackEntry.js';
|
|
3
|
+
import { IExpr } from '../ast/IExpr.js';
|
|
4
|
+
export declare abstract class AbstractCompare extends AbstractOperator {
|
|
5
|
+
/**
|
|
6
|
+
* Differenze between notation of a comparator
|
|
7
|
+
*
|
|
8
|
+
* {key: {$COMPARE_IDENT: value}}
|
|
9
|
+
* or
|
|
10
|
+
* {$COMPARE_IDENT: [key, value]}
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
mode: 'key_ref' | 'array';
|
|
14
|
+
leftSide: IExpr;
|
|
15
|
+
rightSide: IExpr;
|
|
16
|
+
getLeftSide(): IExpr;
|
|
17
|
+
setLeftSide(arg1: IExpr): void;
|
|
18
|
+
getRightSide(): IExpr;
|
|
19
|
+
setRightSide(result: IExpr): void;
|
|
20
|
+
getChildren(): IExpr[];
|
|
21
|
+
parse(entry: IStackEntry, partial: any, key: string | number): IExpr;
|
|
22
|
+
toJson(): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { AbstractOperator } from './AbstractOperator.js';
|
|
2
|
+
import { Selector } from '../ast/Selector.js';
|
|
3
|
+
import { Expr } from '../ast/Expr.js';
|
|
4
|
+
import { NotYetImplementedError } from '../errors/NotYetImplementedError.js';
|
|
5
|
+
import { isArray } from '@allgemein/base';
|
|
6
|
+
import { KeyDesc } from '../ast/KeyDesc.js';
|
|
7
|
+
import { AbstractJunctorArray } from './AbstractJunctorArray.js';
|
|
8
|
+
export class AbstractCompare extends AbstractOperator {
|
|
9
|
+
constructor() {
|
|
10
|
+
// op: string;
|
|
11
|
+
super(...arguments);
|
|
12
|
+
/**
|
|
13
|
+
* Differenze between notation of a comparator
|
|
14
|
+
*
|
|
15
|
+
* {key: {$COMPARE_IDENT: value}}
|
|
16
|
+
* or
|
|
17
|
+
* {$COMPARE_IDENT: [key, value]}
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
this.mode = 'key_ref';
|
|
21
|
+
}
|
|
22
|
+
getLeftSide() {
|
|
23
|
+
return this.leftSide;
|
|
24
|
+
}
|
|
25
|
+
setLeftSide(arg1) {
|
|
26
|
+
this.leftSide = arg1;
|
|
27
|
+
}
|
|
28
|
+
getRightSide() {
|
|
29
|
+
return this.rightSide;
|
|
30
|
+
}
|
|
31
|
+
setRightSide(result) {
|
|
32
|
+
this.rightSide = result;
|
|
33
|
+
}
|
|
34
|
+
getChildren() {
|
|
35
|
+
return [this.leftSide, this.rightSide];
|
|
36
|
+
}
|
|
37
|
+
parse(entry, partial, key) {
|
|
38
|
+
const parent = entry.getParentComp();
|
|
39
|
+
if (parent && parent instanceof Selector) {
|
|
40
|
+
// Mode is key_ref, because the key of this partial is defined
|
|
41
|
+
this.mode = 'key_ref';
|
|
42
|
+
// Selectors an on the left side and the operator becomes the parent, the operation will be the parent of the selector
|
|
43
|
+
this.setLeftSide(parent);
|
|
44
|
+
// switch parents
|
|
45
|
+
const p = parent.getParent();
|
|
46
|
+
parent.setParent(this);
|
|
47
|
+
this.setParent(p);
|
|
48
|
+
if (p) {
|
|
49
|
+
if (p instanceof AbstractJunctorArray) {
|
|
50
|
+
p.switchChildValue(parent, this);
|
|
51
|
+
}
|
|
52
|
+
else if (p instanceof AbstractOperator) {
|
|
53
|
+
p.switchValue(parent, this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
entry.enqueue(partial, key, result => this.setRightSide(result.comp));
|
|
57
|
+
}
|
|
58
|
+
else if (isArray(partial) && partial.length === 2) {
|
|
59
|
+
// No key was previously detected, so key is a given and value is array of 2
|
|
60
|
+
this.mode = 'array';
|
|
61
|
+
if (parent) {
|
|
62
|
+
this.setParent(parent);
|
|
63
|
+
}
|
|
64
|
+
entry.enqueue(partial[0], 0, result => this.setLeftSide(result.comp), { comp: KeyDesc, resolve: (partial) => [partial, undefined] });
|
|
65
|
+
entry.enqueue(partial[1], 1, result => this.setRightSide(result.comp));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new NotYetImplementedError();
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
toJson() {
|
|
73
|
+
const leftSide = this.getLeftSide();
|
|
74
|
+
const rightSide = this.getRightSide();
|
|
75
|
+
let key = null;
|
|
76
|
+
let value = null;
|
|
77
|
+
if (leftSide instanceof Expr) {
|
|
78
|
+
key = leftSide.toJson();
|
|
79
|
+
}
|
|
80
|
+
if (rightSide instanceof Expr) {
|
|
81
|
+
value = rightSide.toJson();
|
|
82
|
+
}
|
|
83
|
+
if (!key) {
|
|
84
|
+
throw new NotYetImplementedError();
|
|
85
|
+
}
|
|
86
|
+
if (this.mode === 'key_ref') {
|
|
87
|
+
return {
|
|
88
|
+
[key]: {
|
|
89
|
+
['$' + this.name]: value
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return {
|
|
95
|
+
['$' + this.name]: [key, value]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=AbstractCompare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractCompare.js","sourceRoot":"","sources":["../../../src/operators/AbstractCompare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAE/D,MAAM,OAAgB,eAAgB,SAAQ,gBAAgB;IAA9D;QAEE,cAAc;;QAGd;;;;;;;WAOG;QACH,SAAI,GAAwB,SAAS,CAAC;IAmGxC,CAAC;IA7FC,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,WAAW,CAAC,IAAW;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACv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C,EAAE;oBACL,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK;iBACzB;aACF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC;aAChC,CAAC;QACJ,CAAC;IACH,CAAC;CAGF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Expr } from '../ast/Expr.js';
|
|
2
|
+
export class AbstractFunction extends Expr {
|
|
3
|
+
getByKey(key) {
|
|
4
|
+
throw new Error('Method not implemented.');
|
|
5
|
+
}
|
|
6
|
+
visit(o) {
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AbstractFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractFunction.js","sourceRoot":"","sources":["../../../src/operators/AbstractFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAGpC,MAAM,OAAgB,gBAAiB,SAAQ,IAAI;IAEjD,QAAQ,CAAC,GAAW;QAClB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,CAAU;QACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CAEF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractOperator } from './AbstractOperator.js';
|
|
2
|
+
import { IStackEntry } from '../ast/IStackEntry.js';
|
|
3
|
+
import { IExpr } from '../ast/IExpr.js';
|
|
4
|
+
export declare abstract class AbstractJunctor extends AbstractOperator {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param entry
|
|
8
|
+
* @param partial
|
|
9
|
+
* @param key
|
|
10
|
+
*/
|
|
11
|
+
parse(entry: IStackEntry, partial: any, key: string | number): IExpr;
|
|
12
|
+
toJson(): any;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AbstractOperator } from './AbstractOperator.js';
|
|
2
|
+
import { NotYetImplementedError } from '../errors/NotYetImplementedError.js';
|
|
3
|
+
export class AbstractJunctor extends AbstractOperator {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param entry
|
|
7
|
+
* @param partial
|
|
8
|
+
* @param key
|
|
9
|
+
*/
|
|
10
|
+
parse(entry, partial, key) {
|
|
11
|
+
throw new NotYetImplementedError();
|
|
12
|
+
// if (isArray(partial)) {
|
|
13
|
+
// throw new NotYetImplementedError();
|
|
14
|
+
// } else if (isObjectLike(partial)) {
|
|
15
|
+
// // TODO is operator in partial
|
|
16
|
+
// const partialKeys = Object.keys(partial);
|
|
17
|
+
// // spilt object in multipe parts
|
|
18
|
+
// for (let partialKey of partialKeys.reverse()) {
|
|
19
|
+
// let partialValue = partial[partialKey];
|
|
20
|
+
// entry.enqueue({[partialKey]: partialValue}, partialKey);
|
|
21
|
+
// }
|
|
22
|
+
// } else {
|
|
23
|
+
// throw new NotYetImplementedError();
|
|
24
|
+
// }
|
|
25
|
+
// return this
|
|
26
|
+
}
|
|
27
|
+
toJson() {
|
|
28
|
+
return { ['$' + this.name]: this.value.toJson() };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=AbstractJunctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractJunctor.js","sourceRoot":"","sources":["../../../src/operators/AbstractJunctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAE3E,MAAM,OAAgB,eAAgB,SAAQ,gBAAgB;IAI5D;;;;;OAKG;IACH,KAAK,CAAC,KAAkB,EAAE,OAAY,EAAE,GAAoB;QAC1D,MAAM,IAAI,sBAAsB,EAAE,CAAC;QACnC,0BAA0B;QAC1B,wCAAwC;QACxC,sCAAsC;QACtC,mCAAmC;QACnC,8CAA8C;QAC9C,qCAAqC;QACrC,oDAAoD;QACpD,8CAA8C;QAC9C,+DAA+D;QAC/D,MAAM;QACN,WAAW;QACX,wCAAwC;QACxC,IAAI;QACJ,cAAc;IAChB,CAAC;IAID,MAAM;QACJ,OAAO,EAAC,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAC,CAAC;IAClD,CAAC;CAGF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IStackEntry } from '../ast/IStackEntry.js';
|
|
2
|
+
import { IExpr } from '../ast/IExpr.js';
|
|
3
|
+
import { AbstractJunctor } from './AbstractJunctor.js';
|
|
4
|
+
export declare abstract class AbstractJunctorArray extends AbstractJunctor {
|
|
5
|
+
value: IExpr[];
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param entry
|
|
9
|
+
* @param partial
|
|
10
|
+
* @param key
|
|
11
|
+
*/
|
|
12
|
+
parse(entry: IStackEntry, partial: any, key: string | number): IExpr;
|
|
13
|
+
isGroup(): boolean;
|
|
14
|
+
getChildren(): IExpr[];
|
|
15
|
+
add(e: IExpr): void;
|
|
16
|
+
switchChildValue(from: IExpr, to: IExpr): void;
|
|
17
|
+
toJson(): any;
|
|
18
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isArray, isObjectLike } from '@allgemein/base';
|
|
2
|
+
import { NotYetImplementedError } from '../errors/NotYetImplementedError.js';
|
|
3
|
+
import { AbstractJunctor } from './AbstractJunctor.js';
|
|
4
|
+
export class AbstractJunctorArray extends AbstractJunctor {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
this.value = [];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param entry
|
|
13
|
+
* @param partial
|
|
14
|
+
* @param key
|
|
15
|
+
*/
|
|
16
|
+
parse(entry, partial, key) {
|
|
17
|
+
if (isArray(partial)) {
|
|
18
|
+
for (let i = partial.length - 1; i >= 0; i--) {
|
|
19
|
+
const partialValue = partial[i];
|
|
20
|
+
entry.enqueue(partialValue, i, result => this.add(result.comp));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (isObjectLike(partial)) {
|
|
24
|
+
// TODO is operator in partial
|
|
25
|
+
const partialKeys = Object.keys(partial);
|
|
26
|
+
// split object in multiple parts
|
|
27
|
+
for (const partialKey of partialKeys.reverse()) {
|
|
28
|
+
const partialValue = partial[partialKey];
|
|
29
|
+
entry.enqueue({ [partialKey]: partialValue }, partialKey, result => this.add(result.comp));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new NotYetImplementedError();
|
|
34
|
+
}
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
isGroup() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
getChildren() {
|
|
41
|
+
return this.value;
|
|
42
|
+
}
|
|
43
|
+
add(e) {
|
|
44
|
+
if (isArray(this.getValue())) {
|
|
45
|
+
e.setParent(this);
|
|
46
|
+
this.getValue().push(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
switchChildValue(from, to) {
|
|
50
|
+
const idx = this.value.findIndex(x => x === from);
|
|
51
|
+
if (idx > -1) {
|
|
52
|
+
this.value[idx] = to;
|
|
53
|
+
to.setParent(this);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error('something went wrong');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
toJson() {
|
|
60
|
+
return { ['$' + this.name]: this.value.map(x => x.toJson()) };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=AbstractJunctorAr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Expr.js';
|
|
2
|
+
import { IExpr } from '../ast/IExpr.js';
|
|
3
|
+
export declare abstract class AbstractOperator extends Expr {
|
|
4
4
|
readonly name: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
readonly symbol: string[];
|
|
6
|
+
isOp(): boolean;
|
|
7
|
+
switchValue(from: IExpr, to: IExpr): void;
|
|
8
8
|
}
|
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
getByKey(key) {
|
|
7
|
-
if (key === this.name || key.replace(/^\$/, '') === this.name || this.getKeyString() === key) {
|
|
8
|
-
return this;
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
1
|
+
import { Expr } from '../ast/Expr.js';
|
|
2
|
+
export class AbstractOperator extends Expr {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.symbol = null;
|
|
11
6
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// // this.setValue(this.getRootExpression().interprete(def, this, ctxt) as any as X);
|
|
15
|
-
// return true;
|
|
16
|
-
// }
|
|
17
|
-
visit(o) {
|
|
18
|
-
if (this.getValue()) {
|
|
19
|
-
return o.onOperator(this, this.getValue().visit(o));
|
|
20
|
-
}
|
|
21
|
-
return o.onOperator(this, null);
|
|
7
|
+
isOp() {
|
|
8
|
+
return true;
|
|
22
9
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
['$' + this.name]: res
|
|
29
|
-
};
|
|
10
|
+
switchValue(from, to) {
|
|
11
|
+
if (this.getValue() === from) {
|
|
12
|
+
this.setValue(to);
|
|
13
|
+
to.setParent(this);
|
|
30
14
|
}
|
|
31
15
|
else {
|
|
32
|
-
|
|
33
|
-
['$' + this.name]: v
|
|
34
|
-
};
|
|
16
|
+
throw new Error('something went wrong');
|
|
35
17
|
}
|
|
36
18
|
}
|
|
37
19
|
}
|
|
38
|
-
exports.AbstractOperator = AbstractOperator;
|
|
39
20
|
//# sourceMappingURL=AbstractOperator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractOperator.js","sourceRoot":"","sources":["../../../src/operators/AbstractOperator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractOperator.js","sourceRoot":"","sources":["../../../src/operators/AbstractOperator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAGpC,MAAM,OAAgB,gBAAiB,SAAQ,IAAI;IAAnD;;QAIW,WAAM,GAAa,IAAI,CAAC;IAgBnC,CAAC;IAbC,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,IAAW,EAAE,EAAS;QAChC,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAClB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Expr } from '../ast/Expr.js';
|
|
2
|
+
import { ClassType } from '../Constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Operators registry
|
|
5
|
+
*/
|
|
6
|
+
export declare class Components {
|
|
7
|
+
static registry: {
|
|
8
|
+
[k: string]: ClassType<any>;
|
|
9
|
+
};
|
|
10
|
+
static key(k: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Install new operator
|
|
13
|
+
*
|
|
14
|
+
* @param name
|
|
15
|
+
* @param opertor
|
|
16
|
+
*/
|
|
17
|
+
static install(name: string, opertor: ClassType<any>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Create an operator instance
|
|
20
|
+
*
|
|
21
|
+
* @param name
|
|
22
|
+
*/
|
|
23
|
+
static create(name: string): Expr;
|
|
24
|
+
/**
|
|
25
|
+
* Check if operator is defined.
|
|
26
|
+
*
|
|
27
|
+
* @param name
|
|
28
|
+
*/
|
|
29
|
+
static has(name: string): boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Match } from './stage/Match.js';
|
|
2
|
+
import { LessThen } from './compare/LessThen.js';
|
|
3
|
+
import { AndDesc } from './logic/AndDesc.js';
|
|
4
|
+
import { OrDesc } from './logic/OrDesc.js';
|
|
5
|
+
import { LessThenEqual } from './compare/LessThenEqual.js';
|
|
6
|
+
import { EqualDesc } from './compare/EqualDesc.js';
|
|
7
|
+
import { GreaterThen } from './compare/GreaterThen.js';
|
|
8
|
+
import { GreaterThenEqual } from './compare/GreaterThenEqual.js';
|
|
9
|
+
import { In } from './compare/In.js';
|
|
10
|
+
import { IsNotNull } from './compare/IsNotNull.js';
|
|
11
|
+
import { IsNull } from './compare/IsNull.js';
|
|
12
|
+
import { Like } from './compare/Like.js';
|
|
13
|
+
import { NotEqual } from './compare/NotEqual.js';
|
|
14
|
+
import { NotIn } from './compare/NotIn.js';
|
|
15
|
+
import { Project } from './stage/Project.js';
|
|
16
|
+
import { Year } from './date/Year.js';
|
|
17
|
+
import { Month } from './date/Month.js';
|
|
18
|
+
import { Day } from './date/Day.js';
|
|
19
|
+
import { Group } from './stage/Group.js';
|
|
20
|
+
import { Sum } from './arithmetic/Sum.js';
|
|
21
|
+
import { Min } from './arithmetic/Min.js';
|
|
22
|
+
import { Max } from './arithmetic/Max.js';
|
|
23
|
+
import { Avg } from './arithmetic/Avg.js';
|
|
24
|
+
import { Count } from './arithmetic/Count.js';
|
|
25
|
+
import { Limit } from './stage/Limit.js';
|
|
26
|
+
import { Skip } from './stage/Skip.js';
|
|
27
|
+
import { Sort } from './stage/Sort.js';
|
|
28
|
+
import { Date } from './date/Date.js';
|
|
29
|
+
import { NotDesc } from './logic/NotDesc.js';
|
|
30
|
+
import { Multiply } from './arithmetic/Multiply.js';
|
|
31
|
+
import { Regex } from './compare/Regex.js';
|
|
32
|
+
/**
|
|
33
|
+
* Operators registry
|
|
34
|
+
*/
|
|
35
|
+
export class Components {
|
|
36
|
+
static key(k) {
|
|
37
|
+
return k.replace(/^\$/, '');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Install new operator
|
|
41
|
+
*
|
|
42
|
+
* @param name
|
|
43
|
+
* @param opertor
|
|
44
|
+
*/
|
|
45
|
+
static install(name, opertor) {
|
|
46
|
+
const _name = this.key(name);
|
|
47
|
+
this.registry[_name] = opertor;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create an operator instance
|
|
51
|
+
*
|
|
52
|
+
* @param name
|
|
53
|
+
*/
|
|
54
|
+
static create(name) {
|
|
55
|
+
const _name = this.key(name);
|
|
56
|
+
if (this.registry[_name]) {
|
|
57
|
+
return Reflect.construct(this.registry[_name], []);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new Error(`no such operator ${_name} defined`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if operator is defined.
|
|
65
|
+
*
|
|
66
|
+
* @param name
|
|
67
|
+
*/
|
|
68
|
+
static has(name) {
|
|
69
|
+
return this.registry.hasOwnProperty(this.key(name));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
Components.registry = {};
|
|
73
|
+
/*
|
|
74
|
+
* Logic registry
|
|
75
|
+
*/
|
|
76
|
+
Components.install(AndDesc.NAME, AndDesc);
|
|
77
|
+
Components.install(OrDesc.NAME, OrDesc);
|
|
78
|
+
Components.install(NotDesc.NAME, NotDesc);
|
|
79
|
+
// TODO $nor
|
|
80
|
+
/*
|
|
81
|
+
* Stage registry
|
|
82
|
+
*/
|
|
83
|
+
Components.install(Match.NAME, Match);
|
|
84
|
+
Components.install(Project.NAME, Project);
|
|
85
|
+
Components.install(Group.NAME, Group);
|
|
86
|
+
Components.install(Limit.NAME, Limit);
|
|
87
|
+
Components.install(Skip.NAME, Skip);
|
|
88
|
+
Components.install(Sort.NAME, Sort);
|
|
89
|
+
/*
|
|
90
|
+
* Date registry
|
|
91
|
+
*/
|
|
92
|
+
Components.install(Year.NAME, Year);
|
|
93
|
+
Components.install(Month.NAME, Month);
|
|
94
|
+
Components.install(Day.NAME, Day);
|
|
95
|
+
Components.install(Date.NAME, Date);
|
|
96
|
+
// TODO $dateToString
|
|
97
|
+
/*
|
|
98
|
+
* Arithmetic registry
|
|
99
|
+
*/
|
|
100
|
+
Components.install(Sum.NAME, Sum);
|
|
101
|
+
Components.install(Min.NAME, Min);
|
|
102
|
+
Components.install(Max.NAME, Max);
|
|
103
|
+
Components.install(Avg.NAME, Avg);
|
|
104
|
+
Components.install(Count.NAME, Count);
|
|
105
|
+
Components.install(Multiply.NAME, Multiply);
|
|
106
|
+
// TODO $add
|
|
107
|
+
// TODO $subtract
|
|
108
|
+
/*
|
|
109
|
+
* Compare registry
|
|
110
|
+
*/
|
|
111
|
+
Components.install(LessThen.NAME, LessThen);
|
|
112
|
+
Components.install(LessThenEqual.NAME, LessThenEqual);
|
|
113
|
+
Components.install('lte', LessThenEqual); // backward compatibility
|
|
114
|
+
Components.install(EqualDesc.NAME, EqualDesc);
|
|
115
|
+
Components.install(GreaterThen.NAME, GreaterThen);
|
|
116
|
+
Components.install(GreaterThenEqual.NAME, GreaterThenEqual);
|
|
117
|
+
Components.install('gte', GreaterThenEqual); // backward compatibility
|
|
118
|
+
Components.install(In.NAME, In);
|
|
119
|
+
Components.install(IsNotNull.NAME, IsNotNull);
|
|
120
|
+
Components.install(IsNull.NAME, IsNull);
|
|
121
|
+
// sql special, cause no eqivalnet in mongo
|
|
122
|
+
Components.install(Like.NAME, Like);
|
|
123
|
+
Components.install(NotEqual.NAME, NotEqual);
|
|
124
|
+
Components.install(NotIn.NAME, NotIn);
|
|
125
|
+
Components.install(Regex.NAME, Regex);
|
|
126
|
+
/*
|
|
127
|
+
* String registry
|
|
128
|
+
*/
|
|
129
|
+
// Operators.install(Substr.NAME, Substr);
|
|
130
|
+
// Operators.install(ToUpper.NAME, ToUpper);
|
|
131
|
+
// Operators.install(ToLower.NAME, ToLower);
|
|
132
|
+
// Operators.install(ToInt.NAME, ToInt);
|
|
133
|
+
// Operators.install(ToFloat.NAME, ToFloat);
|
|
134
|
+
/*
|
|
135
|
+
* Array registry
|
|
136
|
+
*/
|
|
137
|
+
// Operators.install(Map.NAME, Map);
|
|
138
|
+
// Operators.install(First.NAME, First);
|
|
139
|
+
// Operators.install(Last.NAME, Last);
|
|
140
|
+
//# sourceMappingURL=Components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.js","sourceRoot":"","sources":["../../../src/operators/Components.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,EAAE,EAAC,MAAM,iBAAiB,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,KAAK,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;AAClD,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AAC5D,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,yBAAyB;AACtE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAChC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC9C,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAExC,2CAA2C;AAC3C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACpC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC5C,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACtC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAGtC;;GAEG;AACH,0CAA0C;AAC1C,4CAA4C;AAC5C,4CAA4C;AAC5C,wCAAwC;AACxC,4CAA4C;AAE5C;;GAEG;AACH,oCAAoC;AACpC,wCAAwC;AACxC,sCAAsC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class Avg extends
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export declare class Avg extends AbstractFunction {
|
|
3
3
|
static NAME: string;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Avg = void 0;
|
|
4
|
-
const AbstractOperator_1 = require("../AbstractOperator");
|
|
5
|
-
class Avg extends AbstractOperator_1.AbstractOperator {
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export class Avg extends AbstractFunction {
|
|
6
3
|
constructor() {
|
|
7
4
|
super(...arguments);
|
|
8
5
|
this.name = Avg.NAME;
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.Avg = Avg;
|
|
12
8
|
Avg.NAME = 'avg';
|
|
13
9
|
//# sourceMappingURL=Avg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avg.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Avg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Avg.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Avg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,MAAM,OAAO,GAAI,SAAQ,gBAAgB;IAAzC;;QAIE,SAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAElB,CAAC;CAAA;AAJQ,QAAI,GAAG,KAAK,AAAR,CAAS"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class Count extends
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export declare class Count extends AbstractFunction {
|
|
3
3
|
static NAME: string;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Count = void 0;
|
|
4
|
-
const AbstractOperator_1 = require("../AbstractOperator");
|
|
5
|
-
class Count extends AbstractOperator_1.AbstractOperator {
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export class Count extends AbstractFunction {
|
|
6
3
|
constructor() {
|
|
7
4
|
super(...arguments);
|
|
8
5
|
this.name = Count.NAME;
|
|
@@ -13,6 +10,5 @@ class Count extends AbstractOperator_1.AbstractOperator {
|
|
|
13
10
|
// }
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.Count = Count;
|
|
17
13
|
Count.NAME = 'count';
|
|
18
14
|
//# sourceMappingURL=Count.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Count.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Count.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Count.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,MAAM,OAAO,KAAM,SAAQ,gBAAgB;IAA3C;;QAIE,SAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAElB,EAAE;QACF,gCAAgC;QAChC,4DAA4D;QAC5D,iBAAiB;QACjB,IAAI;IAEN,CAAC;CAAA;AAVQ,UAAI,GAAG,OAAO,AAAV,CAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class Max extends
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export declare class Max extends AbstractFunction {
|
|
3
3
|
static NAME: string;
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Max = void 0;
|
|
4
|
-
const AbstractOperator_1 = require("../AbstractOperator");
|
|
5
|
-
class Max extends AbstractOperator_1.AbstractOperator {
|
|
1
|
+
import { AbstractFunction } from '../AbstractFunction.js';
|
|
2
|
+
export class Max extends AbstractFunction {
|
|
6
3
|
constructor() {
|
|
7
4
|
super(...arguments);
|
|
8
5
|
this.name = Max.NAME;
|
|
@@ -14,6 +11,5 @@ class Max extends AbstractOperator_1.AbstractOperator {
|
|
|
14
11
|
// }
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.Max = Max;
|
|
18
14
|
Max.NAME = 'max';
|
|
19
15
|
//# sourceMappingURL=Max.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Max.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Max.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Max.js","sourceRoot":"","sources":["../../../../src/operators/arithmetic/Max.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,MAAM,OAAO,GAAI,SAAQ,gBAAgB;IAAzC;;QAIE,SAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QAChB,EAAE;QACF,EAAE;QACF,gCAAgC;QAChC,4DAA4D;QAC5D,iBAAiB;QACjB,IAAI;IAEN,CAAC;CAAA;AAVQ,QAAI,GAAG,KAAK,AAAR,CAAS"}
|