@fincity/kirun-js 1.9.1 → 2.0.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 (53) hide show
  1. package/__tests__/engine/function/system/math/MathFunctionRepositoryTest.ts +118 -75
  2. package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +3 -3
  3. package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +2 -2
  4. package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +8 -8
  5. package/__tests__/engine/json/schema/SchemaUtil.ts +1 -1
  6. package/__tests__/engine/json/schema/type/TypeUtilTest.ts +1 -1
  7. package/__tests__/engine/json/schema/validator/AnyOfAllOfOneOfValidatorTest.ts +24 -19
  8. package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +22 -22
  9. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +10 -10
  10. package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +22 -22
  11. package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +13 -13
  12. package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +10 -9
  13. package/__tests__/engine/json/schema/validator/NullValidatorTest.ts +6 -6
  14. package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +4 -4
  15. package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +32 -28
  16. package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +184 -182
  17. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +43 -32
  18. package/__tests__/engine/json/schema/validator/StringFormatSchemaValidatorTest.ts +24 -24
  19. package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +14 -14
  20. package/__tests__/engine/repository/KIRunFunctionRepositoryTest.ts +7 -7
  21. package/__tests__/engine/repository/RepositoryFilterTest.ts +7 -7
  22. package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +11 -7
  23. package/__tests__/engine/runtime/KIRuntimeNoParamMapTest.ts +2 -2
  24. package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +2 -2
  25. package/__tests__/engine/runtime/KIRuntimeTest.ts +8 -6
  26. package/__tests__/engine/runtime/KIRuntimeTestWithoutGenEvent.ts +4 -1
  27. package/__tests__/engine/runtime/KIRuntimeUndefinedParamTest.ts +23 -26
  28. package/__tests__/engine/runtime/KIRuntimeValuesEmptyTest.ts +6 -6
  29. package/__tests__/indexTest.ts +10 -10
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/module.js +1 -1
  33. package/dist/module.js.map +1 -1
  34. package/dist/types.d.ts +17 -17
  35. package/dist/types.d.ts.map +1 -1
  36. package/package.json +4 -4
  37. package/src/engine/HybridRepository.ts +5 -5
  38. package/src/engine/Repository.ts +2 -2
  39. package/src/engine/function/AbstractFunction.ts +35 -31
  40. package/src/engine/function/system/array/ArrayFunctionRepository.ts +8 -6
  41. package/src/engine/function/system/math/MathFunctionRepository.ts +7 -5
  42. package/src/engine/function/system/object/ObjectFunctionRepository.ts +7 -5
  43. package/src/engine/function/system/string/StringFunctionRepository.ts +8 -6
  44. package/src/engine/json/schema/SchemaUtil.ts +33 -30
  45. package/src/engine/json/schema/validator/ArrayValidator.ts +25 -20
  46. package/src/engine/json/schema/validator/ObjectValidator.ts +32 -14
  47. package/src/engine/json/schema/validator/SchemaValidator.ts +15 -11
  48. package/src/engine/json/schema/validator/TypeValidator.ts +5 -5
  49. package/src/engine/repository/KIRunFunctionRepository.ts +3 -2
  50. package/src/engine/repository/KIRunSchemaRepository.ts +7 -5
  51. package/src/engine/runtime/KIRuntime.ts +14 -14
  52. package/src/engine/util/duplicate.ts +1 -1
  53. package/tsconfig.json +6 -2
@@ -10,10 +10,10 @@ import {
10
10
 
11
11
  const repo = new KIRunSchemaRepository();
12
12
 
13
- test('Schema Validator fail with date test', () => {
13
+ test('Schema Validator fail with date test', async () => {
14
14
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER));
15
15
 
16
- expect(SchemaValidator.validate([], schema, repo, 2)).toBe(2);
16
+ expect(await SchemaValidator.validate([], schema, repo, 2)).toBe(2);
17
17
 
18
18
  let obj = { name: 'shagil' };
19
19
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -25,17 +25,17 @@ test('Schema Validator fail with date test', () => {
25
25
  )
26
26
  .setRequired(['name', 'date']);
27
27
 
28
- expect(() => SchemaValidator.validate([], objSchema, repo, obj)).toThrow('date is mandatory');
28
+ expect(SchemaValidator.validate([], objSchema, repo, obj)).rejects.toThrow('date is mandatory');
29
29
  const dateObj = { name: 'surendhar.s', date: '1999-13-12' };
30
30
  const errorMsg =
31
31
  'Value {"name":"surendhar.s","date":"1999-13-12"} is not of valid type(s)' +
32
32
  '\n' +
33
33
  'Type is missing in schema for declared DATE format.';
34
34
 
35
- expect(() => SchemaValidator.validate([], objSchema, repo, dateObj)).toThrow(errorMsg);
35
+ expect(SchemaValidator.validate([], objSchema, repo, dateObj)).rejects.toThrow(errorMsg);
36
36
  });
37
37
 
38
- test('Schema Validator pass with date test ', () => {
38
+ test('Schema Validator pass with date test ', async () => {
39
39
  let intSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER)).setMinimum(100);
40
40
 
41
41
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -55,10 +55,10 @@ test('Schema Validator pass with date test ', () => {
55
55
 
56
56
  const dateObj = { intSchema: 1231, date: '1999-09-12' };
57
57
 
58
- expect(SchemaValidator.validate([], objSchema, repo, dateObj)).toBe(dateObj);
58
+ expect(await SchemaValidator.validate([], objSchema, repo, dateObj)).toBe(dateObj);
59
59
  });
60
60
 
61
- test('Schema Validator fail with time string type missing test ', () => {
61
+ test('Schema Validator fail with time string type missing test ', async () => {
62
62
  let intSchema: Schema = new Schema()
63
63
  .setType(TypeUtil.of(SchemaType.INTEGER))
64
64
  .setMaximum(100)
@@ -80,10 +80,10 @@ test('Schema Validator fail with time string type missing test ', () => {
80
80
  'Value {"intSchema":95,"time":"22:23:61","name":"s.surendhar"} is not of valid type(s)\n' +
81
81
  'Type is missing in schema for declared TIME format.';
82
82
 
83
- expect(() => SchemaValidator.validate([], objSchema, repo, timeObj)).toThrow(errMsg);
83
+ expect(SchemaValidator.validate([], objSchema, repo, timeObj)).rejects.toThrow(errMsg);
84
84
  });
85
85
 
86
- test('Schema Validator fail with time test ', () => {
86
+ test('Schema Validator fail with time test ', async () => {
87
87
  let intSchema: Schema = new Schema()
88
88
  .setType(TypeUtil.of(SchemaType.INTEGER))
89
89
  .setMaximum(100)
@@ -111,10 +111,10 @@ test('Schema Validator fail with time test ', () => {
111
111
  'Value "22:23:61" is not of valid type(s)\n' +
112
112
  '22:23:61 is not matched with the time pattern';
113
113
 
114
- expect(() => SchemaValidator.validate([], objSchema, repo, timeObj)).toThrow(errMsg);
114
+ expect(SchemaValidator.validate([], objSchema, repo, timeObj)).rejects.toThrow(errMsg);
115
115
  });
116
116
 
117
- test('Schema Validator pass with time test ', () => {
117
+ test('Schema Validator pass with time test ', async () => {
118
118
  let intSchema: Schema = new Schema()
119
119
  .setType(TypeUtil.of(SchemaType.INTEGER))
120
120
  .setMaximum(100)
@@ -137,10 +137,10 @@ test('Schema Validator pass with time test ', () => {
137
137
 
138
138
  const timeObj = { intSchema: 95, time: '22:23:24', name: 's.surendhar' };
139
139
 
140
- expect(SchemaValidator.validate([], objSchema, repo, timeObj)).toBe(timeObj);
140
+ expect(await SchemaValidator.validate([], objSchema, repo, timeObj)).toBe(timeObj);
141
141
  });
142
142
 
143
- test('Schema Validator fail with email string type missing test ', () => {
143
+ test('Schema Validator fail with email string type missing test ', async () => {
144
144
  let intSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER)).setMaximum(100);
145
145
 
146
146
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -159,10 +159,10 @@ test('Schema Validator fail with email string type missing test ', () => {
159
159
  'Value {"intSchema":95,"email":"iosdjfdf123--@gmail.com","name":"s.surendhar"} is not of valid type(s)\n' +
160
160
  'Type is missing in schema for declared EMAIL format.';
161
161
 
162
- expect(() => SchemaValidator.validate([], objSchema, repo, emailObj)).toThrow(errMsg);
162
+ expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
163
163
  });
164
164
 
165
- test('Schema Validator fail with email test ', () => {
165
+ test('Schema Validator fail with email test ', async () => {
166
166
  let intSchema: Schema = new Schema()
167
167
  .setType(TypeUtil.of(SchemaType.INTEGER))
168
168
  .setMaximum(3)
@@ -190,10 +190,10 @@ test('Schema Validator fail with email test ', () => {
190
190
  'Value "asdasdf@@*.com" is not of valid type(s)\n' +
191
191
  'asdasdf@@*.com is not matched with the email pattern';
192
192
 
193
- expect(() => SchemaValidator.validate([], objSchema, repo, emailObj)).toThrow(errMsg);
193
+ expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
194
194
  });
195
195
 
196
- test('Schema Validator pass with time test ', () => {
196
+ test('Schema Validator pass with time test ', async () => {
197
197
  let intSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER));
198
198
 
199
199
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -213,10 +213,10 @@ test('Schema Validator pass with time test ', () => {
213
213
 
214
214
  const emailObj = { intSchema: 95, email: 'surendhar.s@finc.c', name: 's.surendhar' };
215
215
 
216
- expect(SchemaValidator.validate([], objSchema, repo, emailObj)).toBe(emailObj);
216
+ expect(await SchemaValidator.validate([], objSchema, repo, emailObj)).toBe(emailObj);
217
217
  });
218
218
 
219
- test('Schema Validator fail with dateTime string type missing test ', () => {
219
+ test('Schema Validator fail with dateTime string type missing test ', async () => {
220
220
  let intSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER)).setMaximum(100);
221
221
 
222
222
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -235,10 +235,10 @@ test('Schema Validator fail with dateTime string type missing test ', () => {
235
235
  'Value {"intSchema":95,"dateTime":"2023-08-21T07:56:45+12:12","name":"s.surendhar"} is not of valid type(s)\n' +
236
236
  'Type is missing in schema for declared DATETIME format.';
237
237
 
238
- expect(() => SchemaValidator.validate([], objSchema, repo, emailObj)).toThrow(errMsg);
238
+ expect(SchemaValidator.validate([], objSchema, repo, emailObj)).rejects.toThrow(errMsg);
239
239
  });
240
240
 
241
- test('Schema Validator fail with dateTime test ', () => {
241
+ test('Schema Validator fail with dateTime test ', async () => {
242
242
  let intSchema: Schema = new Schema()
243
243
  .setType(TypeUtil.of(SchemaType.INTEGER))
244
244
  .setMaximum(3)
@@ -266,10 +266,10 @@ test('Schema Validator fail with dateTime test ', () => {
266
266
  'Value "2023-08-221T07:56:45+12:12" is not of valid type(s)\n' +
267
267
  '2023-08-221T07:56:45+12:12 is not matched with the date time pattern';
268
268
 
269
- expect(() => SchemaValidator.validate([], objSchema, repo, dateTimeObj)).toThrow(errMsg);
269
+ expect(SchemaValidator.validate([], objSchema, repo, dateTimeObj)).rejects.toThrow(errMsg);
270
270
  });
271
271
 
272
- test('Schema Validator pass with time test ', () => {
272
+ test('Schema Validator pass with time test ', async () => {
273
273
  let intSchema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER));
274
274
 
275
275
  let objSchema: Schema = Schema.ofObject('testObj')
@@ -293,7 +293,7 @@ test('Schema Validator pass with time test ', () => {
293
293
  name: 's.surendhar',
294
294
  };
295
295
 
296
- expect(SchemaValidator.validate([], objSchema, repo, dateTimeObj)).toBe(dateTimeObj);
296
+ expect(await SchemaValidator.validate([], objSchema, repo, dateTimeObj)).toBe(dateTimeObj);
297
297
  });
298
298
 
299
299
  const dateTimeObj = { dateTime: '2023-08-21T07:56:45+12:12' };
@@ -9,20 +9,20 @@ import { StringValidator } from '../../../../../src';
9
9
 
10
10
  const repo = new KIRunSchemaRepository();
11
11
 
12
- test('String valid case', () => {
12
+ test('String valid case', async () => {
13
13
  let value: String = 'surendhar';
14
14
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING));
15
15
 
16
16
  expect(StringValidator.validate([], schema, value)).toBe(value);
17
17
  });
18
18
 
19
- test('String invalid case', () => {
19
+ test('String invalid case', async () => {
20
20
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING));
21
21
 
22
22
  expect(() => StringValidator.validate([], schema, 123).toThrow(123 + ' is not String'));
23
23
  });
24
24
 
25
- test('String min length invalid', () => {
25
+ test('String min length invalid', async () => {
26
26
  let value: String = 'abcd';
27
27
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING)).setMinLength(5);
28
28
 
@@ -33,7 +33,7 @@ test('String min length invalid', () => {
33
33
  );
34
34
  });
35
35
 
36
- test('String max length invalid', () => {
36
+ test('String max length invalid', async () => {
37
37
  let value: String = 'surendhar';
38
38
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING)).setMaxLength(8);
39
39
 
@@ -44,21 +44,21 @@ test('String max length invalid', () => {
44
44
  );
45
45
  });
46
46
 
47
- test('String min length', () => {
47
+ test('String min length', async () => {
48
48
  let value: String = 'abcdefg';
49
49
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING)).setMinLength(5);
50
50
 
51
51
  expect(StringValidator.validate([], schema, value)).toBe(value);
52
52
  });
53
53
 
54
- test('String max length', () => {
54
+ test('String max length', async () => {
55
55
  let value: String = 'surendhar';
56
56
  let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.STRING)).setMaxLength(12323);
57
57
 
58
58
  expect(StringValidator.validate([], schema, value)).toBe(value);
59
59
  });
60
60
 
61
- test('String date invalid case', () => {
61
+ test('String date invalid case', async () => {
62
62
  let value: String = '1234-12-1245';
63
63
 
64
64
  let schema: Schema = new Schema().setFormat(StringFormat.DATE);
@@ -70,7 +70,7 @@ test('String date invalid case', () => {
70
70
  );
71
71
  });
72
72
 
73
- test('String date valid case', () => {
73
+ test('String date valid case', async () => {
74
74
  let value: String = '2023-01-26';
75
75
 
76
76
  let schema: Schema = new Schema().setFormat(StringFormat.DATE);
@@ -78,7 +78,7 @@ test('String date valid case', () => {
78
78
  expect(StringValidator.validate([], schema, value)).toBe(value);
79
79
  });
80
80
 
81
- test('String time invalid case', () => {
81
+ test('String time invalid case', async () => {
82
82
  let value: String = '231:45:56';
83
83
 
84
84
  let schema: Schema = new Schema().setFormat(StringFormat.TIME);
@@ -88,7 +88,7 @@ test('String time invalid case', () => {
88
88
  );
89
89
  });
90
90
 
91
- test('String time valid case', () => {
91
+ test('String time valid case', async () => {
92
92
  let value: String = '22:32:45';
93
93
 
94
94
  let schema: Schema = new Schema().setFormat(StringFormat.TIME);
@@ -96,7 +96,7 @@ test('String time valid case', () => {
96
96
  expect(StringValidator.validate([], schema, value)).toBe(value);
97
97
  });
98
98
 
99
- test('String date time invalid case', () => {
99
+ test('String date time invalid case', async () => {
100
100
  let value: String = '26-jan-2023 231:45:56';
101
101
 
102
102
  let schema: Schema = new Schema().setFormat(StringFormat.DATETIME);
@@ -106,7 +106,7 @@ test('String date time invalid case', () => {
106
106
  );
107
107
  });
108
108
 
109
- test('String date time valid case', () => {
109
+ test('String date time valid case', async () => {
110
110
  let value: String = '2032-02-12T02:54:23';
111
111
 
112
112
  let schema: Schema = new Schema().setFormat(StringFormat.DATETIME);
@@ -114,7 +114,7 @@ test('String date time valid case', () => {
114
114
  expect(StringValidator.validate([], schema, value)).toBe(value);
115
115
  });
116
116
 
117
- test('String email invalid case', () => {
117
+ test('String email invalid case', async () => {
118
118
  let value: String = 'testemail fai%6&8ls@gmail.com';
119
119
 
120
120
  let schema: Schema = new Schema().setFormat(StringFormat.EMAIL);
@@ -124,7 +124,7 @@ test('String email invalid case', () => {
124
124
  );
125
125
  });
126
126
 
127
- test('String email valid case', () => {
127
+ test('String email valid case', async () => {
128
128
  let value: String = 'testemaifai%6&8lworkings@magil.com';
129
129
 
130
130
  let schema: Schema = new Schema().setFormat(StringFormat.EMAIL);
@@ -1,29 +1,29 @@
1
1
  import { KIRunFunctionRepository, Namespaces } from '../../../src';
2
2
 
3
- test('KIRunFunctionRepository Test', () => {
3
+ test('KIRunFunctionRepository Test', async () => {
4
4
  const repo = new KIRunFunctionRepository();
5
5
 
6
- let fun = repo.find(Namespaces.STRING, 'ToString');
6
+ let fun = await repo.find(Namespaces.STRING, 'ToString');
7
7
  expect(fun).toBeTruthy();
8
8
  expect(fun?.getSignature().getName()).toBe('ToString');
9
9
 
10
- fun = repo.find(Namespaces.STRING, 'IndexOfWithStartPoint');
10
+ fun = await repo.find(Namespaces.STRING, 'IndexOfWithStartPoint');
11
11
  expect(fun).toBeTruthy();
12
12
  expect(fun?.getSignature().getName()).toBe('IndexOfWithStartPoint');
13
13
 
14
- fun = repo.find(Namespaces.SYSTEM_ARRAY, 'Compare');
14
+ fun = await repo.find(Namespaces.SYSTEM_ARRAY, 'Compare');
15
15
  expect(fun).toBeTruthy();
16
16
  expect(fun?.getSignature().getName()).toBe('Compare');
17
17
 
18
- fun = repo.find(Namespaces.MATH, 'RandomInt');
18
+ fun = await repo.find(Namespaces.MATH, 'RandomInt');
19
19
  expect(fun).toBeTruthy();
20
20
  expect(fun?.getSignature().getName()).toBe('RandomInt');
21
21
 
22
- fun = repo.find(Namespaces.MATH, 'Exponential');
22
+ fun = await repo.find(Namespaces.MATH, 'Exponential');
23
23
  expect(fun).toBeTruthy();
24
24
  expect(fun?.getSignature().getName()).toBe('Exponential');
25
25
 
26
- fun = repo.find(Namespaces.SYSTEM, 'If');
26
+ fun = await repo.find(Namespaces.SYSTEM, 'If');
27
27
  expect(fun).toBeTruthy();
28
28
  expect(fun?.getSignature().getName()).toBe('If');
29
29
  });
@@ -3,8 +3,8 @@ import { KIRunSchemaRepository, KIRunFunctionRepository } from '../../../src';
3
3
  const funcRepo = new KIRunFunctionRepository();
4
4
  const schemaRepo = new KIRunSchemaRepository();
5
5
 
6
- test('Repository Filter Test', () => {
7
- expect(funcRepo.filter('Rep')).toStrictEqual([
6
+ test('Repository Filter Test', async () => {
7
+ expect(await funcRepo.filter('Rep')).toStrictEqual([
8
8
  'System.String.Repeat',
9
9
  'System.String.Replace',
10
10
  'System.String.ReplaceFirst',
@@ -12,18 +12,18 @@ test('Repository Filter Test', () => {
12
12
  'System.String.ReplaceAtGivenPosition',
13
13
  ]);
14
14
 
15
- expect(funcRepo.filter('root')).toStrictEqual([
15
+ expect(await funcRepo.filter('root')).toStrictEqual([
16
16
  'System.Math.CubeRoot',
17
17
  'System.Math.SquareRoot',
18
18
  ]);
19
19
 
20
- expect(schemaRepo.filter('root')).toStrictEqual([]);
20
+ expect(await schemaRepo.filter('root')).toStrictEqual([]);
21
21
 
22
- expect(schemaRepo.filter('rin')).toStrictEqual(['System.string']);
22
+ expect(await schemaRepo.filter('rin')).toStrictEqual(['System.string']);
23
23
 
24
- expect(schemaRepo.filter('ny')).toStrictEqual(['System.any']);
24
+ expect(await schemaRepo.filter('ny')).toStrictEqual(['System.any']);
25
25
 
26
- expect(schemaRepo.filter('')).toStrictEqual([
26
+ expect(await schemaRepo.filter('')).toStrictEqual([
27
27
  'System.any',
28
28
  'System.boolean',
29
29
  'System.double',
@@ -143,16 +143,20 @@ test('KIRuntime Function in Function', async () => {
143
143
  );
144
144
 
145
145
  class InternalRepository implements Repository<Function> {
146
- find(namespace: string, name: string): Function | undefined {
147
- if (namespace !== 'Internal') return;
146
+ async find(namespace: string, name: string): Promise<Function | undefined> {
147
+ if (namespace !== 'Internal') return Promise.resolve(undefined);
148
148
 
149
- if (name === 'Third') return third;
150
- if (name === 'Second') return second;
149
+ if (name === 'Third') return Promise.resolve(third);
150
+ if (name === 'Second') return Promise.resolve(second);
151
+
152
+ return Promise.resolve(undefined);
151
153
  }
152
154
 
153
- filter(name: string): string[] {
154
- return [third.getSignature().getFullName(), second.getSignature().getFullName()].filter(
155
- (e) => e.toLowerCase().includes(name.toLowerCase()),
155
+ async filter(name: string): Promise<string[]> {
156
+ return Promise.resolve(
157
+ [third.getSignature().getFullName(), second.getSignature().getFullName()].filter(
158
+ (e) => e.toLowerCase().includes(name.toLowerCase()),
159
+ ),
156
160
  );
157
161
  }
158
162
  }
@@ -29,10 +29,10 @@ test('KIRuntime Without any parameter map passed in definition', async () => {
29
29
  const tstPrint = new Print();
30
30
 
31
31
  class TestRepository implements Repository<Function> {
32
- public find(namespace: string, name: string): Function | undefined {
32
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
33
33
  return tstPrint;
34
34
  }
35
- filter(name: string): string[] {
35
+ public async filter(name: string): Promise<string[]> {
36
36
  throw new Error('Method not implemented.');
37
37
  }
38
38
  }
@@ -31,10 +31,10 @@ test('KIRuntime With Definition without values object inside parameter Map', asy
31
31
  const tstPrint = new Print();
32
32
 
33
33
  class TestRepository implements Repository<Function> {
34
- public find(namespace: string, name: string): Function | undefined {
34
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
35
35
  return tstPrint;
36
36
  }
37
- filter(name: string): string[] {
37
+ public async filter(name: string): Promise<string[]> {
38
38
  throw new Error('Method not implemented.');
39
39
  }
40
40
  }
@@ -340,17 +340,19 @@ test('KIRuntime Test 4', async () => {
340
340
  var expression = { isExpression: true, value: 'Steps.fib.output.value' };
341
341
  let resultObj = { name: 'result', value: expression };
342
342
 
343
- var hybrid = new HybridRepository(new KIRunFunctionRepository(), {
344
- find(namespace, name): Function {
343
+ class X {
344
+ async find(namespace: string, name: string): Promise<Function> {
345
345
  return fibFunction;
346
- },
346
+ }
347
347
 
348
- filter(name: string): string[] {
348
+ async filter(name: string): Promise<string[]> {
349
349
  return [fibFunction.getSignature().getFullName()].filter((e) =>
350
350
  e.toLowerCase().includes(name.toLowerCase()),
351
351
  );
352
- },
353
- });
352
+ }
353
+ }
354
+
355
+ var hybrid = new HybridRepository(new KIRunFunctionRepository(), new X());
354
356
 
355
357
  start = new Date().getTime();
356
358
  let out: EventResult[] = (
@@ -53,6 +53,7 @@ test('KIRuntime Without Gen Event Definition 1', async () => {
53
53
 
54
54
  const fd = FunctionDefinition.from(def);
55
55
 
56
+ const oldConsole = console.log;
56
57
  const test = (console.log = jest.fn().mockImplementation(() => {}));
57
58
 
58
59
  await new KIRuntime(fd, false).execute(
@@ -67,6 +68,7 @@ test('KIRuntime Without Gen Event Definition 1', async () => {
67
68
  ]),
68
69
  ),
69
70
  );
71
+ console.log = oldConsole;
70
72
  expect(test.mock.calls[0][0]).toBe('Nothing muchh....');
71
73
  expect(test.mock.calls[0][1]).toBe(31);
72
74
  });
@@ -124,7 +126,7 @@ test('KIRuntime Without Gen Event Definition 2', async () => {
124
126
  };
125
127
 
126
128
  const fd = FunctionDefinition.from(def);
127
-
129
+ const oldConsole = console.log;
128
130
  const test = (console.log = jest.fn().mockImplementation(() => {}));
129
131
 
130
132
  await new KIRuntime(fd, false).execute(
@@ -139,6 +141,7 @@ test('KIRuntime Without Gen Event Definition 2', async () => {
139
141
  ]),
140
142
  ),
141
143
  );
144
+ console.log = oldConsole;
142
145
  expect(test.mock.calls[0][0]).toBe('Something muchh....');
143
146
  expect(test.mock.calls[0][1]).toBe(31);
144
147
  });
@@ -71,25 +71,21 @@ test('KIRuntime Undefined and null param type with varargs', async () => {
71
71
  const tstPrint = new Print();
72
72
 
73
73
  class TestRepository implements Repository<Function> {
74
- public find(namespace: string, name: string): Function | undefined {
74
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
75
75
  return tstPrint;
76
76
  }
77
- filter(name: string): string[] {
77
+ public async filter(name: string): Promise<string[]> {
78
78
  throw new Error('Method not implemented.');
79
79
  }
80
80
  }
81
81
 
82
- try {
83
- var fo: FunctionOutput = await new KIRuntime(fd).execute(
84
- new FunctionExecutionParameters(
85
- new HybridRepository(new KIRunFunctionRepository(), new TestRepository()),
86
- new KIRunSchemaRepository(),
87
- ).setArguments(new Map()),
88
- );
89
- expect(fo.allResults()).toStrictEqual([]);
90
- } catch (e: any) {
91
- console.error(e);
92
- }
82
+ var fo: FunctionOutput = await new KIRuntime(fd).execute(
83
+ new FunctionExecutionParameters(
84
+ new HybridRepository(new KIRunFunctionRepository(), new TestRepository()),
85
+ new KIRunSchemaRepository(),
86
+ ).setArguments(new Map()),
87
+ );
88
+ expect(fo.allResults()[0].getResult().size).toBe(0);
93
89
  });
94
90
 
95
91
  test('KIRuntime Undefined and null param type without varargs', async () => {
@@ -115,23 +111,24 @@ test('KIRuntime Undefined and null param type without varargs', async () => {
115
111
  const tstPrint = new Print();
116
112
 
117
113
  class TestRepository implements Repository<Function> {
118
- public find(namespace: string, name: string): Function | undefined {
114
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
119
115
  return tstPrint;
120
116
  }
121
- filter(name: string): string[] {
117
+ public async filter(name: string): Promise<string[]> {
122
118
  throw new Error('Method not implemented.');
123
119
  }
124
120
  }
125
121
 
126
- try {
127
- var fo: FunctionOutput = await new KIRuntime(fd).execute(
128
- new FunctionExecutionParameters(
129
- new HybridRepository(new KIRunFunctionRepository(), new TestRepository()),
130
- new KIRunSchemaRepository(),
131
- ).setArguments(new Map()),
132
- );
133
- expect(fo.allResults()).toStrictEqual([]);
134
- } catch (e: any) {
135
- console.error(e);
136
- }
122
+ expect(
123
+ (
124
+ await new KIRuntime(fd).execute(
125
+ new FunctionExecutionParameters(
126
+ new HybridRepository(new KIRunFunctionRepository(), new TestRepository()),
127
+ new KIRunSchemaRepository(),
128
+ ).setArguments(new Map()),
129
+ )
130
+ )
131
+ .allResults()[0]
132
+ .getResult().size,
133
+ ).toBe(0);
137
134
  });
@@ -79,10 +79,10 @@ test('KIRuntime With Definition no values passed ', async () => {
79
79
  const tstPrint = new Print();
80
80
 
81
81
  class TestRepository implements Repository<Function> {
82
- public find(namespace: string, name: string): Function | undefined {
82
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
83
83
  return tstPrint;
84
84
  }
85
- filter(name: string): string[] {
85
+ public async filter(name: string): Promise<string[]> {
86
86
  throw new Error('Method not implemented.');
87
87
  }
88
88
  }
@@ -121,10 +121,10 @@ test('KIRuntime With Definition with no value passed', async () => {
121
121
  const tstPrint = new Print();
122
122
 
123
123
  class TestRepository implements Repository<Function> {
124
- public find(namespace: string, name: string): Function | undefined {
124
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
125
125
  return tstPrint;
126
126
  }
127
- filter(name: string): string[] {
127
+ public async filter(name: string): Promise<string[]> {
128
128
  throw new Error('Method not implemented.');
129
129
  }
130
130
  }
@@ -164,10 +164,10 @@ test('KIRuntime With Definition with no value and values passed', async () => {
164
164
  const tstPrint = new Print();
165
165
 
166
166
  class TestRepository implements Repository<Function> {
167
- public find(namespace: string, name: string): Function | undefined {
167
+ public async find(namespace: string, name: string): Promise<Function | undefined> {
168
168
  return tstPrint;
169
169
  }
170
- filter(name: string): string[] {
170
+ public async filter(name: string): Promise<string[]> {
171
171
  throw new Error('Method not implemented.');
172
172
  }
173
173
  }
@@ -1,45 +1,45 @@
1
- import { HybridRepository } from '../src/index';
1
+ import { HybridRepository, Repository } from '../src/index';
2
2
 
3
- class TestRepository {
3
+ class TestRepository implements Repository<string> {
4
4
  static TEST_INDEX: Map<string, string> = new Map<string, string>([
5
5
  ['one', 'one'],
6
6
  ['one1', 'one1'],
7
7
  ]);
8
8
 
9
- find(namespace: string, name: string): string | undefined {
9
+ async find(namespace: string, name: string): Promise<string | undefined> {
10
10
  return TestRepository.TEST_INDEX.get(name);
11
11
  }
12
12
 
13
- filter(name: string): string[] {
13
+ async filter(name: string): Promise<string[]> {
14
14
  return Array.from(TestRepository.TEST_INDEX.keys()).filter(
15
15
  (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
16
16
  );
17
17
  }
18
18
  }
19
19
 
20
- class TestRepository2 {
20
+ class TestRepository2 implements Repository<string> {
21
21
  static TEST_INDEX: Map<string, string> = new Map<string, string>([
22
22
  ['two', 'two'],
23
23
  ['two1', 'two1'],
24
24
  ]);
25
25
 
26
- find(namespace: string, name: string): string | undefined {
26
+ async find(namespace: string, name: string): Promise<string | undefined> {
27
27
  return TestRepository2.TEST_INDEX.get(name);
28
28
  }
29
29
 
30
- filter(name: string): string[] {
30
+ async filter(name: string): Promise<string[]> {
31
31
  return Array.from(TestRepository.TEST_INDEX.keys()).filter(
32
32
  (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
33
33
  );
34
34
  }
35
35
  }
36
36
 
37
- test('Hybrid Repository Test', () => {
37
+ test('Hybrid Repository Test', async () => {
38
38
  let hybrid: HybridRepository<string> = new HybridRepository<string>(
39
39
  new TestRepository(),
40
40
  new TestRepository2(),
41
41
  );
42
42
 
43
- expect(hybrid.find('', 'one')).toBe('one');
44
- expect(hybrid.find('', 'two1')).toBe('two1');
43
+ expect(await hybrid.find('', 'one')).toBe('one');
44
+ expect(await hybrid.find('', 'two1')).toBe('two1');
45
45
  });