@squiz/dx-json-schema-lib 1.21.1-alpha.2 → 1.21.1-alpha.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. package/.npm/_logs/2023-03-17T05_05_36_315Z-debug-0.log +37 -0
  2. package/lib/JsonValidationService.d.ts +1 -1
  3. package/lib/JsonValidationService.js +23 -5
  4. package/lib/JsonValidationService.js.map +1 -1
  5. package/lib/JsonValidationService.spec.js +469 -426
  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 +117 -2
  19. package/lib/manifest/v1/MatrixAssetSchema.json +390 -0
  20. package/lib/manifest/v1/__test__/schemas/inputStringWithFormat.json +29 -0
  21. package/lib/manifest/v1/subSchemas.d.ts +2 -1
  22. package/lib/manifest/v1/subSchemas.js +3 -1
  23. package/lib/manifest/v1/subSchemas.js.map +1 -1
  24. package/lib/manifest/v1/v1.d.ts +405 -4
  25. package/lib/manifest/v1/v1.json +48 -0
  26. package/lib/primitiveTypes/FormattedText.d.ts +8 -0
  27. package/lib/primitiveTypes/FormattedText.js +21 -0
  28. package/lib/primitiveTypes/FormattedText.js.map +1 -0
  29. package/lib/primitiveTypes/SquizImage.d.ts +26 -0
  30. package/lib/primitiveTypes/SquizImage.js +105 -0
  31. package/lib/primitiveTypes/SquizImage.js.map +1 -0
  32. package/lib/primitiveTypes/index.d.ts +2 -0
  33. package/lib/primitiveTypes/index.js +19 -0
  34. package/lib/primitiveTypes/index.js.map +1 -0
  35. package/lib/resolvableTypes/MatrixAsset.d.ts +9 -0
  36. package/lib/resolvableTypes/MatrixAsset.js +21 -0
  37. package/lib/resolvableTypes/MatrixAsset.js.map +1 -0
  38. package/lib/resolvableTypes/index.d.ts +1 -0
  39. package/lib/resolvableTypes/index.js +18 -0
  40. package/lib/resolvableTypes/index.js.map +1 -0
  41. package/lib/validators/customFormatValidators.d.ts +2 -0
  42. package/lib/validators/customFormatValidators.js +14 -0
  43. package/lib/validators/customFormatValidators.js.map +1 -0
  44. package/lib/validators/utils/matrixAssetValidator.d.ts +2 -0
  45. package/lib/validators/utils/matrixAssetValidator.js +11 -0
  46. package/lib/validators/utils/matrixAssetValidator.js.map +1 -0
  47. package/lib/validators/utils/matrixAssetValidator.spec.d.ts +1 -0
  48. package/lib/validators/utils/matrixAssetValidator.spec.js +43 -0
  49. package/lib/validators/utils/matrixAssetValidator.spec.js.map +1 -0
  50. package/package.json +5 -4
  51. package/src/JsonValidationService.spec.ts +596 -533
  52. package/src/JsonValidationService.ts +28 -10
  53. package/src/index.ts +8 -1
  54. package/src/jsonTypeResolution/{arbitraryTypeResolution.spec.ts → TypeResolver.spec.ts} +23 -70
  55. package/src/jsonTypeResolution/{arbitraryTypeResolution.ts → TypeResolver.ts} +27 -23
  56. package/src/jsonTypeResolution/TypeResolverBuilder.ts +43 -0
  57. package/src/manifest/v1/DxContentMetaSchema.json +117 -2
  58. package/src/manifest/v1/MatrixAssetSchema.json +391 -0
  59. package/src/manifest/v1/__test__/schemas/inputStringWithFormat.json +29 -0
  60. package/src/manifest/v1/subSchemas.ts +2 -1
  61. package/src/manifest/v1/v1.json +48 -0
  62. package/src/manifest/v1/v1.ts +657 -6
  63. package/src/primitiveTypes/FormattedText.ts +24 -0
  64. package/src/primitiveTypes/SquizImage.ts +128 -0
  65. package/src/primitiveTypes/index.ts +2 -0
  66. package/src/resolvableTypes/MatrixAsset.ts +24 -0
  67. package/src/resolvableTypes/index.ts +1 -0
  68. package/src/validators/customFormatValidators.ts +15 -0
  69. package/src/validators/utils/matrixAssetValidator.spec.ts +49 -0
  70. package/src/validators/utils/matrixAssetValidator.ts +8 -0
  71. package/tsconfig.tsbuildinfo +1 -1
  72. package/.npm/_logs/2023-03-02T03_26_09_372Z-debug-0.log +0 -39
  73. package/lib/jsonTypeResolution/arbitraryTypeResolution.js.map +0 -1
  74. package/lib/jsonTypeResolution/arbitraryTypeResolution.spec.js.map +0 -1
  75. package/lib/jsonTypeResolution/index.d.ts +0 -76
  76. package/lib/jsonTypeResolution/index.js +0 -35
  77. package/lib/jsonTypeResolution/index.js.map +0 -1
  78. package/lib/jsonTypeResolution/primitiveTypes.d.ts +0 -10
  79. package/lib/jsonTypeResolution/primitiveTypes.js +0 -27
  80. package/lib/jsonTypeResolution/primitiveTypes.js.map +0 -1
  81. package/lib/jsonTypeResolution/resolvableTypes.d.ts +0 -12
  82. package/lib/jsonTypeResolution/resolvableTypes.js +0 -30
  83. package/lib/jsonTypeResolution/resolvableTypes.js.map +0 -1
  84. package/src/jsonTypeResolution/index.ts +0 -16
  85. package/src/jsonTypeResolution/primitiveTypes.ts +0 -32
  86. package/src/jsonTypeResolution/resolvableTypes.ts +0 -37
  87. /package/lib/jsonTypeResolution/{arbitraryTypeResolution.spec.d.ts → TypeResolver.spec.d.ts} +0 -0
@@ -0,0 +1,391 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "MatrixAssetSchema.json",
4
+ "title": "Matrix asset schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "id": {
8
+ "type": "string",
9
+ "description": "The asset ID."
10
+ },
11
+ "type": {
12
+ "type": "string",
13
+ "description": "The asset type code."
14
+ },
15
+ "type_name": {
16
+ "type": "string",
17
+ "description": "The asset type friendly name."
18
+ },
19
+ "version": {
20
+ "type": "string",
21
+ "description": "The asset semantic version."
22
+ },
23
+ "name": {
24
+ "type": "string",
25
+ "description": "The asset standard field name."
26
+ },
27
+ "short_name": {
28
+ "type": "string",
29
+ "description": "The asset standard field short name."
30
+ },
31
+ "status": {
32
+ "type": "object",
33
+ "description": "A object representing the asset status of the asset resource.",
34
+ "additionalProperties": false,
35
+ "properties": {
36
+ "id": {
37
+ "type": "integer",
38
+ "format": "int32",
39
+ "description": "The bitwise id of the asset status",
40
+ "enum": [1, 2, 4, 8, 16, 32, 64, 128, 256]
41
+ },
42
+ "code": {
43
+ "type": "string",
44
+ "description": "The type code of the asset status",
45
+ "enum": [
46
+ "archived",
47
+ "under_construction",
48
+ "pending_approval",
49
+ "approved",
50
+ "live",
51
+ "live_approval",
52
+ "editing",
53
+ "editing_approval",
54
+ "editing_approved"
55
+ ]
56
+ },
57
+ "name": {
58
+ "type": "string",
59
+ "description": "The description of the asset status",
60
+ "enum": [
61
+ "Archived",
62
+ "Under Construction",
63
+ "Pending Approval",
64
+ "Approved To Go Live",
65
+ "Live",
66
+ "Up For Review",
67
+ "Safe Editing",
68
+ "Safe Editing Pending Approval",
69
+ "Safe Edit Approved To Go Live"
70
+ ]
71
+ }
72
+ },
73
+ "required": ["id", "code"]
74
+ },
75
+ "created": {
76
+ "type": "object",
77
+ "description": "A object representing when the asset status was created.",
78
+ "additionalProperties": false,
79
+ "properties": {
80
+ "date": {
81
+ "type": ["string", "null"],
82
+ "format": "date-time",
83
+ "description": "The creation date of the asset in ISO 8601 format."
84
+ },
85
+ "user_id": {
86
+ "type": ["string", "null"],
87
+ "description": "The asset ID of the User that created the asset."
88
+ }
89
+ },
90
+ "required": ["date", "user_id"]
91
+ },
92
+ "updated": {
93
+ "type": "object",
94
+ "description": "A object representing when the asset status was last updated.",
95
+ "additionalProperties": false,
96
+ "properties": {
97
+ "date": {
98
+ "type": ["string", "null"],
99
+ "format": "date-time",
100
+ "description": "The last updated date of the asset in ISO 8601 format."
101
+ },
102
+ "user_id": {
103
+ "type": ["string", "null"],
104
+ "description": "The asset ID of the User that last updated the asset."
105
+ }
106
+ },
107
+ "required": ["date", "user_id"]
108
+ },
109
+ "published": {
110
+ "type": "object",
111
+ "description": "A object representing when the asset status was last published.",
112
+ "additionalProperties": false,
113
+ "properties": {
114
+ "date": {
115
+ "type": ["string", "null"],
116
+ "format": "date-time",
117
+ "description": "The last published date of the asset in ISO 8601 format."
118
+ },
119
+ "user_id": {
120
+ "type": ["string", "null"],
121
+ "description": "The asset ID of the User that last published the asset."
122
+ }
123
+ },
124
+ "required": ["date", "user_id"]
125
+ },
126
+ "status_changed": {
127
+ "type": "object",
128
+ "description": "A object representing when the asset status was last changed.",
129
+ "additionalProperties": false,
130
+ "properties": {
131
+ "date": {
132
+ "type": ["string", "null"],
133
+ "format": "date-time",
134
+ "description": "The last date the state of the asset was changed in ISO 8601 format."
135
+ },
136
+ "user_id": {
137
+ "type": ["string", "null"],
138
+ "description": "The asset ID of the User that last changed the asset status."
139
+ }
140
+ },
141
+ "required": ["date", "user_id"]
142
+ },
143
+ "url": {
144
+ "type": "string",
145
+ "description": "The primary URL for the asset.",
146
+ "example": "http://mydomain.net/page"
147
+ },
148
+ "urls": {
149
+ "type": "array",
150
+ "items": {
151
+ "type": "string"
152
+ },
153
+ "description": "All URLs for the asset including the primary URL.",
154
+ "example": ["http://mydomain.net/page", "http://seconddomain.net/blog"]
155
+ },
156
+ "attributes": {
157
+ "type": "object",
158
+ "description": "List of attributes for the asset in key-value form."
159
+ },
160
+ "metadata": {
161
+ "type": "object",
162
+ "nullable": true,
163
+ "additionalProperties": {
164
+ "type": "array",
165
+ "items": {
166
+ "type": "string"
167
+ }
168
+ },
169
+ "example": {
170
+ "foo": ["bar1", "bar2"],
171
+ "bar": ["foo"]
172
+ },
173
+ "description": "List of metadata values in key-value form."
174
+ },
175
+ "contents": {
176
+ "type": "string",
177
+ "description": "The contents for the asset (excluding file assets)."
178
+ },
179
+ "thumbnail": {
180
+ "type": "object",
181
+ "nullable": true,
182
+ "properties": {
183
+ "asset_id": {
184
+ "type": "string",
185
+ "description": "The asset ID of the Image asset of the file."
186
+ },
187
+ "url": {
188
+ "type": "string",
189
+ "description": "The accessible URL of the thumbnail image file."
190
+ },
191
+ "file_name": {
192
+ "type": "string",
193
+ "description": "The file name of the thumbnail image."
194
+ },
195
+ "width": {
196
+ "type": "integer",
197
+ "description": "The image file width in pixels."
198
+ },
199
+ "height": {
200
+ "type": "integer",
201
+ "description": "The image file height in pixels."
202
+ },
203
+ "file_type": {
204
+ "type": "string",
205
+ "description": "The file type of the image file, generally its extension."
206
+ },
207
+ "file_size": {
208
+ "type": "integer",
209
+ "description": "The file size in bytes"
210
+ },
211
+ "file_size_readable": {
212
+ "type": "integer",
213
+ "description": "The file size in human readable format"
214
+ },
215
+ "title": {
216
+ "type": "string",
217
+ "description": "The friendly name of the file asset"
218
+ },
219
+ "alt": {
220
+ "type": "string",
221
+ "description": "The alt attribute of the Image asset"
222
+ }
223
+ },
224
+ "description": "The thumbnail image associated with the asset, shows a subset data of an image or image variety.",
225
+ "example": {
226
+ "asset_id": "42",
227
+ "url": "http://mydomain.net/image.png",
228
+ "file_name": "image.png",
229
+ "width": 630,
230
+ "height": 630,
231
+ "file_type": "png",
232
+ "file_size": 40336,
233
+ "file_size_readable": "39.4 KB",
234
+ "title": "Company Logo",
235
+ "alt": "A company logo image"
236
+ }
237
+ },
238
+ "include_dependents": {
239
+ "type": "array",
240
+ "items": {
241
+ "$ref": "#"
242
+ },
243
+ "description": "All direct dependent child assets of the asset in normalized asset format."
244
+ },
245
+ "additional": {
246
+ "description": "Additional data of an arbitrary nature related to the requested asset, which may include derived information or special child asset information.",
247
+ "anyOf": [
248
+ {
249
+ "$ref": "#/definitions/AssetAdditional"
250
+ },
251
+ {
252
+ "$ref": "#/definitions/AssetFileAdditional"
253
+ },
254
+ {
255
+ "$ref": "#/definitions/AssetImageAdditional"
256
+ },
257
+ {
258
+ "$ref": "#/definitions/AssetCalendarEventAdditional"
259
+ }
260
+ ]
261
+ }
262
+ },
263
+ "if": {
264
+ "properties": {
265
+ "type": {
266
+ "const": "image"
267
+ }
268
+ }
269
+ },
270
+ "then": {
271
+ "properties": {
272
+ "additional": {
273
+ "allOf": [
274
+ {
275
+ "$ref": "#/definitions/AssetFileAdditional"
276
+ },
277
+ {
278
+ "$ref": "#/definitions/AssetImageAdditional"
279
+ }
280
+ ]
281
+ }
282
+ }
283
+ },
284
+ "required": [
285
+ "id",
286
+ "type",
287
+ "type_name",
288
+ "version",
289
+ "name",
290
+ "short_name",
291
+ "status",
292
+ "created",
293
+ "updated",
294
+ "published",
295
+ "url",
296
+ "urls",
297
+ "attributes",
298
+ "additional"
299
+ ],
300
+
301
+ "definitions": {
302
+ "AssetAdditional": {
303
+ "title": "Asset additional info",
304
+ "type": "object",
305
+ "properties": {}
306
+ },
307
+ "AssetFileAdditional": {
308
+ "title": "File additional info",
309
+ "type": "object",
310
+ "properties": {
311
+ "file_info": {
312
+ "type": "object",
313
+ "properties": {
314
+ "file_name": {
315
+ "type": "string"
316
+ },
317
+ "size_readable": {
318
+ "type": "string"
319
+ },
320
+ "size_bytes": {
321
+ "type": "integer"
322
+ },
323
+ "width": {
324
+ "type": "integer",
325
+ "nullable": true
326
+ },
327
+ "height": {
328
+ "type": "integer",
329
+ "nullable": true
330
+ },
331
+ "modified_readable": {
332
+ "type": "string"
333
+ },
334
+ "modified_unix": {
335
+ "type": "integer"
336
+ }
337
+ }
338
+ }
339
+ },
340
+ "example": {
341
+ "file_info": {
342
+ "file_name": "logo.png",
343
+ "size_readable": "6.2 MB",
344
+ "size_bytes": 6553070,
345
+ "width": 1200,
346
+ "height": 600,
347
+ "modified_readable": "Feb 3, 2023 12:26 PM",
348
+ "modified_unix": 1675387561
349
+ }
350
+ },
351
+ "required": ["file_info"]
352
+ },
353
+ "AssetImageAdditional": {
354
+ "title": "Image additional info",
355
+ "properties": {
356
+ "varieties": {
357
+ "type": "array",
358
+ "items": {
359
+ "$ref": "#"
360
+ }
361
+ }
362
+ },
363
+ "required": ["varieties"]
364
+ },
365
+ "AssetCalendarEventAdditional": {
366
+ "title": "Calendar Event additional info",
367
+ "type": "object",
368
+ "properties": {
369
+ "event_info": {
370
+ "type": "object",
371
+ "properties": {
372
+ "duration": {
373
+ "type": "integer"
374
+ },
375
+ "frequency": {
376
+ "type": "string",
377
+ "nullable": true
378
+ }
379
+ }
380
+ }
381
+ },
382
+ "required": ["event_info"],
383
+ "example": {
384
+ "event_info": {
385
+ "duration": 1800,
386
+ "frequency": "FREQ=DAILY;INTERVAL=1"
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "../../v1.json",
3
+ "description": "t",
4
+ "displayName": "t",
5
+ "name": "test",
6
+ "namespace": "other",
7
+ "mainFunction": "main",
8
+ "version": "1.0.4",
9
+ "environment": [],
10
+ "functions": [
11
+ {
12
+ "entry": "main.js",
13
+ "name": "main",
14
+ "output": {
15
+ "responseType": "html"
16
+ },
17
+ "input": {
18
+ "type": "object",
19
+ "properties": {
20
+ "prop": {
21
+ "type": "string",
22
+ "format": "matrix-asset-uri"
23
+ }
24
+ },
25
+ "required": []
26
+ }
27
+ }
28
+ ]
29
+ }
@@ -1,5 +1,6 @@
1
1
  import DxComponentIcons from './DxComponentIcons.json';
2
2
  import DxComponentInputSchema from './DxComponentInputSchema.json';
3
3
  import DxContentMetaSchema from './DxContentMetaSchema.json';
4
+ import MatrixAssetSchema from './MatrixAssetSchema.json';
4
5
 
5
- export { DxComponentIcons, DxComponentInputSchema, DxContentMetaSchema };
6
+ export { DxComponentIcons, DxComponentInputSchema, DxContentMetaSchema, MatrixAssetSchema };
@@ -366,6 +366,54 @@
366
366
  }
367
367
  }
368
368
  }
369
+ },
370
+ "mockedUris": {
371
+ "type": "object",
372
+ "description": "Mocked uri objects used in the preview",
373
+ "propertyNames": {
374
+ "type": "string",
375
+ "pattern": "^[a-z0-9_\\-]+:\\/\\/"
376
+ },
377
+ "additionalProperties": {
378
+ "type": "object",
379
+ "description": "Property for defining the mock URI object",
380
+ "properties": {
381
+ "type": {
382
+ "description": "An enum of 'file' or 'inline' for how the uri object is defined",
383
+ "enum": ["file", "inline"]
384
+ }
385
+ },
386
+ "required": ["type"],
387
+ "oneOf": [
388
+ {
389
+ "type": "object",
390
+ "properties": {
391
+ "type": {
392
+ "enum": ["file"]
393
+ },
394
+ "path": {
395
+ "type": "string",
396
+ "format": "uri-reference",
397
+ "description": "Path to uri object"
398
+ }
399
+ },
400
+ "required": ["type", "path"]
401
+ },
402
+ {
403
+ "type": "object",
404
+ "properties": {
405
+ "type": {
406
+ "enum": ["inline"]
407
+ },
408
+ "value": {
409
+ "$ref": "MatrixAssetSchema.json",
410
+ "description": "Inline URI object"
411
+ }
412
+ },
413
+ "required": ["type", "value"]
414
+ }
415
+ ]
416
+ }
369
417
  }
370
418
  },
371
419