From a9c6d6eef6ecb7019493d64a174084ef5e1fcfb5 Mon Sep 17 00:00:00 2001 From: Alex Rock Date: Thu, 11 Apr 2024 22:58:15 -0600 Subject: [PATCH] feat: Angular fixes (#86) * feat: fix build bug, remove environmentId requirement and stop deleting spaces * feat: cleanup * feat: update dependencies --- package-lock.json | 34 +----- packages/angular/package.json | 8 +- .../angular/projects/spaces/package-lock.json | 20 ++-- packages/angular/projects/spaces/package.json | 4 +- .../space/space-frame/spaceFrame.component.ts | 100 ++++++++++-------- .../spaces/src/lib/space/space.component.ts | 4 +- .../projects/spaces/src/utils/addSpaceInfo.ts | 4 +- .../spaces/src/utils/createSimpleListener.ts | 24 +++-- .../spaces/src/utils/useInitializeSpace.ts | 6 +- packages/angular/src/app/app.component.ts | 11 +- packages/angular/src/app/reuse.component.ts | 11 +- packages/angular/src/app/sheet.ts | 23 ++++ .../angular/src/app/simplified.component.ts | 55 +++------- packages/angular/src/app/workbook.ts | 30 +----- 14 files changed, 150 insertions(+), 184 deletions(-) create mode 100644 packages/angular/src/app/sheet.ts diff --git a/package-lock.json b/package-lock.json index 9806ae07..6868a4a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31352,10 +31352,10 @@ "@angular/platform-browser": "^16.2.0", "@angular/platform-browser-dynamic": "^16.2.0", "@angular/router": "^16.2.0", - "@flatfile/api": "^1.6.7", - "@flatfile/embedded-utils": "1.1.14", - "@flatfile/listener": "1.0.1", - "@flatfile/plugin-record-hook": "1.4.1", + "@flatfile/api": "^1.7.11", + "@flatfile/embedded-utils": "^1.1.15", + "@flatfile/listener": "^1.0.2", + "@flatfile/plugin-record-hook": "^1.4.1", "rxjs": "~7.8.0", "symbol-observable": "^4.0.0", "tslib": "^2.3.0", @@ -32272,32 +32272,6 @@ "resolved": "https://registry.npmjs.org/@flatfile/cross-env-config/-/cross-env-config-0.0.4.tgz", "integrity": "sha512-mNaqtASTly4N09pjQts5zDnYXFLC891TCxJEiFUnil8p6lQciyd0gnPSnhJD0TTlO5817gX3mLE9RDoAETtIbg==" }, - "packages/angular/node_modules/@flatfile/embedded-utils": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/@flatfile/embedded-utils/-/embedded-utils-1.1.14.tgz", - "integrity": "sha512-34P6yVGKRBcKjME+krzEvlyztzgJVoeZnWx5CpXNpflKYMMnskEOOIJh5ytUtcvBI3gnfIn8Mv9dTe+cCpzS3Q==", - "dependencies": { - "@flatfile/api": "^1.7.11", - "@flatfile/listener": "^1.0.0", - "@flatfile/util-common": "^1.1.0", - "pubnub": "^7.2.2" - } - }, - "packages/angular/node_modules/@flatfile/listener": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@flatfile/listener/-/listener-1.0.1.tgz", - "integrity": "sha512-XClO1KhQDL9Q7zfTANcMeole7Q/2QaIhzttZI+p04PjB+bUlIvk+yUbHvhnLahNkvLHRoIth4p+oBj8tPC1cxA==", - "dependencies": { - "ansi-colors": "^4.1.3", - "cross-fetch": "^4.0.0", - "flat": "^5.0.2", - "pako": "^2.1.0", - "wildcard-match": "^5.1.2" - }, - "peerDependencies": { - "@flatfile/api": "^1.5.10" - } - }, "packages/angular/node_modules/@flatfile/plugin-record-hook": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/@flatfile/plugin-record-hook/-/plugin-record-hook-1.4.1.tgz", diff --git a/packages/angular/package.json b/packages/angular/package.json index bdc93506..e01249ba 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -18,10 +18,10 @@ "@angular/platform-browser": "^16.2.0", "@angular/platform-browser-dynamic": "^16.2.0", "@angular/router": "^16.2.0", - "@flatfile/api": "^1.6.7", - "@flatfile/embedded-utils": "1.1.14", - "@flatfile/listener": "1.0.1", - "@flatfile/plugin-record-hook": "1.4.1", + "@flatfile/api": "^1.7.11", + "@flatfile/embedded-utils": "^1.1.15", + "@flatfile/listener": "^1.0.2", + "@flatfile/plugin-record-hook": "^1.4.1", "rxjs": "~7.8.0", "symbol-observable": "^4.0.0", "tslib": "^2.3.0", diff --git a/packages/angular/projects/spaces/package-lock.json b/packages/angular/projects/spaces/package-lock.json index 84eb0460..ff2a4a9e 100644 --- a/packages/angular/projects/spaces/package-lock.json +++ b/packages/angular/projects/spaces/package-lock.json @@ -1,15 +1,15 @@ { "name": "@flatfile/angular-sdk", - "version": "1.1.0", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@flatfile/angular-sdk", - "version": "1.1.0", + "version": "1.3.0", "license": "MIT", "dependencies": { - "@flatfile/embedded-utils": "1.1.14", + "@flatfile/embedded-utils": "1.1.15", "@flatfile/hooks": "^1.3.2", "tslib": "^2.3.0" }, @@ -71,12 +71,12 @@ "integrity": "sha512-mNaqtASTly4N09pjQts5zDnYXFLC891TCxJEiFUnil8p6lQciyd0gnPSnhJD0TTlO5817gX3mLE9RDoAETtIbg==" }, "node_modules/@flatfile/embedded-utils": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/@flatfile/embedded-utils/-/embedded-utils-1.1.14.tgz", - "integrity": "sha512-34P6yVGKRBcKjME+krzEvlyztzgJVoeZnWx5CpXNpflKYMMnskEOOIJh5ytUtcvBI3gnfIn8Mv9dTe+cCpzS3Q==", + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/@flatfile/embedded-utils/-/embedded-utils-1.1.15.tgz", + "integrity": "sha512-xi0XWDo7ZdTHwDcNgfM3Mewg6w2kD14w1lpvQB0/KW6SOCjxSHd6CY/GazWVXf0DOSaaaW2UaiVrsH855cOwfA==", "dependencies": { "@flatfile/api": "^1.7.11", - "@flatfile/listener": "^1.0.0", + "@flatfile/listener": "^1.0.2", "@flatfile/util-common": "^1.1.0", "pubnub": "^7.2.2" } @@ -87,9 +87,9 @@ "integrity": "sha512-5HUBar6CnhhMU7lr4DnD79QfV4MtR1dUjZQJdt50HCS5pxy+tbF70JJSnoF/6itj+0hATkSC/Ep5C1XfABAGYw==" }, "node_modules/@flatfile/listener": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@flatfile/listener/-/listener-1.0.1.tgz", - "integrity": "sha512-XClO1KhQDL9Q7zfTANcMeole7Q/2QaIhzttZI+p04PjB+bUlIvk+yUbHvhnLahNkvLHRoIth4p+oBj8tPC1cxA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@flatfile/listener/-/listener-1.0.2.tgz", + "integrity": "sha512-/VW0UvSGBwDG85LbSOa9Nj2aCQ8pMNsaGqiK7N/tWCXtiwF0Pnani1KoESMsGN3ECS7IIrDNuGYmtlc1igUDiQ==", "dependencies": { "ansi-colors": "^4.1.3", "cross-fetch": "^4.0.0", diff --git a/packages/angular/projects/spaces/package.json b/packages/angular/projects/spaces/package.json index 00268c7d..db7a57da 100644 --- a/packages/angular/projects/spaces/package.json +++ b/packages/angular/projects/spaces/package.json @@ -1,6 +1,6 @@ { "name": "@flatfile/angular-sdk", - "version": "1.1.0", + "version": "1.3.0", "homepage": "https://flatfile.com/", "description": "Angular flatfile sdk", "license": "MIT", @@ -17,7 +17,7 @@ "@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" }, "dependencies": { - "@flatfile/embedded-utils": "1.1.14", + "@flatfile/embedded-utils": "1.1.15", "@flatfile/hooks": "^1.3.2", "tslib": "^2.3.0" }, diff --git a/packages/angular/projects/spaces/src/lib/space/space-frame/spaceFrame.component.ts b/packages/angular/projects/spaces/src/lib/space/space-frame/spaceFrame.component.ts index 540214bf..e9ec8382 100644 --- a/packages/angular/projects/spaces/src/lib/space/space-frame/spaceFrame.component.ts +++ b/packages/angular/projects/spaces/src/lib/space/space-frame/spaceFrame.component.ts @@ -1,19 +1,19 @@ -import { Component, Input, OnInit } from "@angular/core"; -import { ISpace, SimpleOnboarding } from "@flatfile/embedded-utils"; -import { Browser, FlatfileEvent } from '@flatfile/listener'; - -import addSpaceInfo from '../../../utils/addSpaceInfo'; -import authenticate from "../../../utils/authenticate"; -import createSimpleListener from "../../../utils/createSimpleListener"; -import { SpaceCloseModalPropsType } from "../space-close-modal/spaceCloseModal.component"; -import { getContainerStyles, getIframeStyles } from "./embeddedStyles"; - -export type SpaceFramePropsType = ISpace & { - spaceId: string; - spaceUrl: string; - localAccessToken: string; - handleCloseInstance: () => void; - closeInstance: boolean; +import { Component, Input, OnInit } from '@angular/core' +import { ISpace, SimpleOnboarding } from '@flatfile/embedded-utils' +import { Browser, FlatfileEvent } from '@flatfile/listener' + +import addSpaceInfo from '../../../utils/addSpaceInfo' +import authenticate from '../../../utils/authenticate' +import createSimpleListener from '../../../utils/createSimpleListener' +import { SpaceCloseModalPropsType } from '../space-close-modal/spaceCloseModal.component' +import { getContainerStyles, getIframeStyles } from './embeddedStyles' + +export type SpaceFramePropsType = ISpace & { + spaceId: string + spaceUrl: string + localAccessToken: string + handleCloseInstance: () => void + closeInstance: boolean } @Component({ @@ -28,21 +28,28 @@ export class SpaceFrame implements OnInit { {} as SpaceCloseModalPropsType iframeWrapperStyle = {} iframeStyle = {} - handlePostMessageInstance: ((event: MessageEvent<{ flatfileEvent: FlatfileEvent }>) => void) = () => {} + handlePostMessageInstance: ( + event: MessageEvent<{ flatfileEvent: FlatfileEvent }> + ) => void = () => {} - @Input({required: true}) spaceFrameProps: SpaceFramePropsType = {} as SpaceFramePropsType - @Input({required: true}) loading: boolean = false + @Input({ required: true }) spaceFrameProps: SpaceFramePropsType = + {} as SpaceFramePropsType + @Input({ required: true }) loading: boolean = false async created() { - const { listener, apiUrl, closeSpace, workbook } = this.spaceFrameProps; + const { listener, apiUrl, closeSpace, workbook } = this.spaceFrameProps const accessToken = this.spaceFrameProps.localAccessToken const simpleListenerSlug = workbook?.sheets?.[0].slug || 'slug' - const listenerInstance = listener || createSimpleListener({ - onRecordHook: (this.spaceFrameProps as SimpleOnboarding).onRecordHook, - onSubmit: (this.spaceFrameProps as SimpleOnboarding).onSubmit, - slug: simpleListenerSlug, - }) + const listenerInstance = + listener || + createSimpleListener({ + onRecordHook: (this.spaceFrameProps as SimpleOnboarding).onRecordHook, + onSubmit: (this.spaceFrameProps as SimpleOnboarding).onSubmit, + submitSettings: (this.spaceFrameProps as SimpleOnboarding) + .submitSettings, + slug: simpleListenerSlug, + }) if (listenerInstance && typeof apiUrl === 'string') { listenerInstance.mount( @@ -57,13 +64,15 @@ export class SpaceFrame implements OnInit { const dispatchEvent = (event: any) => { if (!event) return - const eventPayload = event.src ? event.src : event + const eventPayload = event.src || event const eventInstance = new FlatfileEvent(eventPayload, accessToken, apiUrl) return listenerInstance?.dispatchEvent(eventInstance) } - const handlePostMessage = (event: MessageEvent<{ flatfileEvent:FlatfileEvent }>) => { + const handlePostMessage = ( + event: MessageEvent<{ flatfileEvent: FlatfileEvent }> + ) => { const { flatfileEvent } = event.data if (!flatfileEvent) return if ( @@ -91,24 +100,27 @@ export class SpaceFrame implements OnInit { sidebarConfig, userInfo, spaceId, - apiUrl = "https://platform.flatfile.com/api" - } = this.spaceFrameProps; - - const accessToken = this.spaceFrameProps.localAccessToken; - - if(publishableKey) { - const fullAccessApi = authenticate(accessToken, apiUrl); - await addSpaceInfo({ - publishableKey, - workbook, - environmentId, - document, - themeConfig, - sidebarConfig, - userInfo - }, spaceId, fullAccessApi); + apiUrl = 'https://platform.flatfile.com/api', + } = this.spaceFrameProps + + const accessToken = this.spaceFrameProps.localAccessToken + + if (publishableKey) { + const fullAccessApi = authenticate(accessToken, apiUrl) + await addSpaceInfo( + { + publishableKey, + workbook, + environmentId, + document, + themeConfig, + sidebarConfig, + userInfo, + }, + spaceId, + fullAccessApi + ) } - } openCloseModalDialog() { diff --git a/packages/angular/projects/spaces/src/lib/space/space.component.ts b/packages/angular/projects/spaces/src/lib/space/space.component.ts index 8de2e274..caa6ef31 100644 --- a/packages/angular/projects/spaces/src/lib/space/space.component.ts +++ b/packages/angular/projects/spaces/src/lib/space/space.component.ts @@ -5,7 +5,7 @@ import useInitializeSpace from '../../utils/useInitializeSpace'; import { SpaceFramePropsType } from './space-frame/spaceFrame.component'; import { SpaceService } from './space.service'; -type ReusedOrObording = ReusedSpaceWithAccessToken | SimpleOnboarding +type ReusedOrOnboarding = ReusedSpaceWithAccessToken | SimpleOnboarding @Component({ selector: 'flatfile-space', @@ -43,7 +43,7 @@ export class Space implements OnInit{ this.closeInstance = true; } - initSpace = async (spaceProps: ReusedOrObording) => { + initSpace = async (spaceProps: ReusedOrOnboarding) => { this.closeInstance = false const { space, initializeSpace } = useInitializeSpace(spaceProps as SimpleOnboarding); diff --git a/packages/angular/projects/spaces/src/utils/addSpaceInfo.ts b/packages/angular/projects/spaces/src/utils/addSpaceInfo.ts index 3700c8e9..67ff0938 100644 --- a/packages/angular/projects/spaces/src/utils/addSpaceInfo.ts +++ b/packages/angular/projects/spaces/src/utils/addSpaceInfo.ts @@ -23,7 +23,7 @@ const addSpaceInfo = async ( if (workbook) { const localWorkbook = await api.workbooks.create({ spaceId, - environmentId, + ...(environmentId ? { environmentId } : {}), ...workbook, }) if (!localWorkbook || !localWorkbook.data || !localWorkbook.data.id) { @@ -32,7 +32,7 @@ const addSpaceInfo = async ( } const updatedSpace = await api.spaces.update(spaceId, { - environmentId, + ...(environmentId ? { environmentId } : {}), metadata: { theme: themeConfig, sidebarConfig: sidebarConfig || { showSidebar: false }, diff --git a/packages/angular/projects/spaces/src/utils/createSimpleListener.ts b/packages/angular/projects/spaces/src/utils/createSimpleListener.ts index 32c0d472..6a420bab 100644 --- a/packages/angular/projects/spaces/src/utils/createSimpleListener.ts +++ b/packages/angular/projects/spaces/src/utils/createSimpleListener.ts @@ -1,5 +1,6 @@ -import api from '@flatfile/api' +import { FlatfileClient } from '@flatfile/api' import { + DefaultSubmitSettings, JobHandler, SheetHandler, SimpleOnboarding, @@ -9,14 +10,20 @@ import { FlatfileEvent, FlatfileListener } from '@flatfile/listener' import { recordHook } from '@flatfile/plugin-record-hook' interface SimpleListenerType - extends Pick { + extends Pick< + SimpleOnboarding, + 'onRecordHook' | 'onSubmit' | 'submitSettings' + > { slug: string } +const api = new FlatfileClient() + const createSimpleListener = ({ onRecordHook, onSubmit, slug, + submitSettings, }: SimpleListenerType) => FlatfileListener.create((client: FlatfileListener) => { if (onRecordHook) { @@ -24,12 +31,12 @@ const createSimpleListener = ({ recordHook( slug, async (record: FlatfileRecord, event?: FlatfileEvent) => - // @ts-ignore - something weird with the `data` prop and the types upstream in the packages being declared in different places, but overall this is fine onRecordHook(record, event) ) ) } if (onSubmit) { + const onSubmitSettings = { ...DefaultSubmitSettings, ...submitSettings } client.filter( { job: 'workbook:simpleSubmitAction' }, (configure: FlatfileListener) => { @@ -46,21 +53,22 @@ const createSimpleListener = ({ // this assumes we are only allowing 1 sheet here (which we've talked about doing initially) const sheet = new SheetHandler(workbookSheets[0].id) - await onSubmit({ job, sheet }) + if (onSubmit) { + await onSubmit({ job, sheet, event }) + } await api.jobs.complete(jobId, { outcome: { message: 'complete', }, }) - await api.spaces.delete(spaceId) + if (onSubmitSettings.deleteSpaceAfterSubmit) { + await api.spaces.archiveSpace(spaceId) + } } catch (error: any) { if (jobId) { await api.jobs.cancel(jobId) } - if (spaceId) { - await api.spaces.delete(spaceId) - } console.error('Error:', error.stack) } }) diff --git a/packages/angular/projects/spaces/src/utils/useInitializeSpace.ts b/packages/angular/projects/spaces/src/utils/useInitializeSpace.ts index fd0ba0f1..6666f883 100644 --- a/packages/angular/projects/spaces/src/utils/useInitializeSpace.ts +++ b/packages/angular/projects/spaces/src/utils/useInitializeSpace.ts @@ -38,10 +38,6 @@ const useInitializeSpace = ( throw new Error('Missing required publishable key') } - if (!environmentId) { - throw new Error('Missing required environment id') - } - const limitedAccessApi = authenticate(publishableKey, apiUrl) const spaceRequestBody = { name, @@ -60,7 +56,7 @@ const useInitializeSpace = ( try { space = await limitedAccessApi.spaces.create({ - environmentId, + ...(environmentId ? { environmentId } : {}), ...spaceRequestBody, }) } catch (error) { diff --git a/packages/angular/src/app/app.component.ts b/packages/angular/src/app/app.component.ts index 11fc3510..51d11360 100644 --- a/packages/angular/src/app/app.component.ts +++ b/packages/angular/src/app/app.component.ts @@ -1,7 +1,7 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' import { ISpace, SpaceService } from '@flatfile/angular' -import { workbook } from "./workbook"; -import { listener } from "./listener"; +import { workbook } from './workbook' +import { listener } from './listener' @Component({ selector: 'app-root', @@ -9,13 +9,13 @@ import { listener } from "./listener"; styleUrls: ['./app.component.scss'], }) export class AppComponent { - showSpace: boolean = false; + showSpace: boolean = false constructor(private spaceService: SpaceService) {} toggleSpace() { this.spaceService.OpenEmbed() - this.showSpace = !this.showSpace; + this.showSpace = !this.showSpace } closeSpace() { @@ -24,7 +24,6 @@ export class AppComponent { spaceProps: ISpace = { name: 'Trste!', - environmentId: 'us_env_1234', publishableKey: 'sk_1234', workbook, listener, diff --git a/packages/angular/src/app/reuse.component.ts b/packages/angular/src/app/reuse.component.ts index 7e017a7c..91213e6b 100644 --- a/packages/angular/src/app/reuse.component.ts +++ b/packages/angular/src/app/reuse.component.ts @@ -1,6 +1,6 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' import { ISpace, SpaceService } from '@flatfile/angular' -import { listener } from "./listener"; +import { listener } from './listener' @Component({ selector: 'app-root', @@ -8,13 +8,13 @@ import { listener } from "./listener"; styleUrls: ['./app.component.scss'], }) export class AppComponent { - showSpace: boolean = false; + showSpace: boolean = false constructor(private spaceService: SpaceService) {} toggleSpace() { this.spaceService.OpenEmbed() - this.showSpace = !this.showSpace; + this.showSpace = !this.showSpace } closeSpace() { @@ -24,9 +24,8 @@ export class AppComponent { spaceProps: ISpace = { space: { id: 'us_sp_123', - accessToken: 'sk_1234' + accessToken: 'sk_1234', }, - environmentId: 'us_env_1234', listener, closeSpace: { operation: 'submitActionFg', diff --git a/packages/angular/src/app/sheet.ts b/packages/angular/src/app/sheet.ts new file mode 100644 index 00000000..2ecee15d --- /dev/null +++ b/packages/angular/src/app/sheet.ts @@ -0,0 +1,23 @@ +import { Flatfile } from '@flatfile/api' + +export const sheet: Flatfile.SheetConfig = { + 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', + }, + ], +} diff --git a/packages/angular/src/app/simplified.component.ts b/packages/angular/src/app/simplified.component.ts index 08ad33f6..2a409a18 100644 --- a/packages/angular/src/app/simplified.component.ts +++ b/packages/angular/src/app/simplified.component.ts @@ -1,61 +1,40 @@ -import { Component, OnInit } from '@angular/core'; -import { Flatfile } from '@flatfile/api' - -const sheet = { - name: 'Contacts', - slug: 'contacts', - fields: [ - { - key: 'firstName', - type: 'string', - label: 'First Name', - config: undefined, - } as Flatfile.Property.String, - { - key: 'lastName', - type: 'string', - label: 'Last Name', - config: undefined, - } as Flatfile.Property.String, - { - key: 'email', - type: 'string', - label: 'Email', - config: undefined, - } as Flatfile.Property.String, - ], -} +import { Component, OnInit } from '@angular/core' +import { sheet } from './sheet' @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + styleUrls: ['./app.component.scss'], }) export class AppComponent implements OnInit { - showSpace: boolean = false; - data: any; + showSpace: boolean = false + data: any constructor() {} - ngOnInit() { } - - title = 'angular'; + ngOnInit() {} + title = 'angular' toggleSpace() { - this.showSpace = !this.showSpace; + this.showSpace = !this.showSpace } closeSpace() { - this.showSpace = false; + this.showSpace = false } spaceProps = { name: 'My space!', - environmentId: 'us_env_1234', publishableKey: 'sk_1234', sheet, - onSubmit: async ({ job, sheet, }: { job?: any, sheet?: any }): Promise => { + onSubmit: async ({ + job, + sheet, + }: { + job?: any + sheet?: any + }): Promise => { const data = await sheet.allData() console.log('onSubmit', data) }, @@ -71,6 +50,6 @@ export class AppComponent implements OnInit { closeSpace: { operation: 'submitActionFg', onClose: this.closeSpace.bind(this), - } + }, } } diff --git a/packages/angular/src/app/workbook.ts b/packages/angular/src/app/workbook.ts index cfa1756c..b77374f4 100644 --- a/packages/angular/src/app/workbook.ts +++ b/packages/angular/src/app/workbook.ts @@ -1,34 +1,10 @@ import { Flatfile } from '@flatfile/api' +import { sheet } from './sheet' -export const workbook: Pick< - Flatfile.CreateWorkbookConfig, - 'name' | 'labels' | 'sheets' | 'actions' -> = { +export const workbook: Flatfile.CreateWorkbookConfig = { 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', - }, - ], - }, - ], + sheets: [sheet], actions: [ { operation: 'submitActionFg',