@fincity/kirun-js 1.1.1 → 1.1.4
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/AddFirstTest.ts +29 -7
- package/__tests__/engine/function/system/array/AddTest.ts +21 -5
- package/__tests__/engine/function/system/array/BinarySearchTest.ts +26 -7
- package/__tests__/engine/function/system/array/CompareTest.ts +5 -1
- package/__tests__/engine/function/system/array/CopyTest.ts +22 -7
- package/__tests__/engine/function/system/array/DeleteFirstTest.ts +21 -5
- package/__tests__/engine/function/system/array/DeleteFromTest.ts +17 -4
- package/__tests__/engine/function/system/array/DeleteLastTest.ts +21 -5
- package/__tests__/engine/function/system/array/DeleteTest.ts +29 -9
- package/__tests__/engine/function/system/array/DisjointTest.ts +13 -3
- package/__tests__/engine/function/system/array/Equals.ts +13 -3
- package/__tests__/engine/function/system/array/FillTest.ts +5 -1
- package/__tests__/engine/function/system/array/FrequencyTest.ts +13 -3
- package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +29 -7
- package/__tests__/engine/function/system/array/IndexOfTest.ts +21 -5
- package/__tests__/engine/function/system/array/InsertTest.ts +25 -6
- package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +21 -5
- package/__tests__/engine/function/system/array/LastIndexOfTest.ts +25 -6
- package/__tests__/engine/function/system/array/MaxTest.ts +33 -24
- package/__tests__/engine/function/system/array/MinTest.ts +33 -24
- package/__tests__/engine/function/system/array/MisMatchTest.ts +17 -4
- package/__tests__/engine/function/system/array/ReverseTest.ts +21 -5
- package/__tests__/engine/function/system/array/RotateTest.ts +13 -3
- package/__tests__/engine/function/system/array/ShuffleTest.ts +9 -2
- package/__tests__/engine/function/system/array/SortTest.ts +21 -5
- package/__tests__/engine/function/system/array/SubArrayTest.ts +21 -5
- package/__tests__/engine/function/system/context/SetFunctionTest.ts +13 -3
- package/__tests__/engine/function/system/math/AddTest.ts +5 -3
- package/__tests__/engine/function/system/math/MathFunctionRepositoryTest.ts +108 -0
- package/__tests__/engine/function/system/math/MaximumTest.ts +38 -0
- package/__tests__/engine/function/system/math/MinimumTest.ts +38 -0
- package/__tests__/engine/function/system/math/RandomFloatTest.ts +83 -0
- package/__tests__/engine/function/system/math/RandomIntTest.ts +19 -11
- package/__tests__/engine/function/system/string/ConcatenateTest.ts +9 -2
- package/__tests__/engine/function/system/string/DeleteForGivenLengthTest.ts +9 -2
- package/__tests__/engine/function/system/string/InsertAtGivenPositionTest.ts +13 -3
- package/__tests__/engine/function/system/string/PostPadTest.ts +13 -3
- package/__tests__/engine/function/system/string/PrePadTest.ts +13 -3
- package/__tests__/engine/function/system/string/RegionMatchesTest.ts +13 -3
- package/__tests__/engine/function/system/string/ReverseTest.ts +10 -3
- package/__tests__/engine/function/system/string/SplitTest.ts +9 -2
- package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +13 -3
- package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +9 -2
- package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +33 -8
- package/__tests__/engine/function/system/string/ToStringTest.ts +10 -3
- package/__tests__/engine/function/system/string/TrimToTest.ts +9 -2
- package/__tests__/engine/json/schema/SchemaUtil.ts +3 -0
- package/__tests__/engine/json/schema/type/TypeUtilTest.ts +10 -0
- package/__tests__/engine/json/schema/validator/AnyOfAllOfOneOfValidatorTest.ts +38 -0
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +67 -0
- package/__tests__/engine/runtime/KIRuntimeTest.ts +23 -12
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +88 -0
- package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +5 -1
- 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 +23 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/AbstractFunction.ts +14 -5
- package/src/engine/function/system/math/Maximum.ts +1 -1
- package/src/engine/function/system/math/Minimum.ts +1 -1
- package/src/engine/function/system/math/RandomFloat.ts +2 -2
- package/src/engine/function/system/math/RandomInt.ts +1 -1
- package/src/engine/json/schema/Schema.ts +4 -3
- package/src/engine/json/schema/SchemaUtil.ts +4 -4
- package/src/engine/json/schema/type/TypeUtil.ts +3 -5
- package/src/engine/json/schema/validator/SchemaValidator.ts +4 -1
- package/src/engine/model/AbstractStatement.ts +10 -0
- package/src/engine/model/Event.ts +15 -0
- package/src/engine/model/FunctionDefinition.ts +76 -29
- package/src/engine/model/Parameter.ts +11 -0
- package/src/engine/model/ParameterReference.ts +8 -1
- package/src/engine/model/Position.ts +5 -0
- package/src/engine/model/Statement.ts +16 -0
- package/src/engine/model/StatementGroup.ts +7 -0
- package/src/engine/runtime/FunctionExecutionParameters.ts +30 -0
- package/src/engine/runtime/KIRuntime.ts +37 -24
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { ToString } from '../../../../../src/engine/function/system/string/ToString';
|
|
2
2
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
3
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
4
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
5
|
|
|
5
6
|
const toString: ToString = new ToString();
|
|
6
7
|
|
|
7
8
|
test('toString test1', async () => {
|
|
8
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
9
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
10
|
+
new KIRunFunctionRepository(),
|
|
11
|
+
new KIRunSchemaRepository(),
|
|
12
|
+
);
|
|
9
13
|
fep.setArguments(MapUtil.of('anytype', 123));
|
|
10
14
|
|
|
11
15
|
expect((await toString.execute(fep)).allResults()[0].getResult().get('result')).toBe('123');
|
|
12
16
|
});
|
|
13
17
|
|
|
14
18
|
// test('toString test2', async () => {
|
|
15
|
-
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters();
|
|
19
|
+
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters(new KIRunFunctionRepository(), new KIRunSchemaRepository());
|
|
16
20
|
|
|
17
21
|
// let array: string[] = [];
|
|
18
22
|
// array.push('I');
|
|
@@ -36,7 +40,10 @@ test('toString test1', async () => {
|
|
|
36
40
|
// });
|
|
37
41
|
|
|
38
42
|
test('toString test2 ', async () => {
|
|
39
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
43
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
44
|
+
new KIRunFunctionRepository(),
|
|
45
|
+
new KIRunSchemaRepository(),
|
|
46
|
+
);
|
|
40
47
|
fep.setArguments(MapUtil.of('anytype', true));
|
|
41
48
|
|
|
42
49
|
expect((await toString.execute(fep)).allResults()[0].getResult().get('result')).toBe('true');
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { TrimTo } from '../../../../../src/engine/function/system/string/TrimTo';
|
|
2
2
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
3
4
|
|
|
4
5
|
const trim: TrimTo = new TrimTo();
|
|
5
6
|
|
|
6
7
|
test('Trim to test1 ', async () => {
|
|
7
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
8
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
9
|
+
new KIRunFunctionRepository(),
|
|
10
|
+
new KIRunSchemaRepository(),
|
|
11
|
+
).setArguments(
|
|
8
12
|
new Map<string, string | number>([
|
|
9
13
|
[TrimTo.PARAMETER_STRING_NAME, ' THIScompatY IS A NOcoDE plATFNORM'],
|
|
10
14
|
[TrimTo.PARAMETER_LENGTH_NAME, 14],
|
|
@@ -17,7 +21,10 @@ test('Trim to test1 ', async () => {
|
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
test('Trim to test2 ', async () => {
|
|
20
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
24
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
25
|
+
new KIRunFunctionRepository(),
|
|
26
|
+
new KIRunSchemaRepository(),
|
|
27
|
+
).setArguments(
|
|
21
28
|
new Map<string, string | number>([
|
|
22
29
|
[TrimTo.PARAMETER_STRING_NAME, ' THIScompatY IS A NOcoDE plATFNORM'],
|
|
23
30
|
[TrimTo.PARAMETER_LENGTH_NAME, 0],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaType, TypeUtil } from '../../../../../src';
|
|
2
|
+
|
|
3
|
+
test('TypeUtilTest', () => {
|
|
4
|
+
expect(TypeUtil.from('Object')?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
5
|
+
|
|
6
|
+
let type = TypeUtil.from(['Object', 'String']);
|
|
7
|
+
|
|
8
|
+
expect(type?.contains(SchemaType.STRING)).toBeTruthy();
|
|
9
|
+
expect(type?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
10
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Schema } from "../../../../../src/engine/json/schema/Schema";
|
|
2
|
+
import { SchemaType } from "../../../../../src/engine/json/schema/type/SchemaType";
|
|
3
|
+
import { TypeUtil } from "../../../../../src/engine/json/schema/type/TypeUtil";
|
|
4
|
+
import { AnyOfAllOfOneOfValidator } from "../../../../../src/engine/json/schema/validator/AnyOfAllOfOneOfValidator";
|
|
5
|
+
import { KIRunSchemaRepository } from "../../../../../src/engine/repository/KIRunSchemaRepository";
|
|
6
|
+
|
|
7
|
+
const repo = new KIRunSchemaRepository();
|
|
8
|
+
|
|
9
|
+
test("Any Of All Of One Validator Test 1", () => {
|
|
10
|
+
let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER));
|
|
11
|
+
|
|
12
|
+
expect(AnyOfAllOfOneOfValidator.validate([], schema, repo, 10)).toBe(10);
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
test("Any Of All Of One Validator Test 2", () => {
|
|
16
|
+
let arraySchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.ARRAY));
|
|
17
|
+
|
|
18
|
+
expect(AnyOfAllOfOneOfValidator.validate([], arraySchema, repo, [1, 2, 3])).toStrictEqual([1, 2, 3]);
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test("Any Of All Of One Validator Test 3", () => {
|
|
22
|
+
let objSchema: Schema = Schema.ofObject("testObj").setProperties(new Map<string, Schema>([['key', Schema.ofString('key')]]));
|
|
23
|
+
|
|
24
|
+
expect(AnyOfAllOfOneOfValidator.validate([], objSchema, repo, { "key": "value" })).toStrictEqual({ "key": "value" });
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test("Any Of All Of One Validator Test 3", () => {
|
|
28
|
+
let nullSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.NULL));
|
|
29
|
+
|
|
30
|
+
expect(AnyOfAllOfOneOfValidator.validate([], nullSchema, repo, null)).toBe(null);
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test("Any Of All Of One Validator Test 3", () => {
|
|
34
|
+
let nullSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.BOOLEAN));
|
|
35
|
+
|
|
36
|
+
expect(AnyOfAllOfOneOfValidator.validate([], nullSchema, repo, null)).toBe(null);
|
|
37
|
+
})
|
|
38
|
+
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HybridRepository } from '../../../../../src';
|
|
1
2
|
import { Schema } from '../../../../../src/engine/json/schema/Schema';
|
|
2
3
|
import { SchemaType } from '../../../../../src/engine/json/schema/type/SchemaType';
|
|
3
4
|
import { TypeUtil } from '../../../../../src/engine/json/schema/type/TypeUtil';
|
|
@@ -24,3 +25,69 @@ test('Schema Validator Test 1', () => {
|
|
|
24
25
|
|
|
25
26
|
// expect(SchemaValidator.validate([], schema, repo, 2.5)).toThrowError(new SchemaValidationException('', '2.5 is not a number of type Integer'));
|
|
26
27
|
});
|
|
28
|
+
|
|
29
|
+
test('Schema Validator Test 2', () => {
|
|
30
|
+
const locationSchema = Schema.from({
|
|
31
|
+
name: 'Location',
|
|
32
|
+
namespace: 'Test',
|
|
33
|
+
type: 'Object',
|
|
34
|
+
properties: {
|
|
35
|
+
url: { name: 'url', type: 'String' },
|
|
36
|
+
},
|
|
37
|
+
required: ['url'],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const repo = new HybridRepository<Schema>(
|
|
41
|
+
{
|
|
42
|
+
find(namespace, name): Schema | undefined {
|
|
43
|
+
if (namespace === 'Test' && name === 'Location') {
|
|
44
|
+
return locationSchema;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
new KIRunSchemaRepository(),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const obj = { url: 'http://xxxx.com' };
|
|
53
|
+
|
|
54
|
+
expect(SchemaValidator.validate(undefined, Schema.ofRef('Test.Location'), repo, obj)).toBe(obj);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Schema Validator Test 3', () => {
|
|
58
|
+
const obj = { url: 'http://xxxx.com' };
|
|
59
|
+
|
|
60
|
+
const locationSchema = Schema.from({
|
|
61
|
+
name: 'Location',
|
|
62
|
+
namespace: 'Test',
|
|
63
|
+
type: 'Object',
|
|
64
|
+
properties: {
|
|
65
|
+
url: { name: 'url', type: 'String' },
|
|
66
|
+
},
|
|
67
|
+
required: ['url'],
|
|
68
|
+
defaultValue: obj,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const repo = new HybridRepository<Schema>(
|
|
72
|
+
{
|
|
73
|
+
find(namespace, name): Schema | undefined {
|
|
74
|
+
if (namespace === 'Test' && name === 'Location') {
|
|
75
|
+
return locationSchema;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
new KIRunSchemaRepository(),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const obj1 = { url: 'http://yyyy.com' };
|
|
84
|
+
|
|
85
|
+
expect(
|
|
86
|
+
SchemaValidator.validate(
|
|
87
|
+
undefined,
|
|
88
|
+
Schema.ofRef('Test.Location').setDefaultValue(obj1),
|
|
89
|
+
repo,
|
|
90
|
+
undefined,
|
|
91
|
+
),
|
|
92
|
+
).toMatchObject(obj1);
|
|
93
|
+
});
|
|
@@ -147,9 +147,12 @@ test('KIRuntime Test 1', async () => {
|
|
|
147
147
|
.setParameters(
|
|
148
148
|
new Map([['Count', new Parameter('Count', Schema.ofInteger('Count'))]]),
|
|
149
149
|
) as FunctionDefinition,
|
|
150
|
-
|
|
151
|
-
new
|
|
152
|
-
|
|
150
|
+
).execute(
|
|
151
|
+
new FunctionExecutionParameters(
|
|
152
|
+
new KIRunFunctionRepository(),
|
|
153
|
+
new KIRunSchemaRepository(),
|
|
154
|
+
).setArguments(new Map([['Count', num]])),
|
|
155
|
+
)
|
|
153
156
|
).allResults();
|
|
154
157
|
console.log('KIRunt Logic : ' + (new Date().getTime() - start));
|
|
155
158
|
expect(out[0].getResult().get('result')).toStrictEqual(array);
|
|
@@ -193,9 +196,12 @@ test('KIRuntime Test 2', async () => {
|
|
|
193
196
|
),
|
|
194
197
|
]),
|
|
195
198
|
),
|
|
196
|
-
|
|
197
|
-
new
|
|
198
|
-
|
|
199
|
+
).execute(
|
|
200
|
+
new FunctionExecutionParameters(
|
|
201
|
+
new KIRunFunctionRepository(),
|
|
202
|
+
new KIRunSchemaRepository(),
|
|
203
|
+
).setArguments(new Map([['Value', -10]])),
|
|
204
|
+
)
|
|
199
205
|
).allResults();
|
|
200
206
|
|
|
201
207
|
expect(out[0].getResult().get('result')).toBe(10);
|
|
@@ -238,9 +244,12 @@ test('KIRuntime Test 3', async () => {
|
|
|
238
244
|
),
|
|
239
245
|
]),
|
|
240
246
|
),
|
|
241
|
-
|
|
242
|
-
new
|
|
243
|
-
|
|
247
|
+
).execute(
|
|
248
|
+
new FunctionExecutionParameters(
|
|
249
|
+
new KIRunFunctionRepository(),
|
|
250
|
+
new KIRunSchemaRepository(),
|
|
251
|
+
).setArguments(new Map([['Value', 27]])),
|
|
252
|
+
)
|
|
244
253
|
).allResults();
|
|
245
254
|
|
|
246
255
|
expect(out[0].getResult().get('result')).toBe(3);
|
|
@@ -335,9 +344,11 @@ test('KIRuntime Test 4', async () => {
|
|
|
335
344
|
),
|
|
336
345
|
]),
|
|
337
346
|
),
|
|
338
|
-
|
|
339
|
-
new KIRunSchemaRepository()
|
|
340
|
-
|
|
347
|
+
).execute(
|
|
348
|
+
new FunctionExecutionParameters(hybrid, new KIRunSchemaRepository()).setArguments(
|
|
349
|
+
new Map([['Value', num]]),
|
|
350
|
+
),
|
|
351
|
+
)
|
|
341
352
|
).allResults();
|
|
342
353
|
console.log('KIRun Logic : ' + (new Date().getTime() - start));
|
|
343
354
|
expect(out[0].getResult().get('result')).toStrictEqual(array);
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
import { FunctionDefinition } from '../../../src/engine/model/FunctionDefinition';
|
|
5
|
+
import { Parameter } from '../../../src/engine/model/Parameter';
|
|
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';
|
|
15
|
+
import { KIRunFunctionRepository } from '../../../src/engine/repository/KIRunFunctionRepository';
|
|
16
|
+
import { KIRunSchemaRepository } from '../../../src/engine/repository/KIRunSchemaRepository';
|
|
17
|
+
import { Namespaces } from '../../../src/engine/namespaces/Namespaces';
|
|
18
|
+
import { FunctionSignature } from '../../../src/engine/model/FunctionSignature';
|
|
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';
|
|
23
|
+
|
|
24
|
+
test('KIRuntime With Definition 1', async () => {
|
|
25
|
+
var def = {
|
|
26
|
+
name: 'getAppData',
|
|
27
|
+
namespace: 'UIApp',
|
|
28
|
+
parameters: {
|
|
29
|
+
a: { parameterName: 'a', schema: { name: 'integer', type: 'Integer' } },
|
|
30
|
+
b: { parameterName: 'b', schema: { name: 'integer', type: 'Integer' } },
|
|
31
|
+
c: { parameterName: 'c', schema: { name: 'integer', type: 'Integer' } },
|
|
32
|
+
},
|
|
33
|
+
events: {
|
|
34
|
+
output: {
|
|
35
|
+
name: 'output',
|
|
36
|
+
parameters: { additionResult: { name: 'additionResult', type: 'Integer' } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
steps: {
|
|
40
|
+
add: {
|
|
41
|
+
statementName: 'add',
|
|
42
|
+
namespace: Namespaces.MATH,
|
|
43
|
+
name: 'Add',
|
|
44
|
+
parameterMap: {
|
|
45
|
+
value: [
|
|
46
|
+
{ type: 'EXPRESSION', expression: 'Arguments.a' },
|
|
47
|
+
{ type: 'EXPRESSION', expression: '10 + 1' },
|
|
48
|
+
{ type: 'EXPRESSION', expression: 'Arguments.c' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
genOutput: {
|
|
53
|
+
statementName: 'genOutput',
|
|
54
|
+
namespace: Namespaces.SYSTEM,
|
|
55
|
+
name: 'GenerateEvent',
|
|
56
|
+
parameterMap: {
|
|
57
|
+
eventName: [{ type: 'VALUE', value: 'output' }],
|
|
58
|
+
results: [
|
|
59
|
+
{
|
|
60
|
+
type: 'VALUE',
|
|
61
|
+
value: {
|
|
62
|
+
name: 'additionResult',
|
|
63
|
+
value: { isExpression: true, value: 'Steps.add.output.value' },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const fd = FunctionDefinition.from(def);
|
|
73
|
+
|
|
74
|
+
let result = await new KIRuntime(fd).execute(
|
|
75
|
+
new FunctionExecutionParameters(
|
|
76
|
+
new KIRunFunctionRepository(),
|
|
77
|
+
new KIRunSchemaRepository(),
|
|
78
|
+
).setArguments(
|
|
79
|
+
new Map([
|
|
80
|
+
['a', 7],
|
|
81
|
+
['b', 11],
|
|
82
|
+
['c', 13],
|
|
83
|
+
]),
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(result.allResults()[0].getResult().get('additionResult')).toBe(31);
|
|
88
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../src';
|
|
1
2
|
import { Schema } from '../../../../src/engine/json/schema/Schema';
|
|
2
3
|
import { ContextElement } from '../../../../src/engine/runtime/ContextElement';
|
|
3
4
|
import { ExpressionEvaluator } from '../../../../src/engine/runtime/expression/ExpressionEvaluator';
|
|
@@ -34,7 +35,10 @@ test('Expression Test', () => {
|
|
|
34
35
|
['loop', new Map([['iteration', new Map([['index', 2]])]])],
|
|
35
36
|
]);
|
|
36
37
|
|
|
37
|
-
let parameters: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
38
|
+
let parameters: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
39
|
+
new KIRunFunctionRepository(),
|
|
40
|
+
new KIRunSchemaRepository(),
|
|
41
|
+
)
|
|
38
42
|
.setArguments(new Map())
|
|
39
43
|
.setContext(
|
|
40
44
|
new Map([
|