@squiz/dx-json-schema-lib 1.76.3 → 1.78.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -145,7 +145,24 @@
145
145
  "matrixIdentifier": { "type": "string", "minLength": 1 },
146
146
  "matrixDomain": { "type": "string", "minLength": 1 },
147
147
  "matrixAssetId": { "type": "string", "minLength": 1 },
148
- "target": { "type": "string", "enum": ["_blank", "_self", "_parent", "_top"] }
148
+ "target": { "type": "string", "enum": ["_blank", "_self", "_parent", "_top"] },
149
+ "attributes": {
150
+ "allOf": [
151
+ {
152
+ "type": "object",
153
+ "properties": {
154
+ "href": false,
155
+ "target": false
156
+ }
157
+ },
158
+ {
159
+ "type": "object",
160
+ "additionalProperties": {
161
+ "type": "string"
162
+ }
163
+ }
164
+ ]
165
+ }
149
166
  },
150
167
  "required": ["type", "matrixDomain", "matrixAssetId", "target", "children"]
151
168
  },
@@ -159,7 +176,23 @@
159
176
  "matrixIdentifier": { "type": "string", "minLength": 1 },
160
177
  "matrixDomain": { "type": "string", "minLength": 1 },
161
178
  "matrixAssetId": { "type": "string", "minLength": 1 },
162
- "formattingOptions": { "$ref": "#/definitions/FormattingOptions" }
179
+ "formattingOptions": { "$ref": "#/definitions/FormattingOptions" },
180
+ "attributes": {
181
+ "allOf": [
182
+ {
183
+ "type": "object",
184
+ "properties": {
185
+ "src": false
186
+ }
187
+ },
188
+ {
189
+ "type": "object",
190
+ "additionalProperties": {
191
+ "type": "string"
192
+ }
193
+ }
194
+ ]
195
+ }
163
196
  },
164
197
  "required": ["type", "matrixDomain", "matrixAssetId"]
165
198
  },
@@ -174,7 +207,23 @@
174
207
  "damSystemIdentifier": { "type": "string", "minLength": 1 },
175
208
  "damObjectId": { "type": "string", "minLength": 1 },
176
209
  "damAdditional": { "type": "object", "properties": { "variant": { "type": "string", "minLength": 1 } } },
177
- "formattingOptions": { "$ref": "#/definitions/FormattingOptions" }
210
+ "formattingOptions": { "$ref": "#/definitions/FormattingOptions" },
211
+ "attributes": {
212
+ "allOf": [
213
+ {
214
+ "type": "object",
215
+ "properties": {
216
+ "src": false
217
+ }
218
+ },
219
+ {
220
+ "type": "object",
221
+ "additionalProperties": {
222
+ "type": "string"
223
+ }
224
+ }
225
+ ]
226
+ }
178
227
  },
179
228
  "required": ["type", "damSystemType", "damSystemIdentifier", "damObjectId"]
180
229
  }
@@ -22,6 +22,13 @@ export interface FormattedTextLinkToMatrixAsset {
22
22
  matrixDomain: string;
23
23
  matrixAssetId: string;
24
24
  target: '_blank' | '_self' | '_parent' | '_top';
25
+ attributes?: {
26
+ href?: never;
27
+ target?: never;
28
+ [k: string]: unknown;
29
+ } & {
30
+ [k: string]: string;
31
+ };
25
32
  }
26
33
  export interface FormattingOptions {
27
34
  alignment?: 'center' | 'left' | 'right' | 'justify';
@@ -33,6 +40,12 @@ export interface FormattedTextMatrixImage {
33
40
  matrixDomain: string;
34
41
  matrixAssetId: string;
35
42
  formattingOptions?: FormattingOptions;
43
+ attributes?: {
44
+ src?: never;
45
+ [k: string]: unknown;
46
+ } & {
47
+ [k: string]: string;
48
+ };
36
49
  }
37
50
  export interface FormattedTextDamImage {
38
51
  type: 'dam-image';
@@ -44,6 +57,12 @@ export interface FormattedTextDamImage {
44
57
  [k: string]: unknown;
45
58
  };
46
59
  formattingOptions?: FormattingOptions;
60
+ attributes?: {
61
+ src?: never;
62
+ [k: string]: unknown;
63
+ } & {
64
+ [k: string]: string;
65
+ };
47
66
  }
48
67
  export interface FormattedTextTag {
49
68
  children?: WithChildrenNode;
@@ -67,7 +67,14 @@
67
67
  "type": ["number", "integer", "array", "boolean", "string"]
68
68
  }
69
69
  }
70
- ]
70
+ ],
71
+ "properties": {
72
+ "autoReload": {
73
+ "type": "boolean",
74
+ "description": "Whether the component should automatically reload when the input is changed",
75
+ "default": false
76
+ }
77
+ }
71
78
  }
72
79
  },
73
80
  "type": ["object", "boolean"],
@@ -14,6 +14,21 @@ export type DxComponentInputSchema = CoreSchemaMetaSchema & {
14
14
  [k: string]: unknown;
15
15
  };
16
16
  export type CoreSchemaMetaSchema = CoreSchemaMetaSchema1 & CoreSchemaMetaSchema2;
17
+ export type UiMetadata = {
18
+ /**
19
+ * Whether the component should automatically reload when the input is changed
20
+ */
21
+ autoReload?: boolean;
22
+ [k: string]: unknown;
23
+ } & (
24
+ | {
25
+ collapsedByDefault?: boolean;
26
+ }
27
+ | {
28
+ inlineEditable?: boolean;
29
+ quickOption?: boolean;
30
+ }
31
+ );
17
32
  export type CoreSchemaMetaSchema2 =
18
33
  | {
19
34
  $id?: string;
@@ -30,26 +45,26 @@ export type CoreSchemaMetaSchema2 =
30
45
  $comment?: string;
31
46
  title?: string;
32
47
  description?: string;
33
- default?: true;
48
+ default?: unknown;
34
49
  readOnly?: boolean;
35
50
  writeOnly?: boolean;
36
- examples?: true[];
51
+ examples?: unknown[];
37
52
  multipleOf?: number;
38
53
  maximum?: number;
39
54
  exclusiveMaximum?: number;
40
55
  minimum?: number;
41
56
  exclusiveMinimum?: number;
42
57
  maxLength?: number;
43
- minLength?: number & number;
58
+ minLength?: number;
44
59
  pattern?: string;
45
60
  additionalItems?: CoreSchemaMetaSchema2;
46
61
  items?: CoreSchemaMetaSchema2 | SchemaArray;
47
62
  maxItems?: number;
48
- minItems?: number & number;
63
+ minItems?: number;
49
64
  uniqueItems?: boolean;
50
65
  contains?: CoreSchemaMetaSchema2;
51
66
  maxProperties?: number;
52
- minProperties?: number & number;
67
+ minProperties?: number;
53
68
  required?: StringArray;
54
69
  additionalProperties?: CoreSchemaMetaSchema2;
55
70
  definitions?: {
@@ -65,11 +80,11 @@ export type CoreSchemaMetaSchema2 =
65
80
  [k: string]: CoreSchemaMetaSchema2 | StringArray;
66
81
  };
67
82
  propertyNames?: CoreSchemaMetaSchema2;
68
- const?: true;
83
+ const?: unknown;
69
84
  /**
70
85
  * @minItems 1
71
86
  */
72
- enum?: true[];
87
+ enum?: unknown[];
73
88
  type?:
74
89
  | (
75
90
  | 'array'
@@ -270,39 +285,32 @@ export interface JobFunction {
270
285
  }
271
286
  export interface CoreSchemaMetaSchema1 {
272
287
  $id?: string;
273
- 'ui:metadata'?:
274
- | {
275
- collapsedByDefault?: boolean;
276
- }
277
- | {
278
- inlineEditable?: boolean;
279
- quickOption?: boolean;
280
- };
288
+ 'ui:metadata'?: UiMetadata;
281
289
  $schema?: string;
282
290
  $ref?: string;
283
291
  $comment?: string;
284
292
  title?: string;
285
293
  description?: string;
286
- default?: true;
294
+ default?: unknown;
287
295
  readOnly?: boolean;
288
296
  writeOnly?: boolean;
289
- examples?: true[];
297
+ examples?: unknown[];
290
298
  multipleOf?: number;
291
299
  maximum?: number;
292
300
  exclusiveMaximum?: number;
293
301
  minimum?: number;
294
302
  exclusiveMinimum?: number;
295
303
  maxLength?: number;
296
- minLength?: number & number;
304
+ minLength?: number;
297
305
  pattern?: string;
298
306
  additionalItems?: CoreSchemaMetaSchema2;
299
307
  items?: CoreSchemaMetaSchema2 | SchemaArray;
300
308
  maxItems?: number;
301
- minItems?: number & number;
309
+ minItems?: number;
302
310
  uniqueItems?: boolean;
303
311
  contains?: CoreSchemaMetaSchema2;
304
312
  maxProperties?: number;
305
- minProperties?: number & number;
313
+ minProperties?: number;
306
314
  required?: StringArray;
307
315
  additionalProperties?: CoreSchemaMetaSchema2;
308
316
  definitions?: {
@@ -318,11 +326,11 @@ export interface CoreSchemaMetaSchema1 {
318
326
  [k: string]: CoreSchemaMetaSchema2 | StringArray;
319
327
  };
320
328
  propertyNames?: CoreSchemaMetaSchema2;
321
- const?: true;
329
+ const?: unknown;
322
330
  /**
323
331
  * @minItems 1
324
332
  */
325
- enum?: true[];
333
+ enum?: unknown[];
326
334
  type?:
327
335
  | (
328
336
  | 'array'
@@ -449,6 +449,15 @@
449
449
  }
450
450
  ]
451
451
  }
452
+ },
453
+ "ui:metadata": {
454
+ "properties": {
455
+ "autoReload": {
456
+ "type": "boolean",
457
+ "default": "false"
458
+ }
459
+ },
460
+ "required": ["autoReload"]
452
461
  }
453
462
  },
454
463
  "required": ["name", "namespace", "displayName", "description", "version", "functions", "$schema", "mainFunction"],
@@ -346,6 +346,37 @@ describe('manifest/v1', () => {
346
346
  'failed validation: Value `{"collapsedByDefault":true,"quickOption":false,"inlineEditable":true}` in `#/functions/0/input/properties/users-contact/ui:metadata` does not match any given oneof schema',
347
347
  );
348
348
  });
349
+ it('should allow the autoReload field on the manifest', async () => {
350
+ const manifest = await fetchTestManifest('validComponent.json');
351
+
352
+ expect(
353
+ validationService.validateManifest(
354
+ {
355
+ ...manifest,
356
+ 'ui:metadata': {
357
+ autoReload: false,
358
+ },
359
+ },
360
+ 'v1',
361
+ ),
362
+ ).toEqual(true);
363
+ });
364
+ it('autoReload is required if ui:metadata is specified on the root of the manifest', async () => {
365
+ const manifest = await fetchTestManifest('validComponent.json');
366
+ expectToThrowErrorMatchingTypeAndMessage(
367
+ () => {
368
+ validationService.validateManifest(
369
+ {
370
+ ...manifest,
371
+ 'ui:metadata': {},
372
+ },
373
+ 'v1',
374
+ );
375
+ },
376
+ SchemaValidationError,
377
+ 'failed validation: The required property `autoReload` is missing at `#/ui:metadata`',
378
+ );
379
+ });
349
380
  it('should fail if ui:metadata property on object with type string has collapsedByDefault flag', async () => {
350
381
  const manifest = await fetchTestManifest('validComponent.json');
351
382
  expectToThrowErrorMatchingTypeAndMessage(
@@ -14,6 +14,21 @@ export type DxComponentInputSchema = CoreSchemaMetaSchema & {
14
14
  [k: string]: unknown;
15
15
  };
16
16
  export type CoreSchemaMetaSchema = CoreSchemaMetaSchema1 & CoreSchemaMetaSchema2;
17
+ export type UiMetadata = {
18
+ /**
19
+ * Whether the component should automatically reload when the input is changed
20
+ */
21
+ autoReload?: boolean;
22
+ [k: string]: unknown;
23
+ } & (
24
+ | {
25
+ collapsedByDefault?: boolean;
26
+ }
27
+ | {
28
+ inlineEditable?: boolean;
29
+ quickOption?: boolean;
30
+ }
31
+ );
17
32
  export type CoreSchemaMetaSchema2 =
18
33
  | {
19
34
  $id?: string;
@@ -30,26 +45,26 @@ export type CoreSchemaMetaSchema2 =
30
45
  $comment?: string;
31
46
  title?: string;
32
47
  description?: string;
33
- default?: true;
48
+ default?: unknown;
34
49
  readOnly?: boolean;
35
50
  writeOnly?: boolean;
36
- examples?: true[];
51
+ examples?: unknown[];
37
52
  multipleOf?: number;
38
53
  maximum?: number;
39
54
  exclusiveMaximum?: number;
40
55
  minimum?: number;
41
56
  exclusiveMinimum?: number;
42
57
  maxLength?: number;
43
- minLength?: number & number;
58
+ minLength?: number;
44
59
  pattern?: string;
45
60
  additionalItems?: CoreSchemaMetaSchema2;
46
61
  items?: CoreSchemaMetaSchema2 | SchemaArray;
47
62
  maxItems?: number;
48
- minItems?: number & number;
63
+ minItems?: number;
49
64
  uniqueItems?: boolean;
50
65
  contains?: CoreSchemaMetaSchema2;
51
66
  maxProperties?: number;
52
- minProperties?: number & number;
67
+ minProperties?: number;
53
68
  required?: StringArray;
54
69
  additionalProperties?: CoreSchemaMetaSchema2;
55
70
  definitions?: {
@@ -65,11 +80,11 @@ export type CoreSchemaMetaSchema2 =
65
80
  [k: string]: CoreSchemaMetaSchema2 | StringArray;
66
81
  };
67
82
  propertyNames?: CoreSchemaMetaSchema2;
68
- const?: true;
83
+ const?: unknown;
69
84
  /**
70
85
  * @minItems 1
71
86
  */
72
- enum?: true[];
87
+ enum?: unknown[];
73
88
  type?:
74
89
  | (
75
90
  | 'array'
@@ -223,26 +238,26 @@ export type CoreSchemaMetaSchema5 =
223
238
  $comment?: string;
224
239
  title?: string;
225
240
  description?: string;
226
- default?: true;
241
+ default?: unknown;
227
242
  readOnly?: boolean;
228
243
  writeOnly?: boolean;
229
- examples?: true[];
244
+ examples?: unknown[];
230
245
  multipleOf?: number;
231
246
  maximum?: number;
232
247
  exclusiveMaximum?: number;
233
248
  minimum?: number;
234
249
  exclusiveMinimum?: number;
235
250
  maxLength?: number;
236
- minLength?: number & number;
251
+ minLength?: number;
237
252
  pattern?: string;
238
253
  additionalItems?: CoreSchemaMetaSchema5;
239
254
  items?: CoreSchemaMetaSchema5 | SchemaArray1;
240
255
  maxItems?: number;
241
- minItems?: number & number;
256
+ minItems?: number;
242
257
  uniqueItems?: boolean;
243
258
  contains?: CoreSchemaMetaSchema5;
244
259
  maxProperties?: number;
245
- minProperties?: number & number;
260
+ minProperties?: number;
246
261
  required?: StringArray1;
247
262
  additionalProperties?: CoreSchemaMetaSchema5;
248
263
  definitions?: {
@@ -258,11 +273,11 @@ export type CoreSchemaMetaSchema5 =
258
273
  [k: string]: CoreSchemaMetaSchema5 | StringArray1;
259
274
  };
260
275
  propertyNames?: CoreSchemaMetaSchema5;
261
- const?: true;
276
+ const?: unknown;
262
277
  /**
263
278
  * @minItems 1
264
279
  */
265
- enum?: true[];
280
+ enum?: unknown[];
266
281
  type?:
267
282
  | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string')
268
283
  | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string')[];
@@ -369,6 +384,10 @@ export interface ComponentManifest {
369
384
  [k: string]: unknown;
370
385
  };
371
386
  };
387
+ 'ui:metadata'?: {
388
+ autoReload: boolean & string;
389
+ [k: string]: unknown;
390
+ };
372
391
  }
373
392
  /**
374
393
  * Icon for the component in Matrix and the DXP
@@ -2644,39 +2663,32 @@ export interface ComponentFunction {
2644
2663
  }
2645
2664
  export interface CoreSchemaMetaSchema1 {
2646
2665
  $id?: string;
2647
- 'ui:metadata'?:
2648
- | {
2649
- collapsedByDefault?: boolean;
2650
- }
2651
- | {
2652
- inlineEditable?: boolean;
2653
- quickOption?: boolean;
2654
- };
2666
+ 'ui:metadata'?: UiMetadata;
2655
2667
  $schema?: string;
2656
2668
  $ref?: string;
2657
2669
  $comment?: string;
2658
2670
  title?: string;
2659
2671
  description?: string;
2660
- default?: true;
2672
+ default?: unknown;
2661
2673
  readOnly?: boolean;
2662
2674
  writeOnly?: boolean;
2663
- examples?: true[];
2675
+ examples?: unknown[];
2664
2676
  multipleOf?: number;
2665
2677
  maximum?: number;
2666
2678
  exclusiveMaximum?: number;
2667
2679
  minimum?: number;
2668
2680
  exclusiveMinimum?: number;
2669
2681
  maxLength?: number;
2670
- minLength?: number & number;
2682
+ minLength?: number;
2671
2683
  pattern?: string;
2672
2684
  additionalItems?: CoreSchemaMetaSchema2;
2673
2685
  items?: CoreSchemaMetaSchema2 | SchemaArray;
2674
2686
  maxItems?: number;
2675
- minItems?: number & number;
2687
+ minItems?: number;
2676
2688
  uniqueItems?: boolean;
2677
2689
  contains?: CoreSchemaMetaSchema2;
2678
2690
  maxProperties?: number;
2679
- minProperties?: number & number;
2691
+ minProperties?: number;
2680
2692
  required?: StringArray;
2681
2693
  additionalProperties?: CoreSchemaMetaSchema2;
2682
2694
  definitions?: {
@@ -2692,11 +2704,11 @@ export interface CoreSchemaMetaSchema1 {
2692
2704
  [k: string]: CoreSchemaMetaSchema2 | StringArray;
2693
2705
  };
2694
2706
  propertyNames?: CoreSchemaMetaSchema2;
2695
- const?: true;
2707
+ const?: unknown;
2696
2708
  /**
2697
2709
  * @minItems 1
2698
2710
  */
2699
- enum?: true[];
2711
+ enum?: unknown[];
2700
2712
  type?:
2701
2713
  | (
2702
2714
  | 'array'
@@ -2903,26 +2915,26 @@ export interface CoreSchemaMetaSchema4 {
2903
2915
  $comment?: string;
2904
2916
  title?: string;
2905
2917
  description?: string;
2906
- default?: true;
2918
+ default?: unknown;
2907
2919
  readOnly?: boolean;
2908
2920
  writeOnly?: boolean;
2909
- examples?: true[];
2921
+ examples?: unknown[];
2910
2922
  multipleOf?: number;
2911
2923
  maximum?: number;
2912
2924
  exclusiveMaximum?: number;
2913
2925
  minimum?: number;
2914
2926
  exclusiveMinimum?: number;
2915
2927
  maxLength?: number;
2916
- minLength?: number & number;
2928
+ minLength?: number;
2917
2929
  pattern?: string;
2918
2930
  additionalItems?: CoreSchemaMetaSchema5;
2919
2931
  items?: CoreSchemaMetaSchema5 | SchemaArray1;
2920
2932
  maxItems?: number;
2921
- minItems?: number & number;
2933
+ minItems?: number;
2922
2934
  uniqueItems?: boolean;
2923
2935
  contains?: CoreSchemaMetaSchema5;
2924
2936
  maxProperties?: number;
2925
- minProperties?: number & number;
2937
+ minProperties?: number;
2926
2938
  required?: StringArray1;
2927
2939
  additionalProperties?: CoreSchemaMetaSchema5;
2928
2940
  definitions?: {
@@ -2938,11 +2950,11 @@ export interface CoreSchemaMetaSchema4 {
2938
2950
  [k: string]: CoreSchemaMetaSchema5 | StringArray1;
2939
2951
  };
2940
2952
  propertyNames?: CoreSchemaMetaSchema5;
2941
- const?: true;
2953
+ const?: unknown;
2942
2954
  /**
2943
2955
  * @minItems 1
2944
2956
  */
2945
- enum?: true[];
2957
+ enum?: unknown[];
2946
2958
  type?:
2947
2959
  | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string')
2948
2960
  | ('array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string')[];