@fincity/kirun-js 1.5.2 → 1.6.3

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 (39) hide show
  1. package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +339 -0
  2. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +142 -0
  3. package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +191 -0
  4. package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +152 -0
  5. package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +23 -0
  6. package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +280 -0
  7. package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +20 -3
  8. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +21 -5
  9. package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +0 -2
  10. package/__tests__/engine/repository/RepositoryFilterTest.ts +39 -0
  11. package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +6 -0
  12. package/__tests__/engine/runtime/KIRuntimeMessagesTest.ts +179 -0
  13. package/__tests__/engine/runtime/KIRuntimeTest.ts +6 -0
  14. package/__tests__/indexTest.ts +12 -0
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/module.js +1 -1
  18. package/dist/module.js.map +1 -1
  19. package/dist/types.d.ts +23 -12
  20. package/dist/types.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/src/engine/HybridRepository.ts +8 -0
  23. package/src/engine/Repository.ts +1 -0
  24. package/src/engine/function/system/Print.ts +1 -1
  25. package/src/engine/function/system/array/ArrayFunctionRepository.ts +10 -0
  26. package/src/engine/function/system/math/MathFunctionRepository.ts +10 -1
  27. package/src/engine/function/system/string/StringFunctionRepository.ts +10 -0
  28. package/src/engine/json/schema/Schema.ts +82 -32
  29. package/src/engine/json/schema/SchemaUtil.ts +6 -3
  30. package/src/engine/json/schema/array/ArraySchemaType.ts +13 -2
  31. package/src/engine/json/schema/validator/ArrayValidator.ts +135 -24
  32. package/src/engine/json/schema/validator/ObjectValidator.ts +9 -4
  33. package/src/engine/model/Event.ts +2 -2
  34. package/src/engine/model/FunctionDefinition.ts +3 -3
  35. package/src/engine/model/FunctionSignature.ts +6 -3
  36. package/src/engine/model/Statement.ts +4 -6
  37. package/src/engine/repository/KIRunFunctionRepository.ts +9 -0
  38. package/src/engine/repository/KIRunSchemaRepository.ts +8 -0
  39. package/src/engine/runtime/KIRuntime.ts +36 -48
@@ -0,0 +1,152 @@
1
+ import {
2
+ AdditionalType,
3
+ ArraySchemaType,
4
+ ArrayValidator,
5
+ KIRunSchemaRepository,
6
+ Schema,
7
+ SchemaValidator,
8
+ } from '../../../../../src';
9
+
10
+ const repo = new KIRunSchemaRepository();
11
+
12
+ test('schema array validator tuple schema test for additional items with boolean different datatype', () => {
13
+ let schema = Schema.from({
14
+ type: 'ARRAY',
15
+ items: [
16
+ {
17
+ type: 'INTEGER',
18
+ },
19
+ {
20
+ type: 'STRING',
21
+ },
22
+ {
23
+ type: 'BOOLEAN',
24
+ },
25
+ {
26
+ type: 'OBJECT',
27
+ },
28
+ ],
29
+ additionalItems: {
30
+ schemaValue: {
31
+ type: 'OBJECT',
32
+ },
33
+ },
34
+ });
35
+
36
+ let obj = [1, 'asd', { val: 'stringtype' }, 'stringOnemore'];
37
+
38
+ expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
39
+ });
40
+
41
+ test('schema array validator tuple schema test for additional items with boolean true datatype', () => {
42
+ let schema = Schema.from({
43
+ type: 'ARRAY',
44
+ items: [
45
+ {
46
+ type: 'STRING',
47
+ },
48
+ {
49
+ type: 'BOOLEAN',
50
+ },
51
+ ],
52
+ additionalItems: {
53
+ schemaValue: {
54
+ type: 'OBJECT',
55
+ },
56
+ },
57
+ });
58
+
59
+ let obj = ['asd', true, { a: 'b' }];
60
+
61
+ expect(SchemaValidator.validate([], schema, repo, obj)).toStrictEqual(obj);
62
+ });
63
+
64
+ test('schema array validator test for additional items with boolean false different datatype', () => {
65
+ let schema = Schema.from({
66
+ type: 'ARRAY',
67
+ items: { type: 'INTEGER' },
68
+ additionalItems: { booleanValue: false },
69
+ });
70
+ let obj = [1, 2, 3, 4, 'stringtype', true];
71
+
72
+ expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
73
+ });
74
+
75
+ test('schema array validator test for additional items with boolean true different datatype', () => {
76
+ let schema = Schema.from({
77
+ type: 'ARRAY',
78
+ items: {
79
+ type: 'INTEGER',
80
+ },
81
+ additionalItems: {
82
+ schemaValue: {
83
+ type: 'STRING',
84
+ },
85
+ },
86
+ });
87
+
88
+ let obj = [1, 2, 3, 'stringtype', true];
89
+
90
+ expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
91
+ });
92
+
93
+ test('schema array validator tuple schema test for additional items with boolean different datatype', () => {
94
+ let schema = Schema.from({
95
+ type: 'ARRAY',
96
+ items: [
97
+ {
98
+ type: 'INTEGER',
99
+ },
100
+ {
101
+ type: 'STRING',
102
+ },
103
+ {
104
+ type: 'BOOLEAN',
105
+ },
106
+ ],
107
+ additionalItems: {
108
+ schemaValue: {
109
+ type: 'OBJECT',
110
+ },
111
+ },
112
+ });
113
+
114
+ let obj = [1, 'asd', { val: 'stringtype' }, 'stringOnemore'];
115
+
116
+ expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
117
+ });
118
+
119
+ test('multi level validation inner object pollution test', () => {
120
+ let schema = Schema.from({
121
+ type: 'ARRAY',
122
+ items: {
123
+ type: 'OBJECT',
124
+ properties: {
125
+ x: { type: 'INTEGER' },
126
+ },
127
+ },
128
+ defaultValue: [{ x: 20 }, { x: 30 }],
129
+ });
130
+
131
+ let xschema = Schema.from({
132
+ type: 'ARRAY',
133
+ items: {
134
+ type: 'OBJECT',
135
+ properties: {
136
+ x: { type: 'INTEGER' },
137
+ y: { type: 'STRING', defaultValue: 'Kiran' },
138
+ },
139
+ required: ['x'],
140
+ },
141
+ });
142
+
143
+ let value = SchemaValidator.validate(
144
+ undefined,
145
+ xschema,
146
+ repo,
147
+ SchemaValidator.validate(undefined, schema, repo, undefined),
148
+ );
149
+
150
+ expect(schema?.getDefaultValue()[0].y).toBeUndefined();
151
+ expect(value[0].y).toBe('Kiran');
152
+ });
@@ -0,0 +1,23 @@
1
+ import { KIRunSchemaRepository, Schema, SchemaType, SchemaValidator } from '../../../../../src';
2
+
3
+ const repo = new KIRunSchemaRepository();
4
+
5
+ test('schema Object validator test schema based old ARRAY style', () => {
6
+ let schema = Schema.from({
7
+ type: 'OBJECT',
8
+ properties: { name: { type: 'STRING' } },
9
+ additionalProperties: { schemaValue: { type: 'ARRAY' } },
10
+ });
11
+ expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
12
+
13
+ var obj = { name: 'Kiran', num: [1, 2, 3] };
14
+ expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
15
+
16
+ expect(() =>
17
+ SchemaValidator.validate([], schema!, repo, {
18
+ name: 'Kiran',
19
+ num: 23,
20
+ lastName: 'grandhi',
21
+ }),
22
+ ).toThrowError();
23
+ });
@@ -0,0 +1,280 @@
1
+ import {
2
+ HybridRepository,
3
+ KIRunSchemaRepository,
4
+ ObjectValidator,
5
+ Repository,
6
+ Schema,
7
+ SchemaType,
8
+ SchemaValidator,
9
+ } from '../../../../../src';
10
+
11
+ const repo = new KIRunSchemaRepository();
12
+
13
+ test('schema Object validator test boolean value', () => {
14
+ let schema = Schema.from({
15
+ type: 'OBJECT',
16
+ properties: { name: { type: 'STRING' } },
17
+ additionalProperties: false,
18
+ });
19
+ expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
20
+
21
+ expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
22
+ name: 'Kiran',
23
+ });
24
+
25
+ expect(() =>
26
+ SchemaValidator.validate([], schema!, repo, { name: 'Kiran', lastName: 'Grandhi' }),
27
+ ).toThrowError();
28
+ });
29
+
30
+ test('schema Object validator test schema based', () => {
31
+ let schema = Schema.from({
32
+ type: 'OBJECT',
33
+ properties: { name: { type: 'STRING' } },
34
+ additionalProperties: { type: 'INTEGER' },
35
+ });
36
+ expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
37
+
38
+ expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 })).toStrictEqual({
39
+ name: 'Kiran',
40
+ num: 23,
41
+ });
42
+
43
+ expect(() =>
44
+ SchemaValidator.validate([], schema!, repo, {
45
+ name: 'Kiran',
46
+ num: 23,
47
+ lastName: 'grandhi',
48
+ }),
49
+ ).toThrowError();
50
+ });
51
+
52
+ test('schema Object validator test boolean value old style', () => {
53
+ let schema = Schema.from({
54
+ type: 'OBJECT',
55
+ properties: { name: { type: 'STRING' } },
56
+ additionalProperties: { booleanValue: false },
57
+ });
58
+
59
+ expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
60
+ name: 'Kiran',
61
+ });
62
+
63
+ expect(() =>
64
+ SchemaValidator.validate([], schema!, repo, { name: 'Kiran', lastName: 'Grandhi' }),
65
+ ).toThrowError();
66
+ });
67
+
68
+ test('schema Object validator test schema based old style', () => {
69
+ let schema = Schema.from({
70
+ type: 'OBJECT',
71
+ properties: { name: { type: 'STRING' } },
72
+ additionalProperties: { schemaValue: { type: 'INTEGER' } },
73
+ });
74
+ expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
75
+
76
+ expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 })).toStrictEqual({
77
+ name: 'Kiran',
78
+ num: 23,
79
+ });
80
+
81
+ expect(() =>
82
+ SchemaValidator.validate([], schema!, repo, {
83
+ name: 'Kiran',
84
+ num: 23,
85
+ lastName: 'grandhi',
86
+ }),
87
+ ).toThrowError();
88
+ });
89
+
90
+ test('schema Object validator test schema based old ARRAY style', () => {
91
+ let schema = Schema.from({
92
+ type: 'OBJECT',
93
+ properties: { name: { type: 'STRING' } },
94
+ additionalProperties: { schemaValue: { type: 'ARRAY' } },
95
+ });
96
+ expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
97
+
98
+ var obj = { name: 'Kiran', num: [1, 2, 3] };
99
+ expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
100
+
101
+ expect(() =>
102
+ SchemaValidator.validate([], schema!, repo, {
103
+ name: 'Kiran',
104
+ num: 23,
105
+ lastName: 'grandhi',
106
+ }),
107
+ ).toThrowError();
108
+ });
109
+
110
+ test('schema Object validator test schema based old Object style', () => {
111
+ let schema = Schema.from({
112
+ type: 'OBJECT',
113
+ properties: {
114
+ name: { type: 'STRING' },
115
+ lastname: { type: 'STRING' },
116
+ age: { type: 'INTEGER' },
117
+ },
118
+ additionalProperties: { schemaValue: { type: 'OBJECT' } },
119
+ });
120
+
121
+ var obj = { name: 'Kiran', age: 23 };
122
+ expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
123
+
124
+ var objwithAdditional = {
125
+ name: 'Kiran',
126
+ lastname: 'grandhi',
127
+ addresses: {
128
+ area: 'j.p.nagar',
129
+ city: 'banga',
130
+ },
131
+ };
132
+
133
+ expect(SchemaValidator.validate([], schema!, repo, objwithAdditional)).toStrictEqual(
134
+ objwithAdditional,
135
+ );
136
+
137
+ var objwithMoreAdditional = {
138
+ name: 'Kiran',
139
+ lastname: 'grandhi',
140
+ addresses: {
141
+ area: 'j.p.nagar',
142
+ city: 'banga',
143
+ },
144
+ city: 'kakinada',
145
+ };
146
+
147
+ expect(() => SchemaValidator.validate([], schema!, repo, objwithMoreAdditional)).toThrow();
148
+ });
149
+
150
+ test('Schema test with object value as null for any', () => {
151
+ let filterOperator = Schema.from({
152
+ namespace: 'test',
153
+ name: 'filterOperator',
154
+ version: 1,
155
+ type: 'STRING',
156
+ defaultValue: 'EQUALS',
157
+ enums: ['EQUALS', 'LESS_THAN', 'GREATER_THAN', 'LESS_THAN_EQUAL', 'BETWEEN', 'IN'],
158
+ });
159
+
160
+ let filterCondition = Schema.from({
161
+ namespace: 'test',
162
+ name: 'FilterCondition',
163
+ version: 1,
164
+ type: 'OBJECT',
165
+ properties: {
166
+ field: {
167
+ namespace: '_',
168
+ name: 'field',
169
+ version: 1,
170
+ type: 'STRING',
171
+ },
172
+ multiValue: {
173
+ namespace: '_',
174
+ name: 'multiValue',
175
+ version: 1,
176
+ type: 'ARRAY',
177
+ items: {
178
+ namespace: '_',
179
+ name: 'singleType',
180
+ version: 1,
181
+ type: [
182
+ 'FLOAT',
183
+ 'BOOLEAN',
184
+ 'STRING',
185
+ 'DOUBLE',
186
+ 'INTEGER',
187
+ 'LONG',
188
+ 'NULL',
189
+ 'ARRAY',
190
+ 'OBJECT',
191
+ ],
192
+ },
193
+ },
194
+ isValue: {
195
+ namespace: '_',
196
+ name: 'isValue',
197
+ version: 1,
198
+ type: 'BOOLEAN',
199
+ defaultValue: false,
200
+ },
201
+ toValue: {
202
+ namespace: '_',
203
+ name: 'toValue',
204
+ version: 1,
205
+ type: [
206
+ 'FLOAT',
207
+ 'BOOLEAN',
208
+ 'STRING',
209
+ 'DOUBLE',
210
+ 'INTEGER',
211
+ 'LONG',
212
+ 'NULL',
213
+ 'ARRAY',
214
+ 'OBJECT',
215
+ ],
216
+ },
217
+ operator: {
218
+ namespace: '_',
219
+ version: 1,
220
+ ref: 'test.filterOperator',
221
+ },
222
+ negate: {
223
+ namespace: '_',
224
+ name: 'negate',
225
+ version: 1,
226
+ type: 'BOOLEAN',
227
+ defaultValue: false,
228
+ },
229
+ value: {
230
+ namespace: '_',
231
+ name: 'value',
232
+ version: 1,
233
+ type: [
234
+ 'FLOAT',
235
+ 'BOOLEAN',
236
+ 'STRING',
237
+ 'DOUBLE',
238
+ 'INTEGER',
239
+ 'LONG',
240
+ 'NULL',
241
+ 'ARRAY',
242
+ 'OBJECT',
243
+ ],
244
+ },
245
+ isToValue: {
246
+ namespace: '_',
247
+ name: 'isToValue',
248
+ version: 1,
249
+ type: 'BOOLEAN',
250
+ defaultValue: false,
251
+ },
252
+ },
253
+ additionalProperties: false,
254
+ required: ['operator', 'field'],
255
+ });
256
+
257
+ var schemaMap = new Map<string, Schema>();
258
+
259
+ schemaMap.set('filterOperator', filterOperator!);
260
+ schemaMap.set('FilterCondition', filterCondition!);
261
+
262
+ class TestRepository implements Repository<Schema> {
263
+ public find(namespace: string, name: string): Schema | undefined {
264
+ if (!namespace) {
265
+ return undefined;
266
+ }
267
+ return schemaMap.get(name);
268
+ }
269
+
270
+ public filter(name: string): string[] {
271
+ return [];
272
+ }
273
+ }
274
+ var repo = new HybridRepository(new TestRepository(), new KIRunSchemaRepository());
275
+
276
+ var tempOb2 = { field: 'nullcheck', operator: 'LESS_THAN', value: null, isValue: true };
277
+
278
+ var res3 = SchemaValidator.validate(undefined, filterCondition, repo, tempOb2);
279
+ expect(res3).toStrictEqual(tempOb2);
280
+ });
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, ArraySchemaType, HybridRepository } from '../../../../../src';
1
+ import { AdditionalType, ArraySchemaType, HybridRepository } from '../../../../../src';
2
2
  import { Schema } from '../../../../../src/engine/json/schema/Schema';
3
3
  import { SchemaType } from '../../../../../src/engine/json/schema/type/SchemaType';
4
4
  import { TypeUtil } from '../../../../../src/engine/json/schema/type/TypeUtil';
@@ -42,6 +42,12 @@ test('filter condition with ref schema', () => {
42
42
  if (namespace !== 'Test') return undefined;
43
43
  return schemaMap.get(name);
44
44
  },
45
+
46
+ filter(name: string): string[] {
47
+ return Array.from(schemaMap.values())
48
+ .filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
49
+ .map((e) => e.getFullName());
50
+ },
45
51
  },
46
52
  new KIRunSchemaRepository(),
47
53
  );
@@ -86,6 +92,11 @@ test('complex condition with ref schema', () => {
86
92
  if (namespace !== 'Test') return undefined;
87
93
  return schemaMap.get(name);
88
94
  },
95
+ filter(name: string): string[] {
96
+ return Array.from(schemaMap.values())
97
+ .filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
98
+ .map((e) => e.getFullName());
99
+ },
89
100
  },
90
101
  new KIRunSchemaRepository(),
91
102
  );
@@ -142,7 +153,7 @@ test('filter complex condition with ref schema', () => {
142
153
  ]),
143
154
  )
144
155
  .setRequired(['operator', 'field'])
145
- .setAdditionalProperties(new AdditionalPropertiesType().setBooleanValue(false));
156
+ .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
146
157
 
147
158
  let complexOperator: Schema = Schema.ofString('complexOperator')
148
159
  .setNamespace('Test')
@@ -163,7 +174,7 @@ test('filter complex condition with ref schema', () => {
163
174
  ]),
164
175
  )
165
176
  .setRequired(['conditions', 'operator'])
166
- .setAdditionalProperties(new AdditionalPropertiesType().setBooleanValue(false));
177
+ .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
167
178
 
168
179
  var schemaMap = new Map<string, Schema>([
169
180
  ['filterOperator', filterOperator],
@@ -178,6 +189,12 @@ test('filter complex condition with ref schema', () => {
178
189
  if (namespace !== 'Test') return undefined;
179
190
  return schemaMap.get(name);
180
191
  },
192
+
193
+ filter(name: string): string[] {
194
+ return Array.from(schemaMap.values())
195
+ .filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
196
+ .map((e) => e.getFullName());
197
+ },
181
198
  },
182
199
  new KIRunSchemaRepository(),
183
200
  );
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, HybridRepository } from '../../../../../src';
1
+ import { AdditionalType, HybridRepository } from '../../../../../src';
2
2
  import { Schema } from '../../../../../src/engine/json/schema/Schema';
3
3
  import { SchemaType } from '../../../../../src/engine/json/schema/type/SchemaType';
4
4
  import { TypeUtil } from '../../../../../src/engine/json/schema/type/TypeUtil';
@@ -39,15 +39,13 @@ test('Schema validation when ref of ref', () => {
39
39
 
40
40
  const urlParamsSchema = Schema.ofObject('UrlParameters')
41
41
  .setNamespace('Test')
42
- .setAdditionalProperties(
43
- new AdditionalPropertiesType().setSchemaValue(Schema.ofRef(`Test.Location`)),
44
- )
42
+ .setAdditionalProperties(new AdditionalType().setSchemaValue(Schema.ofRef(`Test.Location`)))
45
43
  .setDefaultValue({});
46
44
 
47
45
  const testSchema = Schema.ofObject('TestSchema')
48
46
  .setNamespace('Test')
49
47
  .setAdditionalProperties(
50
- new AdditionalPropertiesType().setSchemaValue(Schema.ofRef(`Test.UrlParameters`)),
48
+ new AdditionalType().setSchemaValue(Schema.ofRef(`Test.UrlParameters`)),
51
49
  )
52
50
  .setDefaultValue({});
53
51
 
@@ -63,6 +61,12 @@ test('Schema validation when ref of ref', () => {
63
61
  if (namespace !== 'Test') return undefined;
64
62
  return schemaMap.get(name);
65
63
  },
64
+
65
+ filter(name: string): string[] {
66
+ return Array.from(schemaMap.values())
67
+ .map((e) => e!.getFullName())
68
+ .filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1);
69
+ },
66
70
  },
67
71
  new KIRunSchemaRepository(),
68
72
  );
@@ -95,6 +99,11 @@ test('Schema Validator Test 2', () => {
95
99
  }
96
100
  return undefined;
97
101
  },
102
+ filter(name): string[] {
103
+ return [locationSchema!.getFullName()].filter((n) =>
104
+ n.toLowerCase().includes(name.toLowerCase()),
105
+ );
106
+ },
98
107
  },
99
108
  new KIRunSchemaRepository(),
100
109
  );
@@ -132,7 +141,14 @@ test('Schema Validator Test 3', () => {
132
141
  }
133
142
  return undefined;
134
143
  },
144
+
145
+ filter(name): string[] {
146
+ return [locationSchema!.getFullName()].filter((n) =>
147
+ n.toLowerCase().includes(name.toLowerCase()),
148
+ );
149
+ },
135
150
  },
151
+
136
152
  new KIRunSchemaRepository(),
137
153
  );
138
154
 
@@ -129,7 +129,5 @@ test('String email valid case', () => {
129
129
 
130
130
  let schema: Schema = new Schema().setFormat(StringFormat.EMAIL);
131
131
 
132
- console.log(StringValidator.validate([], schema, value));
133
-
134
132
  expect(StringValidator.validate([], schema, value)).toBe(value);
135
133
  });
@@ -0,0 +1,39 @@
1
+ import { KIRunSchemaRepository, KIRunFunctionRepository } from '../../../src';
2
+
3
+ const funcRepo = new KIRunFunctionRepository();
4
+ const schemaRepo = new KIRunSchemaRepository();
5
+
6
+ test('Repository Filter Test', () => {
7
+ expect(funcRepo.filter('Rep')).toStrictEqual([
8
+ 'System.String.Repeat',
9
+ 'System.String.Replace',
10
+ 'System.String.ReplaceFirst',
11
+ 'System.String.PrePad',
12
+ 'System.String.ReplaceAtGivenPosition',
13
+ ]);
14
+
15
+ expect(funcRepo.filter('root')).toStrictEqual([
16
+ 'System.Math.CubeRoot',
17
+ 'System.Math.SquareRoot',
18
+ ]);
19
+
20
+ expect(schemaRepo.filter('root')).toStrictEqual([]);
21
+
22
+ expect(schemaRepo.filter('rin')).toStrictEqual(['System.string']);
23
+
24
+ expect(schemaRepo.filter('ny')).toStrictEqual(['System.any']);
25
+
26
+ expect(schemaRepo.filter('')).toStrictEqual([
27
+ 'System.any',
28
+ 'System.boolean',
29
+ 'System.double',
30
+ 'System.float',
31
+ 'System.integer',
32
+ 'System.long',
33
+ 'System.number',
34
+ 'System.string',
35
+ 'System.ParameterExpression',
36
+ 'System.Null',
37
+ 'System.Schema',
38
+ ]);
39
+ });
@@ -149,6 +149,12 @@ test('KIRuntime Function in Function', async () => {
149
149
  if (name === 'Third') return third;
150
150
  if (name === 'Second') return second;
151
151
  }
152
+
153
+ filter(name: string): string[] {
154
+ return [third.getSignature().getFullName(), second.getSignature().getFullName()].filter(
155
+ (e) => e.toLowerCase().includes(name.toLowerCase()),
156
+ );
157
+ }
152
158
  }
153
159
 
154
160
  const repo = new HybridRepository(new KIRunFunctionRepository(), new InternalRepository());