Skip to content

integromat/make-forman-schema

Repository files navigation

Forman Schema

A utility for converting between Forman Schema and JSON Schema.

Installation

npm install @makehq/forman-schema

Usage

Converting from Forman Schema to JSON 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);

Converting from JSON Schema to Forman Schema

import { toFormanSchema } from '@makehq/forman-schema';

const jsonSchemaField = {
    type: 'object',
    properties: {
        name: {
            type: 'string',
        },
        age: {
            type: 'number',
        },
    },
    required: ['name'],
};

const formanSchema = toFormanSchema(jsonSchemaField);

Supported Types

Forman Schema Types

  • 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

JSON Schema Types

  • string → text
  • number → number
  • boolean → boolean
  • object → collection
  • array → array

Error Handling

SchemaConversionError

SchemaConversionError is thrown when schema conversion fails. It includes a message and optionally the field that caused the error.

Testing

To test the project:

npm test

Building

To build the project:

npm run build        # Builds both ESM and CJS versions

About

Make Forman Schema Tools

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •