@flatfile/plugin-autocast
Parameters
The sheetSlug
indicates the slug name of the sheet you want to monitor.
Use the fieldFilters
parameter to select specific fields to monitor. Without
any specified fieldFilters
, the plugin will automatically monitor
castable-field (number, boolean & Date).
The chunkSize
parameter allows you to specify the quantity of records to in
each chunk.
The parallel
parameter allows you to specify the number of chunks to process
in parallel.
API Calls
api.sheets.get
Imported NPM Packages
@flatfile/api@1.4.9+
@flatfile/listener@0.3.15+
@flatfile/plugin-record-hook@1.0.4+
@flatfile/util-common@0.1.1+
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.
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:
'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'
npm i @flatfile/plugin-autocast
import { autocast } from "@flatfile/plugin-autocast";
listener.use(autocast("sheetSlug"));