@fincity/kirun-js 1.9.1 → 2.0.0

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 (52) 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 +4 -4
  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 +1 -1
  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
@@ -13,10 +13,10 @@ export class SchemaUtil {
13
13
 
14
14
  private static readonly CYCLIC_REFERENCE_LIMIT_COUNTER: number = 20;
15
15
 
16
- public static getDefaultValue(
16
+ public static async getDefaultValue(
17
17
  s: Schema | undefined,
18
18
  sRepository: Repository<Schema> | undefined,
19
- ): any {
19
+ ): Promise<any> {
20
20
  if (!s) return undefined;
21
21
 
22
22
  if (s.getConstant()) return s.getConstant();
@@ -24,45 +24,46 @@ export class SchemaUtil {
24
24
  if (!isNullValue(s.getDefaultValue())) return s.getDefaultValue();
25
25
 
26
26
  return SchemaUtil.getDefaultValue(
27
- SchemaUtil.getSchemaFromRef(s, sRepository, s.getRef()),
27
+ await SchemaUtil.getSchemaFromRef(s, sRepository, s.getRef()),
28
28
  sRepository,
29
29
  );
30
30
  }
31
31
 
32
- public static hasDefaultValueOrNullSchemaType(
32
+ public static async hasDefaultValueOrNullSchemaType(
33
33
  s: Schema | undefined,
34
34
  sRepository: Repository<Schema> | undefined,
35
- ): boolean {
36
- if (!s) return false;
37
- if (s.getConstant()) return true;
35
+ ): Promise<boolean> {
36
+ if (!s) return Promise.resolve(false);
37
+ if (s.getConstant()) return Promise.resolve(true);
38
38
 
39
- if (!isNullValue(s.getDefaultValue())) return true;
39
+ if (!isNullValue(s.getDefaultValue())) return Promise.resolve(true);
40
40
 
41
41
  if (isNullValue(s.getRef())) {
42
- if (s.getType()?.getAllowedSchemaTypes().has(SchemaType.NULL)) return true;
43
- return false;
42
+ if (s.getType()?.getAllowedSchemaTypes().has(SchemaType.NULL))
43
+ return Promise.resolve(true);
44
+ return Promise.resolve(false);
44
45
  }
45
46
 
46
47
  return this.hasDefaultValueOrNullSchemaType(
47
- SchemaUtil.getSchemaFromRef(s, sRepository, s.getRef()),
48
+ await SchemaUtil.getSchemaFromRef(s, sRepository, s.getRef()),
48
49
  sRepository,
49
50
  );
50
51
  }
51
52
 
52
- public static getSchemaFromRef(
53
+ public static async getSchemaFromRef(
53
54
  schema: Schema,
54
55
  sRepository: Repository<Schema> | undefined,
55
56
  ref: string | undefined,
56
57
  iteration: number = 0,
57
- ): Schema | undefined {
58
+ ): Promise<Schema | undefined> {
58
59
  iteration++;
59
60
  if (iteration == SchemaUtil.CYCLIC_REFERENCE_LIMIT_COUNTER)
60
61
  throw new SchemaValidationException(ref ?? '', 'Schema has a cyclic reference');
61
62
 
62
- if (!schema || !ref || StringUtil.isNullOrBlank(ref)) return undefined;
63
+ if (!schema || !ref || StringUtil.isNullOrBlank(ref)) return Promise.resolve(undefined);
63
64
 
64
65
  if (!ref.startsWith('#')) {
65
- var tuple = SchemaUtil.resolveExternalSchema(schema, sRepository, ref);
66
+ var tuple = await SchemaUtil.resolveExternalSchema(schema, sRepository, ref);
66
67
  if (tuple) {
67
68
  schema = tuple.getT1();
68
69
  ref = tuple.getT2();
@@ -72,19 +73,21 @@ export class SchemaUtil {
72
73
  let parts: string[] = ref.split('/');
73
74
  let i: number = 1;
74
75
 
75
- if (i === parts.length) return schema;
76
+ if (i === parts.length) return Promise.resolve(schema);
76
77
 
77
- return SchemaUtil.resolveInternalSchema(schema, sRepository, ref, iteration, parts, i);
78
+ return Promise.resolve(
79
+ SchemaUtil.resolveInternalSchema(schema, sRepository, ref, iteration, parts, i),
80
+ );
78
81
  }
79
82
 
80
- private static resolveInternalSchema(
83
+ private static async resolveInternalSchema(
81
84
  inSchema: Schema,
82
85
  sRepository: Repository<Schema> | undefined,
83
86
  ref: string,
84
87
  iteration: number,
85
88
  parts: string[],
86
89
  i: number,
87
- ): Schema | undefined {
90
+ ): Promise<Schema | undefined> {
88
91
  let schema: Schema | undefined = inSchema;
89
92
  if (i === parts.length) return undefined;
90
93
  while (i < parts.length) {
@@ -120,7 +123,7 @@ export class SchemaUtil {
120
123
  );
121
124
 
122
125
  if (!StringUtil.isNullOrBlank(schema.getRef())) {
123
- schema = SchemaUtil.getSchemaFromRef(
126
+ schema = await SchemaUtil.getSchemaFromRef(
124
127
  schema,
125
128
  sRepository,
126
129
  schema.getRef(),
@@ -133,25 +136,25 @@ export class SchemaUtil {
133
136
  );
134
137
  }
135
138
  }
136
- return schema;
139
+ return Promise.resolve(schema);
137
140
  }
138
141
 
139
- private static resolveExternalSchema(
142
+ private static async resolveExternalSchema(
140
143
  inSchem: Schema,
141
144
  sRepository: Repository<Schema> | undefined,
142
145
  ref: string,
143
- ): Tuple2<Schema, string> | undefined {
144
- if (!sRepository) return undefined;
146
+ ): Promise<Tuple2<Schema, string> | undefined> {
147
+ if (!sRepository) return Promise.resolve(undefined);
145
148
 
146
149
  let nms = StringUtil.splitAtFirstOccurance(ref ?? '', '/');
147
- if (!nms[0]) return undefined;
150
+ if (!nms[0]) return Promise.resolve(undefined);
148
151
 
149
152
  let nmspnm = StringUtil.splitAtFirstOccurance(nms[0], '.');
150
- if (!nmspnm[0] || !nmspnm[1]) return undefined;
153
+ if (!nmspnm[0] || !nmspnm[1]) return Promise.resolve(undefined);
151
154
 
152
- let schema = sRepository.find(nmspnm[0], nmspnm[1]);
153
- if (!schema) return undefined;
154
- if (!nms[1] || nms[1] === '') return new Tuple2(schema, ref);
155
+ let schema = await sRepository.find(nmspnm[0], nmspnm[1]);
156
+ if (!schema) return Promise.resolve(undefined);
157
+ if (!nms[1] || nms[1] === '') return Promise.resolve(new Tuple2(schema, ref));
155
158
 
156
159
  ref = '#/' + nms[1];
157
160
 
@@ -161,7 +164,7 @@ export class SchemaUtil {
161
164
  SchemaUtil.UNABLE_TO_RETRIVE_SCHEMA_FROM_REFERENCED_PATH,
162
165
  );
163
166
 
164
- return new Tuple2(schema, ref);
167
+ return Promise.resolve(new Tuple2(schema, ref));
165
168
  }
166
169
 
167
170
  private constructor() {}
@@ -6,12 +6,12 @@ import { SchemaValidationException } from './exception/SchemaValidationException
6
6
  import { SchemaValidator } from './SchemaValidator';
7
7
 
8
8
  export class ArrayValidator {
9
- public static validate(
9
+ public static async validate(
10
10
  parents: Schema[],
11
11
  schema: Schema,
12
12
  repository: Repository<Schema> | undefined,
13
13
  element: any,
14
- ): any {
14
+ ): Promise<any> {
15
15
  if (isNullValue(element))
16
16
  throw new SchemaValidationException(
17
17
  SchemaValidator.path(parents),
@@ -28,16 +28,16 @@ export class ArrayValidator {
28
28
 
29
29
  ArrayValidator.checkMinMaxItems(parents, schema, array);
30
30
 
31
- ArrayValidator.checkItems(parents, schema, repository, array);
31
+ await ArrayValidator.checkItems(parents, schema, repository, array);
32
32
 
33
33
  ArrayValidator.checkUniqueItems(parents, schema, array);
34
34
 
35
- ArrayValidator.checkContains(schema, parents, repository, array);
35
+ await ArrayValidator.checkContains(schema, parents, repository, array);
36
36
 
37
37
  return element;
38
38
  }
39
39
 
40
- private static checkContains(
40
+ private static async checkContains(
41
41
  schema: Schema,
42
42
  parents: Schema[],
43
43
  repository: Repository<Schema> | undefined,
@@ -45,7 +45,7 @@ export class ArrayValidator {
45
45
  ) {
46
46
  if (isNullValue(schema.getContains())) return;
47
47
 
48
- let count = ArrayValidator.countContains(
48
+ let count = await ArrayValidator.countContains(
49
49
  parents,
50
50
  schema,
51
51
  repository,
@@ -79,19 +79,24 @@ export class ArrayValidator {
79
79
  );
80
80
  }
81
81
 
82
- public static countContains(
82
+ public static async countContains(
83
83
  parents: Schema[],
84
84
  schema: Schema,
85
85
  repository: Repository<Schema> | undefined,
86
86
  array: any[],
87
87
  stopOnFirst?: boolean,
88
- ): number {
88
+ ): Promise<number> {
89
89
  let count = 0;
90
90
  for (let i = 0; i < array.length; i++) {
91
91
  let newParents: Schema[] = !parents ? [] : [...parents];
92
92
 
93
93
  try {
94
- SchemaValidator.validate(newParents, schema.getContains(), repository, array[i]);
94
+ await SchemaValidator.validate(
95
+ newParents,
96
+ schema.getContains(),
97
+ repository,
98
+ array[i],
99
+ );
95
100
  count++;
96
101
  if (stopOnFirst) break;
97
102
  } catch (err) {}
@@ -127,7 +132,7 @@ export class ArrayValidator {
127
132
  }
128
133
  }
129
134
 
130
- public static checkItems(
135
+ public static async checkItems(
131
136
  parents: Schema[],
132
137
  schema: Schema,
133
138
  repository: Repository<Schema> | undefined,
@@ -140,7 +145,7 @@ export class ArrayValidator {
140
145
  if (type.getSingleSchema()) {
141
146
  for (let i = 0; i < array.length; i++) {
142
147
  let newParents: Schema[] = !parents ? [] : [...parents];
143
- let element: any = SchemaValidator.validate(
148
+ let element: any = await SchemaValidator.validate(
144
149
  newParents,
145
150
  type.getSingleSchema(),
146
151
  repository,
@@ -164,13 +169,13 @@ export class ArrayValidator {
164
169
  );
165
170
  }
166
171
 
167
- this.checkItemsInTupleSchema(parents, repository, array, type);
172
+ await this.checkItemsInTupleSchema(parents, repository, array, type);
168
173
 
169
- this.checkAdditionalItems(parents, schema, repository, array, type);
174
+ await this.checkAdditionalItems(parents, schema, repository, array, type);
170
175
  }
171
176
  }
172
177
 
173
- private static checkItemsInTupleSchema(
178
+ private static async checkItemsInTupleSchema(
174
179
  parents: Schema[],
175
180
  repository: Repository<Schema> | undefined,
176
181
  array: any[],
@@ -178,7 +183,7 @@ export class ArrayValidator {
178
183
  ) {
179
184
  for (let i = 0; i < type.getTupleSchema()?.length!; i++) {
180
185
  let newParents: Schema[] = !parents ? [] : [...parents];
181
- let element: any = SchemaValidator.validate(
186
+ let element: any = await SchemaValidator.validate(
182
187
  newParents,
183
188
  type.getTupleSchema()![i],
184
189
  repository,
@@ -188,7 +193,7 @@ export class ArrayValidator {
188
193
  }
189
194
  }
190
195
 
191
- private static checkAdditionalItems(
196
+ private static async checkAdditionalItems(
192
197
  parents: Schema[],
193
198
  schema: Schema,
194
199
  repository: Repository<Schema> | undefined,
@@ -209,7 +214,7 @@ export class ArrayValidator {
209
214
  'No Additional Items are defined',
210
215
  );
211
216
 
212
- this.checkEachItemInAdditionalItems(
217
+ await this.checkEachItemInAdditionalItems(
213
218
  parents,
214
219
  schema,
215
220
  repository,
@@ -219,7 +224,7 @@ export class ArrayValidator {
219
224
  );
220
225
  } else if (additionalSchemaType?.getSchemaValue()) {
221
226
  let schemaType = additionalSchemaType.getSchemaValue();
222
- this.checkEachItemInAdditionalItems(
227
+ await this.checkEachItemInAdditionalItems(
223
228
  parents,
224
229
  schema,
225
230
  repository,
@@ -231,7 +236,7 @@ export class ArrayValidator {
231
236
  }
232
237
  }
233
238
 
234
- private static checkEachItemInAdditionalItems(
239
+ private static async checkEachItemInAdditionalItems(
235
240
  parents: Schema[],
236
241
  schema: Schema,
237
242
  repository: Repository<Schema> | undefined,
@@ -241,7 +246,7 @@ export class ArrayValidator {
241
246
  ) {
242
247
  for (let i = type.getTupleSchema()?.length!; i < array.length; i++) {
243
248
  let newParents: Schema[] = !parents ? [] : [...parents];
244
- let element: any = SchemaValidator.validate(
249
+ let element: any = await SchemaValidator.validate(
245
250
  newParents,
246
251
  schemaType!,
247
252
  repository,
@@ -6,7 +6,7 @@ import { SchemaValidationException } from './exception/SchemaValidationException
6
6
  import { SchemaValidator } from './SchemaValidator';
7
7
 
8
8
  export class ObjectValidator {
9
- public static validate(
9
+ public static async validate(
10
10
  parents: Schema[],
11
11
  schema: Schema,
12
12
  repository: Repository<Schema> | undefined,
@@ -30,7 +30,7 @@ export class ObjectValidator {
30
30
  ObjectValidator.checkMinMaxProperties(parents, schema, keys);
31
31
 
32
32
  if (schema.getPropertyNames()) {
33
- ObjectValidator.checkPropertyNameSchema(parents, schema, repository, keys);
33
+ await ObjectValidator.checkPropertyNameSchema(parents, schema, repository, keys);
34
34
  }
35
35
 
36
36
  if (schema.getRequired()) {
@@ -38,19 +38,31 @@ export class ObjectValidator {
38
38
  }
39
39
 
40
40
  if (schema.getProperties()) {
41
- ObjectValidator.checkProperties(parents, schema, repository, jsonObject, keys);
41
+ await ObjectValidator.checkProperties(parents, schema, repository, jsonObject, keys);
42
42
  }
43
43
 
44
44
  if (schema.getPatternProperties()) {
45
- ObjectValidator.checkPatternProperties(parents, schema, repository, jsonObject, keys);
45
+ await ObjectValidator.checkPatternProperties(
46
+ parents,
47
+ schema,
48
+ repository,
49
+ jsonObject,
50
+ keys,
51
+ );
46
52
  }
47
53
 
48
54
  if (schema.getAdditionalProperties()) {
49
- ObjectValidator.checkAddtionalProperties(parents, schema, repository, jsonObject, keys);
55
+ await ObjectValidator.checkAddtionalProperties(
56
+ parents,
57
+ schema,
58
+ repository,
59
+ jsonObject,
60
+ keys,
61
+ );
50
62
  }
51
63
  }
52
64
 
53
- private static checkPropertyNameSchema(
65
+ private static async checkPropertyNameSchema(
54
66
  parents: Schema[],
55
67
  schema: Schema,
56
68
  repository: Repository<Schema> | undefined,
@@ -58,7 +70,7 @@ export class ObjectValidator {
58
70
  ) {
59
71
  for (let key of Array.from(keys.values())) {
60
72
  try {
61
- SchemaValidator.validate(
73
+ await SchemaValidator.validate(
62
74
  parents,
63
75
  schema.getPropertyNames() as Schema,
64
76
  repository,
@@ -84,7 +96,7 @@ export class ObjectValidator {
84
96
  }
85
97
  }
86
98
 
87
- private static checkAddtionalProperties(
99
+ private static async checkAddtionalProperties(
88
100
  parents: Schema[],
89
101
  schema: Schema,
90
102
  repository: Repository<Schema> | undefined,
@@ -96,7 +108,7 @@ export class ObjectValidator {
96
108
  for (let key of Array.from(keys.values())) {
97
109
  let newParents: Schema[] = !parents ? [] : [...parents];
98
110
 
99
- let element: any = SchemaValidator.validate(
111
+ let element: any = await SchemaValidator.validate(
100
112
  newParents,
101
113
  apt.getSchemaValue(),
102
114
  repository,
@@ -114,7 +126,7 @@ export class ObjectValidator {
114
126
  }
115
127
  }
116
128
 
117
- private static checkPatternProperties(
129
+ private static async checkPatternProperties(
118
130
  parents: Schema[],
119
131
  schema: Schema,
120
132
  repository: Repository<Schema> | undefined,
@@ -132,7 +144,7 @@ export class ObjectValidator {
132
144
 
133
145
  for (const e of Array.from(compiledPatterns.entries())) {
134
146
  if (e[1].test(key)) {
135
- const element: any = SchemaValidator.validate(
147
+ const element: any = await SchemaValidator.validate(
136
148
  newParents,
137
149
  schema.getPatternProperties()!.get(e[0]),
138
150
  repository,
@@ -146,7 +158,7 @@ export class ObjectValidator {
146
158
  }
147
159
  }
148
160
 
149
- private static checkProperties(
161
+ private static async checkProperties(
150
162
  parents: Schema[],
151
163
  schema: Schema,
152
164
  repository: Repository<Schema> | undefined,
@@ -157,12 +169,18 @@ export class ObjectValidator {
157
169
  let value: any = jsonObject[each[0]];
158
170
 
159
171
  if (!jsonObject.hasOwnProperty(each[0]) && isNullValue(value)) {
160
- const defValue = SchemaUtil.getDefaultValue(each[1], repository);
172
+ const defValue = await SchemaUtil.getDefaultValue(each[1], repository);
161
173
  if (isNullValue(defValue)) continue;
162
174
  }
163
175
 
164
176
  let newParents: Schema[] = !parents ? [] : [...parents];
165
- let element: any = SchemaValidator.validate(newParents, each[1], repository, value);
177
+ let element: any = await SchemaValidator.validate(
178
+ newParents,
179
+ each[1],
180
+ repository,
181
+ value,
182
+ );
183
+
166
184
  jsonObject[each[0]] = element;
167
185
  keys.delete(each[0]);
168
186
  }
@@ -4,7 +4,6 @@ import { isNullValue } from '../../../util/NullCheck';
4
4
  import { StringUtil } from '../../../util/string/StringUtil';
5
5
  import { Schema } from '../Schema';
6
6
  import { SchemaUtil } from '../SchemaUtil';
7
- import { SchemaType } from '../type/SchemaType';
8
7
  import { AnyOfAllOfOneOfValidator } from './AnyOfAllOfOneOfValidator';
9
8
  import { SchemaValidationException } from './exception/SchemaValidationException';
10
9
  import { TypeValidator } from './TypeValidator';
@@ -19,12 +18,12 @@ export class SchemaValidator {
19
18
  .reduce((a, c, i) => a + (i === 0 ? '' : '.') + c, '');
20
19
  }
21
20
 
22
- public static validate(
21
+ public static async validate(
23
22
  parents: Schema[] | undefined,
24
23
  schema: Schema | undefined,
25
24
  repository: Repository<Schema> | undefined,
26
25
  element: any,
27
- ): any {
26
+ ): Promise<any> {
28
27
  if (!schema) {
29
28
  throw new SchemaValidationException(
30
29
  SchemaValidator.path(parents),
@@ -58,13 +57,13 @@ export class SchemaValidator {
58
57
  );
59
58
 
60
59
  if (schema.getType()) {
61
- SchemaValidator.typeValidation(parents, schema, repository, element);
60
+ await SchemaValidator.typeValidation(parents, schema, repository, element);
62
61
  }
63
62
 
64
63
  if (!StringUtil.isNullOrBlank(schema.getRef())) {
65
- return SchemaValidator.validate(
64
+ return await SchemaValidator.validate(
66
65
  parents,
67
- SchemaUtil.getSchemaFromRef(parents[0], repository, schema.getRef()),
66
+ await SchemaUtil.getSchemaFromRef(parents[0], repository, schema.getRef()),
68
67
  repository,
69
68
  element,
70
69
  );
@@ -77,7 +76,12 @@ export class SchemaValidator {
77
76
  if (schema.getNot()) {
78
77
  let flag: boolean = false;
79
78
  try {
80
- SchemaValidator.validate(parents, schema.getNot(), repository, element);
79
+ let x = await SchemaValidator.validate(
80
+ parents,
81
+ schema.getNot(),
82
+ repository,
83
+ element,
84
+ );
81
85
  flag = true;
82
86
  } catch (err) {
83
87
  flag = false;
@@ -120,7 +124,7 @@ export class SchemaValidator {
120
124
  }
121
125
  }
122
126
 
123
- public static typeValidation(
127
+ public static async typeValidation(
124
128
  parents: Schema[],
125
129
  schema: Schema,
126
130
  repository: Repository<Schema> | undefined,
@@ -128,10 +132,10 @@ export class SchemaValidator {
128
132
  ) {
129
133
  let valid: boolean = false;
130
134
  let list: SchemaValidationException[] = [];
131
-
132
- for (const type of Array.from(schema.getType()?.getAllowedSchemaTypes()?.values() ?? [])) {
135
+ let type;
136
+ for (type of Array.from(schema.getType()?.getAllowedSchemaTypes()?.values() ?? [])) {
133
137
  try {
134
- TypeValidator.validate(parents, type, schema, repository, element);
138
+ await TypeValidator.validate(parents, type, schema, repository, element);
135
139
  valid = true;
136
140
  break;
137
141
  } catch (err: any) {
@@ -11,13 +11,13 @@ import { SchemaValidator } from './SchemaValidator';
11
11
  import { StringValidator } from './StringValidator';
12
12
 
13
13
  export class TypeValidator {
14
- public static validate(
14
+ public static async validate(
15
15
  parents: Schema[],
16
16
  type: SchemaType,
17
17
  schema: Schema,
18
- repository: Repository<Schema> |undefined,
18
+ repository: Repository<Schema> | undefined,
19
19
  element: any,
20
- ): any {
20
+ ): Promise<any> {
21
21
  if (type == SchemaType.STRING) {
22
22
  StringValidator.validate(parents, schema, element);
23
23
  } else if (
@@ -30,9 +30,9 @@ export class TypeValidator {
30
30
  } else if (type == SchemaType.BOOLEAN) {
31
31
  BooleanValidator.validate(parents, schema, element);
32
32
  } else if (type == SchemaType.OBJECT) {
33
- ObjectValidator.validate(parents, schema, repository, element);
33
+ await ObjectValidator.validate(parents, schema, repository, element);
34
34
  } else if (type == SchemaType.ARRAY) {
35
- ArrayValidator.validate(parents, schema, repository, element);
35
+ await ArrayValidator.validate(parents, schema, repository, element);
36
36
  } else if (type == SchemaType.NULL) {
37
37
  NullValidator.validate(parents, schema, element);
38
38
  } else {
@@ -45,10 +45,11 @@ export class KIRunFunctionRepository extends HybridRepository<Function> {
45
45
  public constructor() {
46
46
  super(
47
47
  {
48
- find(namespace: string, name: string): Function | undefined {
48
+ async find(namespace: string, name: string): Promise<Function | undefined> {
49
49
  return map.get(namespace)?.get(name);
50
50
  },
51
- filter(name: string): string[] {
51
+
52
+ async filter(name: string): Promise<string[]> {
52
53
  return Array.from(filterableNames).filter(
53
54
  (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
54
55
  );
@@ -20,13 +20,15 @@ const map: Map<string, Schema> = new Map([
20
20
  const filterableNames = Array.from(map.values()).map((e) => e.getFullName());
21
21
 
22
22
  export class KIRunSchemaRepository implements Repository<Schema> {
23
- public find(namespace: string, name: string): Schema | undefined {
24
- if (Namespaces.SYSTEM != namespace) return undefined;
23
+ public async find(namespace: string, name: string): Promise<Schema | undefined> {
24
+ if (Namespaces.SYSTEM != namespace) return Promise.resolve(undefined);
25
25
 
26
- return map.get(name);
26
+ return Promise.resolve(map.get(name));
27
27
  }
28
28
 
29
- public filter(name: string): string[] {
30
- return filterableNames.filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1);
29
+ public async filter(name: string): Promise<string[]> {
30
+ return Promise.resolve(
31
+ filterableNames.filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1),
32
+ );
31
33
  }
32
34
  }
@@ -73,7 +73,7 @@ export class KIRuntime extends AbstractFunction {
73
73
  ): Promise<ExecutionGraph<string, StatementExecution>> {
74
74
  let g: ExecutionGraph<string, StatementExecution> = new ExecutionGraph();
75
75
  for (let s of Array.from(this.fd.getSteps().values()))
76
- g.addVertex(this.prepareStatementExecution(s, fRepo, sRepo));
76
+ g.addVertex(await this.prepareStatementExecution(s, fRepo, sRepo));
77
77
 
78
78
  let unresolved = this.makeEdges(g);
79
79
 
@@ -314,7 +314,7 @@ export class KIRuntime extends AbstractFunction {
314
314
  if (!allTrue) return;
315
315
  }
316
316
 
317
- let fun: Function | undefined = fRepo.find(s.getNamespace(), s.getName());
317
+ let fun: Function | undefined = await fRepo.find(s.getNamespace(), s.getName());
318
318
 
319
319
  if (!fun) {
320
320
  throw new KIRuntimeException(
@@ -550,25 +550,25 @@ export class KIRuntime extends AbstractFunction {
550
550
  return ret;
551
551
  }
552
552
 
553
- private prepareStatementExecution(
553
+ private async prepareStatementExecution(
554
554
  s: Statement,
555
555
  fRepo: Repository<Function>,
556
556
  sRepo: Repository<Schema>,
557
- ): StatementExecution {
557
+ ): Promise<StatementExecution> {
558
558
  let se: StatementExecution = new StatementExecution(s);
559
559
 
560
- let fun: Function | undefined = fRepo.find(s.getNamespace(), s.getName());
560
+ let fun: Function | undefined = await fRepo.find(s.getNamespace(), s.getName());
561
561
 
562
562
  if (!fun) {
563
563
  se.addMessage(
564
564
  StatementMessageType.ERROR,
565
565
  StringFormatter.format('$.$ is not available', s.getNamespace(), s.getName()),
566
566
  );
567
- return se;
567
+ return Promise.resolve(se);
568
568
  }
569
569
 
570
570
  let paramSet: Map<string, Parameter> = new Map(fun.getSignature().getParameters());
571
- if (!s.getParameterMap()) return se;
571
+ if (!s.getParameterMap()) return Promise.resolve(se);
572
572
  for (let param of Array.from(s.getParameterMap().entries())) {
573
573
  let p: Parameter | undefined = paramSet.get(param[0]);
574
574
  if (!p) continue;
@@ -576,7 +576,7 @@ export class KIRuntime extends AbstractFunction {
576
576
  let refList: ParameterReference[] = Array.from(param[1]?.values() ?? []);
577
577
 
578
578
  if (!refList.length && !p.isVariableArgument()) {
579
- if (!SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo))
579
+ if (!(await SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo)))
580
580
  se.addMessage(
581
581
  StatementMessageType.ERROR,
582
582
  StringFormatter.format(
@@ -612,7 +612,7 @@ export class KIRuntime extends AbstractFunction {
612
612
  if (paramSet.size) {
613
613
  for (let param of Array.from(paramSet.values())) {
614
614
  if (param.isVariableArgument()) continue;
615
- if (!SchemaUtil.hasDefaultValueOrNullSchemaType(param.getSchema(), sRepo))
615
+ if (!(await SchemaUtil.hasDefaultValueOrNullSchemaType(param.getSchema(), sRepo)))
616
616
  se.addMessage(
617
617
  StatementMessageType.ERROR,
618
618
  StringFormatter.format(
@@ -623,19 +623,19 @@ export class KIRuntime extends AbstractFunction {
623
623
  }
624
624
  }
625
625
 
626
- return se;
626
+ return Promise.resolve(se);
627
627
  }
628
628
 
629
- private parameterReferenceValidation(
629
+ private async parameterReferenceValidation(
630
630
  se: StatementExecution,
631
631
  p: Parameter,
632
632
  ref: ParameterReference,
633
633
  sRepo: Repository<Schema>,
634
- ): void {
634
+ ): Promise<void> {
635
635
  // Breaking this execution doesn't make sense.
636
636
 
637
637
  if (!ref) {
638
- if (isNullValue(SchemaUtil.getDefaultValue(p.getSchema(), sRepo)))
638
+ if (isNullValue(await SchemaUtil.getDefaultValue(p.getSchema(), sRepo)))
639
639
  se.addMessage(
640
640
  StatementMessageType.ERROR,
641
641
  StringFormatter.format(KIRuntime.PARAMETER_NEEDS_A_VALUE, p.getParameterName()),
@@ -643,7 +643,7 @@ export class KIRuntime extends AbstractFunction {
643
643
  } else if (ref.getType() == ParameterReferenceType.VALUE) {
644
644
  if (
645
645
  isNullValue(ref.getValue()) &&
646
- !SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo)
646
+ !(await SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo))
647
647
  )
648
648
  se.addMessage(
649
649
  StatementMessageType.ERROR,