diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ad1502..f50d3b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,39 @@ jobs: yarn test:scripts yarn changelog:check + typescript: + name: TypeScript ${{ matrix.typescript }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # The `typescript` peer accepts ^5 || ^6 || ^7: type-check and build the library and its + # declarations under each supported major that the toolchain (vue-tsc) runs on. + typescript: ['5.9', '6.0'] + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v5 + with: + node-version: '22' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Install TypeScript ${{ matrix.typescript }} + env: + TYPESCRIPT_RANGE: ~${{ matrix.typescript }}.0 + run: | + yarn add --dev --ignore-scripts "typescript@${TYPESCRIPT_RANGE}" + node -e "const v=require('typescript').version;console.log('TypeScript',v);if(!v.startsWith(process.argv[1]+'.'))process.exit(1)" "${{ matrix.typescript }}" + + - name: Type-check and build + run: yarn build + test: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 39b70e7..471c331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,29 @@ versioning follows [SemVer](https://semver.org/). +## [2.1.1](https://github.com/FicSysFR/jsonforms_builder/compare/2.1.0...2.1.1) - 2026-11-17 + +### 🐛 Fixes + +- The `typescript` peer dependency is now optional and accepts `^5 || ^6 || ^7`: TypeScript is only + needed to type-check the host or to consume `./source`, and the former required `^5` peer made + TypeScript 6 hosts fail strict peer resolution (`23170e1`). +- Sources pass TypeScript 6's default `strict` mode, which matters to hosts type-checking the + `./source` export; `strict` is now explicit in the library configuration (`49ebe1a`). +- The npm package ships `THIRD_PARTY_NOTICES.md`, with the MIT notices of the JSON Forms derived + code and of Day.js, which `dist/` bundles; the Day.js notice was missing (`87dd86a`). + +### 📝 Documentation + +- Installation guide (FR/EN) and README: optional `typescript` peer and license notices to + reproduce when redistributing the library. + +### 🔧 Internal + +- CI type-checks and builds the library under TypeScript 5.9 and 6.0; the package audit enforces + the optional `typescript` peer and a notice section for every bundled third-party package + (`49ebe1a`, `87dd86a`). + ## [2.1.0](https://github.com/FicSysFR/jsonforms_builder/compare/2.0.2...2.1.0) - 2026-10-19 ### ✨ Features diff --git a/README.md b/README.md index 8d27dc0..00842f9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ yarn add @ficsysfr/jsonforms_builder @jsonforms/core @jsonforms/vue @nuxt/ui `@nuxt/ui`, `@jsonforms/core`, `@jsonforms/vue`, and `vue` are **peerDependencies**: the library does not ship any Nuxt UI components; it imports them from the host app installation. +`typescript` is an **optional** peerDependency (`^5 || ^6 || ^7`): it only matters for the +host's type-checking or the `./source` export, never at runtime. + +The package is BSD-3-Clause licensed (`LICENSE`) and ships `THIRD_PARTY_NOTICES.md` (MIT notices +of the JSON Forms derived code and of the bundled Day.js): reproduce both when redistributing. + ## Usage ```vue diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 0fe4f87..d02bec6 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -1,13 +1,17 @@ # Third-Party Notices -This project includes source code derived from the JSON Forms project, which is licensed under the MIT License by EclipseSource Munich (2017-2019). The MIT License text is reproduced below in accordance with its terms. +`@ficsysfr/jsonforms_builder` is licensed under the BSD-3-Clause License (see `LICENSE`). This file +ships with the npm package and reproduces the notices of the third-party code it contains. -The playground example corpus is derived from two EclipseSource repositories, both MIT licensed: +Every other runtime dependency (Vue, JSON Forms, Nuxt UI, Tiptap, `@internationalized/date`, +`defu`, `radash`) stays external: it is installed by the host application and keeps its own +license file in `node_modules`. -- [`eclipsesource/jsonforms`](https://github.com/eclipsesource/jsonforms) — `packages/examples` -- [`eclipsesource/jsonforms-vuetify-renderers`](https://github.com/eclipsesource/jsonforms-vuetify-renderers) — `example/src/examples` (files prefixed `vuetify-`) +## JSON Forms (MIT License, derived source) -## JSON Forms (MIT License) +This project includes source code derived from the JSON Forms project, which is licensed under the +MIT License by EclipseSource Munich (2017-2019). The derived code is part of `src/` and of the +compiled `dist/` files. ``` The MIT License @@ -33,3 +37,41 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` + +## Day.js (`dayjs`, MIT License, bundled) + +The compiled `dist/` files bundle Day.js and its `customParseFormat` plugin +(), so that hosts do not have to pre-bundle a CommonJS +dependency. + +``` +MIT License + +Copyright (c) 2018-present, iamkun + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Repository only: playground example corpus + +The playground example corpus (not part of the npm package) is derived from two EclipseSource +repositories, both under the JSON Forms MIT License reproduced above: + +- [`eclipsesource/jsonforms`](https://github.com/eclipsesource/jsonforms) — `packages/examples` +- [`eclipsesource/jsonforms-vuetify-renderers`](https://github.com/eclipsesource/jsonforms-vuetify-renderers) — `example/src/examples` (files prefixed `vuetify-`) diff --git a/changelog/2.1.1.md b/changelog/2.1.1.md new file mode 100644 index 0000000..312a431 --- /dev/null +++ b/changelog/2.1.1.md @@ -0,0 +1,28 @@ +--- +version: 2.1.1 +date: 2026-11-17 +title: TypeScript 6 compatibility and third-party notices +previous: 2.1.0 +prerelease: false +--- + +### 🐛 Fixes + +- The `typescript` peer dependency is now optional and accepts `^5 || ^6 || ^7`: TypeScript is only + needed to type-check the host or to consume `./source`, and the former required `^5` peer made + TypeScript 6 hosts fail strict peer resolution (`23170e1`). +- Sources pass TypeScript 6's default `strict` mode, which matters to hosts type-checking the + `./source` export; `strict` is now explicit in the library configuration (`49ebe1a`). +- The npm package ships `THIRD_PARTY_NOTICES.md`, with the MIT notices of the JSON Forms derived + code and of Day.js, which `dist/` bundles; the Day.js notice was missing (`87dd86a`). + +### 📝 Documentation + +- Installation guide (FR/EN) and README: optional `typescript` peer and license notices to + reproduce when redistributing the library. + +### 🔧 Internal + +- CI type-checks and builds the library under TypeScript 5.9 and 6.0; the package audit enforces + the optional `typescript` peer and a notice section for every bundled third-party package + (`49ebe1a`, `87dd86a`). diff --git a/docs/en/guide/installation.md b/docs/en/guide/installation.md index 2975100..72cb4e7 100644 --- a/docs/en/guide/installation.md +++ b/docs/en/guide/installation.md @@ -9,6 +9,16 @@ unchanged apart from the import path. `@nuxt/ui`, `@jsonforms/core`, `@jsonforms/vue` and `vue` are **peerDependencies**: the library bundles no Nuxt UI component of its own; it imports them from the host application’s installation. +`typescript` is an **optional** peerDependency (`^5 || ^6 || ^7`): it only matters for the +host’s type-checking or the `./source` export, never at runtime. + +## Licenses + +The library is BSD-3-Clause licensed (`LICENSE`). The npm package also ships +`THIRD_PARTY_NOTICES.md`: the MIT notices of the code derived from JSON Forms and of Day.js, which +is bundled into `dist/`. An application that redistributes the library reproduces both files in +its third-party notices. + ## Requirements - Node.js ≥ 22 diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 596a8bb..cf8b641 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -9,6 +9,16 @@ les exports publics restent identiques en dehors du chemin d'import. `@nuxt/ui`, `@jsonforms/core`, `@jsonforms/vue` et `vue` sont des **peerDependencies** : la bibliothèque n’embarque aucun composant Nuxt UI ; elle les importe depuis l’installation de l’application hôte. +`typescript` est une peerDependency **optionnelle** (`^5 || ^6 || ^7`) : elle ne sert qu’au +contrôle de types de l’hôte ou à l’export `./source`, et n’est jamais requise à l’exécution. + +## Licences + +La bibliothèque est sous licence BSD-3-Clause (`LICENSE`). Le paquet npm livre aussi +`THIRD_PARTY_NOTICES.md` : notices MIT du code dérivé de JSON Forms et de Day.js, embarqué dans +`dist/`. Une application qui redistribue la bibliothèque reproduit ces deux fichiers dans ses +notices tierces. + ## Prérequis - Node.js ≥ 22 diff --git a/package.json b/package.json index bb55bed..1fb8908 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "dist/**/*", "src/**/*", "README.md", - "LICENSE" + "LICENSE", + "THIRD_PARTY_NOTICES.md" ], "scripts": { "prebuild": "rimraf dist", @@ -121,9 +122,14 @@ "@jsonforms/core": "^3.6", "@jsonforms/vue": "^3.6", "@nuxt/ui": "^4.10", - "typescript": "^5", + "typescript": "^5 || ^6 || ^7", "vue": "^3.5" }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + }, "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/", diff --git a/scripts/package.mjs b/scripts/package.mjs index a5c16e8..e287a4e 100644 --- a/scripts/package.mjs +++ b/scripts/package.mjs @@ -27,6 +27,7 @@ export const PACKAGE_SPECS = [ 'package.json', 'README.md', 'LICENSE', + 'THIRD_PARTY_NOTICES.md', 'dist/index.d.ts', 'dist/json-formbuilder.es.js', 'dist/json-formbuilder.cjs.js', @@ -142,6 +143,46 @@ export function validatePackResult(result, spec, expectedVersion) { if (errors.length > 0) throw new Error(`${spec.name}:\n- ${errors.join('\n- ')}`) } +/** + * TypeScript is only needed to type-check hosts or to consume `./source`: the compiled + * entries ship declarations that every supported TypeScript major reads. A required peer + * would make TypeScript 6 hosts fail strict peer resolution for no runtime reason. + */ +export const TYPESCRIPT_PEER_RANGE = '^5 || ^6 || ^7' + +/** + * Third-party packages compiled into `dist/` rather than left external in `vite.config.ts`. + * Their licenses require the notice to travel with every copy, so each one needs a section in + * `THIRD_PARTY_NOTICES.md`, which the library tarball must ship. + */ +export const BUNDLED_THIRD_PARTY_PACKAGES = ['dayjs'] + +export function validateThirdPartyNotices(notices) { + const missing = BUNDLED_THIRD_PARTY_PACKAGES.filter( + (name) => !new RegExp(`^## .*\\(\`${name}\`, `, 'm').test(notices), + ) + if (missing.length > 0) { + throw new Error(`THIRD_PARTY_NOTICES.md lacks a section for bundled ${missing.join(', ')}`) + } +} + +export function validateLibraryManifest(manifest) { + const errors = [] + if (!manifest.files?.includes('THIRD_PARTY_NOTICES.md')) { + errors.push('files must publish THIRD_PARTY_NOTICES.md') + } + const typescriptPeer = manifest.peerDependencies?.typescript + if (typescriptPeer !== undefined) { + if (typescriptPeer !== TYPESCRIPT_PEER_RANGE) { + errors.push(`typescript peer must be ${TYPESCRIPT_PEER_RANGE}, got ${typescriptPeer}`) + } + if (manifest.peerDependenciesMeta?.typescript?.optional !== true) { + errors.push('typescript peer must be optional (peerDependenciesMeta.typescript.optional)') + } + } + if (errors.length > 0) throw new Error(`${manifest.name}:\n- ${errors.join('\n- ')}`) +} + function validateManifests() { const manifests = PACKAGE_SPECS.map((spec) => ({ spec, @@ -161,6 +202,8 @@ function validateManifests() { } const library = manifests[0].manifest + validateLibraryManifest(library) + validateThirdPartyNotices(readFileSync(join(root, 'THIRD_PARTY_NOTICES.md'), 'utf8')) for (const target of [ library.main, library.module, diff --git a/scripts/tests/package.test.mjs b/scripts/tests/package.test.mjs index 708029d..deca380 100644 --- a/scripts/tests/package.test.mjs +++ b/scripts/tests/package.test.mjs @@ -1,6 +1,36 @@ import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' import test from 'node:test' -import { PACKAGE_SPECS, validatePackResult } from '../package.mjs' +import { + BUNDLED_THIRD_PARTY_PACKAGES, + PACKAGE_SPECS, + validateLibraryManifest, + validatePackResult, + validateThirdPartyNotices, +} from '../package.mjs' + +const libraryManifest = () => + JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')) + +test('library manifest satisfies the published peer contract', () => { + assert.doesNotThrow(() => validateLibraryManifest(libraryManifest())) +}) + +test('library manifest rejects a required or TypeScript 6 incompatible typescript peer', () => { + const required = libraryManifest() + required.peerDependencies.typescript = '^5 || ^6 || ^7' + delete required.peerDependenciesMeta + assert.throws(() => validateLibraryManifest(required), /typescript.*optional/) + + const outdated = libraryManifest() + outdated.peerDependencies.typescript = '^5' + assert.throws(() => validateLibraryManifest(outdated), /typescript.*\^5 \|\| \^6 \|\| \^7/) + + const absent = libraryManifest() + delete absent.peerDependencies.typescript + delete absent.peerDependenciesMeta?.typescript + assert.doesNotThrow(() => validateLibraryManifest(absent)) +}) function validResult(spec) { return { @@ -38,3 +68,18 @@ test('package audit enforces name, version and size budgets', () => { result.size = spec.maximumPackedSize + 1 assert.throws(() => validatePackResult(result, spec, '2.0.2'), /expected package name/) }) + +test('library package ships the third-party notices', () => { + assert.ok(PACKAGE_SPECS[0].required.includes('THIRD_PARTY_NOTICES.md')) + + const unlisted = libraryManifest() + unlisted.files = unlisted.files.filter((entry) => entry !== 'THIRD_PARTY_NOTICES.md') + assert.throws(() => validateLibraryManifest(unlisted), /THIRD_PARTY_NOTICES\.md/) +}) + +test('third-party notices cover every package bundled into dist', () => { + const notices = readFileSync(new URL('../../THIRD_PARTY_NOTICES.md', import.meta.url), 'utf8') + assert.doesNotThrow(() => validateThirdPartyNotices(notices)) + assert.ok(BUNDLED_THIRD_PARTY_PACKAGES.includes('dayjs')) + assert.throws(() => validateThirdPartyNotices(notices.replaceAll('dayjs', 'removed')), /dayjs/) +}) diff --git a/src/common/control-wrapper.vue b/src/common/control-wrapper.vue index a9b5a7d..ae968e6 100644 --- a/src/common/control-wrapper.vue +++ b/src/common/control-wrapper.vue @@ -221,7 +221,7 @@ export default defineComponent({ * @see help — description is always rendered; cf. template comment. */ fieldUi(): Record { - return this.uiProps?.('formField')?.ui ?? {} + return (this.uiProps?.('formField')?.ui ?? {}) as Record }, }, }) diff --git a/src/controls/file-upload.vue b/src/controls/file-upload.vue index a3aa4b5..2b42c8f 100644 --- a/src/controls/file-upload.vue +++ b/src/controls/file-upload.vue @@ -54,7 +54,7 @@ const isMultipleFileSchema = schemaMatches((schema) => { const items = schema.items - return Boolean(items) && hasType(items, 'string') + return items !== undefined && hasType(items, 'string') }) /** diff --git a/src/i18n/createJsonFormsTranslator.ts b/src/i18n/createJsonFormsTranslator.ts index 93a7a96..4acd8e1 100644 --- a/src/i18n/createJsonFormsTranslator.ts +++ b/src/i18n/createJsonFormsTranslator.ts @@ -48,7 +48,13 @@ export const createJsonFormsTranslator = ( }, } - return (key, defaultMessage, values) => { + // `Translator` ties the return type to `defaultMessage`: a string default always yields a + // string, which the branches below honour; only a missing default can yield `undefined`. + const translate = ( + key: string, + defaultMessage?: string, + values?: Parameters[1], + ): string | undefined => { const fromMessages = options.messages ? (get(options.messages, key) as unknown) : undefined const fromAjv = get(ajvDict, key) as unknown const raw = @@ -68,4 +74,6 @@ export const createJsonFormsTranslator = ( return returnUndefinedWhenMissing ? undefined : '' } + + return translate as Translator } diff --git a/tsconfig.json b/tsconfig.json index b6dbfe5..b7e5392 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { "module": "es2022", + // Explicit since TypeScript 6 turns `strict` on by default: both majors must agree. + "strict": true, "types": ["node"], // `DOM` is required: the library uses drag-and-drop events, `fetch`, // `AbortController`, and `structuredClone`. v1 declared `["es7"]` alone, which