diff --git a/.github/workflows/pullRequests.yml b/.github/workflows/pullRequests.yml index 52fd2866f4d..bc5e82ceff4 100644 --- a/.github/workflows/pullRequests.yml +++ b/.github/workflows/pullRequests.yml @@ -174,10 +174,10 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ - fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') + fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-headless-cms-import-export","id":"api-headless-cms-import-export"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') }} runs-on: ${{ matrix.os }} env: @@ -218,7 +218,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb","storage":"ddb","id":"api-aco_ddb"},{"cmd":"packages/api-apw @@ -279,7 +279,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-es,ddb","storage":"ddb-es","id":"api-aco_ddb-es_ddb"},{"cmd":"packages/api-audit-logs @@ -350,7 +350,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-os,ddb","storage":"ddb-os","id":"api-aco_ddb-os_ddb"},{"cmd":"packages/api-audit-logs @@ -479,7 +479,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 runs-on: ${{ matrix.os }} steps: - uses: actions/setup-node@v4 diff --git a/.github/workflows/pullRequestsCommandCypress.yml b/.github/workflows/pullRequestsCommandCypress.yml index 518a96a096f..3d0631fe842 100644 --- a/.github/workflows/pullRequestsCommandCypress.yml +++ b/.github/workflows/pullRequestsCommandCypress.yml @@ -324,7 +324,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2e-wby-cms-ddb-constants.outputs.cypress-folders) }} @@ -559,7 +559,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2e-wby-cms-ddb-es-constants.outputs.cypress-folders) @@ -799,7 +799,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2e-wby-cms-ddb-os-constants.outputs.cypress-folders) diff --git a/.github/workflows/pushDev.yml b/.github/workflows/pushDev.yml index a99ea434e32..0c473d01084 100644 --- a/.github/workflows/pushDev.yml +++ b/.github/workflows/pushDev.yml @@ -140,10 +140,10 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ - fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') + fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-headless-cms-import-export","id":"api-headless-cms-import-export"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') }} runs-on: ${{ matrix.os }} env: @@ -184,7 +184,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb","storage":"ddb","id":"api-aco_ddb"},{"cmd":"packages/api-apw @@ -245,7 +245,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-es,ddb","storage":"ddb-es","id":"api-aco_ddb-es_ddb"},{"cmd":"packages/api-audit-logs @@ -315,7 +315,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-os,ddb","storage":"ddb-os","id":"api-aco_ddb-os_ddb"},{"cmd":"packages/api-audit-logs @@ -537,7 +537,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: ${{ fromJson(needs.e2eTestsDdb-constants.outputs.cypress-folders) }} environment: next env: @@ -744,7 +744,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2eTestsDdb-es-constants.outputs.cypress-folders) }} @@ -956,7 +956,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2eTestsDdb-os-constants.outputs.cypress-folders) }} diff --git a/.github/workflows/pushNext.yml b/.github/workflows/pushNext.yml index 5022436cf5c..66b948ec1e1 100644 --- a/.github/workflows/pushNext.yml +++ b/.github/workflows/pushNext.yml @@ -140,10 +140,10 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ - fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') + fromJson('[{"cmd":"packages/api","id":"api"},{"cmd":"packages/api-admin-settings","id":"api-admin-settings"},{"cmd":"packages/api-authentication","id":"api-authentication"},{"cmd":"packages/api-authentication-cognito","id":"api-authentication-cognito"},{"cmd":"packages/api-headless-cms-ddb","id":"api-headless-cms-ddb"},{"cmd":"packages/api-headless-cms-import-export","id":"api-headless-cms-import-export"},{"cmd":"packages/api-record-locking","id":"api-record-locking"},{"cmd":"packages/api-wcp","id":"api-wcp"},{"cmd":"packages/api-websockets","id":"api-websockets"},{"cmd":"packages/app-aco","id":"app-aco"},{"cmd":"packages/app-admin","id":"app-admin"},{"cmd":"packages/cwp-template-aws","id":"cwp-template-aws"},{"cmd":"packages/data-migration","id":"data-migration"},{"cmd":"packages/db-dynamodb","id":"db-dynamodb"},{"cmd":"packages/form","id":"form"},{"cmd":"packages/handler","id":"handler"},{"cmd":"packages/handler-aws","id":"handler-aws"},{"cmd":"packages/handler-graphql","id":"handler-graphql"},{"cmd":"packages/handler-logs","id":"handler-logs"},{"cmd":"packages/ioc","id":"ioc"},{"cmd":"packages/lexical-converter","id":"lexical-converter"},{"cmd":"packages/plugins","id":"plugins"},{"cmd":"packages/pubsub","id":"pubsub"},{"cmd":"packages/react-composition","id":"react-composition"},{"cmd":"packages/react-properties","id":"react-properties"},{"cmd":"packages/react-rich-text-lexical-renderer","id":"react-rich-text-lexical-renderer"},{"cmd":"packages/utils","id":"utils"},{"cmd":"packages/validation","id":"validation"}]') }} runs-on: ${{ matrix.os }} env: @@ -184,7 +184,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb","storage":"ddb","id":"api-aco_ddb"},{"cmd":"packages/api-apw @@ -245,7 +245,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-es,ddb","storage":"ddb-es","id":"api-aco_ddb-es_ddb"},{"cmd":"packages/api-audit-logs @@ -315,7 +315,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 package: >- ${{ fromJson('[{"cmd":"packages/api-aco --storage=ddb-os,ddb","storage":"ddb-os","id":"api-aco_ddb-os_ddb"},{"cmd":"packages/api-audit-logs @@ -537,7 +537,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: ${{ fromJson(needs.e2eTestsDdb-constants.outputs.cypress-folders) }} environment: next env: @@ -744,7 +744,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2eTestsDdb-es-constants.outputs.cypress-folders) }} @@ -956,7 +956,7 @@ jobs: os: - ubuntu-latest node: - - 18 + - 20 cypress-folder: >- ${{ fromJson(needs.e2eTestsDdb-os-constants.outputs.cypress-folders) }} diff --git a/.github/workflows/wac/utils/constants.ts b/.github/workflows/wac/utils/constants.ts index 98433a6cd34..f241b14c49e 100644 --- a/.github/workflows/wac/utils/constants.ts +++ b/.github/workflows/wac/utils/constants.ts @@ -1,4 +1,4 @@ -export const NODE_VERSION = 18; +export const NODE_VERSION = 20; export const NODE_OPTIONS = "--max_old_space_size=4096"; diff --git a/.github/workflows/wac/utils/listPackagesWithJestTests.ts b/.github/workflows/wac/utils/listPackagesWithJestTests.ts index 7c9111e269b..82d69873373 100644 --- a/.github/workflows/wac/utils/listPackagesWithJestTests.ts +++ b/.github/workflows/wac/utils/listPackagesWithJestTests.ts @@ -130,6 +130,19 @@ const CUSTOM_HANDLERS: Record Array> = { { cmd: "packages/api-headless-cms --storage=ddb-os,ddb", storage: "ddb-os" } ]; }, + "api-headless-cms-import-export": () => { + return [ + { cmd: "packages/api-headless-cms-import-export --storage=ddb", storage: "ddb" }, + { + cmd: "packages/api-headless-cms-import-export --storage=ddb-es,ddb", + storage: "ddb-es" + }, + { + cmd: "packages/api-headless-cms-import-export --storage=ddb-os,ddb", + storage: "ddb-os" + } + ]; + }, "api-headless-cms-ddb-es": () => { return [ { diff --git a/packages/api-headless-cms-import-export/__tests__/tasks/importFromUrlController.test.ts b/packages/api-headless-cms-import-export/__tests__/tasks/importFromUrlController.test.ts index e6c94127c3c..25ea499c60b 100644 --- a/packages/api-headless-cms-import-export/__tests__/tasks/importFromUrlController.test.ts +++ b/packages/api-headless-cms-import-export/__tests__/tasks/importFromUrlController.test.ts @@ -153,7 +153,7 @@ describe("import from url controller", () => { }); it("should run the task, trigger child tasks and return a continue response", async () => { - expect.assertions(3); + expect.assertions(5); const definition = createImportFromUrlControllerTask(); const files: NonEmptyArray = [ @@ -176,16 +176,6 @@ describe("import from url controller", () => { checksum: "checksum", checked: true, key: "file-2.wa.zip" - }, - { - get: "https://some-url.com/file-3.unknown.zip", - head: "https://some-url.com/file-3.unknown.zip", - size: 2000, - error: undefined, - type: "unknown" as CmsImportExportFileType.ENTRIES, - checksum: "checksum", - checked: true, - key: "something-unknown.zip" } ]; @@ -203,16 +193,19 @@ describe("import from url controller", () => { const runner = createRunner({ context, task: definition, - onContinue: async ({ taskId, iteration, result }) => { - if (iteration === 1) { - return; - } + onContinue: async ({ taskId, result }) => { const children = await context.tasks.listTasks({ where: { parentId: taskId }, limit: 1000000 }); + /** + * Don't update again if not required. + */ + if (children.items.every(child => child.taskStatus === TaskDataStatus.SUCCESS)) { + return; + } for (const child of children.items) { await context.tasks.updateTask(child.id, { taskStatus: TaskDataStatus.SUCCESS @@ -256,22 +249,6 @@ describe("import from url controller", () => { locale: "en-US" }); - expect(result).toEqual({ - message: undefined, - output: { - aborted: [], - done: [], - failed: [], - files: [], - invalid: [] - }, - locale: "en-US", - status: "done", - tenant: "root", - webinyTaskDefinitionId: "importFromUrlController", - webinyTaskId: expect.any(String) - }); - // assertion #2 expect(result).toEqual({ status: TaskResponseStatus.DONE, @@ -284,7 +261,7 @@ describe("import from url controller", () => { done: [], failed: [], invalid: [], - files: [] + files: ["cms-import/file-1.we.zip", "cms-import/file-2.wa.zip"] }, message: undefined }); diff --git a/packages/api-headless-cms-import-export/__tests__/tasks/utils/entryAssetsResolver.test.ts b/packages/api-headless-cms-import-export/__tests__/tasks/utils/entryAssetsResolver.test.ts index 70ab57103d3..087589ca43a 100644 --- a/packages/api-headless-cms-import-export/__tests__/tasks/utils/entryAssetsResolver.test.ts +++ b/packages/api-headless-cms-import-export/__tests__/tasks/utils/entryAssetsResolver.test.ts @@ -38,7 +38,7 @@ describe("entry assets resolver", () => { try { await context.fileManager.createFile(image.data); } catch (ex) { - console.log(ex); + console.error(ex); expect(ex.message).toEqual("Must not happen!"); } } diff --git a/packages/api-headless-cms-import-export/src/tasks/domain/ImportFromUrlController.ts b/packages/api-headless-cms-import-export/src/tasks/domain/ImportFromUrlController.ts index c6cc700a30f..94ff1607ac7 100644 --- a/packages/api-headless-cms-import-export/src/tasks/domain/ImportFromUrlController.ts +++ b/packages/api-headless-cms-import-export/src/tasks/domain/ImportFromUrlController.ts @@ -2,10 +2,10 @@ import type { ITaskResponseResult, ITaskRunParams } from "@webiny/tasks"; import { IImportFromUrlController, IImportFromUrlControllerInput, + IImportFromUrlControllerInputStep, IImportFromUrlControllerInputStepsStep, IImportFromUrlControllerOutput } from "~/tasks/domain/abstractions/ImportFromUrlController"; -import { IImportFromUrlControllerInputStep } from "~/tasks/domain/abstractions/ImportFromUrlController"; import type { Context } from "~/types"; import { ImportFromUrlControllerDownloadStep } from "~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep"; import { ImportFromUrlControllerProcessEntriesStep } from "./importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep"; @@ -53,10 +53,13 @@ export class ImportFromUrlController< }); } - const steps = input.steps || {}; + if (!input.steps) { + input.steps = {}; + } const downloadStep = - steps[IImportFromUrlControllerInputStep.DOWNLOAD] || getDefaultStepValues(); + input.steps[IImportFromUrlControllerInputStep.DOWNLOAD] || getDefaultStepValues(); + if (!downloadStep.finished) { const step = new ImportFromUrlControllerDownloadStep(); return await step.execute(params); @@ -64,12 +67,13 @@ export class ImportFromUrlController< return response.error({ message: `Failed to download files.`, code: "FAILED_DOWNLOADING_FILES", - data: steps + data: input.steps }); } const processEntriesStep = - steps[IImportFromUrlControllerInputStep.PROCESS_ENTRIES] || getDefaultStepValues(); + input.steps[IImportFromUrlControllerInputStep.PROCESS_ENTRIES] || + getDefaultStepValues(); if (!processEntriesStep.finished) { const step = new ImportFromUrlControllerProcessEntriesStep(); return await step.execute(params); @@ -77,12 +81,12 @@ export class ImportFromUrlController< return response.error({ message: `Failed to process entries.`, code: "FAILED_PROCESSING_ENTRIES", - data: steps + data: input.steps }); } const processAssetsStep = - steps[IImportFromUrlControllerInputStep.PROCESS_ASSETS] || getDefaultStepValues(); + input.steps[IImportFromUrlControllerInputStep.PROCESS_ASSETS] || getDefaultStepValues(); if (!processAssetsStep.finished) { const step = new ImportFromUrlControllerProcessAssetsStep(); return await step.execute(params); @@ -90,7 +94,7 @@ export class ImportFromUrlController< return response.error({ message: `Failed to process assets.`, code: "FAILED_PROCESSING_ASSETS", - data: steps + data: input.steps }); } diff --git a/packages/api-headless-cms-import-export/src/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.ts b/packages/api-headless-cms-import-export/src/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.ts index 4ec8a736d2d..78f7be71e79 100644 --- a/packages/api-headless-cms-import-export/src/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.ts +++ b/packages/api-headless-cms-import-export/src/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.ts @@ -5,7 +5,7 @@ import type { } from "~/tasks/domain/abstractions/ImportFromUrlDownload"; import { IMPORT_FROM_URL_DOWNLOAD_TASK } from "~/tasks/constants"; import { getBackOffSeconds } from "~/tasks/utils/helpers/getBackOffSeconds"; -import type { Context } from "~/types"; +import { CmsImportExportFileType, Context } from "~/types"; import type { IImportFromUrlControllerInput, IImportFromUrlControllerOutput @@ -27,7 +27,19 @@ export class ImportFromUrlControllerDownloadStep< const step = input.steps[IImportFromUrlControllerInputStep.DOWNLOAD]; if (!step?.triggered) { - for (const file of input.files) { + const files = input.files.filter(file => { + return ( + file.type === CmsImportExportFileType.ENTRIES || + file.type === CmsImportExportFileType.ASSETS + ); + }); + if (files.length === 0) { + return response.error({ + message: `No files found in the provided data.`, + code: "NO_FILES_FOUND" + }); + } + for (const file of files) { await trigger({ name: `Import From Url - Download`, definition: IMPORT_FROM_URL_DOWNLOAD_TASK, diff --git a/packages/api-headless-cms/src/graphql/schema/createSingularSDL.ts b/packages/api-headless-cms/src/graphql/schema/createSingularSDL.ts index 55f1e183c86..e17a3bda407 100644 --- a/packages/api-headless-cms/src/graphql/schema/createSingularSDL.ts +++ b/packages/api-headless-cms/src/graphql/schema/createSingularSDL.ts @@ -69,6 +69,10 @@ export const createSingularSDL: CreateSingularSDL = ({ } ${fields.map(f => f.typeDefs).join("\n")} + + input ${singularName}ListWhereInput { + id: String + } type ${singularName}Response { data: ${singularName}