Skip to content

Commit

Permalink
feat: bring rich text validator [TOL-2426] (#694)
Browse files Browse the repository at this point in the history
* 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 <chrishelgert@users.noreply.github.com>
  • Loading branch information
YvesRijckaert and chrishelgert authored Oct 29, 2024
1 parent a7386da commit 30893a6
Show file tree
Hide file tree
Showing 52 changed files with 1,872 additions and 8,800 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentful-slatejs-adapter/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'],
},
Expand Down
6 changes: 4 additions & 2 deletions packages/rich-text-from-markdown/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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),
});
2 changes: 0 additions & 2 deletions packages/rich-text-html-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 4 additions & 2 deletions packages/rich-text-html-renderer/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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),
});
6 changes: 4 additions & 2 deletions packages/rich-text-links/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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),
});
6 changes: 4 additions & 2 deletions packages/rich-text-plain-text-renderer/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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),
});
4 changes: 2 additions & 2 deletions packages/rich-text-react-renderer/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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);
11 changes: 5 additions & 6 deletions packages/rich-text-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
34 changes: 4 additions & 30 deletions packages/rich-text-types/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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),
});
Loading

0 comments on commit 30893a6

Please sign in to comment.