@fincity/kirun-js 1.4.3 → 1.4.5
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/json/schema/type/TypeUtilTest.ts +2 -2
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +6 -6
- package/__tests__/engine/runtime/KIRuntimeExtended.ts +142 -0
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +5 -5
- package/__tests__/engine/runtime/expression/operators/unary/LogicalNotOperatorTest.ts +17 -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 +3 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/json/schema/type/TypeUtil.ts +2 -2
- package/src/engine/runtime/KIRuntime.ts +57 -4
- package/src/engine/runtime/expression/operators/unary/LogicalNotOperator.ts +1 -16
- package/src/engine/util/LinkedList.ts +21 -10
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SchemaType, TypeUtil } from '../../../../../src';
|
|
2
2
|
|
|
3
3
|
test('TypeUtilTest', () => {
|
|
4
|
-
expect(TypeUtil.from('
|
|
4
|
+
expect(TypeUtil.from('OBJECT')?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
5
5
|
|
|
6
|
-
let type = TypeUtil.from(['
|
|
6
|
+
let type = TypeUtil.from(['OBJECT', 'STRING']);
|
|
7
7
|
|
|
8
8
|
expect(type?.contains(SchemaType.STRING)).toBeTruthy();
|
|
9
9
|
expect(type?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
@@ -30,9 +30,9 @@ test('Schema validation when ref of ref', () => {
|
|
|
30
30
|
const locationSchema = Schema.from({
|
|
31
31
|
name: 'Location',
|
|
32
32
|
namespace: 'Test',
|
|
33
|
-
type: '
|
|
33
|
+
type: 'OBJECT',
|
|
34
34
|
properties: {
|
|
35
|
-
url: { name: 'url', type: '
|
|
35
|
+
url: { name: 'url', type: 'STRING' },
|
|
36
36
|
},
|
|
37
37
|
required: ['url'],
|
|
38
38
|
});
|
|
@@ -66,7 +66,7 @@ test('Schema validation when ref of ref', () => {
|
|
|
66
66
|
},
|
|
67
67
|
new KIRunSchemaRepository(),
|
|
68
68
|
);
|
|
69
|
-
const obj = { url: 'http://xxxxxx.com' };
|
|
69
|
+
const obj = { obj: { url: 'http://xxxxxx.com' } };
|
|
70
70
|
const queryParams = {
|
|
71
71
|
obj: { obj: { url: 'http://xxxxxx.com' } },
|
|
72
72
|
};
|
|
@@ -80,9 +80,9 @@ test('Schema Validator Test 2', () => {
|
|
|
80
80
|
const locationSchema = Schema.from({
|
|
81
81
|
name: 'Location',
|
|
82
82
|
namespace: 'Test',
|
|
83
|
-
type: '
|
|
83
|
+
type: 'OBJECT',
|
|
84
84
|
properties: {
|
|
85
|
-
url: { name: 'url', type: '
|
|
85
|
+
url: { name: 'url', type: 'STRING' },
|
|
86
86
|
},
|
|
87
87
|
required: ['url'],
|
|
88
88
|
});
|
|
@@ -116,7 +116,7 @@ test('Schema Validator Test 3', () => {
|
|
|
116
116
|
const locationSchema = Schema.from({
|
|
117
117
|
name: 'Location',
|
|
118
118
|
namespace: 'Test',
|
|
119
|
-
type: '
|
|
119
|
+
type: 'OBJECT',
|
|
120
120
|
properties: {
|
|
121
121
|
url: { name: 'url', type: 'String' },
|
|
122
122
|
},
|
|
@@ -0,0 +1,142 @@
|
|
|
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 Extended Definition', async () => {
|
|
25
|
+
var def = {
|
|
26
|
+
name: 'checkExtendedFunction',
|
|
27
|
+
namespace: 'Test',
|
|
28
|
+
parameters: {
|
|
29
|
+
a: { parameterName: 'a', schema: { name: 'INTEGER', type: 'INTEGER' } },
|
|
30
|
+
},
|
|
31
|
+
events: {
|
|
32
|
+
output: {
|
|
33
|
+
name: 'output',
|
|
34
|
+
parameters: { additionResult: { name: 'additionResult', type: 'INTEGER' } },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
steps: {
|
|
38
|
+
add1: {
|
|
39
|
+
statementName: 'add1',
|
|
40
|
+
namespace: Namespaces.MATH,
|
|
41
|
+
name: 'Add',
|
|
42
|
+
parameterMap: {
|
|
43
|
+
value: {
|
|
44
|
+
one: { key: 'one', type: 'EXPRESSION', expression: 'Arguments.a' },
|
|
45
|
+
two: { key: 'two', type: 'VALUE', value: 1 },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
if1: {
|
|
50
|
+
statementName: 'if1',
|
|
51
|
+
namespace: Namespaces.SYSTEM,
|
|
52
|
+
name: 'If',
|
|
53
|
+
parameterMap: {
|
|
54
|
+
condition: {
|
|
55
|
+
one: {
|
|
56
|
+
key: 'one',
|
|
57
|
+
type: 'EXPRESSION',
|
|
58
|
+
expression: 'Steps.add1.output.value % 2 = 0',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
add2: {
|
|
64
|
+
statementName: 'add2',
|
|
65
|
+
namespace: Namespaces.MATH,
|
|
66
|
+
name: 'Add',
|
|
67
|
+
parameterMap: {
|
|
68
|
+
value: {
|
|
69
|
+
one: {
|
|
70
|
+
key: 'one',
|
|
71
|
+
type: 'EXPRESSION',
|
|
72
|
+
expression: 'Steps.add1.output.value',
|
|
73
|
+
},
|
|
74
|
+
two: { key: 'two', type: 'VALUE', value: 2 },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
dependentStatements: {
|
|
78
|
+
'Steps.if1.true': true,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
add3: {
|
|
82
|
+
statementName: 'add3',
|
|
83
|
+
namespace: Namespaces.MATH,
|
|
84
|
+
name: 'Add',
|
|
85
|
+
parameterMap: {
|
|
86
|
+
value: {
|
|
87
|
+
one: {
|
|
88
|
+
key: 'one',
|
|
89
|
+
type: 'EXPRESSION',
|
|
90
|
+
expression: 'Steps.add2.output.value',
|
|
91
|
+
},
|
|
92
|
+
two: { key: 'two', type: 'VALUE', value: 2 },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
add4: {
|
|
97
|
+
statementName: 'add4',
|
|
98
|
+
namespace: Namespaces.MATH,
|
|
99
|
+
name: 'Add',
|
|
100
|
+
parameterMap: {
|
|
101
|
+
value: {
|
|
102
|
+
one: {
|
|
103
|
+
key: 'one',
|
|
104
|
+
type: 'EXPRESSION',
|
|
105
|
+
expression: 'Steps.add1.output.value',
|
|
106
|
+
},
|
|
107
|
+
two: { key: 'two', type: 'VALUE', value: 1 },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
genOutput: {
|
|
112
|
+
statementName: 'genOutput',
|
|
113
|
+
namespace: Namespaces.SYSTEM,
|
|
114
|
+
name: 'GenerateEvent',
|
|
115
|
+
parameterMap: {
|
|
116
|
+
eventName: { one: { key: 'one', type: 'VALUE', value: 'output' } },
|
|
117
|
+
results: {
|
|
118
|
+
one: {
|
|
119
|
+
key: 'one',
|
|
120
|
+
type: 'VALUE',
|
|
121
|
+
value: {
|
|
122
|
+
name: 'additionResult',
|
|
123
|
+
value: { isExpression: true, value: 'Steps.add4.output.value' },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const fd = FunctionDefinition.from(def);
|
|
133
|
+
|
|
134
|
+
let result = await new KIRuntime(fd, true).execute(
|
|
135
|
+
new FunctionExecutionParameters(
|
|
136
|
+
new KIRunFunctionRepository(),
|
|
137
|
+
new KIRunSchemaRepository(),
|
|
138
|
+
).setArguments(new Map([['a', 7]])),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(result.allResults()[0].getResult().get('additionResult')).toBe(9);
|
|
142
|
+
});
|
|
@@ -26,14 +26,14 @@ test('KIRuntime With Definition 1', async () => {
|
|
|
26
26
|
name: 'getAppData',
|
|
27
27
|
namespace: 'UIApp',
|
|
28
28
|
parameters: {
|
|
29
|
-
a: { parameterName: 'a', schema: { name: '
|
|
30
|
-
b: { parameterName: 'b', schema: { name: '
|
|
31
|
-
c: { parameterName: 'c', schema: { name: '
|
|
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
32
|
},
|
|
33
33
|
events: {
|
|
34
34
|
output: {
|
|
35
35
|
name: 'output',
|
|
36
|
-
parameters: { additionResult: { name: 'additionResult', type: '
|
|
36
|
+
parameters: { additionResult: { name: 'additionResult', type: 'INTEGER' } },
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
steps: {
|
|
@@ -72,7 +72,7 @@ test('KIRuntime With Definition 1', async () => {
|
|
|
72
72
|
|
|
73
73
|
const fd = FunctionDefinition.from(def);
|
|
74
74
|
|
|
75
|
-
let result = await new KIRuntime(fd).execute(
|
|
75
|
+
let result = await new KIRuntime(fd, true).execute(
|
|
76
76
|
new FunctionExecutionParameters(
|
|
77
77
|
new KIRunFunctionRepository(),
|
|
78
78
|
new KIRunSchemaRepository(),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LogicalNotOperator } from '../../../../../../src';
|
|
2
|
+
|
|
3
|
+
test('Logical Not Test', () => {
|
|
4
|
+
expect(new LogicalNotOperator().apply(null)).toBeTruthy();
|
|
5
|
+
expect(new LogicalNotOperator().apply(undefined)).toBeTruthy();
|
|
6
|
+
expect(new LogicalNotOperator().apply(false)).toBeTruthy();
|
|
7
|
+
expect(new LogicalNotOperator().apply(0)).toBeTruthy();
|
|
8
|
+
|
|
9
|
+
expect(new LogicalNotOperator().apply(true)).toBeFalsy();
|
|
10
|
+
expect(new LogicalNotOperator().apply(1)).toBeFalsy();
|
|
11
|
+
|
|
12
|
+
expect(new LogicalNotOperator().apply({ name: 'Kiran' })).toBeFalsy();
|
|
13
|
+
|
|
14
|
+
expect(new LogicalNotOperator().apply([])).toBeFalsy();
|
|
15
|
+
expect(new LogicalNotOperator().apply('')).toBeFalsy();
|
|
16
|
+
expect(new LogicalNotOperator().apply('TRUE')).toBeFalsy();
|
|
17
|
+
});
|