From 30893a68b171167502135b48258ba4b93c8375c7 Mon Sep 17 00:00:00 2001 From: Yves Rijckaert Date: Tue, 29 Oct 2024 06:49:25 +0100 Subject: [PATCH] feat: bring rich text validator [TOL-2426] (#694) * feat: bring rich text validator * chore: node 20 * test(rich-text-types): migrate tests for validation [] * fix(rich-text-types): entry hyperlink validation * refactor(rich-text-types): you don't need lodash uniqBy [] * refactor(build): exclude dependencies from bundle [] BREAKING CHANGE: removed getSchemaWithNodeType in favor of validateRichTextDocument --------- Co-authored-by: Chris Helgert --- .nvmrc | 2 +- package.json | 3 +- .../rollup.config.ts | 2 +- .../rich-text-from-markdown/rollup.config.js | 6 +- packages/rich-text-html-renderer/package.json | 2 - .../rich-text-html-renderer/rollup.config.js | 6 +- packages/rich-text-links/rollup.config.js | 6 +- .../rollup.config.js | 6 +- .../rich-text-react-renderer/rollup.config.js | 4 +- packages/rich-text-types/package.json | 11 +- packages/rich-text-types/rollup.config.js | 34 +- .../src/__test__/validation.test.ts | 1086 +++++ packages/rich-text-types/src/index.ts | 3 +- .../__snapshots__/schemas.test.ts.snap | 4256 ----------------- .../src/schemas/__test__/helpers.test.ts | 23 - .../src/schemas/__test__/schemas.test.ts | 26 - .../schemas/generated/asset-hyperlink.json | 122 - .../src/schemas/generated/blockquote.json | 155 - .../src/schemas/generated/document.json | 232 - .../generated/embedded-asset-block.json | 172 - .../generated/embedded-entry-block.json | 172 - .../generated/embedded-entry-inline.json | 123 - .../generated/embedded-resource-block.json | 172 - .../generated/embedded-resource-inline.json | 123 - .../schemas/generated/entry-hyperlink.json | 122 - .../src/schemas/generated/heading-1.json | 128 - .../src/schemas/generated/heading-2.json | 128 - .../src/schemas/generated/heading-3.json | 128 - .../src/schemas/generated/heading-4.json | 128 - .../src/schemas/generated/heading-5.json | 128 - .../src/schemas/generated/heading-6.json | 128 - .../src/schemas/generated/hr.json | 129 - .../src/schemas/generated/hyperlink.json | 87 - .../src/schemas/generated/list-item.json | 232 - .../src/schemas/generated/ordered-list.json | 259 - .../src/schemas/generated/paragraph.json | 128 - .../schemas/generated/resource-hyperlink.json | 122 - .../src/schemas/generated/table-cell.json | 165 - .../schemas/generated/table-header-cell.json | 164 - .../src/schemas/generated/table-row.json | 193 - .../src/schemas/generated/table.json | 221 - .../src/schemas/generated/text.json | 52 - .../src/schemas/generated/unordered-list.json | 259 - packages/rich-text-types/src/schemas/index.ts | 44 - .../rich-text-types/src/validator/assert.ts | 296 ++ .../rich-text-types/src/validator/errors.ts | 104 + .../rich-text-types/src/validator/index.ts | 114 + .../rich-text-types/src/validator/node.ts | 173 + .../rich-text-types/src/validator/path.ts | 19 + .../rich-text-types/src/validator/text.ts | 34 + .../rich-text-types/tools/jsonSchemaGen.ts | 83 - yarn.lock | 157 +- 52 files changed, 1872 insertions(+), 8800 deletions(-) create mode 100644 packages/rich-text-types/src/__test__/validation.test.ts delete mode 100644 packages/rich-text-types/src/schemas/__test__/__snapshots__/schemas.test.ts.snap delete mode 100644 packages/rich-text-types/src/schemas/__test__/helpers.test.ts delete mode 100644 packages/rich-text-types/src/schemas/__test__/schemas.test.ts delete mode 100644 packages/rich-text-types/src/schemas/generated/asset-hyperlink.json delete mode 100644 packages/rich-text-types/src/schemas/generated/blockquote.json delete mode 100644 packages/rich-text-types/src/schemas/generated/document.json delete mode 100644 packages/rich-text-types/src/schemas/generated/embedded-asset-block.json delete mode 100644 packages/rich-text-types/src/schemas/generated/embedded-entry-block.json delete mode 100644 packages/rich-text-types/src/schemas/generated/embedded-entry-inline.json delete mode 100644 packages/rich-text-types/src/schemas/generated/embedded-resource-block.json delete mode 100644 packages/rich-text-types/src/schemas/generated/embedded-resource-inline.json delete mode 100644 packages/rich-text-types/src/schemas/generated/entry-hyperlink.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-1.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-2.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-3.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-4.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-5.json delete mode 100644 packages/rich-text-types/src/schemas/generated/heading-6.json delete mode 100644 packages/rich-text-types/src/schemas/generated/hr.json delete mode 100644 packages/rich-text-types/src/schemas/generated/hyperlink.json delete mode 100644 packages/rich-text-types/src/schemas/generated/list-item.json delete mode 100644 packages/rich-text-types/src/schemas/generated/ordered-list.json delete mode 100644 packages/rich-text-types/src/schemas/generated/paragraph.json delete mode 100644 packages/rich-text-types/src/schemas/generated/resource-hyperlink.json delete mode 100644 packages/rich-text-types/src/schemas/generated/table-cell.json delete mode 100644 packages/rich-text-types/src/schemas/generated/table-header-cell.json delete mode 100644 packages/rich-text-types/src/schemas/generated/table-row.json delete mode 100644 packages/rich-text-types/src/schemas/generated/table.json delete mode 100644 packages/rich-text-types/src/schemas/generated/text.json delete mode 100644 packages/rich-text-types/src/schemas/generated/unordered-list.json delete mode 100644 packages/rich-text-types/src/schemas/index.ts create mode 100644 packages/rich-text-types/src/validator/assert.ts create mode 100644 packages/rich-text-types/src/validator/errors.ts create mode 100644 packages/rich-text-types/src/validator/index.ts create mode 100644 packages/rich-text-types/src/validator/node.ts create mode 100644 packages/rich-text-types/src/validator/path.ts create mode 100644 packages/rich-text-types/src/validator/text.ts delete mode 100644 packages/rich-text-types/tools/jsonSchemaGen.ts diff --git a/.nvmrc b/.nvmrc index 3f430af8..9a2a0e21 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18 +v20 diff --git a/package.json b/package.json index e44fc2b1..b1dcdf3b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/contentful/rich-text.git" }, "engines": { - "node": ">=18" + "node": ">=20" }, "scripts": { "benchmark": "ts-node -O '{\"module\": \"commonjs\"}' bin/benchmark", @@ -71,7 +71,6 @@ "prettier": "^3.2.5", "rimraf": "6.0.1", "rollup": "^4.18.0", - "rollup-plugin-copy": "3.5.0", "rollup-plugin-json": "^4.0.0", "rollup-plugin-typescript2": "^0.36.0", "ts-jest": "^29.1.2", diff --git a/packages/contentful-slatejs-adapter/rollup.config.ts b/packages/contentful-slatejs-adapter/rollup.config.ts index 4cb62f29..e44845ba 100644 --- a/packages/contentful-slatejs-adapter/rollup.config.ts +++ b/packages/contentful-slatejs-adapter/rollup.config.ts @@ -9,7 +9,7 @@ const options = { input: `src/index.ts`, output: { file: pkg.main, format: 'cjs', sourcemap: true }, // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash') - external: ['@contentful/rich-text-types'], + external: Object.keys(pkg.dependencies), watch: { include: ['src/**'], }, diff --git a/packages/rich-text-from-markdown/rollup.config.js b/packages/rich-text-from-markdown/rollup.config.js index 91af6669..c040d03d 100644 --- a/packages/rich-text-from-markdown/rollup.config.js +++ b/packages/rich-text-from-markdown/rollup.config.js @@ -1,4 +1,6 @@ import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; +import { main as outputFile, dependencies } from './package.json'; -export default config(outputFile); +export default config(outputFile, { + external: Object.keys(dependencies), +}); diff --git a/packages/rich-text-html-renderer/package.json b/packages/rich-text-html-renderer/package.json index e6191e9a..9faa9ab8 100644 --- a/packages/rich-text-html-renderer/package.json +++ b/packages/rich-text-html-renderer/package.json @@ -30,8 +30,6 @@ }, "devDependencies": { "@types/escape-html": "^1.0.4", - "@types/lodash.clonedeep": "^4.5.6", - "lodash.clonedeep": "^4.5.0", "ts-jest": "^29.1.2" } } diff --git a/packages/rich-text-html-renderer/rollup.config.js b/packages/rich-text-html-renderer/rollup.config.js index 91af6669..c040d03d 100644 --- a/packages/rich-text-html-renderer/rollup.config.js +++ b/packages/rich-text-html-renderer/rollup.config.js @@ -1,4 +1,6 @@ import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; +import { main as outputFile, dependencies } from './package.json'; -export default config(outputFile); +export default config(outputFile, { + external: Object.keys(dependencies), +}); diff --git a/packages/rich-text-links/rollup.config.js b/packages/rich-text-links/rollup.config.js index 91af6669..c040d03d 100644 --- a/packages/rich-text-links/rollup.config.js +++ b/packages/rich-text-links/rollup.config.js @@ -1,4 +1,6 @@ import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; +import { main as outputFile, dependencies } from './package.json'; -export default config(outputFile); +export default config(outputFile, { + external: Object.keys(dependencies), +}); diff --git a/packages/rich-text-plain-text-renderer/rollup.config.js b/packages/rich-text-plain-text-renderer/rollup.config.js index 91af6669..c040d03d 100644 --- a/packages/rich-text-plain-text-renderer/rollup.config.js +++ b/packages/rich-text-plain-text-renderer/rollup.config.js @@ -1,4 +1,6 @@ import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; +import { main as outputFile, dependencies } from './package.json'; -export default config(outputFile); +export default config(outputFile, { + external: Object.keys(dependencies), +}); diff --git a/packages/rich-text-react-renderer/rollup.config.js b/packages/rich-text-react-renderer/rollup.config.js index fba24bbd..19b2d866 100644 --- a/packages/rich-text-react-renderer/rollup.config.js +++ b/packages/rich-text-react-renderer/rollup.config.js @@ -1,9 +1,9 @@ import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; +import { main as outputFile, dependencies } from './package.json'; const overrides = { input: 'src/index.tsx', - external: ['react'], + external: [...Object.keys(dependencies), 'react'], }; export default config(outputFile, overrides); diff --git a/packages/rich-text-types/package.json b/packages/rich-text-types/package.json index 64d4526d..d2cf5ba6 100644 --- a/packages/rich-text-types/package.json +++ b/packages/rich-text-types/package.json @@ -20,17 +20,16 @@ }, "scripts": { "prebuild": "rimraf dist", - "build": "yarn generate-json-schema && tsc --module commonjs && rollup -c --bundleConfigAsCjs rollup.config.js", + "build": "tsc --module commonjs && rollup -c --bundleConfigAsCjs rollup.config.js", "start": "tsc && rollup -c --bundleConfigAsCjs rollup.config.js -w", - "generate-json-schema": "ts-node -O '{\"module\": \"commonjs\"}' ./tools/jsonSchemaGen", "test": "jest" }, + "dependencies": { + "is-plain-obj": "^3.0.0" + }, "devDependencies": { - "@cspotcode/source-map-consumer": "^0.8.0", - "@faker-js/faker": "^9.0.0", "@types/jest": "^29.5.12", "@types/node": "^22.0.0", - "ts-jest": "^29.1.2", - "typescript-json-schema": "0.65.1" + "ts-jest": "^29.1.2" } } diff --git a/packages/rich-text-types/rollup.config.js b/packages/rich-text-types/rollup.config.js index 9d666172..c040d03d 100644 --- a/packages/rich-text-types/rollup.config.js +++ b/packages/rich-text-types/rollup.config.js @@ -1,32 +1,6 @@ -import copy from 'rollup-plugin-copy'; - import config from '../../rollup.config'; -import { main as outputFile } from './package.json'; - -const customConfig = () => { - const baseConfig = config(outputFile); - - return { - ...baseConfig, - output: { - // Maintain the same file names & folders structure as "src" - // This is necessary to resolve generated JSON schema files - // - // https://rollupjs.org/guide/en/#outputpreservemodules - preserveModules: true, - }, - plugins: [ - ...baseConfig.plugins, - copy({ - targets: [ - { - src: 'src/schemas/generated', - dest: 'dist/schemas', - }, - ], - }), - ], - }; -}; +import { main as outputFile, dependencies } from './package.json'; -export default customConfig(); +export default config(outputFile, { + external: Object.keys(dependencies), +}); diff --git a/packages/rich-text-types/src/__test__/validation.test.ts b/packages/rich-text-types/src/__test__/validation.test.ts new file mode 100644 index 00000000..64e7af2b --- /dev/null +++ b/packages/rich-text-types/src/__test__/validation.test.ts @@ -0,0 +1,1086 @@ +import { BLOCKS } from '../blocks'; +import { INLINES } from '../inlines'; +import type { Document } from '../types'; +import { validateRichTextDocument } from '../validator'; + +describe('validation', () => { + it('fails if it is not document node', () => { + // @ts-expect-error we force a wrong node type to check that it fails + const document: Document = { nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: ['document'], + name: 'in', + path: ['nodeType'], + value: 'paragraph', + }, + ]); + }); + + it('fails if it has an invalid shape', () => { + // @ts-expect-error we force a wrong node type to check that it fails + const document: Document = { nodeType: BLOCKS.DOCUMENT }; + + expect(validateRichTextDocument(document)).toEqual([ + { + name: 'required', + path: ['content'], + details: 'The property "content" is required here', + }, + { + name: 'required', + path: ['data'], + details: 'The property "data" is required here', + }, + ]); + }); + + it('fails if it has nested documents', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ nodeType: BLOCKS.DOCUMENT, content: [], data: {} }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: 'document', + }, + ]); + }); + + it('fails without a nodeType property', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ content: [], data: {} }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: undefined, + }, + ]); + }); + + it('fails on custom nodeTypes (unknown nodeType)', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ nodeType: 'custom-node-type', content: [], data: {} }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: 'custom-node-type', + }, + ]); + }); + + it('fails without a content property', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ nodeType: BLOCKS.PARAGRAPH, data: {} }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "content" is required here', + name: 'required', + path: ['content', 0, 'content'], + value: undefined, + }, + ]); + }); + + it('fails with a invalid content property', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong type to check that it fails + content: [{ nodeType: BLOCKS.PARAGRAPH, content: 'Hello World', data: {} }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "content" is incorrect, expected type: Array', + name: 'type', + path: ['content', 0, 'content'], + type: 'Array', + value: 'Hello World', + }, + ]); + }); + + it('fails without data property', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [] }], + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "data" is required here', + name: 'required', + path: ['data'], + }, + ]); + }); + + it('fails with invalid data property', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: null }], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "data" is incorrect, expected type: Object', + name: 'type', + path: ['content', 0, 'data'], + type: 'Object', + value: null, + }, + ]); + }); + + it('fails if undefined is in the content list', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }, undefined], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "1" is incorrect, expected type: Object', + name: 'type', + path: ['content', 1], + type: 'Object', + value: undefined, + }, + ]); + }); + + it('fails if undefined is in the content list of child nodes', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.UL_LIST, + content: [ + { + nodeType: BLOCKS.LIST_ITEM, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }, undefined], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "1" is incorrect, expected type: Object', + name: 'type', + path: ['content', 0, 'content', 0, 'content', 1], + type: 'Object', + value: undefined, + }, + ]); + }); + + it('fails with unknown properties', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [], + data: {}, + // @ts-expect-error we force a wrong property to check that it fails + myCustomProperty: 'Hello World', + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "myCustomProperty" is not expected', + name: 'unexpected', + path: ['myCustomProperty'], + }, + ]); + }); + + it.each([BLOCKS.LIST_ITEM, BLOCKS.TABLE_ROW, BLOCKS.TABLE_HEADER_CELL, BLOCKS.TABLE_CELL])( + 'fails with a invalid block node as children (nodeType: %s) of the root node', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + // @ts-expect-error we force a wrong node type to check that it fails + nodeType, + content: [], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: nodeType, + }, + ]); + }, + ); + + it.each(Object.values(INLINES))( + 'fails with a inline node (%s) as direct children of the root node', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + // @ts-expect-error we force a wrong node type to check that it fails + nodeType, + content: [], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: nodeType, + }, + ]); + }, + ); + + it('fails with text as a direct children of the root node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + // @ts-expect-error we force a wrong node type to check that it fails + nodeType: 'text', + data: {}, + marks: [], + value: 'Hello World', + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: 'text', + }, + ]); + }); + + it('fails with inline node and text as a direct children of the root node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + // @ts-expect-error we force a wrong node type to check that it fails + nodeType: 'text', + data: {}, + marks: [], + value: 'Hello World', + }, + { + // @ts-expect-error we force a wrong node type to check that it fails + nodeType: INLINES.ASSET_HYPERLINK, + data: { target: {} }, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'table', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'nodeType'], + value: 'text', + }, + ]); + }); + + it.each([BLOCKS.OL_LIST, BLOCKS.UL_LIST] as const)( + 'fails for invalid block nodes inside of (%s)', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: nodeType, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.LIST_ITEM], + name: 'in', + path: ['content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.PARAGRAPH, + }, + ]); + }, + ); + + it('fails on text node directly inside of a list item node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.UL_LIST, + content: [ + { + nodeType: BLOCKS.LIST_ITEM, + content: [ + { + nodeType: 'text', + data: {}, + value: 'Hello World', + marks: [], + }, + ], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'blockquote', + 'embedded-asset-block', + 'embedded-entry-block', + 'embedded-resource-block', + 'heading-1', + 'heading-2', + 'heading-3', + 'heading-4', + 'heading-5', + 'heading-6', + 'hr', + 'ordered-list', + 'paragraph', + 'unordered-list', + ], + name: 'in', + path: ['content', 0, 'content', 0, 'content', 0, 'nodeType'], + value: 'text', + }, + ]); + }); + + it('fails on invalid block nodes inside of a table node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.TABLE_ROW], + name: 'in', + path: ['content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.PARAGRAPH, + }, + ]); + }); + + it('fails on invalid block nodes inside of a table row node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL], + name: 'in', + path: ['content', 0, 'content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.PARAGRAPH, + }, + ]); + }); + + it('fails on invalid block nodes inside of a table header node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL], + name: 'in', + path: ['content', 0, 'content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.PARAGRAPH, + }, + ]); + }); + + it.each([BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL] as const)( + 'fails on invalid node inside of %s', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [ + { + nodeType, + content: [{ nodeType: 'text', data: {}, marks: [], value: 'Hello World' }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.PARAGRAPH], + name: 'in', + path: ['content', 0, 'content', 0, 'content', 0, 'content', 0, 'nodeType'], + value: 'text', + }, + ]); + }, + ); + + it('fails if a table node has not at least one table row', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Size must be at least 1', + min: 1, + name: 'size', + path: ['content', 0, 'content'], + value: [], + }, + ]); + }); + + it('fails if a table row node has not at least one table cell', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Size must be at least 1', + min: 1, + name: 'size', + path: ['content', 0, 'content', 0, 'content'], + value: [], + }, + ]); + }); + + it.each([BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL] as const)( + 'fails if a %s has not at least one child', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [ + { + nodeType, + content: [], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Size must be at least 1', + min: 1, + name: 'size', + path: ['content', 0, 'content', 0, 'content', 0, 'content'], + value: [], + }, + ]); + }, + ); + + it('fails if inline nodes contains something else as a inline node or text', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [ + { + nodeType: INLINES.HYPERLINK, + // @ts-expect-error we force a wrong node type to check that it fails + content: [{ nodeType: BLOCKS.PARAGRAPH, content: [], data: {} }], + data: { uri: '' }, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: ['text'], + name: 'in', + path: ['content', 0, 'content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.PARAGRAPH, + }, + ]); + }); + + it.each([ + BLOCKS.HEADING_1, + BLOCKS.HEADING_2, + BLOCKS.HEADING_3, + BLOCKS.HEADING_4, + BLOCKS.HEADING_5, + BLOCKS.HEADING_6, + ] as const)( + 'fails if the headline node (%s) contains something else as a inline or text node', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType, + content: [ + { + nodeType: BLOCKS.QUOTE, + content: [{ nodeType: 'text', value: 'Hello World', data: {}, marks: [] }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [ + 'asset-hyperlink', + 'embedded-entry-inline', + 'embedded-resource-inline', + 'entry-hyperlink', + 'hyperlink', + 'resource-hyperlink', + 'text', + ], + name: 'in', + path: ['content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.QUOTE, + }, + ]); + }, + ); + + it('fails on invalid block nodes inside of a quote node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.QUOTE, + content: [ + { + nodeType: BLOCKS.HEADING_1, + content: [{ nodeType: 'text', value: 'Hello World', data: {}, marks: [] }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'Value must be one of expected values', + expected: [BLOCKS.PARAGRAPH], + name: 'in', + path: ['content', 0, 'content', 0, 'nodeType'], + value: BLOCKS.HEADING_1, + }, + ]); + }); + + it('fails without value property on text nodes', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [ + { + nodeType: 'text', + value: null, + data: {}, + marks: [], + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "value" is incorrect, expected type: String', + name: 'type', + path: ['content', 0, 'content', 0, 'value'], + type: 'String', + value: null, + }, + ]); + }); + + it('fails with invalid row/colspan on table cell nodes', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [ + { + nodeType: BLOCKS.TABLE_CELL, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [{ nodeType: 'text', value: 'Hello Table', data: {}, marks: [] }], + data: {}, + }, + ], + data: { rowspan: 'argh' }, + }, + ], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The type of "rowspan" is incorrect, expected type: Number', + name: 'type', + path: ['content', 0, 'content', 0, 'content', 0, 'data', 'rowspan'], + type: 'Number', + value: 'argh', + }, + ]); + }); + + it.each([INLINES.ASSET_HYPERLINK, INLINES.ENTRY_HYPERLINK, INLINES.RESOURCE_HYPERLINK] as const)( + 'fails with invalid properties for %s', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [ + { + nodeType, + data: {}, + content: [{ nodeType: 'text', value: `Hello ${nodeType}`, data: {}, marks: [] }], + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "target" is required here', + name: 'required', + path: ['content', 0, 'content', 0, 'data', 'target'], + }, + ]); + }, + ); + + it('fails with invalid properties for hypperlink node', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [ + { + nodeType: INLINES.HYPERLINK, + data: {}, + content: [{ nodeType: 'text', value: 'Hello hyperlink', data: {}, marks: [] }], + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "uri" is required here', + name: 'required', + path: ['content', 0, 'content', 0, 'data', 'uri'], + }, + ]); + }); + + it.each([INLINES.EMBEDDED_ENTRY, INLINES.EMBEDDED_RESOURCE] as const)( + 'fails with invalid properties for %s', + (nodeType) => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [ + { + nodeType, + data: {}, + content: [], + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([ + { + details: 'The property "target" is required here', + name: 'required', + path: ['content', 0, 'content', 0, 'data', 'target'], + }, + ]); + }, + ); + + it('succeeds with a valid structure', () => { + const document: Document = { + nodeType: BLOCKS.DOCUMENT, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [{ nodeType: 'text', value: 'Hello World', data: {}, marks: [] }], + data: {}, + }, + { + nodeType: BLOCKS.HEADING_1, + content: [{ nodeType: 'text', value: 'Hello Headline', data: {}, marks: [] }], + data: {}, + }, + { + nodeType: BLOCKS.UL_LIST, + content: [ + { + nodeType: BLOCKS.LIST_ITEM, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [{ nodeType: 'text', value: 'Hello List', data: {}, marks: [] }], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }, + { + nodeType: BLOCKS.TABLE, + content: [ + { + nodeType: BLOCKS.TABLE_ROW, + content: [ + { + nodeType: BLOCKS.TABLE_CELL, + content: [ + { + nodeType: BLOCKS.PARAGRAPH, + content: [{ nodeType: 'text', value: 'Hello Table', data: {}, marks: [] }], + data: {}, + }, + ], + data: { rowspan: 2, colspan: 2 }, + }, + ], + data: {}, + }, + ], + data: {}, + }, + ], + data: {}, + }; + + expect(validateRichTextDocument(document)).toEqual([]); + }); +}); diff --git a/packages/rich-text-types/src/index.ts b/packages/rich-text-types/src/index.ts index d5e78f31..7ebaa1d0 100644 --- a/packages/rich-text-types/src/index.ts +++ b/packages/rich-text-types/src/index.ts @@ -12,4 +12,5 @@ export { EMPTY_DOCUMENT } from './emptyDocument'; import * as helpers from './helpers'; export { helpers }; -export { getSchemaWithNodeType } from './schemas'; +export { validateRichTextDocument } from './validator'; +export type { ValidationError } from './validator'; diff --git a/packages/rich-text-types/src/schemas/__test__/__snapshots__/schemas.test.ts.snap b/packages/rich-text-types/src/schemas/__test__/__snapshots__/schemas.test.ts.snap deleted file mode 100644 index 8245aaab..00000000 --- a/packages/rich-text-types/src/schemas/__test__/__snapshots__/schemas.test.ts.snap +++ /dev/null @@ -1,4256 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getSchemaWithNodeType returns json schema for each nodeType: asset-hyperlink 1`] = ` -{ - "$ref": "#/definitions/AssetHyperlink", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AssetHyperlink": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/Link<"Asset">", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "asset-hyperlink", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Link<"Asset">": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - }, - "linkType": { - "enum": [ - "Asset", - ], - "type": "string", - }, - "type": { - "enum": [ - "Link", - ], - "type": "string", - }, - }, - "required": [ - "id", - "linkType", - "type", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: blockquote 1`] = ` -{ - "$ref": "#/definitions/Quote", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Quote": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Paragraph", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "blockquote", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: document 1`] = ` -{ - "$ref": "#/definitions/Document", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - "Block": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/BLOCKS", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Document": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/TopLevelBlock", - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "enum": [ - "document", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - "TopLevelBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/TopLevelBlockEnum", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TopLevelBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "table", - "unordered-list", - ], - "type": "string", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: embedded-asset-block 1`] = ` -{ - "$ref": "#/definitions/AssetLinkBlock", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AssetLinkBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "maxItems": 0, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/Link<"Asset">", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "embedded-asset-block", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Link<"Asset">": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - }, - "linkType": { - "enum": [ - "Asset", - ], - "type": "string", - }, - "type": { - "enum": [ - "Link", - ], - "type": "string", - }, - }, - "required": [ - "id", - "linkType", - "type", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: embedded-entry-block 1`] = ` -{ - "$ref": "#/definitions/EntryLinkBlock", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "EntryLinkBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "maxItems": 0, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/Link<"Entry">", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "embedded-entry-block", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Link<"Entry">": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - }, - "linkType": { - "enum": [ - "Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "Link", - ], - "type": "string", - }, - }, - "required": [ - "id", - "linkType", - "type", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: embedded-entry-inline 1`] = ` -{ - "$ref": "#/definitions/EntryLinkInline", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "EntryLinkInline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "maxItems": 0, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/Link<"Entry">", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "embedded-entry-inline", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Link<"Entry">": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - }, - "linkType": { - "enum": [ - "Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "Link", - ], - "type": "string", - }, - }, - "required": [ - "id", - "linkType", - "type", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: embedded-resource-block 1`] = ` -{ - "$ref": "#/definitions/ResourceLinkBlock", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "ResourceLink": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "linkType": { - "enum": [ - "Contentful:Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "ResourceLink", - ], - "type": "string", - }, - "urn": { - "type": "string", - }, - }, - "required": [ - "linkType", - "type", - "urn", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "ResourceLinkBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "maxItems": 0, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "embedded-resource-block", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: embedded-resource-inline 1`] = ` -{ - "$ref": "#/definitions/ResourceLinkInline", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "ResourceLink": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "linkType": { - "enum": [ - "Contentful:Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "ResourceLink", - ], - "type": "string", - }, - "urn": { - "type": "string", - }, - }, - "required": [ - "linkType", - "type", - "urn", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "ResourceLinkInline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "maxItems": 0, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "embedded-resource-inline", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: entry-hyperlink 1`] = ` -{ - "$ref": "#/definitions/EntryHyperlink", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "EntryHyperlink": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/Link<"Entry">", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "entry-hyperlink", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Link<"Entry">": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - }, - "linkType": { - "enum": [ - "Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "Link", - ], - "type": "string", - }, - }, - "required": [ - "id", - "linkType", - "type", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-1 1`] = ` -{ - "$ref": "#/definitions/Heading1", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading1": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-1", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-2 1`] = ` -{ - "$ref": "#/definitions/Heading2", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading2": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-2", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-3 1`] = ` -{ - "$ref": "#/definitions/Heading3", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading3": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-3", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-4 1`] = ` -{ - "$ref": "#/definitions/Heading4", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading4": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-4", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-5 1`] = ` -{ - "$ref": "#/definitions/Heading5", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading5": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-5", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: heading-6 1`] = ` -{ - "$ref": "#/definitions/Heading6", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Heading6": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "heading-6", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: hr 1`] = ` -{ - "$ref": "#/definitions/Hr", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Hr": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "maxItems": 0, - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "hr", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: hyperlink 1`] = ` -{ - "$ref": "#/definitions/Hyperlink", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Hyperlink": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "uri": { - "type": "string", - }, - }, - "required": [ - "uri", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "hyperlink", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: list-item 1`] = ` -{ - "$ref": "#/definitions/ListItem", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - "Block": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/BLOCKS", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItem": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/ListItemBlock", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "list-item", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list", - ], - "type": "string", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: ordered-list 1`] = ` -{ - "$ref": "#/definitions/OrderedList", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - "Block": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/BLOCKS", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItem": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/ListItemBlock", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "list-item", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list", - ], - "type": "string", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "OrderedList": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/ListItem", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "ordered-list", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: paragraph 1`] = ` -{ - "$ref": "#/definitions/Paragraph", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: resource-hyperlink 1`] = ` -{ - "$ref": "#/definitions/ResourceHyperlink", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "ResourceHyperlink": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Text", - }, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink", - }, - }, - "required": [ - "target", - ], - "type": "object", - }, - "nodeType": { - "enum": [ - "resource-hyperlink", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ResourceLink": { - "additionalProperties": false, - "properties": { - "sys": { - "additionalProperties": false, - "properties": { - "linkType": { - "enum": [ - "Contentful:Entry", - ], - "type": "string", - }, - "type": { - "enum": [ - "ResourceLink", - ], - "type": "string", - }, - "urn": { - "type": "string", - }, - }, - "required": [ - "linkType", - "type", - "urn", - ], - "type": "object", - }, - }, - "required": [ - "sys", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: table 1`] = ` -{ - "$ref": "#/definitions/Table", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Table": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/TableRow", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "table", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableCell": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Paragraph", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "colspan": { - "type": "number", - }, - "rowspan": { - "type": "number", - }, - }, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableRow": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/TableCell", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-row", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: table-cell 1`] = ` -{ - "$ref": "#/definitions/TableCell", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableCell": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Paragraph", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "colspan": { - "type": "number", - }, - "rowspan": { - "type": "number", - }, - }, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: table-header-cell 1`] = ` -{ - "$ref": "#/definitions/TableHeaderCell", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableHeaderCell": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Paragraph", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "colspan": { - "type": "number", - }, - "rowspan": { - "type": "number", - }, - }, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-header-cell", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: table-row 1`] = ` -{ - "$ref": "#/definitions/TableRow", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Paragraph": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "paragraph", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableCell": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/Paragraph", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "additionalProperties": false, - "properties": { - "colspan": { - "type": "number", - }, - "rowspan": { - "type": "number", - }, - }, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "TableRow": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/TableCell", - }, - "minItems": 1, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "table-row", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: text 1`] = ` -{ - "$ref": "#/definitions/Text", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType returns json schema for each nodeType: unordered-list 1`] = ` -{ - "$ref": "#/definitions/UnorderedList", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell", - ], - "type": "string", - }, - "Block": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/BLOCKS", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink", - ], - "type": "string", - }, - "Inline": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/INLINES", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItem": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/ListItemBlock", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "list-item", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlock": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block", - }, - { - "$ref": "#/definitions/Inline", - }, - { - "$ref": "#/definitions/Text", - }, - ], - }, - "type": "array", - }, - "data": { - "$ref": "#/definitions/NodeData", - }, - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list", - ], - "type": "string", - }, - "Mark": { - "additionalProperties": false, - "properties": { - "type": { - "type": "string", - }, - }, - "required": [ - "type", - ], - "type": "object", - }, - "NodeData": { - "additionalProperties": true, - "type": "object", - }, - "Text": { - "additionalProperties": false, - "properties": { - "data": { - "$ref": "#/definitions/NodeData", - }, - "marks": { - "items": { - "$ref": "#/definitions/Mark", - }, - "type": "array", - }, - "nodeType": { - "enum": [ - "text", - ], - "type": "string", - }, - "value": { - "type": "string", - }, - }, - "required": [ - "data", - "marks", - "nodeType", - "value", - ], - "type": "object", - }, - "UnorderedList": { - "additionalProperties": false, - "properties": { - "content": { - "items": { - "$ref": "#/definitions/ListItem", - }, - "type": "array", - }, - "data": { - "properties": {}, - "type": "object", - }, - "nodeType": { - "enum": [ - "unordered-list", - ], - "type": "string", - }, - }, - "required": [ - "content", - "data", - "nodeType", - ], - "type": "object", - }, - }, -} -`; - -exports[`getSchemaWithNodeType throws error if no schema found 1`] = `"Schema for nodeType "unknown-node-type" was not found."`; diff --git a/packages/rich-text-types/src/schemas/__test__/helpers.test.ts b/packages/rich-text-types/src/schemas/__test__/helpers.test.ts deleted file mode 100644 index 7dd6da86..00000000 --- a/packages/rich-text-types/src/schemas/__test__/helpers.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { BLOCKS } from '../../blocks'; -import { isBlock, isInline } from '../../helpers'; -import { INLINES } from '../../inlines'; - -test('isBlock', () => { - const block: any = { nodeType: BLOCKS.PARAGRAPH }; - const nonBlock: any = { nodeType: 'Paragraph' }; - const nonBlock2: any = { nodeType: undefined }; - - expect(isBlock(block)).toBe(true); - expect(isBlock(nonBlock)).toBe(false); - expect(isBlock(nonBlock2)).toBe(false); -}); - -test('isInline', () => { - const inline: any = { nodeType: INLINES.HYPERLINK }; - const noninline: any = { nodeType: 'Hyperlink' }; - const noninline2: any = { nodeType: undefined }; - - expect(isInline(inline)).toBe(true); - expect(isInline(noninline)).toBe(false); - expect(isInline(noninline2)).toBe(false); -}); diff --git a/packages/rich-text-types/src/schemas/__test__/schemas.test.ts b/packages/rich-text-types/src/schemas/__test__/schemas.test.ts deleted file mode 100644 index 5d41b92b..00000000 --- a/packages/rich-text-types/src/schemas/__test__/schemas.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { BLOCKS } from '../../blocks'; -import { INLINES } from '../../inlines'; -import { getSchemaWithNodeType } from '../index'; - -const matchesSnapshot = (nodeType: string): void => { - const jsonSchema = getSchemaWithNodeType(nodeType); - - expect(jsonSchema).toMatchSnapshot(nodeType); -}; - -describe('getSchemaWithNodeType', () => { - it('returns json schema for each nodeType', () => { - Object.values(INLINES).forEach((nodeType) => { - matchesSnapshot(nodeType); - }); - Object.values(BLOCKS).forEach((nodeType) => { - matchesSnapshot(nodeType); - }); - - matchesSnapshot('text'); - }); - - it('throws error if no schema found', () => { - expect(() => getSchemaWithNodeType('unknown-node-type')).toThrowErrorMatchingSnapshot(); - }); -}); diff --git a/packages/rich-text-types/src/schemas/generated/asset-hyperlink.json b/packages/rich-text-types/src/schemas/generated/asset-hyperlink.json deleted file mode 100644 index c44085c8..00000000 --- a/packages/rich-text-types/src/schemas/generated/asset-hyperlink.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "$ref": "#/definitions/AssetHyperlink", - "definitions": { - "AssetHyperlink": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "asset-hyperlink" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/Link<\"Asset\">" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Link<\"Asset\">": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "Link" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Asset" - ] - }, - "id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id", - "linkType", - "type" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/blockquote.json b/packages/rich-text-types/src/schemas/generated/blockquote.json deleted file mode 100644 index 82250159..00000000 --- a/packages/rich-text-types/src/schemas/generated/blockquote.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "$ref": "#/definitions/Quote", - "definitions": { - "Quote": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "blockquote" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/Paragraph" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/document.json b/packages/rich-text-types/src/schemas/generated/document.json deleted file mode 100644 index 3420ca00..00000000 --- a/packages/rich-text-types/src/schemas/generated/document.json +++ /dev/null @@ -1,232 +0,0 @@ -{ - "$ref": "#/definitions/Document", - "definitions": { - "Document": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "document" - ] - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/TopLevelBlock" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "TopLevelBlock": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/TopLevelBlockEnum" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "TopLevelBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "table", - "unordered-list" - ], - "type": "string" - }, - "Block": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/BLOCKS" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "type": "string", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/embedded-asset-block.json b/packages/rich-text-types/src/schemas/generated/embedded-asset-block.json deleted file mode 100644 index 3c53e9fb..00000000 --- a/packages/rich-text-types/src/schemas/generated/embedded-asset-block.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "$ref": "#/definitions/AssetLinkBlock", - "definitions": { - "AssetLinkBlock": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "embedded-asset-block" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/Link<\"Asset\">" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "maxItems": 0, - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Link<\"Asset\">": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "Link" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Asset" - ] - }, - "id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id", - "linkType", - "type" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/embedded-entry-block.json b/packages/rich-text-types/src/schemas/generated/embedded-entry-block.json deleted file mode 100644 index a1314fd3..00000000 --- a/packages/rich-text-types/src/schemas/generated/embedded-entry-block.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "$ref": "#/definitions/EntryLinkBlock", - "definitions": { - "EntryLinkBlock": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "embedded-entry-block" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/Link<\"Entry\">" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "maxItems": 0, - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Link<\"Entry\">": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "Link" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Entry" - ] - }, - "id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id", - "linkType", - "type" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/embedded-entry-inline.json b/packages/rich-text-types/src/schemas/generated/embedded-entry-inline.json deleted file mode 100644 index 4bd5cb15..00000000 --- a/packages/rich-text-types/src/schemas/generated/embedded-entry-inline.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "$ref": "#/definitions/EntryLinkInline", - "definitions": { - "EntryLinkInline": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "embedded-entry-inline" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/Link<\"Entry\">" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "maxItems": 0, - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Link<\"Entry\">": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "Link" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Entry" - ] - }, - "id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id", - "linkType", - "type" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/embedded-resource-block.json b/packages/rich-text-types/src/schemas/generated/embedded-resource-block.json deleted file mode 100644 index c2d4bd71..00000000 --- a/packages/rich-text-types/src/schemas/generated/embedded-resource-block.json +++ /dev/null @@ -1,172 +0,0 @@ -{ - "$ref": "#/definitions/ResourceLinkBlock", - "definitions": { - "ResourceLinkBlock": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "embedded-resource-block" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "maxItems": 0, - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ResourceLink": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "ResourceLink" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Contentful:Entry" - ] - }, - "urn": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "linkType", - "type", - "urn" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/embedded-resource-inline.json b/packages/rich-text-types/src/schemas/generated/embedded-resource-inline.json deleted file mode 100644 index 2ea02573..00000000 --- a/packages/rich-text-types/src/schemas/generated/embedded-resource-inline.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "$ref": "#/definitions/ResourceLinkInline", - "definitions": { - "ResourceLinkInline": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "embedded-resource-inline" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "maxItems": 0, - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ResourceLink": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "ResourceLink" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Contentful:Entry" - ] - }, - "urn": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "linkType", - "type", - "urn" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/entry-hyperlink.json b/packages/rich-text-types/src/schemas/generated/entry-hyperlink.json deleted file mode 100644 index 61912e68..00000000 --- a/packages/rich-text-types/src/schemas/generated/entry-hyperlink.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "$ref": "#/definitions/EntryHyperlink", - "definitions": { - "EntryHyperlink": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "entry-hyperlink" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/Link<\"Entry\">" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Link<\"Entry\">": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "Link" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Entry" - ] - }, - "id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id", - "linkType", - "type" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-1.json b/packages/rich-text-types/src/schemas/generated/heading-1.json deleted file mode 100644 index 9291d03b..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-1.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading1", - "definitions": { - "Heading1": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-1" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-2.json b/packages/rich-text-types/src/schemas/generated/heading-2.json deleted file mode 100644 index 2673f270..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-2.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading2", - "definitions": { - "Heading2": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-2" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-3.json b/packages/rich-text-types/src/schemas/generated/heading-3.json deleted file mode 100644 index 357fcf6f..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-3.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading3", - "definitions": { - "Heading3": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-3" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-4.json b/packages/rich-text-types/src/schemas/generated/heading-4.json deleted file mode 100644 index ff877733..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-4.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading4", - "definitions": { - "Heading4": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-4" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-5.json b/packages/rich-text-types/src/schemas/generated/heading-5.json deleted file mode 100644 index 6f45986a..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-5.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading5", - "definitions": { - "Heading5": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-5" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/heading-6.json b/packages/rich-text-types/src/schemas/generated/heading-6.json deleted file mode 100644 index 97b97392..00000000 --- a/packages/rich-text-types/src/schemas/generated/heading-6.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Heading6", - "definitions": { - "Heading6": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "heading-6" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/hr.json b/packages/rich-text-types/src/schemas/generated/hr.json deleted file mode 100644 index f7d3a65e..00000000 --- a/packages/rich-text-types/src/schemas/generated/hr.json +++ /dev/null @@ -1,129 +0,0 @@ -{ - "$ref": "#/definitions/Hr", - "definitions": { - "Hr": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "hr" - ] - }, - "data": { - "maxItems": 0, - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/hyperlink.json b/packages/rich-text-types/src/schemas/generated/hyperlink.json deleted file mode 100644 index eead7982..00000000 --- a/packages/rich-text-types/src/schemas/generated/hyperlink.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "$ref": "#/definitions/Hyperlink", - "definitions": { - "Hyperlink": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "hyperlink" - ] - }, - "data": { - "type": "object", - "properties": { - "uri": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "uri" - ] - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/list-item.json b/packages/rich-text-types/src/schemas/generated/list-item.json deleted file mode 100644 index f07c1a1c..00000000 --- a/packages/rich-text-types/src/schemas/generated/list-item.json +++ /dev/null @@ -1,232 +0,0 @@ -{ - "$ref": "#/definitions/ListItem", - "definitions": { - "ListItem": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "list-item" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/ListItemBlock" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlock": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list" - ], - "type": "string" - }, - "Block": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/BLOCKS" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "type": "string", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/ordered-list.json b/packages/rich-text-types/src/schemas/generated/ordered-list.json deleted file mode 100644 index 488f86eb..00000000 --- a/packages/rich-text-types/src/schemas/generated/ordered-list.json +++ /dev/null @@ -1,259 +0,0 @@ -{ - "$ref": "#/definitions/OrderedList", - "definitions": { - "OrderedList": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "ordered-list" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/ListItem" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItem": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "list-item" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/ListItemBlock" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlock": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list" - ], - "type": "string" - }, - "Block": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/BLOCKS" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "type": "string", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/paragraph.json b/packages/rich-text-types/src/schemas/generated/paragraph.json deleted file mode 100644 index ffdf3aec..00000000 --- a/packages/rich-text-types/src/schemas/generated/paragraph.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "$ref": "#/definitions/Paragraph", - "definitions": { - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/resource-hyperlink.json b/packages/rich-text-types/src/schemas/generated/resource-hyperlink.json deleted file mode 100644 index 6f3b11bd..00000000 --- a/packages/rich-text-types/src/schemas/generated/resource-hyperlink.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "$ref": "#/definitions/ResourceHyperlink", - "definitions": { - "ResourceHyperlink": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "resource-hyperlink" - ] - }, - "data": { - "type": "object", - "properties": { - "target": { - "$ref": "#/definitions/ResourceLink" - } - }, - "additionalProperties": false, - "required": [ - "target" - ] - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/Text" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ResourceLink": { - "type": "object", - "properties": { - "sys": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "ResourceLink" - ] - }, - "linkType": { - "type": "string", - "enum": [ - "Contentful:Entry" - ] - }, - "urn": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "linkType", - "type", - "urn" - ] - } - }, - "additionalProperties": false, - "required": [ - "sys" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/table-cell.json b/packages/rich-text-types/src/schemas/generated/table-cell.json deleted file mode 100644 index c58070e5..00000000 --- a/packages/rich-text-types/src/schemas/generated/table-cell.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "$ref": "#/definitions/TableCell", - "definitions": { - "TableCell": { - "type": "object", - "properties": { - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell" - ], - "type": "string" - }, - "data": { - "type": "object", - "properties": { - "colspan": { - "type": "number" - }, - "rowspan": { - "type": "number" - } - }, - "additionalProperties": false - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/Paragraph" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/table-header-cell.json b/packages/rich-text-types/src/schemas/generated/table-header-cell.json deleted file mode 100644 index 8151797a..00000000 --- a/packages/rich-text-types/src/schemas/generated/table-header-cell.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "$ref": "#/definitions/TableHeaderCell", - "definitions": { - "TableHeaderCell": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "table-header-cell" - ] - }, - "data": { - "type": "object", - "properties": { - "colspan": { - "type": "number" - }, - "rowspan": { - "type": "number" - } - }, - "additionalProperties": false - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/Paragraph" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/table-row.json b/packages/rich-text-types/src/schemas/generated/table-row.json deleted file mode 100644 index 98f27854..00000000 --- a/packages/rich-text-types/src/schemas/generated/table-row.json +++ /dev/null @@ -1,193 +0,0 @@ -{ - "$ref": "#/definitions/TableRow", - "definitions": { - "TableRow": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "table-row" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/TableCell" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "TableCell": { - "type": "object", - "properties": { - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell" - ], - "type": "string" - }, - "data": { - "type": "object", - "properties": { - "colspan": { - "type": "number" - }, - "rowspan": { - "type": "number" - } - }, - "additionalProperties": false - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/Paragraph" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/table.json b/packages/rich-text-types/src/schemas/generated/table.json deleted file mode 100644 index 9fa8def8..00000000 --- a/packages/rich-text-types/src/schemas/generated/table.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "$ref": "#/definitions/Table", - "definitions": { - "Table": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "table" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/TableRow" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "TableRow": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "table-row" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/TableCell" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "TableCell": { - "type": "object", - "properties": { - "nodeType": { - "enum": [ - "table-cell", - "table-header-cell" - ], - "type": "string" - }, - "data": { - "type": "object", - "properties": { - "colspan": { - "type": "number" - }, - "rowspan": { - "type": "number" - } - }, - "additionalProperties": false - }, - "content": { - "minItems": 1, - "type": "array", - "items": { - "$ref": "#/definitions/Paragraph" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Paragraph": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "paragraph" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/text.json b/packages/rich-text-types/src/schemas/generated/text.json deleted file mode 100644 index 8b57bf0d..00000000 --- a/packages/rich-text-types/src/schemas/generated/text.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "$ref": "#/definitions/Text", - "definitions": { - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/generated/unordered-list.json b/packages/rich-text-types/src/schemas/generated/unordered-list.json deleted file mode 100644 index 959fe0fa..00000000 --- a/packages/rich-text-types/src/schemas/generated/unordered-list.json +++ /dev/null @@ -1,259 +0,0 @@ -{ - "$ref": "#/definitions/UnorderedList", - "definitions": { - "UnorderedList": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "unordered-list" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/ListItem" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItem": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "list-item" - ] - }, - "data": { - "type": "object", - "properties": {} - }, - "content": { - "type": "array", - "items": { - "$ref": "#/definitions/ListItemBlock" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlock": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/ListItemBlockEnum" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "ListItemBlockEnum": { - "enum": [ - "blockquote", - "embedded-asset-block", - "embedded-entry-block", - "embedded-resource-block", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "hr", - "ordered-list", - "paragraph", - "unordered-list" - ], - "type": "string" - }, - "Block": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/BLOCKS" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Block" - }, - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "BLOCKS": { - "description": "Map of all Contentful block types. Blocks contain inline or block nodes.", - "type": "string", - "enum": [ - "document", - "paragraph", - "heading-1", - "heading-2", - "heading-3", - "heading-4", - "heading-5", - "heading-6", - "ordered-list", - "unordered-list", - "list-item", - "hr", - "blockquote", - "embedded-entry-block", - "embedded-asset-block", - "embedded-resource-block", - "table", - "table-row", - "table-cell", - "table-header-cell" - ] - }, - "Inline": { - "type": "object", - "properties": { - "nodeType": { - "$ref": "#/definitions/INLINES" - }, - "content": { - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/Inline" - }, - { - "$ref": "#/definitions/Text" - } - ] - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "content", - "data", - "nodeType" - ] - }, - "INLINES": { - "description": "Map of all Contentful inline types. Inline contain inline or text nodes.", - "type": "string", - "enum": [ - "asset-hyperlink", - "embedded-entry-inline", - "embedded-resource-inline", - "entry-hyperlink", - "hyperlink", - "resource-hyperlink" - ] - }, - "Text": { - "type": "object", - "properties": { - "nodeType": { - "type": "string", - "enum": [ - "text" - ] - }, - "value": { - "type": "string" - }, - "marks": { - "type": "array", - "items": { - "$ref": "#/definitions/Mark" - } - }, - "data": { - "$ref": "#/definitions/NodeData" - } - }, - "additionalProperties": false, - "required": [ - "data", - "marks", - "nodeType", - "value" - ] - }, - "Mark": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "type" - ] - }, - "NodeData": { - "additionalProperties": true, - "type": "object" - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/rich-text-types/src/schemas/index.ts b/packages/rich-text-types/src/schemas/index.ts deleted file mode 100644 index 4ab086fa..00000000 --- a/packages/rich-text-types/src/schemas/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -export declare type PrimitiveType = number | boolean | string | null; -export declare type Definition = { - $ref?: string; - $schema?: string; - $id?: string; - description?: string; - allOf?: Definition[]; - oneOf?: Definition[]; - anyOf?: Definition[]; - title?: string; - type?: string | string[]; - definitions?: { - [key: string]: any; - }; - format?: string; - items?: Definition | Definition[]; - minItems?: number; - additionalItems?: - | { - anyOf: Definition[]; - } - | Definition; - enum?: PrimitiveType[] | Definition[]; - default?: PrimitiveType | Record; - additionalProperties?: Definition | boolean; - required?: string[]; - propertyOrder?: string[]; - properties?: { - [key: string]: any; - }; - defaultProperties?: string[]; - patternProperties?: { - [pattern: string]: Definition; - }; - typeof?: 'function'; -}; - -export function getSchemaWithNodeType(nodeType: string): Definition { - try { - return require(`./generated/${nodeType}.json`); - } catch (error) { - throw new Error(`Schema for nodeType "${nodeType}" was not found.`); - } -} diff --git a/packages/rich-text-types/src/validator/assert.ts b/packages/rich-text-types/src/validator/assert.ts new file mode 100644 index 00000000..5caf6b5c --- /dev/null +++ b/packages/rich-text-types/src/validator/assert.ts @@ -0,0 +1,296 @@ +import isPlainObject from 'is-plain-obj'; + +import { ValidationError } from '.'; +import { + maxSizeError, + typeMismatchError, + enumError, + unknownPropertyError, + requiredPropertyError, + minSizeError, +} from './errors'; +import type { Path } from './path'; + +export class ObjectAssertion { + private _errors: ValidationError[] = []; + + constructor( + private readonly obj: Record, + private readonly path: Path, + ) {} + + catch = (...errors: ValidationError[]): void => { + this._errors.push(...errors); + }; + + get errors(): ValidationError[] { + const serializeError = (error: ValidationError): string => + JSON.stringify({ + details: error.details, + path: error.path, + }); + + return this._errors.filter( + (error, index) => + this._errors.findIndex((step) => serializeError(error) === serializeError(step)) === index, + ); + } + + /** + * Asserts the key exists in the object. You probably shouldn't call this + * function directly. Instead, use `$.object`, `$.number`, `$.string`, etc. + */ + exists = (key: string): boolean => { + if (key in this.obj) { + return true; + } + + this.catch( + requiredPropertyError({ + property: key, + path: this.path.of(key), + }), + ); + + return false; + }; + + /** + * Asserts the key exists in the object and its value is a plain object. if + * no key is provided, it asserts the object itself. + */ + public object = (key?: string): boolean => { + const value = key ? this.obj[key] : this.obj; + + if (key) { + if (!this.exists(key)) { + return false; + } + } + + if (isPlainObject(value)) { + return true; + } + + const path = key ? this.path.of(key) : this.path; + const property = key ?? this.path.last() ?? 'value'; + + this.catch( + typeMismatchError({ + typeName: 'Object', + property, + path, + value, + }), + ); + + return false; + }; + + /** + * Asserts the key exists in the object and its value is a string. + */ + public string = (key: string): boolean => { + const value = this.obj[key]; + + if (key && !this.exists(key)) { + return false; + } + + if (typeof value === 'string') { + return true; + } + + this.catch( + typeMismatchError({ + typeName: 'String', + property: key, + path: this.path.of(key), + value, + }), + ); + + return false; + }; + + /** + * Asserts the key exists in the object and its value is a number. + */ + public number = (key: string, optional?: boolean): boolean => { + const value = this.obj[key]; + + if (optional && !(key in this.obj)) { + return true; + } + + if (!this.exists(key)) { + return false; + } + + if (typeof value === 'number' && !Number.isNaN(value)) { + return true; + } + + this.catch( + typeMismatchError({ + typeName: 'Number', + property: key, + path: this.path.of(key), + value, + }), + ); + + return false; + }; + + /** + * Asserts the key exists in the object and its value is an array. You don't + * need to manually call this function before `$.each` or `$.maxLength`. + */ + public array = (key: string): boolean => { + const value = this.obj[key]; + + if (key && !this.exists(key)) { + return false; + } + + if (Array.isArray(value)) { + return true; + } + + this.catch( + typeMismatchError({ + typeName: 'Array', + property: key, + path: this.path.of(key), + value, + }), + ); + + return false; + }; + + /** + * Asserts the value of the key is one of the expected values. + */ + public enum = (key: string, expected: string[]): boolean => { + const value = this.obj[key]; + + if (typeof value === 'string' && expected.includes(value)) { + return true; + } + + this.catch( + enumError({ + expected, + value, + path: this.path.of(key), + }), + ); + + return false; + }; + + /** + * Asserts the array value of the object key is empty. If the value isn't an + * array, the function captures a type error and returns false. + */ + public empty = (key: string): boolean => { + if (!this.array(key)) { + return false; + } + + const value = this.obj[key] as Array; + + if (value.length === 0) { + return true; + } + + this.catch( + maxSizeError({ + max: 0, + value, + path: this.path.of(key), + }), + ); + + return false; + }; + + /** + * Asserts the length of the value of the object key is at least `min`. If the + * value isn't an array, the function captures a type error and returns false. + */ + public minLength = (key: string, min: number): boolean => { + if (!this.array(key)) { + return false; + } + + const value = this.obj[key] as Array; + + if (value.length >= min) { + return true; + } + + this.catch( + minSizeError({ + min, + value, + path: this.path.of(key), + }), + ); + + return false; + }; + + /** + * Asserts the object has no additional properties other than the ones + * specified + */ + public noAdditionalProperties = (properties: string[]): boolean => { + const unknowns = Object.keys(this.obj) + .sort() + .filter((key) => !properties.includes(key)); + + unknowns.forEach((property) => + this.catch( + unknownPropertyError({ + property, + path: this.path.of(property), + }), + ), + ); + + return unknowns.length === 0; + }; + + /** + * Iterates over the value of the key and assert each item. If the value isn't + * an array, the function captures a type error and safely exits. + * + * To maintain compatibility with previous implementation, we stop early if we + * find any errors. + */ + public each = (key: string, assert: (item: any, path: Path) => ValidationError[]): void => { + if (!this.array(key)) { + return; + } + + const value = this.obj[key] as Array; + + let foundErrors = false; + value.forEach((item, index) => { + if (foundErrors) { + return; + } + + const errors = assert(item, this.path.of(key).of(index)); + + if (errors.length > 0) { + foundErrors = true; + } + + this.catch(...errors); + }); + }; +} diff --git a/packages/rich-text-types/src/validator/errors.ts b/packages/rich-text-types/src/validator/errors.ts new file mode 100644 index 00000000..4370d179 --- /dev/null +++ b/packages/rich-text-types/src/validator/errors.ts @@ -0,0 +1,104 @@ +import { ValidationError } from '.'; +import type { Path } from './path'; + +export const typeMismatchError = ({ + path, + property, + typeName, + value, +}: { + path: Path; + property: string | number; + typeName: string; + value: any; +}): ValidationError => { + return { + details: `The type of "${property}" is incorrect, expected type: ${typeName}`, + name: 'type', + path: path.toArray(), + type: typeName, + value, + }; +}; + +export const minSizeError = ({ + min, + value, + path, +}: { + min: number; + value: any; + path: Path; +}): ValidationError => { + return { + name: 'size', + min, + path: path.toArray(), + details: `Size must be at least ${min}`, + value, + }; +}; + +export const maxSizeError = ({ + max, + value, + path, +}: { + max: number; + value: any; + path: Path; +}): ValidationError => { + return { + name: 'size', + max, + path: path.toArray(), + details: `Size must be at most ${max}`, + value, + }; +}; + +export const enumError = ({ + expected, + value, + path, +}: { + expected: string[]; + value: any; + path: Path; +}): ValidationError => { + return { + details: `Value must be one of expected values`, + name: 'in', + expected: [...expected].sort(), + path: path.toArray(), + value, + }; +}; + +export const unknownPropertyError = ({ + property, + path, +}: { + property: string; + path: Path; +}): ValidationError => { + return { + details: `The property "${property}" is not expected`, + name: 'unexpected', + path: path.toArray(), + }; +}; + +export const requiredPropertyError = ({ + property, + path, +}: { + property: string; + path: Path; +}): ValidationError => { + return { + details: `The property "${property}" is required here`, + name: 'required', + path: path.toArray(), + }; +}; diff --git a/packages/rich-text-types/src/validator/index.ts b/packages/rich-text-types/src/validator/index.ts new file mode 100644 index 00000000..2f82a2cd --- /dev/null +++ b/packages/rich-text-types/src/validator/index.ts @@ -0,0 +1,114 @@ +import { BLOCKS } from '../blocks'; +import { INLINES } from '../inlines'; +import { CONTAINERS, LIST_ITEM_BLOCKS, TOP_LEVEL_BLOCKS } from '../schemaConstraints'; +import { Document, Text } from '../types'; +import { ObjectAssertion } from './assert'; +import { NodeAssertion, Node, HyperLinkAssertion, assert, assertLink, VOID_CONTENT } from './node'; +import { Path } from './path'; +import { assertText } from './text'; + +export type ValidationError = { + name: string; + type?: string; + value?: Record | string | number | boolean | null; + min?: number | string; + max?: number | string; + details?: string | null; + path?: (string | number)[]; + contentTypeId?: string | string[]; + nodeType?: string; + customMessage?: string; + expected?: string[]; +}; + +const assertInlineOrText = assert([...Object.values(INLINES), 'text'].sort()); + +const assertList = assert([BLOCKS.LIST_ITEM]); +const assertVoidEntryLink = assertLink('Entry', VOID_CONTENT); +const assertTableCell = assert( + () => ({ + nodeTypes: [BLOCKS.PARAGRAPH], + min: 1, + }), + (data, path) => { + const $ = new ObjectAssertion(data, path); + + $.noAdditionalProperties(['colspan', 'rowspan']); + $.number('colspan', true); + $.number('rowspan', true); + + return $.errors; + }, +); + +const nodeValidator: Record> = { + [BLOCKS.DOCUMENT]: assert(TOP_LEVEL_BLOCKS), + [BLOCKS.PARAGRAPH]: assertInlineOrText, + [BLOCKS.HEADING_1]: assertInlineOrText, + [BLOCKS.HEADING_2]: assertInlineOrText, + [BLOCKS.HEADING_3]: assertInlineOrText, + [BLOCKS.HEADING_4]: assertInlineOrText, + [BLOCKS.HEADING_5]: assertInlineOrText, + [BLOCKS.HEADING_6]: assertInlineOrText, + [BLOCKS.QUOTE]: assert(CONTAINERS[BLOCKS.QUOTE]), + [BLOCKS.EMBEDDED_ENTRY]: assertVoidEntryLink, + [BLOCKS.EMBEDDED_ASSET]: assertLink('Asset', VOID_CONTENT), + [BLOCKS.EMBEDDED_RESOURCE]: assertLink('Contentful:Entry', VOID_CONTENT), + [BLOCKS.HR]: assert(VOID_CONTENT), + [BLOCKS.OL_LIST]: assertList, + [BLOCKS.UL_LIST]: assertList, + [BLOCKS.LIST_ITEM]: assert([...LIST_ITEM_BLOCKS].sort()), + [BLOCKS.TABLE]: assert(() => ({ + nodeTypes: [BLOCKS.TABLE_ROW], + min: 1, + })), + [BLOCKS.TABLE_ROW]: assert(() => ({ + nodeTypes: [BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL], + min: 1, + })), + [BLOCKS.TABLE_CELL]: assertTableCell, + [BLOCKS.TABLE_HEADER_CELL]: assertTableCell, + [INLINES.HYPERLINK]: new HyperLinkAssertion(), + [INLINES.EMBEDDED_ENTRY]: assertVoidEntryLink, + [INLINES.EMBEDDED_RESOURCE]: assertLink('Contentful:Entry', VOID_CONTENT), + [INLINES.ENTRY_HYPERLINK]: assertLink('Entry', ['text']), + [INLINES.ASSET_HYPERLINK]: assertLink('Asset', ['text']), + [INLINES.RESOURCE_HYPERLINK]: assertLink('Contentful:Entry', ['text']), +}; + +function validateNode(node: Node | Text, path: Path): ValidationError[] { + if (node.nodeType === 'text') { + return assertText(node, path); + } + + const errors = nodeValidator[node.nodeType].assert(node, path); + + if (errors.length > 0) { + return errors; + } + + const $ = new ObjectAssertion(node, path); + + $.each('content', (item, path) => { + // We already know those are valid nodes thanks to the assertion done in + // the NodeAssertion class + return validateNode(item, path); + }); + + return $.errors; +} + +export const validateRichTextDocument = (document: Document): ValidationError[] => { + const path = new Path(); + const $ = new ObjectAssertion(document, path); + + if ($.object()) { + $.enum('nodeType', [BLOCKS.DOCUMENT]); + } + + if ($.errors.length > 0) { + return $.errors; + } + + return validateNode(document, path); +}; diff --git a/packages/rich-text-types/src/validator/node.ts b/packages/rich-text-types/src/validator/node.ts new file mode 100644 index 00000000..bffc5ab9 --- /dev/null +++ b/packages/rich-text-types/src/validator/node.ts @@ -0,0 +1,173 @@ +import { ValidationError } from '.'; +import { + AssetHyperlink, + AssetLinkBlock, + EntryHyperlink, + EntryLinkBlock, + Hyperlink, + ResourceLinkBlock, + ResourceLinkInline, +} from '../nodeTypes'; +import { Block, Document, Inline } from '../types'; +import { ObjectAssertion } from './assert'; +import type { Path } from './path'; + +export type Node = Document | Block | Inline; + +export type GetContentRule = + | string[] + | (( + node: T, + path: Path, + ) => { + nodeTypes: string[]; + min?: number; + }); + +export type ValidateData = (data: T['data'], path: Path) => ValidationError[]; + +export const VOID_CONTENT: GetContentRule = []; + +export class NodeAssertion { + constructor( + private contentRule: GetContentRule, + private validateData?: ValidateData, + ) {} + + assert(node: T, path: Path): ValidationError[] { + const $ = new ObjectAssertion(node, path); + + if (!$.object()) { + return $.errors; + } + + $.noAdditionalProperties(['nodeType', 'data', 'content']); + + const { nodeTypes, min = 0 } = Array.isArray(this.contentRule) + ? { + nodeTypes: this.contentRule, + } + : this.contentRule(node, path); + + if (nodeTypes.length === 0 && min > 0) { + throw new Error( + `Invalid content rule. Cannot have enforce a 'min' of ${min} with no nodeTypes`, + ); + } + + $.minLength('content', min); + + // Is void + if (nodeTypes.length === 0) { + $.empty('content'); + } + + // Ensure content nodes have valid nodeTypes without validating the full + // shape which is something that's only done later if the current node is + // valid. + else { + $.each('content', (item, path) => { + const item$ = new ObjectAssertion(item, path); + + if (!item$.object()) { + return item$.errors; + } + + item$.enum('nodeType', nodeTypes); + + return item$.errors; + }); + } + + if ($.object('data')) { + const dataErrors = this.validateData?.(node.data, path.of('data')) ?? []; + $.catch(...dataErrors); + } + + return $.errors; + } +} + +export class EntityLinkAssertion< + T extends + | EntryLinkBlock + | EntryHyperlink + | AssetLinkBlock + | AssetHyperlink + | ResourceLinkBlock + | ResourceLinkInline, +> extends NodeAssertion { + private type: 'ResourceLink' | 'Link'; + + constructor( + private linkType: 'Entry' | 'Asset' | 'Contentful:Entry', + contentNodeTypes: GetContentRule, + ) { + super(contentNodeTypes, (data, path) => this.assertLink(data, path)); + this.type = this.linkType.startsWith('Contentful:') ? 'ResourceLink' : 'Link'; + } + + private assertLink = (data: T['data'], path: Path): ValidationError[] => { + const $ = new ObjectAssertion(data, path); + + if ($.object('target')) { + const sys$ = new ObjectAssertion(data.target.sys, path.of('target').of('sys')); + + if (sys$.object()) { + sys$.enum('type', [this.type]); + sys$.enum('linkType', [this.linkType]); + + if (this.type === 'Link') { + sys$.string('id'); + sys$.noAdditionalProperties(['type', 'linkType', 'id']); + } else if (this.type === 'ResourceLink') { + sys$.string('urn'); + sys$.noAdditionalProperties(['type', 'linkType', 'urn']); + } + } + + $.catch(...sys$.errors); + } + + $.noAdditionalProperties(['target']); + + return $.errors; + }; +} + +export class HyperLinkAssertion extends NodeAssertion { + constructor() { + super(['text'], (data, path) => this.assertLink(data, path)); + } + + private assertLink = (data: T['data'], path: Path): ValidationError[] => { + const $ = new ObjectAssertion(data, path); + + $.string('uri'); + $.noAdditionalProperties(['uri']); + + return $.errors; + }; +} + +export const assert = ( + contentRule: GetContentRule, + validateData?: ValidateData, +): NodeAssertion => { + return new NodeAssertion(contentRule, validateData); +}; + +export const assertLink = < + T extends + | EntryLinkBlock + | EntryHyperlink + | AssetLinkBlock + | AssetHyperlink + | ResourceLinkBlock + | ResourceLinkInline, +>( + linkType: 'Entry' | 'Asset' | 'Contentful:Entry', + contentRule: GetContentRule, +): EntityLinkAssertion => { + return new EntityLinkAssertion(linkType, contentRule); +}; diff --git a/packages/rich-text-types/src/validator/path.ts b/packages/rich-text-types/src/validator/path.ts new file mode 100644 index 00000000..0c35eb7e --- /dev/null +++ b/packages/rich-text-types/src/validator/path.ts @@ -0,0 +1,19 @@ +export class Path { + constructor(private readonly path: (string | number)[] = []) {} + + of = (element: string | number): Path => { + return new Path([...this.path, element]); + }; + + isRoot = (): boolean => { + return this.path.length === 0; + }; + + last = (): string | number | undefined => { + return this.path[this.path.length - 1]; + }; + + toArray = (): (string | number)[] => { + return this.path; + }; +} diff --git a/packages/rich-text-types/src/validator/text.ts b/packages/rich-text-types/src/validator/text.ts new file mode 100644 index 00000000..4390ea9f --- /dev/null +++ b/packages/rich-text-types/src/validator/text.ts @@ -0,0 +1,34 @@ +import { ValidationError } from '.'; +import { Text } from '../types'; +import { ObjectAssertion } from './assert'; +import type { Path } from './path'; + +export function assertText(text: Text, path: Path): ValidationError[] { + const $ = new ObjectAssertion(text, path); + + if (!$.object()) { + return $.errors; + } + + $.noAdditionalProperties(['nodeType', 'data', 'value', 'marks']); + + $.object('data'); + $.each('marks', (mark, path) => { + const mark$ = new ObjectAssertion(mark, path); + + if (!mark$.object()) { + return mark$.errors; + } + + // For historical reasons, we don't explicitly check for supported marks + // e.g. bold, italic ..etc. This makes it possible for a customer to add + // custom marks + mark$.string('type'); + + return mark$.errors; + }); + + $.string('value'); + + return $.errors; +} diff --git a/packages/rich-text-types/tools/jsonSchemaGen.ts b/packages/rich-text-types/tools/jsonSchemaGen.ts deleted file mode 100644 index 57586c24..00000000 --- a/packages/rich-text-types/tools/jsonSchemaGen.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { writeFile } from 'fs'; -import { resolve } from 'path'; -import * as TJS from 'typescript-json-schema'; - -import { BLOCKS, INLINES } from '../src/index'; - -// optionally pass argument to schema generator -const settings: TJS.PartialArgs = { - topRef: true, - noExtraProps: true, - required: true, - // @ts-expect-error causes a bug in the generated schema if left out - useTypeOfKeyword: true, - constAsEnum: true, -}; - -// optionally pass ts compiler options -const compilerOptions: TJS.CompilerOptions = { - strictNullChecks: true, - // composite: true, - lib: ['es2015', 'es2016', 'es2017', 'dom'], -}; - -const createJsonSchema = (symbolName: string, nodeType: string): void => { - const doc = TJS.generateSchema(program, symbolName, settings); - - const schemaString = JSON.stringify(doc, null, 2); - - writeFile(`./src/schemas/generated/${nodeType}.json`, schemaString, (err) => { - if (err) { - return console.log(err); - } - }); -}; - -const program = TJS.getProgramFromFiles( - [resolve('./src/types.ts'), resolve('./src/nodeTypes.ts')], - compilerOptions, -); - -const blockSymbolsMap = new Map([ - [BLOCKS.DOCUMENT, 'Document'], - [BLOCKS.PARAGRAPH, 'Paragraph'], - [BLOCKS.HEADING_1, 'Heading1'], - [BLOCKS.HEADING_2, 'Heading2'], - [BLOCKS.HEADING_3, 'Heading3'], - [BLOCKS.HEADING_4, 'Heading4'], - [BLOCKS.HEADING_5, 'Heading5'], - [BLOCKS.HEADING_6, 'Heading6'], - [BLOCKS.OL_LIST, 'OrderedList'], - [BLOCKS.UL_LIST, 'UnorderedList'], - [BLOCKS.LIST_ITEM, 'ListItem'], - [BLOCKS.HR, 'Hr'], - [BLOCKS.QUOTE, 'Quote'], - [BLOCKS.EMBEDDED_ENTRY, 'EntryLinkBlock'], - [BLOCKS.EMBEDDED_ASSET, 'AssetLinkBlock'], - [BLOCKS.EMBEDDED_RESOURCE, 'ResourceLinkBlock'], - [BLOCKS.TABLE, 'Table'], - [BLOCKS.TABLE_ROW, 'TableRow'], - [BLOCKS.TABLE_CELL, 'TableCell'], - [BLOCKS.TABLE_HEADER_CELL, 'TableHeaderCell'], -]); - -const inlineSymbolsMap = new Map([ - [INLINES.HYPERLINK, 'Hyperlink'], - [INLINES.ENTRY_HYPERLINK, 'EntryHyperlink'], - [INLINES.ASSET_HYPERLINK, 'AssetHyperlink'], - [INLINES.RESOURCE_HYPERLINK, 'ResourceHyperlink'], - [INLINES.EMBEDDED_ENTRY, 'EntryLinkInline'], - [INLINES.EMBEDDED_RESOURCE, 'ResourceLinkInline'], -]); - -Object.values(BLOCKS).forEach((nodeType) => { - const symbolName = blockSymbolsMap.get(nodeType); - createJsonSchema(symbolName as string, nodeType); -}); - -Object.values(INLINES).forEach((nodeType) => { - const symbolName = inlineSymbolsMap.get(nodeType); - createJsonSchema(symbolName as string, nodeType); -}); - -createJsonSchema('Text', 'text'); diff --git a/yarn.lock b/yarn.lock index e031a891..2ee69151 100644 --- a/yarn.lock +++ b/yarn.lock @@ -461,11 +461,6 @@ "@types/conventional-commits-parser" "^5.0.0" chalk "^5.3.0" -"@cspotcode/source-map-consumer@^0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" - integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== - "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -1548,21 +1543,6 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== -"@types/fs-extra@^8.0.1": - version "8.1.5" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.5.tgz#33aae2962d3b3ec9219b5aca2555ee00274f5927" - integrity sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ== - dependencies: - "@types/node" "*" - -"@types/glob@^7.1.1": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" - integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== - dependencies: - "@types/minimatch" "*" - "@types/node" "*" - "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -1597,24 +1577,12 @@ expect "^29.0.0" pretty-format "^29.0.0" -"@types/json-schema@^7.0.9": - version "7.0.15" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" - integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== - "@types/json5@^0.0.29": version "0.0.29" resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== -"@types/lodash.clonedeep@^4.5.6": - version "4.5.9" - resolved "https://registry.yarnpkg.com/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.9.tgz#ea48276c7cc18d080e00bb56cf965bcceb3f0fc1" - integrity sha512-19429mWC+FyaAhOLzsS8kZUsI+/GmBAQ0HFiCPsKGU+7pBXOQWhyrY6xNNDwUSX8SMZMJvuFVMF9O5dQOlQK9Q== - dependencies: - "@types/lodash" "*" - -"@types/lodash@*", "@types/lodash@^4.14.172": +"@types/lodash@^4.14.172": version "4.17.12" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.12.tgz#25d71312bf66512105d71e55d42e22c36bcfc689" integrity sha512-sviUmCE8AYdaF/KIHLDJBQgeYzPBI0vf/17NaYehBJfYD1j6/L95Slh07NlyK2iNyBNaEkb3En2jRt+a8y3xZQ== @@ -1626,11 +1594,6 @@ dependencies: "@types/unist" "^2" -"@types/minimatch@*": - version "5.1.2" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" - integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== - "@types/minimatch@^3.0.3": version "3.0.5" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" @@ -1648,13 +1611,6 @@ dependencies: undici-types "~6.19.8" -"@types/node@^18.11.9": - version "18.19.45" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.45.tgz#a9ebfe4c316a356be7ca11f753ecb2feda6d6bdf" - integrity sha512-VZxPKNNhjKmaC1SUYowuXSRSMGyQGmQjvvA1xE4QZ0xce2kLtEhPDS+kqpCPBZYgqblCLQ2DAjSzmgCM5auvhA== - dependencies: - undici-types "~5.26.4" - "@types/normalize-package-data@^2.4.0": version "2.4.4" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz#56e2cc26c397c038fab0e3a917a12d5c5909e901" @@ -2679,11 +2635,6 @@ color-support@1.1.3: resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== -colorette@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" - integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== - colorette@^2.0.20: version "2.0.20" resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" @@ -3779,7 +3730,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.0.3, fast-glob@^3.2.9: +fast-glob@^3.2.9: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== @@ -4013,15 +3964,6 @@ fs-extra@^11.1.0, fs-extra@^11.2.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-extra@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" - integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^4.0.0" - universalify "^0.1.0" - fs-minipass@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" @@ -4218,7 +4160,7 @@ glob-parent@^5.1.2: dependencies: is-glob "^4.0.1" -glob@7.2.3, glob@^7.1.3, glob@^7.1.4, glob@^7.1.7: +glob@7.2.3, glob@^7.1.3, glob@^7.1.4: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -4311,20 +4253,6 @@ globalthis@^1.0.3, globalthis@^1.0.4: define-properties "^1.2.1" gopd "^1.0.1" -globby@10.0.1: - version "10.0.1" - resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22" - integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A== - dependencies: - "@types/glob" "^7.1.1" - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.0.3" - glob "^7.1.3" - ignore "^5.1.1" - merge2 "^1.2.3" - slash "^3.0.0" - globby@11.1.0, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" @@ -4537,7 +4465,7 @@ ignore-walk@^6.0.4: dependencies: minimatch "^9.0.0" -ignore@^5.0.4, ignore@^5.1.1, ignore@^5.2.0, ignore@^5.3.1: +ignore@^5.0.4, ignore@^5.2.0, ignore@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== @@ -4874,6 +4802,11 @@ is-plain-obj@^2.0.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" @@ -4881,11 +4814,6 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.1.tgz#662d92d24c0aa4302407b0d45d21f2251c85f85b" - integrity sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g== - is-plain-object@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" @@ -5619,13 +5547,6 @@ jsonc-parser@3.2.0: resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76" integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w== -jsonfile@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== - optionalDependencies: - graceful-fs "^4.1.6" - jsonfile@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" @@ -5928,11 +5849,6 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== -lodash.clonedeep@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== - lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" @@ -6245,7 +6161,7 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1: +merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== @@ -7145,11 +7061,6 @@ parse-url@^8.1.0: dependencies: parse-path "^7.0.0" -path-equal@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/path-equal/-/path-equal-1.2.5.tgz#9fcbdd5e5daee448e96f43f3bac06c666b5e982a" - integrity sha512-i73IctDr3F2W+bsOWDyyVm/lqsXO47aY9nsFZUjTT/aljSbkxHxxCoyZ9UUrM8jK0JVod+An+rl48RCsvWM+9g== - path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" @@ -7733,17 +7644,6 @@ rimraf@^4.4.1: dependencies: glob "^9.2.0" -rollup-plugin-copy@3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.5.0.tgz#7ffa2a7a8303e143876fa64fb5eed9022d304eeb" - integrity sha512-wI8D5dvYovRMx/YYKtUNt3Yxaw4ORC9xo6Gt9t22kveWz1enG9QrhVlagzwrxSC455xD1dHMKhIJkbsQ7d48BA== - dependencies: - "@types/fs-extra" "^8.0.1" - colorette "^1.1.0" - fs-extra "^8.1.0" - globby "10.0.1" - is-plain-object "^3.0.0" - rollup-plugin-json@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz#a18da0a4b30bf5ca1ee76ddb1422afbb84ae2b9e" @@ -7852,11 +7752,6 @@ safe-regex-test@^1.0.3: es-errors "^1.3.0" is-regex "^1.1.4" -safe-stable-stringify@^2.2.0: - version "2.4.3" - resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz#138c84b6f6edb3db5f8ef3ef7115b8f55ccbf886" - integrity sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g== - "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -8492,7 +8387,7 @@ ts-jest@^29.1.2: semver "^7.6.3" yargs-parser "^21.1.1" -ts-node@10.9.2, ts-node@^10.9.1: +ts-node@10.9.2: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== @@ -8647,26 +8542,12 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -typescript-json-schema@0.65.1: - version "0.65.1" - resolved "https://registry.yarnpkg.com/typescript-json-schema/-/typescript-json-schema-0.65.1.tgz#24840812f69b220b75d86ed87e220b3b3345db2c" - integrity sha512-tuGH7ff2jPaUYi6as3lHyHcKpSmXIqN7/mu50x3HlYn0EHzLpmt3nplZ7EuhUkO0eqDRc9GqWNkfjgBPIS9kxg== - dependencies: - "@types/json-schema" "^7.0.9" - "@types/node" "^18.11.9" - glob "^7.1.7" - path-equal "^1.2.5" - safe-stable-stringify "^2.2.0" - ts-node "^10.9.1" - typescript "~5.5.0" - yargs "^17.1.1" - -typescript@5.6.3, "typescript@>=3 < 6": +typescript@5.6.3: version "5.6.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b" integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw== -typescript@~5.5.0: +"typescript@>=3 < 6": version "5.5.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== @@ -8686,11 +8567,6 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -undici-types@~5.26.4: - version "5.26.5" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" - integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== - undici-types@~6.19.8: version "6.19.8" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" @@ -8752,11 +8628,6 @@ universal-user-agent@^6.0.0: resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa" integrity sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ== -universalify@^0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - universalify@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" @@ -9124,7 +8995,7 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs@17.7.2, yargs@^17.0.0, yargs@^17.1.1, yargs@^17.3.1, yargs@^17.6.2: +yargs@17.7.2, yargs@^17.0.0, yargs@^17.3.1, yargs@^17.6.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==