@squiz/dx-json-schema-lib 1.39.1-alpha.8 → 1.40.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/.npm/_logs/{2023-06-26T04_04_34_059Z-debug-0.log → 2023-07-06T01_50_49_748Z-debug-0.log} +8 -8
- package/lib/JsonValidationService.spec.js +19 -33
- package/lib/JsonValidationService.spec.js.map +1 -1
- package/lib/formatted-text/v1/formattedText.d.ts +10 -1
- package/lib/formatted-text/v1/formattedText.json +24 -1
- package/lib/formatted-text/v1/resolveFormattedTextNodes.d.ts +2 -2
- package/lib/formatted-text/v1/resolveFormattedTextNodes.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/pageContents/v1/pageContents.d.ts +7 -36
- package/lib/pageContents/v1/pageContents.json +21 -106
- package/package.json +2 -2
- package/src/JsonValidationService.spec.ts +19 -34
- package/src/formatted-text/v1/formattedText.json +26 -1
- package/src/formatted-text/v1/formattedText.ts +10 -1
- package/src/formatted-text/v1/resolveFormattedTextNodes.ts +2 -1
- package/src/index.ts +2 -2
- package/src/pageContents/v1/pageContents.json +21 -106
- package/src/pageContents/v1/pageContents.ts +7 -41
- package/tsconfig.tsbuildinfo +1 -1
@@ -2,125 +2,40 @@
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
3
|
"type": "object",
|
4
4
|
"properties": {
|
5
|
-
"
|
6
|
-
"
|
5
|
+
"id": {
|
6
|
+
"type": "string"
|
7
7
|
},
|
8
|
-
"
|
8
|
+
"name": {
|
9
|
+
"type": "string"
|
10
|
+
},
|
11
|
+
"layouts": {
|
9
12
|
"type": "array",
|
10
13
|
"items": {
|
11
|
-
"
|
12
|
-
|
13
|
-
"layout": {
|
14
|
-
"$ref": "#/definitions/layout"
|
15
|
-
},
|
16
|
-
"rule": {
|
17
|
-
"$ref": "#/definitions/rule"
|
18
|
-
},
|
19
|
-
"items": {
|
20
|
-
"$ref": "#/definitions/items"
|
21
|
-
}
|
22
|
-
}
|
23
|
-
},
|
24
|
-
"additionalProperties": false
|
14
|
+
"$ref": "#/definitions/layout"
|
15
|
+
}
|
25
16
|
}
|
26
17
|
},
|
27
|
-
"required": ["
|
18
|
+
"required": ["name", "layouts"],
|
28
19
|
"definitions": {
|
29
|
-
"rule": {
|
30
|
-
"type": "object",
|
31
|
-
"properties": {
|
32
|
-
"type": {
|
33
|
-
"type": "string",
|
34
|
-
"enum": ["language", "segment", "split"]
|
35
|
-
},
|
36
|
-
"values": {
|
37
|
-
"type": "array",
|
38
|
-
"items": {
|
39
|
-
"type": "string"
|
40
|
-
}
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"required": ["type", "values"]
|
44
|
-
},
|
45
20
|
"layout": {
|
46
21
|
"type": "object",
|
47
22
|
"properties": {
|
48
|
-
"
|
23
|
+
"schemaName": {
|
49
24
|
"type": "string"
|
50
25
|
},
|
51
|
-
"
|
52
|
-
"type": "
|
53
|
-
"
|
54
|
-
|
55
|
-
|
56
|
-
|
26
|
+
"content": {
|
27
|
+
"type": "object",
|
28
|
+
"properties": {
|
29
|
+
"contentItemId": {
|
30
|
+
"type": "string"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"required": ["contentItemId"],
|
34
|
+
"additionalProperties": false
|
57
35
|
}
|
58
36
|
},
|
59
|
-
"required": ["
|
60
|
-
|
61
|
-
"items": {
|
62
|
-
"type": "array",
|
63
|
-
"items": {
|
64
|
-
"properties": {
|
65
|
-
"rule": {
|
66
|
-
"$ref": "#/definitions/rule"
|
67
|
-
},
|
68
|
-
"type": {
|
69
|
-
"type": "string",
|
70
|
-
"enum": ["component", "rich-text"]
|
71
|
-
},
|
72
|
-
"component": {
|
73
|
-
"type": "string"
|
74
|
-
},
|
75
|
-
"layout-area": {
|
76
|
-
"type": "number"
|
77
|
-
},
|
78
|
-
"content": {
|
79
|
-
"oneOf": [
|
80
|
-
{
|
81
|
-
"type": "object",
|
82
|
-
"patternProperties": {
|
83
|
-
"^.*$": {
|
84
|
-
"oneOf": [
|
85
|
-
{
|
86
|
-
"type": "object",
|
87
|
-
"properties": {
|
88
|
-
"html": {
|
89
|
-
"type": "array",
|
90
|
-
"items": {
|
91
|
-
"type": "object",
|
92
|
-
"properties": {
|
93
|
-
"tag": {
|
94
|
-
"type": "string"
|
95
|
-
},
|
96
|
-
"content": {
|
97
|
-
"type": "string"
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
},
|
103
|
-
"description": "NOTE : This is a temp object, will be a reference to FT schema",
|
104
|
-
"additionalProperties": false
|
105
|
-
},
|
106
|
-
{
|
107
|
-
"type": "string",
|
108
|
-
"additionalProperties": {
|
109
|
-
"type": "string"
|
110
|
-
}
|
111
|
-
}
|
112
|
-
]
|
113
|
-
}
|
114
|
-
}
|
115
|
-
},
|
116
|
-
{
|
117
|
-
"type": "string"
|
118
|
-
}
|
119
|
-
]
|
120
|
-
}
|
121
|
-
},
|
122
|
-
"required": ["type", "content", "layout_area"]
|
123
|
-
}
|
37
|
+
"required": ["schemaName", "content"],
|
38
|
+
"additionalProperties": false
|
124
39
|
}
|
125
40
|
},
|
126
41
|
"additionalProperties": false
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squiz/dx-json-schema-lib",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.40.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"scripts": {
|
@@ -31,5 +31,5 @@
|
|
31
31
|
"@squiz/json-schema-library": "7.4.7",
|
32
32
|
"ts-brand": "0.0.2"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "42d08bd61b20a1a8a4bb6ccb4a9c60ababcd8f39"
|
35
35
|
}
|
@@ -344,26 +344,16 @@ describe('JsonValidationService', () => {
|
|
344
344
|
describe('validatePageContents', () => {
|
345
345
|
const validPageContents: PageContents[] = [
|
346
346
|
{
|
347
|
-
|
348
|
-
},
|
349
|
-
{
|
350
|
-
containers: [
|
347
|
+
layouts: [
|
351
348
|
{
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
value: '<div>[area://output/1]</div>',
|
349
|
+
schemaName: 'content-item-schema',
|
350
|
+
content: {
|
351
|
+
contentItemId: '123',
|
356
352
|
},
|
357
|
-
items: [
|
358
|
-
{
|
359
|
-
type: 'component',
|
360
|
-
content: 'content-store://asdfkjashdfkjhwek234j234',
|
361
|
-
component: 'namespace/componentname/version',
|
362
|
-
layout_area: 1,
|
363
|
-
},
|
364
|
-
],
|
365
353
|
},
|
366
354
|
],
|
355
|
+
name: 'test',
|
356
|
+
id: ' 1',
|
367
357
|
},
|
368
358
|
];
|
369
359
|
it.each(validPageContents)('should validate valid page contents', (input) => {
|
@@ -377,13 +367,11 @@ describe('JsonValidationService', () => {
|
|
377
367
|
jsonValidationService.validatePageContents(input);
|
378
368
|
},
|
379
369
|
SchemaValidationError,
|
380
|
-
'failed validation: The required property `
|
370
|
+
'failed validation: The required property `name` is missing at `#`,\nThe required property `layouts` is missing at `#`',
|
381
371
|
{
|
382
372
|
'#': [
|
383
|
-
{
|
384
|
-
|
385
|
-
message: 'The required property `containers` is missing at `#`',
|
386
|
-
},
|
373
|
+
{ data: { key: 'name', pointer: '#' }, message: 'The required property `name` is missing at `#`' },
|
374
|
+
{ data: { key: 'layouts', pointer: '#' }, message: 'The required property `layouts` is missing at `#`' },
|
387
375
|
],
|
388
376
|
},
|
389
377
|
);
|
@@ -414,22 +402,19 @@ describe('JsonValidationService', () => {
|
|
414
402
|
jsonValidationService.validatePageContents(input);
|
415
403
|
},
|
416
404
|
SchemaValidationError,
|
417
|
-
'failed validation:
|
418
|
-
'\n' +
|
419
|
-
'Expected given value `bad-type` in #/containers/0/items/0/type` to be one of `[component, rich-text]`',
|
405
|
+
'failed validation: Additional property `containers` in `#` is not allowed,\nThe required property `name` is missing at `#`,\nThe required property `layouts` is missing at `#`',
|
420
406
|
{
|
421
|
-
'
|
422
|
-
{
|
423
|
-
data: { pointer: '#/containers/0/items/0/type', value: 'bad-type', values: ['component', 'rich-text'] },
|
424
|
-
message:
|
425
|
-
'Expected given value `bad-type` in #/containers/0/items/0/type` to be one of `[component, rich-text]`',
|
426
|
-
},
|
427
|
-
],
|
428
|
-
'#/containers/0/layout/value': [
|
407
|
+
'#': [
|
429
408
|
{
|
430
|
-
data: {
|
431
|
-
|
409
|
+
data: {
|
410
|
+
pointer: '#',
|
411
|
+
properties: ['id', 'name', 'layouts'],
|
412
|
+
property: 'containers',
|
413
|
+
},
|
414
|
+
message: 'Additional property `containers` in `#` is not allowed',
|
432
415
|
},
|
416
|
+
{ data: { key: 'name', pointer: '#' }, message: 'The required property `name` is missing at `#`' },
|
417
|
+
{ data: { key: 'layouts', pointer: '#' }, message: 'The required property `layouts` is missing at `#`' },
|
433
418
|
],
|
434
419
|
},
|
435
420
|
);
|
@@ -21,7 +21,11 @@
|
|
21
21
|
},
|
22
22
|
|
23
23
|
"BaseFormattedNodes": {
|
24
|
-
"anyOf": [
|
24
|
+
"anyOf": [
|
25
|
+
{ "$ref": "#/definitions/FormattedTextTag" },
|
26
|
+
{ "$ref": "#/definitions/TextNode" },
|
27
|
+
{ "$ref": "#/definitions/ComponentNode" }
|
28
|
+
]
|
25
29
|
},
|
26
30
|
|
27
31
|
"TextNode": {
|
@@ -87,6 +91,27 @@
|
|
87
91
|
"required": ["type", "tag", "children"]
|
88
92
|
},
|
89
93
|
|
94
|
+
"ComponentNode": {
|
95
|
+
"type": "object",
|
96
|
+
"additionalProperties": false,
|
97
|
+
|
98
|
+
"properties": {
|
99
|
+
"type": { "const": "component" },
|
100
|
+
"schemaName": { "type": "string" },
|
101
|
+
"componentSet": { "type": "string" },
|
102
|
+
"content": {
|
103
|
+
"type": "object",
|
104
|
+
"title": "ContentItemReference",
|
105
|
+
"properties": {
|
106
|
+
"contentItemId": { "type": "string" }
|
107
|
+
},
|
108
|
+
"required": ["contentItemId"],
|
109
|
+
"additionalProperties": false
|
110
|
+
}
|
111
|
+
},
|
112
|
+
"required": ["type", "schemaName", "componentSet"]
|
113
|
+
},
|
114
|
+
|
90
115
|
"FormattedTextLinkToMatrixAsset": {
|
91
116
|
"type": "object",
|
92
117
|
"additionalProperties": false,
|
@@ -8,7 +8,7 @@
|
|
8
8
|
export type FormattedNodes = HigherOrderFormattedNodes | BaseFormattedNodes;
|
9
9
|
export type HigherOrderFormattedNodes = FormattedTextLinkToMatrixAsset | FormattedTextMatrixImage;
|
10
10
|
export type WithChildrenNode = FormattedNodes[];
|
11
|
-
export type BaseFormattedNodes = FormattedTextTag | TextNode;
|
11
|
+
export type BaseFormattedNodes = FormattedTextTag | TextNode | ComponentNode;
|
12
12
|
export type FormattedText = FormattedNodes[];
|
13
13
|
|
14
14
|
export interface FormattedTextLinkToMatrixAsset {
|
@@ -54,3 +54,12 @@ export interface TextNode {
|
|
54
54
|
type: 'text';
|
55
55
|
value: string;
|
56
56
|
}
|
57
|
+
export interface ComponentNode {
|
58
|
+
type: 'component';
|
59
|
+
schemaName: string;
|
60
|
+
componentSet: string;
|
61
|
+
content?: ContentItemReference;
|
62
|
+
}
|
63
|
+
export interface ContentItemReference {
|
64
|
+
contentItemId: string;
|
65
|
+
}
|
@@ -3,6 +3,7 @@ import { JSONSchema } from '@squiz/json-schema-library';
|
|
3
3
|
import { ComponentInputSchema } from '../..';
|
4
4
|
import {
|
5
5
|
BaseFormattedNodes,
|
6
|
+
ComponentNode,
|
6
7
|
FormattedText,
|
7
8
|
FormattedTextTag,
|
8
9
|
HigherOrderFormattedNodes,
|
@@ -33,7 +34,7 @@ export type ResolvedChildNode<
|
|
33
34
|
? Omit<DEFAULT_NODES, 'children'> & { children: CHILD_NODE[] }
|
34
35
|
: DEFAULT_NODES;
|
35
36
|
|
36
|
-
export type FullyResolvedNodes = ResolvedChildNode<TextNode | FormattedTextTag, string>;
|
37
|
+
export type FullyResolvedNodes = ResolvedChildNode<TextNode | FormattedTextTag | ComponentNode, string>;
|
37
38
|
export type BaseResolvedNodes = ResolvedChildNode<BaseFormattedNodes, BaseFormattedNodes>;
|
38
39
|
export type HigherOrderResolvedNodes = ResolvedChildNode<HigherOrderFormattedNodes, BaseResolvedNodes>;
|
39
40
|
|
package/src/index.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
export * as MANIFEST_MODELS from './manifest/v1/manifestModels';
|
2
2
|
export * as MANIFEST_SCHEMAS from './manifest/v1/manifestSchemas';
|
3
3
|
|
4
|
-
export * as PAGE_CONTENTS_MODELS from './
|
5
|
-
export * as PAGE_CONTENT_SCHEMAS from './
|
4
|
+
export * as PAGE_CONTENTS_MODELS from './pageContents/pageContentsModels';
|
5
|
+
export * as PAGE_CONTENT_SCHEMAS from './pageContents/pageContentsSchemas';
|
6
6
|
|
7
7
|
export * as FORMATTED_TEXT_MODELS from './formatted-text/v1/formattedTextModels';
|
8
8
|
export * as FORMATTED_TEXT_SCHEMAS from './formatted-text/v1/formattedTextSchemas';
|
@@ -2,125 +2,40 @@
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
3
|
"type": "object",
|
4
4
|
"properties": {
|
5
|
-
"
|
6
|
-
"
|
5
|
+
"id": {
|
6
|
+
"type": "string"
|
7
7
|
},
|
8
|
-
"
|
8
|
+
"name": {
|
9
|
+
"type": "string"
|
10
|
+
},
|
11
|
+
"layouts": {
|
9
12
|
"type": "array",
|
10
13
|
"items": {
|
11
|
-
"
|
12
|
-
|
13
|
-
"layout": {
|
14
|
-
"$ref": "#/definitions/layout"
|
15
|
-
},
|
16
|
-
"rule": {
|
17
|
-
"$ref": "#/definitions/rule"
|
18
|
-
},
|
19
|
-
"items": {
|
20
|
-
"$ref": "#/definitions/items"
|
21
|
-
}
|
22
|
-
}
|
23
|
-
},
|
24
|
-
"additionalProperties": false
|
14
|
+
"$ref": "#/definitions/layout"
|
15
|
+
}
|
25
16
|
}
|
26
17
|
},
|
27
|
-
"required": ["
|
18
|
+
"required": ["name", "layouts"],
|
28
19
|
"definitions": {
|
29
|
-
"rule": {
|
30
|
-
"type": "object",
|
31
|
-
"properties": {
|
32
|
-
"type": {
|
33
|
-
"type": "string",
|
34
|
-
"enum": ["language", "segment", "split"]
|
35
|
-
},
|
36
|
-
"values": {
|
37
|
-
"type": "array",
|
38
|
-
"items": {
|
39
|
-
"type": "string"
|
40
|
-
}
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"required": ["type", "values"]
|
44
|
-
},
|
45
20
|
"layout": {
|
46
21
|
"type": "object",
|
47
22
|
"properties": {
|
48
|
-
"
|
23
|
+
"schemaName": {
|
49
24
|
"type": "string"
|
50
25
|
},
|
51
|
-
"
|
52
|
-
"type": "
|
53
|
-
"
|
54
|
-
|
55
|
-
|
56
|
-
|
26
|
+
"content": {
|
27
|
+
"type": "object",
|
28
|
+
"properties": {
|
29
|
+
"contentItemId": {
|
30
|
+
"type": "string"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"required": ["contentItemId"],
|
34
|
+
"additionalProperties": false
|
57
35
|
}
|
58
36
|
},
|
59
|
-
"required": ["
|
60
|
-
|
61
|
-
"items": {
|
62
|
-
"type": "array",
|
63
|
-
"items": {
|
64
|
-
"properties": {
|
65
|
-
"rule": {
|
66
|
-
"$ref": "#/definitions/rule"
|
67
|
-
},
|
68
|
-
"type": {
|
69
|
-
"type": "string",
|
70
|
-
"enum": ["component", "rich-text"]
|
71
|
-
},
|
72
|
-
"component": {
|
73
|
-
"type": "string"
|
74
|
-
},
|
75
|
-
"layout-area": {
|
76
|
-
"type": "number"
|
77
|
-
},
|
78
|
-
"content": {
|
79
|
-
"oneOf": [
|
80
|
-
{
|
81
|
-
"type": "object",
|
82
|
-
"patternProperties": {
|
83
|
-
"^.*$": {
|
84
|
-
"oneOf": [
|
85
|
-
{
|
86
|
-
"type": "object",
|
87
|
-
"properties": {
|
88
|
-
"html": {
|
89
|
-
"type": "array",
|
90
|
-
"items": {
|
91
|
-
"type": "object",
|
92
|
-
"properties": {
|
93
|
-
"tag": {
|
94
|
-
"type": "string"
|
95
|
-
},
|
96
|
-
"content": {
|
97
|
-
"type": "string"
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
},
|
103
|
-
"description": "NOTE : This is a temp object, will be a reference to FT schema",
|
104
|
-
"additionalProperties": false
|
105
|
-
},
|
106
|
-
{
|
107
|
-
"type": "string",
|
108
|
-
"additionalProperties": {
|
109
|
-
"type": "string"
|
110
|
-
}
|
111
|
-
}
|
112
|
-
]
|
113
|
-
}
|
114
|
-
}
|
115
|
-
},
|
116
|
-
{
|
117
|
-
"type": "string"
|
118
|
-
}
|
119
|
-
]
|
120
|
-
}
|
121
|
-
},
|
122
|
-
"required": ["type", "content", "layout_area"]
|
123
|
-
}
|
37
|
+
"required": ["schemaName", "content"],
|
38
|
+
"additionalProperties": false
|
124
39
|
}
|
125
40
|
},
|
126
41
|
"additionalProperties": false
|
@@ -5,48 +5,14 @@
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
export type Items = {
|
9
|
-
rule?: Rule;
|
10
|
-
type: 'component' | 'rich-text';
|
11
|
-
component?: string;
|
12
|
-
'layout-area'?: number;
|
13
|
-
content:
|
14
|
-
| {
|
15
|
-
/**
|
16
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
17
|
-
* via the `patternProperty` "^.*$".
|
18
|
-
*/
|
19
|
-
[k: string]:
|
20
|
-
| {
|
21
|
-
html?: {
|
22
|
-
tag?: string;
|
23
|
-
content?: string;
|
24
|
-
[k: string]: unknown;
|
25
|
-
}[];
|
26
|
-
}
|
27
|
-
| string;
|
28
|
-
}
|
29
|
-
| string;
|
30
|
-
[k: string]: unknown;
|
31
|
-
}[];
|
32
|
-
|
33
8
|
export interface PageContents {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
rule?: Rule;
|
38
|
-
items?: Items;
|
39
|
-
[k: string]: unknown;
|
40
|
-
}[];
|
41
|
-
}
|
42
|
-
export interface Rule {
|
43
|
-
type: 'language' | 'segment' | 'split';
|
44
|
-
values: string[];
|
45
|
-
[k: string]: unknown;
|
9
|
+
id?: string;
|
10
|
+
name: string;
|
11
|
+
layouts: Layout[];
|
46
12
|
}
|
47
13
|
export interface Layout {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
14
|
+
schemaName: string;
|
15
|
+
content: {
|
16
|
+
contentItemId: string;
|
17
|
+
};
|
52
18
|
}
|