From fac647a673d4662efa9612bae73fab4604b928fb Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 17:32:39 -0500 Subject: [PATCH 1/7] Add space-configure-from-template plugin --- package-lock.json | 34 +++++- .../CHANGELOG.md | 0 .../space-configure-from-template/README.md | 81 ++++++++++++++ .../package.json | 76 +++++++++++++ .../src/index.ts | 1 + .../src/space.configure.e2e.spec.ts | 69 ++++++++++++ .../src/space.configure.from.template.ts | 105 ++++++++++++++++++ .../tsup.config.mjs | 3 + .../vitest.config.ts | 4 + 9 files changed, 367 insertions(+), 6 deletions(-) create mode 100644 plugins/space-configure-from-template/CHANGELOG.md create mode 100644 plugins/space-configure-from-template/README.md create mode 100644 plugins/space-configure-from-template/package.json create mode 100644 plugins/space-configure-from-template/src/index.ts create mode 100644 plugins/space-configure-from-template/src/space.configure.e2e.spec.ts create mode 100644 plugins/space-configure-from-template/src/space.configure.from.template.ts create mode 100644 plugins/space-configure-from-template/tsup.config.mjs create mode 100644 plugins/space-configure-from-template/vitest.config.ts diff --git a/package-lock.json b/package-lock.json index bf80d70dc..186b4ac5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -293,6 +293,7 @@ "flatfilers/playground": { "name": "@private/playground", "version": "0.0.0", + "extraneous": true, "license": "ISC", "dependencies": { "@flatfile/api": "^1.9.19", @@ -4109,6 +4110,10 @@ "resolved": "plugins/space-configure", "link": true }, + "node_modules/@flatfile/plugin-space-configure-from-template": { + "resolved": "plugins/space-configure-from-template", + "link": true + }, "node_modules/@flatfile/plugin-stored-constraints": { "resolved": "plugins/stored-constraints", "link": true @@ -4991,10 +4996,6 @@ "node": ">=14" } }, - "node_modules/@private/playground": { - "resolved": "flatfilers/playground", - "link": true - }, "node_modules/@private/sandbox": { "resolved": "flatfilers/sandbox", "link": true @@ -17870,6 +17871,27 @@ "@flatfile/listener": "^1.1.0" } }, + "plugins/space-configure-from-template": { + "name": "@flatfile/plugin-space-configure-from-template", + "version": "0.0.1", + "license": "ISC", + "dependencies": { + "@flatfile/plugin-job-handler": "^0.8.1" + }, + "devDependencies": { + "@flatfile/api": "^1.9.19", + "@flatfile/bundler-config-tsup": "^0.2.0", + "@flatfile/config-vitest": "^0.0.0", + "@flatfile/utils-testing": "^0.5.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@flatfile/api": "^1.9.19", + "@flatfile/listener": "^1.1.0" + } + }, "plugins/sql-ddl-converter": { "name": "@flatfile/plugin-convert-sql-ddl", "version": "0.4.1", @@ -17932,7 +17954,7 @@ }, "plugins/view-mapped": { "name": "@flatfile/plugin-view-mapped", - "version": "1.3.1", + "version": "1.3.2", "license": "ISC", "dependencies": { "@flatfile/api": "^1.9.19", @@ -18167,7 +18189,7 @@ }, "utils/extractor": { "name": "@flatfile/util-extractor", - "version": "2.4.0", + "version": "2.4.1", "license": "ISC", "dependencies": { "@flatfile/util-common": "^1.6.0", diff --git a/plugins/space-configure-from-template/CHANGELOG.md b/plugins/space-configure-from-template/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/space-configure-from-template/README.md b/plugins/space-configure-from-template/README.md new file mode 100644 index 000000000..299e65d27 --- /dev/null +++ b/plugins/space-configure-from-template/README.md @@ -0,0 +1,81 @@ + + +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](/docs/orchestration/listeners#listener-types) + + +## Parameters + +#### `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 Calls + +- `api.spaces.update` +- `api.workbooks.create` +- `api.documents.create` + + + +## Usage + +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. + +#### Install + +```bash install +npm i @flatfile/plugin-space-configure-from-template +``` + +#### Example + +#### `listener.ts` + +```typescript listener.ts +import { configureSpaceFromTemplate } from "@flatfile/plugin-space-configure-from-template"; + +export default function (listener: FlatfileListener) { + listener.use(configureSpaceFromTemplate()); +} +``` + + +## Example with Callback + +#### `listener.ts` + +```typescript 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!"); + } + ) + ); +} +``` diff --git a/plugins/space-configure-from-template/package.json b/plugins/space-configure-from-template/package.json new file mode 100644 index 000000000..d698df9bc --- /dev/null +++ b/plugins/space-configure-from-template/package.json @@ -0,0 +1,76 @@ +{ + "name": "@flatfile/plugin-space-configure-from-template", + "version": "0.0.1", + "url": "https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/space-configure-from-template", + "description": "A plugin for configuring a Flatfile Space from a Space Template.", + "registryMetadata": { + "category": "core" + }, + "type": "module", + "engines": { + "node": ">= 18" + }, + "exports": { + ".": { + "node": { + "types": { + "import": "./dist/index.d.ts", + "require": "./dist/index.d.cts" + }, + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, + "browser": { + "types": { + "import": "./dist/index.d.ts", + "require": "./dist/index.d.cts" + }, + "import": "./dist/index.browser.js", + "require": "./dist/index.browser.cjs" + }, + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "source": "./src/index.ts", + "types": "./dist/index.d.ts", + "files": [ + "dist/**" + ], + "scripts": { + "build": "tsup", + "build:watch": "tsup --watch", + "build:prod": "NODE_ENV=production tsup", + "checks": "tsc --noEmit && attw --pack . && publint .", + "lint": "tsc --noEmit", + "test": "vitest run --mode defaults src/*.spec.ts --passWithNoTests", + "test:unit": "vitest run --mode defaults src/*.spec.ts --passWithNoTests --exclude src/*.e2e.spec.ts", + "test:e2e": "vitest run --mode defaults src/*.e2e.spec.ts --passWithNoTests --no-file-parallelism" + }, + "keywords": [ + "flatfile-plugins", + "category-core" + ], + "author": "Flatfile, Inc.", + "repository": { + "type": "git", + "url": "git+https://github.com/FlatFilers/flatfile-plugins.git", + "directory": "plugins/space-configure-from-template" + }, + "license": "ISC", + "dependencies": { + "@flatfile/plugin-job-handler": "^0.8.1" + }, + "peerDependencies": { + "@flatfile/api": "^1.9.19", + "@flatfile/listener": "^1.1.0" + }, + "devDependencies": { + "@flatfile/api": "^1.9.19", + "@flatfile/bundler-config-tsup": "^0.2.0", + "@flatfile/config-vitest": "^0.0.0", + "@flatfile/utils-testing": "^0.5.0" + } +} diff --git a/plugins/space-configure-from-template/src/index.ts b/plugins/space-configure-from-template/src/index.ts new file mode 100644 index 000000000..94345f028 --- /dev/null +++ b/plugins/space-configure-from-template/src/index.ts @@ -0,0 +1 @@ +export * from './space.configure.from.template' diff --git a/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts b/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts new file mode 100644 index 000000000..c4a83f87e --- /dev/null +++ b/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts @@ -0,0 +1,69 @@ +import { FlatfileClient } from '@flatfile/api' +import { + deleteSpace, + setupDriver, + setupSpace, + TestListener, +} from '@flatfile/utils-testing' +import { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, +} from 'vitest' +import { configureSpaceFromTemplate } from '.' + +const api = new FlatfileClient() + +describe('SpaceConfigureFromTemplate plugin e2e tests', () => { + const mockFn = vi.fn() + const listener = new TestListener() + const driver = setupDriver() + let spaceId: string + + beforeAll(async () => { + await driver.start() + listener.mount(driver) + + listener.use(configureSpaceFromTemplate(mockFn)) + + const space = await setupSpace() + spaceId = space.id + }) + + afterAll(async () => { + await deleteSpace(spaceId) + + driver.shutdown() + }) + + beforeEach(() => { + listener.resetCount() + }) + + afterEach(() => { + listener.reset() + }) + + it('should configure a space & run callback', async () => { + await listener.waitFor('job:ready', 1, 'space:configure') + + const space = await api.spaces.get(spaceId) + const workspace = await api.workbooks.get(space.data.primaryWorkbookId!) + + // expect(workspace.data.name).toBe(setup.workbooks[0].name) + // expect(workspace.data.labels).toMatchObject(setup.workbooks[0].labels!) + // expect(workspace.data.sheets![0].name).toBe( + // setup.workbooks[0].sheets![0].name + // ) + // expect(workspace.data.sheets![0].config).toMatchObject( + // setup.workbooks[0].sheets![0] + // ) + // expect(workspace.data.actions).toMatchObject(setup.workbooks[0].actions!) + // expect(mockFn).toHaveBeenCalled() + }) +}) diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.ts b/plugins/space-configure-from-template/src/space.configure.from.template.ts new file mode 100644 index 000000000..ca00cbe95 --- /dev/null +++ b/plugins/space-configure-from-template/src/space.configure.from.template.ts @@ -0,0 +1,105 @@ +import type { Flatfile } from '@flatfile/api' +import { FlatfileClient } from '@flatfile/api' +import type { FlatfileEvent, FlatfileListener } from '@flatfile/listener' +import { type TickFunction, jobHandler } from '@flatfile/plugin-job-handler' + +const api = new FlatfileClient() + +/** + * `configureSpaceFromTemplate` 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 {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. + */ +export function configureSpaceFromTemplate( + callback?: ( + event: FlatfileEvent, + workbookIds: string[], + tick: TickFunction + ) => any | Promise +) { + return function (listener: FlatfileListener) { + listener.use( + jobHandler('space:configure', async (event, tick) => { + const { spaceId, environmentId, appId } = event.context + const app = await api.apps.get(appId) + + // Get all the space templates for the app sorted by creation date, oldest first + const spaceTemplates = await api.spaces.list({ + namespace: app.data.namespace, + isCollaborative: true, // TODO: change to isTemplate + sortField: 'createdAt', + sortDirection: 'asc', + }) + + if (spaceTemplates.data.length === 0) { + throw new Error('No space template found') + } + + // Get the oldest space template + const spaceTemplate = spaceTemplates.data[0] + const spaceTemplateId = spaceTemplate.id + + // Get all the workbooks for the space template + const workbooks = await api.workbooks.list({ + spaceId: spaceTemplateId, + }) + + // Convert workbooks from the template to workbook configs + const workbookConfigs: Flatfile.CreateWorkbookConfig[] = workbooks.data.map((workbook) => ({ + name: workbook.name, + labels: workbook.labels, + spaceId: spaceId, + environmentId: environmentId, + namespace: app.data.namespace, + sheets: workbook.sheets.map((sheet) => ({ + ...sheet.config, + })), + actions: workbook.actions, + settings: workbook.settings, + metadata: workbook.metadata, + treatments: workbook.treatments, + })) + + // Create the workbooks + const workbookIds = await Promise.all( + workbookConfigs.map(async (workbookConfig) => { + const workbook = await api.workbooks.create(workbookConfig) + return workbook.data.id + }) + ) + + await tick(50, 'Workbook created') + + // Set some metadata on the space + await api.spaces.update(spaceId, { + primaryWorkbookId: + workbookIds && workbookIds.length > 0 ? workbookIds[0] : '', + settings: spaceTemplate.settings + }) + + // Get all the documents for the space template... + const documents = await api.documents.list(spaceTemplateId) + + // ...and create them in the new space + documents.data.forEach(async (document) => { + await api.documents.create(spaceId, document) + }) + + if (callback) { + await callback(event, workbookIds, tick) + } + return { info: 'Space configured' } + }) + ) + } +} diff --git a/plugins/space-configure-from-template/tsup.config.mjs b/plugins/space-configure-from-template/tsup.config.mjs new file mode 100644 index 000000000..bd6420831 --- /dev/null +++ b/plugins/space-configure-from-template/tsup.config.mjs @@ -0,0 +1,3 @@ +import { defineConfig } from '@flatfile/bundler-config-tsup' + +export default defineConfig({}) diff --git a/plugins/space-configure-from-template/vitest.config.ts b/plugins/space-configure-from-template/vitest.config.ts new file mode 100644 index 000000000..e9e1729f9 --- /dev/null +++ b/plugins/space-configure-from-template/vitest.config.ts @@ -0,0 +1,4 @@ +import config from '@flatfile/config-vitest' +import { defineConfig } from 'vitest/config' + +export default defineConfig(config) From 6ab1073c046662be820438388fc02edaa94f9e7f Mon Sep 17 00:00:00 2001 From: Matthew McCoy Date: Tue, 21 Jan 2025 18:49:46 -0500 Subject: [PATCH 2/7] Update plugins/space-configure-from-template/src/space.configure.from.template.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../src/space.configure.from.template.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.ts b/plugins/space-configure-from-template/src/space.configure.from.template.ts index ca00cbe95..7d1e2a884 100644 --- a/plugins/space-configure-from-template/src/space.configure.from.template.ts +++ b/plugins/space-configure-from-template/src/space.configure.from.template.ts @@ -91,9 +91,9 @@ export function configureSpaceFromTemplate( const documents = await api.documents.list(spaceTemplateId) // ...and create them in the new space - documents.data.forEach(async (document) => { + for (const document of documents.data) { await api.documents.create(spaceId, document) - }) + } if (callback) { await callback(event, workbookIds, tick) From c9915713da69cb70939aadb54b66aacb4597d008 Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 18:57:53 -0500 Subject: [PATCH 3/7] lint fixes --- .../src/space.configure.e2e.spec.ts | 69 ------------------- .../src/space.configure.from.template.ts | 31 +++++---- 2 files changed, 16 insertions(+), 84 deletions(-) delete mode 100644 plugins/space-configure-from-template/src/space.configure.e2e.spec.ts diff --git a/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts b/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts deleted file mode 100644 index c4a83f87e..000000000 --- a/plugins/space-configure-from-template/src/space.configure.e2e.spec.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { FlatfileClient } from '@flatfile/api' -import { - deleteSpace, - setupDriver, - setupSpace, - TestListener, -} from '@flatfile/utils-testing' -import { - afterAll, - afterEach, - beforeAll, - beforeEach, - describe, - expect, - it, - vi, -} from 'vitest' -import { configureSpaceFromTemplate } from '.' - -const api = new FlatfileClient() - -describe('SpaceConfigureFromTemplate plugin e2e tests', () => { - const mockFn = vi.fn() - const listener = new TestListener() - const driver = setupDriver() - let spaceId: string - - beforeAll(async () => { - await driver.start() - listener.mount(driver) - - listener.use(configureSpaceFromTemplate(mockFn)) - - const space = await setupSpace() - spaceId = space.id - }) - - afterAll(async () => { - await deleteSpace(spaceId) - - driver.shutdown() - }) - - beforeEach(() => { - listener.resetCount() - }) - - afterEach(() => { - listener.reset() - }) - - it('should configure a space & run callback', async () => { - await listener.waitFor('job:ready', 1, 'space:configure') - - const space = await api.spaces.get(spaceId) - const workspace = await api.workbooks.get(space.data.primaryWorkbookId!) - - // expect(workspace.data.name).toBe(setup.workbooks[0].name) - // expect(workspace.data.labels).toMatchObject(setup.workbooks[0].labels!) - // expect(workspace.data.sheets![0].name).toBe( - // setup.workbooks[0].sheets![0].name - // ) - // expect(workspace.data.sheets![0].config).toMatchObject( - // setup.workbooks[0].sheets![0] - // ) - // expect(workspace.data.actions).toMatchObject(setup.workbooks[0].actions!) - // expect(mockFn).toHaveBeenCalled() - }) -}) diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.ts b/plugins/space-configure-from-template/src/space.configure.from.template.ts index 7d1e2a884..e7ca234b1 100644 --- a/plugins/space-configure-from-template/src/space.configure.from.template.ts +++ b/plugins/space-configure-from-template/src/space.configure.from.template.ts @@ -55,20 +55,21 @@ export function configureSpaceFromTemplate( }) // Convert workbooks from the template to workbook configs - const workbookConfigs: Flatfile.CreateWorkbookConfig[] = workbooks.data.map((workbook) => ({ - name: workbook.name, - labels: workbook.labels, - spaceId: spaceId, - environmentId: environmentId, - namespace: app.data.namespace, - sheets: workbook.sheets.map((sheet) => ({ - ...sheet.config, - })), - actions: workbook.actions, - settings: workbook.settings, - metadata: workbook.metadata, - treatments: workbook.treatments, - })) + const workbookConfigs: Flatfile.CreateWorkbookConfig[] = + workbooks.data.map((workbook) => ({ + name: workbook.name, + labels: workbook.labels, + spaceId: spaceId, + environmentId: environmentId, + namespace: app.data.namespace, + sheets: workbook.sheets.map((sheet) => ({ + ...sheet.config, + })), + actions: workbook.actions, + settings: workbook.settings, + metadata: workbook.metadata, + treatments: workbook.treatments, + })) // Create the workbooks const workbookIds = await Promise.all( @@ -84,7 +85,7 @@ export function configureSpaceFromTemplate( await api.spaces.update(spaceId, { primaryWorkbookId: workbookIds && workbookIds.length > 0 ? workbookIds[0] : '', - settings: spaceTemplate.settings + settings: spaceTemplate.settings, }) // Get all the documents for the space template... From df59683edfb398c2af1a5ebf5d736a5d3b6003bf Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 18:58:05 -0500 Subject: [PATCH 4/7] rename test file --- .../space.configure.from.template.e2e.spec.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts b/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts new file mode 100644 index 000000000..c4a83f87e --- /dev/null +++ b/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts @@ -0,0 +1,69 @@ +import { FlatfileClient } from '@flatfile/api' +import { + deleteSpace, + setupDriver, + setupSpace, + TestListener, +} from '@flatfile/utils-testing' +import { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, +} from 'vitest' +import { configureSpaceFromTemplate } from '.' + +const api = new FlatfileClient() + +describe('SpaceConfigureFromTemplate plugin e2e tests', () => { + const mockFn = vi.fn() + const listener = new TestListener() + const driver = setupDriver() + let spaceId: string + + beforeAll(async () => { + await driver.start() + listener.mount(driver) + + listener.use(configureSpaceFromTemplate(mockFn)) + + const space = await setupSpace() + spaceId = space.id + }) + + afterAll(async () => { + await deleteSpace(spaceId) + + driver.shutdown() + }) + + beforeEach(() => { + listener.resetCount() + }) + + afterEach(() => { + listener.reset() + }) + + it('should configure a space & run callback', async () => { + await listener.waitFor('job:ready', 1, 'space:configure') + + const space = await api.spaces.get(spaceId) + const workspace = await api.workbooks.get(space.data.primaryWorkbookId!) + + // expect(workspace.data.name).toBe(setup.workbooks[0].name) + // expect(workspace.data.labels).toMatchObject(setup.workbooks[0].labels!) + // expect(workspace.data.sheets![0].name).toBe( + // setup.workbooks[0].sheets![0].name + // ) + // expect(workspace.data.sheets![0].config).toMatchObject( + // setup.workbooks[0].sheets![0] + // ) + // expect(workspace.data.actions).toMatchObject(setup.workbooks[0].actions!) + // expect(mockFn).toHaveBeenCalled() + }) +}) From 9fddfe97a328a4e94e7cf61e47e7fbef5148d048 Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 19:19:33 -0500 Subject: [PATCH 5/7] skip tests for now --- .../src/space.configure.from.template.e2e.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts b/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts index c4a83f87e..ed2f9597e 100644 --- a/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts +++ b/plugins/space-configure-from-template/src/space.configure.from.template.e2e.spec.ts @@ -49,7 +49,7 @@ describe('SpaceConfigureFromTemplate plugin e2e tests', () => { listener.reset() }) - it('should configure a space & run callback', async () => { + it.skip('should configure a space & run callback', async () => { await listener.waitFor('job:ready', 1, 'space:configure') const space = await api.spaces.get(spaceId) From 3ffda20d5b0440e2de1645b4d6d217f62fb041b5 Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 19:41:56 -0500 Subject: [PATCH 6/7] update spaces update --- .../src/space.configure.from.template.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.ts b/plugins/space-configure-from-template/src/space.configure.from.template.ts index e7ca234b1..63ca3b8c8 100644 --- a/plugins/space-configure-from-template/src/space.configure.from.template.ts +++ b/plugins/space-configure-from-template/src/space.configure.from.template.ts @@ -86,6 +86,12 @@ export function configureSpaceFromTemplate( primaryWorkbookId: workbookIds && workbookIds.length > 0 ? workbookIds[0] : '', settings: spaceTemplate.settings, + metadata: spaceTemplate.metadata, + actions: spaceTemplate.actions, + access: spaceTemplate.access, + labels: spaceTemplate.labels, + translationsPath: spaceTemplate.translationsPath, + languageOverride: spaceTemplate.languageOverride, }) // Get all the documents for the space template... From a31eaee19624d1e75ae6dcaf6cf4be81672f3df6 Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Tue, 21 Jan 2025 21:12:02 -0500 Subject: [PATCH 7/7] update @flatfile/api to version 1.13.0 and update isAppTemplate --- package-lock.json | 9 ++++++--- package.json | 3 +++ .../src/space.configure.from.template.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 186b4ac5e..326644b76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,9 @@ "utils/*", "validate/*" ], + "dependencies": { + "@flatfile/api": "^1.13.0" + }, "devDependencies": { "@arethetypeswrong/cli": "^0.15.4", "@changesets/cli": "^2.26.1", @@ -3839,9 +3842,9 @@ } }, "node_modules/@flatfile/api": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@flatfile/api/-/api-1.11.0.tgz", - "integrity": "sha512-kz7BdxdiCWEXZSSxwcB8BfujWUKAwNivlKuWM5UCyCAyp5qf4VEDfUgd3FQcxa6KJ01E6aYkkp+45ICxrJL/Cw==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/@flatfile/api/-/api-1.13.0.tgz", + "integrity": "sha512-fdE6d8L0jUeIxVHOCEZaZA8mcqZoxvEC0Bywn3RTf5v3w2KZWSJLLfWD7NxltiS9OxH3lvqOrqPofznv3OxD4w==", "dependencies": { "@flatfile/cross-env-config": "0.0.4", "@types/pako": "2.0.1", diff --git a/package.json b/package.json index 18eda0000..05549665d 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,8 @@ "optionalDependencies": { "@flatfile/changelog": "^1.0.3", "@rollup/rollup-linux-x64-gnu": "^4.8.0" + }, + "dependencies": { + "@flatfile/api": "^1.13.0" } } diff --git a/plugins/space-configure-from-template/src/space.configure.from.template.ts b/plugins/space-configure-from-template/src/space.configure.from.template.ts index 63ca3b8c8..cc3e0bc5c 100644 --- a/plugins/space-configure-from-template/src/space.configure.from.template.ts +++ b/plugins/space-configure-from-template/src/space.configure.from.template.ts @@ -36,7 +36,7 @@ export function configureSpaceFromTemplate( // Get all the space templates for the app sorted by creation date, oldest first const spaceTemplates = await api.spaces.list({ namespace: app.data.namespace, - isCollaborative: true, // TODO: change to isTemplate + isAppTemplate: true, sortField: 'createdAt', sortDirection: 'asc', })