Skip to content

feat(types): adding filestorage and scenario#52

Merged
Marek Spiska (marekspiska) merged 2 commits into
mainfrom
spiska/new-types
Apr 23, 2026
Merged

feat(types): adding filestorage and scenario#52
Marek Spiska (marekspiska) merged 2 commits into
mainfrom
spiska/new-types

Conversation

@marekspiska

Copy link
Copy Markdown
Contributor

I'm adding support for two types previously unknown to the Forman Schema:

filestorage
scenario

Copilot AI review requested due to automatic review settings April 22, 2026 13:19
@marekspiska Marek Spiska (marekspiska) requested a review from a team as a code owner April 22, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 filestorage and scenario handling to Forman→JSON Schema conversion and runtime validation.
  • Add round-trip support for filestorage via a non-enumerable x-filestorage marker in JSON Schema.
  • Add new Jest specs for scenario and filestorage, 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.

Comment thread src/json.ts
Comment on lines +65 to +70
if (filestorageMarker) {
return {
type: 'filestorage',
label: noEmpty(field.title),
help: noEmpty(field.description),
};

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no min/max validation as for generic arrays

@marekspiska Marek Spiska (marekspiska) merged commit b683599 into main Apr 23, 2026
8 checks passed
@marekspiska Marek Spiska (marekspiska) deleted the spiska/new-types branch April 23, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants