@flatfile/plugin-space-configure
Version:
A plugin for configuring a Flatfile Space.
40 lines (35 loc) • 2.03 kB
text/typescript
import { FlatfileListener, FlatfileEvent } from '@flatfile/listener';
import { Flatfile } from '@flatfile/api';
import { TickFunction } from '@flatfile/plugin-job-handler';
declare function dataChecklistPlugin(): (listener: FlatfileListener) => void;
/**
* `configureSpace` is a higher-order function that creates a plugin to configure a
* workspace using the Flatfile API. This function takes a setup factory that may either
* be a static setup configuration or a function that creates a setup configuration
* given a FlatfileEvent.
*
* When the job:ready for space:configure is emitted, the plugin will extract the necessary IDs, create a
* configuration using the provided setup factory, create a workbook with this configuration,
* and update the space with the workbook ID as the primary workbook ID.
*
* @param {SetupFactory} setup - The setup factory used to create the configuration for the workbook.
* This can either be a static Setup object or a function that creates a Setup object given a FlatfileEvent.
*
* @param {Function} callback - A callback function that is called after the workbook is created.
*
* @returns {Function} Returns a function that takes a FlatfileListener, adding a "space:configure" event listener
* and configuring the space when the event is emitted.
*/
declare function configureSpace(setupFactory: SetupFactory, callback?: (event: FlatfileEvent, workbookIds: string[], tick: TickFunction) => any | Promise<any>): (listener: FlatfileListener) => void;
type SetupFactory = Setup | ((event: FlatfileEvent) => Setup | Promise<Setup>);
type Setup = {
workbooks: PartialWb[];
space?: Partial<Flatfile.SpaceConfig>;
documents?: Flatfile.DocumentConfig[];
config?: {
maintainWorkbookOrder?: boolean;
};
};
type PartialWb = Partial<Flatfile.CreateWorkbookConfig>;
declare const dataChecklist: (spaceId: Flatfile.SpaceId) => Promise<void>;
export { type PartialWb, type Setup, type SetupFactory, configureSpace, dataChecklist, dataChecklistPlugin };