@remoteoss/remote-json-schema-form-kit
v0.0.11
Published
Remote's kit for json-schema-form
Readme
remote-json-schema-form-kit
Remote's wrapper around @remoteoss/json-schema-form (JSF) with added JSON logic operators.
This package exposes the two JSF versions v0 (legacy) and v1 (new).
Installation
npm install @remoteoss/remote-json-schema-form-kitUsage
import { createHeadlessForm, modify } from '@remoteoss/remote-json-schema-form-kit';How version routing works
This package exposes the two JSF versions we use:
- v0 (legacy) —
@remoteoss/[email protected] - v1 —
@remoteoss/[email protected]
When you call createHeadlessForm(schema, options) or modify(schema, options), the kit checks:
schema["x-rmt-meta"].jsfVersion === "1"(schema-level marker set when consuming schemas via API)options.nextVersion === true(explicit caller override)
If either condition is true, the call is forwarded to the v1 implementation. Otherwise it falls back to the v0 implementation.
For v1, the kit also injects:
- Custom JSON Logic operators via
customJsonLogicOps - Legacy compatibility options (
treatNullAsUndefined,allowForbiddenValues)
⚠️ In the next major version of this kit, the default JSF will be v1, unless callers opt out explicitly.
TypeScript types (v0 vs v1)
The kit already disambiguates some overlapping concepts. All types are v1 by default. Some types for v0 has a *Legacy suffix, for example ModifyConfigLegacy, FieldLegacy, etc.
CONTRIBUTING
This project was previously in Github, but it has moved to our internal private monorepo to improve the DX when updating JSF. We might consider doing a new mirror on Github for transparency. If you need it, let us know!
Adding a new custom JSON Logic operator
- Create a new file in
src/json-logic-operators/and write tests (follow the existing pattern, e.g.dateAddDays.ts) - Export it from
src/json-logic-operators/index.tsin theoperatorsobject - The key in the
operatorsobject is the operator name used in JSON Schemas (e.g.date_add_days)
Deploy
Read README_internal.md for more info.
