0.0.13 • Published 7 months ago

@flatfile/blueprint-utils v0.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

@flatfile/blueprint-utils

This package offers utilities for working with blueprint easily.

import { sheet } from '@flatfile/blueprint-utils'

Defaults type to "string"

sheet({
  name: 'Contacts',
  fields: [
    {
      key: 'name',
      label: 'Full Name'
    },
  ],
})

Returns full Blueprint

{
  "name": "Contacts",
  "fields": [
    {
      "label": "Full Name",
      "key": "name",
      "type": "string"
    }
  ]
}

Simple strings as field specifications

sheet({
  name: 'Contacts',
  fields: ['name', 'email', 'phone'],
})

Returns full Blueprint

{
  "name": "Contacts",
  "fields": [
    {
      "key": "name",
      "type": "string"
    },
    {
      "key": "email",
      "type": "string"
    },
    {
      "key": "phone",
      "type": "string"
    }
  ]
}

Provide only a label if keys aren't important

sheet({
  name: 'Contacts',
  fields: [
    {
      label: 'Name / Nombre',
      type: 'string',
    },
  ],
})

Returns full Blueprint

{
  "name": "Contacts",
  "fields": [
    {
      "label": "Name / Nombre",
      "key": "Name_Nombre",
      "type": "string"
    }
  ]
}

Provide constraints as simple strings

sheet({
  name: 'Contacts',
  fields: [
    {
      key: 'email',
      label: 'Email Address',
      constraints: ['required', 'unique'],
    },
    {
      key: 'phone',
      label: 'Phone Number',
      constraints: 'required',
    },
  ],
})

Returns full Blueprint

{
  "name": "Contacts",
  "fields": [
    {
      "label": "Email Address",
      "key": "email",
      "type": "string",
      "constraints": [
        {
          "type": "required"
        },
        {
          "type": "unique"
        }
      ]
    },
    {
      "label": "Phone Number",
      "key": "phone",
      "type": "string",
      "constraints": [
        {
          "type": "required"
        }
      ]
    }
  ]
}
0.0.13

7 months ago

0.0.12

7 months ago

0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago