@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
@@ -9,19 +9,20 @@ import { SingleType } from './type/SingleType';
9
9
  import { MultipleType } from './type/MultipleType';
10
10
 
11
11
  const ADDITIONAL_PROPERTY: string = 'additionalProperty';
12
+ const ADDITIONAL_ITEMS: string = 'additionalItems';
12
13
  const ENUMS: string = 'enums';
13
14
  const ITEMS_STRING: string = 'items';
14
- const SCHEMA_ROOT_PATH: string = '#/';
15
+ const SCHEMA_ROOT_PATH: string = 'System.Schema';
15
16
  const REQUIRED_STRING: string = 'required';
16
17
  const VERSION_STRING: string = 'version';
17
18
  const NAMESPACE_STRING: string = 'namespace';
18
19
  const TEMPORARY: string = '_';
19
20
 
20
- export class AdditionalPropertiesType {
21
+ export class AdditionalType {
21
22
  private booleanValue?: boolean;
22
23
  private schemaValue?: Schema;
23
24
 
24
- constructor(apt: AdditionalPropertiesType | undefined = undefined) {
25
+ constructor(apt: AdditionalType | undefined = undefined) {
25
26
  if (!apt) return;
26
27
  this.booleanValue = apt.booleanValue;
27
28
  if (!apt.schemaValue) return;
@@ -36,21 +37,27 @@ export class AdditionalPropertiesType {
36
37
  return this.schemaValue;
37
38
  }
38
39
 
39
- public setBooleanValue(booleanValue: boolean): AdditionalPropertiesType {
40
+ public setBooleanValue(booleanValue: boolean): AdditionalType {
40
41
  this.booleanValue = booleanValue;
41
42
  return this;
42
43
  }
43
44
 
44
- public setSchemaValue(schemaValue: Schema): AdditionalPropertiesType {
45
+ public setSchemaValue(schemaValue: Schema): AdditionalType {
45
46
  this.schemaValue = schemaValue;
46
47
  return this;
47
48
  }
48
49
 
49
- public static from(obj: any): AdditionalPropertiesType | undefined {
50
- if (!obj) return undefined;
51
- const ad = new AdditionalPropertiesType();
52
- ad.booleanValue = obj.booleanValue;
53
- ad.schemaValue = obj.schemaValue;
50
+ public static from(obj: any): AdditionalType | undefined {
51
+ if (isNullValue(obj)) return undefined;
52
+ const ad = new AdditionalType();
53
+ if (typeof obj === 'boolean') ad.booleanValue = obj;
54
+ else {
55
+ let keys = Object.keys(obj);
56
+ if (keys.indexOf('booleanValue') != -1) ad.booleanValue = obj.booleanValue;
57
+ else if (keys.indexOf('schemaValue') != -1)
58
+ ad.schemaValue = Schema.from(obj.schemaValue);
59
+ else ad.schemaValue = Schema.from(obj);
60
+ }
54
61
  return ad;
55
62
  }
56
63
  }
@@ -133,9 +140,7 @@ export class Schema {
133
140
  [
134
141
  'properties',
135
142
  Schema.of('properties', SchemaType.OBJECT).setAdditionalProperties(
136
- new AdditionalPropertiesType().setSchemaValue(
137
- Schema.ofRef(SCHEMA_ROOT_PATH),
138
- ),
143
+ new AdditionalType().setSchemaValue(Schema.ofRef(SCHEMA_ROOT_PATH)),
139
144
  ),
140
145
  ],
141
146
  [
@@ -162,9 +167,7 @@ export class Schema {
162
167
  [
163
168
  'patternProperties',
164
169
  Schema.of('patternProperties', SchemaType.OBJECT).setAdditionalProperties(
165
- new AdditionalPropertiesType().setSchemaValue(
166
- Schema.ofRef(SCHEMA_ROOT_PATH),
167
- ),
170
+ new AdditionalType().setSchemaValue(Schema.ofRef(SCHEMA_ROOT_PATH)),
168
171
  ),
169
172
  ],
170
173
 
@@ -179,16 +182,25 @@ export class Schema {
179
182
  ],
180
183
 
181
184
  ['contains', Schema.ofRef(SCHEMA_ROOT_PATH)],
185
+ ['minContains', Schema.ofInteger('minContains')],
186
+ ['maxContains', Schema.ofInteger('maxContains')],
182
187
  ['minItems', Schema.ofInteger('minItems')],
183
188
  ['maxItems', Schema.ofInteger('maxItems')],
184
189
  ['uniqueItems', Schema.ofBoolean('uniqueItems')],
185
-
190
+ [
191
+ 'additionalItems',
192
+ new Schema()
193
+ .setName(ADDITIONAL_ITEMS)
194
+ .setNamespace(Namespaces.SYSTEM)
195
+ .setAnyOf([
196
+ Schema.ofBoolean(ADDITIONAL_ITEMS),
197
+ Schema.ofObject(ADDITIONAL_ITEMS).setRef(SCHEMA_ROOT_PATH),
198
+ ]),
199
+ ],
186
200
  [
187
201
  '$defs',
188
202
  Schema.of('$defs', SchemaType.OBJECT).setAdditionalProperties(
189
- new AdditionalPropertiesType().setSchemaValue(
190
- Schema.ofRef(SCHEMA_ROOT_PATH),
191
- ),
203
+ new AdditionalType().setSchemaValue(Schema.ofRef(SCHEMA_ROOT_PATH)),
192
204
  ),
193
205
  ],
194
206
 
@@ -288,8 +300,8 @@ export class Schema {
288
300
  .setItems(ArraySchemaType.of(...itemSchemas));
289
301
  }
290
302
 
291
- public static fromListOfSchemas(list: any): Schema[] {
292
- if (isNullValue(list) && !Array.isArray(list)) return [];
303
+ public static fromListOfSchemas(list: any): Schema[] | undefined {
304
+ if (isNullValue(list) && !Array.isArray(list)) return undefined;
293
305
  let x: Schema[] = [];
294
306
  for (let e of Array.from(list)) {
295
307
  let v = Schema.from(e);
@@ -354,7 +366,7 @@ export class Schema {
354
366
 
355
367
  // Object
356
368
  schema.properties = Schema.fromMapOfSchemas(obj.properties);
357
- schema.additionalProperties = AdditionalPropertiesType.from(obj.additionalProperties);
369
+ schema.additionalProperties = AdditionalType.from(obj.additionalProperties);
358
370
  schema.required = obj.required;
359
371
  schema.propertyNames = Schema.from(obj.propertyNames, true);
360
372
  schema.minProperties = obj.minProperties;
@@ -363,7 +375,10 @@ export class Schema {
363
375
 
364
376
  // Array
365
377
  schema.items = ArraySchemaType.from(obj.items);
378
+ schema.additionalItems = AdditionalType.from(obj.additionalItems);
366
379
  schema.contains = Schema.from(obj.contains);
380
+ schema.minContains = obj.minContains;
381
+ schema.maxContains = obj.maxContains;
367
382
  schema.minItems = obj.minItems;
368
383
  schema.maxItems = obj.maxItems;
369
384
  schema.uniqueItems = obj.uniqueItems;
@@ -409,7 +424,7 @@ export class Schema {
409
424
 
410
425
  // Object
411
426
  private properties?: Map<string, Schema>;
412
- private additionalProperties?: AdditionalPropertiesType;
427
+ private additionalProperties?: AdditionalType;
413
428
  private required?: string[];
414
429
  private propertyNames?: Schema;
415
430
  private minProperties?: number;
@@ -418,7 +433,10 @@ export class Schema {
418
433
 
419
434
  // Array
420
435
  private items?: ArraySchemaType;
436
+ private additionalItems?: AdditionalType;
421
437
  private contains?: Schema;
438
+ private minContains?: number;
439
+ private maxContains?: number;
422
440
  private minItems?: number;
423
441
  private maxItems?: number;
424
442
  private uniqueItems?: boolean;
@@ -474,7 +492,7 @@ export class Schema {
474
492
  : undefined;
475
493
 
476
494
  this.additionalProperties = schema.additionalProperties
477
- ? new AdditionalPropertiesType(schema.additionalProperties)
495
+ ? new AdditionalType(schema.additionalProperties)
478
496
  : undefined;
479
497
 
480
498
  this.required = schema.required ? [...schema.required] : undefined;
@@ -494,10 +512,14 @@ export class Schema {
494
512
 
495
513
  this.items = schema.items ? new ArraySchemaType(schema.items) : undefined;
496
514
  this.contains = schema.contains ? new Schema(this.contains) : undefined;
497
-
515
+ this.minContains = schema.minContains;
516
+ this.maxContains = schema.maxContains;
498
517
  this.minItems = schema.minItems;
499
518
  this.maxItems = schema.maxItems;
500
519
  this.uniqueItems = schema.uniqueItems;
520
+ this.additionalItems = schema.additionalItems
521
+ ? new AdditionalType(schema.additionalItems)
522
+ : undefined;
501
523
 
502
524
  this.$defs = schema.$defs
503
525
  ? new Map(Array.from(schema.$defs.entries()).map((e) => [e[0], new Schema(e[1])]))
@@ -507,15 +529,15 @@ export class Schema {
507
529
  }
508
530
 
509
531
  public getTitle(): string | undefined {
510
- return this.getFullName();
511
- }
512
-
513
- private getFullName(): string | undefined {
514
532
  if (!this.namespace || this.namespace == TEMPORARY) return this.name;
515
533
 
516
534
  return this.namespace + '.' + this.name;
517
535
  }
518
536
 
537
+ public getFullName(): string {
538
+ return this.namespace + '.' + this.name;
539
+ }
540
+
519
541
  public get$defs(): Map<string, Schema> | undefined {
520
542
  return this.$defs;
521
543
  }
@@ -700,13 +722,22 @@ export class Schema {
700
722
  this.properties = properties;
701
723
  return this;
702
724
  }
703
- public getAdditionalProperties(): AdditionalPropertiesType | undefined {
725
+ public getAdditionalProperties(): AdditionalType | undefined {
704
726
  return this.additionalProperties;
705
727
  }
706
- public setAdditionalProperties(additionalProperties: AdditionalPropertiesType): Schema {
728
+ public setAdditionalProperties(additionalProperties: AdditionalType): Schema {
707
729
  this.additionalProperties = additionalProperties;
708
730
  return this;
709
731
  }
732
+
733
+ public getAdditionalItems(): AdditionalType | undefined {
734
+ return this.additionalItems;
735
+ }
736
+ public setAdditionalItems(additionalItems: AdditionalType): Schema {
737
+ this.additionalItems = additionalItems;
738
+ return this;
739
+ }
740
+
710
741
  public getRequired(): string[] | undefined {
711
742
  return this.required;
712
743
  }
@@ -757,6 +788,25 @@ export class Schema {
757
788
  this.contains = contains;
758
789
  return this;
759
790
  }
791
+
792
+ public getMinContains(): number | undefined {
793
+ return this.minContains;
794
+ }
795
+
796
+ public setMinContains(minContains: number): Schema {
797
+ this.minContains = minContains;
798
+ return this;
799
+ }
800
+
801
+ public getMaxContains(): number | undefined {
802
+ return this.maxContains;
803
+ }
804
+
805
+ public setMaxContains(maxContains: number): Schema {
806
+ this.maxContains = maxContains;
807
+ return this;
808
+ }
809
+
760
810
  public getMinItems(): number | undefined {
761
811
  return this.minItems;
762
812
  }
@@ -1,4 +1,5 @@
1
1
  import { Repository } from '../../Repository';
2
+ import { isNullValue } from '../../util/NullCheck';
2
3
  import { StringUtil } from '../../util/string/StringUtil';
3
4
  import { Tuple2 } from '../../util/Tuples';
4
5
  import { Schema } from './Schema';
@@ -12,12 +13,15 @@ export class SchemaUtil {
12
13
 
13
14
  private static readonly CYCLIC_REFERENCE_LIMIT_COUNTER: number = 20;
14
15
 
15
- public static getDefaultValue(s: Schema | undefined, sRepository: Repository<Schema>): any {
16
+ public static getDefaultValue(
17
+ s: Schema | undefined,
18
+ sRepository: Repository<Schema> | undefined,
19
+ ): any {
16
20
  if (!s) return undefined;
17
21
 
18
22
  if (s.getConstant()) return s.getConstant();
19
23
 
20
- if (s.getDefaultValue()) return s.getDefaultValue();
24
+ if (!isNullValue(s.getDefaultValue())) return s.getDefaultValue();
21
25
 
22
26
  return SchemaUtil.getDefaultValue(
23
27
  SchemaUtil.getSchemaFromRef(s, sRepository, s.getRef()),
@@ -32,7 +36,6 @@ export class SchemaUtil {
32
36
  iteration: number = 0,
33
37
  ): Schema | undefined {
34
38
  iteration++;
35
-
36
39
  if (iteration == SchemaUtil.CYCLIC_REFERENCE_LIMIT_COUNTER)
37
40
  throw new SchemaValidationException(ref ?? '', 'Schema has a cyclic reference');
38
41
 
@@ -41,10 +41,21 @@ export class ArraySchemaType {
41
41
 
42
42
  public static from(obj: any): ArraySchemaType | undefined {
43
43
  if (!obj) return undefined;
44
- if (Array.isArray(obj)) ArraySchemaType.of(...Schema.fromListOfSchemas(obj));
44
+ if (Array.isArray(obj))
45
+ return new ArraySchemaType().setTupleSchema(Schema.fromListOfSchemas(obj)!);
46
+
47
+ let keys: any[] = Object.keys(obj);
48
+
49
+ if (keys.indexOf('singleSchema') != -1) {
50
+ return new ArraySchemaType().setSingleSchema(Schema.from(obj['singleSchema'])!);
51
+ } else if (keys.indexOf('tupleSchema') != -1) {
52
+ return new ArraySchemaType().setTupleSchema(
53
+ Schema.fromListOfSchemas(obj['tupleSchema'])!,
54
+ );
55
+ }
45
56
 
46
57
  let x = Schema.from(obj);
47
58
  if (!x) return undefined;
48
- return ArraySchemaType.of(x);
59
+ return new ArraySchemaType().setSingleSchema(x);
49
60
  }
50
61
  }
@@ -32,38 +32,71 @@ export class ArrayValidator {
32
32
 
33
33
  ArrayValidator.checkUniqueItems(parents, schema, array);
34
34
 
35
- ArrayValidator.checkContains(parents, schema, repository, array);
35
+ ArrayValidator.checkContains(schema, parents, repository, array);
36
36
 
37
37
  return element;
38
38
  }
39
39
 
40
- public static checkContains(
41
- parents: Schema[],
40
+ private static checkContains(
42
41
  schema: Schema,
42
+ parents: Schema[],
43
43
  repository: Repository<Schema> | undefined,
44
44
  array: any[],
45
45
  ) {
46
- if (!schema.getContains()) return;
46
+ if (isNullValue(schema.getContains())) return;
47
47
 
48
- let flag: boolean = false;
49
- for (let i = 0; i < array.length; i++) {
50
- let newParents: Schema[] = !parents ? [] : [...parents];
48
+ let count = ArrayValidator.countContains(
49
+ parents,
50
+ schema,
51
+ repository,
52
+ array,
53
+ isNullValue(schema.getMinContains()) && isNullValue(schema.getMaxContains()),
54
+ );
51
55
 
52
- try {
53
- SchemaValidator.validate(newParents, schema.getContains(), repository, array[i]);
54
- flag = true;
55
- break;
56
- } catch (err) {
57
- flag = false;
58
- }
56
+ if (count === 0) {
57
+ throw new SchemaValidationException(
58
+ SchemaValidator.path(parents),
59
+ 'None of the items are of type contains schema',
60
+ );
59
61
  }
60
62
 
61
- if (!flag) {
63
+ if (!isNullValue(schema.getMinContains()) && schema.getMinContains()! > count)
62
64
  throw new SchemaValidationException(
63
65
  SchemaValidator.path(parents),
64
- 'None of the items are of type contains schema',
66
+ 'The minimum number of the items of type contains schema should be ' +
67
+ schema.getMinContains() +
68
+ ' but found ' +
69
+ count,
70
+ );
71
+
72
+ if (!isNullValue(schema.getMaxContains()) && schema.getMaxContains()! < count)
73
+ throw new SchemaValidationException(
74
+ SchemaValidator.path(parents),
75
+ 'The maximum number of the items of type contains schema should be ' +
76
+ schema.getMaxContains() +
77
+ ' but found ' +
78
+ count,
65
79
  );
80
+ }
81
+
82
+ public static countContains(
83
+ parents: Schema[],
84
+ schema: Schema,
85
+ repository: Repository<Schema> | undefined,
86
+ array: any[],
87
+ stopOnFirst?: boolean,
88
+ ): number {
89
+ let count = 0;
90
+ for (let i = 0; i < array.length; i++) {
91
+ let newParents: Schema[] = !parents ? [] : [...parents];
92
+
93
+ try {
94
+ SchemaValidator.validate(newParents, schema.getContains(), repository, array[i]);
95
+ count++;
96
+ if (stopOnFirst) break;
97
+ } catch (err) {}
66
98
  }
99
+ return count;
67
100
  }
68
101
 
69
102
  public static checkUniqueItems(parents: Schema[], schema: Schema, array: any[]): void {
@@ -118,7 +151,10 @@ export class ArrayValidator {
118
151
  }
119
152
 
120
153
  if (type.getTupleSchema()) {
121
- if (type.getTupleSchema()!.length !== array.length) {
154
+ if (
155
+ type.getTupleSchema()!.length !== array.length &&
156
+ isNullValue(schema?.getAdditionalItems())
157
+ ) {
122
158
  throw new SchemaValidationException(
123
159
  SchemaValidator.path(parents),
124
160
  'Expected an array with only ' +
@@ -128,18 +164,93 @@ export class ArrayValidator {
128
164
  );
129
165
  }
130
166
 
131
- for (let i = 0; i < array.length; i++) {
132
- let newParents: Schema[] = !parents ? [] : [...parents];
133
- let element: any = SchemaValidator.validate(
134
- newParents,
135
- type.getTupleSchema()![i],
167
+ this.checkItemsInTupleSchema(parents, repository, array, type);
168
+
169
+ this.checkAdditionalItems(parents, schema, repository, array, type);
170
+ }
171
+ }
172
+
173
+ private static checkItemsInTupleSchema(
174
+ parents: Schema[],
175
+ repository: Repository<Schema> | undefined,
176
+ array: any[],
177
+ type: ArraySchemaType,
178
+ ) {
179
+ for (let i = 0; i < type.getTupleSchema()?.length!; i++) {
180
+ let newParents: Schema[] = !parents ? [] : [...parents];
181
+ let element: any = SchemaValidator.validate(
182
+ newParents,
183
+ type.getTupleSchema()![i],
184
+ repository,
185
+ array[i],
186
+ );
187
+ array[i] = element;
188
+ }
189
+ }
190
+
191
+ private static checkAdditionalItems(
192
+ parents: Schema[],
193
+ schema: Schema,
194
+ repository: Repository<Schema> | undefined,
195
+ array: any[],
196
+ type: ArraySchemaType,
197
+ ) {
198
+ if (!isNullValue(schema.getAdditionalItems())) {
199
+ let additionalSchemaType = schema.getAdditionalItems();
200
+ if (additionalSchemaType?.getBooleanValue()) {
201
+ //validate the additional items whether schema is valid or not
202
+ let anySchemaType = Schema.ofAny('item'); // as additional items is true it should validate against any valid schema defined in the system
203
+ if (
204
+ additionalSchemaType?.getBooleanValue() === false &&
205
+ array.length > type.getTupleSchema()?.length!
206
+ )
207
+ throw new SchemaValidationException(
208
+ SchemaValidator.path(parents),
209
+ 'No Additional Items are defined',
210
+ );
211
+
212
+ this.checkEachItemInAdditionalItems(
213
+ parents,
214
+ schema,
136
215
  repository,
137
- array[i],
216
+ array,
217
+ type,
218
+ anySchemaType,
219
+ );
220
+ } else if (additionalSchemaType?.getSchemaValue()) {
221
+ let schemaType = additionalSchemaType.getSchemaValue();
222
+ this.checkEachItemInAdditionalItems(
223
+ parents,
224
+ schema,
225
+ repository,
226
+ array,
227
+ type,
228
+ schemaType,
138
229
  );
139
- array[i] = element;
140
230
  }
141
231
  }
142
232
  }
143
233
 
234
+ private static checkEachItemInAdditionalItems(
235
+ parents: Schema[],
236
+ schema: Schema,
237
+ repository: Repository<Schema> | undefined,
238
+ array: any[],
239
+ type: ArraySchemaType,
240
+ schemaType: Schema | undefined,
241
+ ) {
242
+ for (let i = type.getTupleSchema()?.length!; i < array.length; i++) {
243
+ let newParents: Schema[] = !parents ? [] : [...parents];
244
+ let element: any = SchemaValidator.validate(
245
+ newParents,
246
+ schemaType!,
247
+ repository,
248
+ array[i],
249
+ );
250
+ array[i] = element;
251
+ }
252
+ return;
253
+ }
254
+
144
255
  private constructor() {}
145
256
  }
@@ -1,6 +1,7 @@
1
1
  import { Repository } from '../../../Repository';
2
2
  import { isNullValue } from '../../../util/NullCheck';
3
- import { AdditionalPropertiesType, Schema } from '../Schema';
3
+ import { AdditionalType, Schema } from '../Schema';
4
+ import { SchemaUtil } from '../SchemaUtil';
4
5
  import { SchemaValidationException } from './exception/SchemaValidationException';
5
6
  import { SchemaValidator } from './SchemaValidator';
6
7
 
@@ -90,7 +91,7 @@ export class ObjectValidator {
90
91
  jsonObject: any,
91
92
  keys: Set<string>,
92
93
  ) {
93
- let apt: AdditionalPropertiesType = schema.getAdditionalProperties()!;
94
+ let apt: AdditionalType = schema.getAdditionalProperties()!;
94
95
  if (apt.getSchemaValue()) {
95
96
  for (let key of Array.from(keys.values())) {
96
97
  let newParents: Schema[] = !parents ? [] : [...parents];
@@ -107,7 +108,7 @@ export class ObjectValidator {
107
108
  if (apt.getBooleanValue() === false && keys.size) {
108
109
  throw new SchemaValidationException(
109
110
  SchemaValidator.path(parents),
110
- keys.toString() + ' are additional properties which are not allowed.',
111
+ Array.from(keys) + ' is/are additional properties which are not allowed.',
111
112
  );
112
113
  }
113
114
  }
@@ -154,7 +155,11 @@ export class ObjectValidator {
154
155
  ) {
155
156
  for (const each of Array.from(schema.getProperties()!)) {
156
157
  let value: any = jsonObject[each[0]];
157
- if (isNullValue(value)) continue;
158
+
159
+ if (!jsonObject.hasOwnProperty(each[0]) && isNullValue(value)) {
160
+ const defValue = SchemaUtil.getDefaultValue(each[1], repository);
161
+ if (isNullValue(defValue)) continue;
162
+ }
158
163
 
159
164
  let newParents: Schema[] = !parents ? [] : [...parents];
160
165
  let element: any = SchemaValidator.validate(newParents, each[1], repository, value);
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, Schema } from '../json/schema/Schema';
1
+ import { AdditionalType, Schema } from '../json/schema/Schema';
2
2
  import { SchemaType } from '../json/schema/type/SchemaType';
3
3
  import { TypeUtil } from '../json/schema/type/TypeUtil';
4
4
  import { SchemaReferenceException } from '../json/schema/validator/exception/SchemaReferenceException';
@@ -21,7 +21,7 @@ export class Event {
21
21
  [
22
22
  'parameters',
23
23
  Schema.ofObject('parameter').setAdditionalProperties(
24
- new AdditionalPropertiesType().setSchemaValue(Schema.SCHEMA),
24
+ new AdditionalType().setSchemaValue(Schema.SCHEMA),
25
25
  ),
26
26
  ],
27
27
  ]),
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, Schema } from '../json/schema/Schema';
1
+ import { AdditionalType, Schema } from '../json/schema/Schema';
2
2
  import { Namespaces } from '../namespaces/Namespaces';
3
3
  import { Event } from './Event';
4
4
  import { FunctionSignature } from './FunctionSignature';
@@ -18,13 +18,13 @@ const IN_SCHEMA = new Schema()
18
18
  [
19
19
  'events',
20
20
  Schema.ofObject('events').setAdditionalProperties(
21
- new AdditionalPropertiesType().setSchemaValue(Event.SCHEMA),
21
+ new AdditionalType().setSchemaValue(Event.SCHEMA),
22
22
  ),
23
23
  ],
24
24
  [
25
25
  'steps',
26
26
  Schema.ofObject('steps').setAdditionalProperties(
27
- new AdditionalPropertiesType().setSchemaValue(Statement.SCHEMA),
27
+ new AdditionalType().setSchemaValue(Statement.SCHEMA),
28
28
  ),
29
29
  ],
30
30
  ]),
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, Schema } from '../json/schema/Schema';
1
+ import { AdditionalType, Schema } from '../json/schema/Schema';
2
2
  import { Namespaces } from '../namespaces/Namespaces';
3
3
  import { Event } from './Event';
4
4
  import { Parameter } from './Parameter';
@@ -15,13 +15,13 @@ export class FunctionSignature {
15
15
  [
16
16
  'parameters',
17
17
  Schema.ofObject('parameters').setAdditionalProperties(
18
- new AdditionalPropertiesType().setSchemaValue(Parameter.SCHEMA),
18
+ new AdditionalType().setSchemaValue(Parameter.SCHEMA),
19
19
  ),
20
20
  ],
21
21
  [
22
22
  'events',
23
23
  Schema.ofObject('events').setAdditionalProperties(
24
- new AdditionalPropertiesType().setSchemaValue(Event.SCHEMA),
24
+ new AdditionalType().setSchemaValue(Event.SCHEMA),
25
25
  ),
26
26
  ],
27
27
  ]),
@@ -74,4 +74,7 @@ export class FunctionSignature {
74
74
  this.events = events;
75
75
  return this;
76
76
  }
77
+ public getFullName(): string {
78
+ return this.namespace + '.' + this.name;
79
+ }
77
80
  }
@@ -1,4 +1,4 @@
1
- import { AdditionalPropertiesType, Schema } from '../json/schema/Schema';
1
+ import { AdditionalType, Schema } from '../json/schema/Schema';
2
2
  import { SchemaType } from '../json/schema/type/SchemaType';
3
3
  import { TypeUtil } from '../json/schema/type/TypeUtil';
4
4
  import { Namespaces } from '../namespaces/Namespaces';
@@ -22,7 +22,7 @@ export class Statement extends AbstractStatement {
22
22
  [
23
23
  'dependentStatements',
24
24
  Schema.ofObject('dependentstatement').setAdditionalProperties(
25
- new AdditionalPropertiesType().setSchemaValue(Schema.ofBoolean('exists')),
25
+ new AdditionalType().setSchemaValue(Schema.ofBoolean('exists')),
26
26
  ),
27
27
  ],
28
28
  [
@@ -30,11 +30,9 @@ export class Statement extends AbstractStatement {
30
30
  new Schema()
31
31
  .setName('parameterMap')
32
32
  .setAdditionalProperties(
33
- new AdditionalPropertiesType().setSchemaValue(
33
+ new AdditionalType().setSchemaValue(
34
34
  Schema.ofObject('parameterReference').setAdditionalProperties(
35
- new AdditionalPropertiesType().setSchemaValue(
36
- ParameterReference.SCHEMA,
37
- ),
35
+ new AdditionalType().setSchemaValue(ParameterReference.SCHEMA),
38
36
  ),
39
37
  ),
40
38
  ),
@@ -26,6 +26,10 @@ const map: Map<string, Map<string, Function>> = new Map([
26
26
  ],
27
27
  ]);
28
28
 
29
+ const filterableNames = Array.from(map.values())
30
+ .flatMap((e) => Array.from(e.values()))
31
+ .map((e) => e.getSignature().getFullName());
32
+
29
33
  export class KIRunFunctionRepository extends HybridRepository<Function> {
30
34
  public constructor() {
31
35
  super(
@@ -33,6 +37,11 @@ export class KIRunFunctionRepository extends HybridRepository<Function> {
33
37
  find(namespace: string, name: string): Function | undefined {
34
38
  return map.get(namespace)?.get(name);
35
39
  },
40
+ filter(name: string): string[] {
41
+ return Array.from(filterableNames).filter(
42
+ (e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
43
+ );
44
+ },
36
45
  },
37
46
  new MathFunctionRepository(),
38
47
  new StringFunctionRepository(),