@autoinvent/conveyor-schema
v0.8.0
Published
a schema helper library for conveyor
Downloads
65
Keywords
Readme
conveyor-schema
Conveyor-schema is a helper library for @autoinvent/conveyor. It is required for instantiating a SchemaBuilder object to be passed into conveyor's components.
This library provides is an easy way to traverse the schema used in conveyor's framework.
It contains:
1.) schema getters (so you don't have to traverse the tree structure)
2.) methods for checking mutate-ability (creatable, editable, ect)
3.) schema merge helpers
Installation
yarn add @autoinvent/conveyor-schema
With npm:
npm install --save @autoinvent/conveyor-schema
Usage
Getting Started
Inside your main project, after generating your raw schema JSON, convert the object to a 'SchemaBuilder' type:
import { SchemaBuilder } from '@autoinvent/conveyor-schema'
const schema = new SchemaBuilder(schema)
Now your schema is ready to be passed into any conveyor component
Traversing the Schema
The SchemaBuilder
object has methods for easily getting props. You will never have to remember the path to take in order to access attributes.
Furthermore, for schema props which can be a boolean or a function, conveyor-schema evaluates both scenarios and returns the correct value. This is useful for attributes such as 'creatable', 'deletable', and 'editable', which may be associated with a callback.
To see a full list of built-in methods, see the SchemaBuilder API docs.