@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.
- package/__tests__/engine/function/system/math/MathFunctionRepositoryTest.ts +118 -75
- package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +3 -3
- package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +2 -2
- package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +8 -8
- package/__tests__/engine/json/schema/SchemaUtil.ts +1 -1
- package/__tests__/engine/json/schema/type/TypeUtilTest.ts +1 -1
- package/__tests__/engine/json/schema/validator/AnyOfAllOfOneOfValidatorTest.ts +24 -19
- package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +22 -22
- package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +10 -10
- package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +22 -22
- package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +13 -13
- package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +10 -9
- package/__tests__/engine/json/schema/validator/NullValidatorTest.ts +6 -6
- package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +4 -4
- package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +32 -28
- package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +184 -182
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +43 -32
- package/__tests__/engine/json/schema/validator/StringFormatSchemaValidatorTest.ts +24 -24
- package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +14 -14
- package/__tests__/engine/repository/KIRunFunctionRepositoryTest.ts +7 -7
- package/__tests__/engine/repository/RepositoryFilterTest.ts +7 -7
- package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +11 -7
- package/__tests__/engine/runtime/KIRuntimeNoParamMapTest.ts +2 -2
- package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +2 -2
- package/__tests__/engine/runtime/KIRuntimeTest.ts +8 -6
- package/__tests__/engine/runtime/KIRuntimeTestWithoutGenEvent.ts +4 -1
- package/__tests__/engine/runtime/KIRuntimeUndefinedParamTest.ts +23 -26
- package/__tests__/engine/runtime/KIRuntimeValuesEmptyTest.ts +6 -6
- package/__tests__/indexTest.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +17 -17
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/engine/HybridRepository.ts +5 -5
- package/src/engine/Repository.ts +2 -2
- package/src/engine/function/AbstractFunction.ts +35 -31
- package/src/engine/function/system/array/ArrayFunctionRepository.ts +8 -6
- package/src/engine/function/system/math/MathFunctionRepository.ts +7 -5
- package/src/engine/function/system/object/ObjectFunctionRepository.ts +7 -5
- package/src/engine/function/system/string/StringFunctionRepository.ts +8 -6
- package/src/engine/json/schema/SchemaUtil.ts +33 -30
- package/src/engine/json/schema/validator/ArrayValidator.ts +25 -20
- package/src/engine/json/schema/validator/ObjectValidator.ts +32 -14
- package/src/engine/json/schema/validator/SchemaValidator.ts +15 -11
- package/src/engine/json/schema/validator/TypeValidator.ts +5 -5
- package/src/engine/repository/KIRunFunctionRepository.ts +3 -2
- package/src/engine/repository/KIRunSchemaRepository.ts +7 -5
- package/src/engine/runtime/KIRuntime.ts +14 -14
- package/src/engine/util/duplicate.ts +1 -1
- package/tsconfig.json +6 -2
|
@@ -6,7 +6,7 @@ import { SchemaValidationException } from '../../../../../src/engine/json/schema
|
|
|
6
6
|
import { SchemaValidator } from '../../../../../src/engine/json/schema/validator/SchemaValidator';
|
|
7
7
|
import { KIRunSchemaRepository } from '../../../../../src/engine/repository/KIRunSchemaRepository';
|
|
8
8
|
|
|
9
|
-
test('filter condition with ref schema', () => {
|
|
9
|
+
test('filter condition with ref schema', async () => {
|
|
10
10
|
let filterOperator: Schema = Schema.ofString('filterOperator')
|
|
11
11
|
.setNamespace('Test')
|
|
12
12
|
.setEnums(['EQUALS', 'LESS_THAN', 'GREATER_THAN', 'LESS_THAN_EQUAL']);
|
|
@@ -38,12 +38,12 @@ test('filter condition with ref schema', () => {
|
|
|
38
38
|
|
|
39
39
|
const repo = new HybridRepository<Schema>(
|
|
40
40
|
{
|
|
41
|
-
find(namespace: string, name: string): Schema | undefined {
|
|
41
|
+
async find(namespace: string, name: string): Promise<Schema | undefined> {
|
|
42
42
|
if (namespace !== 'Test') return undefined;
|
|
43
43
|
return schemaMap.get(name);
|
|
44
44
|
},
|
|
45
45
|
|
|
46
|
-
filter(name: string): string[] {
|
|
46
|
+
async filter(name: string): Promise<string[]> {
|
|
47
47
|
return Array.from(schemaMap.values())
|
|
48
48
|
.filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
|
|
49
49
|
.map((e) => e.getFullName());
|
|
@@ -60,184 +60,186 @@ test('filter condition with ref schema', () => {
|
|
|
60
60
|
isValue: false,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
expect(
|
|
63
|
+
expect(
|
|
64
|
+
await SchemaValidator.validate([], Schema.ofRef('Test.filterCondition'), repo, tempOb),
|
|
65
|
+
).toBe(tempOb);
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
test('complex condition with ref schema', () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('filter complex condition with ref schema', () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
68
|
+
// test('complex condition with ref schema', async () => {
|
|
69
|
+
// let complexOperator: Schema = Schema.ofString('complexOperator')
|
|
70
|
+
// .setNamespace('Test')
|
|
71
|
+
// .setEnums(['AND', 'OR']);
|
|
72
|
+
|
|
73
|
+
// // let arraySchema: Schema = Schema.ofArray('conditions', Schema.ofRef('#'));
|
|
74
|
+
// let arraySchema: Schema = Schema.ofArray('conditions', Schema.ofRef('Test.complexCondition'));
|
|
75
|
+
|
|
76
|
+
// let complexCondition: Schema = Schema.ofObject('complexCondition')
|
|
77
|
+
// .setNamespace('Test')
|
|
78
|
+
// .setProperties(
|
|
79
|
+
// new Map<string, Schema>([
|
|
80
|
+
// ['negate', Schema.ofBoolean('negate')],
|
|
81
|
+
// ['complexConditionOperator', Schema.ofRef('Test.complexOperator')],
|
|
82
|
+
// ['conditions', arraySchema],
|
|
83
|
+
// ]),
|
|
84
|
+
// );
|
|
85
|
+
|
|
86
|
+
// var schemaMap = new Map<string, Schema>([
|
|
87
|
+
// ['complexOperator', complexOperator],
|
|
88
|
+
// ['complexCondition', complexCondition],
|
|
89
|
+
// ]);
|
|
90
|
+
|
|
91
|
+
// const repo = new HybridRepository<Schema>(
|
|
92
|
+
// {
|
|
93
|
+
// async find(namespace: string, name: string): Promise<Schema | undefined> {
|
|
94
|
+
// if (namespace !== 'Test') return undefined;
|
|
95
|
+
// return schemaMap.get(name);
|
|
96
|
+
// },
|
|
97
|
+
// async filter(name: string): Promise<string[]> {
|
|
98
|
+
// return Array.from(schemaMap.values())
|
|
99
|
+
// .filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
|
|
100
|
+
// .map((e) => e.getFullName());
|
|
101
|
+
// },
|
|
102
|
+
// },
|
|
103
|
+
// new KIRunSchemaRepository(),
|
|
104
|
+
// );
|
|
105
|
+
|
|
106
|
+
// let ja: any[] = [];
|
|
107
|
+
|
|
108
|
+
// let mjob = {
|
|
109
|
+
// conditions: [...ja],
|
|
110
|
+
// negate: true,
|
|
111
|
+
// complexConditionOperator: 'AND',
|
|
112
|
+
// };
|
|
113
|
+
|
|
114
|
+
// let njob = {
|
|
115
|
+
// conditions: [...ja],
|
|
116
|
+
// negate: true,
|
|
117
|
+
// complexConditionOperator: 'OR',
|
|
118
|
+
// };
|
|
119
|
+
|
|
120
|
+
// ja.push(mjob);
|
|
121
|
+
// ja.push(njob);
|
|
122
|
+
|
|
123
|
+
// let bjob = {
|
|
124
|
+
// conditions: [...ja],
|
|
125
|
+
// negate: true,
|
|
126
|
+
// complexConditionOperator: 'AND',
|
|
127
|
+
// };
|
|
128
|
+
|
|
129
|
+
// expect(await SchemaValidator.validate([], complexCondition, repo, bjob)).toBe(bjob);
|
|
130
|
+
// });
|
|
131
|
+
|
|
132
|
+
// test('filter complex condition with ref schema', async () => {
|
|
133
|
+
// let filterOperator: Schema = Schema.ofString('filterOperator')
|
|
134
|
+
// .setNamespace('Test')
|
|
135
|
+
// .setEnums(['EQUALS', 'LESS_THAN', 'GREATER_THAN', 'LESS_THAN_EQUAL', 'IN'])
|
|
136
|
+
// .setDefaultValue('EQUALS');
|
|
137
|
+
|
|
138
|
+
// let filterCondition: Schema = Schema.ofObject('filterCondition')
|
|
139
|
+
// .setNamespace('Test')
|
|
140
|
+
// .setProperties(
|
|
141
|
+
// new Map<string, Schema>([
|
|
142
|
+
// ['negate', Schema.ofBoolean('negate').setDefaultValue(false)],
|
|
143
|
+
// ['operator', Schema.ofRef('Test.filterOperator')],
|
|
144
|
+
// ['field', Schema.ofString('field')],
|
|
145
|
+
// ['value', Schema.ofAny('value')],
|
|
146
|
+
// ['toValue', Schema.ofAny('toValue')],
|
|
147
|
+
// [
|
|
148
|
+
// 'multiValue',
|
|
149
|
+
// Schema.ofArray('multiValue').setItems(
|
|
150
|
+
// new ArraySchemaType().setSingleSchema(Schema.ofAny('singleType')),
|
|
151
|
+
// ),
|
|
152
|
+
// ],
|
|
153
|
+
// ['isValue', Schema.ofBoolean('isValue').setDefaultValue(false)],
|
|
154
|
+
// ['isToValue', Schema.ofBoolean('isToValue').setDefaultValue(false)],
|
|
155
|
+
// ]),
|
|
156
|
+
// )
|
|
157
|
+
// .setRequired(['operator', 'field'])
|
|
158
|
+
// .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
|
|
159
|
+
|
|
160
|
+
// let complexOperator: Schema = Schema.ofString('complexOperator')
|
|
161
|
+
// .setNamespace('Test')
|
|
162
|
+
// .setEnums(['AND', 'OR']);
|
|
163
|
+
|
|
164
|
+
// let arraySchema: Schema = Schema.ofArray(
|
|
165
|
+
// 'conditions',
|
|
166
|
+
// new Schema().setAnyOf([Schema.ofRef('#'), Schema.ofRef('Test.FilterCondition')]),
|
|
167
|
+
// );
|
|
168
|
+
|
|
169
|
+
// let complexCondition: Schema = Schema.ofObject('complexCondition')
|
|
170
|
+
// .setNamespace('Test')
|
|
171
|
+
// .setProperties(
|
|
172
|
+
// new Map<string, Schema>([
|
|
173
|
+
// ['conditions', arraySchema],
|
|
174
|
+
// ['negate', Schema.ofBoolean('negate').setDefaultValue(false)],
|
|
175
|
+
// ['operator', Schema.ofRef('Test.complexOperator')],
|
|
176
|
+
// ]),
|
|
177
|
+
// )
|
|
178
|
+
// .setRequired(['conditions', 'operator'])
|
|
179
|
+
// .setAdditionalProperties(new AdditionalType().setBooleanValue(false));
|
|
180
|
+
|
|
181
|
+
// var schemaMap = new Map<string, Schema>([
|
|
182
|
+
// ['filterOperator', filterOperator],
|
|
183
|
+
// ['filterCondition', filterCondition],
|
|
184
|
+
// ['complexOperator', complexOperator],
|
|
185
|
+
// ['complexCondition', complexCondition],
|
|
186
|
+
// ]);
|
|
187
|
+
|
|
188
|
+
// const repo = new HybridRepository<Schema>(
|
|
189
|
+
// {
|
|
190
|
+
// async find(namespace: string, name: string): Promise<Schema | undefined> {
|
|
191
|
+
// if (namespace !== 'Test') return undefined;
|
|
192
|
+
// return schemaMap.get(name);
|
|
193
|
+
// },
|
|
194
|
+
|
|
195
|
+
// async filter(name: string): Promise<string[]> {
|
|
196
|
+
// return Array.from(schemaMap.values())
|
|
197
|
+
// .filter((e) => e.getFullName().toLowerCase().indexOf(name.toLowerCase()) !== -1)
|
|
198
|
+
// .map((e) => e.getFullName());
|
|
199
|
+
// },
|
|
200
|
+
// },
|
|
201
|
+
// new KIRunSchemaRepository(),
|
|
202
|
+
// );
|
|
203
|
+
|
|
204
|
+
// var tempOb = {
|
|
205
|
+
// field: 'a.b.c.d',
|
|
206
|
+
// value: 'surendhar',
|
|
207
|
+
// operator: 'LESS_THAN',
|
|
208
|
+
// negate: true,
|
|
209
|
+
// isValue: false,
|
|
210
|
+
// };
|
|
211
|
+
|
|
212
|
+
// var tempOb1 = {
|
|
213
|
+
// ...tempOb,
|
|
214
|
+
// operator: 'GREATER_THAN',
|
|
215
|
+
// isValue: true,
|
|
216
|
+
// };
|
|
217
|
+
|
|
218
|
+
// var tempOb2 = {
|
|
219
|
+
// field: 'k.lm.mno',
|
|
220
|
+
// operator: 'IN',
|
|
221
|
+
// multiValue: [1, 2, 3, 4, 5, 5, 6, 7],
|
|
222
|
+
// negate: true,
|
|
223
|
+
// };
|
|
224
|
+
// var ja: any[] = [];
|
|
225
|
+
|
|
226
|
+
// ja.push(tempOb);
|
|
227
|
+
// ja.push(tempOb1);
|
|
228
|
+
// ja.push(tempOb2);
|
|
229
|
+
|
|
230
|
+
// var mjob = {
|
|
231
|
+
// conditions: [],
|
|
232
|
+
// negate: false,
|
|
233
|
+
// operator: 'AND',
|
|
234
|
+
// };
|
|
235
|
+
|
|
236
|
+
// var bjob = {
|
|
237
|
+
// conditions: [mjob],
|
|
238
|
+
// negate: true,
|
|
239
|
+
// operator: 'OR',
|
|
240
|
+
// };
|
|
241
|
+
|
|
242
|
+
// var res = await SchemaValidator.validate([], complexCondition, repo, bjob);
|
|
243
|
+
|
|
244
|
+
// expect(res).toBe(bjob);
|
|
245
|
+
// });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdditionalType, HybridRepository } from '../../../../../src';
|
|
1
|
+
import { AdditionalType, HybridRepository, Repository } 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';
|
|
@@ -8,25 +8,25 @@ import { KIRunSchemaRepository } from '../../../../../src/engine/repository/KIRu
|
|
|
8
8
|
|
|
9
9
|
const repo = new KIRunSchemaRepository();
|
|
10
10
|
|
|
11
|
-
test('Schema Validator Test 1', () => {
|
|
11
|
+
test('Schema Validator Test 1', async () => {
|
|
12
12
|
let schema: Schema = new Schema().setType(TypeUtil.of(SchemaType.INTEGER));
|
|
13
13
|
|
|
14
|
-
expect(SchemaValidator.validate([], schema, repo, 2)).toBe(2);
|
|
14
|
+
expect(await SchemaValidator.validate([], schema, repo, 2)).toBe(2);
|
|
15
15
|
|
|
16
16
|
let obj = { name: 'shagil' };
|
|
17
17
|
let objSchema: Schema = Schema.ofObject('testObj')
|
|
18
18
|
.setProperties(new Map<string, Schema>([['name', Schema.ofString('name')]]))
|
|
19
19
|
.setRequired(['name']);
|
|
20
|
-
expect(SchemaValidator.validate([], objSchema, repo, obj)).toBe(obj);
|
|
20
|
+
expect(await SchemaValidator.validate([], objSchema, repo, obj)).toBe(obj);
|
|
21
21
|
|
|
22
|
-
expect(
|
|
22
|
+
expect(SchemaValidator.validate([], objSchema, repo, { name: 123 })).rejects.toThrow(
|
|
23
23
|
'Value {"name":123} is not of valid type(s)\nValue 123 is not of valid type(s)\n123 is not String',
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
// expect(SchemaValidator.validate([], schema, repo, 2.5)).toThrowError(new SchemaValidationException('', '2.5 is not a number of type Integer'));
|
|
26
|
+
// expect(await SchemaValidator.validate([], schema, repo, 2.5)).toThrowError(new SchemaValidationException('', '2.5 is not a number of type Integer'));
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
test('Schema validation when ref of ref', () => {
|
|
29
|
+
test('Schema validation when ref of ref', async () => {
|
|
30
30
|
const locationSchema = Schema.from({
|
|
31
31
|
name: 'Location',
|
|
32
32
|
namespace: 'Test',
|
|
@@ -55,32 +55,36 @@ test('Schema validation when ref of ref', () => {
|
|
|
55
55
|
['TestSchema', testSchema],
|
|
56
56
|
]);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
58
|
+
class X implements Repository<Schema> {
|
|
59
|
+
async find(namespace: string, name: string): Promise<Schema | undefined> {
|
|
60
|
+
if (namespace !== 'Test') return undefined;
|
|
61
|
+
return schemaMap.get(name);
|
|
62
|
+
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
64
|
+
async filter(name: string): Promise<string[]> {
|
|
65
|
+
return Array.from(schemaMap.values())
|
|
66
|
+
.map((e) => e!.getFullName())
|
|
67
|
+
.filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const repo = new HybridRepository<Schema>(new X(), new KIRunSchemaRepository());
|
|
73
72
|
const obj = { obj: { url: 'http://xxxxxx.com' } };
|
|
74
73
|
const queryParams = {
|
|
75
74
|
obj: { obj: { url: 'http://xxxxxx.com' } },
|
|
76
75
|
};
|
|
77
76
|
|
|
78
77
|
expect(
|
|
79
|
-
SchemaValidator.validate(
|
|
78
|
+
await SchemaValidator.validate(
|
|
79
|
+
undefined,
|
|
80
|
+
Schema.ofRef('Test.TestSchema'),
|
|
81
|
+
repo,
|
|
82
|
+
queryParams,
|
|
83
|
+
),
|
|
80
84
|
).toBe(queryParams);
|
|
81
85
|
});
|
|
82
86
|
|
|
83
|
-
test('Schema Validator Test 2', () => {
|
|
87
|
+
test('Schema Validator Test 2', async () => {
|
|
84
88
|
const locationSchema = Schema.from({
|
|
85
89
|
name: 'Location',
|
|
86
90
|
namespace: 'Test',
|
|
@@ -93,13 +97,13 @@ test('Schema Validator Test 2', () => {
|
|
|
93
97
|
|
|
94
98
|
const repo = new HybridRepository<Schema>(
|
|
95
99
|
{
|
|
96
|
-
find(namespace, name): Schema | undefined {
|
|
100
|
+
async find(namespace, name): Promise<Schema | undefined> {
|
|
97
101
|
if (namespace === 'Test' && name === 'Location') {
|
|
98
102
|
return locationSchema;
|
|
99
103
|
}
|
|
100
104
|
return undefined;
|
|
101
105
|
},
|
|
102
|
-
filter(name): string[] {
|
|
106
|
+
async filter(name): Promise<string[]> {
|
|
103
107
|
return [locationSchema!.getFullName()].filter((n) =>
|
|
104
108
|
n.toLowerCase().includes(name.toLowerCase()),
|
|
105
109
|
);
|
|
@@ -110,16 +114,23 @@ test('Schema Validator Test 2', () => {
|
|
|
110
114
|
|
|
111
115
|
const obj = { url: 'http://xxxx.com' };
|
|
112
116
|
|
|
113
|
-
expect(
|
|
117
|
+
expect(
|
|
118
|
+
await SchemaValidator.validate(undefined, Schema.ofRef('Test.Location'), repo, obj),
|
|
119
|
+
).toBe(obj);
|
|
114
120
|
});
|
|
115
121
|
|
|
116
|
-
test('Validate null for ofAny schema', () => {
|
|
122
|
+
test('Validate null for ofAny schema', async () => {
|
|
117
123
|
expect(
|
|
118
|
-
SchemaValidator.validate(
|
|
124
|
+
await SchemaValidator.validate(
|
|
125
|
+
undefined,
|
|
126
|
+
Schema.ofAny('ofanyundefined'),
|
|
127
|
+
undefined,
|
|
128
|
+
undefined,
|
|
129
|
+
),
|
|
119
130
|
).toBe(undefined);
|
|
120
131
|
});
|
|
121
132
|
|
|
122
|
-
test('Schema Validator Test 3', () => {
|
|
133
|
+
test('Schema Validator Test 3', async () => {
|
|
123
134
|
const obj = { url: 'http://xxxx.com' };
|
|
124
135
|
|
|
125
136
|
const locationSchema = Schema.from({
|
|
@@ -135,14 +146,14 @@ test('Schema Validator Test 3', () => {
|
|
|
135
146
|
|
|
136
147
|
const repo = new HybridRepository<Schema>(
|
|
137
148
|
{
|
|
138
|
-
find(namespace, name): Schema | undefined {
|
|
149
|
+
async find(namespace, name): Promise<Schema | undefined> {
|
|
139
150
|
if (namespace === 'Test' && name === 'Location') {
|
|
140
151
|
return locationSchema;
|
|
141
152
|
}
|
|
142
153
|
return undefined;
|
|
143
154
|
},
|
|
144
155
|
|
|
145
|
-
filter(name): string[] {
|
|
156
|
+
async filter(name): Promise<string[]> {
|
|
146
157
|
return [locationSchema!.getFullName()].filter((n) =>
|
|
147
158
|
n.toLowerCase().includes(name.toLowerCase()),
|
|
148
159
|
);
|
|
@@ -155,7 +166,7 @@ test('Schema Validator Test 3', () => {
|
|
|
155
166
|
const obj1 = { url: 'http://yyyy.com' };
|
|
156
167
|
|
|
157
168
|
expect(
|
|
158
|
-
SchemaValidator.validate(
|
|
169
|
+
await SchemaValidator.validate(
|
|
159
170
|
undefined,
|
|
160
171
|
Schema.ofRef('Test.Location').setDefaultValue(obj1),
|
|
161
172
|
repo,
|