@fincity/kirun-js 1.6.17 → 1.8.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 (84) hide show
  1. package/__tests__/engine/function/system/array/AddFirstTest.ts +28 -19
  2. package/__tests__/engine/function/system/array/ArrayToArrayOfObjectsTest.ts +0 -2
  3. package/__tests__/engine/function/system/array/ArrayToObjectTest.ts +180 -0
  4. package/__tests__/engine/function/system/array/BinarySearchTest.ts +5 -20
  5. package/__tests__/engine/function/system/array/{AddTest.ts → ConcatenateTest.ts} +22 -24
  6. package/__tests__/engine/function/system/array/CopyTest.ts +1 -1
  7. package/__tests__/engine/function/system/array/DeleteFirstTest.ts +7 -9
  8. package/__tests__/engine/function/system/array/DeleteFromTest.ts +4 -12
  9. package/__tests__/engine/function/system/array/DeleteLastTest.ts +7 -9
  10. package/__tests__/engine/function/system/array/DeleteTest.ts +7 -9
  11. package/__tests__/engine/function/system/array/DisjointTest.ts +3 -3
  12. package/__tests__/engine/function/system/array/FillTest.ts +6 -6
  13. package/__tests__/engine/function/system/array/FrequencyTest.ts +2 -2
  14. package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +6 -24
  15. package/__tests__/engine/function/system/array/IndexOfTest.ts +5 -17
  16. package/__tests__/engine/function/system/array/InsertTest.ts +5 -15
  17. package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +3 -3
  18. package/__tests__/engine/function/system/array/LastIndexOfTest.ts +4 -18
  19. package/__tests__/engine/function/system/array/MaxTest.ts +6 -8
  20. package/__tests__/engine/function/system/array/MinTest.ts +8 -8
  21. package/__tests__/engine/function/system/array/MisMatchTest.ts +3 -12
  22. package/__tests__/engine/function/system/array/RemoveDuplicatesTest.ts +74 -0
  23. package/__tests__/engine/function/system/array/ReverseTest.ts +4 -8
  24. package/__tests__/engine/function/system/array/RotateTest.ts +9 -9
  25. package/__tests__/engine/function/system/array/SortTest.ts +5 -5
  26. package/__tests__/engine/function/system/array/SubArrayTest.ts +4 -13
  27. package/__tests__/engine/function/system/loop/BreakLoopTest.ts +173 -0
  28. package/__tests__/engine/function/system/loop/CountLoopTest.ts +1 -1
  29. package/__tests__/engine/function/system/loop/RangeLoopTest.ts +145 -0
  30. package/__tests__/engine/function/system/string/SplitTest.ts +2 -2
  31. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +0 -1
  32. package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +47 -0
  33. package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +0 -1
  34. package/__tests__/engine/runtime/expression/tokenextractor/ObjectValueSetterExtractorTest.ts +51 -0
  35. package/dist/index.js +1 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/module.js +1 -1
  38. package/dist/module.js.map +1 -1
  39. package/dist/types.d.ts +41 -30
  40. package/dist/types.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/engine/function/system/array/AbstractArrayFunction.ts +5 -0
  43. package/src/engine/function/system/array/AddFirst.ts +8 -7
  44. package/src/engine/function/system/array/ArrayFunctionRepository.ts +8 -2
  45. package/src/engine/function/system/array/ArrayToObject.ts +77 -0
  46. package/src/engine/function/system/array/BinarySearch.ts +1 -1
  47. package/src/engine/function/system/array/{Add.ts → Concatenate.ts} +8 -6
  48. package/src/engine/function/system/array/Copy.ts +2 -2
  49. package/src/engine/function/system/array/Delete.ts +11 -7
  50. package/src/engine/function/system/array/DeleteFirst.ts +5 -2
  51. package/src/engine/function/system/array/DeleteFrom.ts +5 -2
  52. package/src/engine/function/system/array/DeleteLast.ts +5 -2
  53. package/src/engine/function/system/array/Disjoint.ts +1 -5
  54. package/src/engine/function/system/array/Fill.ts +6 -2
  55. package/src/engine/function/system/array/Frequency.ts +2 -5
  56. package/src/engine/function/system/array/IndexOf.ts +2 -2
  57. package/src/engine/function/system/array/IndexOfArray.ts +2 -2
  58. package/src/engine/function/system/array/Insert.ts +9 -3
  59. package/src/engine/function/system/array/InsertLast.ts +31 -0
  60. package/src/engine/function/system/array/LastIndexOf.ts +2 -7
  61. package/src/engine/function/system/array/LastIndexOfArray.ts +2 -6
  62. package/src/engine/function/system/array/Max.ts +1 -3
  63. package/src/engine/function/system/array/Min.ts +1 -3
  64. package/src/engine/function/system/array/MisMatch.ts +1 -1
  65. package/src/engine/function/system/array/RemoveDuplicates.ts +64 -0
  66. package/src/engine/function/system/array/Reverse.ts +6 -2
  67. package/src/engine/function/system/array/Rotate.ts +10 -3
  68. package/src/engine/function/system/array/Shuffle.ts +9 -3
  69. package/src/engine/function/system/array/Sort.ts +4 -3
  70. package/src/engine/function/system/array/SubArray.ts +1 -1
  71. package/src/engine/function/system/loop/Break.ts +31 -0
  72. package/src/engine/function/system/loop/CountLoop.ts +8 -2
  73. package/src/engine/function/system/loop/ForEachLoop.ts +70 -0
  74. package/src/engine/function/system/loop/RangeLoop.ts +7 -1
  75. package/src/engine/function/system/object/ObjectFunctionRepository.ts +2 -0
  76. package/src/engine/function/system/object/ObjectPutValue.ts +61 -0
  77. package/src/engine/json/schema/validator/SchemaValidator.ts +3 -2
  78. package/src/engine/repository/KIRunFunctionRepository.ts +5 -1
  79. package/src/engine/runtime/FunctionExecutionParameters.ts +10 -1
  80. package/src/engine/runtime/KIRuntime.ts +2 -1
  81. package/src/engine/runtime/expression/operators/binary/ArithmeticAdditionOperator.ts +3 -2
  82. package/src/engine/runtime/expression/tokenextractor/ObjectValueSetterExtractor.ts +172 -0
  83. package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +1 -1
  84. package/src/index.ts +1 -0
@@ -0,0 +1,70 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { SchemaType } from '../../../json/schema/type/SchemaType';
3
+ import { Event } from '../../../model/Event';
4
+ import { EventResult } from '../../../model/EventResult';
5
+ import { FunctionOutput } from '../../../model/FunctionOutput';
6
+ import { FunctionSignature } from '../../../model/FunctionSignature';
7
+ import { Parameter } from '../../../model/Parameter';
8
+ import { Namespaces } from '../../../namespaces/Namespaces';
9
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
10
+ import { AbstractFunction } from '../../AbstractFunction';
11
+
12
+ const SOURCE = 'source';
13
+ const EACH = 'each';
14
+ const INDEX = 'index';
15
+ const VALUE = 'value';
16
+
17
+ const SIGNATURE = new FunctionSignature('ForEachLoop')
18
+ .setNamespace(Namespaces.SYSTEM_LOOP)
19
+ .setParameters(
20
+ new Map([Parameter.ofEntry(SOURCE, Schema.ofArray(SOURCE, Schema.ofAny(SOURCE)))]),
21
+ )
22
+ .setEvents(
23
+ new Map([
24
+ Event.eventMapEntry(
25
+ Event.ITERATION,
26
+ new Map([
27
+ [INDEX, Schema.of(INDEX, SchemaType.INTEGER)],
28
+ [EACH, Schema.ofAny(EACH)],
29
+ ]),
30
+ ),
31
+ Event.outputEventMapEntry(new Map([[VALUE, Schema.of(VALUE, SchemaType.INTEGER)]])),
32
+ ]),
33
+ );
34
+
35
+ export class ForEachLoop extends AbstractFunction {
36
+ public getSignature(): FunctionSignature {
37
+ return SIGNATURE;
38
+ }
39
+
40
+ protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
41
+ let source: any[] = context.getArguments()?.get(SOURCE);
42
+
43
+ let current = 0;
44
+
45
+ let statementName = context.getStatementExecution()?.getStatement()?.getStatementName();
46
+
47
+ return new FunctionOutput({
48
+ next(): EventResult {
49
+ if (
50
+ current >= source.length ||
51
+ (statementName && context.getExecutionContext()?.get(statementName)) //check for breaks;
52
+ ) {
53
+ if (statementName) context.getExecutionContext()?.delete(statementName);
54
+ return EventResult.outputOf(new Map([[VALUE, current]]));
55
+ }
56
+
57
+ const eve = EventResult.of(
58
+ Event.ITERATION,
59
+ new Map([
60
+ [INDEX, current],
61
+ [EACH, source[current]],
62
+ ]),
63
+ );
64
+ ++current;
65
+
66
+ return eve;
67
+ },
68
+ });
69
+ }
70
+ }
@@ -100,13 +100,19 @@ export class RangeLoop extends AbstractFunction {
100
100
  const forward = step > 0;
101
101
  let current: number = from;
102
102
  let done: boolean = false;
103
+ let statementName = context.getStatementExecution()?.getStatement()?.getStatementName();
103
104
 
104
105
  return new FunctionOutput({
105
106
  next(): EventResult | undefined {
106
107
  if (done) return undefined;
107
108
 
108
- if ((forward && current >= to) || (!forward && current <= to)) {
109
+ if (
110
+ (forward && current >= to) ||
111
+ (!forward && current <= to) ||
112
+ (statementName && context.getExecutionContext()?.get(statementName)) //Check for break;
113
+ ) {
109
114
  done = true;
115
+ if (statementName) context.getExecutionContext()?.delete(statementName);
110
116
  return EventResult.outputOf(new Map([[VALUE, current]]));
111
117
  }
112
118
 
@@ -6,6 +6,7 @@ import { Function } from '../../Function';
6
6
  import { ObjectDeleteKey } from './ObjectDeleteKey';
7
7
  import { ObjectEntries } from './ObjectEntries';
8
8
  import { ObjectKeys } from './ObjectKeys';
9
+ import { ObjectPutValue } from './ObjectPutValue';
9
10
  import { ObjectValues } from './ObjectValues';
10
11
 
11
12
  const functionObjectsIndex: { [key: string]: AbstractFunction } = {
@@ -13,6 +14,7 @@ const functionObjectsIndex: { [key: string]: AbstractFunction } = {
13
14
  ObjectKeys: new ObjectKeys(),
14
15
  ObjectEntries: new ObjectEntries(),
15
16
  ObjectDeleteKey: new ObjectDeleteKey(),
17
+ ObjectPutValue: new ObjectPutValue(),
16
18
  };
17
19
 
18
20
  const filterableNames = Object.values(functionObjectsIndex).map((e) =>
@@ -0,0 +1,61 @@
1
+ import { FunctionOutput } from '../../../model/FunctionOutput';
2
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
3
+
4
+ import { Schema } from '../../../json/schema/Schema';
5
+ import { Event } from '../../../model/Event';
6
+ import { EventResult } from '../../../model/EventResult';
7
+ import { FunctionSignature } from '../../../model/FunctionSignature';
8
+ import { Parameter } from '../../../model/Parameter';
9
+ import { Namespaces } from '../../../namespaces/Namespaces';
10
+ import { duplicate } from '../../../util/duplicate';
11
+ import { AbstractFunction } from '../../AbstractFunction';
12
+ import { isNullValue } from '../../../util/NullCheck';
13
+ import { ObjectValueSetterExtractor } from '../../../runtime/expression/tokenextractor/ObjectValueSetterExtractor';
14
+
15
+ const VALUE = 'value';
16
+ const SOURCE = 'source';
17
+ const KEY = 'key';
18
+ const OVERWRITE = 'overwrite';
19
+ const DELETE_KEY_ON_NULL = 'deleteKeyOnNull';
20
+
21
+ export class ObjectPutValue extends AbstractFunction {
22
+ private signature: FunctionSignature;
23
+
24
+ public constructor() {
25
+ super();
26
+ this.signature = new FunctionSignature('ObjectPutValue')
27
+ .setNamespace(Namespaces.SYSTEM_OBJECT)
28
+ .setParameters(
29
+ new Map([
30
+ Parameter.ofEntry(SOURCE, Schema.ofObject(SOURCE)),
31
+ Parameter.ofEntry(KEY, Schema.ofString(KEY)),
32
+ Parameter.ofEntry(VALUE, Schema.ofAny(VALUE)),
33
+ Parameter.ofEntry(OVERWRITE, Schema.ofBoolean(OVERWRITE).setDefaultValue(true)),
34
+ Parameter.ofEntry(
35
+ DELETE_KEY_ON_NULL,
36
+ Schema.ofBoolean(DELETE_KEY_ON_NULL).setDefaultValue(false),
37
+ ),
38
+ ]),
39
+ )
40
+ .setEvents(
41
+ new Map([Event.outputEventMapEntry(new Map([[VALUE, Schema.ofObject(VALUE)]]))]),
42
+ );
43
+ }
44
+
45
+ public getSignature(): FunctionSignature {
46
+ return this.signature;
47
+ }
48
+
49
+ protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
50
+ let source = context.getArguments()?.get(SOURCE);
51
+ let key = context.getArguments()?.get(KEY);
52
+ let value = context.getArguments()?.get(VALUE);
53
+ let overwrite = context.getArguments()?.get(OVERWRITE);
54
+ let deleteKeyOnNull = context.getArguments()?.get(DELETE_KEY_ON_NULL);
55
+
56
+ const ove = new ObjectValueSetterExtractor(source, 'Data.');
57
+ ove.setValue(key, value, overwrite, deleteKeyOnNull);
58
+
59
+ return new FunctionOutput([EventResult.outputOf(new Map([[VALUE, ove.getStore()]]))]);
60
+ }
61
+ }
@@ -1,4 +1,5 @@
1
1
  import { Repository } from '../../../Repository';
2
+ import { deepEqual } from '../../../util/deepEqual';
2
3
  import { isNullValue } from '../../../util/NullCheck';
3
4
  import { StringUtil } from '../../../util/string/StringUtil';
4
5
  import { Schema } from '../Schema';
@@ -40,7 +41,7 @@ export class SchemaValidator {
40
41
  return JSON.parse(JSON.stringify(schema.getDefaultValue()));
41
42
  }
42
43
 
43
- if (schema.getConstant()) {
44
+ if (!isNullValue(schema.getConstant())) {
44
45
  return SchemaValidator.constantValidation(parents, schema, element);
45
46
  }
46
47
 
@@ -92,7 +93,7 @@ export class SchemaValidator {
92
93
  }
93
94
 
94
95
  public static constantValidation(parents: Schema[], schema: Schema, element: any): any {
95
- if (!schema.getConstant().equals(element)) {
96
+ if (!deepEqual(schema.getConstant(), element)) {
96
97
  throw new SchemaValidationException(
97
98
  SchemaValidator.path(parents),
98
99
  'Expecting a constant value : ' + element,
@@ -5,6 +5,7 @@ import { Get } from '../function/system/context/Get';
5
5
  import { SetFunction } from '../function/system/context/SetFunction';
6
6
  import { GenerateEvent } from '../function/system/GenerateEvent';
7
7
  import { If } from '../function/system/If';
8
+ import { Break } from '../function/system/loop/Break';
8
9
  import { CountLoop } from '../function/system/loop/CountLoop';
9
10
  import { RangeLoop } from '../function/system/loop/RangeLoop';
10
11
  import { MathFunctionRepository } from '../function/system/math/MathFunctionRepository';
@@ -20,7 +21,10 @@ const map: Map<string, Map<string, Function>> = new Map([
20
21
  Namespaces.SYSTEM_CTX,
21
22
  new Map([mapEntry(new Create()), mapEntry(new Get()), mapEntry(new SetFunction())]),
22
23
  ],
23
- [Namespaces.SYSTEM_LOOP, new Map([mapEntry(new RangeLoop()), mapEntry(new CountLoop())])],
24
+ [
25
+ Namespaces.SYSTEM_LOOP,
26
+ new Map([mapEntry(new RangeLoop()), mapEntry(new CountLoop()), mapEntry(new Break())]),
27
+ ],
24
28
  [
25
29
  Namespaces.SYSTEM,
26
30
  new Map([mapEntry(new If()), mapEntry(new GenerateEvent()), mapEntry(new Print())]),
@@ -5,7 +5,6 @@ import UUID from '../util/UUID';
5
5
  import { ContextElement } from './ContextElement';
6
6
  import { TokenValueExtractor } from './expression/tokenextractor/TokenValueExtractor';
7
7
  import { StatementExecution } from './StatementExecution';
8
- import { ArgumentsTokenValueExtractor } from './tokenextractor/ArgumentsTokenValueExtractor';
9
8
  import { ContextTokenValueExtractor } from './tokenextractor/ContextTokenValueExtractor';
10
9
  import { OutputMapTokenValueExtractor } from './tokenextractor/OutputMapTokenValueExtractor';
11
10
 
@@ -19,6 +18,7 @@ export class FunctionExecutionParameters {
19
18
  private functionRepository: Repository<Function>;
20
19
  private schemaRepository: Repository<Schema>;
21
20
  private executionId: string;
21
+ private executionContext: Map<string, any> = new Map();
22
22
 
23
23
  private valueExtractors: Map<string, TokenValueExtractor> = new Map();
24
24
 
@@ -121,4 +121,13 @@ export class FunctionExecutionParameters {
121
121
 
122
122
  return this;
123
123
  }
124
+
125
+ public setExecutionContext(executionContext: Map<string, any>): FunctionExecutionParameters {
126
+ this.executionContext = executionContext;
127
+ return this;
128
+ }
129
+
130
+ public getExecutionContext(): Map<string, any> {
131
+ return this.executionContext;
132
+ }
124
133
  }
@@ -359,7 +359,8 @@ export class KIRuntime extends AbstractFunction {
359
359
  .setEvents(inContext.getEvents()!)
360
360
  .setSteps(inContext.getSteps()!)
361
361
  .setStatementExecution(vertex.getData())
362
- .setCount(inContext.getCount());
362
+ .setCount(inContext.getCount())
363
+ .setExecutionContext(inContext.getExecutionContext());
363
364
  }
364
365
 
365
366
  let result: FunctionOutput = await fun.execute(fep);
@@ -1,9 +1,10 @@
1
- import { Operation } from '../../Operation';
1
+ import { isNullValue } from '../../../../util/NullCheck';
2
2
  import { BinaryOperator } from './BinaryOperator';
3
3
 
4
4
  export class ArithmeticAdditionOperator extends BinaryOperator {
5
5
  public apply(t: any, u: any): any {
6
- this.nullCheck(t, u, Operation.ADDITION);
6
+ if (isNullValue(t)) return u;
7
+ else if (isNullValue(u)) return t;
7
8
  return t + u;
8
9
  }
9
10
  }
@@ -0,0 +1,172 @@
1
+ import { KIRuntimeException } from '../../../exception/KIRuntimeException';
2
+ import { isNullValue } from '../../../util/NullCheck';
3
+ import { duplicate } from '../../../util/duplicate';
4
+ import { StringFormatter } from '../../../util/string/StringFormatter';
5
+ import { StringUtil } from '../../../util/string/StringUtil';
6
+ import { Expression } from '../Expression';
7
+ import { ExpressionTokenValue } from '../ExpressionTokenValue';
8
+ import { Operation } from '../Operation';
9
+ import { ExpressionEvaluationException } from '../exception/ExpressionEvaluationException';
10
+ import { TokenValueExtractor } from './TokenValueExtractor';
11
+
12
+ export class ObjectValueSetterExtractor extends TokenValueExtractor {
13
+ private store: any;
14
+ private prefix: string;
15
+ constructor(store: any, prefix: string) {
16
+ super();
17
+ this.store = store;
18
+ this.prefix = prefix;
19
+ }
20
+ protected getValueInternal(token: string) {
21
+ let parts: string[] = token.split(TokenValueExtractor.REGEX_DOT);
22
+ return this.retrieveElementFrom(token, parts, 1, this.store);
23
+ }
24
+
25
+ public getStore(): any {
26
+ return this.store;
27
+ }
28
+ public setStore(store: any): ObjectValueSetterExtractor {
29
+ this.store = store;
30
+ return this;
31
+ }
32
+
33
+ public setValue(
34
+ token: string,
35
+ value: any,
36
+ overwrite: boolean = true,
37
+ deleteOnNull: boolean = false,
38
+ ) {
39
+ this.store = duplicate(this.store);
40
+ this.modifyStore(token, value, overwrite, deleteOnNull);
41
+ }
42
+
43
+ private modifyStore(
44
+ stringToken: string,
45
+ value: any,
46
+ overwrite: boolean,
47
+ deleteOnNull: boolean,
48
+ ) {
49
+ const exp = new Expression(stringToken);
50
+ const tokens = exp.getTokens();
51
+ tokens.removeLast();
52
+ const ops = exp.getOperations();
53
+
54
+ let op = ops.removeLast();
55
+ let token = tokens.removeLast();
56
+ let mem =
57
+ token instanceof ExpressionTokenValue
58
+ ? (token as ExpressionTokenValue).getElement()
59
+ : token.getExpression();
60
+
61
+ let el = this.store;
62
+
63
+ while (!ops.isEmpty()) {
64
+ if (op == Operation.OBJECT_OPERATOR) {
65
+ el = this.getDataFromObject(el, mem, ops.peekLast());
66
+ } else {
67
+ el = this.getDataFromArray(el, mem, ops.peekLast());
68
+ }
69
+
70
+ op = ops.removeLast();
71
+ token = tokens.removeLast();
72
+ mem =
73
+ token instanceof ExpressionTokenValue
74
+ ? (token as ExpressionTokenValue).getElement()
75
+ : token.getExpression();
76
+ }
77
+
78
+ if (op == Operation.OBJECT_OPERATOR)
79
+ this.putDataInObject(el, mem, value, overwrite, deleteOnNull);
80
+ else this.putDataInArray(el, mem, value, overwrite, deleteOnNull);
81
+ }
82
+
83
+ private getDataFromArray(el: any, mem: string, nextOp: Operation): any {
84
+ if (!Array.isArray(el))
85
+ throw new KIRuntimeException(
86
+ StringFormatter.format('Expected an array but found $', el),
87
+ );
88
+
89
+ const index = parseInt(mem);
90
+ if (isNaN(index))
91
+ throw new KIRuntimeException(
92
+ StringFormatter.format('Expected an array index but found $', mem),
93
+ );
94
+ if (index < 0)
95
+ throw new KIRuntimeException(
96
+ StringFormatter.format('Array index is out of bound - $', mem),
97
+ );
98
+
99
+ let je = el[index];
100
+
101
+ if (isNullValue(je)) {
102
+ je = nextOp == Operation.OBJECT_OPERATOR ? {} : [];
103
+ el[index] = je;
104
+ }
105
+ return je;
106
+ }
107
+
108
+ private getDataFromObject(el: any, mem: string, nextOp: Operation): any {
109
+ if (Array.isArray(el) || typeof el !== 'object')
110
+ throw new KIRuntimeException(
111
+ StringFormatter.format('Expected an object but found $', el),
112
+ );
113
+
114
+ let je = el[mem];
115
+
116
+ if (isNullValue(je)) {
117
+ je = nextOp == Operation.OBJECT_OPERATOR ? {} : [];
118
+ el[mem] = je;
119
+ }
120
+ return je;
121
+ }
122
+
123
+ private putDataInArray(
124
+ el: any,
125
+ mem: string,
126
+ value: any,
127
+ overwrite: boolean,
128
+ deleteOnNull: boolean,
129
+ ): void {
130
+ if (!Array.isArray(el))
131
+ throw new KIRuntimeException(
132
+ StringFormatter.format('Expected an array but found $', el),
133
+ );
134
+
135
+ const index = parseInt(mem);
136
+ if (isNaN(index))
137
+ throw new KIRuntimeException(
138
+ StringFormatter.format('Expected an array index but found $', mem),
139
+ );
140
+ if (index < 0)
141
+ throw new KIRuntimeException(
142
+ StringFormatter.format('Array index is out of bound - $', mem),
143
+ );
144
+
145
+ if (overwrite || isNullValue(el[index])) {
146
+ if (deleteOnNull && isNullValue(value)) el.splice(index, 1);
147
+ else el[index] = value;
148
+ }
149
+ }
150
+
151
+ private putDataInObject(
152
+ el: any,
153
+ mem: string,
154
+ value: any,
155
+ overwrite: boolean,
156
+ deleteOnNull: boolean,
157
+ ): void {
158
+ if (Array.isArray(el) || typeof el !== 'object')
159
+ throw new KIRuntimeException(
160
+ StringFormatter.format('Expected an object but found $', el),
161
+ );
162
+
163
+ if (overwrite || isNullValue(el[mem])) {
164
+ if (deleteOnNull && isNullValue(value)) delete el[mem];
165
+ else el[mem] = value;
166
+ }
167
+ }
168
+
169
+ getPrefix(): string {
170
+ return this.prefix;
171
+ }
172
+ }
@@ -115,7 +115,7 @@ export abstract class TokenValueExtractor {
115
115
  }
116
116
  }
117
117
 
118
- private checkIfObject(
118
+ protected checkIfObject(
119
119
  token: string,
120
120
  parts: string[],
121
121
  partNumber: number,
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export * from './engine/runtime/FunctionExecutionParameters';
27
27
  export * from './engine/runtime/expression/Expression';
28
28
  export * from './engine/runtime/expression/tokenextractor/TokenValueExtractor';
29
29
  export * from './engine/runtime/expression/tokenextractor/LiteralTokenValueExtractor';
30
+ export * from './engine/runtime/expression/tokenextractor/ObjectValueSetterExtractor';
30
31
  export * from './engine/runtime/expression/ExpressionEvaluator';
31
32
  export * from './engine/runtime/expression/Operation';
32
33
  export * from './engine/runtime/expression/ExpressionToken';