@atlaskit/adf-schema 37.1.40 → 37.1.42
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 +12 -0
- package/dist/cjs/next-schema/groups/atomicInlineGroup.js +19 -0
- package/dist/cjs/next-schema/groups/tableCellContentPseudoGroup.js +1 -1
- package/dist/cjs/next-schema/nodes/nestedExpand.js +1 -1
- package/dist/cjs/next-schema/nodes/paragraph.js +2 -1
- package/dist/cjs/next-schema/nodes/tableCellContent.js +1 -1
- package/dist/cjs/validator-schema/generated/validatorSpec.js +1875 -0
- package/dist/cjs/validator-schema/utils/sortNestedArrays.js +33 -0
- package/dist/es2019/next-schema/groups/atomicInlineGroup.js +13 -0
- package/dist/es2019/next-schema/groups/tableCellContentPseudoGroup.js +1 -1
- package/dist/es2019/next-schema/nodes/nestedExpand.js +1 -1
- package/dist/es2019/next-schema/nodes/paragraph.js +2 -1
- package/dist/es2019/next-schema/nodes/tableCellContent.js +1 -1
- package/dist/es2019/validator-schema/generated/validatorSpec.js +1869 -0
- package/dist/es2019/validator-schema/utils/sortNestedArrays.js +24 -0
- package/dist/esm/next-schema/groups/atomicInlineGroup.js +13 -0
- package/dist/esm/next-schema/groups/tableCellContentPseudoGroup.js +1 -1
- package/dist/esm/next-schema/nodes/nestedExpand.js +1 -1
- package/dist/esm/next-schema/nodes/paragraph.js +2 -1
- package/dist/esm/next-schema/nodes/tableCellContent.js +1 -1
- package/dist/esm/validator-schema/generated/validatorSpec.js +1869 -0
- package/dist/esm/validator-schema/utils/sortNestedArrays.js +26 -0
- package/dist/types/next-schema/groups/atomicInlineGroup.d.ts +1 -0
- package/dist/types/next-schema/nodes/nestedExpand.d.ts +1 -1
- package/dist/types/validator-schema/generated/validatorSpec.d.ts +1888 -0
- package/dist/types/validator-schema/utils/sortNestedArrays.d.ts +1 -0
- package/package.json +3 -2
- package/schema-generators/__tests__/unit/adfToValidatorSpecValidation.unit.ts +2 -42
- package/schema-generators/__tests__/unit/json-full-schema-backwards-compat.unit.ts +23 -46
- package/schema-generators/validator-full-schema.ts +22 -0
@@ -0,0 +1 @@
|
|
1
|
+
export declare function sortNestedArrays<T>(obj: T): T;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/adf-schema",
|
3
|
-
"version": "37.1.
|
3
|
+
"version": "37.1.42",
|
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/"
|
@@ -35,6 +35,7 @@
|
|
35
35
|
"build": "yarn clean:build && yarn workspace @atlaskit/editor-prosemirror build && yarn workspace @atlaskit/adf-schema-generator build && yarn run build:all && yarn run generate:json-schema && yarn run build:json-schema",
|
36
36
|
"build:pm:full": "yarn ts-node ./schema-generators/pm-full-schema.ts && prettier --write './src/next-schema/generated/**/*.ts'",
|
37
37
|
"build:json:full": "yarn ts-node ./schema-generators/json-full-schema.ts",
|
38
|
+
"build:validator:full": "yarn ts-node ./schema-generators/validator-full-schema.ts && prettier --write './src/validator-schema/generated/**/*.ts'",
|
38
39
|
"clean": "../../scripts/build-clean.sh",
|
39
40
|
"link:afe": "yarn build:all && node ./copy-dist-to-afe.js"
|
40
41
|
},
|
@@ -47,7 +48,7 @@
|
|
47
48
|
},
|
48
49
|
"devDependencies": {
|
49
50
|
"@atlassian/adf-schema-json": "^1.16.0",
|
50
|
-
"@atlaskit/adf-schema-generator": "^1.25.
|
51
|
+
"@atlaskit/adf-schema-generator": "^1.25.11",
|
51
52
|
"@atlaskit/adf-utils": "^19.2.2",
|
52
53
|
"@atlaskit/codemod-utils": "^4.2.4",
|
53
54
|
"@atlaskit/json-schema-generator": "^3.3.9",
|
@@ -1,13 +1,9 @@
|
|
1
1
|
import { adfToValidatorSpec } from '@atlaskit/adf-schema-generator';
|
2
2
|
import * as currentSpecs from '@atlaskit/adf-utils/dist/cjs/validator/specs';
|
3
3
|
import adfNode from '../../../src/next-schema/full-schema.adf';
|
4
|
+
import { sortNestedArrays } from '../../../src/validator-schema/utils/sortNestedArrays';
|
4
5
|
|
5
6
|
const newSpecs = sortNestedArrays(adfToValidatorSpec(adfNode));
|
6
|
-
const SKIP_LIST = [
|
7
|
-
'atomic_inline', // doesn't exist in the output, not even used anywhere...
|
8
|
-
'nestedExpand_content', // doesn't exist in the output, completely different format from other groups
|
9
|
-
'tableCell_content', // doesn't exist in the output, completely different format from other groups
|
10
|
-
];
|
11
7
|
|
12
8
|
const testCases = Object.entries(currentSpecs).map(([key, value]) => {
|
13
9
|
return {
|
@@ -18,43 +14,7 @@ const testCases = Object.entries(currentSpecs).map(([key, value]) => {
|
|
18
14
|
});
|
19
15
|
|
20
16
|
testCases.forEach(({ name, currentSpec, newSpec }) => {
|
21
|
-
|
22
|
-
testMethod(`should be able to handle ${name}`, () => {
|
17
|
+
it(`should be able to handle ${name}`, () => {
|
23
18
|
expect(newSpec).toEqual(currentSpec);
|
24
19
|
});
|
25
20
|
});
|
26
|
-
|
27
|
-
function sortNestedArrays(obj: any): any {
|
28
|
-
if (obj === null || obj === undefined) {
|
29
|
-
return obj;
|
30
|
-
}
|
31
|
-
|
32
|
-
if (
|
33
|
-
Array.isArray(obj) &&
|
34
|
-
typeof obj[0] === 'string' &&
|
35
|
-
typeof obj[1] === 'object'
|
36
|
-
) {
|
37
|
-
// 1. tuple of object + string
|
38
|
-
obj[1] = sortNestedArrays(obj[1]);
|
39
|
-
} else if (Array.isArray(obj) && Array.isArray(obj[0])) {
|
40
|
-
// 2. array of arrays
|
41
|
-
for (let i = 0; i < obj.length; i++) {
|
42
|
-
obj[i] = sortNestedArrays(obj[i]);
|
43
|
-
}
|
44
|
-
} else if (
|
45
|
-
Array.isArray(obj) &&
|
46
|
-
!Array.isArray(obj[0]) &&
|
47
|
-
typeof obj[0] !== 'object'
|
48
|
-
) {
|
49
|
-
// 3. simple array
|
50
|
-
obj.sort();
|
51
|
-
}
|
52
|
-
if (typeof obj === 'object') {
|
53
|
-
// 4. object
|
54
|
-
for (const key of Object.keys(obj)) {
|
55
|
-
obj[key] = sortNestedArrays(obj[key]);
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
return obj;
|
60
|
-
}
|
@@ -101,63 +101,40 @@ test('JSON Schema to ADF DSL backwards compatibility for full schema', () => {
|
|
101
101
|
expect(currentSchema).toBeBackwardsCompatibleWith(nextSchema);
|
102
102
|
});
|
103
103
|
|
104
|
-
const
|
105
|
-
'blockCard_node',
|
106
|
-
'block_content',
|
107
|
-
'bodiedExtension_node',
|
108
|
-
'bodiedExtension_with_marks_node',
|
109
|
-
'codeBlock_node',
|
110
|
-
'codeBlock_with_marks_node',
|
111
|
-
'codeBlock_with_no_marks_node',
|
112
|
-
'code_inline_node',
|
113
|
-
'date_node',
|
104
|
+
const DEFINITIONS_TO_SKIP_STAGE_0_BACKWARDS = [
|
114
105
|
'doc_node',
|
115
|
-
'emoji_node',
|
116
|
-
'expand_node',
|
117
|
-
'expand_with_breakout_mark_node',
|
118
|
-
'expand_with_no_mark_node',
|
119
|
-
'extensionFrame_node',
|
120
|
-
'extension_node',
|
121
|
-
'extension_with_marks_node',
|
122
|
-
'formatted_text_inline_node',
|
123
|
-
'heading_node',
|
124
|
-
'heading_with_alignment_node',
|
125
|
-
'heading_with_indentation_node',
|
126
|
-
'heading_with_no_marks_node',
|
127
106
|
'inlineCard_node',
|
128
|
-
'inlineExtension_node',
|
129
|
-
'inlineExtension_with_marks_node',
|
130
|
-
'inline_node',
|
131
|
-
'layoutSection_node',
|
132
|
-
'layoutSection_full_node',
|
133
107
|
'layoutSection_with_single_column_node',
|
134
|
-
'mediaInline_node',
|
135
|
-
'mediaSingle_caption_node',
|
136
|
-
'mediaSingle_full_node',
|
137
|
-
'mediaSingle_node',
|
138
|
-
'mention_node',
|
139
108
|
'multiBodiedExtension_node',
|
140
|
-
'nestedExpand_content',
|
141
|
-
'nestedExpand_node',
|
142
|
-
'nestedExpand_with_no_marks_node',
|
143
|
-
'non_nestable_block_content',
|
144
|
-
'paragraph_node',
|
145
|
-
'paragraph_with_alignment_node',
|
146
|
-
'paragraph_with_indentation_node',
|
147
|
-
'paragraph_with_no_marks_node',
|
148
|
-
'status_node',
|
149
|
-
'table_cell_content',
|
150
|
-
'table_cell_node',
|
151
|
-
'table_header_node',
|
152
|
-
'text_node',
|
153
109
|
];
|
154
110
|
test('ADF DSL to JSON Schema backwards compatibility for stage0 schema', () => {
|
155
111
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
156
112
|
const currentSchema = require('../../../json-schema/v1/stage-0.json');
|
157
113
|
const nextSchema = adfToJSON(adfNode);
|
158
|
-
|
114
|
+
DEFINITIONS_TO_SKIP_STAGE_0_BACKWARDS.forEach((definition) => {
|
159
115
|
nextSchema.definitions[definition] = currentSchema.definitions[definition];
|
160
116
|
});
|
161
117
|
|
162
118
|
expect(nextSchema).toBeBackwardsCompatibleWith(currentSchema);
|
163
119
|
});
|
120
|
+
|
121
|
+
const DEFINITIONS_TO_SKIP_STAGE_0_FORWARDS = [
|
122
|
+
'extensionFrame_node',
|
123
|
+
'inline_node',
|
124
|
+
'table_row_node',
|
125
|
+
'table_cell_content',
|
126
|
+
'codeBlock_node',
|
127
|
+
'codeBlock_with_marks_node',
|
128
|
+
'mediaInline_node',
|
129
|
+
'mediaGroup_node',
|
130
|
+
];
|
131
|
+
test('JSON Schema to ADF DSL backwards compatibility for stage0 schema', () => {
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
133
|
+
const currentSchema = require('../../../json-schema/v1/stage-0.json');
|
134
|
+
const nextSchema = adfToJSON(adfNode);
|
135
|
+
DEFINITIONS_TO_SKIP_STAGE_0_FORWARDS.forEach((definition) => {
|
136
|
+
currentSchema.definitions[definition] = nextSchema.definitions[definition];
|
137
|
+
});
|
138
|
+
|
139
|
+
expect(currentSchema).toBeBackwardsCompatibleWith(nextSchema);
|
140
|
+
});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import {
|
2
|
+
adfToValidatorSpec,
|
3
|
+
writeToFile,
|
4
|
+
} from '@atlaskit/adf-schema-generator';
|
5
|
+
import adfNode from 'src/next-schema/full-schema.adf';
|
6
|
+
import { sortNestedArrays } from 'src/validator-schema/utils/sortNestedArrays';
|
7
|
+
|
8
|
+
function generateValidatorSpec() {
|
9
|
+
const output = sortNestedArrays(adfToValidatorSpec(adfNode));
|
10
|
+
return Object.entries(output)
|
11
|
+
.map(
|
12
|
+
([key, value]) => `export const ${key} = ${JSON.stringify(value.json)};`,
|
13
|
+
)
|
14
|
+
.join('\n\n');
|
15
|
+
}
|
16
|
+
|
17
|
+
function main() {
|
18
|
+
const spec = generateValidatorSpec();
|
19
|
+
writeToFile('validatorSpec', spec, 'validator-schema');
|
20
|
+
}
|
21
|
+
|
22
|
+
main();
|