@fincity/kirun-js 1.6.12 → 1.6.14
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/__tests__/engine/function/system/array/ArrayToArrayOfObjectsTest.ts +128 -15
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +3 -19
- package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/system/array/ArrayToArrayOfObjects.ts +2 -6
- package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +1 -1
- package/src/engine/runtime/tokenextractor/OutputMapTokenValueExtractor.ts +10 -2
|
@@ -18,9 +18,9 @@ test('Array to Array of objects', async () => {
|
|
|
18
18
|
)
|
|
19
19
|
.allResults()[0]
|
|
20
20
|
.getResult()
|
|
21
|
-
.get('
|
|
21
|
+
.get('result');
|
|
22
22
|
|
|
23
|
-
expect(result).
|
|
23
|
+
expect(result).toStrictEqual([{ value: 1 }, { value: 2 }, { value: 3 }]);
|
|
24
24
|
|
|
25
25
|
result = (
|
|
26
26
|
await fun.execute(
|
|
@@ -37,9 +37,9 @@ test('Array to Array of objects', async () => {
|
|
|
37
37
|
)
|
|
38
38
|
.allResults()[0]
|
|
39
39
|
.getResult()
|
|
40
|
-
.get('
|
|
40
|
+
.get('result');
|
|
41
41
|
|
|
42
|
-
expect(result).
|
|
42
|
+
expect(result).toStrictEqual([{ number: 1 }, { number: 2 }, { number: 3 }]);
|
|
43
43
|
|
|
44
44
|
result = (
|
|
45
45
|
await fun.execute(
|
|
@@ -51,9 +51,9 @@ test('Array to Array of objects', async () => {
|
|
|
51
51
|
)
|
|
52
52
|
.allResults()[0]
|
|
53
53
|
.getResult()
|
|
54
|
-
.get('
|
|
54
|
+
.get('result');
|
|
55
55
|
|
|
56
|
-
expect(result).
|
|
56
|
+
expect(result).toStrictEqual([
|
|
57
57
|
{ value: { number: 1 } },
|
|
58
58
|
{ value: { number: 2 } },
|
|
59
59
|
{ value: { number: 3 } },
|
|
@@ -80,9 +80,9 @@ test('Array to Array of objects', async () => {
|
|
|
80
80
|
)
|
|
81
81
|
.allResults()[0]
|
|
82
82
|
.getResult()
|
|
83
|
-
.get('
|
|
83
|
+
.get('result');
|
|
84
84
|
|
|
85
|
-
expect(result).
|
|
85
|
+
expect(result).toStrictEqual([
|
|
86
86
|
{ value1: 'a', value2: 1 },
|
|
87
87
|
{ value1: 'b', value2: 2 },
|
|
88
88
|
{ value1: 'c', value2: '3' },
|
|
@@ -110,12 +110,12 @@ test('Array to Array of objects', async () => {
|
|
|
110
110
|
)
|
|
111
111
|
.allResults()[0]
|
|
112
112
|
.getResult()
|
|
113
|
-
.get('
|
|
113
|
+
.get('result');
|
|
114
114
|
|
|
115
|
-
expect(result).
|
|
116
|
-
{ key: 'a', value: 1 },
|
|
117
|
-
{ key: 'b', value: 2 },
|
|
118
|
-
{ key: 'c', value: '3' },
|
|
115
|
+
expect(result).toStrictEqual([
|
|
116
|
+
{ key: 'a', value: 1, other: undefined },
|
|
117
|
+
{ key: 'b', value: 2, other: undefined },
|
|
118
|
+
{ key: 'c', value: '3', other: undefined },
|
|
119
119
|
]);
|
|
120
120
|
|
|
121
121
|
result = (
|
|
@@ -140,7 +140,120 @@ test('Array to Array of objects', async () => {
|
|
|
140
140
|
)
|
|
141
141
|
.allResults()[0]
|
|
142
142
|
.getResult()
|
|
143
|
-
.get('
|
|
143
|
+
.get('result');
|
|
144
|
+
|
|
145
|
+
expect(result).toStrictEqual([{ maKey: 'a' }, { maKey: 'b' }, { maKey: 'c' }]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('Array with nested object and mixed', async () => {
|
|
149
|
+
let fun = new ArrayToArrayOfObjects();
|
|
150
|
+
|
|
151
|
+
let result = (
|
|
152
|
+
await fun.execute(
|
|
153
|
+
new FunctionExecutionParameters(
|
|
154
|
+
new KIRunFunctionRepository(),
|
|
155
|
+
new KIRunSchemaRepository(),
|
|
156
|
+
).setArguments(
|
|
157
|
+
new Map([
|
|
158
|
+
['source', [true, 1, 2, ['a', 'b', 'c']]],
|
|
159
|
+
['keyName', ['akey', 'bkey', 'ckey']],
|
|
160
|
+
]),
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
)
|
|
164
|
+
.allResults()[0]
|
|
165
|
+
.getResult()
|
|
166
|
+
.get('result');
|
|
167
|
+
|
|
168
|
+
expect(result).toMatchObject([
|
|
169
|
+
{ akey: true },
|
|
170
|
+
{ akey: 1 },
|
|
171
|
+
{ akey: 2 },
|
|
172
|
+
{ akey: 'a', bkey: 'b', ckey: 'c' },
|
|
173
|
+
]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('Array with nested array object and mixed without key', async () => {
|
|
177
|
+
let fun = new ArrayToArrayOfObjects();
|
|
144
178
|
|
|
145
|
-
|
|
179
|
+
let result = (
|
|
180
|
+
await fun.execute(
|
|
181
|
+
new FunctionExecutionParameters(
|
|
182
|
+
new KIRunFunctionRepository(),
|
|
183
|
+
new KIRunSchemaRepository(),
|
|
184
|
+
).setArguments(new Map([['source', [true, 1, 2, ['a', 'b', 'c']]]])),
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
.allResults()[0]
|
|
188
|
+
.getResult()
|
|
189
|
+
.get('result');
|
|
190
|
+
|
|
191
|
+
expect(result).toStrictEqual([
|
|
192
|
+
{ value: true },
|
|
193
|
+
{ value: 1 },
|
|
194
|
+
{ value: 2 },
|
|
195
|
+
{ value1: 'a', value2: 'b', value3: 'c' },
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('Array with nested array object and mixed without key', async () => {
|
|
200
|
+
let fun = new ArrayToArrayOfObjects();
|
|
201
|
+
|
|
202
|
+
let result = (
|
|
203
|
+
await fun.execute(
|
|
204
|
+
new FunctionExecutionParameters(
|
|
205
|
+
new KIRunFunctionRepository(),
|
|
206
|
+
new KIRunSchemaRepository(),
|
|
207
|
+
).setArguments(
|
|
208
|
+
new Map([['source', [true, 1, 2, ['a', 'b', 'c', ['d', 'e'], { obj1: 'val1' }]]]]),
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
.allResults()[0]
|
|
213
|
+
.getResult()
|
|
214
|
+
.get('result');
|
|
215
|
+
|
|
216
|
+
expect(result).toStrictEqual([
|
|
217
|
+
{ value: true },
|
|
218
|
+
{ value: 1 },
|
|
219
|
+
{ value: 2 },
|
|
220
|
+
{
|
|
221
|
+
value1: 'a',
|
|
222
|
+
value2: 'b',
|
|
223
|
+
value3: 'c',
|
|
224
|
+
value4: ['d', 'e'],
|
|
225
|
+
value5: {
|
|
226
|
+
obj1: 'val1',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
]);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test('Array with nested array object and mixed with key arrays', async () => {
|
|
233
|
+
let fun = new ArrayToArrayOfObjects();
|
|
234
|
+
|
|
235
|
+
let result = (
|
|
236
|
+
await fun.execute(
|
|
237
|
+
new FunctionExecutionParameters(
|
|
238
|
+
new KIRunFunctionRepository(),
|
|
239
|
+
new KIRunSchemaRepository(),
|
|
240
|
+
).setArguments(
|
|
241
|
+
new Map([
|
|
242
|
+
['source', [[true, false], [1, 'surendhar'], ['satya']]],
|
|
243
|
+
['keyName', ['valueA', 'valueB', 'valueC', 'valueD']],
|
|
244
|
+
]),
|
|
245
|
+
),
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
.allResults()[0]
|
|
249
|
+
.getResult()
|
|
250
|
+
.get('result');
|
|
251
|
+
|
|
252
|
+
console.log(result);
|
|
253
|
+
|
|
254
|
+
expect(result).toStrictEqual([
|
|
255
|
+
{ valueA: true, valueB: false, valueC: undefined, valueD: undefined },
|
|
256
|
+
{ valueA: 1, valueB: 'surendhar', valueC: undefined, valueD: undefined },
|
|
257
|
+
{ valueA: 'satya', valueB: undefined, valueC: undefined, valueD: undefined },
|
|
258
|
+
]);
|
|
146
259
|
});
|
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
import { KIRuntime } from '../../../src/engine/runtime/KIRuntime';
|
|
2
|
-
import { EventResult } from '../../../src/engine/model/EventResult';
|
|
3
|
-
import { Event } from '../../../src/engine/model/Event';
|
|
4
1
|
import { FunctionDefinition } from '../../../src/engine/model/FunctionDefinition';
|
|
5
|
-
import {
|
|
6
|
-
import { FunctionExecutionParameters } from '../../../src/engine/runtime/FunctionExecutionParameters';
|
|
7
|
-
import { Create } from '../../../src/engine/function/system/context/Create';
|
|
8
|
-
import { SetFunction } from '../../../src/engine/function/system/context/SetFunction';
|
|
9
|
-
import { GenerateEvent } from '../../../src/engine/function/system/GenerateEvent';
|
|
10
|
-
import { If } from '../../../src/engine/function/system/If';
|
|
11
|
-
import { RangeLoop } from '../../../src/engine/function/system/loop/RangeLoop';
|
|
12
|
-
import { Statement } from '../../../src/engine/model/Statement';
|
|
13
|
-
import { ParameterReference } from '../../../src/engine/model/ParameterReference';
|
|
14
|
-
import { Schema } from '../../../src/engine/json/schema/Schema';
|
|
2
|
+
import { Namespaces } from '../../../src/engine/namespaces/Namespaces';
|
|
15
3
|
import { KIRunFunctionRepository } from '../../../src/engine/repository/KIRunFunctionRepository';
|
|
16
4
|
import { KIRunSchemaRepository } from '../../../src/engine/repository/KIRunSchemaRepository';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { AbstractFunction } from '../../../src/engine/function/AbstractFunction';
|
|
20
|
-
import { FunctionOutput } from '../../../src/engine/model/FunctionOutput';
|
|
21
|
-
import { HybridRepository } from '../../../src/engine/HybridRepository';
|
|
22
|
-
import { Function } from '../../../src/engine/function/Function';
|
|
5
|
+
import { FunctionExecutionParameters } from '../../../src/engine/runtime/FunctionExecutionParameters';
|
|
6
|
+
import { KIRuntime } from '../../../src/engine/runtime/KIRuntime';
|
|
23
7
|
|
|
24
8
|
test('KIRuntime With Definition 1', async () => {
|
|
25
9
|
var def = {
|
package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts
CHANGED
|
@@ -42,3 +42,13 @@ test('OutputMapTokenValueExtractor Test', () => {
|
|
|
42
42
|
expect(omtv.getValue('Steps.step1.output.zero')).toBe(0);
|
|
43
43
|
expect(omtv.getValue('Steps.step1.output.obj.address.phone.phone2')).toBe('5678');
|
|
44
44
|
});
|
|
45
|
+
|
|
46
|
+
test('OutputMapTokenValueExtractor Test 2', () => {
|
|
47
|
+
let output: Map<string, Map<string, Map<string, any>>> = new Map([
|
|
48
|
+
['step1', new Map([['output', new Map([['arr', ['a', 'b', 'c']]])]])],
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
var omtv = new OutputMapTokenValueExtractor(output);
|
|
52
|
+
expect(omtv.getValue('Steps.step1.output.arr[1]')).toBe('b');
|
|
53
|
+
expect(omtv.getValue('Steps.step1.output.arr1[1]')).toBeUndefined();
|
|
54
|
+
});
|