@fincity/kirun-js 1.1.1 → 1.1.2
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/DeleteTest.ts +4 -3
- package/__tests__/engine/function/system/math/RandomIntTest.ts +6 -6
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +89 -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 +14 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/system/math/RandomInt.ts +1 -1
- package/src/engine/json/schema/Schema.ts +1 -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
|
@@ -47,7 +47,6 @@ test('Delete Test 2', async () => {
|
|
|
47
47
|
expect(source).toStrictEqual(temp);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
test('Delete Test 3', async () => {
|
|
52
51
|
let delet: Delete = new Delete();
|
|
53
52
|
let source = undefined;
|
|
@@ -105,7 +104,9 @@ test('Delete Test 4', async () => {
|
|
|
105
104
|
await expect(delet.execute(fep)).rejects.toThrow();
|
|
106
105
|
});
|
|
107
106
|
|
|
108
|
-
test('Delete Test 5', () => {
|
|
107
|
+
test('Delete Test 5', async () => {
|
|
108
|
+
let delet: Delete = new Delete();
|
|
109
|
+
|
|
109
110
|
var arr1: any[] = ['nocode', 'platform', 14];
|
|
110
111
|
var arr2: any[] = ['nocode', 'platiform', 14];
|
|
111
112
|
var obj: object = {
|
|
@@ -138,7 +139,7 @@ test('Delete Test 5', () => {
|
|
|
138
139
|
.setSteps(new Map([]))
|
|
139
140
|
.setContext(new Map([]));
|
|
140
141
|
|
|
141
|
-
delet.execute(fep);
|
|
142
|
+
await delet.execute(fep);
|
|
142
143
|
|
|
143
144
|
expect(arr).toStrictEqual(res);
|
|
144
145
|
});
|
|
@@ -3,7 +3,7 @@ import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/F
|
|
|
3
3
|
|
|
4
4
|
const rand = new RandomInt();
|
|
5
5
|
|
|
6
|
-
test(' rand int 1', () => {
|
|
6
|
+
test(' rand int 1', async () => {
|
|
7
7
|
let min = 100,
|
|
8
8
|
max = 1000123;
|
|
9
9
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters().setArguments(
|
|
@@ -12,24 +12,24 @@ test(' rand int 1', () => {
|
|
|
12
12
|
['maxValue', max],
|
|
13
13
|
]),
|
|
14
14
|
);
|
|
15
|
-
let num: number = rand.execute(fep).allResults()[0].getResult().get('value');
|
|
15
|
+
let num: number = (await rand.execute(fep)).allResults()[0].getResult().get('value');
|
|
16
16
|
|
|
17
17
|
expect(num).toBeLessThanOrEqual(max);
|
|
18
18
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
test(' rand int 2', () => {
|
|
21
|
+
test(' rand int 2', async () => {
|
|
22
22
|
let min = 100;
|
|
23
23
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters().setArguments(
|
|
24
24
|
new Map([['minValue', min]]),
|
|
25
25
|
);
|
|
26
|
-
let num: number = rand.execute(fep).allResults()[0].getResult().get('value');
|
|
26
|
+
let num: number = (await rand.execute(fep)).allResults()[0].getResult().get('value');
|
|
27
27
|
|
|
28
28
|
expect(num).toBeLessThanOrEqual(2147483647);
|
|
29
29
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
test(' rand int 3', () => {
|
|
32
|
+
test(' rand int 3', async () => {
|
|
33
33
|
let min = 100,
|
|
34
34
|
max = 101;
|
|
35
35
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters().setArguments(
|
|
@@ -38,7 +38,7 @@ test(' rand int 3', () => {
|
|
|
38
38
|
['maxValue', max],
|
|
39
39
|
]),
|
|
40
40
|
);
|
|
41
|
-
let num: number = rand.execute(fep).allResults()[0].getResult().get('value');
|
|
41
|
+
let num: number = (await rand.execute(fep)).allResults()[0].getResult().get('value');
|
|
42
42
|
|
|
43
43
|
console.log(num);
|
|
44
44
|
expect(num).toBeLessThanOrEqual(max);
|
|
@@ -0,0 +1,89 @@
|
|
|
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(
|
|
75
|
+
fd,
|
|
76
|
+
new KIRunFunctionRepository(),
|
|
77
|
+
new KIRunSchemaRepository(),
|
|
78
|
+
).execute(
|
|
79
|
+
new FunctionExecutionParameters().setArguments(
|
|
80
|
+
new Map([
|
|
81
|
+
['a', 7],
|
|
82
|
+
['b', 11],
|
|
83
|
+
['c', 13],
|
|
84
|
+
]),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
expect(result.allResults()[0].getResult().get('additionResult')).toBe(31);
|
|
89
|
+
});
|