Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@flatfile/blueprint-utils

Package Overview
Dependencies
Maintainers
25
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flatfile/blueprint-utils

A helper for generating valid blueprint.

  • 0.0.12
  • npm
  • Socket score

Version published
Maintainers
25
Created
Source

@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"
        }
      ]
    }
  ]
}

FAQs

Package last updated on 16 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc