plugin-autocast

A plugin for automatically casting values in Flatfile.


plugin-autocast

A plugin for automatically casting values in Flatfile.

plugin-automap

A plugin to provide automapping imported files for headless workflows.

plugin-constraints

A plugin for extending blueprint with external constraints

plugin-convert-currency

A Flatfile plugin for currency conversion using Open Exchange Rates API

plugin-convert-json-schema

A plugin for converting JSON Schema to Flatfile Blueprint and configuring a...

plugin-convert-openapi-schema

A plugin for converting OpenAPI schema to Flatfile Blueprint.

plugin-convert-sql-ddl

A plugin for converting SQL DDL into Flatfile Blueprint.

plugin-convert-translate

A Flatfile Listener plugin for field translation using the Google Translate...

plugin-convert-what3words

A Flatfile plugin for converting What3Words addresses to standard addresses...

plugin-convert-yaml-schema

A plugin for converting YAML Schema definitions to Flatfile Blueprint.

plugin-dedupe

Dedupe records in a sheet via a sheet level custom action.

plugin-delimiter-extractor

A plugin for parsing .delimiter files in Flatfile.

plugin-dxp-configure

A plugin for using DXP class-based configurations.

plugin-enrich-geocode

A Flatfile plugin for geocoding addresses using the Google Maps Geocoding A...

plugin-enrich-gpx

A Flatfile plugin for parsing GPX files and extracting relevant data

plugin-enrich-sentiment

A Flatfile plugin for sentiment analysis of text fields in records

plugin-enrich-summarize

A Flatfile plugin for text summarization and key phrase extraction

plugin-export-delimited-zip

A Flatfile plugin for exporting Workbooks to delimited files and zipping th...

plugin-export-pivot-table

A Flatfile plugin for generating pivot tables from sheet data and saving as...

plugin-export-workbook

A plugin for exporting data in Flatfile to Workbooks.

plugin-extract-html-table

A Flatfile plugin for extracting table data from HTML files

plugin-extract-markdown

A plugin for parsing markdown files in Flatfile.

plugin-import-faker

A Flatfile plugin that generates example records using Faker

plugin-import-llm-records

A Flatfile plugin that generates example records using AI

plugin-import-rss

A Flatfile plugin for importing RSS feed data

plugin-job-handler

A plugin for handling Flatfile Jobs.

plugin-json-extractor

A plugin for parsing json files in Flatfile.

plugin-markdown-extractor

A plugin for parsing markdown files in Flatfile.

plugin-pdf-extractor

A plugin for parsing PDF files in Flatfile.

plugin-record-hook

A plugin for running custom logic on individual data records in Flatfile.

plugin-rollout

A plugin for automatically rolling out new changes to workbooks in flatfile...

plugin-space-configure

A plugin for configuring a Flatfile Space.

plugin-space-configure-from-template

A plugin for configuring a Flatfile Space from a Space Template.

plugin-stored-constraints

A plugin for running stored constraints

plugin-validate-boolean

A Flatfile plugin for boolean validation with multi-language support

plugin-validate-date

A Flatfile plugin for normalizing date formats

plugin-validate-email

A Flatfile Listener plugin for email validation

plugin-validate-isbn

A Flatfile Listener plugin for ISBN validation with configurable options. V...

plugin-validate-number

A Flatfile Listener plugin for number validation

plugin-validate-phone

A validator plugin for phone number formatting on individual data records i...

plugin-validate-string

A Flatfile plugin for string configuration and validation

plugin-view-mapped

A plugin for making the view post mapping show only mapped columns.

plugin-webhook-egress

A plugin for egressing data from a Flatfile Workbook to a webhook.

plugin-xlsx-extractor

A plugin for parsing xlsx files in Flatfile.

plugin-xml-extractor

A plugin for parsing .xml files in Flatfile.

plugin-zip-extractor

A plugin for unzipping zip files and uploading content back in Flatfile.

util-extractor

A library containing common utilities and helpers for extractors.

util-file-buffer

A utility for extracting data from any file and making it available as a bu...

util-response-rejection

This plugin handles response rejections returned from an external source.

Installation


Installnpm i @flatfile/plugin-autocast
Source: View source
Package:@flatfile/plugin-autocast 2k installs

@flatfile/plugin-autocast

Automatically cast values in Flatfile to their appropriate types with this plugin.

The @flatfile/plugin-autocast plugin is an opinionated transformer that will automatically convert the data in the Sheet to match the type defined by the Blueprint.

Event Type: listener.on('commit:created')

Supported field types: number, boolean, date

Parameters

sheetSlug - string - (required)

The sheetSlug indicates the slug name of the sheet you want to monitor.

fieldFilters - string[]

Use the fieldFilters parameter to select specific fields to monitor. Without any specified fieldFilters, the plugin will automatically monitor all castable fields, including strings, numbers, booleans, and dates.

options.chunkSize - default: "10_000" - number

The chunkSize parameter allows you to specify the quantity of records to in each chunk.

options.parallel - default: "1" - number

The parallel parameter allows you to specify the number of chunks to process in parallel.

API Calls

  • api.sheets.get

Usage

The autocast plugin will listen for the commit:created event and cast strings, numbers, booleans, and dates to the appropriate Blueprint type. Note that the recordHook and bulkRecordHook plugins listen for the same event type. Plugins will fire in the order they are placed in the listener.

Strings

Numbers and booleans are transformed from strings to their respective types (i.e., '1' to 1, "true" to true).

Numbers

String numbers (i.e '1'), string decimals (i.e '1.1'), and string numbers with commas (i.e '1,000') are interpreted as numbers.

Booleans

'1', 'yes', 'true', 'on', 't', 'y', and 1 are interpreted as truthy values.

'-1', '0', 'no', 'false', 'off', 'f', 'n', 0, -1 are interpreted as falsy values.

Dates

Date strings and numbers are cast to UTC strings. For example, YYYY-MM-DD... formats are treated as ISO 8601 dates (UTC), whereas other formats are considered local time and converted to UTC:

  • '2023-08-16' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '08-16-2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '08/16/2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 'Aug 16, 2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 'August 16, 2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '2023-08-16T00:00:00.000Z' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 1692144000000 => 'Wed, 16 Aug 2023 00:00:00 GMT'

install

npm i @flatfile/plugin-autocast

import

import { autocast } from "@flatfile/plugin-autocast";

listener.js

listener.use(autocast("sheetSlug"));

listener.js w/ fieldFilters

listener.use(autocast("sheetSlug", ["numberField", "dateField"]));

listener.js w/ fieldFilters & options

listener.use(
  autocast("sheetSlug", ["numberField", "dateField"], {
    chunkSize: 10_000,
    parallel: 2,
  })
);