@fincity/kirun-js 1.6.16 → 1.7.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/__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/BinarySearchTest.ts +5 -20
  4. package/__tests__/engine/function/system/array/{AddTest.ts → ConcatenateTest.ts} +22 -24
  5. package/__tests__/engine/function/system/array/CopyTest.ts +1 -1
  6. package/__tests__/engine/function/system/array/DeleteFirstTest.ts +7 -9
  7. package/__tests__/engine/function/system/array/DeleteFromTest.ts +4 -12
  8. package/__tests__/engine/function/system/array/DeleteLastTest.ts +7 -9
  9. package/__tests__/engine/function/system/array/DeleteTest.ts +7 -9
  10. package/__tests__/engine/function/system/array/DisjointTest.ts +3 -3
  11. package/__tests__/engine/function/system/array/FillTest.ts +6 -6
  12. package/__tests__/engine/function/system/array/FrequencyTest.ts +2 -2
  13. package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +6 -24
  14. package/__tests__/engine/function/system/array/IndexOfTest.ts +5 -17
  15. package/__tests__/engine/function/system/array/InsertTest.ts +5 -15
  16. package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +3 -3
  17. package/__tests__/engine/function/system/array/LastIndexOfTest.ts +4 -18
  18. package/__tests__/engine/function/system/array/MaxTest.ts +6 -8
  19. package/__tests__/engine/function/system/array/MinTest.ts +8 -8
  20. package/__tests__/engine/function/system/array/MisMatchTest.ts +3 -12
  21. package/__tests__/engine/function/system/array/ReverseTest.ts +4 -8
  22. package/__tests__/engine/function/system/array/RotateTest.ts +9 -9
  23. package/__tests__/engine/function/system/array/SortTest.ts +5 -5
  24. package/__tests__/engine/function/system/array/SubArrayTest.ts +4 -13
  25. package/__tests__/engine/function/system/loop/BreakLoopTest.ts +173 -0
  26. package/__tests__/engine/function/system/loop/RangeLoopTest.ts +145 -0
  27. package/__tests__/engine/function/system/string/SplitTest.ts +2 -2
  28. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +0 -1
  29. package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +47 -0
  30. package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +0 -1
  31. package/dist/index.js +1 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/module.js +1 -1
  34. package/dist/module.js.map +1 -1
  35. package/dist/types.d.ts +32 -30
  36. package/dist/types.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/engine/function/system/array/AddFirst.ts +8 -7
  39. package/src/engine/function/system/array/ArrayFunctionRepository.ts +6 -2
  40. package/src/engine/function/system/array/BinarySearch.ts +1 -1
  41. package/src/engine/function/system/array/{Add.ts → Concatenate.ts} +8 -6
  42. package/src/engine/function/system/array/Copy.ts +2 -2
  43. package/src/engine/function/system/array/Delete.ts +11 -7
  44. package/src/engine/function/system/array/DeleteFirst.ts +5 -2
  45. package/src/engine/function/system/array/DeleteFrom.ts +5 -2
  46. package/src/engine/function/system/array/DeleteLast.ts +5 -2
  47. package/src/engine/function/system/array/Disjoint.ts +1 -5
  48. package/src/engine/function/system/array/Fill.ts +6 -2
  49. package/src/engine/function/system/array/Frequency.ts +2 -5
  50. package/src/engine/function/system/array/IndexOf.ts +2 -2
  51. package/src/engine/function/system/array/IndexOfArray.ts +2 -2
  52. package/src/engine/function/system/array/Insert.ts +9 -3
  53. package/src/engine/function/system/array/InsertLast.ts +31 -0
  54. package/src/engine/function/system/array/LastIndexOf.ts +2 -7
  55. package/src/engine/function/system/array/LastIndexOfArray.ts +2 -6
  56. package/src/engine/function/system/array/Max.ts +1 -3
  57. package/src/engine/function/system/array/Min.ts +1 -3
  58. package/src/engine/function/system/array/MisMatch.ts +1 -1
  59. package/src/engine/function/system/array/Reverse.ts +6 -2
  60. package/src/engine/function/system/array/Rotate.ts +10 -3
  61. package/src/engine/function/system/array/Shuffle.ts +9 -3
  62. package/src/engine/function/system/array/Sort.ts +4 -3
  63. package/src/engine/function/system/array/SubArray.ts +1 -1
  64. package/src/engine/function/system/loop/Break.ts +31 -0
  65. package/src/engine/function/system/loop/CountLoop.ts +8 -2
  66. package/src/engine/function/system/loop/ForEachLoop.ts +70 -0
  67. package/src/engine/function/system/loop/RangeLoop.ts +7 -1
  68. package/src/engine/json/schema/validator/SchemaValidator.ts +3 -2
  69. package/src/engine/repository/KIRunFunctionRepository.ts +5 -1
  70. package/src/engine/runtime/FunctionExecutionParameters.ts +10 -1
  71. package/src/engine/runtime/KIRuntime.ts +2 -1
@@ -58,9 +58,7 @@ test('Insert of Test 1', async () => {
58
58
  res.push('Driven');
59
59
  res.push('developement');
60
60
 
61
- await ins.execute(fep);
62
-
63
- expect(array).toStrictEqual(res);
61
+ expect((await ins.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
64
62
  });
65
63
 
66
64
  test('Insert of Test 2', async () => {
@@ -102,9 +100,7 @@ test('Insert of Test 2', async () => {
102
100
  res.push(6);
103
101
  res.push(7);
104
102
  res.push(8);
105
- await ins.execute(fep);
106
-
107
- expect(arr).toStrictEqual(res);
103
+ expect((await ins.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
108
104
  });
109
105
 
110
106
  test('Insert of Test 3', async () => {
@@ -146,9 +142,7 @@ test('Insert of Test 3', async () => {
146
142
  res.push(6);
147
143
  res.push(7);
148
144
  res.push(8);
149
- await ins.execute(fep);
150
-
151
- expect(arr).toStrictEqual(res);
145
+ expect((await ins.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
152
146
  });
153
147
 
154
148
  test('Insert of Test 4', async () => {
@@ -191,9 +185,7 @@ test('Insert of Test 4', async () => {
191
185
  res.push(8);
192
186
  res.push(['this is an array']);
193
187
 
194
- await ins.execute(fep);
195
-
196
- expect(arr).toStrictEqual(res);
188
+ expect((await ins.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
197
189
  });
198
190
 
199
191
  test('Insert of Test 5', async () => {
@@ -218,9 +210,7 @@ test('Insert of Test 5', async () => {
218
210
 
219
211
  res.push(['this is an array']);
220
212
 
221
- await ins.execute(fep);
222
-
223
- expect(arr).toStrictEqual(res);
213
+ expect((await ins.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
224
214
  });
225
215
 
226
216
  test('Insert of Test 6', async () => {
@@ -39,7 +39,7 @@ test('Last Index of array Test 1', async () => {
39
39
  (await larr.execute(fep))
40
40
  .allResults()[0]
41
41
  .getResult()
42
- .get(LastIndexOfArray.EVENT_RESULT_INTEGER.getName()),
42
+ .get(LastIndexOfArray.EVENT_RESULT_NAME),
43
43
  ).toBe(9);
44
44
  });
45
45
 
@@ -76,7 +76,7 @@ test('last index of array test 2', async () => {
76
76
  (await larr.execute(fep))
77
77
  .allResults()[0]
78
78
  .getResult()
79
- .get(LastIndexOfArray.EVENT_RESULT_INTEGER.getName()),
79
+ .get(LastIndexOfArray.EVENT_RESULT_NAME),
80
80
  ).toBe(-1);
81
81
  });
82
82
 
@@ -221,6 +221,6 @@ test('last index of array test 4', async () => {
221
221
  (await larr.execute(fep))
222
222
  .allResults()[0]
223
223
  .getResult()
224
- .get(LastIndexOfArray.EVENT_RESULT_INTEGER.getName()),
224
+ .get(LastIndexOfArray.EVENT_RESULT_NAME),
225
225
  ).toBe(7);
226
226
  });
@@ -37,10 +37,7 @@ test('Last Index of Test 1', async () => {
37
37
  ]),
38
38
  );
39
39
  expect(
40
- (await lind.execute(fep))
41
- .allResults()[0]
42
- .getResult()
43
- .get(LastIndexOf.EVENT_RESULT_INTEGER.getName()),
40
+ (await lind.execute(fep)).allResults()[0].getResult().get(LastIndexOf.EVENT_RESULT_NAME),
44
41
  ).toBe(13);
45
42
  });
46
43
 
@@ -153,10 +150,7 @@ test('Last Index of Test 4', async () => {
153
150
  ]),
154
151
  );
155
152
  expect(
156
- (await lind.execute(fep))
157
- .allResults()[0]
158
- .getResult()
159
- .get(LastIndexOf.EVENT_RESULT_INTEGER.getName()),
153
+ (await lind.execute(fep)).allResults()[0].getResult().get(LastIndexOf.EVENT_RESULT_NAME),
160
154
  ).toBe(15);
161
155
 
162
156
  fep.setArguments(
@@ -167,10 +161,7 @@ test('Last Index of Test 4', async () => {
167
161
  ]),
168
162
  );
169
163
  expect(
170
- (await lind.execute(fep))
171
- .allResults()[0]
172
- .getResult()
173
- .get(LastIndexOf.EVENT_RESULT_INTEGER.getName()),
164
+ (await lind.execute(fep)).allResults()[0].getResult().get(LastIndexOf.EVENT_RESULT_NAME),
174
165
  ).toBe(-1);
175
166
  });
176
167
 
@@ -263,10 +254,5 @@ test('Last Index of Test 6', async () => {
263
254
  [LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 1],
264
255
  ]),
265
256
  );
266
- expect(
267
- (await lind.execute(fep))
268
- .allResults()[0]
269
- .getResult()
270
- .get(LastIndexOf.EVENT_RESULT_EMPTY.getName()),
271
- ).toBe(4);
257
+ expect((await lind.execute(fep)).allResults()[0].getResult().get('result')).toBe(4);
272
258
  });
@@ -14,9 +14,7 @@ test('max test 1 ', async () => {
14
14
  new KIRunSchemaRepository(),
15
15
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr]]));
16
16
 
17
- expect(
18
- (await max.execute(fep)).allResults()[0].getResult().get(Max.EVENT_RESULT_ANY.getName()),
19
- ).toBe(12);
17
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe(12);
20
18
  });
21
19
 
22
20
  test('max test 2 ', async () => {
@@ -42,7 +40,7 @@ test('max test 3', async () => {
42
40
  new KIRunFunctionRepository(),
43
41
  new KIRunSchemaRepository(),
44
42
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr]]));
45
- expect((await max.execute(fep)).allResults()[0].getResult().get('output')).toBe(98);
43
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe(98);
46
44
  });
47
45
 
48
46
  test('Max test 4', async () => {
@@ -54,7 +52,7 @@ test('Max test 4', async () => {
54
52
  new KIRunFunctionRepository(),
55
53
  new KIRunSchemaRepository(),
56
54
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr]]));
57
- expect((await max.execute(fep)).allResults()[0].getResult().get('output')).toBe('platform');
55
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe('platform');
58
56
  });
59
57
 
60
58
  test('Max test 6', async () => {
@@ -79,7 +77,7 @@ test('Max test 5', async () => {
79
77
  new KIRunFunctionRepository(),
80
78
  new KIRunSchemaRepository(),
81
79
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr]]));
82
- expect((await max.execute(fep)).allResults()[0].getResult().get('output')).toBe('platform');
80
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe('platform');
83
81
  });
84
82
 
85
83
  test('Max test 7', async () => {
@@ -93,7 +91,7 @@ test('Max test 7', async () => {
93
91
  new KIRunSchemaRepository(),
94
92
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr1]]));
95
93
 
96
- expect((await max.execute(fep)).allResults()[0].getResult().get('output')).toBe('s');
94
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe('s');
97
95
  });
98
96
 
99
97
  test('Max test 8', async () => {
@@ -103,5 +101,5 @@ test('Max test 8', async () => {
103
101
  new KIRunSchemaRepository(),
104
102
  ).setArguments(new Map([[Max.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr]]));
105
103
 
106
- expect((await max.execute(fep)).allResults()[0].getResult().get('output')).toBe('surendhar');
104
+ expect((await max.execute(fep)).allResults()[0].getResult().get('result')).toBe('surendhar');
107
105
  });
@@ -14,9 +14,9 @@ test('min test 1 ', async () => {
14
14
  new KIRunSchemaRepository(),
15
15
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr]]));
16
16
 
17
- expect(
18
- (await min.execute(fep)).allResults()[0].getResult().get(Min.EVENT_RESULT_ANY.getName()),
19
- ).toBe(12);
17
+ expect((await min.execute(fep)).allResults()[0].getResult().get(Min.EVENT_RESULT_NAME)).toBe(
18
+ 12,
19
+ );
20
20
  });
21
21
 
22
22
  test('min test 2 ', async () => {
@@ -42,7 +42,7 @@ test('min test 3', async () => {
42
42
  new KIRunFunctionRepository(),
43
43
  new KIRunSchemaRepository(),
44
44
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr]]));
45
- expect((await min.execute(fep)).allResults()[0].getResult().get('output')).toBe(1);
45
+ expect((await min.execute(fep)).allResults()[0].getResult().get('result')).toBe(1);
46
46
  });
47
47
 
48
48
  test('min test 4', async () => {
@@ -55,7 +55,7 @@ test('min test 4', async () => {
55
55
  new KIRunFunctionRepository(),
56
56
  new KIRunSchemaRepository(),
57
57
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr]]));
58
- expect((await min.execute(fep)).allResults()[0].getResult().get('output')).toBe('NoCode');
58
+ expect((await min.execute(fep)).allResults()[0].getResult().get('result')).toBe('NoCode');
59
59
  });
60
60
 
61
61
  test('min test 5', async () => {
@@ -81,7 +81,7 @@ test('min test 6', async () => {
81
81
  new KIRunFunctionRepository(),
82
82
  new KIRunSchemaRepository(),
83
83
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr]]));
84
- expect((await min.execute(fep)).allResults()[0].getResult().get('output')).toBe(1);
84
+ expect((await min.execute(fep)).allResults()[0].getResult().get('result')).toBe(1);
85
85
  });
86
86
 
87
87
  test('min test 7', async () => {
@@ -95,7 +95,7 @@ test('min test 7', async () => {
95
95
  new KIRunSchemaRepository(),
96
96
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr1]]));
97
97
 
98
- expect((await min.execute(fep)).allResults()[0].getResult().get('output')).toBe('c');
98
+ expect((await min.execute(fep)).allResults()[0].getResult().get('result')).toBe('c');
99
99
  });
100
100
 
101
101
  test('min test 8', async () => {
@@ -104,5 +104,5 @@ test('min test 8', async () => {
104
104
  new KIRunFunctionRepository(),
105
105
  new KIRunSchemaRepository(),
106
106
  ).setArguments(new Map([[Min.PARAMETER_ARRAY_SOURCE.getParameterName(), arr]]));
107
- expect((await min.execute(fep)).allResults()[0].getResult().get('output')).toBe('surendhar');
107
+ expect((await min.execute(fep)).allResults()[0].getResult().get('result')).toBe('surendhar');
108
108
  });
@@ -37,10 +37,7 @@ test('mismatch test 1', async () => {
37
37
  );
38
38
 
39
39
  expect(
40
- (await mismatch.execute(fep))
41
- .allResults()[0]
42
- .getResult()
43
- .get(MisMatch.EVENT_RESULT_INTEGER.getName()),
40
+ (await mismatch.execute(fep)).allResults()[0].getResult().get(MisMatch.EVENT_RESULT_NAME),
44
41
  ).toBe(2);
45
42
  });
46
43
 
@@ -177,10 +174,7 @@ test('Mismatch test 3', async () => {
177
174
  );
178
175
 
179
176
  expect(
180
- (await mismatch.execute(fep))
181
- .allResults()[0]
182
- .getResult()
183
- .get(MisMatch.EVENT_RESULT_INTEGER.getName()),
177
+ (await mismatch.execute(fep)).allResults()[0].getResult().get(MisMatch.EVENT_RESULT_NAME),
184
178
  ).toBe(2);
185
179
  });
186
180
 
@@ -217,9 +211,6 @@ test('mismatch test 4', async () => {
217
211
  );
218
212
 
219
213
  expect(
220
- (await mismatch.execute(fep))
221
- .allResults()[0]
222
- .getResult()
223
- .get(MisMatch.EVENT_RESULT_INTEGER.getName()),
214
+ (await mismatch.execute(fep)).allResults()[0].getResult().get(MisMatch.EVENT_RESULT_NAME),
224
215
  ).toBe(-1);
225
216
  });
@@ -22,8 +22,7 @@ test('Reverse test 1 ', async () => {
22
22
  .setSteps(new Map([]));
23
23
 
24
24
  let res = [5, 4, 6, 7];
25
- await rev.execute(fep);
26
- expect(src).toStrictEqual(res);
25
+ expect((await rev.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
27
26
  });
28
27
 
29
28
  test('Reverse test 2 ', async () => {
@@ -177,8 +176,7 @@ test('Rev test 4', async () => {
177
176
  res.push(array3);
178
177
  res.push(array1);
179
178
 
180
- await rev.execute(fep);
181
-
179
+ arr = (await rev.execute(fep)).allResults()[0].getResult().get('result');
182
180
  expect(arr).toStrictEqual(res);
183
181
 
184
182
  fep.setArguments(
@@ -196,8 +194,7 @@ test('Rev test 4', async () => {
196
194
  res1.push(array2);
197
195
  res1.push(array4);
198
196
 
199
- await rev.execute(fep);
200
- expect(arr).toStrictEqual(res1);
197
+ expect((await rev.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res1);
201
198
  });
202
199
 
203
200
  test('rev test 5', async () => {
@@ -236,8 +233,7 @@ test('rev test 5', async () => {
236
233
  res.push('c');
237
234
  res.push('a');
238
235
 
239
- await rev.execute(fep);
240
- expect(arr).toStrictEqual(res);
236
+ expect((await rev.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
241
237
 
242
238
  fep.setArguments(
243
239
  new Map<string, any>([
@@ -47,9 +47,9 @@ test('Rotate test1 ', async () => {
47
47
  res.push('using');
48
48
  res.push('eclipse');
49
49
 
50
- await rotate.execute(fep);
51
-
52
- expect(array).toStrictEqual(res);
50
+ expect((await rotate.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(
51
+ res,
52
+ );
53
53
  });
54
54
 
55
55
  test('rotate test 2', async () => {
@@ -96,9 +96,9 @@ test('rotate test 2', async () => {
96
96
  res.push('test');
97
97
  res.push('Driven');
98
98
 
99
- await rotate.execute(fep);
100
-
101
- expect(src).toStrictEqual(res);
99
+ expect((await rotate.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(
100
+ res,
101
+ );
102
102
  });
103
103
 
104
104
  test('rotate test 3', async () => {
@@ -141,7 +141,7 @@ test('rotate test 3', async () => {
141
141
 
142
142
  res.push('I');
143
143
 
144
- await rotate.execute(fep);
145
-
146
- expect(array).toStrictEqual(res);
144
+ expect((await rotate.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(
145
+ res,
146
+ );
147
147
  });
@@ -29,7 +29,7 @@ test('sort test 1', async () => {
29
29
  res.push(15);
30
30
  res.push(98);
31
31
 
32
- expect((await sort.execute(fep)).allResults()[0].getResult().get('output')).toStrictEqual(res);
32
+ expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
33
33
  });
34
34
 
35
35
  test('sort test 2', async () => {
@@ -57,7 +57,7 @@ test('sort test 2', async () => {
57
57
  res.push(15);
58
58
  res.push(98);
59
59
 
60
- expect((await sort.execute(fep)).allResults()[0].getResult().get('output')).toStrictEqual(res);
60
+ expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
61
61
  });
62
62
 
63
63
  test('sort test 3', async () => {
@@ -88,7 +88,7 @@ test('sort test 3', async () => {
88
88
  ]),
89
89
  );
90
90
 
91
- expect((await sort.execute(fep)).allResults()[0].getResult().get('output')).toStrictEqual(res);
91
+ expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
92
92
  });
93
93
 
94
94
  test('sort test 4', async () => {
@@ -125,7 +125,7 @@ test('sort test 4', async () => {
125
125
  ]),
126
126
  );
127
127
 
128
- expect((await sort.execute(fep)).allResults()[0].getResult().get('output')).toStrictEqual(res);
128
+ expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
129
129
  });
130
130
 
131
131
  test('sort test 5', async () => {
@@ -142,5 +142,5 @@ test('sort test 5', async () => {
142
142
  ]),
143
143
  );
144
144
  let res: any[] = ['Banana', 'Apple', 'Mango', 'Orange'];
145
- expect((await sort.execute(fep)).allResults()[0].getResult().get('output')).toStrictEqual(res);
145
+ expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res);
146
146
  });
@@ -48,10 +48,7 @@ test('SubArray of Test 1', async () => {
48
48
  );
49
49
 
50
50
  expect(
51
- (await sub.execute(fep))
52
- .allResults()[0]
53
- .getResult()
54
- .get(SubArray.EVENT_RESULT_ARRAY.getName()),
51
+ (await sub.execute(fep)).allResults()[0].getResult().get(SubArray.EVENT_RESULT_NAME),
55
52
  ).toStrictEqual(res);
56
53
  });
57
54
 
@@ -112,10 +109,7 @@ test('SubArray of Test 5', async () => {
112
109
  );
113
110
 
114
111
  expect(
115
- (await sub.execute(fep))
116
- .allResults()[0]
117
- .getResult()
118
- .get(SubArray.EVENT_RESULT_ARRAY.getName()),
112
+ (await sub.execute(fep)).allResults()[0].getResult().get(SubArray.EVENT_RESULT_NAME),
119
113
  ).toStrictEqual(res);
120
114
  });
121
115
 
@@ -253,9 +247,6 @@ test('SubArray of Test 4', async () => {
253
247
  ]),
254
248
  );
255
249
  expect(
256
- (await sub.execute(fep))
257
- .allResults()[0]
258
- .getResult()
259
- .get(SubArray.EVENT_RESULT_ARRAY.getName()),
260
- ).toStrictEqual(res);
250
+ (await sub.execute(fep)).allResults()[0].getResult().get(SubArray.EVENT_RESULT_NAME),
251
+ ).toMatchObject(res);
261
252
  });
@@ -0,0 +1,173 @@
1
+ import {
2
+ FunctionDefinition,
3
+ FunctionExecutionParameters,
4
+ KIRunFunctionRepository,
5
+ KIRunSchemaRepository,
6
+ KIRuntime,
7
+ } from '../../../../../src';
8
+
9
+ test('Range Loop Break Test', async () => {
10
+ const breakDefinition = {
11
+ name: 'Break Me 1',
12
+ events: {
13
+ output: {
14
+ name: 'output',
15
+ parameters: {
16
+ returnValue: {
17
+ schema: { type: 'ARRAY', items: { type: 'INTEGER' } },
18
+ },
19
+ },
20
+ },
21
+ },
22
+ steps: {
23
+ create: {
24
+ name: 'Create',
25
+ namespace: 'System.Context',
26
+ statementName: 'create',
27
+ parameterMap: {
28
+ name: { one: { key: 'one', type: 'VALUE', value: 'array' } },
29
+ schema: {
30
+ one: {
31
+ key: 'one',
32
+ type: 'VALUE',
33
+ value: { type: 'ARRAY', items: { type: 'INTEGER' } },
34
+ },
35
+ },
36
+ },
37
+ },
38
+ createSet: {
39
+ name: 'Set',
40
+ namespace: 'System.Context',
41
+ statementName: 'createSet',
42
+ parameterMap: {
43
+ name: { one: { key: 'one', type: 'VALUE', value: 'Context.array' } },
44
+ value: { one: { key: 'one', type: 'VALUE', value: [] } },
45
+ },
46
+ dependentStatements: {
47
+ 'Steps.create.output': true,
48
+ },
49
+ },
50
+ loop: {
51
+ name: 'RangeLoop',
52
+ namespace: 'System.Loop',
53
+ statementName: 'loop',
54
+ parameterMap: {
55
+ from: {
56
+ one: { key: 'one', type: 'VALUE', value: 5 },
57
+ },
58
+ to: { one: { key: 'one', type: 'VALUE', value: 10 } },
59
+ step: { one: { key: 'one', type: 'VALUE', value: 1 } },
60
+ },
61
+ dependentStatements: {
62
+ 'Steps.createSet.output': true,
63
+ },
64
+ },
65
+ insert: {
66
+ name: 'InsertLast',
67
+ namespace: 'System.Array',
68
+ statementName: 'insert',
69
+ parameterMap: {
70
+ source: {
71
+ one: { key: 'one', type: 'EXPRESSION', expression: 'Context.array' },
72
+ },
73
+ element: {
74
+ one: {
75
+ key: 'one',
76
+ type: 'EXPRESSION',
77
+ expression: 'Steps.loop.iteration.index',
78
+ },
79
+ },
80
+ },
81
+ dependentStatements: {
82
+ 'Steps.if.false': true,
83
+ },
84
+ },
85
+ set: {
86
+ name: 'Set',
87
+ namespace: 'System.Context',
88
+ statementName: 'set',
89
+ parameterMap: {
90
+ name: { one: { key: 'one', type: 'VALUE', value: 'Context.array' } },
91
+ value: {
92
+ one: {
93
+ key: 'one',
94
+ type: 'EXPRESSION',
95
+ expression: 'Steps.insert.output.result',
96
+ },
97
+ },
98
+ },
99
+ },
100
+ if: {
101
+ name: 'If',
102
+ namespace: 'System',
103
+ statementName: 'if',
104
+ parameterMap: {
105
+ condition: {
106
+ one: {
107
+ key: 'one',
108
+ type: 'EXPRESSION',
109
+ expression: 'Steps.loop.iteration.index = 7',
110
+ },
111
+ },
112
+ },
113
+ },
114
+ break: {
115
+ name: 'Break',
116
+ namespace: 'System.Loop',
117
+ statementName: 'break',
118
+ parameterMap: {
119
+ stepName: { one: { key: 'one', type: 'VALUE', value: 'loop' } },
120
+ },
121
+ dependentStatements: {
122
+ 'Steps.if.true': true,
123
+ },
124
+ },
125
+ generateEvent: {
126
+ statementName: 'generateEvent',
127
+ name: 'GenerateEvent',
128
+ namespace: 'System',
129
+ parameterMap: {
130
+ eventName: {
131
+ '5OdGxruBiEyysESbAubdX2': {
132
+ key: '5OdGxruBiEyysESbAubdX2',
133
+ type: 'VALUE',
134
+ expression: '',
135
+ value: 'output',
136
+ },
137
+ },
138
+ results: {
139
+ '4o0c0kvVtWiGjgb37hMTBX': {
140
+ key: '4o0c0kvVtWiGjgb37hMTBX',
141
+ type: 'VALUE',
142
+ order: 1,
143
+ value: {
144
+ name: 'returnValue',
145
+ value: {
146
+ isExpression: true,
147
+ value: 'Context.array',
148
+ },
149
+ },
150
+ },
151
+ },
152
+ },
153
+ dependentStatements: {
154
+ 'Steps.loop.output': true,
155
+ },
156
+ },
157
+ },
158
+ };
159
+
160
+ const fd = FunctionDefinition.from(breakDefinition);
161
+ const result = (
162
+ await new KIRuntime(fd, true).execute(
163
+ new FunctionExecutionParameters(
164
+ new KIRunFunctionRepository(),
165
+ new KIRunSchemaRepository(),
166
+ ),
167
+ )
168
+ )
169
+ .next()
170
+ ?.getResult()
171
+ .get('returnValue');
172
+ expect(result).toMatchObject([5, 6]);
173
+ });