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.
Files changed (71) hide show
  1. package/Evaluator/ExpresionLogicService.ts +669 -0
  2. package/Evaluator/Parser/AddLeadZerosParse.ts +70 -0
  3. package/Evaluator/Parser/AppearParse.ts +67 -0
  4. package/Evaluator/Parser/BaseParse.ts +93 -0
  5. package/Evaluator/Parser/CalcDateParse.ts +73 -0
  6. package/Evaluator/Parser/CheckParse.ts +99 -0
  7. package/Evaluator/Parser/CommaParser.ts +17 -0
  8. package/Evaluator/Parser/ConcatParse.ts +34 -0
  9. package/Evaluator/Parser/CountParse.ts +26 -0
  10. package/Evaluator/Parser/EmptyParse.ts +41 -0
  11. package/Evaluator/Parser/ExistParse.ts +69 -0
  12. package/Evaluator/Parser/IfParse.ts +388 -0
  13. package/Evaluator/Parser/IfStategment.ts +345 -0
  14. package/Evaluator/Parser/InDetailParse.ts +109 -0
  15. package/Evaluator/Parser/InListParse.ts +57 -0
  16. package/Evaluator/Parser/LiteralValueParse.ts +36 -0
  17. package/Evaluator/Parser/LogicalOperatorParse.ts +16 -0
  18. package/Evaluator/Parser/OnlyExpressionParse.ts +137 -0
  19. package/Evaluator/Parser/OperatorParse.ts +17 -0
  20. package/Evaluator/Parser/StartsParse.ts +36 -0
  21. package/Evaluator/Parser/SubstrParse.ts +110 -0
  22. package/Evaluator/Parser/SumParse.ts +15 -0
  23. package/Evaluator/Parser/ToNullParser.ts +0 -0
  24. package/Evaluator/Parser/TrimParse.ts +30 -0
  25. package/Evaluator/Parser/UpperLoverParse.ts +41 -0
  26. package/Evaluator/Parser/ValueFromObjParse.ts +37 -0
  27. package/Evaluator/Parser/ValueParse.ts +61 -0
  28. package/HelperSessionStorage.ts +13 -0
  29. package/Interfaces/SchemaStruct.ts +28 -0
  30. package/Library/jsonrpc-2.0.js +869 -0
  31. package/Structure/InvoiceObj.ts +691 -0
  32. package/Structure/RecordArray.ts +145 -0
  33. package/Structure/RecordSingle.ts +1076 -0
  34. package/Structure/TableLevel.ts +248 -0
  35. package/dist/Evaluator/ExpresionLogicService.js +505 -0
  36. package/dist/Evaluator/Parser/AddLeadZerosParse.js +55 -0
  37. package/dist/Evaluator/Parser/AppearParse.js +48 -0
  38. package/dist/Evaluator/Parser/BaseParse.js +89 -0
  39. package/dist/Evaluator/Parser/CalcDateParse.js +54 -0
  40. package/dist/Evaluator/Parser/CheckParse.js +80 -0
  41. package/dist/Evaluator/Parser/CommaParser.js +13 -0
  42. package/dist/Evaluator/Parser/ConcatParse.js +29 -0
  43. package/dist/Evaluator/Parser/CountParse.js +23 -0
  44. package/dist/Evaluator/Parser/EmptyParse.js +35 -0
  45. package/dist/Evaluator/Parser/ExistParse.js +57 -0
  46. package/dist/Evaluator/Parser/IfParse.js +296 -0
  47. package/dist/Evaluator/Parser/IfStategment.js +287 -0
  48. package/dist/Evaluator/Parser/InDetailParse.js +79 -0
  49. package/dist/Evaluator/Parser/InListParse.js +40 -0
  50. package/dist/Evaluator/Parser/LiteralValueParse.js +26 -0
  51. package/dist/Evaluator/Parser/LogicalOperatorParse.js +13 -0
  52. package/dist/Evaluator/Parser/OnlyExpressionParse.js +106 -0
  53. package/dist/Evaluator/Parser/OperatorParse.js +13 -0
  54. package/dist/Evaluator/Parser/StartsParse.js +30 -0
  55. package/dist/Evaluator/Parser/SubstrParse.js +83 -0
  56. package/dist/Evaluator/Parser/SumParse.js +13 -0
  57. package/dist/Evaluator/Parser/ToNullParser.js +1 -0
  58. package/dist/Evaluator/Parser/TrimParse.js +25 -0
  59. package/dist/Evaluator/Parser/UpperLoverParse.js +32 -0
  60. package/dist/Evaluator/Parser/ValueFromObjParse.js +29 -0
  61. package/dist/Evaluator/Parser/ValueParse.js +59 -0
  62. package/dist/HelperSessionStorage.js +12 -0
  63. package/dist/Interfaces/SchemaStruct.js +2 -0
  64. package/dist/Structure/InvoiceObj.js +610 -0
  65. package/dist/Structure/RecordArray.js +102 -0
  66. package/dist/Structure/RecordSingle.js +950 -0
  67. package/dist/Structure/TableLevel.js +162 -0
  68. package/dist/index.js +19 -0
  69. package/index.ts +20 -0
  70. package/package.json +20 -0
  71. package/tsconfig.json +103 -0
@@ -0,0 +1,248 @@
1
+
2
+
3
+ import { InvoiceObj } from "./InvoiceObj";
4
+ import { RecordArray } from "./RecordArray";
5
+ import { RecordSingle } from "./RecordSingle";
6
+
7
+ export class TableLevel {
8
+ public Root:InvoiceObj|null;
9
+ public Tablename:string;
10
+ public DefaultRecord:any;
11
+ public ObjectInfo:any;
12
+ public Record:RecordSingle|null=null;
13
+ public Records:RecordArray|null=null;
14
+
15
+ public validateDetailsErrors = <any> [];
16
+
17
+ public constructor(
18
+ table:string,
19
+ obj:any,
20
+ def:any,
21
+ objectInfo:any,
22
+ root:InvoiceObj|null,
23
+
24
+ )
25
+ {
26
+ this.Tablename=table;
27
+ this.Root=root;
28
+ this.ObjectInfo=objectInfo;
29
+
30
+
31
+
32
+
33
+ if(Array.isArray(obj))
34
+ {
35
+ if(def!=null)
36
+ {
37
+ this.DefaultRecord=def[0];
38
+ }
39
+
40
+ this.Records=new RecordArray(obj,this.DefaultRecord,objectInfo,this);
41
+
42
+ }
43
+ else
44
+ {
45
+ this.Record=new RecordSingle(obj,def,objectInfo,this);
46
+ this.DefaultRecord=def;
47
+ }
48
+ }
49
+ public GetObject():object
50
+ {
51
+ let obj=JSON.parse("{}");
52
+ if(this.Record!=null)
53
+ {
54
+ obj[this.Tablename]=this.Record.GetObject();
55
+ }
56
+ else if(this.Records!=null)
57
+ {
58
+ obj[this.Tablename]=this.Records.GetObject();
59
+ }
60
+ return obj;
61
+ }
62
+ TranslateObj(obj:any){
63
+ if(this.Record!=null)
64
+ {
65
+ this.Record?.TranslateObj(obj);
66
+ }
67
+ else if(this.Records!=null)
68
+ {
69
+ this.Records?.TranslateObj(obj);
70
+ }
71
+ }
72
+ public Inicialize(skippedLevels:string[])
73
+ {
74
+ if(this.Record!=null)
75
+ {
76
+ this.Record?.Inicialize(skippedLevels);
77
+ }
78
+ else if(this.Records!=null)
79
+ {
80
+ this.Records?.Inicialize(skippedLevels);
81
+ }
82
+ }
83
+ public getSaveObject(objectInfoUIEdit:any){
84
+
85
+ if(objectInfoUIEdit[this.Tablename]==null)
86
+ {
87
+ return null;
88
+ }
89
+ let result:any=null;
90
+ if(this.Record!=null)
91
+ {
92
+
93
+ let obj=this.Record.getSaveObject(objectInfoUIEdit);
94
+ if(obj==null)
95
+ {
96
+ return null;
97
+ }
98
+ result=obj;
99
+
100
+ }
101
+ if(this.Records!=null)
102
+ {
103
+ let obj=this.Records.getSaveObject(objectInfoUIEdit);
104
+ if(obj==null)
105
+ {
106
+ return null;
107
+ }
108
+
109
+ result=obj;
110
+ }
111
+ return result;
112
+ }
113
+ public getFullObject(objectInfo:any){
114
+
115
+ if(objectInfo[this.Tablename]==null)
116
+ {
117
+ return null;
118
+ }
119
+ let result:any=null;
120
+ if(this.Record!=null)
121
+ {
122
+
123
+ let obj=this.Record.getFullObject(objectInfo);
124
+ if(obj==null)
125
+ {
126
+ return null;
127
+ }
128
+ result=obj;
129
+
130
+ }
131
+ if(this.Records!=null)
132
+ {
133
+ let obj=this.Records.getFullObject(objectInfo);
134
+ if(obj==null)
135
+ {
136
+ return null;
137
+ }
138
+
139
+ result=obj;
140
+ }
141
+ return result;
142
+ }
143
+ public Validate()
144
+ {
145
+ this.validateDetailsErrors = [];
146
+ let validateErrors:any = [];
147
+
148
+ let errorMessage="";
149
+ let detailErrors="";
150
+
151
+ if(this.Record!=null)
152
+ {
153
+ let val:any=this.Record.Validate();
154
+ if(val==null)
155
+ {
156
+ return null;
157
+ }
158
+
159
+ if(val["missingKeys"]!=null)
160
+ {
161
+ errorMessage="Missing mandatory keys:"+val["missingKeys"];
162
+ validateErrors.push(val["missingKeys"]);
163
+
164
+
165
+ }
166
+
167
+ // dodal maxx
168
+ if(val["validateDetailsErrors"]!=null) {
169
+ this.validateDetailsErrors.push(...val["validateDetailsErrors"]);
170
+
171
+ }
172
+
173
+ if(val["details"] != null && val["details"].length > 0)
174
+ {
175
+
176
+ detailErrors = val["details"];
177
+ }
178
+
179
+ if(detailErrors!="")
180
+ {
181
+ if(errorMessage==null)
182
+ {
183
+ errorMessage=detailErrors;
184
+ }
185
+ else
186
+ {
187
+ errorMessage+= "\n "+detailErrors
188
+ }
189
+ }
190
+
191
+ }
192
+
193
+ if(this.Records!=null)
194
+ {
195
+ let val:any = this.Records.Validate();
196
+ let valErrorMessage:string|null = null;
197
+ let valValidateDetailsErrors:string|null = null;
198
+
199
+ if(val != null) {
200
+ valErrorMessage = val['errorMessage'];
201
+ valValidateDetailsErrors = val['validateDetailsErrors'];
202
+ }
203
+
204
+
205
+
206
+ if(valErrorMessage==null)
207
+ {
208
+ return null;
209
+ } else {
210
+ errorMessage = valErrorMessage.toString();
211
+ }
212
+
213
+ if(valValidateDetailsErrors==null)
214
+ {
215
+ return null;
216
+ } else {
217
+
218
+ if(valValidateDetailsErrors.length > 0) {
219
+ validateErrors.push(val["validateDetailsErrors"]);
220
+
221
+ }
222
+ }
223
+
224
+
225
+
226
+ }
227
+
228
+ // return "Missing data on level "+this.Tablename+": "+errorMessage;
229
+ let combError = "Missing data on level "+this.Tablename+": " + errorMessage;
230
+ // let validateDeatilsError:any[] = [];
231
+
232
+
233
+ // if(validateErrors.length > 0) {
234
+ // validateDeatilsError.push(validateErrors[0]);
235
+ // }
236
+ // console.log('validateErrors' + validateErrors);
237
+ // console.log('this.validateDetailsErrors: ' + JSON.stringify(this.validateDetailsErrors));
238
+
239
+ // if(this.validateDetailsErrors != '') {
240
+ // validateDeatilsError = this.validateDetailsErrors;
241
+ // }
242
+
243
+
244
+ return { "combineErrors": combError =='' ? null : combError, "validateErrors": validateErrors, "validateDeatailErrors": this.validateDetailsErrors.length > 0 ? this.validateDetailsErrors : [] };
245
+
246
+
247
+ }
248
+ }