A utility for converting between Forman Schema and JSON Schema.
npm install @makehq/forman-schema
import { toJSONSchema } from '@makehq/forman-schema';
const formanField = {
type: 'collection',
spec: [
{
name: 'name',
type: 'text',
required: true,
},
{
name: 'age',
type: 'number',
},
],
};
const jsonSchema = toJSONSchema(formanField);
import { toFormanSchema } from '@makehq/forman-schema';
const jsonSchemaField = {
type: 'object',
properties: {
name: {
type: 'string',
},
age: {
type: 'number',
},
},
required: ['name'],
};
const formanSchema = toFormanSchema(jsonSchemaField);
- account → number
- aiagent → string
- array → array
- buffer → string
- cert → string
- collection → object
- color → string
- datastore → number
- date → string
- email → string
- file → string
- filename → string
- folder → string
- hidden → string
- hook → number
- integer → number
- json → string
- keychain → number
- number → number
- path → string
- pkey → string
- port → number
- select → string with enum
- text → string
- time → string
- timestamp → string
- timezone → string
- uinteger → number
- url → string
- uuid → string
- string → text
- number → number
- boolean → boolean
- object → collection
- array → array
SchemaConversionError
is thrown when schema conversion fails. It includes a message and optionally the field that caused the error.
To test the project:
npm test
To build the project:
npm run build # Builds both ESM and CJS versions