@atlaskit/adf-schema 37.1.39 → 37.1.41
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 +13 -0
- package/dist/cjs/next-schema/nodes/layoutSection.js +21 -2
- package/dist/cjs/next-schema/nodes/nestedExpand.js +17 -1
- package/dist/cjs/validator-schema/generated/validatorSpec.js +1879 -0
- package/dist/cjs/validator-schema/utils/sortNestedArrays.js +33 -0
- package/dist/es2019/next-schema/nodes/layoutSection.js +21 -2
- package/dist/es2019/next-schema/nodes/nestedExpand.js +17 -1
- package/dist/es2019/validator-schema/generated/validatorSpec.js +1873 -0
- package/dist/es2019/validator-schema/utils/sortNestedArrays.js +24 -0
- package/dist/esm/next-schema/nodes/layoutSection.js +21 -2
- package/dist/esm/next-schema/nodes/nestedExpand.js +17 -1
- package/dist/esm/validator-schema/generated/validatorSpec.js +1873 -0
- package/dist/esm/validator-schema/utils/sortNestedArrays.js +26 -0
- package/dist/types/next-schema/nodes/layoutSection.d.ts +19 -0
- package/dist/types/validator-schema/generated/validatorSpec.d.ts +1892 -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 +1 -38
- 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.41",
|
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.10",
|
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,12 +1,10 @@
|
|
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
7
|
const SKIP_LIST = [
|
7
|
-
'layoutSection_with_single_column', // doesn't exist in the output
|
8
|
-
'nestedExpand', // doesn't match existing spec
|
9
|
-
|
10
8
|
'atomic_inline', // doesn't exist in the output, not even used anywhere...
|
11
9
|
'nestedExpand_content', // doesn't exist in the output, completely different format from other groups
|
12
10
|
'tableCell_content', // doesn't exist in the output, completely different format from other groups
|
@@ -26,38 +24,3 @@ testCases.forEach(({ name, currentSpec, newSpec }) => {
|
|
26
24
|
expect(newSpec).toEqual(currentSpec);
|
27
25
|
});
|
28
26
|
});
|
29
|
-
|
30
|
-
function sortNestedArrays(obj: any): any {
|
31
|
-
if (obj === null || obj === undefined) {
|
32
|
-
return obj;
|
33
|
-
}
|
34
|
-
|
35
|
-
if (
|
36
|
-
Array.isArray(obj) &&
|
37
|
-
typeof obj[0] === 'string' &&
|
38
|
-
typeof obj[1] === 'object'
|
39
|
-
) {
|
40
|
-
// 1. tuple of object + string
|
41
|
-
obj[1] = sortNestedArrays(obj[1]);
|
42
|
-
} else if (Array.isArray(obj) && Array.isArray(obj[0])) {
|
43
|
-
// 2. array of arrays
|
44
|
-
for (let i = 0; i < obj.length; i++) {
|
45
|
-
obj[i] = sortNestedArrays(obj[i]);
|
46
|
-
}
|
47
|
-
} else if (
|
48
|
-
Array.isArray(obj) &&
|
49
|
-
!Array.isArray(obj[0]) &&
|
50
|
-
typeof obj[0] !== 'object'
|
51
|
-
) {
|
52
|
-
// 3. simple array
|
53
|
-
obj.sort();
|
54
|
-
}
|
55
|
-
if (typeof obj === 'object') {
|
56
|
-
// 4. object
|
57
|
-
for (const key of Object.keys(obj)) {
|
58
|
-
obj[key] = sortNestedArrays(obj[key]);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
return obj;
|
63
|
-
}
|
@@ -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();
|