@squiz/dx-json-schema-lib 1.21.1-alpha.9 → 1.22.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/.npm/_logs/2023-03-30T09_50_45_736Z-debug-0.log +37 -0
  2. package/lib/JsonValidationService.d.ts +1 -1
  3. package/lib/JsonValidationService.js +15 -5
  4. package/lib/JsonValidationService.js.map +1 -1
  5. package/lib/JsonValidationService.spec.js +444 -445
  6. package/lib/JsonValidationService.spec.js.map +1 -1
  7. package/lib/index.d.ts +6 -1
  8. package/lib/index.js +6 -1
  9. package/lib/index.js.map +1 -1
  10. package/lib/jsonTypeResolution/{arbitraryTypeResolution.d.ts → TypeResolver.d.ts} +7 -12
  11. package/lib/jsonTypeResolution/{arbitraryTypeResolution.js → TypeResolver.js} +17 -17
  12. package/lib/jsonTypeResolution/TypeResolver.js.map +1 -0
  13. package/lib/jsonTypeResolution/{arbitraryTypeResolution.spec.js → TypeResolver.spec.js} +12 -39
  14. package/lib/jsonTypeResolution/TypeResolver.spec.js.map +1 -0
  15. package/lib/jsonTypeResolution/TypeResolverBuilder.d.ts +12 -0
  16. package/lib/jsonTypeResolution/TypeResolverBuilder.js +32 -0
  17. package/lib/jsonTypeResolution/TypeResolverBuilder.js.map +1 -0
  18. package/lib/manifest/v1/DxContentMetaSchema.json +1 -1
  19. package/lib/manifest/v1/MatrixAssetSchema.json +28 -8
  20. package/lib/manifest/v1/v1.d.ts +10 -7
  21. package/lib/primitiveTypes/FormattedText.d.ts +8 -0
  22. package/lib/primitiveTypes/FormattedText.js +21 -0
  23. package/lib/primitiveTypes/FormattedText.js.map +1 -0
  24. package/lib/primitiveTypes/SquizImage.d.ts +26 -0
  25. package/lib/primitiveTypes/SquizImage.js +105 -0
  26. package/lib/primitiveTypes/SquizImage.js.map +1 -0
  27. package/lib/primitiveTypes/index.d.ts +2 -0
  28. package/lib/primitiveTypes/index.js +19 -0
  29. package/lib/primitiveTypes/index.js.map +1 -0
  30. package/lib/resolvableTypes/MatrixAsset.d.ts +9 -0
  31. package/lib/resolvableTypes/MatrixAsset.js +21 -0
  32. package/lib/resolvableTypes/MatrixAsset.js.map +1 -0
  33. package/lib/resolvableTypes/index.d.ts +1 -0
  34. package/lib/resolvableTypes/index.js +18 -0
  35. package/lib/resolvableTypes/index.js.map +1 -0
  36. package/package.json +5 -4
  37. package/src/JsonValidationService.spec.ts +585 -584
  38. package/src/JsonValidationService.ts +19 -9
  39. package/src/index.ts +8 -1
  40. package/src/jsonTypeResolution/{arbitraryTypeResolution.spec.ts → TypeResolver.spec.ts} +23 -70
  41. package/src/jsonTypeResolution/{arbitraryTypeResolution.ts → TypeResolver.ts} +27 -23
  42. package/src/jsonTypeResolution/TypeResolverBuilder.ts +43 -0
  43. package/src/manifest/v1/DxContentMetaSchema.json +1 -1
  44. package/src/manifest/v1/MatrixAssetSchema.json +28 -8
  45. package/src/manifest/v1/v1.ts +22 -9
  46. package/src/primitiveTypes/FormattedText.ts +24 -0
  47. package/src/primitiveTypes/SquizImage.ts +128 -0
  48. package/src/primitiveTypes/index.ts +2 -0
  49. package/src/resolvableTypes/MatrixAsset.ts +24 -0
  50. package/src/resolvableTypes/index.ts +1 -0
  51. package/tsconfig.tsbuildinfo +1 -1
  52. package/.npm/_logs/2023-03-08T03_21_11_525Z-debug-0.log +0 -39
  53. package/lib/jsonTypeResolution/arbitraryTypeResolution.js.map +0 -1
  54. package/lib/jsonTypeResolution/arbitraryTypeResolution.spec.js.map +0 -1
  55. package/lib/jsonTypeResolution/index.d.ts +0 -76
  56. package/lib/jsonTypeResolution/index.js +0 -35
  57. package/lib/jsonTypeResolution/index.js.map +0 -1
  58. package/lib/jsonTypeResolution/primitiveTypes.d.ts +0 -10
  59. package/lib/jsonTypeResolution/primitiveTypes.js +0 -27
  60. package/lib/jsonTypeResolution/primitiveTypes.js.map +0 -1
  61. package/lib/jsonTypeResolution/resolvableTypes.d.ts +0 -12
  62. package/lib/jsonTypeResolution/resolvableTypes.js +0 -30
  63. package/lib/jsonTypeResolution/resolvableTypes.js.map +0 -1
  64. package/src/jsonTypeResolution/index.ts +0 -16
  65. package/src/jsonTypeResolution/primitiveTypes.ts +0 -32
  66. package/src/jsonTypeResolution/resolvableTypes.ts +0 -37
  67. /package/lib/jsonTypeResolution/{arbitraryTypeResolution.spec.d.ts → TypeResolver.spec.d.ts} +0 -0
@@ -8,7 +8,8 @@ const SchemaValidationError_1 = require("./errors/SchemaValidationError");
8
8
  const validComponent_json_1 = __importDefault(require("./manifest/v1/__test__/schemas/validComponent.json"));
9
9
  const validComponentJson_json_1 = __importDefault(require("./manifest/v1/__test__/schemas/validComponentJson.json"));
10
10
  const inputStringWithFormat_json_1 = __importDefault(require("./manifest/v1/__test__/schemas/inputStringWithFormat.json"));
11
- const arbitraryTypeResolution_1 = require("./jsonTypeResolution/arbitraryTypeResolution");
11
+ const TypeResolver_1 = require("./jsonTypeResolution/TypeResolver");
12
+ const primitiveTypes_1 = require("./primitiveTypes");
12
13
  // eslint-disable-next-line @typescript-eslint/ban-types
13
14
  function expectToThrowErrorMatchingTypeAndMessage(received, errorType, message) {
14
15
  let error = null;
@@ -50,63 +51,7 @@ describe('JsonValidationService', () => {
50
51
  expect(result).toBe(true);
51
52
  });
52
53
  });
53
- describe('validateContentSchema', () => {
54
- it('should return true for a valid content schema', () => {
55
- const contentSchema = {
56
- type: 'object',
57
- properties: {
58
- 'my-input': { type: 'number' },
59
- },
60
- required: ['my-input'],
61
- };
62
- const result = jsonValidationService.validateContentSchema(contentSchema);
63
- expect(result).toBe(true);
64
- });
65
- it('should return false for an invalid content schema, where the required property is missed from a child object', () => {
66
- const contentSchema = {
67
- type: 'object',
68
- properties: {
69
- 'my-input': {
70
- type: 'object',
71
- properties: {
72
- 'my-deep-input': { type: 'object' },
73
- },
74
- },
75
- },
76
- required: ['my-input'],
77
- };
78
- expectToThrowErrorMatchingTypeAndMessage(() => {
79
- jsonValidationService.validateContentSchema(contentSchema);
80
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: The required property `required` is missing at `#/properties/my-input`');
81
- });
82
- it('should throw a SchemaValidationError for an invalid content schema, top level type must be object', () => {
83
- const contentSchema = {
84
- type: 'array',
85
- items: {
86
- type: 'object',
87
- properties: {
88
- 'my-input': { type: 'number' },
89
- },
90
- required: ['my-input'],
91
- },
92
- };
93
- expectToThrowErrorMatchingTypeAndMessage(() => {
94
- jsonValidationService.validateContentSchema(contentSchema);
95
- }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected value at \`#/type\` to be \`object\`, but value given is \`array\``);
96
- });
97
- it('should throw a SchemaValidationError for an invalid content schema missing the required property', () => {
98
- const contentSchema = {
99
- type: 'object',
100
- properties: {
101
- 'my-input': { type: 'number' },
102
- },
103
- };
104
- expectToThrowErrorMatchingTypeAndMessage(() => {
105
- jsonValidationService.validateContentSchema(contentSchema);
106
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: The required property `required` is missing at `#`');
107
- });
108
- });
109
- describe('validateComponentInput', () => {
54
+ describe('validateRenderInput', () => {
110
55
  describe('matrix-asset-uri input', () => {
111
56
  const functionInputSchema = {
112
57
  type: 'object',
@@ -117,14 +62,14 @@ describe('JsonValidationService', () => {
117
62
  };
118
63
  it('should return true for valid a string with matrix-asset-uri format', () => {
119
64
  const validMatrixAssetUri = 'matrix-asset://canary.uat.matrix.squiz.cloud/abc123';
120
- expect(jsonValidationService.validateComponentInput(functionInputSchema, {
65
+ expect(jsonValidationService.validateRenderInput(functionInputSchema, {
121
66
  'matrix-asset': validMatrixAssetUri,
122
67
  })).toEqual(true);
123
68
  });
124
69
  it('should throw error for invalid matrix-asset-uri format', () => {
125
70
  const invalidMatrixAssetUri = 'not-valid://canary.uat.matrix.squiz.cloud//abc123';
126
71
  expectToThrowErrorMatchingTypeAndMessage(() => {
127
- jsonValidationService.validateComponentInput(functionInputSchema, {
72
+ jsonValidationService.validateRenderInput(functionInputSchema, {
128
73
  'matrix-asset': invalidMatrixAssetUri,
129
74
  });
130
75
  }, SchemaValidationError_1.SchemaValidationError, `failed validation: value "not-valid://canary.uat.matrix.squiz.cloud//abc123" isn't a valid matrix asset uri`);
@@ -132,7 +77,7 @@ describe('JsonValidationService', () => {
132
77
  it('should throw error for invalid matrix-asset-uri type number', () => {
133
78
  const invalidMatrixAssetUri = 1234;
134
79
  expectToThrowErrorMatchingTypeAndMessage(() => {
135
- jsonValidationService.validateComponentInput(functionInputSchema, {
80
+ jsonValidationService.validateRenderInput(functionInputSchema, {
136
81
  'matrix-asset': invalidMatrixAssetUri,
137
82
  });
138
83
  }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Expected `1234` (number) in `#/matrix-asset` to be of type `string`');
@@ -140,351 +85,12 @@ describe('JsonValidationService', () => {
140
85
  it('should throw error for invalid matrix-asset-uri which does not contain correct number of parts', () => {
141
86
  const invalidMatrixAssetUri = 'matrix://';
142
87
  expectToThrowErrorMatchingTypeAndMessage(() => {
143
- jsonValidationService.validateComponentInput(functionInputSchema, {
88
+ jsonValidationService.validateRenderInput(functionInputSchema, {
144
89
  'matrix-asset': invalidMatrixAssetUri,
145
90
  });
146
91
  }, SchemaValidationError_1.SchemaValidationError, `failed validation: value "matrix://" isn't a valid matrix asset uri`);
147
92
  });
148
93
  });
149
- describe('FormattedText input', () => {
150
- it('should handle type as an array', () => {
151
- const functionInputSchema = {
152
- type: 'object',
153
- properties: {
154
- 'my-input': { type: ['number', 'string'] },
155
- },
156
- required: ['my-input'],
157
- };
158
- expect(jsonValidationService.validateComponentInput(functionInputSchema, {
159
- 'my-input': 'formattedText',
160
- })).toEqual(true);
161
- expect(jsonValidationService.validateComponentInput(functionInputSchema, {
162
- 'my-input': 123,
163
- })).toEqual(true);
164
- });
165
- it('should handle type is an array of both string and FormattedText', () => {
166
- const formattedText = [
167
- {
168
- tag: 'p',
169
- type: 'tag',
170
- children: [
171
- { type: 'text', value: 'This is some ' },
172
- { type: 'text', value: 'Link to asset 12345' },
173
- { type: 'text', value: ' with an image ' },
174
- { type: 'text', value: '.' },
175
- ],
176
- },
177
- ];
178
- const functionInputSchema = {
179
- type: 'object',
180
- properties: {
181
- 'my-input': { type: ['FormattedText', 'string'] },
182
- },
183
- required: ['my-input'],
184
- };
185
- expect(jsonValidationService.validateComponentInput(functionInputSchema, {
186
- 'my-input': formattedText,
187
- })).toEqual(true);
188
- expect(jsonValidationService.validateComponentInput(functionInputSchema, {
189
- 'my-input': 'hello',
190
- })).toEqual(true);
191
- });
192
- it('should return true if input is formatted text', () => {
193
- const functionInputSchema = {
194
- type: 'object',
195
- properties: {
196
- 'my-input': { type: 'FormattedText' },
197
- },
198
- required: ['my-input'],
199
- };
200
- const formattedText = [
201
- {
202
- tag: 'p',
203
- type: 'tag',
204
- children: [
205
- { type: 'text', value: 'This is some ' },
206
- { type: 'text', value: 'Link to asset 12345' },
207
- { type: 'text', value: ' with an image ' },
208
- { type: 'text', value: '.' },
209
- ],
210
- },
211
- ];
212
- const inputValue = {
213
- 'my-input': formattedText,
214
- };
215
- expect(jsonValidationService.validateComponentInput(functionInputSchema, inputValue)).toEqual(true);
216
- });
217
- it('should throw an error if the FormattedText input is not formatted text', () => {
218
- const functionInputSchema = {
219
- type: 'object',
220
- properties: {
221
- 'my-input': { type: 'FormattedText' },
222
- },
223
- required: ['my-input'],
224
- };
225
- const inputValue = {
226
- 'my-input': 123,
227
- };
228
- expectToThrowErrorMatchingTypeAndMessage(() => {
229
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
230
- }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected \`123\` (number) in \`#/my-input\` to be of type \`array\``);
231
- });
232
- it('should throw an error if the FormattedText input is invalid formatted text', () => {
233
- const functionInputSchema = {
234
- type: 'object',
235
- properties: {
236
- 'my-input': { type: 'FormattedText' },
237
- },
238
- required: ['my-input'],
239
- };
240
- const inputValue = {
241
- 'my-input': {
242
- something: 'aa',
243
- },
244
- };
245
- expectToThrowErrorMatchingTypeAndMessage(() => {
246
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
247
- }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected \`[object Object]\` (object) in \`#/my-input\` to be of type \`array\``);
248
- });
249
- it('should throw an error if the FormattedText input is invalid formatted text (deeply nested)', () => {
250
- const functionInputSchema = {
251
- type: 'object',
252
- properties: {
253
- 'my-input': { type: 'FormattedText' },
254
- },
255
- required: ['my-input'],
256
- };
257
- const formattedText = [
258
- {
259
- tag: 'p',
260
- type: 'tag',
261
- children: [
262
- { type: 'text', value: 'This is some ' },
263
- { type: 'text', value: 'Link to asset 12345' },
264
- { type: 'text', value: ' with an image ' },
265
- { type: 'text', value: 123 },
266
- { type: 'text', value: '.' },
267
- ],
268
- },
269
- ];
270
- const inputValue = {
271
- 'my-input': formattedText,
272
- };
273
- expectToThrowErrorMatchingTypeAndMessage(() => {
274
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
275
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Object at `#/my-input/0` does not match any schema');
276
- });
277
- it('should validate an array of formatted texts', () => {
278
- const formattedText = [
279
- {
280
- tag: 'p',
281
- type: 'tag',
282
- children: [{ type: 'text', value: 'hello' }],
283
- },
284
- ];
285
- const schema = {
286
- type: 'object',
287
- properties: {
288
- arr: {
289
- type: 'array',
290
- items: { type: 'FormattedText' },
291
- },
292
- },
293
- };
294
- const value = {
295
- arr: [formattedText],
296
- };
297
- expect(jsonValidationService.validateComponentInput(schema, value)).toEqual(true);
298
- });
299
- it('should throw an error if the FormattedText input is invalid formatted text (deeply, deeply nested)', () => {
300
- const formattedText = [
301
- {
302
- tag: 'p',
303
- type: 'tag',
304
- children: [{ type: 'text', value: 'hello' }],
305
- },
306
- ];
307
- const inputValue = {
308
- 'my-input': formattedText,
309
- deep: {
310
- arr: [
311
- {
312
- prop: formattedText,
313
- formattedTextArray: [formattedText, formattedText, { bad: 'data' }],
314
- },
315
- ],
316
- },
317
- };
318
- const functionInputSchema = {
319
- type: 'object',
320
- properties: {
321
- 'my-input': { type: 'FormattedText' },
322
- deep: {
323
- type: 'object',
324
- properties: {
325
- arr: {
326
- type: 'array',
327
- items: {
328
- type: 'object',
329
- required: ['prop', 'formattedTextArray'],
330
- properties: {
331
- prop: 'FormattedText',
332
- formattedTextArray: {
333
- type: 'array',
334
- items: {
335
- type: 'FormattedText',
336
- },
337
- },
338
- },
339
- },
340
- },
341
- },
342
- required: ['arr'],
343
- },
344
- },
345
- required: ['my-input', 'deep'],
346
- };
347
- expectToThrowErrorMatchingTypeAndMessage(() => {
348
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
349
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Expected `[object Object]` (object) in `#/deep/arr/0/formattedTextArray/2` to be of type `array`');
350
- });
351
- it('should validate a FormattedText value when the schema is a $ref', async () => {
352
- const formattedText = [
353
- {
354
- tag: 'p',
355
- type: 'tag',
356
- children: [{ type: 'text', value: 'hello' }],
357
- },
358
- ];
359
- const schema = {
360
- type: 'object',
361
- properties: {
362
- 'my-input': { $ref: '#/definitions/FormattedText' },
363
- },
364
- definitions: {
365
- FormattedText: { type: 'FormattedText' },
366
- },
367
- required: ['my-input'],
368
- };
369
- const value = {
370
- 'my-input': formattedText,
371
- };
372
- expect(jsonValidationService.validateComponentInput(schema, value)).toEqual(true);
373
- });
374
- it('should error when a FormattedText value is invalid when the schema is a $ref', async () => {
375
- const schema = {
376
- type: 'object',
377
- properties: {
378
- 'my-input': { $ref: '#/definitions/FormattedText' },
379
- },
380
- definitions: {
381
- FormattedText: { type: 'FormattedText' },
382
- },
383
- required: ['my-input'],
384
- };
385
- const value = {
386
- 'my-input': { bad: 'data' },
387
- };
388
- expectToThrowErrorMatchingTypeAndMessage(() => {
389
- jsonValidationService.validateComponentInput(schema, value);
390
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Expected `[object Object]` (object) in `#/my-input` to be of type `array`');
391
- });
392
- it('should validate a FormattedText value when the schema is a $ref to a $ref', async () => {
393
- const formattedText = [
394
- {
395
- tag: 'p',
396
- type: 'tag',
397
- children: [{ type: 'text', value: 'hello' }],
398
- },
399
- ];
400
- const schema = {
401
- type: 'object',
402
- properties: {
403
- 'my-input': { $ref: '#/definitions/FormattedText' },
404
- },
405
- definitions: {
406
- FormattedText: { $ref: '#/definitions/FormattedText2' },
407
- FormattedText2: { type: 'FormattedText' },
408
- },
409
- required: ['my-input'],
410
- };
411
- const value = {
412
- 'my-input': formattedText,
413
- };
414
- expect(jsonValidationService.validateComponentInput(schema, value)).toEqual(true);
415
- });
416
- it('should validate a FormattedText value when the schema is in an if/then/else', async () => {
417
- const formattedText = [
418
- {
419
- tag: 'p',
420
- type: 'tag',
421
- children: [{ type: 'text', value: 'hello' }],
422
- },
423
- ];
424
- const schema = {
425
- type: 'object',
426
- properties: {
427
- 'my-input': {
428
- if: { type: 'string' },
429
- then: { type: 'string' },
430
- else: { type: 'FormattedText' },
431
- },
432
- },
433
- required: ['my-input'],
434
- };
435
- const value = {
436
- 'my-input': formattedText,
437
- };
438
- expect(jsonValidationService.validateComponentInput(schema, value)).toEqual(true);
439
- });
440
- });
441
- describe('standard inputs', () => {
442
- const functionInputSchema = {
443
- type: 'object',
444
- properties: {
445
- 'my-input': { type: 'number' },
446
- },
447
- required: ['my-input'],
448
- };
449
- it('should return true for valid input values', () => {
450
- const inputValue = {
451
- 'my-input': 123,
452
- };
453
- const result = jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
454
- expect(result).toBe(true);
455
- });
456
- it('should throw a SchemaValidationError for invalid input type', () => {
457
- const inputValue = {
458
- 'my-input': '123',
459
- };
460
- expectToThrowErrorMatchingTypeAndMessage(() => {
461
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
462
- }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected \`123\` (string) in \`#/my-input\` to be of type \`number\``);
463
- });
464
- it('should throw a SchemaValidationError for invalid input missing properties', () => {
465
- const inputValue = {};
466
- expectToThrowErrorMatchingTypeAndMessage(() => {
467
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
468
- }, SchemaValidationError_1.SchemaValidationError, `failed validation: The required property \`my-input\` is missing at \`#\``);
469
- });
470
- it('should throw a SchemaValidationError with a truncated enum value list if there are more than 5 enum options', () => {
471
- expectToThrowErrorMatchingTypeAndMessage(() => {
472
- jsonValidationService.validateComponentInput({ type: 'object', properties: { enum: { type: 'string', enum: ['a', 'b', 'c', 'd', 'e', 'f', 'g'] } } }, { enum: 'z' });
473
- }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Expected given value `z` in #/enum` to be one of `[a, b, c, d, e, ... 2 more]`');
474
- });
475
- // TODO DEVX-658
476
- it.skip('should throw a SchemaValidationError for invalid input additional properties', () => {
477
- const inputValue = {
478
- 'my-input': 123,
479
- 'my-input-2': 123,
480
- };
481
- expect(() => {
482
- jsonValidationService.validateComponentInput(functionInputSchema, inputValue);
483
- }).toThrowErrorMatchingInlineSnapshot();
484
- });
485
- });
486
- });
487
- describe('validateRenderInput', () => {
488
94
  it('should validate a property with type FormattedText as string', () => {
489
95
  const schema = {
490
96
  type: 'object',
@@ -567,29 +173,426 @@ const defaultSchema = {
567
173
  required: ['myProperty'],
568
174
  };
569
175
  function primitiveTypeFixture(title, schema = defaultSchema) {
570
- return (0, arbitraryTypeResolution_1.PrimitiveType)({
176
+ return (0, TypeResolver_1.PrimitiveType)({
571
177
  ...schema,
572
178
  title,
573
179
  });
574
180
  }
575
181
  function resolvableTypeFixture(title, schema = defaultSchema) {
576
- return (0, arbitraryTypeResolution_1.ResolvableType)({
182
+ return (0, TypeResolver_1.ResolvableType)({
577
183
  ...schema,
578
184
  title,
579
185
  });
580
186
  }
581
187
  describe('JsonSchemaService', () => {
188
+ let jsonSchemaService;
189
+ beforeAll(() => {
190
+ const typeResolver = new TypeResolver_1.TypeResolver([primitiveTypes_1.FormattedTextType]);
191
+ jsonSchemaService = new JsonValidationService_1.JSONSchemaService(typeResolver, JsonValidationService_1.ComponentInputMetaSchema);
192
+ });
193
+ describe('validateContentSchema', () => {
194
+ it('should return true for a valid content schema', () => {
195
+ const contentSchema = {
196
+ type: 'object',
197
+ properties: {
198
+ 'my-input': { type: 'number' },
199
+ },
200
+ required: ['my-input'],
201
+ };
202
+ const result = jsonSchemaService.validateInput(contentSchema);
203
+ expect(result).toBe(true);
204
+ });
205
+ it('should return false for an invalid content schema, where the required property is missed from a child object', () => {
206
+ const contentSchema = {
207
+ type: 'object',
208
+ properties: {
209
+ 'my-input': {
210
+ type: 'object',
211
+ properties: {
212
+ 'my-deep-input': { type: 'object' },
213
+ },
214
+ },
215
+ },
216
+ required: ['my-input'],
217
+ };
218
+ expectToThrowErrorMatchingTypeAndMessage(() => {
219
+ jsonSchemaService.validateInput(contentSchema);
220
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: The required property `required` is missing at `#/properties/my-input`');
221
+ });
222
+ it('should throw a SchemaValidationError for an invalid content schema, top level type must be object', () => {
223
+ const contentSchema = {
224
+ type: 'array',
225
+ items: {
226
+ type: 'object',
227
+ properties: {
228
+ 'my-input': { type: 'number' },
229
+ },
230
+ required: ['my-input'],
231
+ },
232
+ };
233
+ expectToThrowErrorMatchingTypeAndMessage(() => {
234
+ jsonSchemaService.validateInput(contentSchema);
235
+ }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected value at \`#/type\` to be \`object\`, but value given is \`array\``);
236
+ });
237
+ it('should throw a SchemaValidationError for an invalid content schema missing the required property', () => {
238
+ const contentSchema = {
239
+ type: 'object',
240
+ properties: {
241
+ 'my-input': { type: 'number' },
242
+ },
243
+ };
244
+ expectToThrowErrorMatchingTypeAndMessage(() => {
245
+ jsonSchemaService.validateInput(contentSchema);
246
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: The required property `required` is missing at `#`');
247
+ });
248
+ });
249
+ describe('FormattedText input', () => {
250
+ it('should handle type as an array', () => {
251
+ const functionInputSchema = {
252
+ type: 'object',
253
+ properties: {
254
+ 'my-input': { type: ['number', 'string'] },
255
+ },
256
+ required: ['my-input'],
257
+ };
258
+ expect(jsonSchemaService.validateInput({
259
+ 'my-input': 'formattedText',
260
+ }, functionInputSchema)).toEqual(true);
261
+ expect(jsonSchemaService.validateInput({
262
+ 'my-input': 123,
263
+ }, functionInputSchema)).toEqual(true);
264
+ });
265
+ it.failing('should handle type is an array of both string and FormattedText', () => {
266
+ const formattedText = [
267
+ {
268
+ tag: 'p',
269
+ type: 'tag',
270
+ children: [
271
+ { type: 'text', value: 'This is some ' },
272
+ { type: 'text', value: 'Link to asset 12345' },
273
+ { type: 'text', value: ' with an image ' },
274
+ { type: 'text', value: '.' },
275
+ ],
276
+ },
277
+ ];
278
+ const functionInputSchema = {
279
+ type: 'object',
280
+ properties: {
281
+ 'my-input': { type: ['FormattedText', 'string'] },
282
+ },
283
+ required: ['my-input'],
284
+ };
285
+ expect(jsonSchemaService.validateInput({
286
+ 'my-input': formattedText,
287
+ }, functionInputSchema)).toEqual(true);
288
+ expect(jsonSchemaService.validateInput({
289
+ 'my-input': 'hello',
290
+ }, functionInputSchema)).toEqual(true);
291
+ });
292
+ it('should return true if input is formatted text', () => {
293
+ const functionInputSchema = {
294
+ type: 'object',
295
+ properties: {
296
+ 'my-input': { type: 'FormattedText' },
297
+ },
298
+ required: ['my-input'],
299
+ };
300
+ const formattedText = [
301
+ {
302
+ tag: 'p',
303
+ type: 'tag',
304
+ children: [
305
+ { type: 'text', value: 'This is some ' },
306
+ { type: 'text', value: 'Link to asset 12345' },
307
+ { type: 'text', value: ' with an image ' },
308
+ { type: 'text', value: '.' },
309
+ ],
310
+ },
311
+ ];
312
+ const inputValue = {
313
+ 'my-input': formattedText,
314
+ };
315
+ expect(() => jsonSchemaService.validateInput(inputValue, functionInputSchema)).not.toThrow();
316
+ });
317
+ it('should throw an error if the FormattedText input is not formatted text', () => {
318
+ const functionInputSchema = {
319
+ type: 'object',
320
+ properties: {
321
+ 'my-input': { type: 'FormattedText' },
322
+ },
323
+ required: ['my-input'],
324
+ };
325
+ const inputValue = {
326
+ 'my-input': 123,
327
+ };
328
+ expectToThrowErrorMatchingTypeAndMessage(() => {
329
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
330
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Value `123` in `#/my-input` does not match any given oneof schema');
331
+ });
332
+ it('should throw an error if the FormattedText input is invalid formatted text', () => {
333
+ const functionInputSchema = {
334
+ type: 'object',
335
+ properties: {
336
+ 'my-input': { type: 'FormattedText' },
337
+ },
338
+ required: ['my-input'],
339
+ };
340
+ const inputValue = {
341
+ 'my-input': {
342
+ something: 'aa',
343
+ },
344
+ };
345
+ expectToThrowErrorMatchingTypeAndMessage(() => {
346
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
347
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Value `{"something":"aa"}` in `#/my-input` does not match any given oneof schema');
348
+ });
349
+ it('should throw an error if the FormattedText input is invalid formatted text (deeply nested)', () => {
350
+ const functionInputSchema = {
351
+ type: 'object',
352
+ properties: {
353
+ 'my-input': { type: 'FormattedText' },
354
+ },
355
+ required: ['my-input'],
356
+ };
357
+ const formattedText = [
358
+ {
359
+ tag: 'p',
360
+ type: 'tag',
361
+ children: [
362
+ { type: 'text', value: 'This is some ' },
363
+ { type: 'text', value: 'Link to asset 12345' },
364
+ { type: 'text', value: ' with an image ' },
365
+ { type: 'text', value: 123 },
366
+ { type: 'text', value: '.' },
367
+ ],
368
+ },
369
+ ];
370
+ const inputValue = {
371
+ 'my-input': formattedText,
372
+ };
373
+ expectToThrowErrorMatchingTypeAndMessage(() => {
374
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
375
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Value `[{"tag":"p","type":"tag","children":[{"type":"text","value":"This is some "},{"type":"text","value":"Link to asset 12345"},{"type":"text","value":" with an image "},{"type":"text","value":123},{"type":"text","value":"."}]}]` in `#/my-input` does not match any given oneof schema');
376
+ });
377
+ it('should validate an array of formatted texts', () => {
378
+ const formattedText = [
379
+ {
380
+ tag: 'p',
381
+ type: 'tag',
382
+ children: [{ type: 'text', value: 'hello' }],
383
+ },
384
+ ];
385
+ const schema = {
386
+ type: 'object',
387
+ properties: {
388
+ arr: {
389
+ type: 'array',
390
+ items: { type: 'FormattedText' },
391
+ },
392
+ },
393
+ };
394
+ const value = {
395
+ arr: [formattedText],
396
+ };
397
+ expect(jsonSchemaService.validateInput(value, schema)).toEqual(true);
398
+ });
399
+ it('should throw an error if the FormattedText input is invalid formatted text (deeply, deeply nested)', () => {
400
+ const formattedText = [
401
+ {
402
+ tag: 'p',
403
+ type: 'tag',
404
+ children: [{ type: 'text', value: 'hello' }],
405
+ },
406
+ ];
407
+ const inputValue = {
408
+ 'my-input': formattedText,
409
+ deep: {
410
+ arr: [
411
+ {
412
+ prop: formattedText,
413
+ formattedTextArray: [formattedText, formattedText, { bad: 'data' }],
414
+ },
415
+ ],
416
+ },
417
+ };
418
+ const functionInputSchema = {
419
+ type: 'object',
420
+ properties: {
421
+ 'my-input': { type: 'FormattedText' },
422
+ deep: {
423
+ type: 'object',
424
+ properties: {
425
+ arr: {
426
+ type: 'array',
427
+ items: {
428
+ type: 'object',
429
+ required: ['prop', 'formattedTextArray'],
430
+ properties: {
431
+ prop: 'FormattedText',
432
+ formattedTextArray: {
433
+ type: 'array',
434
+ items: {
435
+ type: 'FormattedText',
436
+ },
437
+ },
438
+ },
439
+ },
440
+ },
441
+ },
442
+ required: ['arr'],
443
+ },
444
+ },
445
+ required: ['my-input', 'deep'],
446
+ };
447
+ expectToThrowErrorMatchingTypeAndMessage(() => {
448
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
449
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Value `{"bad":"data"}` in `#/deep/arr/0/formattedTextArray/2` does not match any given oneof schema');
450
+ });
451
+ it('should validate a FormattedText value when the schema is a $ref', async () => {
452
+ const formattedText = [
453
+ {
454
+ tag: 'p',
455
+ type: 'tag',
456
+ children: [{ type: 'text', value: 'hello' }],
457
+ },
458
+ ];
459
+ const schema = {
460
+ type: 'object',
461
+ properties: {
462
+ 'my-input': { $ref: '#/definitions/FormattedText' },
463
+ },
464
+ definitions: {
465
+ FormattedText: { type: 'FormattedText' },
466
+ },
467
+ required: ['my-input'],
468
+ };
469
+ const value = {
470
+ 'my-input': formattedText,
471
+ };
472
+ expect(jsonSchemaService.validateInput(value, schema)).toEqual(true);
473
+ });
474
+ it('should error when a FormattedText value is invalid when the schema is a $ref', async () => {
475
+ const schema = {
476
+ type: 'object',
477
+ properties: {
478
+ 'my-input': { $ref: '#/definitions/FormattedText' },
479
+ },
480
+ definitions: {
481
+ FormattedText: { type: 'FormattedText' },
482
+ },
483
+ required: ['my-input'],
484
+ };
485
+ const value = {
486
+ 'my-input': { bad: 'data' },
487
+ };
488
+ expectToThrowErrorMatchingTypeAndMessage(() => {
489
+ jsonSchemaService.validateInput(value, schema);
490
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Value `{"bad":"data"}` in `#/my-input` does not match any given oneof schema');
491
+ });
492
+ it('should validate a FormattedText value when the schema is a $ref to a $ref', async () => {
493
+ const formattedText = [
494
+ {
495
+ tag: 'p',
496
+ type: 'tag',
497
+ children: [{ type: 'text', value: 'hello' }],
498
+ },
499
+ ];
500
+ const schema = {
501
+ type: 'object',
502
+ properties: {
503
+ 'my-input': { $ref: '#/definitions/FormattedText' },
504
+ },
505
+ definitions: {
506
+ FormattedText: { $ref: '#/definitions/FormattedText2' },
507
+ FormattedText2: { type: 'FormattedText' },
508
+ },
509
+ required: ['my-input'],
510
+ };
511
+ const value = {
512
+ 'my-input': formattedText,
513
+ };
514
+ expect(jsonSchemaService.validateInput(value, schema)).toEqual(true);
515
+ });
516
+ it('should validate a FormattedText value when the schema is in an if/then/else', async () => {
517
+ const formattedText = [
518
+ {
519
+ tag: 'p',
520
+ type: 'tag',
521
+ children: [{ type: 'text', value: 'hello' }],
522
+ },
523
+ ];
524
+ const schema = {
525
+ type: 'object',
526
+ properties: {
527
+ 'my-input': {
528
+ if: { type: 'string' },
529
+ then: { type: 'string' },
530
+ else: { type: 'FormattedText' },
531
+ },
532
+ },
533
+ required: ['my-input'],
534
+ };
535
+ const value = {
536
+ 'my-input': formattedText,
537
+ };
538
+ expect(jsonSchemaService.validateInput(value, schema)).toEqual(true);
539
+ });
540
+ });
541
+ describe('standard inputs', () => {
542
+ const functionInputSchema = {
543
+ type: 'object',
544
+ properties: {
545
+ 'my-input': { type: 'number' },
546
+ },
547
+ required: ['my-input'],
548
+ };
549
+ it('should return true for valid input values', () => {
550
+ const inputValue = {
551
+ 'my-input': 123,
552
+ };
553
+ const result = jsonSchemaService.validateInput(inputValue, functionInputSchema);
554
+ expect(result).toBe(true);
555
+ });
556
+ it('should throw a SchemaValidationError for invalid input type', () => {
557
+ const inputValue = {
558
+ 'my-input': '123',
559
+ };
560
+ expectToThrowErrorMatchingTypeAndMessage(() => {
561
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
562
+ }, SchemaValidationError_1.SchemaValidationError, `failed validation: Expected \`123\` (string) in \`#/my-input\` to be of type \`number\``);
563
+ });
564
+ it('should throw a SchemaValidationError for invalid input missing properties', () => {
565
+ const inputValue = {};
566
+ expectToThrowErrorMatchingTypeAndMessage(() => {
567
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
568
+ }, SchemaValidationError_1.SchemaValidationError, `failed validation: The required property \`my-input\` is missing at \`#\``);
569
+ });
570
+ it('should throw a SchemaValidationError with a truncated enum value list if there are more than 5 enum options', () => {
571
+ expectToThrowErrorMatchingTypeAndMessage(() => {
572
+ jsonSchemaService.validateInput({ enum: 'z' }, { type: 'object', properties: { enum: { type: 'string', enum: ['a', 'b', 'c', 'd', 'e', 'f', 'g'] } } });
573
+ }, SchemaValidationError_1.SchemaValidationError, 'failed validation: Expected given value `z` in #/enum` to be one of `[a, b, c, d, e, ... 2 more]`');
574
+ });
575
+ // TODO DEVX-658
576
+ it.skip('should throw a SchemaValidationError for invalid input additional properties', () => {
577
+ const inputValue = {
578
+ 'my-input': 123,
579
+ 'my-input-2': 123,
580
+ };
581
+ expect(() => {
582
+ jsonSchemaService.validateInput(inputValue, functionInputSchema);
583
+ }).toThrowErrorMatchingInlineSnapshot();
584
+ });
585
+ });
582
586
  describe('validateInput', () => {
583
587
  it.each([String('123'), Number(123), [123]])('should validate any primitive type with its resolvable type %s', (propertyValue) => {
584
588
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
585
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
586
- MyPrimitive: primitiveSchema,
587
- }, {
588
- MyResolvableNumber: resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
589
- MyResolvableArray: resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
590
- }, {
589
+ const MyResolvableNumber = resolvableTypeFixture('MyResolvableNumber', { type: 'number' });
590
+ const MyResolvableArray = resolvableTypeFixture('MyResolvableArray', { type: 'array' });
591
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [MyResolvableNumber, MyResolvableArray], {
591
592
  MyPrimitive: {
593
+ // @ts-expect-error - fixture is unknown but we know the actual shape
592
594
  MyResolvableNumber: (value) => value.toString(),
595
+ // @ts-expect-error - fixture is unknown but we know the actual shape
593
596
  MyResolvableArray: (value) => value.join(''),
594
597
  },
595
598
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -597,14 +600,13 @@ describe('JsonSchemaService', () => {
597
600
  });
598
601
  it('should error when a primitive type is provided a value that cannot be resolved by its resolvable types', () => {
599
602
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
600
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
601
- MyPrimitive: primitiveSchema,
602
- }, {
603
- MyResolvableNumber: resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
604
- MyResolvableArray: resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
605
- }, {
603
+ const MyResolvableNumber = resolvableTypeFixture('MyResolvableNumber', { type: 'number' });
604
+ const MyResolvableArray = resolvableTypeFixture('MyResolvableArray', { type: 'array' });
605
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [MyResolvableNumber, MyResolvableArray], {
606
606
  MyPrimitive: {
607
+ // @ts-expect-error - fixture is unknown but we know the actual shape
607
608
  MyResolvableNumber: (value) => value.toString(),
609
+ // @ts-expect-error - fixture is unknown but we know the actual shape
608
610
  MyResolvableArray: (value) => value.join(''),
609
611
  },
610
612
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -614,14 +616,13 @@ describe('JsonSchemaService', () => {
614
616
  });
615
617
  it.each([String('123'), Number(123), [123]])('should validate a primitive type when defined as a ref with resolvable value %s', (propertyValue) => {
616
618
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
617
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
618
- MyPrimitive: primitiveSchema,
619
- }, {
620
- MyResolvableNumber: resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
621
- MyResolvableArray: resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
622
- }, {
619
+ const MyResolvableNumber = resolvableTypeFixture('MyResolvableNumber', { type: 'number' });
620
+ const MyResolvableArray = resolvableTypeFixture('MyResolvableArray', { type: 'array' });
621
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [MyResolvableNumber, MyResolvableArray], {
623
622
  MyPrimitive: {
623
+ // @ts-expect-error - fixture is unknown but we know the actual shape
624
624
  MyResolvableNumber: (value) => value.toString(),
625
+ // @ts-expect-error - fixture is unknown but we know the actual shape
625
626
  MyResolvableArray: (value) => value.join(''),
626
627
  },
627
628
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -633,13 +634,11 @@ describe('JsonSchemaService', () => {
633
634
  });
634
635
  it('should not validate on a primitive type against a resolvable type when a resolver is not defined', () => {
635
636
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
636
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
637
- MyPrimitive: primitiveSchema,
638
- }, {
639
- MyResolvableNumber: resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
640
- MyResolvableArray: resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
641
- }, {
637
+ const MyResolvableNumber = resolvableTypeFixture('MyResolvableNumber', { type: 'number' });
638
+ const MyResolvableArray = resolvableTypeFixture('MyResolvableArray', { type: 'array' });
639
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [MyResolvableNumber, MyResolvableArray], {
642
640
  MyPrimitive: {
641
+ // @ts-expect-error - fixture is unknown but we know the actual shape
643
642
  MyResolvableNumber: (value) => value.toString(),
644
643
  },
645
644
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -649,24 +648,24 @@ describe('JsonSchemaService', () => {
649
648
  });
650
649
  it('should validate a primitive type against similar but different resolvable types', () => {
651
650
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
652
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
653
- MyPrimitive: primitiveSchema,
654
- }, {
655
- MyResolvableSrcNumber: resolvableTypeFixture('MyResolvableSrcNumber', {
651
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [
652
+ resolvableTypeFixture('MyResolvableSrcNumber', {
656
653
  type: 'object',
657
654
  properties: {
658
655
  src: { type: 'number' },
659
656
  },
660
657
  }),
661
- MyResolvableSrcString: resolvableTypeFixture('MyResolvableSrcString', {
658
+ resolvableTypeFixture('MyResolvableSrcString', {
662
659
  type: 'object',
663
660
  properties: {
664
661
  src: { type: 'string' },
665
662
  },
666
663
  }),
667
- }, {
664
+ ], {
668
665
  MyPrimitive: {
666
+ // @ts-expect-error - fixture is unknown but we know the actual shape
669
667
  MyResolvableSrcNumber: (value) => value.src.toString(),
668
+ // @ts-expect-error - fixture is unknown but we know the actual shape
670
669
  MyResolvableSrcString: (value) => value.src,
671
670
  },
672
671
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -685,14 +684,14 @@ describe('JsonSchemaService', () => {
685
684
  describe('resolveInput', () => {
686
685
  it.each([String('123'), Number(123), [123]])('should resolve a primitive type from its resolvable type %s', async (resolvableValue) => {
687
686
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
688
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
689
- MyPrimitive: primitiveSchema,
690
- }, {
691
- MyResolvableNumber: resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
692
- MyResolvableArray: resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
693
- }, {
687
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [
688
+ resolvableTypeFixture('MyResolvableNumber', { type: 'number' }),
689
+ resolvableTypeFixture('MyResolvableArray', { type: 'array' }),
690
+ ], {
694
691
  MyPrimitive: {
692
+ // @ts-expect-error - fixture is unknown but we know the actual shape
695
693
  MyResolvableNumber: (value) => value.toString(),
694
+ // @ts-expect-error - fixture is unknown but we know the actual shape
696
695
  MyResolvableArray: (value) => value.join(''),
697
696
  },
698
697
  }), JsonValidationService_1.ComponentInputMetaSchema);
@@ -703,20 +702,20 @@ describe('JsonSchemaService', () => {
703
702
  [{ src: 1132 }, '1132'],
704
703
  ])('should resolve a resolvable type %s against the correct resolver to %s', async (resolvableValue, output) => {
705
704
  const primitiveSchema = primitiveTypeFixture('MyPrimitive', { type: 'string' });
706
- const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new arbitraryTypeResolution_1.TypeResolver({
707
- MyPrimitive: primitiveSchema,
708
- }, {
709
- MyResolvableSrcString: resolvableTypeFixture('MyResolvableSrcString', {
705
+ const jsonSchemaService = new JsonValidationService_1.JSONSchemaService(new TypeResolver_1.TypeResolver([primitiveSchema], [
706
+ resolvableTypeFixture('MyResolvableSrcString', {
710
707
  type: 'object',
711
708
  properties: { src: { type: 'string' } },
712
709
  }),
713
- MyResolvableSrcNumber: resolvableTypeFixture('MyResolvableSrcNumber', {
710
+ resolvableTypeFixture('MyResolvableSrcNumber', {
714
711
  type: 'object',
715
712
  properties: { src: { type: 'number' } },
716
713
  }),
717
- }, {
714
+ ], {
718
715
  MyPrimitive: {
716
+ // @ts-expect-error - fixture is unknown but we know the actual shape
719
717
  MyResolvableSrcNumber: (value) => value.src.toString(),
718
+ // @ts-expect-error - fixture is unknown but we know the actual shape
720
719
  MyResolvableSrcString: (value) => value.src,
721
720
  },
722
721
  }), JsonValidationService_1.ComponentInputMetaSchema);