@fincity/kirun-js 2.2.1 → 2.3.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.
- package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +26 -1
- package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +21 -0
- 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.map +1 -1
- package/package.json +1 -1
- package/src/engine/json/schema/Schema.ts +6 -4
- package/src/engine/json/schema/type/TypeUtil.ts +17 -2
- package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +18 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KIRunSchemaRepository, SchemaValidator } from '../../../../../src';
|
|
1
|
+
import { KIRunSchemaRepository, SchemaType, SchemaValidator } from '../../../../../src';
|
|
2
2
|
import { Schema } from '../../../../../src/engine/json/schema/Schema';
|
|
3
3
|
|
|
4
4
|
const repo = new KIRunSchemaRepository();
|
|
@@ -139,3 +139,28 @@ test('schemaArray With out Tuple Test ', async () => {
|
|
|
139
139
|
];
|
|
140
140
|
expect(await SchemaValidator.validate([], schema, repo, obj)).toBe(obj);
|
|
141
141
|
});
|
|
142
|
+
|
|
143
|
+
test('Regular JSON', async () => {
|
|
144
|
+
let schema = Schema.from({
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {
|
|
147
|
+
productId: {
|
|
148
|
+
description: 'The unique identifier for a product',
|
|
149
|
+
type: 'integer',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
|
|
155
|
+
expect(schema?.getType()?.contains(SchemaType.INTEGER)).toBe(false);
|
|
156
|
+
expect(schema?.getProperties()?.get('productId')?.getType()?.contains(SchemaType.INTEGER)).toBe(
|
|
157
|
+
true,
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('Only Ref test', async () => {
|
|
162
|
+
let schema = Schema.from({ ref: 'System.any' });
|
|
163
|
+
|
|
164
|
+
expect(schema?.getType()).toBeUndefined();
|
|
165
|
+
expect(schema?.getRef()).toBe('System.any');
|
|
166
|
+
});
|
|
@@ -449,3 +449,24 @@ test('Full Store Test when undefined', () => {
|
|
|
449
449
|
|
|
450
450
|
expect(ev.evaluate(MapUtil.of(ttv.getPrefix(), ttv))).toBeUndefined();
|
|
451
451
|
});
|
|
452
|
+
|
|
453
|
+
test('index retrieval', () => {
|
|
454
|
+
let ttv: TestTokenValueExtractor = new TestTokenValueExtractor({
|
|
455
|
+
a: 'kirun',
|
|
456
|
+
b: 2,
|
|
457
|
+
c: { a: 2, b: [true, false], c: { x: 'kiran' } },
|
|
458
|
+
d: { a: 2, b: [true, false], c: { x: 'kiran' } },
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
let ev: ExpressionEvaluator = new ExpressionEvaluator('Test.a');
|
|
462
|
+
expect(ev.evaluate(MapUtil.of(ttv.getPrefix(), ttv))).toBe('kirun');
|
|
463
|
+
|
|
464
|
+
ev = new ExpressionEvaluator('Test.b.__index');
|
|
465
|
+
expect(ev.evaluate(MapUtil.of(ttv.getPrefix(), ttv))).toBe('b');
|
|
466
|
+
|
|
467
|
+
ev = new ExpressionEvaluator('Test.c.c.x.__index');
|
|
468
|
+
expect(ev.evaluate(MapUtil.of(ttv.getPrefix(), ttv))).toBe('x');
|
|
469
|
+
|
|
470
|
+
ev = new ExpressionEvaluator('Test.c.b[1].__index');
|
|
471
|
+
expect(ev.evaluate(MapUtil.of(ttv.getPrefix(), ttv))).toBe(1);
|
|
472
|
+
});
|