agent:created or agent:updated events), this plugin identifies relevant workbooks and initiates an update process.
Its primary use case is to ensure that all workbooks associated with a particular configuration stay up-to-date with the latest schema definitions without manual intervention. It works by creating a job to apply the new schema via a user-defined updater function. After the schema is updated, it cleverly re-triggers all data hooks on all records in the updated sheets, ensuring data validity and transformations are re-evaluated against the new schema.
This plugin should be deployed in a server-side listener.
Installation
Configuration & Parameters
The rollout plugin accepts a configuration object with the following parameters:namespace (required)
- Type:
string - Description: A string used to filter which spaces the plugin should operate on. The plugin will only consider spaces matching this namespace. The expected format is typically
workbook:your-namespace.
dev (required)
- Type:
boolean - Description: When set to
true, the plugin will also trigger an update check when the agent starts up in a local development environment (i.e., not running on AWS Lambda). This is useful for testing changes locally without needing to deploy a new agent version. - Default: Effectively
false- updates in local development are suppressed unless this is explicitly set totrue.
updater (required)
- Type:
(space: Flatfile.Space, workbooks: Flatfile.Workbook[]) => Promise<undefined | Flatfile.Workbook[]> - Description: An asynchronous callback function you provide to perform the actual schema updates. It receives the
spacebeing processed and a list of itsworkbooks. You are responsible for using the Flatfile API within this function to apply your new schema to the workbooks. The function should return an array of the workbooks that were successfully updated.
Usage Examples
API Reference
rollout(config)
Initializes the rollout plugin. It sets up listeners for agent deployment events and a job handler to perform the updates. It relies on a user-provided updater function to apply the specific schema changes.
Parameters:
config(object): Configuration object with the following properties:namespace(string, required): The namespace to filter spaces for updatesdev(boolean, required): Set totrueto enable updates on local agent reloadsupdater(function, required): Async function that performs the schema update
.root property (also a listener callback). The main callback handles the space:auto-update job, while the .root callback handles agent:created and agent:updated events.
Troubleshooting
Updates not triggering
- Ensure the
agent:createdoragent:updatedevents are firing upon deployment - Check that the target space has the correct namespace and the required secret (
FF_AUTO_UPDATEorFF_AUTO_UPDATE_DEV) is set to'true'
Local updates not working
- Make sure you have set
dev: truein the plugin configuration
Hooks not re-running
- Verify that your
updaterfunction is returning an array containing the workbooks that you successfully updated - If an empty or
undefinedvalue is returned, the hook re-triggering step will be skipped
Notes
Default Behavior
By default, the plugin will only trigger updates for production spaces that have a secret namedFF_AUTO_UPDATE with a value of 'true'. If the dev: true option is used, it will trigger updates for development spaces that have a secret named FF_AUTO_UPDATE_DEV with a value of 'true'. This secret-based mechanism acts as an explicit opt-in for each space, preventing accidental updates.
Special Considerations
- Dual Listener Registration: The plugin returns a function with a
.rootproperty. You MUST register both. The main function handles the job execution and should be on a namespaced listener. The.rootfunction handles the global events that trigger the job and must be on the root listener. - Server-Side Only: This plugin is designed to run in a server-side listener environment, not in the browser.
- Opt-In via Secrets: The plugin will not update a space unless it contains a specific secret. For production environments, a secret named
FF_AUTO_UPDATEmust exist with the value'true'. For local development (withdev: true), the secret must beFF_AUTO_UPDATE_DEVwith the value'true'. - Hook Re-triggering: To re-run data hooks after a schema change, the plugin updates the metadata of every record in the updated sheets by adding a
_autoUpdateKeywith a random UUID. This modification forces Flatfile to re-evaluate each record.
API Permissions
The agent using this plugin requires API permissions for the following actions:space:read(forspaces.list,spaces.get)secret:read(forsecrets.list)workbook:read(forworkbooks.list)job:write(forjobs.create)- Your
updaterfunction will likely require additional permissions, such assheet:writeto update sheet configurations.

