@atlaskit/adf-schema 36.18.1 → 36.18.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 36.18.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4126ead: json schema validation for the next schema produced by adf-schema-generator
8
+
3
9
  ## 36.18.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "36.18.1",
3
+ "version": "36.18.2",
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/"
@@ -66,6 +66,7 @@
66
66
  "cross-env": "^7.0.3",
67
67
  "jest": "^29.6.2",
68
68
  "jest-environment-jsdom": "^29.6.2",
69
+ "json-schema-diff-validator": "^0.4.1",
69
70
  "prop-types": "^15.5.4",
70
71
  "react": "^16.8.0",
71
72
  "react-dom": "^16.8.0",
@@ -0,0 +1,129 @@
1
+ import { validateSchemaCompatibility } from 'json-schema-diff-validator';
2
+ import { adfToJSON } from '@atlaskit/adf-schema-generator';
3
+ import adfNode from '@atlaskit/adf-schema/src/next-schema/full-schema.adf';
4
+
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
+ ];
47
+
48
+ 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');
51
+ const nextSchema = adfToJSON(adfNode);
52
+ DEFINITIONS_TO_SKIP_FULL.forEach((definition) => {
53
+ nextSchema.definitions[definition] = currentSchema.definitions[definition];
54
+ });
55
+
56
+ expect(() => {
57
+ validateSchemaCompatibility(currentSchema, nextSchema, {
58
+ allowNewOneOf: true,
59
+ allowNewEnumValue: true,
60
+ allowReorder: true,
61
+ });
62
+ }).not.toThrow();
63
+ });
64
+
65
+ const DEFINITIONS_TO_SKIP_STAGE_0 = [
66
+ 'blockCard_node',
67
+ 'block_content',
68
+ 'bodiedExtension_node',
69
+ 'bodiedExtension_with_marks_node',
70
+ 'codeBlock_node',
71
+ 'codeBlock_with_marks_node',
72
+ 'codeBlock_with_no_marks_node',
73
+ 'code_inline_node',
74
+ 'date_node',
75
+ 'doc_node',
76
+ 'emoji_node',
77
+ 'expand_node',
78
+ 'expand_with_breakout_mark_node',
79
+ 'expand_with_no_mark_node',
80
+ 'extensionFrame_node',
81
+ 'extension_node',
82
+ 'extension_with_marks_node',
83
+ 'formatted_text_inline_node',
84
+ 'heading_node',
85
+ 'heading_with_alignment_node',
86
+ 'heading_with_indentation_node',
87
+ 'heading_with_no_marks_node',
88
+ 'inlineCard_node',
89
+ 'inlineExtension_node',
90
+ 'inlineExtension_with_marks_node',
91
+ 'inline_node',
92
+ 'layoutSection_full_node',
93
+ 'layoutSection_with_single_column_node',
94
+ 'mediaInline_node',
95
+ 'mediaSingle_caption_node',
96
+ 'mediaSingle_full_node',
97
+ 'mediaSingle_node',
98
+ 'mention_node',
99
+ 'multiBodiedExtension_node',
100
+ 'nestedExpand_content',
101
+ 'nestedExpand_node',
102
+ 'nestedExpand_with_no_marks_node',
103
+ 'non_nestable_block_content',
104
+ 'paragraph_node',
105
+ 'paragraph_with_alignment_node',
106
+ 'paragraph_with_indentation_node',
107
+ 'paragraph_with_no_marks_node',
108
+ 'status_node',
109
+ 'table_cell_content',
110
+ 'table_cell_node',
111
+ 'table_header_node',
112
+ 'text_node',
113
+ ];
114
+ test('ADF DSL to JSON Schema backwards compatibility for stage0 schema', () => {
115
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
116
+ const currentSchema = require('../../../json-schema/v1/stage-0.json');
117
+ const nextSchema = adfToJSON(adfNode);
118
+ DEFINITIONS_TO_SKIP_STAGE_0.forEach((definition) => {
119
+ nextSchema.definitions[definition] = currentSchema.definitions[definition];
120
+ });
121
+
122
+ expect(() => {
123
+ validateSchemaCompatibility(currentSchema, nextSchema, {
124
+ allowNewOneOf: true,
125
+ allowNewEnumValue: true,
126
+ allowReorder: true,
127
+ });
128
+ }).not.toThrow();
129
+ });