import api from "@flatfile/api";
import { configureSpace } from "@flatfile/plugin-space-configure";
export default function (listener) {
listener.use(
configureSpace(
{
workbooks: [
{
name: "All Data",
labels: ["pinned"],
sheets: [
{
name: "Contacts",
slug: "contacts",
fields: [
{
key: "firstName",
type: "string",
label: "First Name",
},
{
key: "lastName",
type: "string",
label: "Last Name",
},
{
key: "email",
type: "string",
label: "Email",
},
],
actions: [
{
operation: "sendToPeople",
mode: "background",
label: "Send to selected People",
description: "Send this data to those selected.",
constraints: [{ type: "hasSelection" }],
},
],
},
{
name: "Sheet 2",
slug: "sheet2",
fields: [
{
key: "firstName",
type: "string",
label: "First Name",
},
{
key: "lastName",
type: "string",
label: "Last Name",
},
{
key: "email",
type: "string",
label: "Email",
},
],
},
],
actions: [
{
operation: "submitActionFg",
mode: "foreground",
label: "Submit foreground",
description: "Submit data to webhook.site",
primary: true,
},
],
},
],
},
async (event, workbookIds, tick) => {
const { spaceId } = event.context;
await api.documents.create(spaceId, {
title: "Getting Started",
body:
"# Welcome\n" +
"### Say hello to your first customer Space in the new Flatfile!\n" +
"Let's begin by first getting acquainted with what you're seeing in your Space initially.\n" +
"---\n",
});
await tick(80, "Document created");
}
)
);
}
// See full code example (https://github.com/FlatFilers/flatfile-docs-kitchen-sink/blob/main/javascript/dynamic-configurations/index.js)