@fincity/kirun-js 1.5.0 → 1.6.1

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 (37) hide show
  1. package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +339 -0
  2. package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +191 -0
  3. package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +152 -0
  4. package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +23 -0
  5. package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +280 -0
  6. package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +243 -0
  7. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +21 -5
  8. package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +0 -2
  9. package/__tests__/engine/repository/RepositoryFilterTest.ts +39 -0
  10. package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +6 -0
  11. package/__tests__/engine/runtime/KIRuntimeTest.ts +6 -0
  12. package/__tests__/indexTest.ts +12 -0
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/module.js +1 -1
  16. package/dist/module.js.map +1 -1
  17. package/dist/types.d.ts +21 -10
  18. package/dist/types.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/engine/HybridRepository.ts +8 -0
  21. package/src/engine/Repository.ts +1 -0
  22. package/src/engine/function/system/Print.ts +1 -1
  23. package/src/engine/function/system/array/ArrayFunctionRepository.ts +10 -0
  24. package/src/engine/function/system/math/MathFunctionRepository.ts +10 -1
  25. package/src/engine/function/system/string/StringFunctionRepository.ts +10 -0
  26. package/src/engine/json/schema/Schema.ts +82 -32
  27. package/src/engine/json/schema/SchemaUtil.ts +6 -3
  28. package/src/engine/json/schema/array/ArraySchemaType.ts +3 -2
  29. package/src/engine/json/schema/validator/ArrayValidator.ts +135 -24
  30. package/src/engine/json/schema/validator/ObjectValidator.ts +9 -4
  31. package/src/engine/model/Event.ts +2 -2
  32. package/src/engine/model/FunctionDefinition.ts +3 -3
  33. package/src/engine/model/FunctionSignature.ts +6 -3
  34. package/src/engine/model/Statement.ts +4 -6
  35. package/src/engine/repository/KIRunFunctionRepository.ts +9 -0
  36. package/src/engine/repository/KIRunSchemaRepository.ts +8 -0
  37. package/src/engine/runtime/expression/tokenextractor/LiteralTokenValueExtractor.ts +1 -0
@@ -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
+ });
@@ -0,0 +1,243 @@
1
+ import { AdditionalType, ArraySchemaType, HybridRepository } from '../../../../../src';
2
+ import { Schema } from '../../../../../src/engine/json/schema/Schema';
3
+ import { SchemaType } from '../../../../../src/engine/json/schema/type/SchemaType';
4
+ import { TypeUtil } from '../../../../../src/engine/json/schema/type/TypeUtil';
5
+ import { SchemaValidationException } from '../../../../../src/engine/json/schema/validator/exception/SchemaValidationException';
6
+ import { SchemaValidator } from '../../../../../src/engine/json/schema/validator/SchemaValidator';
7
+ import { KIRunSchemaRepository } from '../../../../../src/engine/repository/KIRunSchemaRepository';
8
+
9
+ test('filter condition with ref schema', () => {
10
+ let filterOperator: Schema = Schema.ofString('filterOperator')
11
+ .setNamespace('Test')
12
+ .setEnums(['EQUALS', 'LESS_THAN', 'GREATER_THAN', 'LESS_THAN_EQUAL']);
13
+
14
+ let filterCondition: Schema = Schema.ofObject('filterCondition')
15
+ .setNamespace('Test')
16
+ .setProperties(
17
+ new Map<string, Schema>([
18
+ ['negate', Schema.ofBoolean('negate')],
19
+ ['filterConditionOperator', Schema.ofRef('Test.filterOperator')],
20
+ ['field', Schema.ofString('field')],
21
+ ['value', Schema.ofAny('value')],
22
+ ['toValue', Schema.ofAny('toValue')],
23
+ [
24
+ 'multiValue',
25
+ Schema.ofArray('multiValue').setItems(
26
+ new ArraySchemaType().setSingleSchema(Schema.ofAny('singleType')),
27
+ ),
28
+ ],
29
+ ['isValue', Schema.ofBoolean('isValue')],
30
+ ['isToValue', Schema.ofBoolean('isToValue')],
31
+ ]),
32
+ );
33
+
34
+ var schemaMap = new Map<string, Schema>([
35
+ ['filterOperator', filterOperator],
36
+ ['filterCondition', filterCondition],
37
+ ]);
38
+
39
+ const repo = new HybridRepository<Schema>(
40
+ {
41
+ find(namespace: string, name: string): Schema | undefined {
42
+ if (namespace !== 'Test') return undefined;
43
+ return schemaMap.get(name);
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
+ },
51
+ },
52
+ new KIRunSchemaRepository(),
53
+ );
54
+
55
+ var tempOb = {
56
+ field: 'a.b.c.d',
57
+ value: 'surendhar',
58
+ filterConditionOperator: 'LESS_THAN',
59
+ negate: true,
60
+ isValue: false,
61
+ };
62
+
63
+ expect(SchemaValidator.validate([], filterCondition, repo, tempOb)).toBe(tempOb);
64
+ });
65
+
66
+ test('complex condition with ref schema', () => {
67
+ let complexOperator: Schema = Schema.ofString('complexOperator')
68
+ .setNamespace('Test')
69
+ .setEnums(['AND', 'OR']);
70
+
71
+ // let arraySchema: Schema = Schema.ofArray('conditions', Schema.ofRef('#'));
72
+ let arraySchema: Schema = Schema.ofArray('conditions', Schema.ofRef('Test.complexCondition'));
73
+
74
+ let complexCondition: Schema = Schema.ofObject('complexCondition')
75
+ .setNamespace('Test')
76
+ .setProperties(
77
+ new Map<string, Schema>([
78
+ ['negate', Schema.ofBoolean('negate')],
79
+ ['complexConditionOperator', Schema.ofRef('Test.complexOperator')],
80
+ ['conditions', arraySchema],
81
+ ]),
82
+ );
83
+
84
+ var schemaMap = new Map<string, Schema>([
85
+ ['complexOperator', complexOperator],
86
+ ['complexCondition', complexCondition],
87
+ ]);
88
+
89
+ const repo = new HybridRepository<Schema>(
90
+ {
91
+ find(namespace: string, name: string): Schema | undefined {
92
+ if (namespace !== 'Test') return undefined;
93
+ return schemaMap.get(name);
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
+ },
100
+ },
101
+ new KIRunSchemaRepository(),
102
+ );
103
+
104
+ let ja: any[] = [];
105
+
106
+ let mjob = {
107
+ conditions: [...ja],
108
+ negate: true,
109
+ complexConditionOperator: 'AND',
110
+ };
111
+
112
+ let njob = {
113
+ conditions: [...ja],
114
+ negate: true,
115
+ complexConditionOperator: 'OR',
116
+ };
117
+
118
+ ja.push(mjob);
119
+ ja.push(njob);
120
+
121
+ let bjob = {
122
+ conditions: [...ja],
123
+ negate: true,
124
+ complexConditionOperator: 'AND',
125
+ };
126
+
127
+ expect(SchemaValidator.validate([], complexCondition, repo, bjob)).toBe(bjob);
128
+ });
129
+
130
+ test('filter complex condition with ref schema', () => {
131
+ let filterOperator: Schema = Schema.ofString('filterOperator')
132
+ .setNamespace('Test')
133
+ .setEnums(['EQUALS', 'LESS_THAN', 'GREATER_THAN', 'LESS_THAN_EQUAL', 'IN'])
134
+ .setDefaultValue('EQUALS');
135
+
136
+ let filterCondition: Schema = Schema.ofObject('filterCondition')
137
+ .setNamespace('Test')
138
+ .setProperties(
139
+ new Map<string, Schema>([
140
+ ['negate', Schema.ofBoolean('negate').setDefaultValue(false)],
141
+ ['operator', Schema.ofRef('Test.filterOperator')],
142
+ ['field', Schema.ofString('field')],
143
+ ['value', Schema.ofAny('value')],
144
+ ['toValue', Schema.ofAny('toValue')],
145
+ [
146
+ 'multiValue',
147
+ Schema.ofArray('multiValue').setItems(
148
+ new ArraySchemaType().setSingleSchema(Schema.ofAny('singleType')),
149
+ ),
150
+ ],
151
+ ['isValue', Schema.ofBoolean('isValue').setDefaultValue(false)],
152
+ ['isToValue', Schema.ofBoolean('isToValue').setDefaultValue(false)],
153
+ ]),
154
+ )
155
+ .setRequired(['operator', 'field'])
156
+ .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
157
+
158
+ let complexOperator: Schema = Schema.ofString('complexOperator')
159
+ .setNamespace('Test')
160
+ .setEnums(['AND', 'OR']);
161
+
162
+ let arraySchema: Schema = Schema.ofArray(
163
+ 'conditions',
164
+ new Schema().setAnyOf([Schema.ofRef('#'), Schema.ofRef('Test.FilterCondition')]),
165
+ );
166
+
167
+ let complexCondition: Schema = Schema.ofObject('complexCondition')
168
+ .setNamespace('Test')
169
+ .setProperties(
170
+ new Map<string, Schema>([
171
+ ['conditions', arraySchema],
172
+ ['negate', Schema.ofBoolean('negate').setDefaultValue(false)],
173
+ ['operator', Schema.ofRef('Test.complexOperator')],
174
+ ]),
175
+ )
176
+ .setRequired(['conditions', 'operator'])
177
+ .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
178
+
179
+ var schemaMap = new Map<string, Schema>([
180
+ ['filterOperator', filterOperator],
181
+ ['filterCondition', filterCondition],
182
+ ['complexOperator', complexOperator],
183
+ ['complexCondition', complexCondition],
184
+ ]);
185
+
186
+ const repo = new HybridRepository<Schema>(
187
+ {
188
+ find(namespace: string, name: string): Schema | undefined {
189
+ if (namespace !== 'Test') return undefined;
190
+ return schemaMap.get(name);
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
+ },
198
+ },
199
+ new KIRunSchemaRepository(),
200
+ );
201
+
202
+ var tempOb = {
203
+ field: 'a.b.c.d',
204
+ value: 'surendhar',
205
+ operator: 'LESS_THAN',
206
+ negate: true,
207
+ isValue: false,
208
+ };
209
+
210
+ var tempOb1 = {
211
+ ...tempOb,
212
+ operator: 'GREATER_THAN',
213
+ isValue: true,
214
+ };
215
+
216
+ var tempOb2 = {
217
+ field: 'k.lm.mno',
218
+ operator: 'IN',
219
+ multiValue: [1, 2, 3, 4, 5, 5, 6, 7],
220
+ negate: true,
221
+ };
222
+ var ja: any[] = [];
223
+
224
+ ja.push(tempOb);
225
+ ja.push(tempOb1);
226
+ ja.push(tempOb2);
227
+
228
+ var mjob = {
229
+ conditions: [],
230
+ negate: false,
231
+ operator: 'AND',
232
+ };
233
+
234
+ var bjob = {
235
+ conditions: [mjob],
236
+ negate: true,
237
+ operator: 'OR',
238
+ };
239
+
240
+ var res = SchemaValidator.validate([], complexCondition, repo, bjob);
241
+
242
+ expect(res).toBe(bjob);
243
+ });
@@ -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());
@@ -344,6 +344,12 @@ test('KIRuntime Test 4', async () => {
344
344
  find(namespace, name): Function {
345
345
  return fibFunction;
346
346
  },
347
+
348
+ filter(name: string): string[] {
349
+ return [fibFunction.getSignature().getFullName()].filter((e) =>
350
+ e.toLowerCase().includes(name.toLowerCase()),
351
+ );
352
+ },
347
353
  });
348
354
 
349
355
  start = new Date().getTime();
@@ -9,6 +9,12 @@ class TestRepository {
9
9
  find(namespace: string, name: string): string | undefined {
10
10
  return TestRepository.TEST_INDEX.get(name);
11
11
  }
12
+
13
+ filter(name: string): string[] {
14
+ return Array.from(TestRepository.TEST_INDEX.keys()).filter(
15
+ (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
16
+ );
17
+ }
12
18
  }
13
19
 
14
20
  class TestRepository2 {
@@ -20,6 +26,12 @@ class TestRepository2 {
20
26
  find(namespace: string, name: string): string | undefined {
21
27
  return TestRepository2.TEST_INDEX.get(name);
22
28
  }
29
+
30
+ filter(name: string): string[] {
31
+ return Array.from(TestRepository.TEST_INDEX.keys()).filter(
32
+ (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
33
+ );
34
+ }
23
35
  }
24
36
 
25
37
  test('Hybrid Repository Test', () => {