A plugin for configuring a Flatfile Space from a Space Template.
npm i @flatfile/plugin-space-configure-from-template
The @flatfile/plugin-space-configure-from-template
plugin streamlines the setup of a new Flatfile Space from a Space Template.
Event Type:
listener.on('space:configure')
When embedding Flatfile, this plugin should be deployed in a server-side listener. Learn more
callback
- function
The callback
parameter receives three arguments: event
, workbookIds
, and a tick
function. The tick
function can be used to update the Job's progress. The callback
function is invoked once the Space and Workbooks are fully configured.
api.spaces.update
api.workbooks.create
api.documents.create
The @flatfile/plugin-space-configure-from-template
plugin simplifies the setup of a new Flatfile Space from a Space Template.
Designed for server-side listeners, it auto-configures the Space using the supplied settings.
npm i @flatfile/plugin-space-configure-from-template
listener.ts
import { configureSpaceFromTemplate } from "@flatfile/plugin-space-configure-from-template";
export default function (listener: FlatfileListener) {
listener.use(configureSpaceFromTemplate());
}
listener.ts
import api from "@flatfile/api";
import type { FlatfileListener } from "@flatfile/listener";
import { configureSpaceFromTemplate } from "@flatfile/plugin-space-configure-from-template";
import { contactsSheet } from "./contactsSheet";
import { companiesSheet } from "./companiesSheet";
export default function (listener: FlatfileListener) {
listener.use(
configureSpaceFromTemplate(
async (event, workbookIds, tick) => {
const { spaceId } = event.context;
// Callback is invoked once the Space and Workbooks are fully configured.
// Job progress will be at 50% when the callback is invoked.
tick(51, "Running callback!");
// Do something...
await tick(99, "Callback complete!");
}
)
);
}