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 castable-field (number, boolean & Date).

options.chunkSize
number
default: "10_000"

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

options.parallel
number
default: "1"

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

API Calls

  • api.sheets.get

Imported NPM Packages

Usage

The autocast plugin will listen for the commit:created event and cast 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 cast to strings (i.e '1' -> 1, true -> "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 a UTC string. These are example of dates that will be cast (note: YYYY-MM-DD... is interpreted as an ISO 8601 date and is treated as treated as UTC, while other formats are treated as 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.use(autocast("sheetSlug"));

See the code