@webiny/api-headless-cms-import-export 6.2.0 → 6.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/crud/useCases/validateImportFromUrlIntegrity/ValidateImportFromUrlIntegrityUseCase.js.map +1 -1
  2. package/features/ExportContentAssetsTask/ExportContentAssets.js.map +1 -1
  3. package/features/ExportContentAssetsTask/ExportContentAssetsTask.js.map +1 -1
  4. package/features/ExportContentAssetsTask/feature.d.ts +4 -1
  5. package/features/ExportContentEntriesControllerTask/ExportContentEntriesController.js.map +1 -1
  6. package/features/ExportContentEntriesControllerTask/ExportContentEntriesControllerTask.js.map +1 -1
  7. package/features/ExportContentEntriesControllerTask/feature.d.ts +4 -1
  8. package/features/ExportContentEntriesTask/ExportContentEntries.js.map +1 -1
  9. package/features/ExportContentEntriesTask/ExportContentEntriesTask.js.map +1 -1
  10. package/features/ExportContentEntriesTask/feature.d.ts +4 -1
  11. package/features/ImportFromUrlControllerTask/ImportFromUrlController.js.map +1 -1
  12. package/features/ImportFromUrlControllerTask/ImportFromUrlControllerTask.js.map +1 -1
  13. package/features/ImportFromUrlControllerTask/feature.d.ts +4 -1
  14. package/features/ImportFromUrlDownloadTask/ImportFromUrlDownload.js.map +1 -1
  15. package/features/ImportFromUrlDownloadTask/ImportFromUrlDownloadTask.js.map +1 -1
  16. package/features/ImportFromUrlDownloadTask/feature.d.ts +4 -1
  17. package/features/ImportFromUrlProcessAssetsTask/ImportFromUrlProcessAssetsTask.js.map +1 -1
  18. package/features/ImportFromUrlProcessAssetsTask/feature.d.ts +4 -1
  19. package/features/ImportFromUrlProcessAssetsTask/importFromUrlProcessAssets/ImportFromUrlProcessAssets.js.map +1 -1
  20. package/features/ImportFromUrlProcessEntriesTask/ImportFromUrlProcessEntriesTask.js.map +1 -1
  21. package/features/ImportFromUrlProcessEntriesTask/feature.d.ts +4 -1
  22. package/features/ImportFromUrlProcessEntriesTask/importFromUrlProcessEntries/ImportFromUrlProcessEntries.js.map +1 -1
  23. package/features/ImportFromUrlProcessEntriesTask/importFromUrlProcessEntries/ImportFromUrlProcessEntriesDecompress.js.map +1 -1
  24. package/features/ImportFromUrlProcessEntriesTask/importFromUrlProcessEntries/ImportFromUrlProcessEntriesInsert.js.map +1 -1
  25. package/features/ValidateImportFromUrlTask/ValidateImportFromUrl.js.map +1 -1
  26. package/features/ValidateImportFromUrlTask/ValidateImportFromUrlTask.js.map +1 -1
  27. package/features/ValidateImportFromUrlTask/feature.d.ts +4 -1
  28. package/package.json +20 -20
  29. package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.js.map +1 -1
  30. package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.js.map +1 -1
  31. package/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.js.map +1 -1
  32. package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteContinueWithoutResult.js.map +1 -1
  33. package/tasks/utils/cmsAssetsZipper/CmsAssetsZipperExecuteDoneWithoutResult.js.map +1 -1
  34. package/tasks/utils/entryAssets/EntryAssetsResolver.js +1 -0
  35. package/tasks/utils/entryAssets/EntryAssetsResolver.js.map +1 -1
  36. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK","ValidateImportFromUrlIntegrityUseCase","constructor","params","triggerTask","execute","files","model","result","name","definition","input","task","value","id","status","taskStatus"],"sources":["ValidateImportFromUrlIntegrityUseCase.ts"],"sourcesContent":["import type {\n IValidateImportFromUrlIntegrityUseCase,\n IValidateImportFromUrlIntegrityUseCaseExecuteParams,\n IValidateImportFromUrlIntegrityUseCaseExecuteResult\n} from \"./abstractions/ValidateImportFromUrlIntegrityUseCase.js\";\nimport type { ITasksContextObject } from \"@webiny/tasks\";\nimport { VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK } from \"~/tasks/constants.js\";\nimport type { IValidateImportFromUrlInput } from \"~/tasks/domain/abstractions/ValidateImportFromUrl.js\";\n\nexport interface IValidateImportFromUrlIntegrityUseCaseParams {\n triggerTask: ITasksContextObject[\"trigger\"];\n}\n\nexport class ValidateImportFromUrlIntegrityUseCase\n implements IValidateImportFromUrlIntegrityUseCase\n{\n private readonly triggerTask: ITasksContextObject[\"trigger\"];\n\n public constructor(params: IValidateImportFromUrlIntegrityUseCaseParams) {\n this.triggerTask = params.triggerTask;\n }\n\n public async execute(\n params: IValidateImportFromUrlIntegrityUseCaseExecuteParams\n ): Promise<IValidateImportFromUrlIntegrityUseCaseExecuteResult> {\n const { files, model } = params;\n\n const result = await this.triggerTask<IValidateImportFromUrlInput>({\n name: `Validate Import from URL Integrity`,\n definition: VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK,\n input: {\n model,\n files\n }\n });\n\n const task = result.value;\n\n return {\n id: task.id,\n status: task.taskStatus\n };\n }\n}\n"],"mappings":"AAMA,SAASA,uCAAuC;AAOhD,OAAO,MAAMC,qCAAqC,CAElD;EAGWC,WAAWA,CAACC,MAAoD,EAAE;IACrE,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACC,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAChBF,MAA2D,EACC;IAC5D,MAAM;MAAEG,KAAK;MAAEC;IAAM,CAAC,GAAGJ,MAAM;IAE/B,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACJ,WAAW,CAA8B;MAC/DK,IAAI,EAAE,oCAAoC;MAC1CC,UAAU,EAAEV,uCAAuC;MACnDW,KAAK,EAAE;QACHJ,KAAK;QACLD;MACJ;IACJ,CAAC,CAAC;IAEF,MAAMM,IAAI,GAAGJ,MAAM,CAACK,KAAK;IAEzB,OAAO;MACHC,EAAE,EAAEF,IAAI,CAACE,EAAE;MACXC,MAAM,EAAEH,IAAI,CAACI;IACjB,CAAC;EACL;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK","ValidateImportFromUrlIntegrityUseCase","constructor","params","triggerTask","execute","files","model","result","name","definition","input","task","value","id","status","taskStatus"],"sources":["ValidateImportFromUrlIntegrityUseCase.ts"],"sourcesContent":["import type {\n IValidateImportFromUrlIntegrityUseCase,\n IValidateImportFromUrlIntegrityUseCaseExecuteParams,\n IValidateImportFromUrlIntegrityUseCaseExecuteResult\n} from \"./abstractions/ValidateImportFromUrlIntegrityUseCase.js\";\nimport type { ITasksContextObject } from \"@webiny/tasks\";\nimport { VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK } from \"~/tasks/constants.js\";\nimport type { IValidateImportFromUrlInput } from \"~/tasks/domain/abstractions/ValidateImportFromUrl.js\";\n\nexport interface IValidateImportFromUrlIntegrityUseCaseParams {\n triggerTask: ITasksContextObject[\"trigger\"];\n}\n\nexport class ValidateImportFromUrlIntegrityUseCase implements IValidateImportFromUrlIntegrityUseCase {\n private readonly triggerTask: ITasksContextObject[\"trigger\"];\n\n public constructor(params: IValidateImportFromUrlIntegrityUseCaseParams) {\n this.triggerTask = params.triggerTask;\n }\n\n public async execute(\n params: IValidateImportFromUrlIntegrityUseCaseExecuteParams\n ): Promise<IValidateImportFromUrlIntegrityUseCaseExecuteResult> {\n const { files, model } = params;\n\n const result = await this.triggerTask<IValidateImportFromUrlInput>({\n name: `Validate Import from URL Integrity`,\n definition: VALIDATE_IMPORT_FROM_URL_INTEGRITY_TASK,\n input: {\n model,\n files\n }\n });\n\n const task = result.value;\n\n return {\n id: task.id,\n status: task.taskStatus\n };\n }\n}\n"],"mappings":"AAMA,SAASA,uCAAuC;AAOhD,OAAO,MAAMC,qCAAqC,CAAmD;EAG1FC,WAAWA,CAACC,MAAoD,EAAE;IACrE,IAAI,CAACC,WAAW,GAAGD,MAAM,CAACC,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAChBF,MAA2D,EACC;IAC5D,MAAM;MAAEG,KAAK;MAAEC;IAAM,CAAC,GAAGJ,MAAM;IAE/B,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACJ,WAAW,CAA8B;MAC/DK,IAAI,EAAE,oCAAoC;MAC1CC,UAAU,EAAEV,uCAAuC;MACnDW,KAAK,EAAE;QACHJ,KAAK;QACLD;MACJ;IACJ,CAAC,CAAC;IAEF,MAAMM,IAAI,GAAGJ,MAAM,CAACK,KAAK;IAEzB,OAAO;MACHC,EAAE,EAAEF,IAAI,CAACE,EAAE;MACXC,MAAM,EAAEH,IAAI,CAACI;IACjB,CAAC;EACL;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["createCmsEntryFetcher","EntryAssets","EntryAssetsResolver","CmsAssetsZipperExecuteContinueResult","CmsAssetsZipperExecuteContinueWithoutResult","CmsAssetsZipperExecuteDoneResult","CmsAssetsZipperExecuteDoneWithoutResult","FileFetcher","getErrorProperties","getBucket","createS3Client","UniqueResolver","WEBINY_EXPORT_ASSETS_EXTENSION","ListFilesUseCase","ContentEntryTraverserProvider","getFilename","input","current","entryAfter","fileAfter","filter","item","undefined","join","prefix","ExportContentAssets","constructor","params","context","createCmsAssetsZipper","run","controller","model","cms","getModel","modelId","ex","response","error","message","code","data","traverserProvider","container","resolve","traverser","getTraverser","entryFetcher","after","where","limit","sort","items","meta","listLatestEntries","fileFetcher","client","bucket","filename","zipper","createEntryAssets","uniqueResolver","createEntryAssetsResolver","fetchFiles","listFiles","listResult","execute","value","result","isAborted","runtime","isCloseToTimeout","seconds","files","Array","isArray","done","concat","key","checksum","continue","fileCursor","entryCursor","type","name"],"sources":["ExportContentAssets.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type {\n IExportContentAssets,\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport type { ICmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/index.js\";\nimport { createCmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/index.js\";\nimport type { IEntryAssets, IEntryAssetsResolver } from \"~/tasks/utils/entryAssets/index.js\";\nimport { EntryAssets, EntryAssetsResolver } from \"~/tasks/utils/entryAssets/index.js\";\nimport type {\n ICmsAssetsZipper,\n ICmsAssetsZipperExecuteResult\n} from \"~/tasks/utils/cmsAssetsZipper/index.js\";\nimport {\n CmsAssetsZipperExecuteContinueResult,\n CmsAssetsZipperExecuteContinueWithoutResult,\n CmsAssetsZipperExecuteDoneResult,\n CmsAssetsZipperExecuteDoneWithoutResult\n} from \"~/tasks/utils/cmsAssetsZipper/index.js\";\nimport type { IFileFetcher } from \"~/tasks/utils/fileFetcher/index.js\";\nimport { FileFetcher } from \"~/tasks/utils/fileFetcher/index.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getErrorProperties } from \"@webiny/tasks/utils/index.js\";\nimport { getBucket } from \"~/tasks/utils/helpers/getBucket.js\";\nimport { createS3Client } from \"~/tasks/utils/helpers/s3Client.js\";\nimport { UniqueResolver } from \"~/tasks/utils/uniqueResolver/UniqueResolver.js\";\nimport { WEBINY_EXPORT_ASSETS_EXTENSION } from \"~/tasks/constants.js\";\nimport { ListFilesUseCase } from \"@webiny/api-file-manager/features/file/ListFiles/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ContentEntryTraverserProvider } from \"@webiny/api-headless-cms\";\n\nexport interface ICreateCmsAssetsZipperCallableConfig {\n filename: string;\n entryFetcher: ICmsEntryFetcher;\n createEntryAssets: () => IEntryAssets;\n createEntryAssetsResolver: () => IEntryAssetsResolver;\n fileFetcher: IFileFetcher;\n}\n\nexport interface ICreateCmsAssetsZipperCallable {\n (config: ICreateCmsAssetsZipperCallableConfig): ICmsAssetsZipper;\n}\n\nconst getFilename = (input: IExportContentAssetsInput): string => {\n const current = [input.entryAfter, input.fileAfter]\n .filter(item => item !== undefined)\n .join(\"-\");\n\n return `${input.prefix}/assets${\n current ? `-${current}` : \"\"\n }.${WEBINY_EXPORT_ASSETS_EXTENSION}`;\n};\n\nexport interface IExportContentAssetsParams {\n context: Context;\n createCmsAssetsZipper: ICreateCmsAssetsZipperCallable;\n}\n\nexport class ExportContentAssets<\n I extends IExportContentAssetsInput = IExportContentAssetsInput,\n O extends IExportContentAssetsOutput = IExportContentAssetsOutput\n> implements IExportContentAssets<I, O>\n{\n private readonly createCmsAssetsZipper: ICreateCmsAssetsZipperCallable;\n private context: Context;\n\n public constructor(params: IExportContentAssetsParams) {\n this.context = params.context;\n this.createCmsAssetsZipper = params.createCmsAssetsZipper;\n }\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(input.modelId);\n } catch (ex) {\n return controller.response.error({\n message: `Could not fetch entry manager for model \"${input.modelId}\".`,\n code: \"MODEL_NOT_FOUND\",\n data: {\n error: getErrorProperties(ex)\n }\n });\n }\n\n const traverserProvider = this.context.container.resolve(ContentEntryTraverserProvider);\n const traverser = await traverserProvider.getTraverser(model.modelId);\n\n const entryFetcher = createCmsEntryFetcher(async after => {\n const input = {\n where: params.input.where,\n limit: params.input.limit || 10000,\n sort: params.input.sort,\n after\n };\n const [items, meta] = await this.context.cms.listLatestEntries(model, input);\n\n return {\n items,\n meta\n };\n });\n\n const fileFetcher = new FileFetcher({\n client: createS3Client(),\n bucket: getBucket()\n });\n\n const filename = getFilename(input);\n\n const zipper = this.createCmsAssetsZipper({\n filename,\n fileFetcher,\n entryFetcher,\n createEntryAssets: () => {\n return new EntryAssets({\n traverser,\n uniqueResolver: new UniqueResolver()\n });\n },\n createEntryAssetsResolver: () => {\n return new EntryAssetsResolver({\n fetchFiles: async params => {\n const listFiles = this.context.container.resolve(ListFilesUseCase);\n const listResult = await listFiles.execute(params ?? {});\n\n return listResult.value;\n }\n });\n }\n });\n\n let result: ICmsAssetsZipperExecuteResult;\n\n try {\n result = await zipper.execute({\n fileAfter: input.fileAfter,\n entryAfter: input.entryAfter,\n isAborted() {\n return controller.runtime.isAborted();\n },\n isCloseToTimeout(seconds?: number) {\n return controller.runtime.isCloseToTimeout(seconds);\n }\n });\n } catch (ex) {\n return controller.response.error(ex);\n }\n\n const files = Array.isArray(input.files) ? input.files : [];\n /**\n * Zipper is done, but there is no result?\n * We will output existing input files.\n */\n if (result instanceof CmsAssetsZipperExecuteDoneWithoutResult) {\n return controller.response.done({\n files\n } as O);\n }\n /**\n * Zipper is done and there is a result?\n * We will output existing input files and the new file.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteDoneResult) {\n return controller.response.done({\n files: files.concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ])\n } as O);\n }\n /**\n * Zipper is not done and there is no result?\n * Let's continue with the next iteration.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteContinueWithoutResult) {\n return controller.response.continue({\n ...input,\n fileAfter: result.fileCursor,\n entryAfter: result.entryCursor\n });\n }\n /**\n * Zipper is not done and there is a result?\n * Let's merge the existing files with the new file and continue with the next iteration.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteContinueResult) {\n return controller.response.continue({\n ...input,\n fileAfter: result.fileCursor,\n entryAfter: result.entryCursor,\n files: files.concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ])\n });\n }\n\n return controller.response.error({\n message: \"Unknown zipper result.\",\n code: \"UNKNOWN_ZIPPER_RESULT\",\n data: {\n type: typeof result,\n constructor: result?.constructor?.name || \"unknown constructor\",\n result\n }\n });\n }\n}\n"],"mappings":"AAOA,SAASA,qBAAqB;AAE9B,SAASC,WAAW,EAAEC,mBAAmB;AAKzC,SACIC,oCAAoC,EACpCC,2CAA2C,EAC3CC,gCAAgC,EAChCC,uCAAuC;AAG3C,SAASC,WAAW;AAEpB,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,SAAS;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,SAASC,8BAA8B;AACvC,SAASC,gBAAgB,QAAQ,2DAA2D;AAE5F,SAASC,6BAA6B,QAAQ,0BAA0B;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CAACa,UAAU;QAC5B/D,UAAU,EAAEkD,MAAM,CAACc;MACvB,CAAC,CAAC;IACN;IACA;AACR;AACA;AACA;IACQ;IAAA,KACK,IAAId,MAAM,YAAYjE,oCAAoC,EAAE;MAC7D,OAAO4B,UAAU,CAACM,QAAQ,CAAC2C,QAAQ,CAAC;QAChC,GAAGhE,KAAK;QACRG,SAAS,EAAEiD,MAAM,CAACa,UAAU;QAC5B/D,UAAU,EAAEkD,MAAM,CAACc,WAAW;QAC9BT,KAAK,EAAEA,KAAK,CAACI,MAAM,CAAC,CAChB;UACIC,GAAG,EAAEV,MAAM,CAACU,GAAG;UACfC,QAAQ,EAAEX,MAAM,CAACW;QACrB,CAAC,CACJ;MACL,CAAC,CAAC;IACN;IAEA,OAAOhD,UAAU,CAACM,QAAQ,CAACC,KAAK,CAAC;MAC7BC,OAAO,EAAE,wBAAwB;MACjCC,IAAI,EAAE,uBAAuB;MAC7BC,IAAI,EAAE;QACF0C,IAAI,EAAE,OAAOf,MAAM;QACnB1C,WAAW,EAAE0C,MAAM,EAAE1C,WAAW,EAAE0D,IAAI,IAAI,qBAAqB;QAC/DhB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["createCmsEntryFetcher","EntryAssets","EntryAssetsResolver","CmsAssetsZipperExecuteContinueResult","CmsAssetsZipperExecuteContinueWithoutResult","CmsAssetsZipperExecuteDoneResult","CmsAssetsZipperExecuteDoneWithoutResult","FileFetcher","getErrorProperties","getBucket","createS3Client","UniqueResolver","WEBINY_EXPORT_ASSETS_EXTENSION","ListFilesUseCase","ContentEntryTraverserProvider","getFilename","input","current","entryAfter","fileAfter","filter","item","undefined","join","prefix","ExportContentAssets","constructor","params","context","createCmsAssetsZipper","run","controller","model","cms","getModel","modelId","ex","response","error","message","code","data","traverserProvider","container","resolve","traverser","getTraverser","entryFetcher","after","where","limit","sort","items","meta","listLatestEntries","fileFetcher","client","bucket","filename","zipper","createEntryAssets","uniqueResolver","createEntryAssetsResolver","fetchFiles","listFiles","listResult","execute","value","result","isAborted","runtime","isCloseToTimeout","seconds","files","Array","isArray","done","concat","key","checksum","continue","fileCursor","entryCursor","type","name"],"sources":["ExportContentAssets.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type {\n IExportContentAssets,\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport type { ICmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/index.js\";\nimport { createCmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/index.js\";\nimport type { IEntryAssets, IEntryAssetsResolver } from \"~/tasks/utils/entryAssets/index.js\";\nimport { EntryAssets, EntryAssetsResolver } from \"~/tasks/utils/entryAssets/index.js\";\nimport type {\n ICmsAssetsZipper,\n ICmsAssetsZipperExecuteResult\n} from \"~/tasks/utils/cmsAssetsZipper/index.js\";\nimport {\n CmsAssetsZipperExecuteContinueResult,\n CmsAssetsZipperExecuteContinueWithoutResult,\n CmsAssetsZipperExecuteDoneResult,\n CmsAssetsZipperExecuteDoneWithoutResult\n} from \"~/tasks/utils/cmsAssetsZipper/index.js\";\nimport type { IFileFetcher } from \"~/tasks/utils/fileFetcher/index.js\";\nimport { FileFetcher } from \"~/tasks/utils/fileFetcher/index.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getErrorProperties } from \"@webiny/tasks/utils/index.js\";\nimport { getBucket } from \"~/tasks/utils/helpers/getBucket.js\";\nimport { createS3Client } from \"~/tasks/utils/helpers/s3Client.js\";\nimport { UniqueResolver } from \"~/tasks/utils/uniqueResolver/UniqueResolver.js\";\nimport { WEBINY_EXPORT_ASSETS_EXTENSION } from \"~/tasks/constants.js\";\nimport { ListFilesUseCase } from \"@webiny/api-file-manager/features/file/ListFiles/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ContentEntryTraverserProvider } from \"@webiny/api-headless-cms\";\n\nexport interface ICreateCmsAssetsZipperCallableConfig {\n filename: string;\n entryFetcher: ICmsEntryFetcher;\n createEntryAssets: () => IEntryAssets;\n createEntryAssetsResolver: () => IEntryAssetsResolver;\n fileFetcher: IFileFetcher;\n}\n\nexport interface ICreateCmsAssetsZipperCallable {\n (config: ICreateCmsAssetsZipperCallableConfig): ICmsAssetsZipper;\n}\n\nconst getFilename = (input: IExportContentAssetsInput): string => {\n const current = [input.entryAfter, input.fileAfter]\n .filter(item => item !== undefined)\n .join(\"-\");\n\n return `${input.prefix}/assets${\n current ? `-${current}` : \"\"\n }.${WEBINY_EXPORT_ASSETS_EXTENSION}`;\n};\n\nexport interface IExportContentAssetsParams {\n context: Context;\n createCmsAssetsZipper: ICreateCmsAssetsZipperCallable;\n}\n\nexport class ExportContentAssets<\n I extends IExportContentAssetsInput = IExportContentAssetsInput,\n O extends IExportContentAssetsOutput = IExportContentAssetsOutput\n> implements IExportContentAssets<I, O> {\n private readonly createCmsAssetsZipper: ICreateCmsAssetsZipperCallable;\n private context: Context;\n\n public constructor(params: IExportContentAssetsParams) {\n this.context = params.context;\n this.createCmsAssetsZipper = params.createCmsAssetsZipper;\n }\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(input.modelId);\n } catch (ex) {\n return controller.response.error({\n message: `Could not fetch entry manager for model \"${input.modelId}\".`,\n code: \"MODEL_NOT_FOUND\",\n data: {\n error: getErrorProperties(ex)\n }\n });\n }\n\n const traverserProvider = this.context.container.resolve(ContentEntryTraverserProvider);\n const traverser = await traverserProvider.getTraverser(model.modelId);\n\n const entryFetcher = createCmsEntryFetcher(async after => {\n const input = {\n where: params.input.where,\n limit: params.input.limit || 10000,\n sort: params.input.sort,\n after\n };\n const [items, meta] = await this.context.cms.listLatestEntries(model, input);\n\n return {\n items,\n meta\n };\n });\n\n const fileFetcher = new FileFetcher({\n client: createS3Client(),\n bucket: getBucket()\n });\n\n const filename = getFilename(input);\n\n const zipper = this.createCmsAssetsZipper({\n filename,\n fileFetcher,\n entryFetcher,\n createEntryAssets: () => {\n return new EntryAssets({\n traverser,\n uniqueResolver: new UniqueResolver()\n });\n },\n createEntryAssetsResolver: () => {\n return new EntryAssetsResolver({\n fetchFiles: async params => {\n const listFiles = this.context.container.resolve(ListFilesUseCase);\n const listResult = await listFiles.execute(params ?? {});\n\n return listResult.value;\n }\n });\n }\n });\n\n let result: ICmsAssetsZipperExecuteResult;\n\n try {\n result = await zipper.execute({\n fileAfter: input.fileAfter,\n entryAfter: input.entryAfter,\n isAborted() {\n return controller.runtime.isAborted();\n },\n isCloseToTimeout(seconds?: number) {\n return controller.runtime.isCloseToTimeout(seconds);\n }\n });\n } catch (ex) {\n return controller.response.error(ex);\n }\n\n const files = Array.isArray(input.files) ? input.files : [];\n /**\n * Zipper is done, but there is no result?\n * We will output existing input files.\n */\n if (result instanceof CmsAssetsZipperExecuteDoneWithoutResult) {\n return controller.response.done({\n files\n } as O);\n }\n /**\n * Zipper is done and there is a result?\n * We will output existing input files and the new file.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteDoneResult) {\n return controller.response.done({\n files: files.concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ])\n } as O);\n }\n /**\n * Zipper is not done and there is no result?\n * Let's continue with the next iteration.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteContinueWithoutResult) {\n return controller.response.continue({\n ...input,\n fileAfter: result.fileCursor,\n entryAfter: result.entryCursor\n });\n }\n /**\n * Zipper is not done and there is a result?\n * Let's merge the existing files with the new file and continue with the next iteration.\n */\n //\n else if (result instanceof CmsAssetsZipperExecuteContinueResult) {\n return controller.response.continue({\n ...input,\n fileAfter: result.fileCursor,\n entryAfter: result.entryCursor,\n files: files.concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ])\n });\n }\n\n return controller.response.error({\n message: \"Unknown zipper result.\",\n code: \"UNKNOWN_ZIPPER_RESULT\",\n data: {\n type: typeof result,\n constructor: result?.constructor?.name || \"unknown constructor\",\n result\n }\n });\n }\n}\n"],"mappings":"AAOA,SAASA,qBAAqB;AAE9B,SAASC,WAAW,EAAEC,mBAAmB;AAKzC,SACIC,oCAAoC,EACpCC,2CAA2C,EAC3CC,gCAAgC,EAChCC,uCAAuC;AAG3C,SAASC,WAAW;AAEpB,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,SAAS;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,SAASC,8BAA8B;AACvC,SAASC,gBAAgB,QAAQ,2DAA2D;AAE5F,SAASC,6BAA6B,QAAQ,0BAA0B;AAcxE,MAAMC,WAAW,GAAIC,KAAgC,IAAa;EAC9D,MAAMC,OAAO,GAAG,CAACD,KAAK,CAACE,UAAU,EAAEF,KAAK,CAACG,SAAS,CAAC,CAC9CC,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKC,SAAS,CAAC,CAClCC,IAAI,CAAC,GAAG,CAAC;EAEd,OAAO,GAAGP,KAAK,CAACQ,MAAM,UAClBP,OAAO,GAAG,IAAIA,OAAO,EAAE,GAAG,EAAE,IAC5BL,8BAA8B,EAAE;AACxC,CAAC;AAOD,OAAO,MAAMa,mBAAmB,CAGQ;EAI7BC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,qBAAqB,GAAGF,MAAM,CAACE,qBAAqB;EAC7D;EAEA,MAAaC,GAAGA,CAACH,MAAsC,EAAE;IACrD,MAAM;MAAEX,KAAK;MAAEe;IAAW,CAAC,GAAGJ,MAAM;IAEpC,IAAIK,KAAe;IACnB,IAAI;MACAA,KAAK,GAAG,MAAM,IAAI,CAACJ,OAAO,CAACK,GAAG,CAACC,QAAQ,CAAClB,KAAK,CAACmB,OAAO,CAAC;IAC1D,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,OAAOL,UAAU,CAACM,QAAQ,CAACC,KAAK,C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etsTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createExportContentAssets","runner","ex","controller","response","error","ExportContentAssetsTask","createImplementation","implementation","dependencies"],"sources":["ExportContentAssetsTask.ts"],"sourcesContent":["import type {\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ASSETS_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IExportContentAssetsInput, IExportContentAssetsOutput>;\n\nclass ExportContentAssetsTaskDefinition\n implements TaskDefinition.Interface<IExportContentAssetsInput, IExportContentAssetsOutput>\n{\n id = EXPORT_CONTENT_ASSETS_TASK;\n title = \"Export Content Assets\";\n maxIterations = 50;\n isPrivate = true;\n description = \"Export content assets from a specific model.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createExportContentAssets } = await import(\n /* webpackChunkName: \"createExportContentAssets\" */ \"./createExportContentAssets.js\"\n );\n\n try {\n const runner = createExportContentAssets(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentAssetsTask = TaskDefinition.createImplementation({\n implementation: ExportContentAssetsTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAIA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,0BAA0B;AAInC,MAAMC,iCAAiC,CAEvC;EACIC,EAAE,GAAGF,0BAA0B;EAC/BG,KAAK,GAAG,uBAAuB;EAC/BC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,8CAA8C;EAE5DC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA0B,CAAC,GAAG,MAAM,MAAM,CAC9C,mFACJ,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAGD,yBAAyB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACjE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,uBAAuB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACvEC,cAAc,EAAElB,iCAAiC;EACjDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","CmsContext","EXPORT_CONTENT_ASSETS_TASK","ExportContentAssetsTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createExportContentAssets","runner","ex","controller","response","error","ExportContentAssetsTask","createImplementation","implementation","dependencies"],"sources":["ExportContentAssetsTask.ts"],"sourcesContent":["import type {\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ASSETS_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IExportContentAssetsInput, IExportContentAssetsOutput>;\n\nclass ExportContentAssetsTaskDefinition implements TaskDefinition.Interface<\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n> {\n id = EXPORT_CONTENT_ASSETS_TASK;\n title = \"Export Content Assets\";\n maxIterations = 50;\n isPrivate = true;\n description = \"Export content assets from a specific model.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createExportContentAssets } = await import(\n /* webpackChunkName: \"createExportContentAssets\" */ \"./createExportContentAssets.js\"\n );\n\n try {\n const runner = createExportContentAssets(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentAssetsTask = TaskDefinition.createImplementation({\n implementation: ExportContentAssetsTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAIA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,0BAA0B;AAInC,MAAMC,iCAAiC,CAGrC;EACEC,EAAE,GAAGF,0BAA0B;EAC/BG,KAAK,GAAG,uBAAuB;EAC/BC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,8CAA8C;EAE5DC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA0B,CAAC,GAAG,MAAM,MAAM,CAC9C,mFACJ,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAGD,yBAAyB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACjE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,uBAAuB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACvEC,cAAc,EAAElB,iCAAiC;EACjDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ExportContentAssetsTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ExportContentAssetsTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["uniqueId","TaskDataStatus","CmsImportExportFileType","ExportContentEntriesControllerState","EXPORT_BASE_PATH","EXPORT_CONTENT_ASSETS_TASK","EXPORT_CONTENT_ENTRIES_TASK","getBackOffSeconds","prepareExportModel","model","modelId","fields","ExportContentEntriesController","constructor","context","run","params","input","controller","state","cms","getModel","response","error","message","code","currentTask","getTask","backOffSeconds","iterations","entriesTask","prefix","id","result","task","trigger","definition","exportAssets","limit","where","sort","name","value","continue","contentEntriesTaskId","entryExport","seconds","getEntriesTask","taskStatus","RUNNING","PENDING","FAILED","ABORTED","output","files","length","file","push","key","checksum","type","ENTRIES","done","entryAfter","undefined","fileAfter","assetTask","contentAssetsTaskId","assetsExport","assetsTask","getAssetsTask","entriesFiles","assetFiles","ASSETS","tasks","definitionId"],"sources":["ExportContentEntriesController.ts"],"sourcesContent":["import uniqueId from \"uniqid\";\nimport { IGetTaskResponse, TaskDataStatus } from \"@webiny/tasks\";\nimport type { Context } from \"~/types.js\";\nimport { CmsImportExportFileType } from \"~/types.js\";\nimport type {\n IExportContentEntriesController,\n IControllerInput,\n IControllerOutput,\n IControllerOutputFile,\n IExportedCmsModel\n} from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport { ExportContentEntriesControllerState } from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport {\n EXPORT_BASE_PATH,\n EXPORT_CONTENT_ASSETS_TASK,\n EXPORT_CONTENT_ENTRIES_TASK\n} from \"~/tasks/constants.js\";\nimport type {\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport type {\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport { getBackOffSeconds } from \"~/tasks/utils/helpers/getBackOffSeconds.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nconst prepareExportModel = (model: Pick<CmsModel, \"modelId\" | \"fields\">): IExportedCmsModel => {\n return {\n modelId: model.modelId,\n fields: model.fields\n };\n};\n\nexport class ExportContentEntriesController<\n I extends IControllerInput = IControllerInput,\n O extends IControllerOutput = IControllerOutput\n> implements IExportContentEntriesController<I, O>\n{\n constructor(private context: Context) {}\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n const { state, modelId } = input;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n const currentTask = controller.state.getTask();\n const backOffSeconds = getBackOffSeconds(currentTask.iterations);\n\n let entriesTask: IGetTaskResponse<IExportContentEntriesInput, IExportContentEntriesOutput>;\n\n /**\n * In case of no state yet, we will start the content entries export process.\n */\n const prefix =\n input.prefix || uniqueId(`${EXPORT_BASE_PATH}/${model.modelId}/${currentTask.id}`);\n if (!state) {\n const result = await controller.task.trigger<IExportContentEntriesInput>({\n definition: EXPORT_CONTENT_ENTRIES_TASK,\n input: {\n prefix,\n exportAssets: input.exportAssets,\n modelId: model.modelId,\n limit: input.limit,\n where: input.where,\n sort: input.sort\n },\n name: `Export Content Entries ${currentTask.id}`\n });\n\n const task = result.value;\n\n return controller.response.continue(\n {\n ...input,\n prefix,\n contentEntriesTaskId: task.id,\n state: ExportContentEntriesControllerState.entryExport\n },\n {\n seconds: backOffSeconds\n }\n );\n }\n /**\n * If the state of the task is \"entryExport\", we need to check if there are any child tasks of the \"Export Content Entries\" task.\n * If there are, we need to wait for them to finish before we can proceed.\n * If there are no child tasks, we'll return an error.\n * If there are child tasks, but they are not finished, we'll return a \"continue\" response, which will make the task wait for X seconds before checking again.\n */\n //\n else if (state === ExportContentEntriesControllerState.entryExport) {\n if (!input.contentEntriesTaskId) {\n return controller.response.error({\n message: `Missing \"contentEntriesTaskId\" in the input, but the input notes that the task is in \"entryExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ENTRIES_TASK_ID\"\n });\n }\n entriesTask = await this.getEntriesTask(this.context, input.contentEntriesTaskId);\n if (!entriesTask) {\n return controller.response.error({\n message: `Task \"${input.contentEntriesTaskId}\" not found.`,\n code: \"TASK_NOT_FOUND\"\n });\n }\n if (\n entriesTask.taskStatus == TaskDataStatus.RUNNING ||\n entriesTask.taskStatus === TaskDataStatus.PENDING\n ) {\n return controller.response.continue(input, {\n seconds: backOffSeconds\n });\n } else if (entriesTask.taskStatus === TaskDataStatus.FAILED) {\n return controller.response.error({\n message: `Failed to export content entries. Task \"${entriesTask.id}\" failed.`,\n code: \"EXPORT_ENTRIES_FAILED\"\n });\n } else if (entriesTask.taskStatus === TaskDataStatus.ABORTED) {\n return controller.response.error({\n message: `Export content entries process was aborted. Task \"${entriesTask.id}\" was aborted.`,\n code: \"EXPORT_ENTRIES_ABORTED\"\n });\n } else if (!entriesTask.output) {\n return controller.response.error({\n message: `No output found on task \"${entriesTask.id}\". Stopping export process.`,\n code: \"NO_OUTPUT\"\n });\n }\n /**\n * Possibly the task does not require any assets to be exported.\n */\n if (!input.exportAssets || entriesTask.output.files.length === 0) {\n const files: IControllerOutputFile[] = [];\n for (const file of entriesTask.output.files) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ENTRIES\n });\n }\n\n const output: IControllerOutput = {\n files,\n model: prepareExportModel(model)\n };\n return controller.response.done(\"Export done, without assets.\", output as O);\n }\n\n const result = await controller.task.trigger<IExportContentAssetsInput>({\n definition: EXPORT_CONTENT_ASSETS_TASK,\n input: {\n prefix,\n modelId: model.modelId,\n limit: input.limit,\n where: input.where,\n sort: input.sort,\n entryAfter: undefined,\n fileAfter: undefined\n },\n name: `Export Content Assets ${currentTask.id}`\n });\n\n const assetTask = result.value;\n\n return controller.response.continue(\n {\n ...input,\n contentAssetsTaskId: assetTask.id,\n state: ExportContentEntriesControllerState.assetsExport\n },\n {\n seconds: backOffSeconds\n }\n );\n }\n /**\n * If the state is \"assetsExport\", we need to check if there are any child tasks of the \"Export Content Assets\" task.\n * If there are, we need to wait for them to finish before we can proceed.\n * If there are no child tasks, we'll return as done.\n * If there are child tasks, but they are not finished, we'll return a \"continue\" response, which will make the task wait for X seconds before checking again.\n */\n //\n else if (state === ExportContentEntriesControllerState.assetsExport) {\n if (!input.contentEntriesTaskId) {\n return controller.response.error({\n message: `Missing \"contentEntriesTaskId\" in the input, but the input notes that the task is in \"assetsExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ENTRIES_TASK_ID\"\n });\n } else if (!input.contentAssetsTaskId) {\n return controller.response.error({\n message: `Missing \"contentAssetsTaskId\" in the input, but the input notes that the task is in \"assetsExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ASSETS_TASK_ID\"\n });\n }\n\n const assetsTask = await this.getAssetsTask(this.context, input.contentAssetsTaskId);\n if (!assetsTask) {\n return controller.response.error({\n message: `Task \"${input.contentAssetsTaskId}\" not found.`,\n code: \"TASK_NOT_FOUND\"\n });\n }\n if (\n assetsTask.taskStatus == TaskDataStatus.RUNNING ||\n assetsTask.taskStatus === TaskDataStatus.PENDING\n ) {\n return controller.response.continue(\n {\n ...input\n },\n {\n seconds: backOffSeconds\n }\n );\n } else if (assetsTask.taskStatus === TaskDataStatus.FAILED) {\n return controller.response.error({\n message: `Failed to export content assets. Task \"${assetsTask.id}\" failed.`,\n code: \"EXPORT_ASSETS_FAILED\"\n });\n } else if (assetsTask.taskStatus === TaskDataStatus.ABORTED) {\n return controller.response.error({\n message: `Export content assets process was aborted. Task \"${assetsTask.id}\" was aborted.`,\n code: \"EXPORT_ASSETS_ABORTED\"\n });\n }\n\n entriesTask = await this.getEntriesTask(this.context, input.contentEntriesTaskId);\n\n const files: IControllerOutputFile[] = [];\n const entriesFiles = entriesTask?.output?.files || [];\n for (const file of entriesFiles) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ENTRIES\n });\n }\n const assetFiles = assetsTask.output?.files || [];\n for (const file of assetFiles) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ASSETS\n });\n }\n\n const output: IControllerOutput = {\n model: prepareExportModel(model),\n files\n };\n\n return controller.response.done(\"Export done, with assets.\", output as O);\n }\n\n return controller.response.error({\n message: `Invalid state \"${state}\".`,\n code: \"INVALID_STATE\"\n });\n }\n\n private async getEntriesTask(context: Context, id: string) {\n try {\n const result = await context.tasks.getTask<\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n >(id);\n if (result?.definitionId === EXPORT_CONTENT_ENTRIES_TASK) {\n return result;\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async getAssetsTask(context: Context, id: string) {\n try {\n const result = await context.tasks.getTask<\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n >(id);\n if (result?.definitionId == EXPORT_CONTENT_ASSETS_TASK) {\n return result;\n }\n return null;\n } catch {\n return null;\n }\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,QAAQ;AAC7B,SAA2BC,cAAc,QAAQ,eAAe;AAEhE,SAASC,uBAAuB;AAQhC,SAASC,mCAAmC;AAC5C,SACIC,gBAAgB,EAChBC,0BAA0B,EAC1BC,2BAA2B;AAU/B,SAASC,iBAAiB;AAI1B,MAAMC,kBAAkB,GAAIC,KAA2C,IAAwB;EAC3F,OAAO;IACHC,OAAO,EAAED,KAAK,CAACC,OAAO;IACtBC,MAAM,EAAEF,KAAK,CAACE;EAClB,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,8BAA8B,CAI3C;EACIC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;EAAG;EACvC,MAAaC,GAAGA,CAACC,MAAsC,EA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AACG,QAAQ;UACvBC,IAAI,EAAE1D,uBAAuB,CAACuE;QAClC,CAAC,CAAC;MACN;MAEA,MAAMpB,MAAyB,GAAG;QAC9B5C,KAAK,EAAED,kBAAkB,CAACC,KAAK,CAAC;QAChC6C;MACJ,CAAC;MAED,OAAOpC,UAAU,CAACI,QAAQ,CAACwC,IAAI,CAAC,2BAA2B,EAAET,MAAW,CAAC;IAC7E;IAEA,OAAOnC,UAAU,CAACI,QAAQ,CAACC,KAAK,CAAC;MAC7BC,OAAO,EAAE,kBAAkBL,KAAK,IAAI;MACpCM,IAAI,EAAE;IACV,CAAC,CAAC;EACN;EAEA,MAAcsB,cAAcA,CAACjC,OAAgB,EAAEkB,EAAU,EAAE;IACvD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMnB,OAAO,CAAC4D,KAAK,CAAC/C,OAAO,CAGxCK,EAAE,CAAC;MACL,IAAIC,MAAM,EAAE0C,YAAY,KAAKrE,2BAA2B,EAAE;QACtD,OAAO2B,MAAM;MACjB;MACA,OAAO,IAAI;IACf,CAAC,CAAC,MAAM;MACJ,OAAO,IAAI;IACf;EACJ;EAEA,MAAcqC,aAAaA,CAACxD,OAAgB,EAAEkB,EAAU,EAAE;IACtD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMnB,OAAO,CAAC4D,KAAK,CAAC/C,OAAO,CAGxCK,EAAE,CAAC;MACL,IAAIC,MAAM,EAAE0C,YAAY,IAAItE,0BAA0B,EAAE;QACpD,OAAO4B,MAAM;MACjB;MACA,OAAO,IAAI;IACf,CAAC,CAAC,MAAM;MACJ,OAAO,IAAI;IACf;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["uniqueId","TaskDataStatus","CmsImportExportFileType","ExportContentEntriesControllerState","EXPORT_BASE_PATH","EXPORT_CONTENT_ASSETS_TASK","EXPORT_CONTENT_ENTRIES_TASK","getBackOffSeconds","prepareExportModel","model","modelId","fields","ExportContentEntriesController","constructor","context","run","params","input","controller","state","cms","getModel","response","error","message","code","currentTask","getTask","backOffSeconds","iterations","entriesTask","prefix","id","result","task","trigger","definition","exportAssets","limit","where","sort","name","value","continue","contentEntriesTaskId","entryExport","seconds","getEntriesTask","taskStatus","RUNNING","PENDING","FAILED","ABORTED","output","files","length","file","push","key","checksum","type","ENTRIES","done","entryAfter","undefined","fileAfter","assetTask","contentAssetsTaskId","assetsExport","assetsTask","getAssetsTask","entriesFiles","assetFiles","ASSETS","tasks","definitionId"],"sources":["ExportContentEntriesController.ts"],"sourcesContent":["import uniqueId from \"uniqid\";\nimport { IGetTaskResponse, TaskDataStatus } from \"@webiny/tasks\";\nimport type { Context } from \"~/types.js\";\nimport { CmsImportExportFileType } from \"~/types.js\";\nimport type {\n IExportContentEntriesController,\n IControllerInput,\n IControllerOutput,\n IControllerOutputFile,\n IExportedCmsModel\n} from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport { ExportContentEntriesControllerState } from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport {\n EXPORT_BASE_PATH,\n EXPORT_CONTENT_ASSETS_TASK,\n EXPORT_CONTENT_ENTRIES_TASK\n} from \"~/tasks/constants.js\";\nimport type {\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport type {\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n} from \"~/tasks/domain/abstractions/ExportContentAssets.js\";\nimport { getBackOffSeconds } from \"~/tasks/utils/helpers/getBackOffSeconds.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nconst prepareExportModel = (model: Pick<CmsModel, \"modelId\" | \"fields\">): IExportedCmsModel => {\n return {\n modelId: model.modelId,\n fields: model.fields\n };\n};\n\nexport class ExportContentEntriesController<\n I extends IControllerInput = IControllerInput,\n O extends IControllerOutput = IControllerOutput\n> implements IExportContentEntriesController<I, O> {\n constructor(private context: Context) {}\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n const { state, modelId } = input;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n const currentTask = controller.state.getTask();\n const backOffSeconds = getBackOffSeconds(currentTask.iterations);\n\n let entriesTask: IGetTaskResponse<IExportContentEntriesInput, IExportContentEntriesOutput>;\n\n /**\n * In case of no state yet, we will start the content entries export process.\n */\n const prefix =\n input.prefix || uniqueId(`${EXPORT_BASE_PATH}/${model.modelId}/${currentTask.id}`);\n if (!state) {\n const result = await controller.task.trigger<IExportContentEntriesInput>({\n definition: EXPORT_CONTENT_ENTRIES_TASK,\n input: {\n prefix,\n exportAssets: input.exportAssets,\n modelId: model.modelId,\n limit: input.limit,\n where: input.where,\n sort: input.sort\n },\n name: `Export Content Entries ${currentTask.id}`\n });\n\n const task = result.value;\n\n return controller.response.continue(\n {\n ...input,\n prefix,\n contentEntriesTaskId: task.id,\n state: ExportContentEntriesControllerState.entryExport\n },\n {\n seconds: backOffSeconds\n }\n );\n }\n /**\n * If the state of the task is \"entryExport\", we need to check if there are any child tasks of the \"Export Content Entries\" task.\n * If there are, we need to wait for them to finish before we can proceed.\n * If there are no child tasks, we'll return an error.\n * If there are child tasks, but they are not finished, we'll return a \"continue\" response, which will make the task wait for X seconds before checking again.\n */\n //\n else if (state === ExportContentEntriesControllerState.entryExport) {\n if (!input.contentEntriesTaskId) {\n return controller.response.error({\n message: `Missing \"contentEntriesTaskId\" in the input, but the input notes that the task is in \"entryExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ENTRIES_TASK_ID\"\n });\n }\n entriesTask = await this.getEntriesTask(this.context, input.contentEntriesTaskId);\n if (!entriesTask) {\n return controller.response.error({\n message: `Task \"${input.contentEntriesTaskId}\" not found.`,\n code: \"TASK_NOT_FOUND\"\n });\n }\n if (\n entriesTask.taskStatus == TaskDataStatus.RUNNING ||\n entriesTask.taskStatus === TaskDataStatus.PENDING\n ) {\n return controller.response.continue(input, {\n seconds: backOffSeconds\n });\n } else if (entriesTask.taskStatus === TaskDataStatus.FAILED) {\n return controller.response.error({\n message: `Failed to export content entries. Task \"${entriesTask.id}\" failed.`,\n code: \"EXPORT_ENTRIES_FAILED\"\n });\n } else if (entriesTask.taskStatus === TaskDataStatus.ABORTED) {\n return controller.response.error({\n message: `Export content entries process was aborted. Task \"${entriesTask.id}\" was aborted.`,\n code: \"EXPORT_ENTRIES_ABORTED\"\n });\n } else if (!entriesTask.output) {\n return controller.response.error({\n message: `No output found on task \"${entriesTask.id}\". Stopping export process.`,\n code: \"NO_OUTPUT\"\n });\n }\n /**\n * Possibly the task does not require any assets to be exported.\n */\n if (!input.exportAssets || entriesTask.output.files.length === 0) {\n const files: IControllerOutputFile[] = [];\n for (const file of entriesTask.output.files) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ENTRIES\n });\n }\n\n const output: IControllerOutput = {\n files,\n model: prepareExportModel(model)\n };\n return controller.response.done(\"Export done, without assets.\", output as O);\n }\n\n const result = await controller.task.trigger<IExportContentAssetsInput>({\n definition: EXPORT_CONTENT_ASSETS_TASK,\n input: {\n prefix,\n modelId: model.modelId,\n limit: input.limit,\n where: input.where,\n sort: input.sort,\n entryAfter: undefined,\n fileAfter: undefined\n },\n name: `Export Content Assets ${currentTask.id}`\n });\n\n const assetTask = result.value;\n\n return controller.response.continue(\n {\n ...input,\n contentAssetsTaskId: assetTask.id,\n state: ExportContentEntriesControllerState.assetsExport\n },\n {\n seconds: backOffSeconds\n }\n );\n }\n /**\n * If the state is \"assetsExport\", we need to check if there are any child tasks of the \"Export Content Assets\" task.\n * If there are, we need to wait for them to finish before we can proceed.\n * If there are no child tasks, we'll return as done.\n * If there are child tasks, but they are not finished, we'll return a \"continue\" response, which will make the task wait for X seconds before checking again.\n */\n //\n else if (state === ExportContentEntriesControllerState.assetsExport) {\n if (!input.contentEntriesTaskId) {\n return controller.response.error({\n message: `Missing \"contentEntriesTaskId\" in the input, but the input notes that the task is in \"assetsExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ENTRIES_TASK_ID\"\n });\n } else if (!input.contentAssetsTaskId) {\n return controller.response.error({\n message: `Missing \"contentAssetsTaskId\" in the input, but the input notes that the task is in \"assetsExport\" state. This should not happen.`,\n code: \"MISSING_CONTENT_ASSETS_TASK_ID\"\n });\n }\n\n const assetsTask = await this.getAssetsTask(this.context, input.contentAssetsTaskId);\n if (!assetsTask) {\n return controller.response.error({\n message: `Task \"${input.contentAssetsTaskId}\" not found.`,\n code: \"TASK_NOT_FOUND\"\n });\n }\n if (\n assetsTask.taskStatus == TaskDataStatus.RUNNING ||\n assetsTask.taskStatus === TaskDataStatus.PENDING\n ) {\n return controller.response.continue(\n {\n ...input\n },\n {\n seconds: backOffSeconds\n }\n );\n } else if (assetsTask.taskStatus === TaskDataStatus.FAILED) {\n return controller.response.error({\n message: `Failed to export content assets. Task \"${assetsTask.id}\" failed.`,\n code: \"EXPORT_ASSETS_FAILED\"\n });\n } else if (assetsTask.taskStatus === TaskDataStatus.ABORTED) {\n return controller.response.error({\n message: `Export content assets process was aborted. Task \"${assetsTask.id}\" was aborted.`,\n code: \"EXPORT_ASSETS_ABORTED\"\n });\n }\n\n entriesTask = await this.getEntriesTask(this.context, input.contentEntriesTaskId);\n\n const files: IControllerOutputFile[] = [];\n const entriesFiles = entriesTask?.output?.files || [];\n for (const file of entriesFiles) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ENTRIES\n });\n }\n const assetFiles = assetsTask.output?.files || [];\n for (const file of assetFiles) {\n files.push({\n key: file.key,\n checksum: file.checksum,\n type: CmsImportExportFileType.ASSETS\n });\n }\n\n const output: IControllerOutput = {\n model: prepareExportModel(model),\n files\n };\n\n return controller.response.done(\"Export done, with assets.\", output as O);\n }\n\n return controller.response.error({\n message: `Invalid state \"${state}\".`,\n code: \"INVALID_STATE\"\n });\n }\n\n private async getEntriesTask(context: Context, id: string) {\n try {\n const result = await context.tasks.getTask<\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n >(id);\n if (result?.definitionId === EXPORT_CONTENT_ENTRIES_TASK) {\n return result;\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async getAssetsTask(context: Context, id: string) {\n try {\n const result = await context.tasks.getTask<\n IExportContentAssetsInput,\n IExportContentAssetsOutput\n >(id);\n if (result?.definitionId == EXPORT_CONTENT_ASSETS_TASK) {\n return result;\n }\n return null;\n } catch {\n return null;\n }\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,QAAQ;AAC7B,SAA2BC,cAAc,QAAQ,eAAe;AAEhE,SAASC,uBAAuB;AAQhC,SAASC,mCAAmC;AAC5C,SACIC,gBAAgB,EAChBC,0BAA0B,EAC1BC,2BAA2B;AAU/B,SAASC,iBAAiB;AAI1B,MAAMC,kBAAkB,GAAIC,KAA2C,IAAwB;EAC3F,OAAO;IACHC,OAAO,EAAED,KAAK,CAACC,OAAO;IACtBC,MAAM,EAAEF,KAAK,CAACE;EAClB,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,8BAA8B,CAGQ;EAC/CC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;EAAG;EACvC,MAAaC,GAAGA,CAACC,MAAsC,EAAE;IACrD,MAAM;MAAEC,KAAK;MAAEC;IAAW,CAAC,GAAGF,MAAM;IACpC,MAAM;MAAEG,KAAK;MAAET;IAAQ,CAAC,GAAGO,KAAK;IAEhC,IAAIR,KAAe;IACnB,IAAI;MACAA,KAAK,GAAG,MAAM,IAAI,CAACK,OAAO,CAACM,GAAG,CAACC,QAAQ,CAACX,OAAO,CAAC;IACpD,CAAC,CAAC,MAAM;MACJ,OAAOQ,UAAU,CAACI,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,UAAUd,OAAO,cAAc;QACxCe,I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EAAE;IACV,CAAC,CAAC;EACN;EAEA,MAAcsB,cAAcA,CAACjC,OAAgB,EAAEkB,EAAU,EAAE;IACvD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMnB,OAAO,CAAC4D,KAAK,CAAC/C,OAAO,CAGxCK,EAAE,CAAC;MACL,IAAIC,MAAM,EAAE0C,YAAY,KAAKrE,2BAA2B,EAAE;QACtD,OAAO2B,MAAM;MACjB;MACA,OAAO,IAAI;IACf,CAAC,CAAC,MAAM;MACJ,OAAO,IAAI;IACf;EACJ;EAEA,MAAcqC,aAAaA,CAACxD,OAAgB,EAAEkB,EAAU,EAAE;IACtD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAMnB,OAAO,CAAC4D,KAAK,CAAC/C,OAAO,CAGxCK,EAAE,CAAC;MACL,IAAIC,MAAM,EAAE0C,YAAY,IAAItE,0BAA0B,EAAE;QACpD,OAAO4B,MAAM;MACjB;MACA,OAAO,IAAI;IACf,CAAC,CAAC,MAAM;MACJ,OAAO,IAAI;IACf;EACJ;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TaskDefinition","CmsContext","EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK","ExportContentEntriesControllerTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ExportContentEntriesController","controller","ex","response","error","ExportContentEntriesControllerTask","createImplementation","implementation","dependencies"],"sources":["ExportContentEntriesControllerTask.ts"],"sourcesContent":["import type * as Controller from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n Controller.IControllerInput,\n Controller.IControllerOutput\n>;\n\nclass ExportContentEntriesControllerTaskDefinition\n implements TaskDefinition.Interface<Controller.IControllerInput, Controller.IControllerOutput>\n{\n id = EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK;\n title = \"Export Content Entries and Assets Controller\";\n maxIterations = 100;\n isPrivate = true;\n description = \"Export content entries and assets from a specific model - controller.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ExportContentEntriesController } = await import(\n /* webpackChunkName: \"ExportContentEntriesController\" */ \"./ExportContentEntriesController.js\"\n );\n\n try {\n const controller = new ExportContentEntriesController(this.context as Context);\n return await controller.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentEntriesControllerTask = TaskDefinition.createImplementation({\n implementation: ExportContentEntriesControllerTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,sCAAsC;AAO/C,MAAMC,4CAA4C,CAElD;EACIC,EAAE,GAAGF,sCAAsC;EAC3CG,KAAK,GAAG,8CAA8C;EACtDC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,uEAAuE;EAErFC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA+B,CAAC,GAAG,MAAM,MAAM,CACnD,6FACJ,CAAC;IAED,IAAI;MACA,MAAMC,UAAU,GAAG,IAAID,8BAA8B,CAAC,IAAI,CAACH,OAAkB,CAAC;MAC9E,OAAO,MAAMI,UAAU,CAACH,GAAG,CAACC,MAAM,CAAC;IACvC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACE,UAAU,CAACE,QAAQ,CAACC,KAAK,CAACF,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMG,kCAAkC,GAAGlB,cAAc,CAACmB,oBAAoB,CAAC;EAClFC,cAAc,EAAEjB,4CAA4C;EAC5DkB,YAAY,EAAE,CAACpB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","CmsContext","EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK","ExportContentEntriesControllerTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ExportContentEntriesController","controller","ex","response","error","ExportContentEntriesControllerTask","createImplementation","implementation","dependencies"],"sources":["ExportContentEntriesControllerTask.ts"],"sourcesContent":["import type * as Controller from \"~/tasks/domain/abstractions/ExportContentEntriesController.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n Controller.IControllerInput,\n Controller.IControllerOutput\n>;\n\nclass ExportContentEntriesControllerTaskDefinition implements TaskDefinition.Interface<\n Controller.IControllerInput,\n Controller.IControllerOutput\n> {\n id = EXPORT_CONTENT_ENTRIES_CONTROLLER_TASK;\n title = \"Export Content Entries and Assets Controller\";\n maxIterations = 100;\n isPrivate = true;\n description = \"Export content entries and assets from a specific model - controller.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ExportContentEntriesController } = await import(\n /* webpackChunkName: \"ExportContentEntriesController\" */ \"./ExportContentEntriesController.js\"\n );\n\n try {\n const controller = new ExportContentEntriesController(this.context as Context);\n return await controller.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentEntriesControllerTask = TaskDefinition.createImplementation({\n implementation: ExportContentEntriesControllerTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,sCAAsC;AAO/C,MAAMC,4CAA4C,CAGhD;EACEC,EAAE,GAAGF,sCAAsC;EAC3CG,KAAK,GAAG,8CAA8C;EACtDC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,uEAAuE;EAErFC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA+B,CAAC,GAAG,MAAM,MAAM,CACnD,6FACJ,CAAC;IAED,IAAI;MACA,MAAMC,UAAU,GAAG,IAAID,8BAA8B,CAAC,IAAI,CAACH,OAAkB,CAAC;MAC9E,OAAO,MAAMI,UAAU,CAACH,GAAG,CAACC,MAAM,CAAC;IACvC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACE,UAAU,CAACE,QAAQ,CAACC,KAAK,CAACF,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMG,kCAAkC,GAAGlB,cAAc,CAACmB,oBAAoB,CAAC;EAClFC,cAAc,EAAEjB,4CAA4C;EAC5DkB,YAAY,EAAE,CAACpB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ExportContentEntriesControllerTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ExportContentEntriesControllerTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["getErrorProperties","CmsEntryZipperExecuteContinueResult","createCmsEntryFetcher","ContentEntryTraverserProvider","WEBINY_EXPORT_ENTRIES_EXTENSION","ExportContentEntries","constructor","config","context","createCmsEntryZipper","run","params","input","controller","prefix","basePrefix","model","cms","getModel","modelId","ex","response","error","message","code","data","fetcher","after","where","limit","sort","items","meta","listLatestEntries","filenamePrefix","filter","Boolean","join","filename","traverserProvider","container","resolve","traverser","getTraverser","entryZipper","result","execute","isCloseToTimeout","runtime","isAborted","exportAssets","files","concat","key","checksum","continue","cursor","output","done"],"sources":["ExportContentEntries.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getErrorProperties } from \"@webiny/tasks/utils/index.js\";\nimport type { ICmsEntryZipper, ICmsEntryZipperConfig } from \"~/tasks/utils/cmsEntryZipper/index.js\";\nimport { CmsEntryZipperExecuteContinueResult } from \"~/tasks/utils/cmsEntryZipper/index.js\";\nimport type {\n IExportContentEntries,\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport { createCmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/createCmsEntryFetcher.js\";\nimport {\n ContentEntryTraverserProvider,\n type IContentEntryTraverser\n} from \"@webiny/api-headless-cms\";\nimport { WEBINY_EXPORT_ENTRIES_EXTENSION } from \"~/tasks/constants.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface IExportContentEntriesConfig {\n context: Context;\n createCmsEntryZipper(config: Pick<ICmsEntryZipperConfig, \"fetcher\">): ICmsEntryZipper;\n}\n\nexport interface ICreateCmsEntryZipperConfig extends Pick<ICmsEntryZipperConfig, \"fetcher\"> {\n filename: string;\n model: Pick<CmsModel, \"modelId\">;\n traverser: IContentEntryTraverser;\n}\n\nexport class ExportContentEntries<\n I extends IExportContentEntriesInput = IExportContentEntriesInput,\n O extends IExportContentEntriesOutput = IExportContentEntriesOutput\n> implements IExportContentEntries<I, O>\n{\n private readonly createCmsEntryZipper: (config: ICreateCmsEntryZipperConfig) => ICmsEntryZipper;\n private readonly context: Context;\n\n public constructor(config: IExportContentEntriesConfig) {\n this.context = config.context;\n this.createCmsEntryZipper = config.createCmsEntryZipper;\n }\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n const { prefix: basePrefix } = input;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(input.modelId);\n } catch (ex) {\n return controller.response.error({\n message: `Could not fetch entry manager for model \"${input.modelId}\".`,\n code: \"MODEL_NOT_FOUND\",\n data: {\n error: getErrorProperties(ex)\n }\n });\n }\n\n const prefix = `${basePrefix}/entries`;\n const fetcher = createCmsEntryFetcher(async after => {\n const input = {\n where: params.input.where,\n limit: params.input.limit || 100000,\n sort: params.input.sort,\n after\n };\n const [items, meta] = await this.context.cms.listLatestEntries(model, input);\n\n return {\n items,\n meta\n };\n });\n\n const filenamePrefix = [prefix, input.after].filter(Boolean).join(\"-\");\n\n const filename = `${filenamePrefix}.${WEBINY_EXPORT_ENTRIES_EXTENSION}`;\n\n const traverserProvider = this.context.container.resolve(ContentEntryTraverserProvider);\n const traverser = await traverserProvider.getTraverser(model.modelId);\n\n const entryZipper = this.createCmsEntryZipper({\n filename,\n model,\n fetcher,\n traverser\n });\n\n const result = await entryZipper.execute({\n isCloseToTimeout: () => controller.runtime.isCloseToTimeout(),\n isAborted: () => controller.runtime.isAborted(),\n model,\n after: input.after,\n exportAssets: input.exportAssets\n });\n\n const files = (input.files || []).concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ]);\n\n if (result instanceof CmsEntryZipperExecuteContinueResult) {\n return controller.response.continue({\n ...input,\n files,\n after: result.cursor\n });\n }\n const output: IExportContentEntriesOutput = {\n files\n };\n return controller.response.done(output as O);\n }\n}\n"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,8BAA8B;AAEjE,SAASC,mCAAmC;AAM5C,SAASC,qBAAqB;AAC9B,SACIC,6BAA6B,QAE1B,0BAA0B;AACjC,SAASC,+BAA+B;AAcxC,OAAO,MAAMC,oBAAoB,CAIjC;EAIWC,WAAWA,CAACC,MAAmC,EAAE;IACpD,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,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perties","CmsEntryZipperExecuteContinueResult","createCmsEntryFetcher","ContentEntryTraverserProvider","WEBINY_EXPORT_ENTRIES_EXTENSION","ExportContentEntries","constructor","config","context","createCmsEntryZipper","run","params","input","controller","prefix","basePrefix","model","cms","getModel","modelId","ex","response","error","message","code","data","fetcher","after","where","limit","sort","items","meta","listLatestEntries","filenamePrefix","filter","Boolean","join","filename","traverserProvider","container","resolve","traverser","getTraverser","entryZipper","result","execute","isCloseToTimeout","runtime","isAborted","exportAssets","files","concat","key","checksum","continue","cursor","output","done"],"sources":["ExportContentEntries.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { getErrorProperties } from \"@webiny/tasks/utils/index.js\";\nimport type { ICmsEntryZipper, ICmsEntryZipperConfig } from \"~/tasks/utils/cmsEntryZipper/index.js\";\nimport { CmsEntryZipperExecuteContinueResult } from \"~/tasks/utils/cmsEntryZipper/index.js\";\nimport type {\n IExportContentEntries,\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport { createCmsEntryFetcher } from \"~/tasks/utils/cmsEntryFetcher/createCmsEntryFetcher.js\";\nimport {\n ContentEntryTraverserProvider,\n type IContentEntryTraverser\n} from \"@webiny/api-headless-cms\";\nimport { WEBINY_EXPORT_ENTRIES_EXTENSION } from \"~/tasks/constants.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nexport interface IExportContentEntriesConfig {\n context: Context;\n createCmsEntryZipper(config: Pick<ICmsEntryZipperConfig, \"fetcher\">): ICmsEntryZipper;\n}\n\nexport interface ICreateCmsEntryZipperConfig extends Pick<ICmsEntryZipperConfig, \"fetcher\"> {\n filename: string;\n model: Pick<CmsModel, \"modelId\">;\n traverser: IContentEntryTraverser;\n}\n\nexport class ExportContentEntries<\n I extends IExportContentEntriesInput = IExportContentEntriesInput,\n O extends IExportContentEntriesOutput = IExportContentEntriesOutput\n> implements IExportContentEntries<I, O> {\n private readonly createCmsEntryZipper: (config: ICreateCmsEntryZipperConfig) => ICmsEntryZipper;\n private readonly context: Context;\n\n public constructor(config: IExportContentEntriesConfig) {\n this.context = config.context;\n this.createCmsEntryZipper = config.createCmsEntryZipper;\n }\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n const { prefix: basePrefix } = input;\n\n let model: CmsModel;\n try {\n model = await this.context.cms.getModel(input.modelId);\n } catch (ex) {\n return controller.response.error({\n message: `Could not fetch entry manager for model \"${input.modelId}\".`,\n code: \"MODEL_NOT_FOUND\",\n data: {\n error: getErrorProperties(ex)\n }\n });\n }\n\n const prefix = `${basePrefix}/entries`;\n const fetcher = createCmsEntryFetcher(async after => {\n const input = {\n where: params.input.where,\n limit: params.input.limit || 100000,\n sort: params.input.sort,\n after\n };\n const [items, meta] = await this.context.cms.listLatestEntries(model, input);\n\n return {\n items,\n meta\n };\n });\n\n const filenamePrefix = [prefix, input.after].filter(Boolean).join(\"-\");\n\n const filename = `${filenamePrefix}.${WEBINY_EXPORT_ENTRIES_EXTENSION}`;\n\n const traverserProvider = this.context.container.resolve(ContentEntryTraverserProvider);\n const traverser = await traverserProvider.getTraverser(model.modelId);\n\n const entryZipper = this.createCmsEntryZipper({\n filename,\n model,\n fetcher,\n traverser\n });\n\n const result = await entryZipper.execute({\n isCloseToTimeout: () => controller.runtime.isCloseToTimeout(),\n isAborted: () => controller.runtime.isAborted(),\n model,\n after: input.after,\n exportAssets: input.exportAssets\n });\n\n const files = (input.files || []).concat([\n {\n key: result.key,\n checksum: result.checksum\n }\n ]);\n\n if (result instanceof CmsEntryZipperExecuteContinueResult) {\n return controller.response.continue({\n ...input,\n files,\n after: result.cursor\n });\n }\n const output: IExportContentEntriesOutput = {\n files\n };\n return controller.response.done(output as O);\n }\n}\n"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,8BAA8B;AAEjE,SAASC,mCAAmC;AAM5C,SAASC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,EAAEkB,MAAM,CAACW;MAClB,CAAC,CAAC;IACN;IACA,MAAMC,MAAmC,GAAG;MACxCN;IACJ,CAAC;IACD,OAAOtC,UAAU,CAACQ,QAAQ,CAACqC,IAAI,CAACD,MAAW,CAAC;EAChD;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TaskDefinition","CmsContext","EXPORT_CONTENT_ENTRIES_TASK","ExportContentEntriesTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createExportContentEntries","runner","ex","controller","response","error","ExportContentEntriesTask","createImplementation","implementation","dependencies"],"sources":["ExportContentEntriesTask.ts"],"sourcesContent":["import type {\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ENTRIES_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IExportContentEntriesInput, IExportContentEntriesOutput>;\n\nclass ExportContentEntriesTaskDefinition\n implements TaskDefinition.Interface<IExportContentEntriesInput, IExportContentEntriesOutput>\n{\n id = EXPORT_CONTENT_ENTRIES_TASK;\n title = \"Export Content Entries\";\n maxIterations = 50;\n isPrivate = true;\n description = \"Export content entries from a specific model.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createExportContentEntries } = await import(\n /* webpackChunkName: \"createExportContentEntries\" */ \"./createExportContentEntries.js\"\n );\n\n try {\n const runner = createExportContentEntries(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentEntriesTask = TaskDefinition.createImplementation({\n implementation: ExportContentEntriesTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAIA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,2BAA2B;AAIpC,MAAMC,kCAAkC,CAExC;EACIC,EAAE,GAAGF,2BAA2B;EAChCG,KAAK,GAAG,wBAAwB;EAChCC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,+CAA+C;EAE7DC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA2B,CAAC,GAAG,MAAM,MAAM,CAC/C,qFACJ,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAGD,0BAA0B,CAAC,IAAI,CAACH,OAAkB,CAAC;MAClE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,wBAAwB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACxEC,cAAc,EAAElB,kCAAkC;EAClDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","CmsContext","EXPORT_CONTENT_ENTRIES_TASK","ExportContentEntriesTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createExportContentEntries","runner","ex","controller","response","error","ExportContentEntriesTask","createImplementation","implementation","dependencies"],"sources":["ExportContentEntriesTask.ts"],"sourcesContent":["import type {\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n} from \"~/tasks/domain/abstractions/ExportContentEntries.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { Context } from \"~/types.js\";\nimport { EXPORT_CONTENT_ENTRIES_TASK } from \"~/tasks/constants.js\";\n\ntype IRunParams = TaskDefinition.RunParams<IExportContentEntriesInput, IExportContentEntriesOutput>;\n\nclass ExportContentEntriesTaskDefinition implements TaskDefinition.Interface<\n IExportContentEntriesInput,\n IExportContentEntriesOutput\n> {\n id = EXPORT_CONTENT_ENTRIES_TASK;\n title = \"Export Content Entries\";\n maxIterations = 50;\n isPrivate = true;\n description = \"Export content entries from a specific model.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createExportContentEntries } = await import(\n /* webpackChunkName: \"createExportContentEntries\" */ \"./createExportContentEntries.js\"\n );\n\n try {\n const runner = createExportContentEntries(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ExportContentEntriesTask = TaskDefinition.createImplementation({\n implementation: ExportContentEntriesTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAIA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AAErF,SAASC,2BAA2B;AAIpC,MAAMC,kCAAkC,CAGtC;EACEC,EAAE,GAAGF,2BAA2B;EAChCG,KAAK,GAAG,wBAAwB;EAChCC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,+CAA+C;EAE7DC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAA2B,CAAC,GAAG,MAAM,MAAM,CAC/C,qFACJ,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAGD,0BAA0B,CAAC,IAAI,CAACH,OAAkB,CAAC;MAClE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,wBAAwB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACxEC,cAAc,EAAElB,kCAAkC;EAClDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ExportContentEntriesTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ExportContentEntriesTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["IImportFromUrlControllerInputStep","ImportFromUrlControllerDownloadStep","ImportFromUrlControllerProcessEntriesStep","ImportFromUrlControllerProcessAssetsStep","getDefaultStepValues","files","triggered","finished","done","failed","invalid","aborted","ImportFromUrlController","constructor","context","run","params","input","controller","modelId","response","error","message","code","Array","isArray","length","cms","getModel","steps","downloadStep","DOWNLOAD","step","execute","data","processEntriesStep","PROCESS_ENTRIES","processAssetsStep","PROCESS_ASSETS","concat","output"],"sources":["ImportFromUrlController.ts"],"sourcesContent":["import type {\n IImportFromUrlController,\n IImportFromUrlControllerInput,\n IImportFromUrlControllerInputStepsStep,\n IImportFromUrlControllerOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport { IImportFromUrlControllerInputStep } from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport type { Context } from \"~/types.js\";\nimport { ImportFromUrlControllerDownloadStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.js\";\nimport { ImportFromUrlControllerProcessEntriesStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.js\";\nimport { ImportFromUrlControllerProcessAssetsStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nconst getDefaultStepValues = (): IImportFromUrlControllerInputStepsStep => {\n return {\n files: [],\n triggered: false,\n finished: false,\n done: [],\n failed: [],\n invalid: [],\n aborted: []\n };\n};\n\nexport class ImportFromUrlController<\n I extends IImportFromUrlControllerInput = IImportFromUrlControllerInput,\n O extends IImportFromUrlControllerOutput = IImportFromUrlControllerOutput\n> implements IImportFromUrlController<I, O>\n{\n constructor(private context: Context) {}\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n if (!input.modelId) {\n return controller.response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (Array.isArray(input.files) === false || input.files.length === 0) {\n return controller.response.error({\n message: `No files found in the provided data.`,\n code: \"NO_FILES_FOUND\"\n });\n }\n\n try {\n await this.context.cms.getModel(input.modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${input.modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n if (!input.steps) {\n input.steps = {};\n }\n\n const downloadStep =\n input.steps[IImportFromUrlControllerInputStep.DOWNLOAD] || getDefaultStepValues();\n\n if (!downloadStep.finished) {\n const step = new ImportFromUrlControllerDownloadStep<I, O>(this.context);\n return await step.execute({ input, controller });\n } else if (downloadStep.failed.length) {\n return controller.response.error({\n message: `Failed to download files.`,\n code: \"FAILED_DOWNLOADING_FILES\",\n data: input.steps\n });\n }\n\n const processEntriesStep =\n input.steps[IImportFromUrlControllerInputStep.PROCESS_ENTRIES] ||\n getDefaultStepValues();\n if (!processEntriesStep.finished) {\n const step = new ImportFromUrlControllerProcessEntriesStep<I, O>(this.context);\n return await step.execute(params);\n } else if (processEntriesStep.failed.length) {\n return controller.response.error({\n message: `Failed to process entries.`,\n code: \"FAILED_PROCESSING_ENTRIES\",\n data: input.steps\n });\n }\n\n const processAssetsStep =\n input.steps[IImportFromUrlControllerInputStep.PROCESS_ASSETS] || getDefaultStepValues();\n if (!processAssetsStep.finished) {\n const step = new ImportFromUrlControllerProcessAssetsStep<I, O>(this.context);\n return await step.execute(params);\n } else if (processAssetsStep.failed.length) {\n return controller.response.error({\n message: `Failed to process assets.`,\n code: \"FAILED_PROCESSING_ASSETS\",\n data: input.steps\n });\n }\n\n const files = downloadStep.files\n .concat(processEntriesStep.files)\n .concat(processAssetsStep.files);\n\n const output: IImportFromUrlControllerOutput = {\n files,\n done: [],\n invalid: [],\n failed: [],\n aborted: []\n };\n\n return controller.response.done(output as O);\n }\n}\n"],"mappings":"AAMA,SAASA,iCAAiC;AAE1C,SAASC,mCAAmC;AAC5C,SAASC,yCAAyC;AAClD,SAASC,wCAAwC;AAGjD,MAAMC,oBAAoB,GAAGA,CAAA,KAA8C;EACvE,OAAO;IACHC,KAAK,EAAE,EAAE;IACTC,SAAS,EAAE,KAAK;IAChBC,QAAQ,EAAE,KAAK;IACfC,IAAI,EAAE,EAAE;IACRC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,EAAE;IACXC,OAAO,EAAE;EACb,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,uBAAuB,CAIpC;EACIC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;EAAG;EAEvC,MAAaC,GAAGA,CAACC,MAAsC,EAAE;IACrD,MAAM;MAAEC,KAAK;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAEpC,IAAI,CAACC,KAAK,CAACE,OAAO,EAAE;MAChB,OAAOD,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,iCAAiC;QAC1CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACR,KAAK,CAACZ,KAAK,CAAC,KAAK,KAAK,IAAIY,KAAK,CAACZ,KAAK,CAACqB,MAAM,KAAK,CAAC,EAAE;MACzE,OAAOR,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC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ImportFromUrlControllerProcessEntriesStep","ImportFromUrlControllerProcessAssetsStep","getDefaultStepValues","files","triggered","finished","done","failed","invalid","aborted","ImportFromUrlController","constructor","context","run","params","input","controller","modelId","response","error","message","code","Array","isArray","length","cms","getModel","steps","downloadStep","DOWNLOAD","step","execute","data","processEntriesStep","PROCESS_ENTRIES","processAssetsStep","PROCESS_ASSETS","concat","output"],"sources":["ImportFromUrlController.ts"],"sourcesContent":["import type {\n IImportFromUrlController,\n IImportFromUrlControllerInput,\n IImportFromUrlControllerInputStepsStep,\n IImportFromUrlControllerOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport { IImportFromUrlControllerInputStep } from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport type { Context } from \"~/types.js\";\nimport { ImportFromUrlControllerDownloadStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerDownloadStep.js\";\nimport { ImportFromUrlControllerProcessEntriesStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessEntriesStep.js\";\nimport { ImportFromUrlControllerProcessAssetsStep } from \"~/tasks/domain/importFromUrlControllerSteps/ImportFromUrlControllerProcessAssetsStep.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\nconst getDefaultStepValues = (): IImportFromUrlControllerInputStepsStep => {\n return {\n files: [],\n triggered: false,\n finished: false,\n done: [],\n failed: [],\n invalid: [],\n aborted: []\n };\n};\n\nexport class ImportFromUrlController<\n I extends IImportFromUrlControllerInput = IImportFromUrlControllerInput,\n O extends IImportFromUrlControllerOutput = IImportFromUrlControllerOutput\n> implements IImportFromUrlController<I, O> {\n constructor(private context: Context) {}\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n if (!input.modelId) {\n return controller.response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (Array.isArray(input.files) === false || input.files.length === 0) {\n return controller.response.error({\n message: `No files found in the provided data.`,\n code: \"NO_FILES_FOUND\"\n });\n }\n\n try {\n await this.context.cms.getModel(input.modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${input.modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n if (!input.steps) {\n input.steps = {};\n }\n\n const downloadStep =\n input.steps[IImportFromUrlControllerInputStep.DOWNLOAD] || getDefaultStepValues();\n\n if (!downloadStep.finished) {\n const step = new ImportFromUrlControllerDownloadStep<I, O>(this.context);\n return await step.execute({ input, controller });\n } else if (downloadStep.failed.length) {\n return controller.response.error({\n message: `Failed to download files.`,\n code: \"FAILED_DOWNLOADING_FILES\",\n data: input.steps\n });\n }\n\n const processEntriesStep =\n input.steps[IImportFromUrlControllerInputStep.PROCESS_ENTRIES] ||\n getDefaultStepValues();\n if (!processEntriesStep.finished) {\n const step = new ImportFromUrlControllerProcessEntriesStep<I, O>(this.context);\n return await step.execute(params);\n } else if (processEntriesStep.failed.length) {\n return controller.response.error({\n message: `Failed to process entries.`,\n code: \"FAILED_PROCESSING_ENTRIES\",\n data: input.steps\n });\n }\n\n const processAssetsStep =\n input.steps[IImportFromUrlControllerInputStep.PROCESS_ASSETS] || getDefaultStepValues();\n if (!processAssetsStep.finished) {\n const step = new ImportFromUrlControllerProcessAssetsStep<I, O>(this.context);\n return await step.execute(params);\n } else if (processAssetsStep.failed.length) {\n return controller.response.error({\n message: `Failed to process assets.`,\n code: \"FAILED_PROCESSING_ASSETS\",\n data: input.steps\n });\n }\n\n const files = downloadStep.files\n .concat(processEntriesStep.files)\n .concat(processAssetsStep.files);\n\n const output: IImportFromUrlControllerOutput = {\n files,\n done: [],\n invalid: [],\n failed: [],\n aborted: []\n };\n\n return controller.response.done(output as O);\n }\n}\n"],"mappings":"AAMA,SAASA,iCAAiC;AAE1C,SAASC,mCAAmC;AAC5C,SAASC,yCAAyC;AAClD,SAASC,wCAAwC;AAGjD,MAAMC,oBAAoB,GAAGA,CAAA,KAA8C;EACvE,OA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AAO,IAAI,CAACW,OAAO,CAAC;MAC7E,OAAO,MAAMkB,IAAI,CAACC,OAAO,CAACjB,MAAM,CAAC;IACrC,CAAC,MAAM,IAAIqB,iBAAiB,CAAC5B,MAAM,CAACiB,MAAM,EAAE;MACxC,OAAOR,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,2BAA2B;QACpCC,IAAI,EAAE,0BAA0B;QAChCW,IAAI,EAAEjB,KAAK,CAACY;MAChB,CAAC,CAAC;IACN;IAEA,MAAMxB,KAAK,GAAGyB,YAAY,CAACzB,KAAK,CAC3BkC,MAAM,CAACJ,kBAAkB,CAAC9B,KAAK,CAAC,CAChCkC,MAAM,CAACF,iBAAiB,CAAChC,KAAK,CAAC;IAEpC,MAAMmC,MAAsC,GAAG;MAC3CnC,KAAK;MACLG,IAAI,EAAE,EAAE;MACRE,OAAO,EAAE,EAAE;MACXD,MAAM,EAAE,EAAE;MACVE,OAAO,EAAE;IACb,CAAC;IAED,OAAOO,UAAU,CAACE,QAAQ,CAACZ,IAAI,CAACgC,MAAW,CAAC;EAChD;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TaskDefinition","IMPORT_FROM_URL_CONTROLLER_TASK","CmsContext","ImportFromUrlControllerTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ImportFromUrlController","runner","ex","controller","response","error","onDone","task","createDeleteFiles","deleteFiles","execute","output","files","ImportFromUrlControllerTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlControllerTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { IMPORT_FROM_URL_CONTROLLER_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n>;\n\nclass ImportFromUrlControllerTaskDefinition\n implements\n TaskDefinition.Interface<IImportFromUrlControllerInput, IImportFromUrlControllerOutput>\n{\n id = IMPORT_FROM_URL_CONTROLLER_TASK;\n title = \"Import from URL List - Controller\";\n maxIterations = 500;\n isPrivate = true;\n description = \"Imports the data from the given URL list - controller.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ImportFromUrlController } = await import(\"./ImportFromUrlController.js\");\n\n try {\n const runner = new ImportFromUrlController(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n\n async onDone({\n task\n }: TaskDefinition.LifecycleHookParams<\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n >) {\n const { createDeleteFiles } = await import(\"./deleteFiles/DeleteFiles.js\");\n\n const deleteFiles = createDeleteFiles();\n\n await deleteFiles.execute(task.output?.files);\n }\n}\n\nexport const ImportFromUrlControllerTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlControllerTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,+BAA+B;AAMxC,SAASC,UAAU,QAAQ,0DAA0D;AAOrF,MAAMC,qCAAqC,CAG3C;EACIC,EAAE,GAAGH,+BAA+B;EACpCI,KAAK,GAAG,mCAAmC;EAC3CC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,wDAAwD;EAEtEC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAwB,CAAC,GAAG,MAAM,MAAM,+BAA+B,CAAC;IAEhF,IAAI;MACA,MAAMC,MAAM,GAAG,IAAID,uBAAuB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACnE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;EAEA,MAAMI,MAAMA,CAAC;IACTC;EAIJ,CAAC,EAAE;IACC,MAAM;MAAEC;IAAkB,CAAC,GAAG,MAAM,MAAM,+BAA+B,CAAC;IAE1E,MAAMC,WAAW,GAAGD,iBAAiB,CAAC,CAAC;IAEvC,MAAMC,WAAW,CAACC,OAAO,CAACH,IAAI,CAACI,MAAM,EAAEC,KAAK,CAAC;EACjD;AACJ;AAEA,OAAO,MAAMC,2BAA2B,GAAG1B,cAAc,CAAC2B,oBAAoB,CAAC;EAC3EC,cAAc,EAAEzB,qCAAqC;EACrD0B,YAAY,EAAE,CAAC3B,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","IMPORT_FROM_URL_CONTROLLER_TASK","CmsContext","ImportFromUrlControllerTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ImportFromUrlController","runner","ex","controller","response","error","onDone","task","createDeleteFiles","deleteFiles","execute","output","files","ImportFromUrlControllerTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlControllerTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { IMPORT_FROM_URL_CONTROLLER_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlController.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n>;\n\nclass ImportFromUrlControllerTaskDefinition implements TaskDefinition.Interface<\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n> {\n id = IMPORT_FROM_URL_CONTROLLER_TASK;\n title = \"Import from URL List - Controller\";\n maxIterations = 500;\n isPrivate = true;\n description = \"Imports the data from the given URL list - controller.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ImportFromUrlController } = await import(\"./ImportFromUrlController.js\");\n\n try {\n const runner = new ImportFromUrlController(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n\n async onDone({\n task\n }: TaskDefinition.LifecycleHookParams<\n IImportFromUrlControllerInput,\n IImportFromUrlControllerOutput\n >) {\n const { createDeleteFiles } = await import(\"./deleteFiles/DeleteFiles.js\");\n\n const deleteFiles = createDeleteFiles();\n\n await deleteFiles.execute(task.output?.files);\n }\n}\n\nexport const ImportFromUrlControllerTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlControllerTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,+BAA+B;AAMxC,SAASC,UAAU,QAAQ,0DAA0D;AAOrF,MAAMC,qCAAqC,CAGzC;EACEC,EAAE,GAAGH,+BAA+B;EACpCI,KAAK,GAAG,mCAAmC;EAC3CC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,wDAAwD;EAEtEC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAwB,CAAC,GAAG,MAAM,MAAM,+BAA+B,CAAC;IAEhF,IAAI;MACA,MAAMC,MAAM,GAAG,IAAID,uBAAuB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACnE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;EAEA,MAAMI,MAAMA,CAAC;IACTC;EAIJ,CAAC,EAAE;IACC,MAAM;MAAEC;IAAkB,CAAC,GAAG,MAAM,MAAM,+BAA+B,CAAC;IAE1E,MAAMC,WAAW,GAAGD,iBAAiB,CAAC,CAAC;IAEvC,MAAMC,WAAW,CAACC,OAAO,CAACH,IAAI,CAACI,MAAM,EAAEC,KAAK,CAAC;EACjD;AACJ;AAEA,OAAO,MAAMC,2BAA2B,GAAG1B,cAAc,CAAC2B,oBAAoB,CAAC;EAC3EC,cAAc,EAAEzB,qCAAqC;EACrD0B,YAAY,EAAE,CAAC3B,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ImportFromUrlControllerTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ImportFromUrlControllerTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["createS3Client","getBucket","createMultipartUpload","createMultipartUploadFactory","prependImportPath","createDownloadFileFromUrl","ImportFromUrlDownload","constructor","context","run","params","input","controller","modelId","response","error","message","code","file","cms","getModel","client","filename","key","uploadFactory","bucket","createHandler","uploadParams","uploadId","upload","start","download","fetch","url","get","size","nextRange","result","process","stop","isClose","runtime","isCloseToTimeout","isAborted","ex","abort","aborted","continueValue","getUploadId","done","isDone","getNextRange","continue","output"],"sources":["ImportFromUrlDownload.ts"],"sourcesContent":["import type {\n IImportFromUrlDownload,\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlDownload.js\";\nimport type { Context } from \"~/types.js\";\nimport { createS3Client } from \"~/tasks/utils/helpers/s3Client.js\";\nimport { getBucket } from \"~/tasks/utils/helpers/getBucket.js\";\nimport type { IMultipartUploadFactoryContinueParams } from \"~/tasks/utils/upload/index.js\";\nimport { createMultipartUpload, createMultipartUploadFactory } from \"~/tasks/utils/upload/index.js\";\nimport { prependImportPath } from \"~/tasks/utils/helpers/importPath.js\";\nimport type { IDownloadFileFromUrlProcessResponseType } from \"~/tasks/domain/downloadFileFromUrl/index.js\";\nimport { createDownloadFileFromUrl } from \"~/tasks/domain/downloadFileFromUrl/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\ntype ProcessType = IDownloadFileFromUrlProcessResponseType<\"continue\" | \"aborted\">;\n\nexport class ImportFromUrlDownload<\n I extends IImportFromUrlDownloadInput = IImportFromUrlDownloadInput,\n O extends IImportFromUrlDownloadOutput = IImportFromUrlDownloadOutput\n> implements IImportFromUrlDownload<I, O>\n{\n constructor(private context: Context) {}\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n if (!input.modelId) {\n return controller.response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (!input.file) {\n return controller.response.error({\n message: `No file found in the provided data.`,\n code: \"NO_FILE_FOUND\"\n });\n }\n\n try {\n await this.context.cms.getModel(input.modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${input.modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n const client = createS3Client();\n\n const filename = prependImportPath(input.file.key);\n const uploadFactory = createMultipartUploadFactory({\n client,\n bucket: getBucket(),\n filename,\n createHandler: createMultipartUpload\n });\n\n const uploadParams: IMultipartUploadFactoryContinueParams = {\n uploadId: input.uploadId\n };\n const upload = await uploadFactory.start(uploadParams);\n\n const download = createDownloadFileFromUrl({\n fetch,\n file: {\n url: input.file.get,\n size: input.file.size,\n key: input.file.key\n },\n nextRange: input.nextRange,\n upload\n });\n let result: ProcessType;\n try {\n result = await download.process<ProcessType>(async ({ stop }) => {\n const isClose = controller.runtime.isCloseToTimeout();\n if (isClose) {\n return stop(\"continue\");\n } else if (controller.runtime.isAborted()) {\n return stop(\"aborted\");\n }\n });\n } catch (ex) {\n return controller.response.error(ex);\n }\n\n switch (result) {\n case \"aborted\":\n await upload.abort();\n return controller.response.aborted();\n case \"continue\":\n const continueValue: I = {\n ...input,\n uploadId: upload.getUploadId(),\n done: download.isDone(),\n nextRange: download.getNextRange()\n };\n return controller.response.continue({\n ...continueValue\n });\n case \"done\":\n const output: IImportFromUrlDownloadOutput = {\n file: filename\n };\n return controller.response.done(output as O);\n /**\n * There should be nothing else other than \"continue\" or \"aborted\" or null.\n */\n default:\n await upload.abort();\n return controller.response.error({\n message: `Method not implemented. Result: ${result}`\n });\n }\n }\n}\n"],"mappings":"AAMA,SAASA,cAAc;AACvB,SAASC,SAAS;AAElB,SAASC,qBAAqB,EAAEC,4BAA4B;AAC5D,SAASC,iBAAiB;AAE1B,SAASC,yBAAyB;AAKlC,OAAO,MAAMC,qBAAqB,CAIlC;EACIC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;EAAG;EAEvC,MAAaC,GAAGA,CAACC,MAAsC,EAAE;IACrD,MAAM;MAAEC,KAAK;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAEpC,IAAI,CAACC,KAAK,CAACE,OAAO,EAAE;MAChB,OAAOD,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,iCAAiC;QAC1CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,CAACN,KAAK,CAACO,IAAI,EAAE;MACpB,OAAON,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,qCAAqC;QAC9CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;IAEA,IAAI;MACA,MAAM,IAAI,CAACT,OAAO,CAACW,GAAG,CAACC,QAAQ,CAACT,KAAK,CAACE,OAAO,CAAC;IAClD,CAAC,CAAC,MAA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CAAC;QAC1B;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT,OAAOhC,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC6B,EAAE,CAAC;IACxC;IAEA,QAAQP,MAAM;MACV,KAAK,SAAS;QACV,MAAMR,MAAM,CAACgB,KAAK,CAAC,CAAC;QACpB,OAAOjC,UAAU,CAACE,QAAQ,CAACgC,OAAO,CAAC,CAAC;MACxC,KAAK,UAAU;QACX,MAAMC,aAAgB,GAAG;UACrB,GAAGpC,KAAK;UACRiB,QAAQ,EAAEC,MAAM,CAACmB,WAAW,CAAC,CAAC;UAC9BC,IAAI,EAAElB,QAAQ,CAACmB,MAAM,CAAC,CAAC;UACvBd,SAAS,EAAEL,QAAQ,CAACoB,YAAY,CAAC;QACrC,CAAC;QACD,OAAOvC,UAAU,CAACE,QAAQ,CAACsC,QAAQ,CAAC;UAChC,GAAGL;QACP,CAAC,CAAC;MACN,KAAK,MAAM;QACP,MAAMM,MAAoC,GAAG;UACzCnC,IAAI,EAAEI;QACV,CAAC;QACD,OAAOV,UAAU,CAACE,QAAQ,CAACmC,IAAI,CAACI,MAAW,CAAC;MAChD;AACZ;AACA;MACY;QACI,MAAMxB,MAAM,CAACgB,KAAK,CAAC,CAAC;QACpB,OAAOjC,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;UAC7BC,OAAO,EAAE,mCAAmCqB,MAAM;QACtD,CAAC,CAAC;IACV;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["createS3Client","getBucket","createMultipartUpload","createMultipartUploadFactory","prependImportPath","createDownloadFileFromUrl","ImportFromUrlDownload","constructor","context","run","params","input","controller","modelId","response","error","message","code","file","cms","getModel","client","filename","key","uploadFactory","bucket","createHandler","uploadParams","uploadId","upload","start","download","fetch","url","get","size","nextRange","result","process","stop","isClose","runtime","isCloseToTimeout","isAborted","ex","abort","aborted","continueValue","getUploadId","done","isDone","getNextRange","continue","output"],"sources":["ImportFromUrlDownload.ts"],"sourcesContent":["import type {\n IImportFromUrlDownload,\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlDownload.js\";\nimport type { Context } from \"~/types.js\";\nimport { createS3Client } from \"~/tasks/utils/helpers/s3Client.js\";\nimport { getBucket } from \"~/tasks/utils/helpers/getBucket.js\";\nimport type { IMultipartUploadFactoryContinueParams } from \"~/tasks/utils/upload/index.js\";\nimport { createMultipartUpload, createMultipartUploadFactory } from \"~/tasks/utils/upload/index.js\";\nimport { prependImportPath } from \"~/tasks/utils/helpers/importPath.js\";\nimport type { IDownloadFileFromUrlProcessResponseType } from \"~/tasks/domain/downloadFileFromUrl/index.js\";\nimport { createDownloadFileFromUrl } from \"~/tasks/domain/downloadFileFromUrl/index.js\";\nimport { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\n\ntype ProcessType = IDownloadFileFromUrlProcessResponseType<\"continue\" | \"aborted\">;\n\nexport class ImportFromUrlDownload<\n I extends IImportFromUrlDownloadInput = IImportFromUrlDownloadInput,\n O extends IImportFromUrlDownloadOutput = IImportFromUrlDownloadOutput\n> implements IImportFromUrlDownload<I, O> {\n constructor(private context: Context) {}\n\n public async run(params: TaskDefinition.RunParams<I, O>) {\n const { input, controller } = params;\n\n if (!input.modelId) {\n return controller.response.error({\n message: `Missing \"modelId\" in the input.`,\n code: \"MISSING_MODEL_ID\"\n });\n } else if (!input.file) {\n return controller.response.error({\n message: `No file found in the provided data.`,\n code: \"NO_FILE_FOUND\"\n });\n }\n\n try {\n await this.context.cms.getModel(input.modelId);\n } catch {\n return controller.response.error({\n message: `Model \"${input.modelId}\" not found.`,\n code: \"MODEL_NOT_FOUND\"\n });\n }\n\n const client = createS3Client();\n\n const filename = prependImportPath(input.file.key);\n const uploadFactory = createMultipartUploadFactory({\n client,\n bucket: getBucket(),\n filename,\n createHandler: createMultipartUpload\n });\n\n const uploadParams: IMultipartUploadFactoryContinueParams = {\n uploadId: input.uploadId\n };\n const upload = await uploadFactory.start(uploadParams);\n\n const download = createDownloadFileFromUrl({\n fetch,\n file: {\n url: input.file.get,\n size: input.file.size,\n key: input.file.key\n },\n nextRange: input.nextRange,\n upload\n });\n let result: ProcessType;\n try {\n result = await download.process<ProcessType>(async ({ stop }) => {\n const isClose = controller.runtime.isCloseToTimeout();\n if (isClose) {\n return stop(\"continue\");\n } else if (controller.runtime.isAborted()) {\n return stop(\"aborted\");\n }\n });\n } catch (ex) {\n return controller.response.error(ex);\n }\n\n switch (result) {\n case \"aborted\":\n await upload.abort();\n return controller.response.aborted();\n case \"continue\":\n const continueValue: I = {\n ...input,\n uploadId: upload.getUploadId(),\n done: download.isDone(),\n nextRange: download.getNextRange()\n };\n return controller.response.continue({\n ...continueValue\n });\n case \"done\":\n const output: IImportFromUrlDownloadOutput = {\n file: filename\n };\n return controller.response.done(output as O);\n /**\n * There should be nothing else other than \"continue\" or \"aborted\" or null.\n */\n default:\n await upload.abort();\n return controller.response.error({\n message: `Method not implemented. Result: ${result}`\n });\n }\n }\n}\n"],"mappings":"AAMA,SAASA,cAAc;AACvB,SAASC,SAAS;AAElB,SAASC,qBAAqB,EAAEC,4BAA4B;AAC5D,SAASC,iBAAiB;AAE1B,SAASC,yBAAyB;AAKlC,OAAO,MAAMC,qBAAqB,CAGQ;EACtCC,WAAWA,CAASC,OAAgB,EAAE;IAAA,KAAlBA,OAAgB,GAAhBA,OAAgB;EAAG;EAEvC,MAAaC,GAAGA,CAACC,MAAsC,EAAE;IACrD,MAAM;MAAEC,KAAK;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAEpC,IAAI,CAACC,KAAK,CAACE,OAAO,EAAE;MAChB,OAAOD,UAAU,CAACE,QAAQ,CAACC,KAAK,CAAC;QAC7BC,OAAO,EAAE,iCAAiC;QAC1CC,IAAI,EAAE;MACV,CAAC,CAAC;IACN,CAAC,MAAM,IAAI,CAACN,KAAK,CAACO,IAAI,EAAE;MACpB,OAAON,UAAU,CA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rlDownloadTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ImportFromUrlDownload","runner","ex","controller","response","error","ImportFromUrlDownloadTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlDownloadTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { IMPORT_FROM_URL_DOWNLOAD_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlDownload.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n>;\n\nclass ImportFromUrlDownloadTaskDefinition\n implements TaskDefinition.Interface<IImportFromUrlDownloadInput, IImportFromUrlDownloadOutput>\n{\n id = IMPORT_FROM_URL_DOWNLOAD_TASK;\n title = \"Import from URL List - Download\";\n maxIterations = 500;\n isPrivate = true;\n description = \"Downloads the files from external URL.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ImportFromUrlDownload } = await import(\"./ImportFromUrlDownload.js\");\n\n try {\n const runner = new ImportFromUrlDownload(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ImportFromUrlDownloadTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlDownloadTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AACrF,SAASC,6BAA6B;AAYtC,MAAMC,mCAAmC,CAEzC;EACIC,EAAE,GAAGF,6BAA6B;EAClCG,KAAK,GAAG,iCAAiC;EACzCC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,wCAAwC;EAEtDC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAsB,CAAC,GAAG,MAAM,MAAM,6BAA6B,CAAC;IAE5E,IAAI;MACA,MAAMC,MAAM,GAAG,IAAID,qBAAqB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACjE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,yBAAyB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACzEC,cAAc,EAAElB,mCAAmC;EACnDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","CmsContext","IMPORT_FROM_URL_DOWNLOAD_TASK","ImportFromUrlDownloadTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","ImportFromUrlDownload","runner","ex","controller","response","error","ImportFromUrlDownloadTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlDownloadTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { IMPORT_FROM_URL_DOWNLOAD_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n} from \"~/tasks/domain/abstractions/ImportFromUrlDownload.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n>;\n\nclass ImportFromUrlDownloadTaskDefinition implements TaskDefinition.Interface<\n IImportFromUrlDownloadInput,\n IImportFromUrlDownloadOutput\n> {\n id = IMPORT_FROM_URL_DOWNLOAD_TASK;\n title = \"Import from URL List - Download\";\n maxIterations = 500;\n isPrivate = true;\n description = \"Downloads the files from external URL.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { ImportFromUrlDownload } = await import(\"./ImportFromUrlDownload.js\");\n\n try {\n const runner = new ImportFromUrlDownload(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ImportFromUrlDownloadTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlDownloadTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AACrF,SAASC,6BAA6B;AAYtC,MAAMC,mCAAmC,CAGvC;EACEC,EAAE,GAAGF,6BAA6B;EAClCG,KAAK,GAAG,iCAAiC;EACzCC,aAAa,GAAG,GAAG;EACnBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,wCAAwC;EAEtDC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAsB,CAAC,GAAG,MAAM,MAAM,6BAA6B,CAAC;IAE5E,IAAI;MACA,MAAMC,MAAM,GAAG,IAAID,qBAAqB,CAAC,IAAI,CAACH,OAAkB,CAAC;MACjE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,yBAAyB,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EACzEC,cAAc,EAAElB,mCAAmC;EACnDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ImportFromUrlDownloadTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ImportFromUrlDownloadTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["TaskDefinition","CmsContext","IMPORT_FROM_URL_PROCESS_ASSETS_TASK","ImportFromUrlProcessAssetsTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createImportFromUrlProcessAssets","runner","ex","controller","response","error","ImportFromUrlProcessAssetsTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlProcessAssetsTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { IMPORT_FROM_URL_PROCESS_ASSETS_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n} from \"./importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n>;\n\nclass ImportFromUrlProcessAssetsTaskDefinition\n implements\n TaskDefinition.Interface<\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n >\n{\n id = IMPORT_FROM_URL_PROCESS_ASSETS_TASK;\n title = \"Import from URL List - Process entries\";\n maxIterations = 10;\n isPrivate = true;\n description = \"Process entries import.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createImportFromUrlProcessAssets } = await import(\n \"./createImportFromUrlProcessAssets.js\"\n );\n\n try {\n const runner = createImportFromUrlProcessAssets(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ImportFromUrlProcessAssetsTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlProcessAssetsTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AACrF,SAASC,mCAAmC;AAY5C,MAAMC,wCAAwC,CAM9C;EACIC,EAAE,GAAGF,mCAAmC;EACxCG,KAAK,GAAG,wCAAwC;EAChDC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,yBAAyB;EAEvCC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAiC,CAAC,GAAG,MAAM,MAAM,wCAEzD,CAAC;IAED,IAAI;MACA,MAAMC,MAAM,GAAGD,gCAAgC,CAAC,IAAI,CAACH,OAAkB,CAAC;MACxE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,8BAA8B,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EAC9EC,cAAc,EAAElB,wCAAwC;EACxDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TaskDefinition","CmsContext","IMPORT_FROM_URL_PROCESS_ASSETS_TASK","ImportFromUrlProcessAssetsTaskDefinition","id","title","maxIterations","isPrivate","description","constructor","context","run","params","createImportFromUrlProcessAssets","runner","ex","controller","response","error","ImportFromUrlProcessAssetsTask","createImplementation","implementation","dependencies"],"sources":["ImportFromUrlProcessAssetsTask.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CmsContext } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { IMPORT_FROM_URL_PROCESS_ASSETS_TASK } from \"~/tasks/constants.js\";\nimport type { Context } from \"~/types.js\";\nimport type {\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n} from \"./importFromUrlProcessAssets/abstractions/ImportFromUrlProcessAssets.js\";\n\ntype IRunParams = TaskDefinition.RunParams<\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n>;\n\nclass ImportFromUrlProcessAssetsTaskDefinition implements TaskDefinition.Interface<\n IImportFromUrlProcessAssetsInput,\n IImportFromUrlProcessAssetsOutput\n> {\n id = IMPORT_FROM_URL_PROCESS_ASSETS_TASK;\n title = \"Import from URL List - Process entries\";\n maxIterations = 10;\n isPrivate = true;\n description = \"Process entries import.\";\n\n constructor(private context: CmsContext.Interface) {}\n\n async run(params: IRunParams) {\n const { createImportFromUrlProcessAssets } =\n await import(\"./createImportFromUrlProcessAssets.js\");\n\n try {\n const runner = createImportFromUrlProcessAssets(this.context as Context);\n return await runner.run(params);\n } catch (ex) {\n return params.controller.response.error(ex);\n }\n }\n}\n\nexport const ImportFromUrlProcessAssetsTask = TaskDefinition.createImplementation({\n implementation: ImportFromUrlProcessAssetsTaskDefinition,\n dependencies: [CmsContext]\n});\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,wDAAwD;AACvF,SAASC,UAAU,QAAQ,0DAA0D;AACrF,SAASC,mCAAmC;AAY5C,MAAMC,wCAAwC,CAG5C;EACEC,EAAE,GAAGF,mCAAmC;EACxCG,KAAK,GAAG,wCAAwC;EAChDC,aAAa,GAAG,EAAE;EAClBC,SAAS,GAAG,IAAI;EAChBC,WAAW,GAAG,yBAAyB;EAEvCC,WAAWA,CAASC,OAA6B,EAAE;IAAA,KAA/BA,OAA6B,GAA7BA,OAA6B;EAAG;EAEpD,MAAMC,GAAGA,CAACC,MAAkB,EAAE;IAC1B,MAAM;MAAEC;IAAiC,CAAC,GACtC,MAAM,MAAM,wCAAwC,CAAC;IAEzD,IAAI;MACA,MAAMC,MAAM,GAAGD,gCAAgC,CAAC,IAAI,CAACH,OAAkB,CAAC;MACxE,OAAO,MAAMI,MAAM,CAACH,GAAG,CAACC,MAAM,CAAC;IACnC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,OAAOH,MAAM,CAACI,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACH,EAAE,CAAC;IAC/C;EACJ;AACJ;AAEA,OAAO,MAAMI,8BAA8B,GAAGnB,cAAc,CAACoB,oBAAoB,CAAC;EAC9EC,cAAc,EAAElB,wCAAwC;EACxDmB,YAAY,EAAE,CAACrB,UAAU;AAC7B,CAAC,CAAC","ignoreList":[]}
@@ -1 +1,4 @@
1
- export declare const ImportFromUrlProcessAssetsTaskFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const ImportFromUrlProcessAssetsTaskFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };