js-gei 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Evaluator/ExpresionLogicService.ts +669 -0
- package/Evaluator/Parser/AddLeadZerosParse.ts +70 -0
- package/Evaluator/Parser/AppearParse.ts +67 -0
- package/Evaluator/Parser/BaseParse.ts +93 -0
- package/Evaluator/Parser/CalcDateParse.ts +73 -0
- package/Evaluator/Parser/CheckParse.ts +99 -0
- package/Evaluator/Parser/CommaParser.ts +17 -0
- package/Evaluator/Parser/ConcatParse.ts +34 -0
- package/Evaluator/Parser/CountParse.ts +26 -0
- package/Evaluator/Parser/EmptyParse.ts +41 -0
- package/Evaluator/Parser/ExistParse.ts +69 -0
- package/Evaluator/Parser/IfParse.ts +388 -0
- package/Evaluator/Parser/IfStategment.ts +345 -0
- package/Evaluator/Parser/InDetailParse.ts +109 -0
- package/Evaluator/Parser/InListParse.ts +57 -0
- package/Evaluator/Parser/LiteralValueParse.ts +36 -0
- package/Evaluator/Parser/LogicalOperatorParse.ts +16 -0
- package/Evaluator/Parser/OnlyExpressionParse.ts +137 -0
- package/Evaluator/Parser/OperatorParse.ts +17 -0
- package/Evaluator/Parser/StartsParse.ts +36 -0
- package/Evaluator/Parser/SubstrParse.ts +110 -0
- package/Evaluator/Parser/SumParse.ts +15 -0
- package/Evaluator/Parser/ToNullParser.ts +0 -0
- package/Evaluator/Parser/TrimParse.ts +30 -0
- package/Evaluator/Parser/UpperLoverParse.ts +41 -0
- package/Evaluator/Parser/ValueFromObjParse.ts +37 -0
- package/Evaluator/Parser/ValueParse.ts +61 -0
- package/HelperSessionStorage.ts +13 -0
- package/Interfaces/SchemaStruct.ts +28 -0
- package/Library/jsonrpc-2.0.js +869 -0
- package/Structure/InvoiceObj.ts +691 -0
- package/Structure/RecordArray.ts +145 -0
- package/Structure/RecordSingle.ts +1076 -0
- package/Structure/TableLevel.ts +248 -0
- package/dist/Evaluator/ExpresionLogicService.js +505 -0
- package/dist/Evaluator/Parser/AddLeadZerosParse.js +55 -0
- package/dist/Evaluator/Parser/AppearParse.js +48 -0
- package/dist/Evaluator/Parser/BaseParse.js +89 -0
- package/dist/Evaluator/Parser/CalcDateParse.js +54 -0
- package/dist/Evaluator/Parser/CheckParse.js +80 -0
- package/dist/Evaluator/Parser/CommaParser.js +13 -0
- package/dist/Evaluator/Parser/ConcatParse.js +29 -0
- package/dist/Evaluator/Parser/CountParse.js +23 -0
- package/dist/Evaluator/Parser/EmptyParse.js +35 -0
- package/dist/Evaluator/Parser/ExistParse.js +57 -0
- package/dist/Evaluator/Parser/IfParse.js +296 -0
- package/dist/Evaluator/Parser/IfStategment.js +287 -0
- package/dist/Evaluator/Parser/InDetailParse.js +79 -0
- package/dist/Evaluator/Parser/InListParse.js +40 -0
- package/dist/Evaluator/Parser/LiteralValueParse.js +26 -0
- package/dist/Evaluator/Parser/LogicalOperatorParse.js +13 -0
- package/dist/Evaluator/Parser/OnlyExpressionParse.js +106 -0
- package/dist/Evaluator/Parser/OperatorParse.js +13 -0
- package/dist/Evaluator/Parser/StartsParse.js +30 -0
- package/dist/Evaluator/Parser/SubstrParse.js +83 -0
- package/dist/Evaluator/Parser/SumParse.js +13 -0
- package/dist/Evaluator/Parser/ToNullParser.js +1 -0
- package/dist/Evaluator/Parser/TrimParse.js +25 -0
- package/dist/Evaluator/Parser/UpperLoverParse.js +32 -0
- package/dist/Evaluator/Parser/ValueFromObjParse.js +29 -0
- package/dist/Evaluator/Parser/ValueParse.js +59 -0
- package/dist/HelperSessionStorage.js +12 -0
- package/dist/Interfaces/SchemaStruct.js +2 -0
- package/dist/Structure/InvoiceObj.js +610 -0
- package/dist/Structure/RecordArray.js +102 -0
- package/dist/Structure/RecordSingle.js +950 -0
- package/dist/Structure/TableLevel.js +162 -0
- package/dist/index.js +19 -0
- package/index.ts +20 -0
- package/package.json +20 -0
- package/tsconfig.json +103 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
3
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
4
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
5
|
+
import { BaseParse } from "./BaseParse";
|
|
6
|
+
|
|
7
|
+
export class OperatorParser extends BaseParse {
|
|
8
|
+
|
|
9
|
+
public constructor( valueExpression:string)
|
|
10
|
+
{
|
|
11
|
+
super(valueExpression,null);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
15
|
+
return this.Expression;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
import { OnlyExpressionParse } from "./OnlyExpressionParse";
|
|
6
|
+
|
|
7
|
+
export class StartsParse extends BaseParse {
|
|
8
|
+
|
|
9
|
+
public starts:OnlyExpressionParse|null=null;
|
|
10
|
+
public value:OnlyExpressionParse|null=null;
|
|
11
|
+
public constructor( valueExpression:string,funname:string)
|
|
12
|
+
{
|
|
13
|
+
super(valueExpression,funname);
|
|
14
|
+
var split = this.Expression.split(",");
|
|
15
|
+
if (split.length == 2)
|
|
16
|
+
{
|
|
17
|
+
this.starts = new OnlyExpressionParse(split[0]);
|
|
18
|
+
this.value = new OnlyExpressionParse(split[1]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
23
|
+
var startsEvaluate = this.starts?.Evaluate(obj,critm,record, item);
|
|
24
|
+
var valueEvaluate = this.value?.Evaluate(obj, critm, record, item);
|
|
25
|
+
|
|
26
|
+
if(startsEvaluate==null|| valueEvaluate==null)
|
|
27
|
+
{
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
var evaluated:string = startsEvaluate.ToString();
|
|
31
|
+
var evaluatedValue:string = valueEvaluate.ToString();
|
|
32
|
+
|
|
33
|
+
var result = evaluatedValue.startsWith(evaluated);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
import { CommaParser } from "./CommaParser";
|
|
6
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
7
|
+
|
|
8
|
+
export class SubstrParse extends BaseParse {
|
|
9
|
+
|
|
10
|
+
public starts:BaseParse[]=[];
|
|
11
|
+
public value:BaseParse[]=[];
|
|
12
|
+
public length:BaseParse[]=[];
|
|
13
|
+
public constructor( valueExpression:string,funname:string)
|
|
14
|
+
{
|
|
15
|
+
super(valueExpression,funname);
|
|
16
|
+
var dd = ExpresionLogicService.GetExpressions(this.Expression, this);
|
|
17
|
+
var current:BaseParse[] =[];
|
|
18
|
+
if(dd==null)
|
|
19
|
+
{
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for(let i=0;i<dd.length;i++)
|
|
23
|
+
{
|
|
24
|
+
current=this.logic(current, dd[i]);
|
|
25
|
+
}
|
|
26
|
+
this.logic(current, null);
|
|
27
|
+
|
|
28
|
+
if (this.value.length==0 || this.starts.length==0 || this.length.length==0)
|
|
29
|
+
{
|
|
30
|
+
throw "Can't parse if stategment "+valueExpression+"!";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
35
|
+
var valueEval = ExpresionLogicService.ConcatValues(this.value, obj, critm, record, item);
|
|
36
|
+
if(valueEval == null)
|
|
37
|
+
{
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
var val = valueEval.ToString();
|
|
41
|
+
let str = -1;
|
|
42
|
+
var startEval=ExpresionLogicService.ConcatValues(this.starts, obj, critm, record, item);
|
|
43
|
+
if(typeof startEval =="number")
|
|
44
|
+
{
|
|
45
|
+
str = startEval;
|
|
46
|
+
}
|
|
47
|
+
else if(typeof startEval =="string")
|
|
48
|
+
{
|
|
49
|
+
|
|
50
|
+
str = parseInt(startEval);
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
if(str==-1)
|
|
54
|
+
{
|
|
55
|
+
throw "Substr start index can't be parsed! Value: "+startEval+"!";
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
str--;
|
|
60
|
+
}
|
|
61
|
+
let len = -1;
|
|
62
|
+
var lengthEval = ExpresionLogicService.ConcatValues(this.length, obj, critm, record, item);
|
|
63
|
+
if (typeof lengthEval =="number")
|
|
64
|
+
{
|
|
65
|
+
len = lengthEval;
|
|
66
|
+
}
|
|
67
|
+
else if (lengthEval =="string")
|
|
68
|
+
{
|
|
69
|
+
len=parseInt(lengthEval);
|
|
70
|
+
}
|
|
71
|
+
if (len == -1)
|
|
72
|
+
{
|
|
73
|
+
throw "Substr length index can't be parsed! Value: "+lengthEval+"!";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (val.Length<=str)
|
|
77
|
+
{
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
var tem = val.substring(str);
|
|
81
|
+
if(tem.Length<=len)
|
|
82
|
+
{
|
|
83
|
+
return tem;
|
|
84
|
+
}
|
|
85
|
+
return tem.substring(0, len);
|
|
86
|
+
}
|
|
87
|
+
private logic(list:BaseParse[], c:BaseParse|null):BaseParse[]
|
|
88
|
+
{
|
|
89
|
+
if (c == null || c instanceof CommaParser)
|
|
90
|
+
{
|
|
91
|
+
if (this.value.length==0)
|
|
92
|
+
{
|
|
93
|
+
this.value = list;
|
|
94
|
+
}
|
|
95
|
+
else if (this.starts.length==0)
|
|
96
|
+
{
|
|
97
|
+
this.starts = list;
|
|
98
|
+
}
|
|
99
|
+
else if (this.length.length==0)
|
|
100
|
+
{
|
|
101
|
+
this.length = list;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return [];
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
list.push(c);
|
|
108
|
+
return list;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
|
|
6
|
+
export class SumParse extends BaseParse {
|
|
7
|
+
public constructor( valueExpression:string,funname:string)
|
|
8
|
+
{
|
|
9
|
+
super(valueExpression,funname);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
13
|
+
return obj.SumByKey(this.Expression);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
6
|
+
|
|
7
|
+
export class TrimParse extends BaseParse {
|
|
8
|
+
public constructor( valueExpression:string,funname:string)
|
|
9
|
+
{
|
|
10
|
+
super(valueExpression,funname);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
14
|
+
var express = ExpresionLogicService.GetExpressions(this.Expression,this);
|
|
15
|
+
if(express==null)
|
|
16
|
+
{
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (express.length == 1)
|
|
20
|
+
{
|
|
21
|
+
var value = express[0].Evaluate(obj, critm, record, item);
|
|
22
|
+
if (typeof value == "string")
|
|
23
|
+
{
|
|
24
|
+
return value.trim();
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
return express.length;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
6
|
+
|
|
7
|
+
export class UpperLowerParse extends BaseParse {
|
|
8
|
+
|
|
9
|
+
public lower:boolean=true;
|
|
10
|
+
public constructor( valueExpression:string,funname:string)
|
|
11
|
+
{
|
|
12
|
+
super(valueExpression,funname);
|
|
13
|
+
if(funname.toLowerCase()=="upper(")
|
|
14
|
+
{
|
|
15
|
+
this.lower=false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct):any {
|
|
20
|
+
var express = ExpresionLogicService.GetExpressions(this.Expression,this);
|
|
21
|
+
if(express==null)
|
|
22
|
+
{
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
var value=ExpresionLogicService.ConcatValues(express,obj,critm,record,item);
|
|
26
|
+
if(value==null)
|
|
27
|
+
{
|
|
28
|
+
return null;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
if(typeof value =="string")
|
|
32
|
+
{
|
|
33
|
+
if(this.lower)
|
|
34
|
+
{
|
|
35
|
+
return value.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
return value.toUpperCase();
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
import { ExpresionLogicService } from "../ExpresionLogicService";
|
|
6
|
+
|
|
7
|
+
export class ValueFromObjParse extends BaseParse {
|
|
8
|
+
|
|
9
|
+
private Numeric:boolean=false;
|
|
10
|
+
public constructor(valueExpression: string, numeric: boolean) {
|
|
11
|
+
super(valueExpression, null);
|
|
12
|
+
this.Numeric=numeric;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct): any {
|
|
17
|
+
var value =ExpresionLogicService.ValueExpresion(item, this.Expression, obj,critm);
|
|
18
|
+
if(value==null)
|
|
19
|
+
{
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if(this.Numeric)
|
|
23
|
+
{
|
|
24
|
+
|
|
25
|
+
if(typeof value == "string")
|
|
26
|
+
{
|
|
27
|
+
return parseFloat(value);
|
|
28
|
+
}
|
|
29
|
+
if(typeof value =="number")
|
|
30
|
+
{
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
throw "Value is "+typeof value+" isn't number type!";
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SchemaStruct } from "../../Interfaces/SchemaStruct";
|
|
2
|
+
import { InvoiceObj } from "../../Structure/InvoiceObj";
|
|
3
|
+
import { RecordSingle } from "../../Structure/RecordSingle";
|
|
4
|
+
import { BaseParse } from "./BaseParse";
|
|
5
|
+
|
|
6
|
+
export class ValueParse extends BaseParse {
|
|
7
|
+
|
|
8
|
+
private Table: string = "";
|
|
9
|
+
private FieldName: string = "";
|
|
10
|
+
private Position: string = "";
|
|
11
|
+
public constructor(valueExpression: string, numeric: boolean) {
|
|
12
|
+
super(valueExpression, null);
|
|
13
|
+
var outerSplit = this.Expression.split(",");
|
|
14
|
+
var position = "first";
|
|
15
|
+
if (outerSplit.length == 2) {
|
|
16
|
+
position = outerSplit[1];
|
|
17
|
+
}
|
|
18
|
+
var split = outerSplit[0].split(".");
|
|
19
|
+
this.Table = split[0];
|
|
20
|
+
this.FieldName = split[1];
|
|
21
|
+
this.Position = position;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public Evaluate(obj: InvoiceObj, critm: RecordSingle, record: any, item: SchemaStruct): any {
|
|
26
|
+
var tablelevel = obj.FindTableLevel(this.Table);
|
|
27
|
+
if (tablelevel == null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
let validRecord: any = null;
|
|
31
|
+
if (tablelevel.Record != null) {
|
|
32
|
+
validRecord = tablelevel.Record;
|
|
33
|
+
}
|
|
34
|
+
else if (tablelevel.Records != null) {
|
|
35
|
+
var rec = tablelevel.Records;
|
|
36
|
+
if (rec.Records.length == 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (this.Position.toLowerCase() == "first") {
|
|
40
|
+
validRecord = rec.Records[0].Record;
|
|
41
|
+
}
|
|
42
|
+
else if (this.Position.toLowerCase() == "first") {
|
|
43
|
+
validRecord = rec.Records[rec.Records.length - 1].Record;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (validRecord == null) {
|
|
47
|
+
throw "Can't find valid record for " + this.Table + "!";
|
|
48
|
+
}
|
|
49
|
+
if (validRecord[this.FieldName] == null) {
|
|
50
|
+
throw "Value not defined for fieldname " + this.FieldName + "!";
|
|
51
|
+
}
|
|
52
|
+
var value = validRecord[this.FieldName];
|
|
53
|
+
if (value == null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (typeof value == "number") {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
return value.ToString();;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class HelperSessionStorage{
|
|
2
|
+
static hasKey(key:string)
|
|
3
|
+
{
|
|
4
|
+
return this.getFromSessionStorage(key)!=null;
|
|
5
|
+
}
|
|
6
|
+
static getFromSessionStorage(key:string) {
|
|
7
|
+
return localStorage.getItem(key);
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
static setToSessionStorage(key:string,value:any) {
|
|
11
|
+
localStorage.setItem(key,JSON.stringify( value));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SchemaStruct {
|
|
2
|
+
TableName:string|null;
|
|
3
|
+
Version:string|null;
|
|
4
|
+
FieldName:string;
|
|
5
|
+
Type:string;
|
|
6
|
+
TypeDDD:string;
|
|
7
|
+
TypeNET:string;
|
|
8
|
+
CountryCode:string|null;
|
|
9
|
+
CreateNewInit:string|null;
|
|
10
|
+
|
|
11
|
+
SourceTableField:string|null;
|
|
12
|
+
Source:string|null;
|
|
13
|
+
|
|
14
|
+
GetValueFrom:string|null;
|
|
15
|
+
|
|
16
|
+
Pattern:string|null;
|
|
17
|
+
|
|
18
|
+
ValueExpression:string|null;
|
|
19
|
+
|
|
20
|
+
CalcPhase:number|null;
|
|
21
|
+
|
|
22
|
+
RoundTo:number|null;
|
|
23
|
+
|
|
24
|
+
EvalOnlyIfEmpty:boolean;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|