@atlaskit/adf-schema 37.0.2 → 37.1.19
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/CHANGELOG.md +151 -0
- package/dist/cjs/next-schema/full-schema.adf.js +1 -1
- package/dist/cjs/next-schema/generated/nodeTypes.js +101 -31
- package/dist/cjs/next-schema/groups/blockGroup.js +1 -1
- package/dist/cjs/next-schema/groups/inlineGroup.js +1 -1
- package/dist/cjs/next-schema/index.js +511 -0
- package/dist/cjs/next-schema/nodes/blockquote.js +3 -2
- package/dist/cjs/next-schema/nodes/bodiedExtension.js +6 -2
- package/dist/cjs/next-schema/nodes/codeBlock.js +10 -3
- package/dist/cjs/next-schema/nodes/date.js +2 -1
- package/dist/cjs/next-schema/nodes/emoji.js +2 -1
- package/dist/cjs/next-schema/nodes/expand.js +11 -3
- package/dist/cjs/next-schema/nodes/extension.js +5 -2
- package/dist/cjs/next-schema/nodes/heading.js +28 -5
- package/dist/cjs/next-schema/nodes/inlineExtension.js +1 -0
- package/dist/cjs/next-schema/nodes/layoutSection.js +15 -2
- package/dist/cjs/next-schema/nodes/list.js +12 -9
- package/dist/cjs/next-schema/nodes/mediaInline.js +2 -1
- package/dist/cjs/next-schema/nodes/mediaSingle.js +75 -4
- package/dist/cjs/next-schema/nodes/mention.js +2 -1
- package/dist/cjs/next-schema/nodes/multiBodiedExtension.js +8 -4
- package/dist/cjs/next-schema/nodes/nestedExpand.js +5 -1
- package/dist/cjs/next-schema/nodes/panel.js +3 -0
- package/dist/cjs/next-schema/nodes/paragraph.js +29 -5
- package/dist/cjs/next-schema/nodes/status.js +2 -1
- package/dist/cjs/next-schema/nodes/tableCell.js +4 -1
- package/dist/cjs/next-schema/nodes/tableHeader.js +5 -2
- package/dist/cjs/next-schema/nodes/task.js +1 -0
- package/dist/cjs/next-schema/nodes/text.js +7 -1
- package/dist/cjs/schema/nodes/media.js +10 -4
- package/dist/cjs/schema/nodes/text.js +1 -0
- package/dist/es2019/next-schema/full-schema.adf.js +1 -1
- package/dist/es2019/next-schema/generated/nodeTypes.js +100 -30
- package/dist/es2019/next-schema/groups/blockGroup.js +1 -1
- package/dist/es2019/next-schema/groups/inlineGroup.js +1 -1
- package/dist/es2019/next-schema/index.js +2 -0
- package/dist/es2019/next-schema/nodes/blockquote.js +3 -2
- package/dist/es2019/next-schema/nodes/bodiedExtension.js +6 -2
- package/dist/es2019/next-schema/nodes/codeBlock.js +10 -3
- package/dist/es2019/next-schema/nodes/date.js +2 -1
- package/dist/es2019/next-schema/nodes/emoji.js +2 -1
- package/dist/es2019/next-schema/nodes/expand.js +11 -3
- package/dist/es2019/next-schema/nodes/extension.js +5 -2
- package/dist/es2019/next-schema/nodes/heading.js +27 -4
- package/dist/es2019/next-schema/nodes/inlineExtension.js +1 -0
- package/dist/es2019/next-schema/nodes/layoutSection.js +15 -2
- package/dist/es2019/next-schema/nodes/list.js +12 -9
- package/dist/es2019/next-schema/nodes/mediaInline.js +2 -1
- package/dist/es2019/next-schema/nodes/mediaSingle.js +76 -5
- package/dist/es2019/next-schema/nodes/mention.js +2 -1
- package/dist/es2019/next-schema/nodes/multiBodiedExtension.js +8 -4
- package/dist/es2019/next-schema/nodes/nestedExpand.js +5 -1
- package/dist/es2019/next-schema/nodes/panel.js +3 -0
- package/dist/es2019/next-schema/nodes/paragraph.js +29 -5
- package/dist/es2019/next-schema/nodes/status.js +2 -1
- package/dist/es2019/next-schema/nodes/tableCell.js +4 -1
- package/dist/es2019/next-schema/nodes/tableHeader.js +5 -2
- package/dist/es2019/next-schema/nodes/task.js +1 -0
- package/dist/es2019/next-schema/nodes/text.js +7 -1
- package/dist/es2019/schema/nodes/media.js +3 -1
- package/dist/es2019/schema/nodes/text.js +1 -0
- package/dist/esm/next-schema/full-schema.adf.js +1 -1
- package/dist/esm/next-schema/generated/nodeTypes.js +100 -30
- package/dist/esm/next-schema/groups/blockGroup.js +1 -1
- package/dist/esm/next-schema/groups/inlineGroup.js +1 -1
- package/dist/esm/next-schema/index.js +2 -0
- package/dist/esm/next-schema/nodes/blockquote.js +3 -2
- package/dist/esm/next-schema/nodes/bodiedExtension.js +6 -2
- package/dist/esm/next-schema/nodes/codeBlock.js +10 -3
- package/dist/esm/next-schema/nodes/date.js +2 -1
- package/dist/esm/next-schema/nodes/emoji.js +2 -1
- package/dist/esm/next-schema/nodes/expand.js +11 -3
- package/dist/esm/next-schema/nodes/extension.js +5 -2
- package/dist/esm/next-schema/nodes/heading.js +27 -4
- package/dist/esm/next-schema/nodes/inlineExtension.js +1 -0
- package/dist/esm/next-schema/nodes/layoutSection.js +15 -2
- package/dist/esm/next-schema/nodes/list.js +12 -9
- package/dist/esm/next-schema/nodes/mediaInline.js +2 -1
- package/dist/esm/next-schema/nodes/mediaSingle.js +76 -5
- package/dist/esm/next-schema/nodes/mention.js +2 -1
- package/dist/esm/next-schema/nodes/multiBodiedExtension.js +8 -4
- package/dist/esm/next-schema/nodes/nestedExpand.js +5 -1
- package/dist/esm/next-schema/nodes/panel.js +3 -0
- package/dist/esm/next-schema/nodes/paragraph.js +29 -5
- package/dist/esm/next-schema/nodes/status.js +2 -1
- package/dist/esm/next-schema/nodes/tableCell.js +4 -1
- package/dist/esm/next-schema/nodes/tableHeader.js +5 -2
- package/dist/esm/next-schema/nodes/task.js +1 -0
- package/dist/esm/next-schema/nodes/text.js +7 -1
- package/dist/esm/schema/nodes/media.js +9 -4
- package/dist/esm/schema/nodes/text.js +1 -0
- package/dist/types/next-schema/full-schema.adf.d.ts +18 -0
- package/dist/types/next-schema/generated/markTypes.d.ts +20 -20
- package/dist/types/next-schema/generated/nodeGroupTypes.d.ts +2 -2
- package/dist/types/next-schema/generated/nodeTypes.d.ts +145 -96
- package/dist/types/next-schema/groups/nonNestableBlockContentGroup.d.ts +128 -6
- package/dist/types/next-schema/index.d.ts +5 -0
- package/dist/types/next-schema/nodes/blockCard.d.ts +18 -0
- package/dist/types/next-schema/nodes/blockquote.d.ts +20 -1
- package/dist/types/next-schema/nodes/bodiedExtension.d.ts +20 -0
- package/dist/types/next-schema/nodes/caption.d.ts +18 -0
- package/dist/types/next-schema/nodes/codeBlock.d.ts +48 -0
- package/dist/types/next-schema/nodes/confluenceJiraIssue.d.ts +18 -0
- package/dist/types/next-schema/nodes/confluenceUnsupportedBlock.d.ts +18 -0
- package/dist/types/next-schema/nodes/confluenceUnsupportedInline.d.ts +18 -0
- package/dist/types/next-schema/nodes/date.d.ts +18 -0
- package/dist/types/next-schema/nodes/decisionItem.d.ts +18 -0
- package/dist/types/next-schema/nodes/decisionList.d.ts +18 -0
- package/dist/types/next-schema/nodes/embedCard.d.ts +18 -0
- package/dist/types/next-schema/nodes/emoji.d.ts +18 -0
- package/dist/types/next-schema/nodes/expand.d.ts +25 -0
- package/dist/types/next-schema/nodes/extension.d.ts +19 -0
- package/dist/types/next-schema/nodes/extensionFrame.d.ts +18 -0
- package/dist/types/next-schema/nodes/hardBreak.d.ts +18 -0
- package/dist/types/next-schema/nodes/heading.d.ts +80 -0
- package/dist/types/next-schema/nodes/image.d.ts +18 -0
- package/dist/types/next-schema/nodes/inlineCard.d.ts +18 -0
- package/dist/types/next-schema/nodes/inlineExtension.d.ts +18 -0
- package/dist/types/next-schema/nodes/layoutColumn.d.ts +18 -0
- package/dist/types/next-schema/nodes/layoutSection.d.ts +22 -0
- package/dist/types/next-schema/nodes/list.d.ts +36 -0
- package/dist/types/next-schema/nodes/media.d.ts +18 -0
- package/dist/types/next-schema/nodes/mediaGroup.d.ts +18 -0
- package/dist/types/next-schema/nodes/mediaInline.d.ts +18 -0
- package/dist/types/next-schema/nodes/mediaSingle.d.ts +67 -1
- package/dist/types/next-schema/nodes/mention.d.ts +18 -0
- package/dist/types/next-schema/nodes/multiBodiedExtension.d.ts +18 -0
- package/dist/types/next-schema/nodes/nestedExpand.d.ts +22 -0
- package/dist/types/next-schema/nodes/panel.d.ts +22 -1
- package/dist/types/next-schema/nodes/paragraph.d.ts +29 -0
- package/dist/types/next-schema/nodes/placeholder.d.ts +18 -0
- package/dist/types/next-schema/nodes/rule.d.ts +18 -0
- package/dist/types/next-schema/nodes/status.d.ts +18 -0
- package/dist/types/next-schema/nodes/table.d.ts +18 -0
- package/dist/types/next-schema/nodes/tableCell.d.ts +18 -0
- package/dist/types/next-schema/nodes/tableHeader.d.ts +18 -0
- package/dist/types/next-schema/nodes/tableRow.d.ts +18 -0
- package/dist/types/next-schema/nodes/task.d.ts +36 -0
- package/dist/types/next-schema/nodes/text.d.ts +22 -1
- package/dist/types/next-schema/nodes/unsupportedBlock.d.ts +18 -0
- package/dist/types/next-schema/nodes/unsupportedInline.d.ts +18 -0
- package/package.json +8 -3
- package/schema-generators/__tests__/unit/__fixtures__/index.fixture.ts +140 -0
- package/schema-generators/__tests__/unit/adfToValidatorSpec.unit.ts +1 -45
- package/schema-generators/__tests__/unit/adfToValidatorSpecValidation.unit.ts +88 -0
- package/schema-generators/__tests__/unit/json-full-schema-backwards-compat.unit.ts +70 -61
- package/schema-generators/__tests__/unit/validate-pm-schema.unit.ts +152 -46
- package/schema-next/package.json +9 -0
- package/schema-generators/__tests__/unit/jqueries.md +0 -194
- package/schema-generators/__tests__/unit/json-full-schema.unit.ts +0 -2320
@@ -7,6 +7,8 @@ export declare const unsupportedInline: import("@atlaskit/adf-schema-generator/d
|
|
7
7
|
inline?: true;
|
8
8
|
code?: boolean;
|
9
9
|
content?: import("@atlaskit/adf-schema-generator/dist/types/types/ADFNodeSpec").ADFNodeContentSpec[];
|
10
|
+
contentMinItems?: number;
|
11
|
+
contentMaxItems?: number;
|
10
12
|
defining?: boolean;
|
11
13
|
definingAsContext?: boolean;
|
12
14
|
definingForContent?: boolean;
|
@@ -16,7 +18,23 @@ export declare const unsupportedInline: import("@atlaskit/adf-schema-generator/d
|
|
16
18
|
marks?: import("@atlaskit/adf-schema-generator/dist/types/adfMark").ADFMark<unknown>[];
|
17
19
|
allowAnyChildMark?: boolean;
|
18
20
|
allowNoChildMark?: boolean;
|
21
|
+
noMarks?: boolean;
|
22
|
+
hasEmptyMarks?: boolean;
|
19
23
|
selectable?: boolean;
|
20
24
|
whitespace?: "pre" | "normal";
|
21
25
|
tableRole?: "table" | "row" | "cell" | "header_cell";
|
26
|
+
DANGEROUS_MANUAL_OVERRIDE?: {
|
27
|
+
'pm-spec'?: {
|
28
|
+
[x: string]: {
|
29
|
+
value: any;
|
30
|
+
reason: string;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
'validator-spec'?: {
|
34
|
+
[x: string]: {
|
35
|
+
value: any;
|
36
|
+
reason: string;
|
37
|
+
};
|
38
|
+
};
|
39
|
+
};
|
22
40
|
}>;
|
package/package.json
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "37.
|
3
|
+
"version": "37.1.19",
|
4
4
|
"description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
7
7
|
},
|
8
|
-
"repository":
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git+https://bitbucket.org/atlassian/adf-schema.git"
|
11
|
+
},
|
9
12
|
"author": "Atlassian Pty Ltd",
|
10
13
|
"license": "Apache-2.0",
|
11
14
|
"main": "dist/cjs/index.js",
|
@@ -44,7 +47,8 @@
|
|
44
47
|
},
|
45
48
|
"devDependencies": {
|
46
49
|
"@atlassian/adf-schema-json": "^1.16.0",
|
47
|
-
"@atlaskit/adf-schema-generator": "^1.
|
50
|
+
"@atlaskit/adf-schema-generator": "^1.24.1",
|
51
|
+
"@atlaskit/adf-utils": "^19.2.2",
|
48
52
|
"@atlaskit/codemod-utils": "^4.2.4",
|
49
53
|
"@atlaskit/json-schema-generator": "^3.3.9",
|
50
54
|
"@babel/cli": "^7.22.9",
|
@@ -60,6 +64,7 @@
|
|
60
64
|
"@babel/preset-typescript": "^7.22.5",
|
61
65
|
"@compiled/babel-plugin": "0.15.0",
|
62
66
|
"@types/jest": "^29.5.3",
|
67
|
+
"@types/json-schema": "^7.0.15",
|
63
68
|
"@types/linkify-it": "^2.0.4",
|
64
69
|
"@types/node": "^20.4.8",
|
65
70
|
"babel-plugin-transform-define": "^2.0.0",
|
@@ -0,0 +1,140 @@
|
|
1
|
+
import { JSONSchema4 } from 'json-schema';
|
2
|
+
|
3
|
+
export const tableCellNodeContent: JSONSchema4 = {
|
4
|
+
type: 'array',
|
5
|
+
items: {
|
6
|
+
anyOf: [
|
7
|
+
{
|
8
|
+
$ref: '#/definitions/codeBlock_with_no_marks_node',
|
9
|
+
},
|
10
|
+
{
|
11
|
+
$ref: '#/definitions/blockCard_node',
|
12
|
+
},
|
13
|
+
{
|
14
|
+
$ref: '#/definitions/paragraph_with_no_marks_node',
|
15
|
+
},
|
16
|
+
{
|
17
|
+
$ref: '#/definitions/paragraph_with_alignment_node',
|
18
|
+
},
|
19
|
+
{
|
20
|
+
$ref: '#/definitions/mediaSingle_caption_node',
|
21
|
+
},
|
22
|
+
{
|
23
|
+
$ref: '#/definitions/mediaSingle_full_node',
|
24
|
+
},
|
25
|
+
{
|
26
|
+
$ref: '#/definitions/taskList_node',
|
27
|
+
},
|
28
|
+
{
|
29
|
+
$ref: '#/definitions/bulletList_node',
|
30
|
+
},
|
31
|
+
{
|
32
|
+
$ref: '#/definitions/orderedList_node',
|
33
|
+
},
|
34
|
+
{
|
35
|
+
$ref: '#/definitions/heading_with_no_marks_node',
|
36
|
+
},
|
37
|
+
{
|
38
|
+
$ref: '#/definitions/heading_with_alignment_node',
|
39
|
+
},
|
40
|
+
{
|
41
|
+
$ref: '#/definitions/heading_with_indentation_node',
|
42
|
+
},
|
43
|
+
{
|
44
|
+
$ref: '#/definitions/mediaGroup_node',
|
45
|
+
},
|
46
|
+
{
|
47
|
+
$ref: '#/definitions/decisionList_node',
|
48
|
+
},
|
49
|
+
{
|
50
|
+
$ref: '#/definitions/rule_node',
|
51
|
+
},
|
52
|
+
{
|
53
|
+
$ref: '#/definitions/panel_node',
|
54
|
+
},
|
55
|
+
{
|
56
|
+
$ref: '#/definitions/blockquote_node',
|
57
|
+
},
|
58
|
+
{
|
59
|
+
$ref: '#/definitions/extension_with_marks_node',
|
60
|
+
},
|
61
|
+
{
|
62
|
+
$ref: '#/definitions/embedCard_node',
|
63
|
+
},
|
64
|
+
{
|
65
|
+
$ref: '#/definitions/nestedExpand_with_no_marks_node',
|
66
|
+
},
|
67
|
+
],
|
68
|
+
},
|
69
|
+
minItems: 1,
|
70
|
+
};
|
71
|
+
|
72
|
+
export const tableHeaderNodeContent: JSONSchema4 = {
|
73
|
+
type: 'array',
|
74
|
+
items: {
|
75
|
+
anyOf: [
|
76
|
+
{
|
77
|
+
$ref: '#/definitions/codeBlock_with_no_marks_node',
|
78
|
+
},
|
79
|
+
{
|
80
|
+
$ref: '#/definitions/blockCard_node',
|
81
|
+
},
|
82
|
+
{
|
83
|
+
$ref: '#/definitions/paragraph_with_no_marks_node',
|
84
|
+
},
|
85
|
+
{
|
86
|
+
$ref: '#/definitions/paragraph_with_alignment_node',
|
87
|
+
},
|
88
|
+
{
|
89
|
+
$ref: '#/definitions/mediaSingle_caption_node',
|
90
|
+
},
|
91
|
+
{
|
92
|
+
$ref: '#/definitions/mediaSingle_full_node',
|
93
|
+
},
|
94
|
+
{
|
95
|
+
$ref: '#/definitions/taskList_node',
|
96
|
+
},
|
97
|
+
{
|
98
|
+
$ref: '#/definitions/bulletList_node',
|
99
|
+
},
|
100
|
+
{
|
101
|
+
$ref: '#/definitions/orderedList_node',
|
102
|
+
},
|
103
|
+
{
|
104
|
+
$ref: '#/definitions/heading_with_no_marks_node',
|
105
|
+
},
|
106
|
+
{
|
107
|
+
$ref: '#/definitions/heading_with_alignment_node',
|
108
|
+
},
|
109
|
+
{
|
110
|
+
$ref: '#/definitions/heading_with_indentation_node',
|
111
|
+
},
|
112
|
+
{
|
113
|
+
$ref: '#/definitions/mediaGroup_node',
|
114
|
+
},
|
115
|
+
{
|
116
|
+
$ref: '#/definitions/decisionList_node',
|
117
|
+
},
|
118
|
+
{
|
119
|
+
$ref: '#/definitions/rule_node',
|
120
|
+
},
|
121
|
+
{
|
122
|
+
$ref: '#/definitions/panel_node',
|
123
|
+
},
|
124
|
+
{
|
125
|
+
$ref: '#/definitions/blockquote_node',
|
126
|
+
},
|
127
|
+
{ $ref: '#/definitions/nestedExpand_node' },
|
128
|
+
{
|
129
|
+
$ref: '#/definitions/extension_with_marks_node',
|
130
|
+
},
|
131
|
+
{
|
132
|
+
$ref: '#/definitions/embedCard_node',
|
133
|
+
},
|
134
|
+
{
|
135
|
+
$ref: '#/definitions/nestedExpand_with_no_marks_node',
|
136
|
+
},
|
137
|
+
],
|
138
|
+
},
|
139
|
+
minItems: 1,
|
140
|
+
};
|
@@ -13,18 +13,6 @@ test('should be able to handle the panel node', () => {
|
|
13
13
|
expect(result.panel.json).toEqual(sortNestedArrays(panel));
|
14
14
|
});
|
15
15
|
|
16
|
-
test('should be able to handle mentions', () => {
|
17
|
-
const result = sortNestedArrays(adfToValidatorSpec(adfNode));
|
18
|
-
|
19
|
-
expect(result.mention.json).toEqual(sortNestedArrays(mention));
|
20
|
-
});
|
21
|
-
|
22
|
-
test('should be able to handle paragraphs', () => {
|
23
|
-
const result = sortNestedArrays(adfToValidatorSpec(adfNode));
|
24
|
-
|
25
|
-
expect(result.paragraph.json).toEqual(sortNestedArrays(paragraph));
|
26
|
-
});
|
27
|
-
|
28
16
|
// i don't know what node on the results object is nested_expand because
|
29
17
|
// nested_expand doesn't exist in the adfNode object :hmmmmmm:
|
30
18
|
test.skip('should be able to handle nested expand', () => {
|
@@ -54,39 +42,6 @@ const nested_expand = {
|
|
54
42
|
required: ['content'],
|
55
43
|
};
|
56
44
|
|
57
|
-
const paragraph = {
|
58
|
-
props: {
|
59
|
-
type: { type: 'enum', values: ['paragraph'] },
|
60
|
-
content: {
|
61
|
-
type: 'array',
|
62
|
-
items: ['inline'],
|
63
|
-
allowUnsupportedInline: true, // currently not supported by DSL
|
64
|
-
optional: true,
|
65
|
-
},
|
66
|
-
marks: { type: 'array', items: [], optional: true },
|
67
|
-
attrs: { props: { localId: { type: 'string', optional: true } } },
|
68
|
-
},
|
69
|
-
};
|
70
|
-
|
71
|
-
const mention = {
|
72
|
-
props: {
|
73
|
-
type: { type: 'enum', values: ['mention'] },
|
74
|
-
attrs: {
|
75
|
-
props: {
|
76
|
-
id: { type: 'string' },
|
77
|
-
text: { type: 'string', optional: true },
|
78
|
-
userType: {
|
79
|
-
type: 'enum',
|
80
|
-
values: ['DEFAULT', 'SPECIAL', 'APP'],
|
81
|
-
optional: true,
|
82
|
-
},
|
83
|
-
accessLevel: { type: 'string', optional: true },
|
84
|
-
localId: { type: 'string', optional: true },
|
85
|
-
},
|
86
|
-
},
|
87
|
-
},
|
88
|
-
};
|
89
|
-
|
90
45
|
const panel = {
|
91
46
|
props: {
|
92
47
|
type: { type: 'enum', values: ['panel'] },
|
@@ -129,6 +84,7 @@ const panel = {
|
|
129
84
|
],
|
130
85
|
],
|
131
86
|
minItems: 1,
|
87
|
+
allowUnsupportedBlock: true,
|
132
88
|
},
|
133
89
|
},
|
134
90
|
};
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { adfToValidatorSpec } from '@atlaskit/adf-schema-generator';
|
2
|
+
import * as currentSpecs from '@atlaskit/adf-utils/dist/cjs/validator/specs';
|
3
|
+
import adfNode from '../../../src/next-schema/full-schema.adf';
|
4
|
+
|
5
|
+
const newSpecs = sortNestedArrays(adfToValidatorSpec(adfNode));
|
6
|
+
const SKIP_LIST = [
|
7
|
+
'link', // doesn't exist in the output - validatorFn in DSL
|
8
|
+
|
9
|
+
'blockCard', // doesn't match existing spec
|
10
|
+
'bodiedExtension', // doesn't match existing spec
|
11
|
+
'caption', // doesn't match existing spec
|
12
|
+
'codeBlock', // doesn't match existing spec
|
13
|
+
'doc', // doesn't match existing spec
|
14
|
+
'embedCard', // doesn't match existing spec, validatorFn
|
15
|
+
'expand', // doesn't match existing spec
|
16
|
+
'extensionFrame', // doesn't match existing spec
|
17
|
+
'inlineCard', // doesn't match existing spec
|
18
|
+
'inlineExtension', // doesn't exist in the output
|
19
|
+
'inline_comment_marker', // doesn't exist in the output
|
20
|
+
'layoutColumn', // doesn't match existing spec, wrong group name in content, allowUnsupportedBlock
|
21
|
+
'layoutSection', // doesn't match existing spec, maxItem/minItem, extra marks
|
22
|
+
'layoutSection_full', // doesn't match existing spec, allowUnsupportedBlock, extra marks
|
23
|
+
'layoutSection_with_single_column', // doesn't exist in the output
|
24
|
+
'media', // doesn't match existing spec
|
25
|
+
'mediaInline', // doesn't match existing spec
|
26
|
+
'multiBodiedExtension', // doesn't match existing spec
|
27
|
+
'nestedExpand', // doesn't match existing spec
|
28
|
+
'tableCell', // doesn't match existing spec
|
29
|
+
'tableHeader', // doesn't match existing spec
|
30
|
+
'tableRow', // doesn't match existing spec, extra minItems
|
31
|
+
|
32
|
+
'atomic_inline', // doesn't exist in the output
|
33
|
+
'inline', // doesn't exist in the output
|
34
|
+
'block_content', // doesn't exist in the output
|
35
|
+
'nestedExpand_content', // doesn't exist in the output
|
36
|
+
'non_nestable_block_content', // doesn't exist in the output
|
37
|
+
'tableCell_content', // doesn't exist in the output
|
38
|
+
];
|
39
|
+
|
40
|
+
const testCases = Object.entries(currentSpecs).map(([key, value]) => {
|
41
|
+
return {
|
42
|
+
name: key,
|
43
|
+
currentSpec: sortNestedArrays(value),
|
44
|
+
newSpec: sortNestedArrays(newSpecs[key]?.json),
|
45
|
+
};
|
46
|
+
});
|
47
|
+
|
48
|
+
testCases.forEach(({ name, currentSpec, newSpec }) => {
|
49
|
+
const testMethod = SKIP_LIST.includes(name) ? it.skip : it;
|
50
|
+
testMethod(`should be able to handle ${name}`, () => {
|
51
|
+
expect(newSpec).toEqual(currentSpec);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
function sortNestedArrays(obj: any): any {
|
56
|
+
if (obj === null || obj === undefined) {
|
57
|
+
return obj;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (
|
61
|
+
Array.isArray(obj) &&
|
62
|
+
typeof obj[0] === 'string' &&
|
63
|
+
typeof obj[1] === 'object'
|
64
|
+
) {
|
65
|
+
// 1. tuple of object + string
|
66
|
+
obj[1] = sortNestedArrays(obj[1]);
|
67
|
+
} else if (Array.isArray(obj) && Array.isArray(obj[0])) {
|
68
|
+
// 2. array of arrays
|
69
|
+
for (let i = 0; i < obj.length; i++) {
|
70
|
+
obj[i] = sortNestedArrays(obj[i]);
|
71
|
+
}
|
72
|
+
} else if (
|
73
|
+
Array.isArray(obj) &&
|
74
|
+
!Array.isArray(obj[0]) &&
|
75
|
+
typeof obj[0] !== 'object'
|
76
|
+
) {
|
77
|
+
// 3. simple array
|
78
|
+
obj.sort();
|
79
|
+
}
|
80
|
+
if (typeof obj === 'object') {
|
81
|
+
// 4. object
|
82
|
+
for (const key of Object.keys(obj)) {
|
83
|
+
obj[key] = sortNestedArrays(obj[key]);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
return obj;
|
88
|
+
}
|
@@ -1,65 +1,79 @@
|
|
1
1
|
import { validateSchemaCompatibility } from 'json-schema-diff-validator';
|
2
2
|
import { adfToJSON } from '@atlaskit/adf-schema-generator';
|
3
3
|
import adfNode from '@atlaskit/adf-schema/src/next-schema/full-schema.adf';
|
4
|
+
import {
|
5
|
+
tableCellNodeContent,
|
6
|
+
tableHeaderNodeContent,
|
7
|
+
} from './__fixtures__/index.fixture';
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
9
|
+
declare let expect: any;
|
10
|
+
expect.extend({
|
11
|
+
toBeBackwardsCompatibleWith(received, expected) {
|
12
|
+
try {
|
13
|
+
validateSchemaCompatibility(expected, received, {
|
14
|
+
allowNewOneOf: true,
|
15
|
+
allowNewEnumValue: true,
|
16
|
+
allowReorder: true,
|
17
|
+
});
|
18
|
+
} catch (e) {
|
19
|
+
if (e.name === 'AssertionError') {
|
20
|
+
return {
|
21
|
+
pass: false,
|
22
|
+
message: () =>
|
23
|
+
JSON.stringify(
|
24
|
+
JSON.parse(
|
25
|
+
e.message.replace(
|
26
|
+
'The schema is not backward compatible. Difference include breaking change = ',
|
27
|
+
'',
|
28
|
+
),
|
29
|
+
),
|
30
|
+
null,
|
31
|
+
4,
|
32
|
+
),
|
33
|
+
};
|
34
|
+
}
|
35
|
+
return {
|
36
|
+
pass: false,
|
37
|
+
message: () => e.message,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
return { pass: true, message: 'Schemas are compatible' };
|
41
|
+
},
|
42
|
+
});
|
43
|
+
|
44
|
+
// The end goal is to be able to remove all transformation for known failures
|
45
|
+
function transformFullFixtureForKnownFailures(json) {
|
46
|
+
const definitions = json.definitions;
|
47
|
+
|
48
|
+
delete definitions.bodiedExtension_node;
|
49
|
+
delete definitions.codeBlock_node;
|
50
|
+
delete definitions.expand_node;
|
51
|
+
delete definitions.extension_node;
|
52
|
+
delete definitions.inlineExtension_node;
|
53
|
+
delete definitions.layoutSection_node;
|
54
|
+
delete definitions.mediaSingle_node;
|
55
|
+
delete definitions.nestedExpand_content;
|
56
|
+
delete definitions.nestedExpand_node;
|
57
|
+
delete definitions.nestedExpand_with_no_marks_node;
|
58
|
+
delete definitions.non_nestable_block_content;
|
59
|
+
delete definitions.table_cell_content;
|
60
|
+
delete definitions.mediaInline_node.properties.attrs.properties.data;
|
61
|
+
|
62
|
+
// New JSON, different to the old JSON schema
|
63
|
+
definitions.table_cell_node.properties.content = tableCellNodeContent;
|
64
|
+
definitions.table_header_node.properties.content = tableHeaderNodeContent;
|
65
|
+
|
66
|
+
return json;
|
67
|
+
}
|
47
68
|
|
48
69
|
test('ADF DSL to JSON Schema backwards compatibility for full schema', () => {
|
49
|
-
|
50
|
-
|
70
|
+
const currentSchema = transformFullFixtureForKnownFailures(
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
72
|
+
require('../../../json-schema/v1/full.json'),
|
73
|
+
);
|
51
74
|
const nextSchema = adfToJSON(adfNode);
|
52
|
-
DEFINITIONS_TO_SKIP_FULL.forEach((definition) => {
|
53
|
-
nextSchema.definitions[definition] = currentSchema.definitions[definition];
|
54
|
-
});
|
55
75
|
|
56
|
-
expect(()
|
57
|
-
validateSchemaCompatibility(currentSchema, nextSchema, {
|
58
|
-
allowNewOneOf: true,
|
59
|
-
allowNewEnumValue: true,
|
60
|
-
allowReorder: true,
|
61
|
-
});
|
62
|
-
}).not.toThrow();
|
76
|
+
expect(nextSchema).toBeBackwardsCompatibleWith(currentSchema);
|
63
77
|
});
|
64
78
|
|
65
79
|
const DEFINITIONS_TO_SKIP_STAGE_0 = [
|
@@ -89,6 +103,7 @@ const DEFINITIONS_TO_SKIP_STAGE_0 = [
|
|
89
103
|
'inlineExtension_node',
|
90
104
|
'inlineExtension_with_marks_node',
|
91
105
|
'inline_node',
|
106
|
+
'layoutSection_node',
|
92
107
|
'layoutSection_full_node',
|
93
108
|
'layoutSection_with_single_column_node',
|
94
109
|
'mediaInline_node',
|
@@ -119,11 +134,5 @@ test('ADF DSL to JSON Schema backwards compatibility for stage0 schema', () => {
|
|
119
134
|
nextSchema.definitions[definition] = currentSchema.definitions[definition];
|
120
135
|
});
|
121
136
|
|
122
|
-
expect(()
|
123
|
-
validateSchemaCompatibility(currentSchema, nextSchema, {
|
124
|
-
allowNewOneOf: true,
|
125
|
-
allowNewEnumValue: true,
|
126
|
-
allowReorder: true,
|
127
|
-
});
|
128
|
-
}).not.toThrow();
|
137
|
+
expect(nextSchema).toBeBackwardsCompatibleWith(currentSchema);
|
129
138
|
});
|