diff --git a/.changeset/few-sloths-clean.md b/.changeset/few-sloths-clean.md new file mode 100644 index 000000000..42711fade --- /dev/null +++ b/.changeset/few-sloths-clean.md @@ -0,0 +1,5 @@ +--- +'@flatfile/plugin-space-configure': minor +--- + +This release adds a data checklist utility that can be used to create a Data Checklist Document diff --git a/flatfilers/sandbox/src/index.ts b/flatfilers/sandbox/src/index.ts index f6ab47330..df55995ff 100644 --- a/flatfilers/sandbox/src/index.ts +++ b/flatfilers/sandbox/src/index.ts @@ -1,6 +1,12 @@ -import type { FlatfileListener } from '@flatfile/listener' +import type { FlatfileEvent, FlatfileListener } from '@flatfile/listener' +import { exportDelimitedZip } from '@flatfile/plugin-export-delimited-zip' +import { type TickFunction } from '@flatfile/plugin-job-handler' +import { JSONExtractor } from '@flatfile/plugin-json-extractor' import { bulkRecordHook } from '@flatfile/plugin-record-hook' -import { configureSpace } from '@flatfile/plugin-space-configure' +import { + configureSpace, + createDataChecklist, +} from '@flatfile/plugin-space-configure' import { storedConstraint } from '@flatfile/plugin-stored-constraints' import { ExcelExtractor } from '@flatfile/plugin-xlsx-extractor' import { contacts } from './sheets/contacts' @@ -32,20 +38,130 @@ export default async function (listener: FlatfileListener) { ) ) listener.use( - configureSpace({ - workbooks: [ - { - name: 'Sandbox', - sheets: [contacts], - actions: [ - { - operation: 'export-delimited-zip', - label: 'Export to Delimited ZIP', - mode: 'foreground', - }, - ], - }, - ], - }) + configureSpace( + { + workbooks: [ + { + name: 'Sandbox', + sheets: [ + { + name: 'Sales', + slug: 'sales', + fields: [ + { + key: 'date', + type: 'string', + label: 'Date', + description: 'The date of the sale', + constraints: [ + { + type: 'required', + }, + { + type: 'unique', + }, + ], + }, + { + key: 'product', + type: 'string', + label: 'Product', + description: 'The product sold', + constraints: [ + { + type: 'required', + }, + ], + }, + { + key: 'category', + type: 'string', + label: 'Category', + description: 'The category of the product', + }, + { + key: 'region', + type: 'string', + label: 'Region', + description: 'The region of the sale', + }, + { + key: 'salesAmount', + type: 'number', + label: 'Sales Amount', + description: 'The amount of the sale', + }, + ], + actions: [ + { + operation: 'generateExampleRecords', + label: 'Generate Example Records', + description: + 'This custom action code generates example records using Anthropic.', + primary: false, + mode: 'foreground', + }, + ], + }, + { + name: 'Sales 2', + slug: 'sales-2', + fields: [ + { + key: 'date', + type: 'string', + label: 'Date', + }, + { + key: 'product', + type: 'string', + label: 'Product', + }, + { + key: 'category', + type: 'string', + label: 'Category', + }, + { + key: 'region', + type: 'string', + label: 'Region', + }, + { + key: 'salesAmount', + type: 'number', + label: 'Sales Amount', + }, + ], + actions: [ + { + operation: 'export-external-api', + label: 'Export to External API', + description: + 'This custom action code exports the records in the Sales sheet to an external API.', + primary: false, + mode: 'foreground', + }, + ], + }, + ], + actions: [ + { + operation: 'export-delimited-zip', + label: 'Export to Delimited ZIP', + mode: 'foreground', + }, + ], + }, + ], + }, + async ( + event: FlatfileEvent, + _workbookIds: string[], + _tick: TickFunction + ) => { + await createDataChecklist(event.context.spaceId) + } + ) ) } diff --git a/package-lock.json b/package-lock.json index cdc1aea0e..a4b2b1b03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -296,7 +296,6 @@ "flatfilers/playground": { "name": "@private/playground", "version": "0.0.0", - "extraneous": true, "license": "ISC", "dependencies": { "@flatfile/api": "^1.9.19", @@ -4999,6 +4998,10 @@ "node": ">=14" } }, + "node_modules/@private/playground": { + "resolved": "flatfilers/playground", + "link": true + }, "node_modules/@private/sandbox": { "resolved": "flatfilers/sandbox", "link": true @@ -17813,7 +17816,7 @@ }, "plugins/record-hook": { "name": "@flatfile/plugin-record-hook", - "version": "2.0.0", + "version": "2.0.1", "license": "ISC", "dependencies": { "@flatfile/util-common": "^1.6.0" @@ -17917,7 +17920,7 @@ }, "plugins/stored-constraints": { "name": "@flatfile/plugin-stored-constraints", - "version": "1.0.0", + "version": "1.0.1", "license": "ISC", "dependencies": { "country-state-city": "^3.2.1", @@ -18017,10 +18020,10 @@ }, "plugins/xlsx-extractor": { "name": "@flatfile/plugin-xlsx-extractor", - "version": "3.4.1", + "version": "3.5.1", "license": "ISC", "dependencies": { - "@flatfile/util-extractor": "^2.3.0", + "@flatfile/util-extractor": "^2.5.0", "remeda": "^1.14.0", "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" }, @@ -18191,7 +18194,7 @@ }, "utils/extractor": { "name": "@flatfile/util-extractor", - "version": "2.4.1", + "version": "2.5.0", "license": "ISC", "dependencies": { "@flatfile/util-common": "^1.6.0", diff --git a/plugins/space-configure/src/index.ts b/plugins/space-configure/src/index.ts index 2af05e817..ec931e448 100644 --- a/plugins/space-configure/src/index.ts +++ b/plugins/space-configure/src/index.ts @@ -1 +1,2 @@ export * from './space.configure' +export * from './utils/data.checklist' diff --git a/plugins/space-configure/src/utils/data.checklist.ts b/plugins/space-configure/src/utils/data.checklist.ts new file mode 100644 index 000000000..34db12259 --- /dev/null +++ b/plugins/space-configure/src/utils/data.checklist.ts @@ -0,0 +1,55 @@ +import { Flatfile, FlatfileClient } from '@flatfile/api' + +const api = new FlatfileClient() + +export const createDataChecklist = async (spaceId: Flatfile.SpaceId) => { + const { data: workbooks } = await api.workbooks.list({ spaceId }) + + let body = `
| Field Name | +Data Type | +Description | +
|---|