@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.
Files changed (150) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/dist/cjs/next-schema/full-schema.adf.js +1 -1
  3. package/dist/cjs/next-schema/generated/nodeTypes.js +101 -31
  4. package/dist/cjs/next-schema/groups/blockGroup.js +1 -1
  5. package/dist/cjs/next-schema/groups/inlineGroup.js +1 -1
  6. package/dist/cjs/next-schema/index.js +511 -0
  7. package/dist/cjs/next-schema/nodes/blockquote.js +3 -2
  8. package/dist/cjs/next-schema/nodes/bodiedExtension.js +6 -2
  9. package/dist/cjs/next-schema/nodes/codeBlock.js +10 -3
  10. package/dist/cjs/next-schema/nodes/date.js +2 -1
  11. package/dist/cjs/next-schema/nodes/emoji.js +2 -1
  12. package/dist/cjs/next-schema/nodes/expand.js +11 -3
  13. package/dist/cjs/next-schema/nodes/extension.js +5 -2
  14. package/dist/cjs/next-schema/nodes/heading.js +28 -5
  15. package/dist/cjs/next-schema/nodes/inlineExtension.js +1 -0
  16. package/dist/cjs/next-schema/nodes/layoutSection.js +15 -2
  17. package/dist/cjs/next-schema/nodes/list.js +12 -9
  18. package/dist/cjs/next-schema/nodes/mediaInline.js +2 -1
  19. package/dist/cjs/next-schema/nodes/mediaSingle.js +75 -4
  20. package/dist/cjs/next-schema/nodes/mention.js +2 -1
  21. package/dist/cjs/next-schema/nodes/multiBodiedExtension.js +8 -4
  22. package/dist/cjs/next-schema/nodes/nestedExpand.js +5 -1
  23. package/dist/cjs/next-schema/nodes/panel.js +3 -0
  24. package/dist/cjs/next-schema/nodes/paragraph.js +29 -5
  25. package/dist/cjs/next-schema/nodes/status.js +2 -1
  26. package/dist/cjs/next-schema/nodes/tableCell.js +4 -1
  27. package/dist/cjs/next-schema/nodes/tableHeader.js +5 -2
  28. package/dist/cjs/next-schema/nodes/task.js +1 -0
  29. package/dist/cjs/next-schema/nodes/text.js +7 -1
  30. package/dist/cjs/schema/nodes/media.js +10 -4
  31. package/dist/cjs/schema/nodes/text.js +1 -0
  32. package/dist/es2019/next-schema/full-schema.adf.js +1 -1
  33. package/dist/es2019/next-schema/generated/nodeTypes.js +100 -30
  34. package/dist/es2019/next-schema/groups/blockGroup.js +1 -1
  35. package/dist/es2019/next-schema/groups/inlineGroup.js +1 -1
  36. package/dist/es2019/next-schema/index.js +2 -0
  37. package/dist/es2019/next-schema/nodes/blockquote.js +3 -2
  38. package/dist/es2019/next-schema/nodes/bodiedExtension.js +6 -2
  39. package/dist/es2019/next-schema/nodes/codeBlock.js +10 -3
  40. package/dist/es2019/next-schema/nodes/date.js +2 -1
  41. package/dist/es2019/next-schema/nodes/emoji.js +2 -1
  42. package/dist/es2019/next-schema/nodes/expand.js +11 -3
  43. package/dist/es2019/next-schema/nodes/extension.js +5 -2
  44. package/dist/es2019/next-schema/nodes/heading.js +27 -4
  45. package/dist/es2019/next-schema/nodes/inlineExtension.js +1 -0
  46. package/dist/es2019/next-schema/nodes/layoutSection.js +15 -2
  47. package/dist/es2019/next-schema/nodes/list.js +12 -9
  48. package/dist/es2019/next-schema/nodes/mediaInline.js +2 -1
  49. package/dist/es2019/next-schema/nodes/mediaSingle.js +76 -5
  50. package/dist/es2019/next-schema/nodes/mention.js +2 -1
  51. package/dist/es2019/next-schema/nodes/multiBodiedExtension.js +8 -4
  52. package/dist/es2019/next-schema/nodes/nestedExpand.js +5 -1
  53. package/dist/es2019/next-schema/nodes/panel.js +3 -0
  54. package/dist/es2019/next-schema/nodes/paragraph.js +29 -5
  55. package/dist/es2019/next-schema/nodes/status.js +2 -1
  56. package/dist/es2019/next-schema/nodes/tableCell.js +4 -1
  57. package/dist/es2019/next-schema/nodes/tableHeader.js +5 -2
  58. package/dist/es2019/next-schema/nodes/task.js +1 -0
  59. package/dist/es2019/next-schema/nodes/text.js +7 -1
  60. package/dist/es2019/schema/nodes/media.js +3 -1
  61. package/dist/es2019/schema/nodes/text.js +1 -0
  62. package/dist/esm/next-schema/full-schema.adf.js +1 -1
  63. package/dist/esm/next-schema/generated/nodeTypes.js +100 -30
  64. package/dist/esm/next-schema/groups/blockGroup.js +1 -1
  65. package/dist/esm/next-schema/groups/inlineGroup.js +1 -1
  66. package/dist/esm/next-schema/index.js +2 -0
  67. package/dist/esm/next-schema/nodes/blockquote.js +3 -2
  68. package/dist/esm/next-schema/nodes/bodiedExtension.js +6 -2
  69. package/dist/esm/next-schema/nodes/codeBlock.js +10 -3
  70. package/dist/esm/next-schema/nodes/date.js +2 -1
  71. package/dist/esm/next-schema/nodes/emoji.js +2 -1
  72. package/dist/esm/next-schema/nodes/expand.js +11 -3
  73. package/dist/esm/next-schema/nodes/extension.js +5 -2
  74. package/dist/esm/next-schema/nodes/heading.js +27 -4
  75. package/dist/esm/next-schema/nodes/inlineExtension.js +1 -0
  76. package/dist/esm/next-schema/nodes/layoutSection.js +15 -2
  77. package/dist/esm/next-schema/nodes/list.js +12 -9
  78. package/dist/esm/next-schema/nodes/mediaInline.js +2 -1
  79. package/dist/esm/next-schema/nodes/mediaSingle.js +76 -5
  80. package/dist/esm/next-schema/nodes/mention.js +2 -1
  81. package/dist/esm/next-schema/nodes/multiBodiedExtension.js +8 -4
  82. package/dist/esm/next-schema/nodes/nestedExpand.js +5 -1
  83. package/dist/esm/next-schema/nodes/panel.js +3 -0
  84. package/dist/esm/next-schema/nodes/paragraph.js +29 -5
  85. package/dist/esm/next-schema/nodes/status.js +2 -1
  86. package/dist/esm/next-schema/nodes/tableCell.js +4 -1
  87. package/dist/esm/next-schema/nodes/tableHeader.js +5 -2
  88. package/dist/esm/next-schema/nodes/task.js +1 -0
  89. package/dist/esm/next-schema/nodes/text.js +7 -1
  90. package/dist/esm/schema/nodes/media.js +9 -4
  91. package/dist/esm/schema/nodes/text.js +1 -0
  92. package/dist/types/next-schema/full-schema.adf.d.ts +18 -0
  93. package/dist/types/next-schema/generated/markTypes.d.ts +20 -20
  94. package/dist/types/next-schema/generated/nodeGroupTypes.d.ts +2 -2
  95. package/dist/types/next-schema/generated/nodeTypes.d.ts +145 -96
  96. package/dist/types/next-schema/groups/nonNestableBlockContentGroup.d.ts +128 -6
  97. package/dist/types/next-schema/index.d.ts +5 -0
  98. package/dist/types/next-schema/nodes/blockCard.d.ts +18 -0
  99. package/dist/types/next-schema/nodes/blockquote.d.ts +20 -1
  100. package/dist/types/next-schema/nodes/bodiedExtension.d.ts +20 -0
  101. package/dist/types/next-schema/nodes/caption.d.ts +18 -0
  102. package/dist/types/next-schema/nodes/codeBlock.d.ts +48 -0
  103. package/dist/types/next-schema/nodes/confluenceJiraIssue.d.ts +18 -0
  104. package/dist/types/next-schema/nodes/confluenceUnsupportedBlock.d.ts +18 -0
  105. package/dist/types/next-schema/nodes/confluenceUnsupportedInline.d.ts +18 -0
  106. package/dist/types/next-schema/nodes/date.d.ts +18 -0
  107. package/dist/types/next-schema/nodes/decisionItem.d.ts +18 -0
  108. package/dist/types/next-schema/nodes/decisionList.d.ts +18 -0
  109. package/dist/types/next-schema/nodes/embedCard.d.ts +18 -0
  110. package/dist/types/next-schema/nodes/emoji.d.ts +18 -0
  111. package/dist/types/next-schema/nodes/expand.d.ts +25 -0
  112. package/dist/types/next-schema/nodes/extension.d.ts +19 -0
  113. package/dist/types/next-schema/nodes/extensionFrame.d.ts +18 -0
  114. package/dist/types/next-schema/nodes/hardBreak.d.ts +18 -0
  115. package/dist/types/next-schema/nodes/heading.d.ts +80 -0
  116. package/dist/types/next-schema/nodes/image.d.ts +18 -0
  117. package/dist/types/next-schema/nodes/inlineCard.d.ts +18 -0
  118. package/dist/types/next-schema/nodes/inlineExtension.d.ts +18 -0
  119. package/dist/types/next-schema/nodes/layoutColumn.d.ts +18 -0
  120. package/dist/types/next-schema/nodes/layoutSection.d.ts +22 -0
  121. package/dist/types/next-schema/nodes/list.d.ts +36 -0
  122. package/dist/types/next-schema/nodes/media.d.ts +18 -0
  123. package/dist/types/next-schema/nodes/mediaGroup.d.ts +18 -0
  124. package/dist/types/next-schema/nodes/mediaInline.d.ts +18 -0
  125. package/dist/types/next-schema/nodes/mediaSingle.d.ts +67 -1
  126. package/dist/types/next-schema/nodes/mention.d.ts +18 -0
  127. package/dist/types/next-schema/nodes/multiBodiedExtension.d.ts +18 -0
  128. package/dist/types/next-schema/nodes/nestedExpand.d.ts +22 -0
  129. package/dist/types/next-schema/nodes/panel.d.ts +22 -1
  130. package/dist/types/next-schema/nodes/paragraph.d.ts +29 -0
  131. package/dist/types/next-schema/nodes/placeholder.d.ts +18 -0
  132. package/dist/types/next-schema/nodes/rule.d.ts +18 -0
  133. package/dist/types/next-schema/nodes/status.d.ts +18 -0
  134. package/dist/types/next-schema/nodes/table.d.ts +18 -0
  135. package/dist/types/next-schema/nodes/tableCell.d.ts +18 -0
  136. package/dist/types/next-schema/nodes/tableHeader.d.ts +18 -0
  137. package/dist/types/next-schema/nodes/tableRow.d.ts +18 -0
  138. package/dist/types/next-schema/nodes/task.d.ts +36 -0
  139. package/dist/types/next-schema/nodes/text.d.ts +22 -1
  140. package/dist/types/next-schema/nodes/unsupportedBlock.d.ts +18 -0
  141. package/dist/types/next-schema/nodes/unsupportedInline.d.ts +18 -0
  142. package/package.json +8 -3
  143. package/schema-generators/__tests__/unit/__fixtures__/index.fixture.ts +140 -0
  144. package/schema-generators/__tests__/unit/adfToValidatorSpec.unit.ts +1 -45
  145. package/schema-generators/__tests__/unit/adfToValidatorSpecValidation.unit.ts +88 -0
  146. package/schema-generators/__tests__/unit/json-full-schema-backwards-compat.unit.ts +70 -61
  147. package/schema-generators/__tests__/unit/validate-pm-schema.unit.ts +152 -46
  148. package/schema-next/package.json +9 -0
  149. package/schema-generators/__tests__/unit/jqueries.md +0 -194
  150. 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.0.2",
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": "https://bitbucket.org/atlassian/adf-schema",
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.17.4",
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
- const DEFINITIONS_TO_SKIP_FULL = [
6
- 'blockCard_node',
7
- 'block_content',
8
- 'bodiedExtension_node',
9
- 'bodiedExtension_with_marks_node',
10
- 'codeBlock_node',
11
- 'codeBlock_with_marks_node',
12
- 'codeBlock_with_no_marks_node',
13
- 'code_inline_node',
14
- 'doc_node',
15
- 'expand_node',
16
- 'expand_with_breakout_mark_node',
17
- 'expand_with_no_mark_node',
18
- 'extension_node',
19
- 'extension_with_marks_node',
20
- 'formatted_text_inline_node',
21
- 'heading_node',
22
- 'heading_with_alignment_node',
23
- 'heading_with_indentation_node',
24
- 'heading_with_no_marks_node',
25
- 'inlineCard_node',
26
- 'inlineExtension_node',
27
- 'inlineExtension_with_marks_node',
28
- 'inline_node',
29
- 'layoutSection_full_node',
30
- 'mediaInline_node',
31
- 'mediaSingle_caption_node',
32
- 'mediaSingle_full_node',
33
- 'mediaSingle_node',
34
- 'nestedExpand_content',
35
- 'nestedExpand_node',
36
- 'nestedExpand_with_no_marks_node',
37
- 'non_nestable_block_content',
38
- 'paragraph_node',
39
- 'paragraph_with_alignment_node',
40
- 'paragraph_with_indentation_node',
41
- 'paragraph_with_no_marks_node',
42
- 'table_cell_content',
43
- 'table_cell_node',
44
- 'table_header_node',
45
- 'text_node',
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
- // eslint-disable-next-line @typescript-eslint/no-var-requires
50
- const currentSchema = require('../../../json-schema/v1/full.json');
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
  });