@webiny/api-page-builder-import-export 5.40.0-beta.1 → 5.40.0-beta.3
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.
- package/client.js.map +1 -1
- package/export/combine/blocksHandler.js.map +1 -1
- package/export/combine/formsHandler.js.map +1 -1
- package/export/combine/index.js.map +1 -1
- package/export/combine/templatesHandler.js.map +1 -1
- package/export/pages/ExportPagesCleanup.js.map +1 -1
- package/export/pages/ExportPagesController.js.map +1 -1
- package/export/pages/ExportPagesZipPages.js.map +1 -1
- package/export/pages/controller/CombineZippedPages.js.map +1 -1
- package/export/pages/controller/CreateZipPagesTasks.js.map +1 -1
- package/export/pages/controller/ProcessZipPagesTasks.js +1 -2
- package/export/pages/controller/ProcessZipPagesTasks.js.map +1 -1
- package/export/pages/types.js +1 -2
- package/export/pages/types.js.map +1 -1
- package/export/pages/utils.js +1 -2
- package/export/pages/utils.js.map +1 -1
- package/export/pages/zipPages/ZipPages.js.map +1 -1
- package/export/pages/zipPages/ZipPagesDataManager.js.map +1 -1
- package/export/pages/zipPages/getPageFactory.js.map +1 -1
- package/export/process/blocksHandler.js.map +1 -1
- package/export/process/exporters/BlockExporter.js.map +1 -1
- package/export/process/exporters/FormExporter.js.map +1 -1
- package/export/process/exporters/PageExporter.js.map +1 -1
- package/export/process/exporters/PageTemplateExporter.js.map +1 -1
- package/export/process/formsHandler.js.map +1 -1
- package/export/process/index.js.map +1 -1
- package/export/process/templatesHandler.js.map +1 -1
- package/export/s3Stream.d.ts +1 -1
- package/export/s3Stream.js +1 -2
- package/export/s3Stream.js.map +1 -1
- package/export/utils.js +4 -8
- package/export/utils.js.map +1 -1
- package/export/zipper.js.map +1 -1
- package/graphql/crud/blocks.crud.js +1 -2
- package/graphql/crud/blocks.crud.js.map +1 -1
- package/graphql/crud/forms.crud.js +1 -2
- package/graphql/crud/forms.crud.js.map +1 -1
- package/graphql/crud/importExportTasks.crud.js +4 -1
- package/graphql/crud/importExportTasks.crud.js.map +1 -1
- package/graphql/crud/pages.crud.js +1 -2
- package/graphql/crud/pages.crud.js.map +1 -1
- package/graphql/crud/templates.crud.js +1 -2
- package/graphql/crud/templates.crud.js.map +1 -1
- package/graphql/crud.js.map +1 -1
- package/graphql/graphql/blocks.gql.js +1 -2
- package/graphql/graphql/blocks.gql.js.map +1 -1
- package/graphql/graphql/forms.gql.js +1 -2
- package/graphql/graphql/forms.gql.js.map +1 -1
- package/graphql/graphql/importExportTasks.gql.js +1 -2
- package/graphql/graphql/importExportTasks.gql.js.map +1 -1
- package/graphql/graphql/pages.gql.js +1 -2
- package/graphql/graphql/pages.gql.js.map +1 -1
- package/graphql/graphql/templates.gql.js +1 -2
- package/graphql/graphql/templates.gql.js.map +1 -1
- package/graphql/graphql/utils/resolve.js.map +1 -1
- package/graphql/graphql.js +1 -2
- package/graphql/graphql.js.map +1 -1
- package/graphql/index.js.map +1 -1
- package/graphql/types.js.map +1 -1
- package/import/constants.js +3 -6
- package/import/constants.js.map +1 -1
- package/import/create/blocksHandler.js.map +1 -1
- package/import/create/formsHandler.js.map +1 -1
- package/import/create/index.js.map +1 -1
- package/import/create/pagesHandler.js.map +1 -1
- package/import/create/templatesHandler.js.map +1 -1
- package/import/pages/ImportPagesController.js.map +1 -1
- package/import/pages/ImportPagesProcessPages.js.map +1 -1
- package/import/pages/controller/ImportPagesProcessPagesChecker.js +2 -2
- package/import/pages/controller/ImportPagesProcessPagesChecker.js.map +1 -1
- package/import/pages/controller/ImportPagesProcessZipFile.js.map +1 -1
- package/import/pages/process/importPage.js.map +1 -1
- package/import/pages/types.js +1 -2
- package/import/pages/types.js.map +1 -1
- package/import/process/blocks/ElementIdsProcessor.d.ts +5 -0
- package/import/process/blocks/ElementIdsProcessor.js +26 -0
- package/import/process/blocks/ElementIdsProcessor.js.map +1 -0
- package/import/process/blocks/blocksHandler.js.map +1 -1
- package/import/process/blocks/importBlock.js +5 -2
- package/import/process/blocks/importBlock.js.map +1 -1
- package/import/process/forms/formsHandler.js.map +1 -1
- package/import/process/forms/importForm.js.map +1 -1
- package/import/process/index.js.map +1 -1
- package/import/process/templates/importTemplate.js.map +1 -1
- package/import/process/templates/templatesHandler.js.map +1 -1
- package/import/utils/deleteS3Folder.js.map +1 -1
- package/import/utils/extractAndUploadZipFileContents.js.map +1 -1
- package/import/utils/extractZipAndUploadToS3.js.map +1 -1
- package/import/utils/getFileNameWithoutExt.js.map +1 -1
- package/import/utils/index.js.map +1 -1
- package/import/utils/initialStats.js.map +1 -1
- package/import/utils/prepareDataDirMap.js.map +1 -1
- package/import/utils/updateFilesInData.js.map +1 -1
- package/import/utils/uploadAssets.js.map +1 -1
- package/import/utils/uploadFilesFromS3.d.ts +1 -1
- package/import/utils/uploadFilesFromS3.js.map +1 -1
- package/mockSecurity.js.map +1 -1
- package/package.json +33 -33
- package/tasks/common/ChildTasksCleanup.js.map +1 -1
- package/tasks/index.js.map +1 -1
- package/tasks/pages/exportPagesCleanupTask.js.map +1 -1
- package/tasks/pages/exportPagesControllerTask.js.map +1 -1
- package/tasks/pages/exportPagesZipPagesTask.js.map +1 -1
- package/tasks/pages/importPagesControllerTask.js.map +1 -1
- package/tasks/pages/importPagesProcessPageTask.js.map +1 -1
- package/tasks/pages/index.js.map +1 -1
- package/types.js +2 -4
- package/types.js.map +1 -1
- package/utils/ZipFiles.js +0 -3
- package/utils/ZipFiles.js.map +1 -1
package/client.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["invokeHandlerClient","context","name","payload","description","request","tenantId","tenancy","getCurrentTenant","id","handlerClient","invoke","httpMethod","method","headers","await"],"sources":["client.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/graphql/types\";\n\nexport interface InvokeHandlerClientParams<TParams> {\n context: PbImportExportContext;\n name: string;\n payload: TParams;\n description: string;\n}\n\nexport async function invokeHandlerClient<TParams>({\n context,\n name,\n payload,\n description\n}: InvokeHandlerClientParams<TParams>) {\n const { request } = context;\n const tenantId = context.tenancy.getCurrentTenant().id;\n\n // Invoke handler\n await context.handlerClient.invoke<TParams & any>({\n name: name,\n payload: {\n ...payload,\n httpMethod: request.method,\n headers: {\n [\"x-i18n-locale\"]: request.headers[\"x-i18n-locale\"],\n [\"x-tenant\"]: request.headers[\"x-tenant\"] || tenantId\n }\n },\n await: false,\n description\n });\n}\n"],"mappings":";;;;;;AASO,eAAeA,mBAAmBA,CAAU;EAC/CC,OAAO;EACPC,IAAI;EACJC,OAAO;EACPC;AACgC,CAAC,EAAE;EACnC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,OAAO;EAC3B,MAAMK,QAAQ,GAAGL,OAAO,CAACM,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACC,EAAE;;EAEtD;EACA,MAAMR,OAAO,CAACS,aAAa,CAACC,MAAM,CAAgB;IAC9CT,IAAI,EAAEA,IAAI;IACVC,OAAO,EAAE;MACL,GAAGA,OAAO;MACVS,UAAU,EAAEP,OAAO,CAACQ,MAAM;MAC1BC,OAAO,EAAE;QACL,CAAC,eAAe,GAAGT,OAAO,CAACS,OAAO,CAAC,eAAe,CAAC;QACnD,CAAC,UAAU,GAAGT,OAAO,CAACS,OAAO,CAAC,UAAU,CAAC,IAAIR;MACjD;IACJ,CAAC;IACDS,KAAK,EAAE,KAAK;IACZX;EACJ,CAAC,CAAC;AACN"}
|
1
|
+
{"version":3,"names":["invokeHandlerClient","context","name","payload","description","request","tenantId","tenancy","getCurrentTenant","id","handlerClient","invoke","httpMethod","method","headers","await"],"sources":["client.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/graphql/types\";\n\nexport interface InvokeHandlerClientParams<TParams> {\n context: PbImportExportContext;\n name: string;\n payload: TParams;\n description: string;\n}\n\nexport async function invokeHandlerClient<TParams>({\n context,\n name,\n payload,\n description\n}: InvokeHandlerClientParams<TParams>) {\n const { request } = context;\n const tenantId = context.tenancy.getCurrentTenant().id;\n\n // Invoke handler\n await context.handlerClient.invoke<TParams & any>({\n name: name,\n payload: {\n ...payload,\n httpMethod: request.method,\n headers: {\n [\"x-i18n-locale\"]: request.headers[\"x-i18n-locale\"],\n [\"x-tenant\"]: request.headers[\"x-tenant\"] || tenantId\n }\n },\n await: false,\n description\n });\n}\n"],"mappings":";;;;;;AASO,eAAeA,mBAAmBA,CAAU;EAC/CC,OAAO;EACPC,IAAI;EACJC,OAAO;EACPC;AACgC,CAAC,EAAE;EACnC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,OAAO;EAC3B,MAAMK,QAAQ,GAAGL,OAAO,CAACM,OAAO,CAACC,gBAAgB,CAAC,CAAC,CAACC,EAAE;;EAEtD;EACA,MAAMR,OAAO,CAACS,aAAa,CAACC,MAAM,CAAgB;IAC9CT,IAAI,EAAEA,IAAI;IACVC,OAAO,EAAE;MACL,GAAGA,OAAO;MACVS,UAAU,EAAEP,OAAO,CAACQ,MAAM;MAC1BC,OAAO,EAAE;QACL,CAAC,eAAe,GAAGT,OAAO,CAACS,OAAO,CAAC,eAAe,CAAC;QACnD,CAAC,UAAU,GAAGT,OAAO,CAACS,OAAO,CAAC,UAAU,CAAC,IAAIR;MACjD;IACJ,CAAC;IACDS,KAAK,EAAE,KAAK;IACZX;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_s3Stream","_zipper","_mockSecurity","blocksHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportBlocksDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","blockExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["blocksHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export blocks combine workflow.\n */\nexport const blocksHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Blocks Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportBlocksDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportBlocksDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining blocks.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportBlocksDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_BLOCK_EXPORT.zip\");\n\n // Upload\n const blockExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${blockExportUpload.Location} `);\n\n // Update task status and save export blocks data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading block export.`,\n key: blockExportUpload.Key,\n url: await s3Stream.getPresignedUrl(blockExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_BLOCKS_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,MAAMI,aAAa,GAAG,MAAAA,CACzBC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EAEvBA,GAAG,CAAC,uCAAuC,CAAC;EAC5C,MAAM;IAAEE;EAAY,CAAC,GAAGH,OAAO;EAC/B,MAAM;IAAEI,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAEpC,IAAAO,0BAAY,EAACD,QAAQ,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACA,MAAMO,IAAI,GAAG,MAAMJ,WAAW,CAACK,gBAAgB,CAACC,OAAO,CAACL,MAAM,CAAC;IAC/D,IAAI,CAACG,IAAI,EAAE;MACP,OAAO;QACHG,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAG,6BAA4BR,MAAO;QACjD;MACJ,CAAC;IACL;IAEA,MAAM;MAAES;IAAoB,CAAC,GAAGN,IAAI,CAACO,KAAK;;IAE1C;IACA,MAAMC,kBAAkB,GAAG,MAAMC,kBAAQ,CAACC,UAAU,CAACJ,mBAAmB,CAAC;IACzE,IAAI,CAACE,kBAAkB,CAACG,QAAQ,EAAE;MAC9B,OAAO;QACHR,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAE;QACb;MACJ,CAAC;IACL;IAEA,MAAMO,WAAW,GAAGJ,kBAAkB,CAACG,QAAQ,CAACE,MAAM,CAClDC,IAAI,IAAIA,IAAI,CAACC,GAAG,KAAKT,mBACzB,CAAC,CACIU,GAAG,CAACF,IAAI,IA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E,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAE8B,CAAC,CAAC9B;MACf;IACJ,CAAC;EACL;EACA,OAAO;IACHF,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACmC,OAAA,CAAAhD,aAAA,GAAAA,aAAA"}
|
1
|
+
{"version":3,"names":["_types","require","_s3Stream","_zipper","_mockSecurity","blocksHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportBlocksDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","blockExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["blocksHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export blocks combine workflow.\n */\nexport const blocksHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Blocks Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportBlocksDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportBlocksDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining blocks.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportBlocksDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_BLOCK_EXPORT.zip\");\n\n // Upload\n const blockExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${blockExportUpload.Location} `);\n\n // Update task status and save export blocks data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading block export.`,\n key: blockExportUpload.Key,\n url: await s3Stream.getPresignedUrl(blockExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_BLOCKS_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,MAAMI,aAAa,GAAG,MAAAA,CACzBC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EAEvBA,GAAG,CAAC,uCAAuC,CAAC;EAC5C,MAAM;IAAEE;EAAY,CAAC,GAAGH,OAAO;EAC/B,MAAM;IAAEI,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAEpC,IAAAO,0BAAY,EAACD,QAAQ,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACA,MA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C;;IAEF;IACA,MAAMe,kBAAkB,GAAGlB,WAAW,CAACI,GAAG,CAACW,GAAG,IAAIlB,kBAAQ,CAACsB,YAAY,CAACJ,GAAG,CAAC,CAAC;IAC7E,MAAMK,OAAO,CAACC,GAAG,CAACH,kBAAkB,CAAC;IACrCpC,GAAG,CAAE,wBAAuBoC,kBAAkB,CAACI,MAAO,aAAY,CAAC;EACvE,CAAC,CAAC,OAAOC,CAAC,EAAE;IACRzC,GAAG,CAAC,mCAAmC,EAAEyC,CAAC,CAAC9B,OAAO,CAAC;;IAEnD;AACR;AACA;AACA;IACQ,MAAMT,WAAW,CAACK,gBAAgB,CAACsB,UAAU,CAAC1B,MAAM,EAAE;MAClD2B,MAAM,EAAEC,6BAAsB,CAACW,MAAM;MACrChC,KAAK,EAAE;QACHiC,IAAI,EAAEF,CAAC,CAACE,IAAI;QACZhC,OAAO,EAAE8B,CAAC,CAAC9B,OAAO;QAClBiC,IAAI,EAAE;MACV;IACJ,CAAC,CAAC;IAEF,OAAO;MACHnC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAE8B,CAAC,CAAC9B;MACf;IACJ,CAAC;EACL;EACA,OAAO;IACHF,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACmC,OAAA,CAAAhD,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_s3Stream","_zipper","_mockSecurity","formsHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportFormsDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","formExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["formsHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export forms combine workflow.\n */\nexport const formsHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Forms Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportFormsDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportFormsDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining forms.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportFormsDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_FORM_EXPORT.zip\");\n\n // Upload\n const formExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${formExportUpload.Location} `);\n\n // Update task status and save export form data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading form export.`,\n key: formExportUpload.Key,\n url: await s3Stream.getPresignedUrl(formExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_FORMS_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,MAAMI,YAAY,GAAG,MAAAA,CACxBC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EAEvBA,GAAG,CAAC,sCAAsC,CAAC;EAC3C,MAAM;IAAEE;EAAY,CAAC,GAAGH,OAAO;EAC/B,MAAM;IAAEI,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAEpC,IAAAO,0BAAY,EAACD,QAAQ,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACA,MAAMO,IAAI,GAAG,MAAMJ,WAAW,CAACK,gBAAgB,CAACC,OAAO,CAACL,MAAM,CAAC;IAC/D,IAAI,CAACG,IAAI,EAAE;MACP,OAAO;QACHG,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAG,6BAA4BR,MAAO;QACjD;MACJ,CAAC;IACL;IAEA,MAAM;MAAES;IAAmB,CAAC,GAAGN,IAAI,CAACO,KAAK;;IAEzC;IACA,MAAMC,kBAAkB,GAAG,MAAMC,kBAAQ,CAACC,UAAU,CAACJ,kBAAkB,CAAC;IACxE,IAAI,CAACE,kBAAkB,CAACG,QAAQ,EAAE;MAC9B,OAAO;QACHR,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAE;QACb;MACJ,CAAC;IACL;IAEA,MAAMO,WAAW,GAAGJ,kBAAkB,CAACG,QAAQ,CAACE,MAAM,CAClDC,IAAI,IAAIA,IAA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,EAAE;MACV;IACJ,CAAC,CAAC;IAEF,OAAO;MACHnC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAE8B,CAAC,CAAC9B;MACf;IACJ,CAAC;EACL;EACA,OAAO;IACHF,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACmC,OAAA,CAAAhD,YAAA,GAAAA,YAAA"}
|
1
|
+
{"version":3,"names":["_types","require","_s3Stream","_zipper","_mockSecurity","formsHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportFormsDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","formExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["formsHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export forms combine workflow.\n */\nexport const formsHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Forms Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportFormsDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportFormsDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining forms.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportFormsDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_FORM_EXPORT.zip\");\n\n // Upload\n const formExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${formExportUpload.Location} `);\n\n // Update task status and save export form data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading form export.`,\n key: formExportUpload.Key,\n url: await s3Stream.getPresignedUrl(formExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_FORMS_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,MAAMI,YAAY,GAAG,MAAAA,CACxBC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EAEvBA,GAAG,CAAC,sCAAsC,CAAC;EAC3C,MAAM;IAAEE;EAAY,CAAC,GAAGH,OAAO;EAC/B,MAAM;IAAEI,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAEpC,IAAAO,0BAAY,EAACD,QAAQ,EAAEL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ACL,GAAG;MAC5D;IACJ,CAAC,CAAC;;IAEF;IACA,MAAMe,kBAAkB,GAAGlB,WAAW,CAACI,GAAG,CAACW,GAAG,IAAIlB,kBAAQ,CAACsB,YAAY,CAACJ,GAAG,CAAC,CAAC;IAC7E,MAAMK,OAAO,CAACC,GAAG,CAACH,kBAAkB,CAAC;IACrCpC,GAAG,CAAE,wBAAuBoC,kBAAkB,CAACI,MAAO,aAAY,CAAC;EACvE,CAAC,CAAC,OAAOC,CAAC,EAAE;IACRzC,GAAG,CAAC,kCAAkC,EAAEyC,CAAC,CAAC9B,OAAO,CAAC;;IAElD;AACR;AACA;AACA;IACQ,MAAMT,WAAW,CAACK,gBAAgB,CAACsB,UAAU,CAAC1B,MAAM,EAAE;MAClD2B,MAAM,EAAEC,6BAAsB,CAACW,MAAM;MACrChC,KAAK,EAAE;QACHiC,IAAI,EAAEF,CAAC,CAACE,IAAI;QACZhC,OAAO,EAAE8B,CAAC,CAAC9B,OAAO;QAClBiC,IAAI,EAAE;MACV;IACJ,CAAC,CAAC;IAEF,OAAO;MACHnC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAE8B,CAAC,CAAC9B;MACf;IACJ,CAAC;EACL;EACA,OAAO;IACHF,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACmC,OAAA,CAAAhD,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_handlerAws","require","_blocksHandler","_formsHandler","_templatesHandler","_default","createRawEventHandler","payload","context","security","withoutAuthorization","type","blocksHandler","formsHandler","templatesHandler","console","log","JSON","stringify","Error","exports","default"],"sources":["index.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { blocksHandler } from \"~/export/combine/blocksHandler\";\nimport { formsHandler } from \"~/export/combine/formsHandler\";\nimport { templatesHandler } from \"~/export/combine/templatesHandler\";\n\nexport interface Payload {\n taskId: string;\n type: string;\n identity: SecurityIdentity;\n}\n\nexport interface Response {\n data: string | null;\n error: Partial<Error> | null;\n}\n\n/**\n * Handles the export pages combine workflow.\n */\nexport default () => {\n return createRawEventHandler<Payload, PbImportExportContext, Response>(\n async ({ payload, context }) => {\n return context.security.withoutAuthorization(() => {\n switch (payload.type) {\n case \"block\": {\n return blocksHandler(payload, context);\n }\n case \"form\": {\n return formsHandler(payload, context);\n }\n case \"template\": {\n return templatesHandler(payload, context);\n }\n default: {\n console.log(\"Export PB combine\", JSON.stringify(payload));\n throw new Error(\"Invalid type provided: pb combine.\");\n }\n }\n });\n }\n );\n};\n"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAaA;AACA;AACA;AAFA,IAAAI,QAAA,GAGeA,CAAA,KAAM;EACjB,OAAO,IAAAC,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC;EAAQ,CAAC,KAAK;IAC5B,OAAOA,OAAO,CAACC,QAAQ,CAACC,oBAAoB,CAAC,MAAM;MAC/C,QAAQH,OAAO,CAACI,IAAI;QAChB,KAAK,OAAO;UAAE;YACV,OAAO,IAAAC,4BAAa,EAACL,OAAO,EAAEC,OAAO,CAAC;UAC1C;QACA,KAAK,MAAM;UAAE;YACT,OAAO,IAAAK,0BAAY,EAACN,OAAO,EAAEC,OAAO,CAAC;UACzC;QACA,KAAK,UAAU;UAAE;YACb,OAAO,IAAAM,kCAAgB,EAACP,OAAO,EAAEC,OAAO,CAAC;UAC7C;QACA;UAAS;YACLO,OAAO,CAACC,GAAG,CAAC,mBAAmB,EAAEC,IAAI,CAACC,SAAS,CAACX,OAAO,CAAC,CAAC;YACzD,MAAM,IAAIY,KAAK,CAAC,oCAAoC,CAAC;UACzD;MACJ;IACJ,CAAC,CAAC;EACN,CACJ,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAhB,QAAA"}
|
1
|
+
{"version":3,"names":["_handlerAws","require","_blocksHandler","_formsHandler","_templatesHandler","_default","createRawEventHandler","payload","context","security","withoutAuthorization","type","blocksHandler","formsHandler","templatesHandler","console","log","JSON","stringify","Error","exports","default"],"sources":["index.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\nimport { blocksHandler } from \"~/export/combine/blocksHandler\";\nimport { formsHandler } from \"~/export/combine/formsHandler\";\nimport { templatesHandler } from \"~/export/combine/templatesHandler\";\n\nexport interface Payload {\n taskId: string;\n type: string;\n identity: SecurityIdentity;\n}\n\nexport interface Response {\n data: string | null;\n error: Partial<Error> | null;\n}\n\n/**\n * Handles the export pages combine workflow.\n */\nexport default () => {\n return createRawEventHandler<Payload, PbImportExportContext, Response>(\n async ({ payload, context }) => {\n return context.security.withoutAuthorization(() => {\n switch (payload.type) {\n case \"block\": {\n return blocksHandler(payload, context);\n }\n case \"form\": {\n return formsHandler(payload, context);\n }\n case \"template\": {\n return templatesHandler(payload, context);\n }\n default: {\n console.log(\"Export PB combine\", JSON.stringify(payload));\n throw new Error(\"Invalid type provided: pb combine.\");\n }\n }\n });\n }\n );\n};\n"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAaA;AACA;AACA;AAFA,IAAAI,QAAA,GAGeA,CAAA,KAAM;EACjB,OAAO,IAAAC,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC;EAAQ,CAAC,KAAK;IAC5B,OAAOA,OAAO,CAACC,QAAQ,CAACC,oBAAoB,CAAC,MAAM;MAC/C,QAAQH,OAAO,CAACI,IAAI;QAChB,KAAK,OAAO;UAAE;YACV,OAAO,IAAAC,4BAAa,EAACL,OAAO,EAAEC,OAAO,CAAC;UAC1C;QACA,KAAK,MAAM;UAAE;YACT,OAAO,IAAAK,0BAAY,EAACN,OAAO,EAAEC,OAAO,CAAC;UACzC;QACA,KAAK,UAAU;UAAE;YACb,OAAO,IAAAM,kCAAgB,EAACP,OAAO,EAAEC,OAAO,CAAC;UAC7C;QACA;UAAS;YACLO,OAAO,CAACC,GAAG,CAAC,mBAAmB,EAAEC,IAAI,CAACC,SAAS,CAACX,OAAO,CAAC,CAAC;YACzD,MAAM,IAAIY,KAAK,CAAC,oCAAoC,CAAC;UACzD;MACJ;IACJ,CAAC,CAAC;EACN,CACJ,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAhB,QAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_s3Stream","_zipper","_mockSecurity","templatesHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportTemplatesDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","templateExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["templatesHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export templates combine workflow.\n */\nexport const templatesHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Templates Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportTemplatesDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportTemplatesDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining templates.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportTemplatesDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_TEMPLATE_EXPORT.zip\");\n\n // Upload\n const templateExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${templateExportUpload.Location} `);\n\n // Update task status and save export templates data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading template export.`,\n key: templateExportUpload.Key,\n url: await s3Stream.getPresignedUrl(templateExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_TEMPLATES_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,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","_s3Stream","_zipper","_mockSecurity","templatesHandler","payload","context","log","console","pageBuilder","taskId","identity","mockSecurity","task","importExportTask","getTask","data","error","message","exportTemplatesDataKey","input","listObjectResponse","s3Stream","listObject","Contents","zipFileKeys","filter","file","Key","map","Boolean","zipOfZip","ZipOfZip","templateExportUpload","process","Location","updateTask","status","ImportExportTaskStatus","COMPLETED","key","url","getPresignedUrl","deleteFilePromises","deleteObject","Promise","all","length","e","FAILED","name","code","exports"],"sources":["templatesHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { s3Stream } from \"../s3Stream\";\nimport { ZipOfZip } from \"../zipper\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { Payload, Response } from \"~/export/combine\";\n\n/**\n * Handles the export templates combine workflow.\n */\nexport const templatesHandler = async (\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n\n log(\"RUNNING Export Templates Combine Handler\");\n const { pageBuilder } = context;\n const { taskId, identity } = payload;\n\n mockSecurity(identity, context);\n\n try {\n const task = await pageBuilder.importExportTask.getTask(taskId);\n if (!task) {\n return {\n data: null,\n error: {\n message: `There is no task with ID \"${taskId}\".`\n }\n };\n }\n\n const { exportTemplatesDataKey } = task.input;\n\n // Get all files (zip) from given key\n const listObjectResponse = await s3Stream.listObject(exportTemplatesDataKey);\n if (!listObjectResponse.Contents) {\n return {\n data: null,\n error: {\n message: \"There is no Contents defined on S3 Stream while combining templates.\"\n }\n };\n }\n\n const zipFileKeys = listObjectResponse.Contents.filter(\n file => file.Key !== exportTemplatesDataKey\n )\n .map(file => file.Key)\n .filter(Boolean) as string[];\n\n // Prepare zip of all zips\n const zipOfZip = new ZipOfZip(zipFileKeys, \"WEBINY_TEMPLATE_EXPORT.zip\");\n\n // Upload\n const templateExportUpload = await zipOfZip.process();\n log(`Done uploading... File is located at ${templateExportUpload.Location} `);\n\n // Update task status and save export templates data key\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading template export.`,\n key: templateExportUpload.Key,\n url: await s3Stream.getPresignedUrl(templateExportUpload.Key)\n }\n });\n\n // Remove individual zip files from storage\n const deleteFilePromises = zipFileKeys.map(key => s3Stream.deleteObject(key));\n await Promise.all(deleteFilePromises);\n log(`Successfully deleted ${deleteFilePromises.length} zip files.`);\n } catch (e) {\n log(\"[EXPORT_TEMPLATES_COMBINE] Error => \", e.message);\n\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n await pageBuilder.importExportTask.updateTask(taskId, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,MAAMI,gBAAgB,GAAG,MAAAA,CAC5BC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EAEvBA,GAAG,CAAC,0CAA0C,CAAC;EAC/C,MAAM;IAAEE;EAAY,CAAC,GAAGH,OAAO;EAC/B,MAAM;IAAEI,MAAM;IAAEC;EAAS,CAAC,GAAGN,OAAO;EAEpC,IAAAO,0BAAY,EAACD,QAAQ,EAAEL,OAAO,CAAC;EAE/B,IAAI;IACA,MAAMO,IAAI,GAAG,MAAMJ,WAAW,CAACK,gBAAgB,CAACC,OAAO,CAACL,MAAM,CAAC;IAC/D,IAAI,CAACG,IAAI,EAAE;MACP,OAAO;QACHG,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE;UACHC,OAAO,EAAG,6BAA4BR,MAAO;QACjD;MACJ,CAAC;IACL;IAE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ACI,MAAO,aAAY,CAAC;EACvE,CAAC,CAAC,OAAOC,CAAC,EAAE;IACRzC,GAAG,CAAC,sCAAsC,EAAEyC,CAAC,CAAC9B,OAAO,CAAC;;IAEtD;AACR;AACA;AACA;IACQ,MAAMT,WAAW,CAACK,gBAAgB,CAACsB,UAAU,CAAC1B,MAAM,EAAE;MAClD2B,MAAM,EAAEC,6BAAsB,CAACW,MAAM;MACrChC,KAAK,EAAE;QACHiC,IAAI,EAAEF,CAAC,CAACE,IAAI;QACZhC,OAAO,EAAE8B,CAAC,CAAC9B,OAAO;QAClBiC,IAAI,EAAE;MACV;IACJ,CAAC,CAAC;IAEF,OAAO;MACHnC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAE;QACHC,OAAO,EAAE8B,CAAC,CAAC9B;MACf;IACJ,CAAC;EACL;EACA,OAAO;IACHF,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACmC,OAAA,CAAAhD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_clientS","_chunk","_interopRequireDefault","ExportPagesCleanup","execute","params","context","response","store","task","getTask","parentId","error","id","parent","tasks","items","subTasks","listTasks","where","definitionId","PageExportTask","ZipPages","limit","length","done","files","reduce","collection","subTask","output","results","Object","values","filter","Boolean","push","s3","createS3Client","region","process","env","AWS_REGION","parentKey","key","deleteObject","Bucket","S3_BUCKET","Key","chunks","lodashChunk","chunk","deleteObjects","Delete","Objects","map","exports"],"sources":["ExportPagesCleanup.ts"],"sourcesContent":["import {\n IExportPagesCleanupTaskParams,\n IExportPagesControllerOutput,\n IExportPagesZipPagesOutput,\n PageExportTask\n} from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { createS3Client } from \"@webiny/aws-sdk/client-s3\";\nimport lodashChunk from \"lodash/chunk\";\n\nexport class ExportPagesCleanup {\n public async execute(params: IExportPagesCleanupTaskParams): Promise<ITaskResponseResult> {\n const { context, response, store } = params;\n /**\n * This task must have a parent one. If it does not, just end with error.\n * This should not happen as we trigger this task from a parent one, not directly.\n *\n * But let's just make sure.\n */\n const task = store.getTask();\n if (!task.parentId) {\n return response.error(`Missing task \"${task.id}\" parent id.`);\n }\n\n const parent = await context.tasks.getTask<IExportPagesControllerOutput>(task.parentId);\n if (!parent) {\n return response.error(`Missing parent task \"${task.parentId}\" in the database.`);\n }\n /**\n * We need to find all the tasks that created zip files, so we can have a list of files to delete.\n */\n const { items: subTasks } = await context.tasks.listTasks<any, IExportPagesZipPagesOutput>({\n where: {\n parentId: parent.id,\n definitionId: PageExportTask.ZipPages\n },\n limit: 10000\n });\n if (subTasks.length === 0) {\n return response.done(\"No subtasks found - nothing to cleanup.\");\n }\n\n const files = subTasks.reduce<string[]>((collection, subTask) => {\n const done = subTask.output?.done;\n if (!done) {\n return collection;\n }\n const results = Object.values(done).filter(Boolean);\n collection.push(...results);\n return collection;\n }, []);\n\n const s3 = createS3Client({\n region: process.env.AWS_REGION\n });\n\n const parentKey = parent.output?.key;\n if (typeof parentKey === \"string\") {\n await s3.deleteObject({\n Bucket: process.env.S3_BUCKET,\n Key: parentKey\n });\n }\n\n const chunks = lodashChunk(files, 500);\n\n for (const chunk of chunks) {\n await s3.deleteObjects({\n Bucket: process.env.S3_BUCKET,\n Delete: {\n Objects: chunk.map(Key => ({ Key }))\n }\n });\n }\n\n return response.done(\"Done with cleanup!\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,kBAAkB,CAAC;EAC5B,MAAaC,OAAOA,CAACC,MAAqC,EAAgC;IACtF,MAAM;MAAEC,OAAO;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGH,MAAM;IAC3C;AACR;AACA;AACA;AACA;AACA;IACQ,MAAMI,IAAI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CAAC;IAEF,MAAMC,SAAS,GAAG7B,MAAM,CAACgB,MAAM,EAAEc,GAAG;IACpC,IAAI,OAAOD,SAAS,KAAK,QAAQ,EAAE;MAC/B,MAAMN,EAAE,CAACQ,YAAY,CAAC;QAClBC,MAAM,EAAEN,OAAO,CAACC,GAAG,CAACM,SAAS;QAC7BC,GAAG,EAAEL;MACT,CAAC,CAAC;IACN;IAEA,MAAMM,MAAM,GAAG,IAAAC,cAAW,EAACxB,KAAK,EAAE,GAAG,CAAC;IAEtC,KAAK,MAAMyB,KAAK,IAAIF,MAAM,EAAE;MACxB,MAAMZ,EAAE,CAACe,aAAa,CAAC;QACnBN,MAAM,EAAEN,OAAO,CAACC,GAAG,CAACM,SAAS;QAC7BM,MAAM,EAAE;UACJC,OAAO,EAAEH,KAAK,CAACI,GAAG,CAACP,GAAG,KAAK;YAAEA;UAAI,CAAC,CAAC;QACvC;MACJ,CAAC,CAAC;IACN;IAEA,OAAOzC,QAAQ,CAACkB,IAAI,CAAC,oBAAoB,CAAC;EAC9C;AACJ;AAAC+B,OAAA,CAAArD,kBAAA,GAAAA,kBAAA"}
|
1
|
+
{"version":3,"names":["_types","require","_clientS","_chunk","_interopRequireDefault","ExportPagesCleanup","execute","params","context","response","store","task","getTask","parentId","error","id","parent","tasks","items","subTasks","listTasks","where","definitionId","PageExportTask","ZipPages","limit","length","done","files","reduce","collection","subTask","output","results","Object","values","filter","Boolean","push","s3","createS3Client","region","process","env","AWS_REGION","parentKey","key","deleteObject","Bucket","S3_BUCKET","Key","chunks","lodashChunk","chunk","deleteObjects","Delete","Objects","map","exports"],"sources":["ExportPagesCleanup.ts"],"sourcesContent":["import {\n IExportPagesCleanupTaskParams,\n IExportPagesControllerOutput,\n IExportPagesZipPagesOutput,\n PageExportTask\n} from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { createS3Client } from \"@webiny/aws-sdk/client-s3\";\nimport lodashChunk from \"lodash/chunk\";\n\nexport class ExportPagesCleanup {\n public async execute(params: IExportPagesCleanupTaskParams): Promise<ITaskResponseResult> {\n const { context, response, store } = params;\n /**\n * This task must have a parent one. If it does not, just end with error.\n * This should not happen as we trigger this task from a parent one, not directly.\n *\n * But let's just make sure.\n */\n const task = store.getTask();\n if (!task.parentId) {\n return response.error(`Missing task \"${task.id}\" parent id.`);\n }\n\n const parent = await context.tasks.getTask<IExportPagesControllerOutput>(task.parentId);\n if (!parent) {\n return response.error(`Missing parent task \"${task.parentId}\" in the database.`);\n }\n /**\n * We need to find all the tasks that created zip files, so we can have a list of files to delete.\n */\n const { items: subTasks } = await context.tasks.listTasks<any, IExportPagesZipPagesOutput>({\n where: {\n parentId: parent.id,\n definitionId: PageExportTask.ZipPages\n },\n limit: 10000\n });\n if (subTasks.length === 0) {\n return response.done(\"No subtasks found - nothing to cleanup.\");\n }\n\n const files = subTasks.reduce<string[]>((collection, subTask) => {\n const done = subTask.output?.done;\n if (!done) {\n return collection;\n }\n const results = Object.values(done).filter(Boolean);\n collection.push(...results);\n return collection;\n }, []);\n\n const s3 = createS3Client({\n region: process.env.AWS_REGION\n });\n\n const parentKey = parent.output?.key;\n if (typeof parentKey === \"string\") {\n await s3.deleteObject({\n Bucket: process.env.S3_BUCKET,\n Key: parentKey\n });\n }\n\n const chunks = lodashChunk(files, 500);\n\n for (const chunk of chunks) {\n await s3.deleteObjects({\n Bucket: process.env.S3_BUCKET,\n Delete: {\n Objects: chunk.map(Key => ({ Key }))\n }\n });\n }\n\n return response.done(\"Done with cleanup!\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,kBAAkB,CAAC;EAC5B,MAAaC,OAAOA,CAACC,MAAqC,EAAgC;IACtF,MAAM;MAAEC,OAAO;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGH,MAAM;IAC3C;AACR;A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OAAO,CAACC,GAAG,CAACC;IACxB,CAAC,CAAC;IAEF,MAAMC,SAAS,GAAG7B,MAAM,CAACgB,MAAM,EAAEc,GAAG;IACpC,IAAI,OAAOD,SAAS,KAAK,QAAQ,EAAE;MAC/B,MAAMN,EAAE,CAACQ,YAAY,CAAC;QAClBC,MAAM,EAAEN,OAAO,CAACC,GAAG,CAACM,SAAS;QAC7BC,GAAG,EAAEL;MACT,CAAC,CAAC;IACN;IAEA,MAAMM,MAAM,GAAG,IAAAC,cAAW,EAACxB,KAAK,EAAE,GAAG,CAAC;IAEtC,KAAK,MAAMyB,KAAK,IAAIF,MAAM,EAAE;MACxB,MAAMZ,EAAE,CAACe,aAAa,CAAC;QACnBN,MAAM,EAAEN,OAAO,CAACC,GAAG,CAACM,SAAS;QAC7BM,MAAM,EAAE;UACJC,OAAO,EAAEH,KAAK,CAACI,GAAG,CAACP,GAAG,KAAK;YAAEA;UAAI,CAAC,CAAC;QACvC;MACJ,CAAC,CAAC;IACN;IAEA,OAAOzC,QAAQ,CAACkB,IAAI,CAAC,oBAAoB,CAAC;EAC9C;AACJ;AAAC+B,OAAA,CAAArD,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ProcessZipPagesTasks","require","_CreateZipPagesTasks","ExportPagesController","execute","params","input","zippingPages","processZipPagesTasks","ProcessZipPagesTasks","createZipPagesTasks","CreateZipPagesTasks","exports"],"sources":["ExportPagesController.ts"],"sourcesContent":["import { IExportPagesControllerTaskParams } from \"./types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ProcessZipPagesTasks } from \"./controller/ProcessZipPagesTasks\";\nimport { CreateZipPagesTasks } from \"./controller/CreateZipPagesTasks\";\n\nexport class ExportPagesController {\n public async execute(params: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const { input } = params;\n /**\n * In case subtasks for zipping pages are already created, we need to wait for them to finish.\n * After they are done, we can combine all zip files into a single one.\n */\n if (input.zippingPages) {\n const processZipPagesTasks = new ProcessZipPagesTasks();\n return await processZipPagesTasks.execute(params);\n }\n /**\n * On the first run of the task, we need to create subtasks for zipping pages in batches.\n */\n const createZipPagesTasks = new CreateZipPagesTasks();\n return await createZipPagesTasks.execute(params);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAEO,MAAME,qBAAqB,CAAC;EAC/B,MAAaC,OAAOA,CAACC,MAAwC,EAAgC;IACzF,MAAM;MAAEC;IAAM,CAAC,GAAGD,MAAM;IACxB;AACR;AACA;AACA;IACQ,IAAIC,KAAK,CAACC,YAAY,EAAE;MACpB,MAAMC,oBAAoB,GAAG,IAAIC,0CAAoB,CAAC,CAAC;MACvD,OAAO,MAAMD,oBAAoB,CAACJ,OAAO,CAACC,MAAM,CAAC;IACrD;IACA;AACR;AACA;IACQ,MAAMK,mBAAmB,GAAG,IAAIC,wCAAmB,CAAC,CAAC;IACrD,OAAO,MAAMD,mBAAmB,CAACN,OAAO,CAACC,MAAM,CAAC;EACpD;AACJ;AAACO,OAAA,CAAAT,qBAAA,GAAAA,qBAAA"}
|
1
|
+
{"version":3,"names":["_ProcessZipPagesTasks","require","_CreateZipPagesTasks","ExportPagesController","execute","params","input","zippingPages","processZipPagesTasks","ProcessZipPagesTasks","createZipPagesTasks","CreateZipPagesTasks","exports"],"sources":["ExportPagesController.ts"],"sourcesContent":["import { IExportPagesControllerTaskParams } from \"./types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ProcessZipPagesTasks } from \"./controller/ProcessZipPagesTasks\";\nimport { CreateZipPagesTasks } from \"./controller/CreateZipPagesTasks\";\n\nexport class ExportPagesController {\n public async execute(params: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const { input } = params;\n /**\n * In case subtasks for zipping pages are already created, we need to wait for them to finish.\n * After they are done, we can combine all zip files into a single one.\n */\n if (input.zippingPages) {\n const processZipPagesTasks = new ProcessZipPagesTasks();\n return await processZipPagesTasks.execute(params);\n }\n /**\n * On the first run of the task, we need to create subtasks for zipping pages in batches.\n */\n const createZipPagesTasks = new CreateZipPagesTasks();\n return await createZipPagesTasks.execute(params);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAEO,MAAME,qBAAqB,CAAC;EAC/B,MAAaC,OAAOA,CAACC,MAAwC,EAAgC;IACzF,MAAM;MAAEC;IAAM,CAAC,GAAGD,MAAM;IACxB;AACR;AACA;AACA;IACQ,IAAIC,KAAK,CAACC,YAAY,EAAE;MACpB,MAAMC,oBAAoB,GAAG,IAAIC,0CAAoB,CAAC,CAAC;MACvD,OAAO,MAAMD,oBAAoB,CAACJ,OAAO,CAACC,MAAM,CAAC;IACrD;IACA;AACR;AACA;IACQ,MAAMK,mBAAmB,GAAG,IAAIC,wCAAmB,CAAC,CAAC;IACrD,OAAO,MAAMD,mBAAmB,CAACN,OAAO,CAACC,MAAM,CAAC;EACpD;AACJ;AAACO,OAAA,CAAAT,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ZipPages","require","ExportPagesZipPages","execute","params","isAborted","response","aborted","zipPages","ZipPages","exports"],"sources":["ExportPagesZipPages.ts"],"sourcesContent":["import { IExportPagesZipPagesTaskParams } from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ZipPages } from \"./zipPages/ZipPages\";\n\nexport class ExportPagesZipPages {\n public async execute(params: IExportPagesZipPagesTaskParams): Promise<ITaskResponseResult> {\n const { isAborted, response } = params;\n if (isAborted()) {\n return response.aborted();\n }\n\n const zipPages = new ZipPages();\n return await zipPages.execute(params);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,CAAC;EAC7B,MAAaC,OAAOA,CAACC,MAAsC,EAAgC;IACvF,MAAM;MAAEC,SAAS;MAAEC;IAAS,CAAC,GAAGF,MAAM;IACtC,IAAIC,SAAS,CAAC,CAAC,EAAE;MACb,OAAOC,QAAQ,CAACC,OAAO,CAAC,CAAC;IAC7B;IAEA,MAAMC,QAAQ,GAAG,IAAIC,kBAAQ,CAAC,CAAC;IAC/B,OAAO,MAAMD,QAAQ,CAACL,OAAO,CAACC,MAAM,CAAC;EACzC;AACJ;AAACM,OAAA,CAAAR,mBAAA,GAAAA,mBAAA"}
|
1
|
+
{"version":3,"names":["_ZipPages","require","ExportPagesZipPages","execute","params","isAborted","response","aborted","zipPages","ZipPages","exports"],"sources":["ExportPagesZipPages.ts"],"sourcesContent":["import { IExportPagesZipPagesTaskParams } from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ZipPages } from \"./zipPages/ZipPages\";\n\nexport class ExportPagesZipPages {\n public async execute(params: IExportPagesZipPagesTaskParams): Promise<ITaskResponseResult> {\n const { isAborted, response } = params;\n if (isAborted()) {\n return response.aborted();\n }\n\n const zipPages = new ZipPages();\n return await zipPages.execute(params);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,mBAAmB,CAAC;EAC7B,MAAaC,OAAOA,CAACC,MAAsC,EAAgC;IACvF,MAAM;MAAEC,SAAS;MAAEC;IAAS,CAAC,GAAGF,MAAM;IACtC,IAAIC,SAAS,CAAC,CAAC,EAAE;MACb,OAAOC,QAAQ,CAACC,OAAO,CAAC,CAAC;IAC7B;IAEA,MAAMC,QAAQ,GAAG,IAAIC,kBAAQ,CAAC,CAAC;IAC/B,OAAO,MAAMD,QAAQ,CAACL,OAAO,CAACC,MAAM,CAAC;EACzC;AACJ;AAACM,OAAA,CAAAR,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_s3Stream","require","_utils","_ZipFiles","_uniqid","_interopRequireDefault","CombineZippedPages","execute","params","response","store","taskId","getTask","id","exportPagesDataKey","createExportPagesDataKey","listObjectResponse","s3Stream","listObject","Array","isArray","Contents","error","message","length","done","ex","zipFileKeys","reduce","files","file","Key","push","key","zipOfZip","ZipFiles","target","uniqueId","pageExportUpload","process","console","log","url","getPresignedUrl","exports"],"sources":["CombineZippedPages.ts"],"sourcesContent":["import { IExportPagesCombineZippedPagesParams } from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ListObjectsOutput, s3Stream } from \"~/export/s3Stream\";\nimport { createExportPagesDataKey } from \"~/export/pages/utils\";\nimport { ZipFiles } from \"~/utils/ZipFiles\";\nimport uniqueId from \"uniqid\";\n\nexport class CombineZippedPages {\n public async execute(\n params: IExportPagesCombineZippedPagesParams\n ): Promise<ITaskResponseResult> {\n const { response, store } = params;\n /**\n * We need to get all the subtasks of the PageExportTask.ZipPages type, so we can get all the zip files and combine them into one.\n * Current task must have a parent for this to work.\n */\n const taskId = store.getTask().id;\n\n /**\n * When we have all the pages IDs and their zip files, we can continue to combine the zip files into one.\n */\n const exportPagesDataKey = createExportPagesDataKey(taskId);\n\n let listObjectResponse: ListObjectsOutput;\n try {\n listObjectResponse = await s3Stream.listObject(exportPagesDataKey);\n if (!Array.isArray(listObjectResponse.Contents)) {\n return response.error({\n message: \"There is no Contents defined on S3 Stream while combining pages.\"\n });\n } else if (listObjectResponse.Contents.length === 0) {\n return response.done(\"No zip files to combine.\");\n }\n } catch (ex) {\n return response.error(ex);\n }\n\n const zipFileKeys = listObjectResponse.Contents.reduce<string[]>((files, file) => {\n if (!file.Key) {\n return files;\n } else if (file.Key === exportPagesDataKey) {\n return files;\n }\n files.push(file.Key);\n\n return files;\n }, []);\n\n let key: string;\n\n try {\n const zipOfZip = new ZipFiles();\n const target = uniqueId(\"EXPORTS/\", \"-WEBINY_PAGE_EXPORT.zip\");\n const pageExportUpload = await zipOfZip.process(target, zipFileKeys);\n\n if (!pageExportUpload?.Key) {\n return response.error({\n message: \"There is no Key defined on pageExportUpload.\"\n });\n }\n key = pageExportUpload.Key;\n } catch (ex) {\n console.error(`Error while combining zip files into a single zip: ${ex.message}`);\n console.log(ex);\n return response.error(ex);\n }\n\n const url = await s3Stream.getPresignedUrl(key);\n\n return response.done(\"Done combining pages.\", {\n key,\n url\n });\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEO,MAAMK,kBAAkB,CAAC;EAC5B,MAAaC,OAAOA,CAChBC,MAA4C,EAChB;IAC5B,MAAM;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAClC;AACR;AACA;AACA;IACQ,MAAMG,MAAM,GAAGD,KAAK,CAACE,OAAO,CAAC,CAAC,CAACC,EAAE;;IAEjC;AACR;AACA;IACQ,MAAMC,kBAAkB,GAAG,IAAAC,+BAAwB,EAACJ,MAAM,CAAC;IAE3D,IAAIK,kBAAqC;IACzC,IAAI;MACAA,kBAAkB,GAAG,MAAMC,kBAAQ,CAACC,UAAU,CAACJ,kBAAkB,CAAC;MAClE,IAAI,CAACK,KAAK,CAACC,OAAO,CAACJ,kBAAkB,CAACK,QAAQ,CAAC,EAAE;QAC7C,OAAOZ,QAAQ,CAACa,KAAK,CAAC;UAClBC,OAAO,EAAE;QACb,CAAC,CAAC;MACN,CAAC,MAAM,IAAIP,kBAAkB,CAACK,QAAQ,CAACG,MAAM,KAAK,CAAC,EAAE;QACjD,OAAOf,QAAQ,CAACgB,IAAI,CAAC,0BAA0B,CAAC;MACpD;IACJ,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,OAAOjB,QAAQ,CAACa,KAAK,CAACI,EAAE,CAAC;IAC7B;IAEA,MAAMC,WAAW,GAAGX,kBAAkB,CAACK,QAAQ,CAACO,MAAM,CAAW,CAACC,KAAK,EAAEC,IAAI,KAAK;MAC9E,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE;QACX,OAAOF,KAAK;MAChB,CAAC,MAAM,IAAIC,IAAI,CAACC,GAAG,KAAKjB,kBAAkB,EAAE;QACxC,OAAOe,KAAK;MAChB;MACAA,KAAK,CAACG,IAAI,CAACF,IAAI,CAACC,GAAG,CAAC;MAEpB,OAAOF,KAAK;IAChB,CAAC,EAAE,EAAE,CAAC;IAEN,IAAII,GAAW;IAEf,IAAI;MACA,MAAMC,QAAQ,GAAG,IAAIC,kBAAQ,CAAC,CAAC;MAC/B,MAAMC,MAAM,GAAG,IAAAC,eAAQ,EAAC,UAAU,EAAE,yBAAyB,CAAC;MAC9D,MAAMC,gBAAgB,GAAG,MAAMJ,QAAQ,CAACK,OAAO,CAACH,MAAM,EAAET,WAAW,CAAC;MAEpE,IAAI,CAACW,gBAAgB,EAAEP,GAAG,EAAE;QACxB,OAAOtB,QAAQ,CAACa,KAAK,CAAC;UAClBC,OAAO,EAAE;QACb,CAAC,CAAC;MACN;MACAU,GAAG,GAAGK,gBAAgB,CAACP,GAAG;IAC9B,CAAC,CAAC,OAAOL,EAAE,EAAE;MACTc,OAAO,CAAClB,KAAK,CAAE,sDAAqDI,EAAE,CAACH,OAAQ,EAAC,CAAC;MACjFiB,OAAO,CAACC,GAAG,CAACf,EAAE,CAAC;MACf,OAAOjB,QAAQ,CAACa,KAAK,CAACI,EAAE,CAAC;IAC7B;IAEA,MAAMgB,GAAG,GAAG,MAAMzB,kBAAQ,CAAC0B,eAAe,CAACV,GAAG,CAAC;IAE/C,OAAOxB,QAAQ,CAACgB,IAAI,CAAC,uBAAuB,EAAE;MAC1CQ,GAAG;MACHS;IACJ,CAAC,CAAC;EACN;AACJ;AAACE,OAAA,CAAAtC,kBAAA,GAAAA,kBAAA"}
|
1
|
+
{"version":3,"names":["_s3Stream","require","_utils","_ZipFiles","_uniqid","_interopRequireDefault","CombineZippedPages","execute","params","response","store","taskId","getTask","id","exportPagesDataKey","createExportPagesDataKey","listObjectResponse","s3Stream","listObject","Array","isArray","Contents","error","message","length","done","ex","zipFileKeys","reduce","files","file","Key","push","key","zipOfZip","ZipFiles","target","uniqueId","pageExportUpload","process","console","log","url","getPresignedUrl","exports"],"sources":["CombineZippedPages.ts"],"sourcesContent":["import { IExportPagesCombineZippedPagesParams } from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport { ListObjectsOutput, s3Stream } from \"~/export/s3Stream\";\nimport { createExportPagesDataKey } from \"~/export/pages/utils\";\nimport { ZipFiles } from \"~/utils/ZipFiles\";\nimport uniqueId from \"uniqid\";\n\nexport class CombineZippedPages {\n public async execute(\n params: IExportPagesCombineZippedPagesParams\n ): Promise<ITaskResponseResult> {\n const { response, store } = params;\n /**\n * We need to get all the subtasks of the PageExportTask.ZipPages type, so we can get all the zip files and combine them into one.\n * Current task must have a parent for this to work.\n */\n const taskId = store.getTask().id;\n\n /**\n * When we have all the pages IDs and their zip files, we can continue to combine the zip files into one.\n */\n const exportPagesDataKey = createExportPagesDataKey(taskId);\n\n let listObjectResponse: ListObjectsOutput;\n try {\n listObjectResponse = await s3Stream.listObject(exportPagesDataKey);\n if (!Array.isArray(listObjectResponse.Contents)) {\n return response.error({\n message: \"There is no Contents defined on S3 Stream while combining pages.\"\n });\n } else if (listObjectResponse.Contents.length === 0) {\n return response.done(\"No zip files to combine.\");\n }\n } catch (ex) {\n return response.error(ex);\n }\n\n const zipFileKeys = listObjectResponse.Contents.reduce<string[]>((files, file) => {\n if (!file.Key) {\n return files;\n } else if (file.Key === exportPagesDataKey) {\n return files;\n }\n files.push(file.Key);\n\n return files;\n }, []);\n\n let key: string;\n\n try {\n const zipOfZip = new ZipFiles();\n const target = uniqueId(\"EXPORTS/\", \"-WEBINY_PAGE_EXPORT.zip\");\n const pageExportUpload = await zipOfZip.process(target, zipFileKeys);\n\n if (!pageExportUpload?.Key) {\n return response.error({\n message: \"There is no Key defined on pageExportUpload.\"\n });\n }\n key = pageExportUpload.Key;\n } catch (ex) {\n console.error(`Error while combining zip files into a single zip: ${ex.message}`);\n console.log(ex);\n return response.error(ex);\n }\n\n const url = await s3Stream.getPresignedUrl(key);\n\n return response.done(\"Done combining pages.\", {\n key,\n url\n });\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEO,MAAMK,kBAAkB,CAAC;EAC5B,MAAaC,OAAOA,CAChBC,MAA4C,EAChB;IAC5B,MAAM;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGF,MAAM;IAClC;AACR;AACA;AACA;IACQ,MAAMG,MAAM,GAAGD,KAAK,CAACE,OAAO,CAAC,CAAC,CAACC,EAAE;;IAEjC;AACR;AACA;IACQ,MAAMC,kBAAkB,GAAG,IAAAC,+BAAwB,EAACJ,MAAM,CAAC;IAE3D,IAAIK,kBAAqC;IACzC,IAAI;MACAA,kBAAkB,GAAG,MAAMC,kBAAQ,CAACC,UAAU,CAACJ,kBAAkB,CAAC;MAClE,IAAI,CAACK,KAAK,CAACC,OAAO,CAACJ,kBAAkB,CAACK,QAAQ,CAAC,EAAE;QAC7C,OAAOZ,QAAQ,CAACa,KAAK,CAAC;UAClBC,OAAO,EAAE;QACb,CAAC,CAAC;MACN,CAAC,MAAM,IAAIP,kBAAkB,CAACK,QAAQ,CAACG,MAAM,KAAK,CAAC,EAAE;QACjD,OAAOf,QAAQ,CAACgB,IAAI,CAAC,0BAA0B,CAAC;MACpD;IACJ,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,OAAOjB,QAAQ,CAACa,KAAK,CAACI,EAAE,CAAC;IAC7B;IAEA,MAAMC,WAAW,GAAGX,kBAAkB,CAACK,QAAQ,CAACO,MAAM,CAAW,CAACC,KAAK,EAAEC,IAAI,KAAK;MAC9E,IAAI,CAACA,IAAI,CAACC,GAAG,EAAE;QACX,OAAOF,KAAK;MAChB,CAAC,MAAM,IAAIC,IAAI,CAACC,GAAG,KAAKjB,kBAAkB,EAAE;QACxC,OAAOe,KAAK;MAChB;MACAA,KAAK,CAACG,IAAI,CAACF,IAAI,CAACC,GAAG,CAAC;MAEpB,OAAOF,KAAK;IAChB,CAAC,EAAE,EAAE,CAAC;IAEN,IAAII,GAAW;IAEf,IAAI;MACA,MAAMC,QAAQ,GAAG,IAAIC,kBAAQ,CAAC,CAAC;MAC/B,MAAMC,MAAM,GAAG,IAAAC,eAAQ,EAAC,UAAU,EAAE,yBAAyB,CAAC;MAC9D,MAAMC,gBAAgB,GAAG,MAAMJ,QAAQ,CAACK,OAAO,CAACH,MAAM,EAAET,WAAW,CAAC;MAEpE,IAAI,CAACW,gBAAgB,EAAEP,GAAG,EAAE;QACxB,OAAOtB,QAAQ,CAACa,KAAK,CAAC;UAClBC,OAAO,EAAE;QACb,CAAC,CAAC;MACN;MACAU,GAAG,GAAGK,gBAAgB,CAACP,GAAG;IAC9B,CAAC,CAAC,OAAOL,EAAE,EAAE;MACTc,OAAO,CAAClB,KAAK,CAAE,sDAAqDI,EAAE,CAACH,OAAQ,EAAC,CAAC;MACjFiB,OAAO,CAACC,GAAG,CAACf,EAAE,CAAC;MACf,OAAOjB,QAAQ,CAACa,KAAK,CAACI,EAAE,CAAC;IAC7B;IAEA,MAAMgB,GAAG,GAAG,MAAMzB,kBAAQ,CAAC0B,eAAe,CAACV,GAAG,CAAC;IAE/C,OAAOxB,QAAQ,CAACgB,IAAI,CAAC,uBAAuB,EAAE;MAC1CQ,GAAG;MACHS;IACJ,CAAC,CAAC;EACN;AACJ;AAACE,OAAA,CAAAtC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ProcessZipPagesTasks","require","_types","PAGES_IN_BATCH","CreateZipPagesTasks","execute","response","input","isAborted","isCloseToTimeout","context","store","listPagesParams","where","after","limit","currentBatch","result","pageBuilder","listLatestPages","aborted","continue","pages","meta","cursor","totalCount","done","length","totalPages","zippingPages","seconds","ZIP_PAGES_WAIT_TIME","queue","map","page","id","tasks","trigger","name","parent","getTask","definition","PageExportTask","ZipPages","type","hasMoreItems","exports"],"sources":["CreateZipPagesTasks.ts"],"sourcesContent":["import { ListMeta, ListPagesParams, Page } from \"@webiny/api-page-builder/types\";\nimport { ZIP_PAGES_WAIT_TIME } from \"./ProcessZipPagesTasks\";\nimport {\n IExportPagesControllerTaskParams,\n IExportPagesZipPagesInput,\n PageExportTask\n} from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks/types\";\n\nconst PAGES_IN_BATCH = 25;\n\n/**\n * Go through all the pages and create subtasks for zipping pages in batches.\n */\nexport class CreateZipPagesTasks {\n public async execute({\n response,\n input,\n isAborted,\n isCloseToTimeout,\n context,\n store\n }: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const listPagesParams: ListPagesParams = {\n where: input.where,\n after: input.after,\n limit: PAGES_IN_BATCH\n };\n\n let currentBatch = input.currentBatch || 1;\n let result: [Page[], ListMeta];\n while ((result = await context.pageBuilder.listLatestPages(listPagesParams))) {\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input,\n ...listPagesParams,\n currentBatch\n });\n }\n const [pages, meta] = result;\n\n listPagesParams.after = meta.cursor;\n /**\n * If no pages are returned there are two options:\n * * mark task as done because there are no pages at all\n * * continue with the control task, but in zippingPages mode\n */\n if (meta.totalCount === 0) {\n return response.done(\"No pages to export.\");\n } else if (pages.length === 0) {\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch,\n totalPages: meta.totalCount,\n zippingPages: true\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n\n const queue = pages.map(page => page.id);\n /**\n * Trigger a task for each of the loaded pages batch.\n */\n await context.tasks.trigger<IExportPagesZipPagesInput>({\n name: `Page Builder - Export Pages - Zip Pages #${currentBatch}`,\n parent: store.getTask(),\n definition: PageExportTask.ZipPages,\n input: {\n queue,\n type: input.type\n }\n });\n /**\n * If there are no more pages to load, we can continue the controller task in a zippingPages mode, with some delay.\n */\n if (!meta.hasMoreItems || !meta.cursor) {\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch,\n totalPages: meta.totalCount,\n zippingPages: true\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n currentBatch++;\n }\n /**\n * Should not be possible to exit the loop without returning a response, but let's have a continue response here just in case.\n */\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,MAAME,cAAc,GAAG,EAAE;;AAEzB;AACA;AACA;AACO,MAAMC,mBAAmB,CAAC;EAC7B,MAAaC,OAAOA,CAAC;IACjBC,QAAQ;IACRC,KAAK;IACLC,SAAS;IACTC,gBAAgB;IAChBC,OAAO;IACPC;EAC8B,CAAC,EAAgC;IAC/D,MAAMC,eAAgC,GAAG;MACrCC,KAAK,EAAEN,KAAK,CAACM,KAAK;MAClBC,KAAK,EAAEP,KAAK,CAACO,KAAK;MAClBC,KAAK,EAAEZ;IACX,CAAC;IAED,IAAIa,YAAY,GAAGT,KAAK,CAACS,YAAY,IAAI,CAAC;IAC1C,IAAIC,MAA0B;IAC9B,OAAQA,MAAM,GAAG,MAAMP,OAAO,CAACQ,WAAW,CAACC,eAAe,CAACP,eAAe,CAAC,EAAG;MAC1E,IAAIJ,SAAS,CAAC,CAAC,EAAE;QACb,OAAOF,QAAQ,CAACc,OAAO,CAAC,CAAC;MAC7B,CAAC,MAAM,IAAIX,gBAAgB,CAAC,CAAC,EAAE;QAC3B,OAAOH,QAAQ,CAACe,QAAQ,CAAC;UACrB,GAAGd,KA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AC;MACL;MACAf,YAAY,EAAE;IAClB;IACA;AACR;AACA;IACQ,OAAOV,QAAQ,CAACe,QAAQ,CACpB;MACI,GAAGd,KAAK;MACR,GAAGK,eAAe;MAClBI;IACJ,CAAC,EACD;MACIc,OAAO,EAAEC;IACb,CACJ,CAAC;EACL;AACJ;AAACe,OAAA,CAAA1C,mBAAA,GAAAA,mBAAA"}
|
1
|
+
{"version":3,"names":["_ProcessZipPagesTasks","require","_types","PAGES_IN_BATCH","CreateZipPagesTasks","execute","response","input","isAborted","isCloseToTimeout","context","store","listPagesParams","where","after","limit","currentBatch","result","pageBuilder","listLatestPages","aborted","continue","pages","meta","cursor","totalCount","done","length","totalPages","zippingPages","seconds","ZIP_PAGES_WAIT_TIME","queue","map","page","id","tasks","trigger","name","parent","getTask","definition","PageExportTask","ZipPages","type","hasMoreItems","exports"],"sources":["CreateZipPagesTasks.ts"],"sourcesContent":["import { ListMeta, ListPagesParams, Page } from \"@webiny/api-page-builder/types\";\nimport { ZIP_PAGES_WAIT_TIME } from \"./ProcessZipPagesTasks\";\nimport {\n IExportPagesControllerTaskParams,\n IExportPagesZipPagesInput,\n PageExportTask\n} from \"~/export/pages/types\";\nimport { ITaskResponseResult } from \"@webiny/tasks/types\";\n\nconst PAGES_IN_BATCH = 25;\n\n/**\n * Go through all the pages and create subtasks for zipping pages in batches.\n */\nexport class CreateZipPagesTasks {\n public async execute({\n response,\n input,\n isAborted,\n isCloseToTimeout,\n context,\n store\n }: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const listPagesParams: ListPagesParams = {\n where: input.where,\n after: input.after,\n limit: PAGES_IN_BATCH\n };\n\n let currentBatch = input.currentBatch || 1;\n let result: [Page[], ListMeta];\n while ((result = await context.pageBuilder.listLatestPages(listPagesParams))) {\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input,\n ...listPagesParams,\n currentBatch\n });\n }\n const [pages, meta] = result;\n\n listPagesParams.after = meta.cursor;\n /**\n * If no pages are returned there are two options:\n * * mark task as done because there are no pages at all\n * * continue with the control task, but in zippingPages mode\n */\n if (meta.totalCount === 0) {\n return response.done(\"No pages to export.\");\n } else if (pages.length === 0) {\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch,\n totalPages: meta.totalCount,\n zippingPages: true\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n\n const queue = pages.map(page => page.id);\n /**\n * Trigger a task for each of the loaded pages batch.\n */\n await context.tasks.trigger<IExportPagesZipPagesInput>({\n name: `Page Builder - Export Pages - Zip Pages #${currentBatch}`,\n parent: store.getTask(),\n definition: PageExportTask.ZipPages,\n input: {\n queue,\n type: input.type\n }\n });\n /**\n * If there are no more pages to load, we can continue the controller task in a zippingPages mode, with some delay.\n */\n if (!meta.hasMoreItems || !meta.cursor) {\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch,\n totalPages: meta.totalCount,\n zippingPages: true\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n currentBatch++;\n }\n /**\n * Should not be possible to exit the loop without returning a response, but let's have a continue response here just in case.\n */\n return response.continue(\n {\n ...input,\n ...listPagesParams,\n currentBatch\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,MAAME,cAAc,GAAG,EAAE;;AAEzB;AACA;AACA;AACO,MAAMC,mBAAmB,CAAC;EAC7B,MAAaC,OAAOA,CAAC;IACjBC,QAAQ;IACRC,KAAK;IACLC,SAAS;IACTC,gBAAgB;IAChBC,OAAO;IACPC;EAC8B,CAAC,EAAgC;IAC/D,MAAMC,eAAgC,GAAG;MACrCC,KAAK,EAAEN,KAAK,CAACM,KAAK;MAClBC,KAAK,EAAEP,KAAK,CAACO,KAAK;MAClBC,KAAK,EAAEZ;IACX,CAAC;IAED,IAAIa,YAAY,GA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IAAI,EAAErC,KAAK,CAACqC;QAChB;MACJ,CAAC,CAAC;MACF;AACZ;AACA;MACY,IAAI,CAACrB,IAAI,CAACsB,YAAY,IAAI,CAACtB,IAAI,CAACC,MAAM,EAAE;QACpC,OAAOlB,QAAQ,CAACe,QAAQ,CACpB;UACI,GAAGd,KAAK;UACR,GAAGK,eAAe;UAClBI,YAAY;UACZY,UAAU,EAAEL,IAAI,CAACE,UAAU;UAC3BI,YAAY,EAAE;QAClB,CAAC,EACD;UACIC,OAAO,EAAEC;QACb,CACJ,CAAC;MACL;MACAf,YAAY,EAAE;IAClB;IACA;AACR;AACA;IACQ,OAAOV,QAAQ,CAACe,QAAQ,CACpB;MACI,GAAGd,KAAK;MACR,GAAGK,eAAe;MAClBI;IACJ,CAAC,EACD;MACIc,OAAO,EAAEC;IACb,CACJ,CAAC;EACL;AACJ;AAACe,OAAA,CAAA1C,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
@@ -7,8 +7,7 @@ exports.ZIP_PAGES_WAIT_TIME = exports.ProcessZipPagesTasks = void 0;
|
|
7
7
|
var _tasks = require("@webiny/tasks");
|
8
8
|
var _types = require("../types");
|
9
9
|
var _CombineZippedPages = require("./CombineZippedPages");
|
10
|
-
const ZIP_PAGES_WAIT_TIME = 5;
|
11
|
-
exports.ZIP_PAGES_WAIT_TIME = ZIP_PAGES_WAIT_TIME;
|
10
|
+
const ZIP_PAGES_WAIT_TIME = exports.ZIP_PAGES_WAIT_TIME = 5;
|
12
11
|
class ProcessZipPagesTasks {
|
13
12
|
async execute(params) {
|
14
13
|
const {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_tasks","require","_types","_CombineZippedPages","ZIP_PAGES_WAIT_TIME","exports","ProcessZipPagesTasks","execute","params","response","input","isAborted","isCloseToTimeout","context","store","aborted","continue","result","tasks","listTasks","where","parentId","getTask","id","definitionId","PageExportTask","ZipPages","taskStatus_in","TaskDataStatus","RUNNING","PENDING","limit","items","length","seconds","combineZippedPages","CombineZippedPages"],"sources":["ProcessZipPagesTasks.ts"],"sourcesContent":["import { ITaskResponseResult, TaskDataStatus } from \"@webiny/tasks\";\nimport { IExportPagesControllerTaskParams, PageExportTask } from \"../types\";\nimport { CombineZippedPages } from \"~/export/pages/controller/CombineZippedPages\";\n\nexport const ZIP_PAGES_WAIT_TIME = 5;\n\nexport class ProcessZipPagesTasks {\n public async execute(params: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const { response, input, isAborted, isCloseToTimeout, context, store } = params;\n\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input\n });\n }\n /**\n * TODO: implement subtasks and subtask management into the base tasks package.\n */\n const result = await context.tasks.listTasks({\n where: {\n parentId: store.getTask().id,\n definitionId: PageExportTask.ZipPages,\n taskStatus_in: [TaskDataStatus.RUNNING, TaskDataStatus.PENDING]\n },\n limit: 1\n });\n /**\n * Do we still need to wait until all subtasks (Zip Pages) are done?\n */\n if (result.items.length > 0) {\n return response.continue(\n {\n ...input\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n /**\n * If all subtasks (Zip Pages) are done, we can continue with zipping all zip files into a single one.\n */\n const combineZippedPages = new CombineZippedPages();\n\n return combineZippedPages.execute({\n store,\n response\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEO,MAAMG,mBAAmB,
|
1
|
+
{"version":3,"names":["_tasks","require","_types","_CombineZippedPages","ZIP_PAGES_WAIT_TIME","exports","ProcessZipPagesTasks","execute","params","response","input","isAborted","isCloseToTimeout","context","store","aborted","continue","result","tasks","listTasks","where","parentId","getTask","id","definitionId","PageExportTask","ZipPages","taskStatus_in","TaskDataStatus","RUNNING","PENDING","limit","items","length","seconds","combineZippedPages","CombineZippedPages"],"sources":["ProcessZipPagesTasks.ts"],"sourcesContent":["import { ITaskResponseResult, TaskDataStatus } from \"@webiny/tasks\";\nimport { IExportPagesControllerTaskParams, PageExportTask } from \"../types\";\nimport { CombineZippedPages } from \"~/export/pages/controller/CombineZippedPages\";\n\nexport const ZIP_PAGES_WAIT_TIME = 5;\n\nexport class ProcessZipPagesTasks {\n public async execute(params: IExportPagesControllerTaskParams): Promise<ITaskResponseResult> {\n const { response, input, isAborted, isCloseToTimeout, context, store } = params;\n\n if (isAborted()) {\n return response.aborted();\n } else if (isCloseToTimeout()) {\n return response.continue({\n ...input\n });\n }\n /**\n * TODO: implement subtasks and subtask management into the base tasks package.\n */\n const result = await context.tasks.listTasks({\n where: {\n parentId: store.getTask().id,\n definitionId: PageExportTask.ZipPages,\n taskStatus_in: [TaskDataStatus.RUNNING, TaskDataStatus.PENDING]\n },\n limit: 1\n });\n /**\n * Do we still need to wait until all subtasks (Zip Pages) are done?\n */\n if (result.items.length > 0) {\n return response.continue(\n {\n ...input\n },\n {\n seconds: ZIP_PAGES_WAIT_TIME\n }\n );\n }\n /**\n * If all subtasks (Zip Pages) are done, we can continue with zipping all zip files into a single one.\n */\n const combineZippedPages = new CombineZippedPages();\n\n return combineZippedPages.execute({\n store,\n response\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEO,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,CAAC;AAE7B,MAAME,oBAAoB,CAAC;EAC9B,MAAaC,OAAOA,CAACC,MAAwC,EAAgC;IACzF,MAAM;MAAEC,QAAQ;MAAEC,KAAK;MAAEC,SAAS;MAAEC,gBAAgB;MAAEC,OAAO;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAE/E,IAAIG,SAAS,CAAC,CAAC,EAAE;MACb,OAAOF,QAAQ,CAACM,OAAO,CAAC,CAAC;IAC7B,CAAC,MAAM,IAAIH,gBAAgB,CAAC,CAAC,EAAE;MAC3B,OAAOH,QAAQ,CAACO,QAAQ,CAAC;QACrB,GAAGN;MACP,CAAC,CAAC;IACN;IACA;AACR;AACA;IACQ,MAAMO,MAAM,GAAG,MAAMJ,OAAO,CAACK,KAAK,CAACC,SAAS,CAAC;MACzCC,KAAK,EAAE;QACHC,QAAQ,EAAEP,KAAK,CAACQ,OAAO,CAAC,CAAC,CAACC,EAAE;QAC5BC,YAAY,EAAEC,qBAAc,CAACC,QAAQ;QACrCC,aAAa,EAAE,CAACC,qBAAc,CAACC,OAAO,EAAED,qBAAc,CAACE,OAAO;MAClE,CAAC;MACDC,KAAK,EAAE;IACX,CAAC,CAAC;IACF;AACR;AACA;IACQ,IAAId,MAAM,CAACe,KAAK,CAACC,MAAM,GAAG,CAAC,EAAE;MACzB,OAAOxB,QAAQ,CAACO,QAAQ,CACpB;QACI,GAAGN;MACP,CAAC,EACD;QACIwB,OAAO,EAAE9B;MACb,CACJ,CAAC;IACL;IACA;AACR;AACA;IACQ,MAAM+B,kBAAkB,GAAG,IAAIC,sCAAkB,CAAC,CAAC;IAEnD,OAAOD,kBAAkB,CAAC5B,OAAO,CAAC;MAC9BO,KAAK;MACLL;IACJ,CAAC,CAAC;EACN;AACJ;AAACJ,OAAA,CAAAC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
package/export/pages/types.js
CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.PageExportTask = void 0;
|
7
|
-
let PageExportTask = /*#__PURE__*/function (PageExportTask) {
|
7
|
+
let PageExportTask = exports.PageExportTask = /*#__PURE__*/function (PageExportTask) {
|
8
8
|
PageExportTask["Controller"] = "pageBuilderExportPagesController";
|
9
9
|
PageExportTask["ZipPages"] = "pageBuilderExportPagesZipPages";
|
10
10
|
PageExportTask["Cleanup"] = "pageBuilderExportPagesCleanup";
|
@@ -22,6 +22,5 @@ let PageExportTask = /*#__PURE__*/function (PageExportTask) {
|
|
22
22
|
/**
|
23
23
|
* Cleanup Zip files
|
24
24
|
*/
|
25
|
-
exports.PageExportTask = PageExportTask;
|
26
25
|
|
27
26
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PageExportTask","exports"],"sources":["types.ts"],"sourcesContent":["import { ITaskResponseDoneResultOutput, ITaskRunParams } from \"@webiny/tasks\";\nimport { PbImportExportContext } from \"~/types\";\n\nexport enum PageExportTask {\n Controller = \"pageBuilderExportPagesController\",\n ZipPages = \"pageBuilderExportPagesZipPages\",\n Cleanup = \"pageBuilderExportPagesCleanup\"\n}\n\n/**\n * Controller\n */\nexport interface IExportPagesControllerInput {\n type: \"published\" | \"latest\";\n where?: Record<string, any>;\n totalPages: number;\n after?: string | null;\n currentBatch?: number;\n zippingPages?: boolean;\n}\n\nexport interface IExportPagesControllerOutput extends ITaskResponseDoneResultOutput {\n key: string;\n url: string;\n}\n\nexport type IExportPagesControllerTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesControllerInput,\n IExportPagesControllerOutput\n>;\n\n/**\n * Zip Pages\n */\nexport interface IExportPagesZipPagesDone {\n [pageId: string]: string;\n}\nexport interface IExportPagesZipPagesInput {\n type: \"published\" | \"latest\";\n queue: string[];\n done?: IExportPagesZipPagesDone;\n failed?: string[];\n}\n\nexport interface IExportPagesZipPagesOutput extends ITaskResponseDoneResultOutput {\n done: IExportPagesZipPagesDone;\n failed: string[];\n}\n\nexport type IExportPagesZipPagesTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesZipPagesInput,\n IExportPagesZipPagesOutput\n>;\n\n/**\n * Combine Zipped Pages\n */\n\nexport interface IExportPagesCombineZippedPagesOutput extends ITaskResponseDoneResultOutput {\n key: string;\n url: string;\n}\n\nexport type IExportPagesCombineZippedPagesParams = Pick<\n ITaskRunParams<\n PbImportExportContext,\n IExportPagesControllerInput,\n IExportPagesCombineZippedPagesOutput\n >,\n \"store\" | \"response\"\n>;\n\n/**\n * Cleanup Zip files\n */\nexport type IExportPagesCleanupInput = Record<string, boolean>;\n\nexport type IExportPagesCleanupTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesCleanupInput\n>;\n"],"mappings":";;;;;;IAGYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B;AACA;AACA;AAqBA;AACA;AACA;AAsBA;AACA;AACA;AAgBA;AACA;AACA
|
1
|
+
{"version":3,"names":["PageExportTask","exports"],"sources":["types.ts"],"sourcesContent":["import { ITaskResponseDoneResultOutput, ITaskRunParams } from \"@webiny/tasks\";\nimport { PbImportExportContext } from \"~/types\";\n\nexport enum PageExportTask {\n Controller = \"pageBuilderExportPagesController\",\n ZipPages = \"pageBuilderExportPagesZipPages\",\n Cleanup = \"pageBuilderExportPagesCleanup\"\n}\n\n/**\n * Controller\n */\nexport interface IExportPagesControllerInput {\n type: \"published\" | \"latest\";\n where?: Record<string, any>;\n totalPages: number;\n after?: string | null;\n currentBatch?: number;\n zippingPages?: boolean;\n}\n\nexport interface IExportPagesControllerOutput extends ITaskResponseDoneResultOutput {\n key: string;\n url: string;\n}\n\nexport type IExportPagesControllerTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesControllerInput,\n IExportPagesControllerOutput\n>;\n\n/**\n * Zip Pages\n */\nexport interface IExportPagesZipPagesDone {\n [pageId: string]: string;\n}\nexport interface IExportPagesZipPagesInput {\n type: \"published\" | \"latest\";\n queue: string[];\n done?: IExportPagesZipPagesDone;\n failed?: string[];\n}\n\nexport interface IExportPagesZipPagesOutput extends ITaskResponseDoneResultOutput {\n done: IExportPagesZipPagesDone;\n failed: string[];\n}\n\nexport type IExportPagesZipPagesTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesZipPagesInput,\n IExportPagesZipPagesOutput\n>;\n\n/**\n * Combine Zipped Pages\n */\n\nexport interface IExportPagesCombineZippedPagesOutput extends ITaskResponseDoneResultOutput {\n key: string;\n url: string;\n}\n\nexport type IExportPagesCombineZippedPagesParams = Pick<\n ITaskRunParams<\n PbImportExportContext,\n IExportPagesControllerInput,\n IExportPagesCombineZippedPagesOutput\n >,\n \"store\" | \"response\"\n>;\n\n/**\n * Cleanup Zip files\n */\nexport type IExportPagesCleanupInput = Record<string, boolean>;\n\nexport type IExportPagesCleanupTaskParams = ITaskRunParams<\n PbImportExportContext,\n IExportPagesCleanupInput\n>;\n"],"mappings":";;;;;;IAGYA,cAAc,GAAAC,OAAA,CAAAD,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B;AACA;AACA;AAqBA;AACA;AACA;AAsBA;AACA;AACA;AAgBA;AACA;AACA","ignoreList":[]}
|
package/export/pages/utils.js
CHANGED
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createExportPagesDataKey = exports.EXPORT_PAGES_FOLDER_KEY = void 0;
|
7
|
-
const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
|
8
|
-
exports.EXPORT_PAGES_FOLDER_KEY = EXPORT_PAGES_FOLDER_KEY;
|
7
|
+
const EXPORT_PAGES_FOLDER_KEY = exports.EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
|
9
8
|
const createExportPagesDataKey = taskId => {
|
10
9
|
return `${EXPORT_PAGES_FOLDER_KEY}/${taskId}`;
|
11
10
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["EXPORT_PAGES_FOLDER_KEY","exports","createExportPagesDataKey","taskId"],"sources":["utils.ts"],"sourcesContent":["export const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\n\nexport const createExportPagesDataKey = (taskId: string) => {\n return `${EXPORT_PAGES_FOLDER_KEY}/${taskId}`;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,
|
1
|
+
{"version":3,"names":["EXPORT_PAGES_FOLDER_KEY","exports","createExportPagesDataKey","taskId"],"sources":["utils.ts"],"sourcesContent":["export const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\n\nexport const createExportPagesDataKey = (taskId: string) => {\n return `${EXPORT_PAGES_FOLDER_KEY}/${taskId}`;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,wBAAwB;AAExD,MAAME,wBAAwB,GAAIC,MAAc,IAAK;EACxD,OAAQ,GAAEH,uBAAwB,IAAGG,MAAO,EAAC;AACjD,CAAC;AAACF,OAAA,CAAAC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_PageExporter","require","_ZipPagesDataManager","_getPageFactory","_utils","CLOSE_TO_TIMEOUT_SECONDS","ZipPages","execute","params","response","input","isAborted","isCloseToTimeout","context","store","parentId","getTask","error","message","exportPageDataKey","createExportPagesDataKey","dataManager","ZipPagesDataManager","hasMore","done","getDone","failed","getFailed","getPage","getPageFactory","type","pageId","queue","aborted","continue","getInput","page","addErrorLog","addFailed","pageExporter","PageExporter","fileManager","pageDataZip","Key","Error","addDone","ex","console","exports"],"sources":["ZipPages.ts"],"sourcesContent":["import { ITaskResponseResult } from \"@webiny/tasks\";\nimport { IExportPagesZipPagesTaskParams } from \"~/export/pages/types\";\nimport { PageExporter } from \"~/export/process/exporters/PageExporter\";\nimport { ZipPagesDataManager } from \"./ZipPagesDataManager\";\nimport { getPageFactory } from \"./getPageFactory\";\nimport { createExportPagesDataKey } from \"~/export/pages/utils\";\n\n/**\n * We will pause the execution of the task if there is less than CLOSE_TO_TIMEOUT_SECONDS left on the Lambda execution time.\n */\nconst CLOSE_TO_TIMEOUT_SECONDS = 300;\n\nexport class ZipPages {\n public async execute(params: IExportPagesZipPagesTaskParams): Promise<ITaskResponseResult> {\n const { response, input, isAborted, isCloseToTimeout, context, store } = params;\n\n const parentId = store.getTask().parentId;\n if (!parentId) {\n return response.error({\n message: `Could not find parent task ID.`\n });\n }\n const exportPageDataKey = createExportPagesDataKey(parentId);\n\n const dataManager = new ZipPagesDataManager(input);\n if (dataManager.hasMore() === false) {\n return response.done(\"Task done.\", {\n done: dataManager.getDone(),\n failed: dataManager.getFailed()\n });\n }\n\n const getPage = getPageFactory(context, store, input.type === \"published\");\n /**\n * We will go page by page and zip them.\n * We are using the input.queue here because we are removing page from the ZipPagesDataManager queue as it is processed.\n *\n */\n for (const pageId of input.queue) {\n /**\n * Check for a possibility that the task was aborted.\n */\n if (isAborted()) {\n return response.aborted();\n }\n /**\n * We need to check if there is enough time left to finish the task.\n */\n if (isCloseToTimeout(CLOSE_TO_TIMEOUT_SECONDS)) {\n /**\n * If there is not enough time left, we will pause the task and return the current state.\n */\n return response.continue(dataManager.getInput());\n }\n\n const page = await getPage(pageId);\n if (!page) {\n await store.addErrorLog({\n message: `Could not load page \"${pageId}\".`,\n error: {\n message: `Could not load page \"${pageId}\".`\n }\n });\n dataManager.addFailed(pageId);\n continue;\n }\n try {\n const pageExporter = new PageExporter(context.fileManager);\n const pageDataZip = await pageExporter.execute(page, exportPageDataKey);\n if (!pageDataZip.Key) {\n throw new Error(`Failed to export page \"${pageId}\" into a zip file.`);\n }\n dataManager.addDone(pageId, pageDataZip.Key);\n } catch (ex) {\n const message = ex.message || `Failed to export page \"${pageId}\" into a zip file.`;\n try {\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n }\n dataManager.addFailed(pageId);\n }\n }\n\n return response.done(\"Task done.\", {\n done: dataManager.getDone(),\n failed: dataManager.getFailed()\n });\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,I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;AAACqB,OAAA,CAAA1C,QAAA,GAAAA,QAAA"}
|
1
|
+
{"version":3,"names":["_PageExporter","require","_ZipPagesDataManager","_getPageFactory","_utils","CLOSE_TO_TIMEOUT_SECONDS","ZipPages","execute","params","response","input","isAborted","isCloseToTimeout","context","store","parentId","getTask","error","message","exportPageDataKey","createExportPagesDataKey","dataManager","ZipPagesDataManager","hasMore","done","getDone","failed","getFailed","getPage","getPageFactory","type","pageId","queue","aborted","continue","getInput","page","addErrorLog","addFailed","pageExporter","PageExporter","fileManager","pageDataZip","Key","Error","addDone","ex","console","exports"],"sources":["ZipPages.ts"],"sourcesContent":["import { ITaskResponseResult } from \"@webiny/tasks\";\nimport { IExportPagesZipPagesTaskParams } from \"~/export/pages/types\";\nimport { PageExporter } from \"~/export/process/exporters/PageExporter\";\nimport { ZipPagesDataManager } from \"./ZipPagesDataManager\";\nimport { getPageFactory } from \"./getPageFactory\";\nimport { createExportPagesDataKey } from \"~/export/pages/utils\";\n\n/**\n * We will pause the execution of the task if there is less than CLOSE_TO_TIMEOUT_SECONDS left on the Lambda execution time.\n */\nconst CLOSE_TO_TIMEOUT_SECONDS = 300;\n\nexport class ZipPages {\n public async execute(params: IExportPagesZipPagesTaskParams): Promise<ITaskResponseResult> {\n const { response, input, isAborted, isCloseToTimeout, context, store } = params;\n\n const parentId = store.getTask().parentId;\n if (!parentId) {\n return response.error({\n message: `Could not find parent task ID.`\n });\n }\n const exportPageDataKey = createExportPagesDataKey(parentId);\n\n const dataManager = new ZipPagesDataManager(input);\n if (dataManager.hasMore() === false) {\n return response.done(\"Task done.\", {\n done: dataManager.getDone(),\n failed: dataManager.getFailed()\n });\n }\n\n const getPage = getPageFactory(context, store, input.type === \"published\");\n /**\n * We will go page by page and zip them.\n * We are using the input.queue here because we are removing page from the ZipPagesDataManager queue as it is processed.\n *\n */\n for (const pageId of input.queue) {\n /**\n * Check for a possibility that the task was aborted.\n */\n if (isAborted()) {\n return response.aborted();\n }\n /**\n * We need to check if there is enough time left to finish the task.\n */\n if (isCloseToTimeout(CLOSE_TO_TIMEOUT_SECONDS)) {\n /**\n * If there is not enough time left, we will pause the task and return the current state.\n */\n return response.continue(dataManager.getInput());\n }\n\n const page = await getPage(pageId);\n if (!page) {\n await store.addErrorLog({\n message: `Could not load page \"${pageId}\".`,\n error: {\n message: `Could not load page \"${pageId}\".`\n }\n });\n dataManager.addFailed(pageId);\n continue;\n }\n try {\n const pageExporter = new PageExporter(context.fileManager);\n const pageDataZip = await pageExporter.execute(page, exportPageDataKey);\n if (!pageDataZip.Key) {\n throw new Error(`Failed to export page \"${pageId}\" into a zip file.`);\n }\n dataManager.addDone(pageId, pageDataZip.Key);\n } catch (ex) {\n const message = ex.message || `Failed to export page \"${pageId}\" into a zip file.`;\n try {\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n }\n dataManager.addFailed(pageId);\n }\n }\n\n return response.done(\"Task done.\", {\n done: dataManager.getDone(),\n failed: dataManager.getFailed()\n });\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA,MAAMI,wBAAwB,GAAG,GAAG;AAE7B,MAAMC,QAAQ,CAAC;EAClB,MAAaC,OAAOA,CAACC,MAAsC,EAAgC;IACvF,MAAM;MAAEC,QAAQ;MAAEC,KAAK;MAAEC,SAAS;MAAEC,gBAAgB;MAAEC,OAAO;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAE/E,MAAMO,QAAQ,GAAGD,KAAK,CAACE,OAAO,CAAC,CAAC,CAACD,QAAQ;IACzC,IAAI,CAACA,QAAQ,EAAE;MACX,OAAON,QAAQ,CAACQ,KAAK,CAAC;QAClBC,OAAO,EAAG;MACd,CAAC,CAAC;IACN;IACA,MAAMC,iBAAiB,GAAG,IAAAC,+B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CAAC6B,IAAI,EAAEjB,iBAAiB,CAAC;QACvE,IAAI,CAACuB,WAAW,CAACC,GAAG,EAAE;UAClB,MAAM,IAAIC,KAAK,CAAE,0BAAyBb,MAAO,oBAAmB,CAAC;QACzE;QACAV,WAAW,CAACwB,OAAO,CAACd,MAAM,EAAEW,WAAW,CAACC,GAAG,CAAC;MAChD,CAAC,CAAC,OAAOG,EAAE,EAAE;QACT,MAAM5B,OAAO,GAAG4B,EAAE,CAAC5B,OAAO,IAAK,0BAAyBa,MAAO,oBAAmB;QAClF,IAAI;UACA,MAAMjB,KAAK,CAACuB,WAAW,CAAC;YACpBnB,OAAO;YACPD,KAAK,EAAE6B;UACX,CAAC,CAAC;QACN,CAAC,CAAC,MAAM;UACJC,OAAO,CAAC9B,KAAK,CAAE,6BAA4BC,OAAQ,GAAE,CAAC;QAC1D;QACAG,WAAW,CAACiB,SAAS,CAACP,MAAM,CAAC;MACjC;IACJ;IAEA,OAAOtB,QAAQ,CAACe,IAAI,CAAC,YAAY,EAAE;MAC/BA,IAAI,EAAEH,WAAW,CAACI,OAAO,CAAC,CAAC;MAC3BC,MAAM,EAAEL,WAAW,CAACM,SAAS,CAAC;IAClC,CAAC,CAAC;EACN;AACJ;AAACqB,OAAA,CAAA1C,QAAA,GAAAA,QAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ZipPagesDataManager","constructor","input","queue","Set","done","failed","hasMore","size","addDone","pageId","key","delete","addFailed","add","getFailed","Array","from","getDone","getInput","exports"],"sources":["ZipPagesDataManager.ts"],"sourcesContent":["import { IExportPagesZipPagesDone, IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport class ZipPagesDataManager {\n private readonly input: IExportPagesZipPagesInput;\n private readonly queue: Set<string>;\n private readonly done: IExportPagesZipPagesDone;\n private readonly failed: Set<string>;\n\n public constructor(input: IExportPagesZipPagesInput) {\n this.input = input;\n this.queue = new Set(input.queue);\n this.done = {\n ...input.done\n };\n this.failed = new Set(input.failed || []);\n }\n\n public hasMore(): boolean {\n return this.queue.size > 0;\n }\n\n public addDone(pageId: string, key: string): void {\n this.queue.delete(pageId);\n this.failed.delete(pageId);\n this.done[pageId] = key;\n }\n\n public addFailed(pageId: string): void {\n this.queue.delete(pageId);\n this.failed.add(pageId);\n delete this.done[pageId];\n }\n\n public getFailed() {\n return Array.from(this.failed);\n }\n\n public getDone() {\n return this.done;\n }\n\n public getInput(): IExportPagesZipPagesInput {\n return {\n ...this.input,\n queue: Array.from(this.queue),\n failed: Array.from(this.failed),\n done: this.done\n };\n }\n}\n"],"mappings":";;;;;;AAEO,MAAMA,mBAAmB,CAAC;EAMtBC,WAAWA,CAACC,KAAgC,EAAE;IACjD,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,KAAK,GAAG,IAAIC,GAAG,CAACF,KAAK,CAACC,KAAK,CAAC;IACjC,IAAI,CAACE,IAAI,GAAG;MACR,GAAGH,KAAK,CAACG;IACb,CAAC;IACD,IAAI,CAACC,MAAM,GAAG,IAAIF,GAAG,CAACF,KAAK,CAACI,MAAM,IAAI,EAAE,CAAC;EAC7C;EAEOC,OAAOA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACJ,KAAK,CAACK,IAAI,GAAG,CAAC;EAC9B;EAEOC,OAAOA,CAACC,MAAc,EAAEC,GAAW,EAAQ;IAC9C,IAAI,CAACR,KAAK,CAACS,MAAM,CAACF,MAAM,CAAC;IACzB,IAAI,CAACJ,MAAM,CAACM,MAAM,CAACF,MAAM,CAAC;IAC1B,IAAI,CAACL,IAAI,CAACK,MAAM,CAAC,GAAGC,GAAG;EAC3B;EAEOE,SAASA,CAACH,MAAc,EAAQ;IACnC,IAAI,CAACP,KAAK,CAACS,MAAM,CAACF,MAAM,CAAC;IACzB,IAAI,CAACJ,MAAM,CAACQ,GAAG,CAACJ,MAAM,CAAC;IACvB,OAAO,IAAI,CAACL,IAAI,CAACK,MAAM,CAAC;EAC5B;EAEOK,SAASA,CAAA,EAAG;IACf,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACX,MAAM,CAAC;EAClC;EAEOY,OAAOA,CAAA,EAAG;IACb,OAAO,IAAI,CAACb,IAAI;EACpB;EAEOc,QAAQA,CAAA,EAA8B;IACzC,OAAO;MACH,GAAG,IAAI,CAACjB,KAAK;MACbC,KAAK,EAAEa,KAAK,CAACC,IAAI,CAAC,IAAI,CAACd,KAAK,CAAC;MAC7BG,MAAM,EAAEU,KAAK,CAACC,IAAI,CAAC,IAAI,CAACX,MAAM,CAAC;MAC/BD,IAAI,EAAE,IAAI,CAACA;IACf,CAAC;EACL;AACJ;AAACe,OAAA,CAAApB,mBAAA,GAAAA,mBAAA"}
|
1
|
+
{"version":3,"names":["ZipPagesDataManager","constructor","input","queue","Set","done","failed","hasMore","size","addDone","pageId","key","delete","addFailed","add","getFailed","Array","from","getDone","getInput","exports"],"sources":["ZipPagesDataManager.ts"],"sourcesContent":["import { IExportPagesZipPagesDone, IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport class ZipPagesDataManager {\n private readonly input: IExportPagesZipPagesInput;\n private readonly queue: Set<string>;\n private readonly done: IExportPagesZipPagesDone;\n private readonly failed: Set<string>;\n\n public constructor(input: IExportPagesZipPagesInput) {\n this.input = input;\n this.queue = new Set(input.queue);\n this.done = {\n ...input.done\n };\n this.failed = new Set(input.failed || []);\n }\n\n public hasMore(): boolean {\n return this.queue.size > 0;\n }\n\n public addDone(pageId: string, key: string): void {\n this.queue.delete(pageId);\n this.failed.delete(pageId);\n this.done[pageId] = key;\n }\n\n public addFailed(pageId: string): void {\n this.queue.delete(pageId);\n this.failed.add(pageId);\n delete this.done[pageId];\n }\n\n public getFailed() {\n return Array.from(this.failed);\n }\n\n public getDone() {\n return this.done;\n }\n\n public getInput(): IExportPagesZipPagesInput {\n return {\n ...this.input,\n queue: Array.from(this.queue),\n failed: Array.from(this.failed),\n done: this.done\n };\n }\n}\n"],"mappings":";;;;;;AAEO,MAAM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EACL;AACJ;AAACe,OAAA,CAAApB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getPageFactory","context","store","published","pageId","pageBuilder","getPublishedPageById","id","ex","getPage","message","addErrorLog","error","console","exports"],"sources":["getPageFactory.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/graphql/types\";\nimport { ITaskManagerStore } from \"@webiny/tasks\";\nimport { IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport const getPageFactory = (\n context: PbImportExportContext,\n store: ITaskManagerStore<IExportPagesZipPagesInput>,\n published: boolean\n) => {\n return async (pageId: string) => {\n if (published) {\n try {\n return await context.pageBuilder.getPublishedPageById({\n id: pageId\n });\n } catch (ex) {\n /**\n * We do not need to do anything on exception because we will fetch the latest version.\n */\n }\n }\n try {\n return await context.pageBuilder.getPage(pageId);\n } catch (ex) {\n const message = `There is no page with ID ${pageId}.`;\n try {\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n }\n return null;\n }\n };\n};\n"],"mappings":";;;;;;AAIO,MAAMA,cAAc,GAAGA,CAC1BC,OAA8B,EAC9BC,KAAmD,EACnDC,SAAkB,KACjB;EACD,OAAO,MAAOC,MAAc,IAAK;IAC7B,IAAID,SAAS,EAAE;MACX,IAAI;QACA,OAAO,MAAMF,OAAO,CAACI,WAAW,CAACC,oBAAoB,CAAC;UAClDC,EAAE,EAAEH;QACR,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACT;AAChB;AACA;MAFgB;IAIR;IACA,IAAI;MACA,OAAO,MAAMP,OAAO,CAACI,WAAW,CAACI,OAAO,CAACL,MAAM,CAAC;IACpD,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAME,OAAO,GAAI,4BAA2BN,MAAO,GAAE;MACrD,IAAI;QACA,MAAMF,KAAK,CAACS,WAAW,CAAC;UACpBD,OAAO;UACPE,KAAK,EAAEJ;QACX,CAAC,CAAC;MACN,CAAC,CAAC,MAAM;QACJK,OAAO,CAACD,KAAK,CAAE,6BAA4BF,OAAQ,GAAE,CAAC;MAC1D;MACA,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAAd,cAAA,GAAAA,cAAA"}
|
1
|
+
{"version":3,"names":["getPageFactory","context","store","published","pageId","pageBuilder","getPublishedPageById","id","ex","getPage","message","addErrorLog","error","console","exports"],"sources":["getPageFactory.ts"],"sourcesContent":["import { PbImportExportContext } from \"~/graphql/types\";\nimport { ITaskManagerStore } from \"@webiny/tasks\";\nimport { IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport const getPageFactory = (\n context: PbImportExportContext,\n store: ITaskManagerStore<IExportPagesZipPagesInput>,\n published: boolean\n) => {\n return async (pageId: string) => {\n if (published) {\n try {\n return await context.pageBuilder.getPublishedPageById({\n id: pageId\n });\n } catch (ex) {\n /**\n * We do not need to do anything on exception because we will fetch the latest version.\n */\n }\n }\n try {\n return await context.pageBuilder.getPage(pageId);\n } catch (ex) {\n const message = `There is no page with ID ${pageId}.`;\n try {\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n }\n return null;\n }\n };\n};\n"],"mappings":";;;;;;AAIO,MAAMA,cAAc,GAAGA,CAC1BC,OAA8B,EAC9BC,KAAmD,EACnDC,SAAkB,KACjB;EACD,OAAO,MAAOC,MAAc,IAAK;IAC7B,IAAID,SAAS,EAAE;MACX,IAAI;QACA,OAAO,MAAMF,OAAO,CAACI,WAAW,CAACC,oBAAoB,CAAC;UAClDC,EAAE,EAAEH;QACR,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACT;AAChB;AACA;MAFgB;IAIR;IACA,IAAI;MACA,OAAO,MAAMP,OAAO,CAACI,WAAW,CAACI,OAAO,CAACL,MAAM,CAAC;IACpD,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAME,OAAO,GAAI,4BAA2BN,MAAO,GAAE;MACrD,IAAI;QACA,MAAMF,KAAK,CAACS,WAAW,CAAC;UACpBD,OAAO;UACPE,KAAK,EAAEJ;QACX,CAAC,CAAC;MACN,CAAC,CAAC,MAAM;QACJK,OAAO,CAACD,KAAK,CAAE,6BAA4BF,OAAQ,GAAE,CAAC;MAC1D;MACA,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_client","_handlerGraphql","_mockSecurity","_utils","_BlockExporter","blocksHandler","configuration","payload","context","log","console","subTask","noPendingTask","prevStatusOfSubTask","ImportExportTaskStatus","PENDING","pageBuilder","fileManager","taskId","subTaskIndex","type","identity","mockSecurity","importExportTask","getSubTask","zeroPad","status","data","error","id","input","blockId","exportBlocksDataKey","block","getPageBlock","NotFoundError","blockCategory","getBlockCategory","updateSubTask","PROCESSING","updateStats","prevStatus","nextStatus","blockExporter","BlockExporter","blockDataZip","execute","COMPLETED","message","key","Key","e","FAILED","name","code","invokeHandlerClient","handlers","combine","security","getIdentity","description","process","exports"],"sources":["blocksHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { Payload as ExtractPayload } from \"../combine\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { Configuration, Payload, Response } from \"~/export/process\";\nimport { BlockExporter } from \"./exporters/BlockExporter\";\n\n/**\n * Handles the export blocks process workflow.\n */\nexport const blocksHandler = async (\n configuration: Configuration,\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n let subTask;\n let noPendingTask = true;\n let prevStatusOfSubTask = ImportExportTaskStatus.PENDING;\n\n log(\"RUNNING Export Blocks Process Handler\");\n const { pageBuilder, fileManager } = context;\n const { taskId, subTaskIndex, type, identity } = payload;\n // Disable authorization; this is necessary because we call Page Builder CRUD methods which include authorization checks\n // and this Lambda is invoked internally, without credentials.\n mockSecurity(identity as SecurityIdentity, context);\n try {\n /*\n * Note: We're not going to DB for finding the next sub-task to process,\n * because the data might be out of sync due to GSI eventual consistency.\n */\n subTask = await pageBuilder.importExportTask.getSubTask(taskId, zeroPad(subTaskIndex, 5));\n /**\n * Base condition!!\n * Bail out early, if task not found or task's status is not \"pending\".\n */\n if (!subTask || subTask.status !== ImportExportTaskStatus.PENDING) {\n noPendingTask = true;\n return {\n data: \"\",\n error: null\n };\n } else {\n noPendingTask = false;\n }\n\n log(`Fetched sub task => ${subTask.id}`);\n\n const { input } = subTask;\n const { blockId, exportBlocksDataKey } = input;\n\n const block = await pageBuilder.getPageBlock(blockId);\n\n if (!block) {\n log(`Unable to load block \"${blockId}\"`);\n throw new NotFoundError(`Unable to load block \"${blockId}\"`);\n }\n\n log(`Processing block key \"${blockId}\"`);\n\n const blockCategory = await pageBuilder.getBlockCategory(block.blockCategory);\n\n if (!blockCategory) {\n log(`Unable to load block category \"${block.blockCategory}\"`);\n throw new NotFoundError(`Unable to load block category \"${block.blockCategory}\"`);\n }\n\n // Mark task status as PROCESSING\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.PROCESSING\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.PROCESSING\n });\n prevStatusOfSubTask = subTask.status;\n\n log(`Extracting block data and uploading to storage...`);\n const blockExporter = new BlockExporter(fileManager);\n const blockDataZip = await blockExporter.execute(block, blockCategory, exportBlocksDataKey);\n\n log(`Finish uploading zip...`);\n // Update task record in DB\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading data for block \"${block.id}\"`,\n key: blockDataZip.Key\n }\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.COMPLETED\n });\n prevStatusOfSubTask = subTask.status;\n } catch (e) {\n log(\"[EXPORT_BLOCKS_PROCESS] Error => \", e.message);\n\n if (subTask && subTask.id) {\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.FAILED\n });\n prevStatusOfSubTask = subTask.status;\n }\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n } finally {\n // Base condition!\n if (noPendingTask) {\n log(`No pending sub-task for task ${taskId}`);\n // Combine individual block zip files.\n await invokeHandlerClient<ExtractPayload>({\n context,\n name: configuration.handlers.combine,\n payload: {\n taskId,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - combine\"\n });\n } else {\n console.log(`Invoking PROCESS for task \"${subTaskIndex + 1}\"`);\n // We want to continue with Self invocation no matter if current block error out.\n await invokeHandlerClient<Payload>({\n context,\n name: configuration.handlers.process,\n payload: {\n taskId,\n subTaskIndex: subTaskIndex + 1,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - process - subtask\"\n });\n }\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAA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AM;UACNE,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACkD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN,CAAC,MAAM;MACHlD,OAAO,CAACD,GAAG,CAAE,8BAA6BU,YAAY,GAAG,CAAE,GAAE,CAAC;MAC9D;MACA,MAAM,IAAAoC,2BAAmB,EAAU;QAC/B/C,OAAO;QACP6C,IAAI,EAAE/C,aAAa,CAACkD,QAAQ,CAACK,OAAO;QACpCtD,OAAO,EAAE;UACLW,MAAM;UACNC,YAAY,EAAEA,YAAY,GAAG,CAAC;UAC9BC,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACkD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN;EACJ;EACA,OAAO;IACHjC,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACkC,OAAA,CAAAzD,aAAA,GAAAA,aAAA"}
|
1
|
+
{"version":3,"names":["_types","require","_client","_handlerGraphql","_mockSecurity","_utils","_BlockExporter","blocksHandler","configuration","payload","context","log","console","subTask","noPendingTask","prevStatusOfSubTask","ImportExportTaskStatus","PENDING","pageBuilder","fileManager","taskId","subTaskIndex","type","identity","mockSecurity","importExportTask","getSubTask","zeroPad","status","data","error","id","input","blockId","exportBlocksDataKey","block","getPageBlock","NotFoundError","blockCategory","getBlockCategory","updateSubTask","PROCESSING","updateStats","prevStatus","nextStatus","blockExporter","BlockExporter","blockDataZip","execute","COMPLETED","message","key","Key","e","FAILED","name","code","invokeHandlerClient","handlers","combine","security","getIdentity","description","process","exports"],"sources":["blocksHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { Payload as ExtractPayload } from \"../combine\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { Configuration, Payload, Response } from \"~/export/process\";\nimport { BlockExporter } from \"./exporters/BlockExporter\";\n\n/**\n * Handles the export blocks process workflow.\n */\nexport const blocksHandler = async (\n configuration: Configuration,\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n let subTask;\n let noPendingTask = true;\n let prevStatusOfSubTask = ImportExportTaskStatus.PENDING;\n\n log(\"RUNNING Export Blocks Process Handler\");\n const { pageBuilder, fileManager } = context;\n const { taskId, subTaskIndex, type, identity } = payload;\n // Disable authorization; this is necessary because we call Page Builder CRUD methods which include authorization checks\n // and this Lambda is invoked internally, without credentials.\n mockSecurity(identity as SecurityIdentity, context);\n try {\n /*\n * Note: We're not going to DB for finding the next sub-task to process,\n * because the data might be out of sync due to GSI eventual consistency.\n */\n subTask = await pageBuilder.importExportTask.getSubTask(taskId, zeroPad(subTaskIndex, 5));\n /**\n * Base condition!!\n * Bail out early, if task not found or task's status is not \"pending\".\n */\n if (!subTask || subTask.status !== ImportExportTaskStatus.PENDING) {\n noPendingTask = true;\n return {\n data: \"\",\n error: null\n };\n } else {\n noPendingTask = false;\n }\n\n log(`Fetched sub task => ${subTask.id}`);\n\n const { input } = subTask;\n const { blockId, exportBlocksDataKey } = input;\n\n const block = await pageBuilder.getPageBlock(blockId);\n\n if (!block) {\n log(`Unable to load block \"${blockId}\"`);\n throw new NotFoundError(`Unable to load block \"${blockId}\"`);\n }\n\n log(`Processing block key \"${blockId}\"`);\n\n const blockCategory = await pageBuilder.getBlockCategory(block.blockCategory);\n\n if (!blockCategory) {\n log(`Unable to load block category \"${block.blockCategory}\"`);\n throw new NotFoundError(`Unable to load block category \"${block.blockCategory}\"`);\n }\n\n // Mark task status as PROCESSING\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.PROCESSING\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.PROCESSING\n });\n prevStatusOfSubTask = subTask.status;\n\n log(`Extracting block data and uploading to storage...`);\n const blockExporter = new BlockExporter(fileManager);\n const blockDataZip = await blockExporter.execute(block, blockCategory, exportBlocksDataKey);\n\n log(`Finish uploading zip...`);\n // Update task record in DB\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading data for block \"${block.id}\"`,\n key: blockDataZip.Key\n }\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.COMPLETED\n });\n prevStatusOfSubTask = subTask.status;\n } catch (e) {\n log(\"[EXPORT_BLOCKS_PROCESS] Error => \", e.message);\n\n if (subTask && subTask.id) {\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.FAILED\n });\n prevStatusOfSubTask = subTask.status;\n }\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n } finally {\n // Base condition!\n if (noPendingTask) {\n log(`No pending sub-task for task ${taskId}`);\n // Combine individual block zip files.\n await invokeHandlerClient<ExtractPayload>({\n context,\n name: configuration.handlers.combine,\n payload: {\n taskId,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - combine\"\n });\n } else {\n console.log(`Invoking PROCESS for task \"${subTaskIndex + 1}\"`);\n // We want to continue with Self invocation no matter if current block error out.\n await invokeHandlerClient<Payload>({\n context,\n name: configuration.handlers.process,\n payload: {\n taskId,\n subTaskIndex: subTaskIndex + 1,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - process - subtask\"\n });\n }\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,cAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACO,MAAMM,aAAa,GAAG,MAAAA,CACzBC,aAA4B,EAC5BC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EACvB,IAAIE,OAAO;EACX,IAAIC,aAAa,GAAG,IAAI;EACxB,IAAIC,mBAAmB,GAAGC,6BAAsB,CAACC,OAAO;EAExDN,GAAG,CAAC,uCAAuC,CAAC;EAC5C,MAAM;IAAEO,WAAW;IAAEC;EAAY,CAAC,GAAGT,OAAO;EAC5C,MAAM;IAAEU,MAAM;IAAEC,YAAY;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGd,OAAO;EACxD;EACA;EACA,IAAAe,0BAAY,EAACD,QAAQ,EAAsBb,OAAO,CAAC;EACnD,IAAI;IACA;AACR;AACA;AACA;IACQG,OAAO,GAAG,MAAMK,WAAW,CAACO,gBAAgB,CAACC,UAAU,CAACN,MAAM,EAAE,IAAAO,cAAO,EAACN,YAAY,EAAE,CAAC,CAAC,CAAC;IACzF;AACR;AACA;AACA;IACQ,IAAI,CAACR,OAAO,IAAIA,OAAO,CAACe,MAAM,KAAKZ,6BAAsB,CAACC,OAAO,EAAE;MAC/DH,aAAa,GAAG,IAAI;MACpB,OAAO;QACHe,IAAI,EAAE,EAAE;QACRC,KAAK,EAAE;MACX,CAAC;IACL,CAAC,MAAM;MACHhB,aAAa,GAAG,KAAK;IACzB;IAEAH,GAAG,CAAE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AAE,IAAI;MACVC,KAAK,EAAE;QACHoB,OAAO,EAAEG,CAAC,CAACH;MACf;IACJ,CAAC;EACL,CAAC,SAAS;IACN;IACA,IAAIpC,aAAa,EAAE;MACfH,GAAG,CAAE,gCAA+BS,MAAO,EAAC,CAAC;MAC7C;MACA,MAAM,IAAAqC,2BAAmB,EAAiB;QACtC/C,OAAO;QACP6C,IAAI,EAAE/C,aAAa,CAACkD,QAAQ,CAACC,OAAO;QACpClD,OAAO,EAAE;UACLW,MAAM;UACNE,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACkD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN,CAAC,MAAM;MACHlD,OAAO,CAACD,GAAG,CAAE,8BAA6BU,YAAY,GAAG,CAAE,GAAE,CAAC;MAC9D;MACA,MAAM,IAAAoC,2BAAmB,EAAU;QAC/B/C,OAAO;QACP6C,IAAI,EAAE/C,aAAa,CAACkD,QAAQ,CAACK,OAAO;QACpCtD,OAAO,EAAE;UACLW,MAAM;UACNC,YAAY,EAAEA,YAAY,GAAG,CAAC;UAC9BC,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACkD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN;EACJ;EACA,OAAO;IACHjC,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACkC,OAAA,CAAAzD,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","BlockExporter","constructor","fileManager","execute","block","blockCategory","exportBlocksDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","blockData","name","category","slug","icon","description","blockDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","dataBuffer","archiveFileKey","process","exports"],"sources":["BlockExporter.ts"],"sourcesContent":["import { BlockCategory, PageBlock } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedBlockData {\n block: Pick<PageBlock, \"name\" | \"content\">;\n category: BlockCategory;\n files: File[];\n}\n\nexport class BlockExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(block.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the block data in a json file and upload it to S3\n const blockData = {\n block: {\n name: block.name,\n content: block.content\n },\n category: {\n name: blockCategory.name,\n slug: blockCategory.slug,\n icon: blockCategory.icon,\n description: blockCategory.description\n },\n files: imageFilesData\n };\n const blockDataBuffer = Buffer.from(JSON.stringify(blockData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: block.name,\n dataBuffer: blockDataBuffer\n },\n archiveFileKey: exportBlocksDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQO,MAAME,aAAa,CAAC;EAGvBC,WAAWA,CAACC,WAA8C,EAAE;IACxD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC;EAEA,MAAMC,OAAOA,CAACC,KAAgB,EAAEC,aAA4B,EAAEC,mBAA2B,EAAE;IACvF;IACA,MAAMC,KAAK,GAAG,IAAAC,2BAAoB,EAACJ,KAAK,CAACK,OAAO,IAAI,CAAC,CAAC,CAAC;IACvD,MAAMC,OAAO,GAAGH,KAAK,CAACI,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC;IACpD;IACA,MAAMC,cAAc,GAAG,EAAE;IACzB,IAAIJ,OAAO,CAACK,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,CAACC,SAAS,CAAC,GAAG,MAAM,IAAI,CAACd,WAAW,CAACe,SAAS,CAAC;QAAEC,KAAK,EAAE;UAAEC,KAAK,EAAET;QAAQ;MAAE,CAAC,CAAC;MACnFI,cAAc,CAACM,IAAI,CAAC,GAAGJ,SAAS,CAAC;IACrC;;IAEA;IACA,MAAMK,SAAS,GAAG;MACdjB,KAAK,EAAE;QACHkB,IAAI,EAAElB,KAAK,CAACkB,IAAI;QAChBb,OAAO,EAAEL,KAAK,CAACK;MACnB,CAAC;MACDc,QAAQ,EAAE;QACND,IAAI,EAAEjB,aAAa,CAACiB,IAAI;QACxBE,IAAI,EAAEnB,aAAa,CAACmB,IAAI;QACxBC,IAAI,EAAEpB,aAAa,CAACoB,IAAI;QACxBC,WAAW,EAAErB,aAAa,CAACqB;MAC/B,CAAC;MACDnB,KAAK,EAAEO;IACX,CAAC;IACD,MAAMa,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,SAAS,CAAC,CAAC;IAE9D,MAAMW,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACR3B,KAAK,EAAEO,cAAc;QACrBQ,IAAI,EAAElB,KAAK,CAACkB,IAAI;QAChBa,UAAU,EAAER;MAChB,CAAC;MACDS,cAAc,EAAE9B;IACpB,CAAC,CAAC;IAEF,OAAO0B,MAAM,CAACK,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAtC,aAAA,GAAAA,aAAA"}
|
1
|
+
{"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","BlockExporter","constructor","fileManager","execute","block","blockCategory","exportBlocksDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","blockData","name","category","slug","icon","description","blockDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","dataBuffer","archiveFileKey","process","exports"],"sources":["BlockExporter.ts"],"sourcesContent":["import { BlockCategory, PageBlock } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedBlockData {\n block: Pick<PageBlock, \"name\" | \"content\">;\n category: BlockCategory;\n files: File[];\n}\n\nexport class BlockExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(block.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the block data in a json file and upload it to S3\n const blockData = {\n block: {\n name: block.name,\n content: block.content\n },\n category: {\n name: blockCategory.name,\n slug: blockCategory.slug,\n icon: blockCategory.icon,\n description: blockCategory.description\n },\n files: imageFilesData\n };\n const blockDataBuffer = Buffer.from(JSON.stringify(blockData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: block.name,\n dataBuffer: blockDataBuffer\n },\n archiveFileKey: exportBlocksDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQO,MAAME,aAAa,CAAC;EAGvBC,WAAWA,CAACC,WAA8C,EAAE;IACxD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC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AC3B;AACJ;AAACC,OAAA,CAAAtC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_zipper","_interopRequireDefault","require","FormExporter","execute","form","exportFormsDataKey","formData","name","status","version","fields","steps","settings","triggers","formDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","files","dataBuffer","archiveFileKey","process","exports"],"sources":["FormExporter.ts"],"sourcesContent":["import Zipper from \"~/export/zipper\";\nimport { FbForm } from \"@webiny/api-form-builder/types\";\nimport { File } from \"@webiny/api-file-manager/types\";\n\nexport interface ExportedFormData {\n form: Pick<\n FbForm,\n \"name\" | \"status\" | \"version\" | \"fields\" | \"steps\" | \"settings\" | \"triggers\"\n >;\n files: File[];\n}\n\nexport class FormExporter {\n async execute(form: FbForm, exportFormsDataKey: string) {\n const formData = {\n form: {\n name: form.name,\n status: form.status,\n version: form.version,\n fields: form.fields,\n steps: form.steps,\n settings: form.settings,\n triggers: form.triggers\n }\n };\n const formDataBuffer = Buffer.from(JSON.stringify(formData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: [],\n name: form.name,\n dataBuffer: formDataBuffer\n },\n archiveFileKey: exportFormsDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAYO,MAAMC,YAAY,CAAC;EACtB,MAAMC,OAAOA,CAACC,IAAY,EAAEC,kBAA0B,EAAE;IACpD,MAAMC,QAAQ,GAAG;MACbF,IAAI,EAAE;QACFG,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfC,MAAM,EAAEJ,IAAI,CAACI,MAAM;QACnBC,OAAO,EAAEL,IAAI,CAACK,OAAO;QACrBC,MAAM,EAAEN,IAAI,CAACM,MAAM;QACnBC,KAAK,EAAEP,IAAI,CAACO,KAAK;QACjBC,QAAQ,EAAER,IAAI,CAACQ,QAAQ;QACvBC,QAAQ,EAAET,IAAI,CAACS;MACnB;IACJ,CAAC;IACD,MAAMC,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACZ,QAAQ,CAAC,CAAC;IAE5D,MAAMa,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRC,KAAK,EAAE,EAAE;QACTf,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfgB,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAEnB;IACpB,CAAC,CAAC;IAEF,OAAOc,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAxB,YAAA,GAAAA,YAAA"}
|
1
|
+
{"version":3,"names":["_zipper","_interopRequireDefault","require","FormExporter","execute","form","exportFormsDataKey","formData","name","status","version","fields","steps","settings","triggers","formDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","files","dataBuffer","archiveFileKey","process","exports"],"sources":["FormExporter.ts"],"sourcesContent":["import Zipper from \"~/export/zipper\";\nimport { FbForm } from \"@webiny/api-form-builder/types\";\nimport { File } from \"@webiny/api-file-manager/types\";\n\nexport interface ExportedFormData {\n form: Pick<\n FbForm,\n \"name\" | \"status\" | \"version\" | \"fields\" | \"steps\" | \"settings\" | \"triggers\"\n >;\n files: File[];\n}\n\nexport class FormExporter {\n async execute(form: FbForm, exportFormsDataKey: string) {\n const formData = {\n form: {\n name: form.name,\n status: form.status,\n version: form.version,\n fields: form.fields,\n steps: form.steps,\n settings: form.settings,\n triggers: form.triggers\n }\n };\n const formDataBuffer = Buffer.from(JSON.stringify(formData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: [],\n name: form.name,\n dataBuffer: formDataBuffer\n },\n archiveFileKey: exportFormsDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAYO,MAAMC,YAAY,CAAC;EACtB,MAAMC,OAAOA,CAACC,IAAY,EAAEC,kBAA0B,EAAE;IACpD,MAAMC,QAAQ,GAAG;MACbF,IAAI,EAAE;QACFG,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfC,MAAM,EAAEJ,IAAI,CAACI,MAAM;QACnBC,OAAO,EAAEL,IAAI,CAACK,OAAO;QACrBC,MAAM,EAAEN,IAAI,CAACM,MAAM;QACnBC,KAAK,EAAEP,IAAI,CAACO,KAAK;QACjBC,QAAQ,EAAER,IAAI,CAACQ,QAAQ;QACvBC,QAAQ,EAAET,IAAI,CAACS;MACnB;IACJ,CAAC;IACD,MAAMC,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACZ,QAAQ,CAAC,CAAC;IAE5D,MAAMa,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRC,KAAK,EAAE,EAAE;QACTf,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfgB,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAEnB;IACpB,CAAC,CAAC;IAEF,OAAOc,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAxB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_get","_interopRequireDefault","require","_zipper","_utils","PageExporter","constructor","fileManager","execute","page","exportPagesDataKey","files","extractFilesFromData","content","pageSettingsImages","get","filter","image","src","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","pageData","title","path","version","status","settings","pageDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageExporter.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { Page } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedPageData {\n /**\n * TODO: is it really ok not to export whole page object?\n * What if we add some new properties in the future?\n *\n * Type of the exported page data is now created by removing unnecessary properties from the Page type.\n * This way TS will break if we add new property and forget to handle it in the export/import process.\n */\n page: Omit<\n Page,\n | \"id\"\n | \"pid\"\n | \"tenant\"\n | \"locale\"\n | \"editor\"\n | \"category\"\n | \"createdFrom\"\n | \"createdBy\"\n | \"createdOn\"\n | \"savedOn\"\n | \"publishedOn\"\n | \"locked\"\n | \"ownedBy\"\n | \"webinyVersion\"\n >;\n files: File[];\n}\n\nexport class PageExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(page: Page, exportPagesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(page.content || {});\n // Extract images from page settings\n const pageSettingsImages = [\n get(page, \"settings.general.image\") as unknown as File,\n get(page, \"settings.social.image\") as unknown as File\n ].filter(image => image && image.src);\n\n const fileIds = [...files, ...pageSettingsImages].map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData: File[] = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the page data in a json file and upload it to S3\n const pageData: ExportedPageData = {\n page: {\n content: page.content,\n title: page.title,\n path: page.path,\n version: page.version,\n status: page.status,\n settings: page.settings\n },\n files: imageFilesData\n };\n const pageDataBuffer = Buffer.from(JSON.stringify(pageData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: page.title,\n dataBuffer: pageDataBuffer\n },\n archiveFileKey: exportPagesDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AA8BO,MAAMG,YAAY,CAAC;EAGtBC,WAAWA,CAACC,WAA8C,EAAE;IACx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CAAC,CAAC;IAE5D,MAAMW,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRhC,KAAK,EAAEY,cAAc;QACrBqB,IAAI,EAAEnC,IAAI,CAACsB,KAAK;QAChBc,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAEpC;IACpB,CAAC,CAAC;IAEF,OAAO+B,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAA3C,YAAA,GAAAA,YAAA"}
|
1
|
+
{"version":3,"names":["_get","_interopRequireDefault","require","_zipper","_utils","PageExporter","constructor","fileManager","execute","page","exportPagesDataKey","files","extractFilesFromData","content","pageSettingsImages","get","filter","image","src","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","pageData","title","path","version","status","settings","pageDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageExporter.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { Page } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedPageData {\n /**\n * TODO: is it really ok not to export whole page object?\n * What if we add some new properties in the future?\n *\n * Type of the exported page data is now created by removing unnecessary properties from the Page type.\n * This way TS will break if we add new property and forget to handle it in the export/import process.\n */\n page: Omit<\n Page,\n | \"id\"\n | \"pid\"\n | \"tenant\"\n | \"locale\"\n | \"editor\"\n | \"category\"\n | \"createdFrom\"\n | \"createdBy\"\n | \"createdOn\"\n | \"savedOn\"\n | \"publishedOn\"\n | \"locked\"\n | \"ownedBy\"\n | \"webinyVersion\"\n >;\n files: File[];\n}\n\nexport class PageExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(page: Page, exportPagesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(page.content || {});\n // Extract images from page settings\n const pageSettingsImages = [\n get(page, \"settings.general.image\") as unknown as File,\n get(page, \"settings.social.image\") as unknown as File\n ].filter(image => image && image.src);\n\n const fileIds = [...files, ...pageSettingsImages].map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData: File[] = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the page data in a json file and upload it to S3\n const pageData: ExportedPageData = {\n page: {\n content: page.content,\n title: page.title,\n path: page.path,\n version: page.version,\n status: page.status,\n settings: page.settings\n },\n files: imageFilesData\n };\n const pageDataBuffer = Buffer.from(JSON.stringify(pageData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: page.title,\n dataBuffer: pageDataBuffer\n },\n archiveFileKey: exportPagesDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AA8BO,MAAMG,YAAY,CAAC;EAGtBC,WAAWA,CAACC,WAA8C,EAAE;IACxD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC;EAEA,MAAMC,OAAOA,CAACC,IAAU,EAAEC,kBAA0B,EAAE;IAClD;IACA,MAAMC,KAAK,GAAG,IAAAC,2BAAoB,EAACH,IAAI,CAACI,OAAO,IAAI,CAAC,CAAC,CAAC;IACtD;IACA,MAAMC,kBAAkB,GAAG,CACvB,IAAAC,YAAG,EAACN,IAAI,EAAE,wBAAwB,CAAC,EACnC,IAAAM,YAAG,EAACN,IAAI,EAAE,uBAAuB,CAAC,CACrC,CAACO,MAAM,CAACC,KAAK,IAAIA,KAAK,IAAIA,KAAK,CAACC,GAAG,CAAC;IAErC,MAAMC,OAAO,GAAG,CAAC,GAAGR,KAAK,EAAE,GAAGG,kBAAkB,CAAC,CAACM,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC;IAChF;IACA,MAAMC,cAAsB,GAAG,EAAE;IACjC,IAAIJ,OAAO,CAACK,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,CAACC,SAAS,CAAC,GAAG,MAAM,IAAI,CAAClB,WAAW,CAACmB,SAAS,CAAC;QAAEC,KAAK,EAAE;UAAEC,KAAK,EAAET;QAAQ;MAAE,CAAC,CAAC;MACnFI,cAAc,CAACM,IAAI,CAAC,GAAGJ,SAAS,CAAC;IACrC;;IAEA;IACA,MAAMK,QAA0B,GAAG;MAC/BrB,IAAI,EAAE;QACFI,OAAO,EAAEJ,IAAI,CAACI,OAAO;QACrBkB,KAAK,EAAEtB,IAAI,CAACsB,KAAK;QACjBC,IAAI,EAAEvB,IAAI,CAACuB,IAAI;QACfC,OAAO,EAAExB,IAAI,CAACwB,OAAO;QACrBC,MAAM,EAAEzB,IAAI,CAACyB,MAAM;QACnBC,QAAQ,EAAE1B,IAAI,CAAC0B;MACnB,CAAC;MACDxB,KAAK,EAAEY;IACX,CAAC;IACD,MAAMa,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,QAAQ,CAAC,CAAC;IAE5D,MAAMW,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRhC,KAAK,EAAEY,cAAc;QACrBqB,IAAI,EAAEnC,IAAI,CAACsB,KAAK;QAChBc,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAEpC;IACpB,CAAC,CAAC;IAEF,OAAO+B,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAA3C,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","PageTemplateExporter","constructor","fileManager","execute","template","exportTemplatesDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","templateData","title","slug","tags","description","layout","pageCategory","templateDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageTemplateExporter.ts"],"sourcesContent":["import { PageTemplate } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedTemplateData {\n template: Pick<\n PageTemplate,\n \"title\" | \"slug\" | \"tags\" | \"description\" | \"content\" | \"layout\" | \"pageCategory\"\n >;\n files: File[];\n}\n\nexport class PageTemplateExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(template: PageTemplate, exportTemplatesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(template.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the template data in a json file and upload it to S3\n const templateData = {\n template: {\n title: template.title,\n slug: template.slug,\n tags: template.tags,\n description: template.description,\n content: template.content,\n layout: template.layout,\n pageCategory: template.pageCategory\n },\n files: imageFilesData\n };\n const templateDataBuffer = Buffer.from(JSON.stringify(templateData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: template.title,\n dataBuffer: templateDataBuffer\n },\n archiveFileKey: exportTemplatesDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUO,MAAME,oBAAoB,CAAC;EAG9BC,WAAWA,CAACC,WAA8C,EAAE;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;IACpB,CAAC,CAAC;IAEF,OAAO2B,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAvC,oBAAA,GAAAA,oBAAA"}
|
1
|
+
{"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","PageTemplateExporter","constructor","fileManager","execute","template","exportTemplatesDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","templateData","title","slug","tags","description","layout","pageCategory","templateDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageTemplateExporter.ts"],"sourcesContent":["import { PageTemplate } from \"@webiny/api-page-builder/types\";\nimport { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedTemplateData {\n template: Pick<\n PageTemplate,\n \"title\" | \"slug\" | \"tags\" | \"description\" | \"content\" | \"layout\" | \"pageCategory\"\n >;\n files: File[];\n}\n\nexport class PageTemplateExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(template: PageTemplate, exportTemplatesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(template.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the template data in a json file and upload it to S3\n const templateData = {\n template: {\n title: template.title,\n slug: template.slug,\n tags: template.tags,\n description: template.description,\n content: template.content,\n layout: template.layout,\n pageCategory: template.pageCategory\n },\n files: imageFilesData\n };\n const templateDataBuffer = Buffer.from(JSON.stringify(templateData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: template.title,\n dataBuffer: templateDataBuffer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