feat(types): adding filestorage and scenario#52
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for two additional Forman field types (filestorage and scenario) across schema conversion and validation, with accompanying Jest coverage and documentation updates.
Changes:
- Add
filestorageandscenariohandling to Forman→JSON Schema conversion and runtime validation. - Add round-trip support for
filestoragevia a non-enumerablex-filestoragemarker in JSON Schema. - Add new Jest specs for
scenarioandfilestorage, plus update README type mapping and bump package version.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/scenario.spec.ts | New tests for scenario conversion (x-fetch) and validation (static + RPC/grouped options). |
| test/filestorage.spec.ts | New tests for filestorage conversion (x-filestorage marker), round-trip, and validation basics. |
| src/validator.ts | Recognize filestorage and scenario in type mapping and validation dispatch. |
| src/types.ts | Add filestorage to the FormanSchemaFieldType union. |
| src/json.ts | Add JSON Schema→Forman short-circuit to collapse x-filestorage arrays back to filestorage. |
| src/forman.ts | Add Forman→JSON Schema conversion support for filestorage and scenario (including x-filestorage). |
| package.json | Version bump to 1.13.1. |
| package-lock.json | Lockfile version bump to 1.13.1. |
| README.md | Document the new type mappings for filestorage and scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (filestorageMarker) { | ||
| return { | ||
| type: 'filestorage', | ||
| label: noEmpty(field.title), | ||
| help: noEmpty(field.description), | ||
| }; |
There was a problem hiding this comment.
toFormanSchema() short-circuits arrays with an x-filestorage property to { type: 'filestorage', ... }, but it only checks for the descriptor's existence (not its boolean value) and it drops any array-level validation (minItems/maxItems) that might be present on the JSON Schema. Consider checking filestorageMarker?.value === true and preserving minItems/maxItems by mapping them into validate on the returned Forman field (similar to the generic array path below).
| if (filestorageMarker) { | |
| return { | |
| type: 'filestorage', | |
| label: noEmpty(field.title), | |
| help: noEmpty(field.description), | |
| }; | |
| if (filestorageMarker?.value === true) { | |
| const formanSchema: FormanSchemaField = { | |
| type: 'filestorage', | |
| label: noEmpty(field.title), | |
| help: noEmpty(field.description), | |
| }; | |
| if (field.minItems !== undefined || field.maxItems !== undefined) { | |
| formanSchema.validate = formanSchema.validate || {}; | |
| if (field.minItems !== undefined) formanSchema.validate.minItems = field.minItems; | |
| if (field.maxItems !== undefined) formanSchema.validate.maxItems = field.maxItems; | |
| } | |
| return formanSchema; |
There was a problem hiding this comment.
there is no min/max validation as for generic arrays
I'm adding support for two types previously unknown to the Forman Schema:
filestorage
scenario