@atlaskit/adf-schema 37.1.40 → 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.
@@ -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.40",
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.9",
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,6 +1,7 @@
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 = [
@@ -23,38 +24,3 @@ testCases.forEach(({ name, currentSpec, newSpec }) => {
23
24
  expect(newSpec).toEqual(currentSpec);
24
25
  });
25
26
  });
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
- }
@@ -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();