@webiny/api-page-builder-import-export 0.0.0-unstable.df6d94b531 → 0.0.0-unstable.e53eceafb5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/client.d.ts +1 -1
  2. package/client.js +12 -21
  3. package/client.js.map +1 -1
  4. package/export/combine/blocksHandler.d.ts +2 -2
  5. package/export/combine/blocksHandler.js +4 -2
  6. package/export/combine/blocksHandler.js.map +1 -1
  7. package/export/combine/formsHandler.d.ts +2 -2
  8. package/export/combine/formsHandler.js +4 -2
  9. package/export/combine/formsHandler.js.map +1 -1
  10. package/export/combine/index.d.ts +2 -2
  11. package/export/combine/index.js +24 -20
  12. package/export/combine/index.js.map +1 -1
  13. package/export/combine/templatesHandler.d.ts +2 -2
  14. package/export/combine/templatesHandler.js +4 -2
  15. package/export/combine/templatesHandler.js.map +1 -1
  16. package/export/pages/ExportPagesCleanup.d.ts +5 -0
  17. package/export/pages/ExportPagesCleanup.js +82 -0
  18. package/export/pages/ExportPagesCleanup.js.map +1 -0
  19. package/export/pages/ExportPagesController.d.ts +5 -0
  20. package/export/pages/ExportPagesController.js +31 -0
  21. package/export/pages/ExportPagesController.js.map +1 -0
  22. package/export/pages/ExportPagesZipPages.d.ts +5 -0
  23. package/export/pages/ExportPagesZipPages.js +23 -0
  24. package/export/pages/ExportPagesZipPages.js.map +1 -0
  25. package/export/pages/controller/CombineZippedPages.d.ts +5 -0
  26. package/export/pages/controller/CombineZippedPages.js +75 -0
  27. package/export/pages/controller/CombineZippedPages.js.map +1 -0
  28. package/export/pages/controller/CreateZipPagesTasks.d.ts +8 -0
  29. package/export/pages/controller/CreateZipPagesTasks.js +103 -0
  30. package/export/pages/controller/CreateZipPagesTasks.js.map +1 -0
  31. package/export/pages/controller/ProcessZipPagesTasks.d.ts +6 -0
  32. package/export/pages/controller/ProcessZipPagesTasks.js +61 -0
  33. package/export/pages/controller/ProcessZipPagesTasks.js.map +1 -0
  34. package/export/pages/types.d.ts +53 -0
  35. package/export/pages/types.js +26 -0
  36. package/export/pages/types.js.map +1 -0
  37. package/export/pages/utils.d.ts +2 -0
  38. package/export/pages/utils.js +13 -0
  39. package/export/pages/utils.js.map +1 -0
  40. package/export/pages/zipPages/ZipPages.d.ts +5 -0
  41. package/export/pages/zipPages/ZipPages.js +100 -0
  42. package/export/pages/zipPages/ZipPages.js.map +1 -0
  43. package/export/pages/zipPages/ZipPagesDataManager.d.ts +14 -0
  44. package/export/pages/zipPages/ZipPagesDataManager.js +46 -0
  45. package/export/pages/zipPages/ZipPagesDataManager.js.map +1 -0
  46. package/export/pages/zipPages/getPageFactory.d.ts +4 -0
  47. package/export/pages/zipPages/getPageFactory.js +38 -0
  48. package/export/pages/zipPages/getPageFactory.js.map +1 -0
  49. package/export/process/blocksHandler.d.ts +2 -2
  50. package/export/process/blocksHandler.js +13 -6
  51. package/export/process/blocksHandler.js.map +1 -1
  52. package/export/process/exporters/BlockExporter.d.ts +12 -0
  53. package/export/process/exporters/BlockExporter.js +57 -0
  54. package/export/process/exporters/BlockExporter.js.map +1 -0
  55. package/export/process/exporters/FormExporter.d.ts +9 -0
  56. package/export/process/exporters/FormExporter.js +36 -0
  57. package/export/process/exporters/FormExporter.js.map +1 -0
  58. package/export/process/exporters/PageExporter.d.ts +18 -0
  59. package/export/process/exporters/PageExporter.js +59 -0
  60. package/export/process/exporters/PageExporter.js.map +1 -0
  61. package/export/process/exporters/PageTemplateExporter.d.ts +11 -0
  62. package/export/process/exporters/PageTemplateExporter.js +58 -0
  63. package/export/process/exporters/PageTemplateExporter.js.map +1 -0
  64. package/export/process/formsHandler.d.ts +2 -2
  65. package/export/process/formsHandler.js +8 -6
  66. package/export/process/formsHandler.js.map +1 -1
  67. package/export/process/index.d.ts +2 -2
  68. package/export/process/index.js +24 -20
  69. package/export/process/index.js.map +1 -1
  70. package/export/process/templatesHandler.d.ts +2 -2
  71. package/export/process/templatesHandler.js +8 -6
  72. package/export/process/templatesHandler.js.map +1 -1
  73. package/export/s3Stream.d.ts +12 -10
  74. package/export/s3Stream.js +27 -23
  75. package/export/s3Stream.js.map +1 -1
  76. package/export/utils.d.ts +10 -15
  77. package/export/utils.js +27 -46
  78. package/export/utils.js.map +1 -1
  79. package/export/zipper.d.ts +7 -6
  80. package/export/zipper.js +18 -22
  81. package/export/zipper.js.map +1 -1
  82. package/graphql/crud/blocks.crud.d.ts +1 -1
  83. package/graphql/crud/blocks.crud.js +49 -27
  84. package/graphql/crud/blocks.crud.js.map +1 -1
  85. package/graphql/crud/forms.crud.d.ts +1 -1
  86. package/graphql/crud/forms.crud.js +51 -18
  87. package/graphql/crud/forms.crud.js.map +1 -1
  88. package/graphql/crud/importExportTasks.crud.d.ts +2 -2
  89. package/graphql/crud/importExportTasks.crud.js +144 -111
  90. package/graphql/crud/importExportTasks.crud.js.map +1 -1
  91. package/graphql/crud/pages.crud.d.ts +1 -1
  92. package/graphql/crud/pages.crud.js +238 -121
  93. package/graphql/crud/pages.crud.js.map +1 -1
  94. package/graphql/crud/templates.crud.d.ts +1 -1
  95. package/graphql/crud/templates.crud.js +48 -16
  96. package/graphql/crud/templates.crud.js.map +1 -1
  97. package/graphql/crud.d.ts +2 -2
  98. package/graphql/crud.js +3 -1
  99. package/graphql/crud.js.map +1 -1
  100. package/graphql/graphql/blocks.gql.d.ts +2 -2
  101. package/graphql/graphql/blocks.gql.js +7 -7
  102. package/graphql/graphql/blocks.gql.js.map +1 -1
  103. package/graphql/graphql/forms.gql.d.ts +2 -2
  104. package/graphql/graphql/forms.gql.js +6 -6
  105. package/graphql/graphql/forms.gql.js.map +1 -1
  106. package/graphql/graphql/importExportTasks.gql.d.ts +2 -2
  107. package/graphql/graphql/importExportTasks.gql.js +7 -7
  108. package/graphql/graphql/importExportTasks.gql.js.map +1 -1
  109. package/graphql/graphql/pages.gql.d.ts +2 -2
  110. package/graphql/graphql/pages.gql.js +103 -14
  111. package/graphql/graphql/pages.gql.js.map +1 -1
  112. package/graphql/graphql/templates.gql.d.ts +2 -2
  113. package/graphql/graphql/templates.gql.js +6 -6
  114. package/graphql/graphql/templates.gql.js.map +1 -1
  115. package/graphql/graphql/utils/resolve.d.ts +3 -3
  116. package/graphql/graphql/utils/resolve.js +16 -5
  117. package/graphql/graphql/utils/resolve.js.map +1 -1
  118. package/graphql/graphql.d.ts +1 -1
  119. package/graphql/graphql.js +3 -2
  120. package/graphql/graphql.js.map +1 -1
  121. package/graphql/index.d.ts +2 -2
  122. package/graphql/index.js +5 -2
  123. package/graphql/index.js.map +1 -1
  124. package/graphql/types.d.ts +173 -33
  125. package/graphql/types.js +3 -1
  126. package/graphql/types.js.map +1 -1
  127. package/import/constants.js +5 -6
  128. package/import/constants.js.map +1 -1
  129. package/import/create/blocksHandler.d.ts +2 -2
  130. package/import/create/blocksHandler.js +3 -3
  131. package/import/create/blocksHandler.js.map +1 -1
  132. package/import/create/formsHandler.d.ts +2 -2
  133. package/import/create/formsHandler.js +3 -1
  134. package/import/create/formsHandler.js.map +1 -1
  135. package/import/create/index.d.ts +2 -2
  136. package/import/create/index.js +24 -20
  137. package/import/create/index.js.map +1 -1
  138. package/import/create/pagesHandler.d.ts +2 -2
  139. package/import/create/pagesHandler.js +3 -1
  140. package/import/create/pagesHandler.js.map +1 -1
  141. package/import/create/templatesHandler.d.ts +2 -2
  142. package/import/create/templatesHandler.js +3 -1
  143. package/import/create/templatesHandler.js.map +1 -1
  144. package/import/pages/ImportPagesController.d.ts +5 -0
  145. package/import/pages/ImportPagesController.js +29 -0
  146. package/import/pages/ImportPagesController.js.map +1 -0
  147. package/import/pages/ImportPagesProcessPages.d.ts +6 -0
  148. package/import/pages/ImportPagesProcessPages.js +112 -0
  149. package/import/pages/ImportPagesProcessPages.js.map +1 -0
  150. package/import/pages/controller/ImportPagesProcessPagesChecker.d.ts +6 -0
  151. package/import/pages/controller/ImportPagesProcessPagesChecker.js +40 -0
  152. package/import/pages/controller/ImportPagesProcessPagesChecker.js.map +1 -0
  153. package/import/pages/controller/ImportPagesProcessZipFile.d.ts +5 -0
  154. package/import/pages/controller/ImportPagesProcessZipFile.js +71 -0
  155. package/import/pages/controller/ImportPagesProcessZipFile.js.map +1 -0
  156. package/import/{process/pages → pages/process}/importPage.d.ts +3 -4
  157. package/import/{process/pages → pages/process}/importPage.js +8 -6
  158. package/import/pages/process/importPage.js.map +1 -0
  159. package/import/pages/types.d.ts +48 -0
  160. package/import/pages/types.js +20 -0
  161. package/import/pages/types.js.map +1 -0
  162. package/import/process/blocks/ElementIdsProcessor.d.ts +5 -0
  163. package/import/process/blocks/ElementIdsProcessor.js +26 -0
  164. package/import/process/blocks/ElementIdsProcessor.js.map +1 -0
  165. package/import/process/blocks/blocksHandler.d.ts +2 -2
  166. package/import/process/blocks/blocksHandler.js +6 -6
  167. package/import/process/blocks/blocksHandler.js.map +1 -1
  168. package/import/process/blocks/importBlock.d.ts +4 -4
  169. package/import/process/blocks/importBlock.js +38 -29
  170. package/import/process/blocks/importBlock.js.map +1 -1
  171. package/import/process/forms/formsHandler.d.ts +2 -2
  172. package/import/process/forms/formsHandler.js +4 -2
  173. package/import/process/forms/formsHandler.js.map +1 -1
  174. package/import/process/forms/importForm.d.ts +2 -2
  175. package/import/process/forms/importForm.js +6 -2
  176. package/import/process/forms/importForm.js.map +1 -1
  177. package/import/process/index.d.ts +2 -2
  178. package/import/process/index.js +24 -20
  179. package/import/process/index.js.map +1 -1
  180. package/import/process/templates/importTemplate.d.ts +3 -3
  181. package/import/process/templates/importTemplate.js +6 -2
  182. package/import/process/templates/importTemplate.js.map +1 -1
  183. package/import/process/templates/templatesHandler.d.ts +2 -2
  184. package/import/process/templates/templatesHandler.js +6 -2
  185. package/import/process/templates/templatesHandler.js.map +1 -1
  186. package/import/utils/deleteS3Folder.js +3 -1
  187. package/import/utils/deleteS3Folder.js.map +1 -1
  188. package/import/utils/extractAndUploadZipFileContents.d.ts +1 -1
  189. package/import/utils/extractAndUploadZipFileContents.js +9 -5
  190. package/import/utils/extractAndUploadZipFileContents.js.map +1 -1
  191. package/import/utils/extractZipAndUploadToS3.d.ts +1 -1
  192. package/import/utils/extractZipAndUploadToS3.js +3 -1
  193. package/import/utils/extractZipAndUploadToS3.js.map +1 -1
  194. package/import/utils/getFileNameWithoutExt.js +3 -1
  195. package/import/utils/getFileNameWithoutExt.js.map +1 -1
  196. package/import/utils/index.js +3 -1
  197. package/import/utils/index.js.map +1 -1
  198. package/import/utils/initialStats.js +3 -1
  199. package/import/utils/initialStats.js.map +1 -1
  200. package/import/utils/prepareDataDirMap.d.ts +1 -1
  201. package/import/utils/prepareDataDirMap.js +3 -1
  202. package/import/utils/prepareDataDirMap.js.map +1 -1
  203. package/import/utils/updateFilesInData.d.ts +1 -1
  204. package/import/utils/updateFilesInData.js +5 -2
  205. package/import/utils/updateFilesInData.js.map +1 -1
  206. package/import/utils/uploadAssets.d.ts +3 -3
  207. package/import/utils/uploadAssets.js +56 -15
  208. package/import/utils/uploadAssets.js.map +1 -1
  209. package/import/utils/uploadFilesFromS3.d.ts +3 -3
  210. package/import/utils/uploadFilesFromS3.js +4 -2
  211. package/import/utils/uploadFilesFromS3.js.map +1 -1
  212. package/mockSecurity.d.ts +1 -1
  213. package/mockSecurity.js +3 -2
  214. package/mockSecurity.js.map +1 -1
  215. package/package.json +37 -54
  216. package/tasks/common/ChildTasksCleanup.d.ts +12 -0
  217. package/tasks/common/ChildTasksCleanup.js +64 -0
  218. package/tasks/common/ChildTasksCleanup.js.map +1 -0
  219. package/tasks/index.d.ts +1 -0
  220. package/tasks/index.js +13 -0
  221. package/tasks/index.js.map +1 -0
  222. package/tasks/pages/exportPagesCleanupTask.d.ts +3 -0
  223. package/tasks/pages/exportPagesCleanupTask.js +36 -0
  224. package/tasks/pages/exportPagesCleanupTask.js.map +1 -0
  225. package/tasks/pages/exportPagesControllerTask.d.ts +3 -0
  226. package/tasks/pages/exportPagesControllerTask.js +83 -0
  227. package/tasks/pages/exportPagesControllerTask.js.map +1 -0
  228. package/tasks/pages/exportPagesZipPagesTask.d.ts +3 -0
  229. package/tasks/pages/exportPagesZipPagesTask.js +39 -0
  230. package/tasks/pages/exportPagesZipPagesTask.js.map +1 -0
  231. package/tasks/pages/importPagesControllerTask.d.ts +3 -0
  232. package/tasks/pages/importPagesControllerTask.js +39 -0
  233. package/tasks/pages/importPagesControllerTask.js.map +1 -0
  234. package/tasks/pages/importPagesProcessPageTask.d.ts +3 -0
  235. package/tasks/pages/importPagesProcessPageTask.js +39 -0
  236. package/tasks/pages/importPagesProcessPageTask.js.map +1 -0
  237. package/tasks/pages/index.d.ts +1 -0
  238. package/tasks/pages/index.js +17 -0
  239. package/tasks/pages/index.js.map +1 -0
  240. package/types.d.ts +2 -2
  241. package/types.js +60 -8
  242. package/types.js.map +1 -1
  243. package/utils/ZipFiles.d.ts +11 -0
  244. package/utils/ZipFiles.js +124 -0
  245. package/utils/ZipFiles.js.map +1 -0
  246. package/export/combine/pagesHandler.d.ts +0 -6
  247. package/export/combine/pagesHandler.js +0 -99
  248. package/export/combine/pagesHandler.js.map +0 -1
  249. package/export/process/pagesHandler.d.ts +0 -6
  250. package/export/process/pagesHandler.js +0 -189
  251. package/export/process/pagesHandler.js.map +0 -1
  252. package/import/process/blocksHandler.d.ts +0 -3
  253. package/import/process/blocksHandler.js +0 -175
  254. package/import/process/blocksHandler.js.map +0 -1
  255. package/import/process/pages/importPage.js.map +0 -1
  256. package/import/process/pages/pagesHandler.d.ts +0 -3
  257. package/import/process/pages/pagesHandler.js +0 -183
  258. package/import/process/pages/pagesHandler.js.map +0 -1
  259. package/import/process/pagesHandler.d.ts +0 -3
  260. package/import/process/pagesHandler.js +0 -180
  261. package/import/process/pagesHandler.js.map +0 -1
  262. package/import/utils.d.ts +0 -49
  263. package/import/utils.js +0 -641
  264. package/import/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["templatesHandler","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","templateId","exportTemplatesDataKey","template","getPageTemplate","where","NotFoundError","updateSubTask","PROCESSING","updateStats","prevStatus","nextStatus","templateDataZip","exportTemplate","COMPLETED","message","key","Key","e","FAILED","name","code","invokeHandlerClient","handlers","combine","security","getIdentity","description","process"],"sources":["templatesHandler.ts"],"sourcesContent":["import { ImportExportTaskStatus, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { exportTemplate } from \"~/export/utils\";\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\";\n\n/**\n * Handles the export templates process workflow.\n */\nexport const templatesHandler = 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 Templates 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 { templateId, exportTemplatesDataKey } = input;\n\n const template = await pageBuilder.getPageTemplate({ where: { id: templateId } });\n\n if (!template) {\n log(`Unable to load template \"${templateId}\"`);\n throw new NotFoundError(`Unable to load template \"${templateId}\"`);\n }\n\n log(`Processing template key \"${templateId}\"`);\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 template data and uploading to storage...`);\n // Extract Template\n const templateDataZip = await exportTemplate(template, exportTemplatesDataKey, fileManager);\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 template \"${template.id}\"`,\n key: templateDataZip.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_TEMPLATES_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 template 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 templates - 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 template 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 templates - process - subtask\"\n });\n }\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG,OAC5BC,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,0CAA0C,CAAC;EAC/C,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,eAAO,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,K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C7C;MACA,MAAM,IAAAkC,2BAAmB,EAAiB;QACtC5C,OAAO;QACP0C,IAAI,EAAE5C,aAAa,CAAC+C,QAAQ,CAACC,OAAO;QACpC/C,OAAO,EAAE;UACLW,MAAM;UACNE,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAAC+C,QAAQ,CAACC,WAAW;QAC1C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN,CAAC,MAAM;MACH/C,OAAO,CAACD,GAAG,CAAE,8BAA6BU,YAAY,GAAG,CAAE,GAAE,CAAC;MAC9D;MACA,MAAM,IAAAiC,2BAAmB,EAAU;QAC/B5C,OAAO;QACP0C,IAAI,EAAE5C,aAAa,CAAC+C,QAAQ,CAACK,OAAO;QACpCnD,OAAO,EAAE;UACLW,MAAM;UACNC,YAAY,EAAEA,YAAY,GAAG,CAAC;UAC9BC,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAAC+C,QAAQ,CAACC,WAAW;QAC1C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN;EACJ;EACA,OAAO;IACH9B,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["_types","require","_client","_handlerGraphql","_mockSecurity","_utils","_PageTemplateExporter","templatesHandler","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","templateId","exportTemplatesDataKey","template","getPageTemplate","where","NotFoundError","updateSubTask","PROCESSING","updateStats","prevStatus","nextStatus","templateExporter","PageTemplateExporter","templateDataZip","execute","COMPLETED","message","key","Key","e","FAILED","name","code","invokeHandlerClient","handlers","combine","security","getIdentity","description","process","exports"],"sources":["templatesHandler.ts"],"sourcesContent":["import type { PbImportExportContext } from \"~/types\";\nimport { ImportExportTaskStatus } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { Payload as ExtractPayload } from \"../combine\";\nimport { mockSecurity } from \"~/mockSecurity\";\nimport type { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { zeroPad } from \"@webiny/utils\";\nimport type { Configuration, Payload, Response } from \"~/export/process\";\nimport { PageTemplateExporter } from \"~/export/process/exporters/PageTemplateExporter\";\n\n/**\n * Handles the export templates process workflow.\n */\nexport const templatesHandler = 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 Templates 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 { templateId, exportTemplatesDataKey } = input;\n\n const template = await pageBuilder.getPageTemplate({ where: { id: templateId } });\n\n if (!template) {\n log(`Unable to load template \"${templateId}\"`);\n throw new NotFoundError(`Unable to load template \"${templateId}\"`);\n }\n\n log(`Processing template key \"${templateId}\"`);\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 template data and uploading to storage...`);\n const templateExporter = new PageTemplateExporter(fileManager);\n const templateDataZip = await templateExporter.execute(template, exportTemplatesDataKey);\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 template \"${template.id}\"`,\n key: templateDataZip.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_TEMPLATES_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 template 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 templates - 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 template 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 templates - process - subtask\"\n });\n }\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;AACA,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,qBAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACO,MAAMM,gBAAgB,GAAG,MAAAA,CAC5BC,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,0CAA0C,CAAC;EAC/C,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,CAAC,uBAAuBE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C,OAAO;QACP4C,IAAI,EAAE9C,aAAa,CAACiD,QAAQ,CAACC,OAAO;QACpCjD,OAAO,EAAE;UACLW,MAAM;UACNE,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACiD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN,CAAC,MAAM;MACHjD,OAAO,CAACD,GAAG,CAAC,8BAA8BU,YAAY,GAAG,CAAC,GAAG,CAAC;MAC9D;MACA,MAAM,IAAAmC,2BAAmB,EAAU;QAC/B9C,OAAO;QACP4C,IAAI,EAAE9C,aAAa,CAACiD,QAAQ,CAACK,OAAO;QACpCrD,OAAO,EAAE;UACLW,MAAM;UACNC,YAAY,EAAEA,YAAY,GAAG,CAAC;UAC9BC,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACiD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN;EACJ;EACA,OAAO;IACHhC,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACiC,OAAA,CAAAxD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,34 +1,36 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { Readable } from "stream";
4
- import S3 from "aws-sdk/clients/s3";
3
+ /// <reference types="node" />
4
+ import type { Readable } from "stream";
5
+ import type { ListObjectsOutput, DeleteObjectOutput, HeadObjectOutput } from "@webiny/aws-sdk/client-s3";
6
+ import { S3 } from "@webiny/aws-sdk/client-s3";
7
+ export type { ListObjectsOutput };
5
8
  declare class S3Stream {
6
9
  s3: S3;
7
10
  bucket: string;
8
11
  constructor();
9
- getPresignedUrl(key: string): string;
12
+ getPresignedUrl(key?: string): Promise<string>;
10
13
  /**
11
14
  * We're checking if the file is accessible on S3 by getting object meta data.
12
15
  * It help us to filter files that we need to download as part of export data.
13
16
  * @param Key {string}
14
17
  */
15
18
  isFileAccessible(Key: string): Promise<boolean>;
16
- getObjectHead(Key: string): Promise<S3.HeadObjectOutput>;
17
- readStream(Key: string): Readable;
19
+ getObjectHead(Key: string): Promise<HeadObjectOutput>;
20
+ readStream(Key: string): Promise<Readable>;
18
21
  writeStream(Key: string, contentType?: string): {
19
22
  streamPassThrough: import("stream").PassThrough;
20
23
  /**
21
24
  * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.
22
25
  */
23
- streamPassThroughUploadPromise: Promise<S3.ManagedUpload.SendData>;
26
+ streamPassThroughUploadPromise: Promise<import("@webiny/aws-sdk/client-s3").CompleteMultipartUploadCommandOutput>;
24
27
  };
25
28
  upload(params: {
26
29
  Key: string;
27
30
  ContentType: string;
28
31
  Body: Buffer;
29
- }): Promise<S3.ManagedUpload.SendData>;
30
- listObject(prefix: string): Promise<S3.ListObjectsOutput>;
31
- deleteObject(key: string): Promise<S3.DeleteObjectOutput>;
32
+ }): Promise<void>;
33
+ listObject(prefix: string): Promise<ListObjectsOutput>;
34
+ deleteObject(key: string): Promise<DeleteObjectOutput>;
32
35
  }
33
36
  export declare const s3Stream: S3Stream;
34
- export {};
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.s3Stream = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
7
  var _stream = require("stream");
11
- var _s = _interopRequireDefault(require("aws-sdk/clients/s3"));
8
+ var _clientS = require("@webiny/aws-sdk/client-s3");
9
+ var _libStorage = require("@webiny/aws-sdk/lib-storage");
12
10
  const ARCHIVE_CONTENT_TYPE = "application/zip";
13
11
  class S3Stream {
14
12
  constructor() {
15
- (0, _defineProperty2.default)(this, "s3", void 0);
16
- (0, _defineProperty2.default)(this, "bucket", void 0);
17
- this.s3 = new _s.default({
13
+ this.s3 = new _clientS.S3({
18
14
  region: process.env.AWS_REGION
19
15
  });
20
16
  this.bucket = process.env.S3_BUCKET;
21
17
  }
22
18
  getPresignedUrl(key) {
23
- return this.s3.getSignedUrl("getObject", {
19
+ return (0, _clientS.getSignedUrl)(this.s3, new _clientS.GetObjectCommand({
24
20
  Bucket: this.bucket,
25
- Key: key,
26
- Expires: 604800 // 1 week
21
+ Key: key
22
+ }), {
23
+ expiresIn: 604800 // 1 week
27
24
  });
28
25
  }
29
26
 
@@ -46,13 +43,14 @@ class S3Stream {
46
43
  return this.s3.headObject({
47
44
  Bucket: this.bucket,
48
45
  Key
49
- }).promise();
46
+ });
50
47
  }
51
- readStream(Key) {
52
- return this.s3.getObject({
48
+ async readStream(Key) {
49
+ const response = await this.s3.send(new _clientS.GetObjectCommand({
53
50
  Bucket: this.bucket,
54
51
  Key
55
- }).createReadStream();
52
+ }));
53
+ return response.Body;
56
54
  }
57
55
  writeStream(Key, contentType = ARCHIVE_CONTENT_TYPE) {
58
56
  const streamPassThrough = new _stream.Stream.PassThrough();
@@ -63,32 +61,38 @@ class S3Stream {
63
61
  ContentType: contentType,
64
62
  Key
65
63
  };
64
+ const upload = new _libStorage.Upload({
65
+ client: this.s3,
66
+ params
67
+ });
66
68
  return {
67
69
  streamPassThrough: streamPassThrough,
68
70
  /**
69
71
  * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.
70
72
  */
71
- streamPassThroughUploadPromise: this.s3.upload(params).promise()
73
+ streamPassThroughUploadPromise: upload.done()
72
74
  };
73
75
  }
74
- upload(params) {
75
- return this.s3.upload((0, _objectSpread2.default)({
76
+ async upload(params) {
77
+ await this.s3.send(new _clientS.PutObjectCommand({
76
78
  ACL: "private",
77
- Bucket: this.bucket
78
- }, params)).promise();
79
+ Bucket: this.bucket,
80
+ ...params
81
+ }));
79
82
  }
80
83
  listObject(prefix) {
81
84
  return this.s3.listObjects({
82
85
  Bucket: this.bucket,
83
86
  Prefix: prefix
84
- }).promise();
87
+ });
85
88
  }
86
89
  deleteObject(key) {
87
90
  return this.s3.deleteObject({
88
91
  Key: key,
89
92
  Bucket: this.bucket
90
- }).promise();
93
+ });
91
94
  }
92
95
  }
93
- const s3Stream = new S3Stream();
94
- exports.s3Stream = s3Stream;
96
+ const s3Stream = exports.s3Stream = new S3Stream();
97
+
98
+ //# sourceMappingURL=s3Stream.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ARCHIVE_CONTENT_TYPE","S3Stream","constructor","s3","S3","region","process","env","AWS_REGION","bucket","S3_BUCKET","getPresignedUrl","key","getSignedUrl","Bucket","Key","Expires","isFileAccessible","getObjectHead","error","console","warn","log","headObject","promise","readStream","getObject","createReadStream","writeStream","contentType","streamPassThrough","Stream","PassThrough","params","ACL","Body","ContentType","streamPassThroughUploadPromise","upload","listObject","prefix","listObjects","Prefix","deleteObject","s3Stream"],"sources":["s3Stream.ts"],"sourcesContent":["import { Stream, Readable } from \"stream\";\nimport S3 from \"aws-sdk/clients/s3\";\n\nconst ARCHIVE_CONTENT_TYPE = \"application/zip\";\n\nclass S3Stream {\n s3: S3;\n bucket: string;\n\n constructor() {\n this.s3 = new S3({\n region: process.env.AWS_REGION as string\n });\n this.bucket = process.env.S3_BUCKET as string;\n }\n\n getPresignedUrl(key: string) {\n return this.s3.getSignedUrl(\"getObject\", {\n Bucket: this.bucket,\n Key: key,\n Expires: 604800 // 1 week\n });\n }\n\n /**\n * We're checking if the file is accessible on S3 by getting object meta data.\n * It help us to filter files that we need to download as part of export data.\n * @param Key {string}\n */\n async isFileAccessible(Key: string): Promise<boolean> {\n try {\n await this.getObjectHead(Key);\n return true;\n } catch (error) {\n console.warn(`Error while fetching meta data for file \"${Key}\"`);\n console.log(error);\n return false;\n }\n }\n\n getObjectHead(Key: string): Promise<S3.HeadObjectOutput> {\n return this.s3.headObject({ Bucket: this.bucket, Key }).promise();\n }\n\n readStream(Key: string): Readable {\n return this.s3.getObject({ Bucket: this.bucket, Key }).createReadStream();\n }\n\n writeStream(Key: string, contentType: string = ARCHIVE_CONTENT_TYPE) {\n const streamPassThrough = new Stream.PassThrough();\n\n const params: S3.PutObjectRequest = {\n ACL: \"private\",\n Body: streamPassThrough,\n Bucket: this.bucket,\n ContentType: contentType,\n Key\n };\n\n return {\n streamPassThrough: streamPassThrough,\n /**\n * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.\n */\n streamPassThroughUploadPromise: this.s3.upload(params).promise()\n };\n }\n\n upload(params: {\n Key: string;\n ContentType: string;\n Body: Buffer;\n }): Promise<S3.ManagedUpload.SendData> {\n return this.s3\n .upload({\n ACL: \"private\",\n Bucket: this.bucket,\n ...params\n })\n .promise();\n }\n\n listObject(prefix: string): Promise<S3.ListObjectsOutput> {\n return this.s3\n .listObjects({\n Bucket: this.bucket,\n Prefix: prefix\n })\n .promise();\n }\n\n deleteObject(key: string): Promise<S3.DeleteObjectOutput> {\n return this.s3.deleteObject({ Key: key, Bucket: this.bucket }).promise();\n }\n}\n\nexport const s3Stream = new S3Stream();\n"],"mappings":";;;;;;;;;AAAA;AACA;AAEA,MAAMA,oBAAoB,GAAG,iBAAiB;AAE9C,MAAMC,QAAQ,CAAC;EAIXC,WAAW,GAAG;IAAA;IAAA;IACV,IAAI,CAACC,EAAE,GAAG,IAAIC,UAAE,CAAC;MACbC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC;IACxB,CAAC,CAAC;IACF,IAAI,CAACC,MAAM,GAAGH,OAAO,CAACC,GAAG,CAACG,SAAmB;EACjD;EAEAC,eAAe,CAACC,GAAW,EAAE;IACzB,OAAO,IAAI,CAACT,EAAE,CAACU,YAAY,CAAC,WAAW,EAAE;MACrCC,MAAM,EAAE,IAAI,CAACL,MAAM;MACnBM,GAAG,EAAEH,GAAG;MACRI,OAAO,EAAE,MAAM,CAAC;IACpB,CAAC,CAAC;EACN;;EAEA;AACJ;AACA;AACA;AACA;EACI,MAAMC,gBAAgB,CAACF,GA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Ae,UAAU,CAACC,MAAc,EAAiC;IACtD,OAAO,IAAI,CAACrC,EAAE,CACTsC,WAAW,CAAC;MACT3B,MAAM,EAAE,IAAI,CAACL,MAAM;MACnBiC,MAAM,EAAEF;IACZ,CAAC,CAAC,CACDhB,OAAO,EAAE;EAClB;EAEAmB,YAAY,CAAC/B,GAAW,EAAkC;IACtD,OAAO,IAAI,CAACT,EAAE,CAACwC,YAAY,CAAC;MAAE5B,GAAG,EAAEH,GAAG;MAAEE,MAAM,EAAE,IAAI,CAACL;IAAO,CAAC,CAAC,CAACe,OAAO,EAAE;EAC5E;AACJ;AAEO,MAAMoB,QAAQ,GAAG,IAAI3C,QAAQ,EAAE;AAAC"}
1
+ {"version":3,"names":["_stream","require","_clientS","_libStorage","ARCHIVE_CONTENT_TYPE","S3Stream","constructor","s3","S3","region","process","env","AWS_REGION","bucket","S3_BUCKET","getPresignedUrl","key","getSignedUrl","GetObjectCommand","Bucket","Key","expiresIn","isFileAccessible","getObjectHead","error","console","warn","log","headObject","readStream","response","send","Body","writeStream","contentType","streamPassThrough","Stream","PassThrough","params","ACL","ContentType","upload","Upload","client","streamPassThroughUploadPromise","done","PutObjectCommand","listObject","prefix","listObjects","Prefix","deleteObject","s3Stream","exports"],"sources":["s3Stream.ts"],"sourcesContent":["import type { Readable } from \"stream\";\nimport { Stream } from \"stream\";\nimport type {\n ListObjectsOutput,\n DeleteObjectOutput,\n HeadObjectOutput,\n PutObjectCommandInput\n} from \"@webiny/aws-sdk/client-s3\";\nimport { S3, getSignedUrl, GetObjectCommand, PutObjectCommand } from \"@webiny/aws-sdk/client-s3\";\nimport { Upload } from \"@webiny/aws-sdk/lib-storage\";\n\nexport type { ListObjectsOutput };\n\nconst ARCHIVE_CONTENT_TYPE = \"application/zip\";\n\nclass S3Stream {\n s3: S3;\n bucket: string;\n\n constructor() {\n this.s3 = new S3({\n region: process.env.AWS_REGION as string\n });\n this.bucket = process.env.S3_BUCKET as string;\n }\n\n getPresignedUrl(key?: string) {\n return getSignedUrl(\n this.s3,\n new GetObjectCommand({\n Bucket: this.bucket,\n Key: key\n }),\n {\n expiresIn: 604800 // 1 week\n }\n );\n }\n\n /**\n * We're checking if the file is accessible on S3 by getting object meta data.\n * It help us to filter files that we need to download as part of export data.\n * @param Key {string}\n */\n async isFileAccessible(Key: string): Promise<boolean> {\n try {\n await this.getObjectHead(Key);\n return true;\n } catch (error) {\n console.warn(`Error while fetching meta data for file \"${Key}\"`);\n console.log(error);\n return false;\n }\n }\n\n getObjectHead(Key: string): Promise<HeadObjectOutput> {\n return this.s3.headObject({ Bucket: this.bucket, Key });\n }\n\n async readStream(Key: string): Promise<Readable> {\n const response = await this.s3.send(new GetObjectCommand({ Bucket: this.bucket, Key }));\n return response.Body as Readable;\n }\n\n writeStream(Key: string, contentType: string = ARCHIVE_CONTENT_TYPE) {\n const streamPassThrough = new Stream.PassThrough();\n\n const params: PutObjectCommandInput = {\n ACL: \"private\",\n Body: streamPassThrough,\n Bucket: this.bucket,\n ContentType: contentType,\n Key\n };\n\n const upload = new Upload({\n client: this.s3,\n params\n });\n\n return {\n streamPassThrough: streamPassThrough,\n /**\n * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.\n */\n streamPassThroughUploadPromise: upload.done()\n };\n }\n\n async upload(params: { Key: string; ContentType: string; Body: Buffer }): Promise<void> {\n await this.s3.send(\n new PutObjectCommand({\n ACL: \"private\",\n Bucket: this.bucket,\n ...params\n })\n );\n }\n\n listObject(prefix: string): Promise<ListObjectsOutput> {\n return this.s3.listObjects({\n Bucket: this.bucket,\n Prefix: prefix\n });\n }\n\n deleteObject(key: string): Promise<DeleteObjectOutput> {\n return this.s3.deleteObject({ Key: key, Bucket: this.bucket });\n }\n}\n\nexport const s3Stream = new S3Stream();\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIA,MAAMG,oBAAoB,GAAG,iBAA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,oBAAoB,EAAE;IACjE,MAAM+B,iBAAiB,GAAG,IAAIC,cAAM,CAACC,WAAW,CAAC,CAAC;IAElD,MAAMC,MAA6B,GAAG;MAClCC,GAAG,EAAE,SAAS;MACdP,IAAI,EAAEG,iBAAiB;MACvBhB,MAAM,EAAE,IAAI,CAACN,MAAM;MACnB2B,WAAW,EAAEN,WAAW;MACxBd;IACJ,CAAC;IAED,MAAMqB,MAAM,GAAG,IAAIC,kBAAM,CAAC;MACtBC,MAAM,EAAE,IAAI,CAACpC,EAAE;MACf+B;IACJ,CAAC,CAAC;IAEF,OAAO;MACHH,iBAAiB,EAAEA,iBAAiB;MACpC;AACZ;AACA;MACYS,8BAA8B,EAAEH,MAAM,CAACI,IAAI,CAAC;IAChD,CAAC;EACL;EAEA,MAAMJ,MAAMA,CAACH,MAA0D,EAAiB;IACpF,MAAM,IAAI,CAAC/B,EAAE,CAACwB,IAAI,CACd,IAAIe,yBAAgB,CAAC;MACjBP,GAAG,EAAE,SAAS;MACdpB,MAAM,EAAE,IAAI,CAACN,MAAM;MACnB,GAAGyB;IACP,CAAC,CACL,CAAC;EACL;EAEAS,UAAUA,CAACC,MAAc,EAA8B;IACnD,OAAO,IAAI,CAACzC,EAAE,CAAC0C,WAAW,CAAC;MACvB9B,MAAM,EAAE,IAAI,CAACN,MAAM;MACnBqC,MAAM,EAAEF;IACZ,CAAC,CAAC;EACN;EAEAG,YAAYA,CAACnC,GAAW,EAA+B;IACnD,OAAO,IAAI,CAACT,EAAE,CAAC4C,YAAY,CAAC;MAAE/B,GAAG,EAAEJ,GAAG;MAAEG,MAAM,EAAE,IAAI,CAACN;IAAO,CAAC,CAAC;EAClE;AACJ;AAEO,MAAMuC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,IAAI/C,QAAQ,CAAC,CAAC","ignoreList":[]}
package/export/utils.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import S3 from "aws-sdk/clients/s3";
2
- import { Page, PageBlock, PageTemplate } from "@webiny/api-page-builder/types";
3
- import { FbForm } from "@webiny/api-form-builder/types";
4
- import { FileManagerContext, File } from "@webiny/api-file-manager/types";
1
+ import type { CompleteMultipartUploadOutput } from "@webiny/aws-sdk/client-s3";
2
+ import type { BlockCategory, Page, PageBlock, PageTemplate } from "@webiny/api-page-builder/types";
3
+ import type { FileManagerContext, File } from "@webiny/api-file-manager/types";
5
4
  export declare const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
6
5
  export declare const EXPORT_BLOCKS_FOLDER_KEY = "WEBINY_PB_EXPORT_BLOCK";
7
6
  export declare const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
@@ -10,20 +9,16 @@ export interface ExportedPageData {
10
9
  page: Pick<Page, "content" | "title" | "version" | "status" | "settings" | "path">;
11
10
  files: File[];
12
11
  }
13
- export declare function exportPage(page: Page, exportPagesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<S3.ManagedUpload.SendData>;
12
+ export declare function exportPage(page: Page, exportPagesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<CompleteMultipartUploadOutput>;
14
13
  export interface ExportedBlockData {
15
- block: Pick<PageBlock, "name" | "content" | "preview">;
14
+ block: Pick<PageBlock, "name" | "content">;
15
+ category: BlockCategory;
16
16
  files: File[];
17
17
  }
18
- export declare function exportBlock(block: PageBlock, exportBlocksDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<S3.ManagedUpload.SendData>;
18
+ export declare function exportBlock(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<CompleteMultipartUploadOutput>;
19
19
  export interface ExportedTemplateData {
20
- template: Pick<PageTemplate, "title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory">;
20
+ template: Pick<PageTemplate, "title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory" | "dataSources" | "dataBindings">;
21
21
  files: File[];
22
22
  }
23
- export declare function exportTemplate(template: PageTemplate, exportTemplatesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<S3.ManagedUpload.SendData>;
24
- export declare function extractFilesFromData(data: Record<string, any>, files?: any[]): File[];
25
- export interface ExportedFormData {
26
- form: Pick<FbForm, "name" | "status" | "version" | "fields" | "layout" | "settings" | "triggers">;
27
- files: File[];
28
- }
29
- export declare function exportForm(form: FbForm, exportFormsDataKey: string): Promise<S3.ManagedUpload.SendData>;
23
+ export declare function exportTemplate(template: PageTemplate, exportTemplatesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<CompleteMultipartUploadOutput>;
24
+ export declare function extractFilesFromData(data: Record<string, any>, files?: File[]): File[];
package/export/utils.js CHANGED
@@ -6,20 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.EXPORT_TEMPLATES_FOLDER_KEY = exports.EXPORT_PAGES_FOLDER_KEY = exports.EXPORT_FORMS_FOLDER_KEY = exports.EXPORT_BLOCKS_FOLDER_KEY = void 0;
8
8
  exports.exportBlock = exportBlock;
9
- exports.exportForm = exportForm;
10
9
  exports.exportPage = exportPage;
11
10
  exports.exportTemplate = exportTemplate;
12
11
  exports.extractFilesFromData = extractFilesFromData;
13
12
  var _get = _interopRequireDefault(require("lodash/get"));
14
13
  var _zipper = _interopRequireDefault(require("./zipper"));
15
- const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
16
- exports.EXPORT_PAGES_FOLDER_KEY = EXPORT_PAGES_FOLDER_KEY;
17
- const EXPORT_BLOCKS_FOLDER_KEY = "WEBINY_PB_EXPORT_BLOCK";
18
- exports.EXPORT_BLOCKS_FOLDER_KEY = EXPORT_BLOCKS_FOLDER_KEY;
19
- const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
20
- exports.EXPORT_TEMPLATES_FOLDER_KEY = EXPORT_TEMPLATES_FOLDER_KEY;
21
- const EXPORT_FORMS_FOLDER_KEY = "WEBINY_FB_EXPORT_FORM";
22
- exports.EXPORT_FORMS_FOLDER_KEY = EXPORT_FORMS_FOLDER_KEY;
14
+ const EXPORT_PAGES_FOLDER_KEY = exports.EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
15
+ const EXPORT_BLOCKS_FOLDER_KEY = exports.EXPORT_BLOCKS_FOLDER_KEY = "WEBINY_PB_EXPORT_BLOCK";
16
+ const EXPORT_TEMPLATES_FOLDER_KEY = exports.EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
17
+ const EXPORT_FORMS_FOLDER_KEY = exports.EXPORT_FORMS_FOLDER_KEY = "WEBINY_FB_EXPORT_FORM";
23
18
  async function exportPage(page, exportPagesDataKey, fileManager) {
24
19
  // Extract all files
25
20
  const files = extractFilesFromData(page.content || {});
@@ -30,7 +25,9 @@ async function exportPage(page, exportPagesDataKey, fileManager) {
30
25
  const imageFilesData = [];
31
26
  if (fileIds.length > 0) {
32
27
  const [filesData] = await fileManager.listFiles({
33
- ids: fileIds
28
+ where: {
29
+ id_in: fileIds
30
+ }
34
31
  });
35
32
  imageFilesData.push(...filesData);
36
33
  }
@@ -58,7 +55,7 @@ async function exportPage(page, exportPagesDataKey, fileManager) {
58
55
  });
59
56
  return zipper.process();
60
57
  }
61
- async function exportBlock(block, exportBlocksDataKey, fileManager) {
58
+ async function exportBlock(block, blockCategory, exportBlocksDataKey, fileManager) {
62
59
  // Extract all files
63
60
  const files = extractFilesFromData(block.content || {});
64
61
  const fileIds = files.map(imageFile => imageFile.id);
@@ -66,21 +63,24 @@ async function exportBlock(block, exportBlocksDataKey, fileManager) {
66
63
  const imageFilesData = [];
67
64
  if (fileIds.length > 0) {
68
65
  const [filesData] = await fileManager.listFiles({
69
- ids: fileIds
66
+ where: {
67
+ id_in: fileIds
68
+ }
70
69
  });
71
70
  imageFilesData.push(...filesData);
72
71
  }
73
- // Add block preview image file data
74
- if (block.preview.id) {
75
- imageFilesData.push(await fileManager.getFile(block.preview.id));
76
- }
77
72
 
78
73
  // Extract the block data in a json file and upload it to S3
79
74
  const blockData = {
80
75
  block: {
81
76
  name: block.name,
82
- content: block.content,
83
- preview: block.preview
77
+ content: block.content
78
+ },
79
+ category: {
80
+ name: blockCategory.name,
81
+ slug: blockCategory.slug,
82
+ icon: blockCategory.icon,
83
+ description: blockCategory.description
84
84
  },
85
85
  files: imageFilesData
86
86
  };
@@ -103,7 +103,9 @@ async function exportTemplate(template, exportTemplatesDataKey, fileManager) {
103
103
  const imageFilesData = [];
104
104
  if (fileIds.length > 0) {
105
105
  const [filesData] = await fileManager.listFiles({
106
- ids: fileIds
106
+ where: {
107
+ id_in: fileIds
108
+ }
107
109
  });
108
110
  imageFilesData.push(...filesData);
109
111
  }
@@ -117,7 +119,9 @@ async function exportTemplate(template, exportTemplatesDataKey, fileManager) {
117
119
  description: template.description,
118
120
  content: template.content,
119
121
  layout: template.layout,
120
- pageCategory: template.pageCategory
122
+ pageCategory: template.pageCategory,
123
+ dataSources: template.dataSources,
124
+ dataBindings: template.dataBindings
121
125
  },
122
126
  files: imageFilesData
123
127
  };
@@ -133,10 +137,10 @@ async function exportTemplate(template, exportTemplatesDataKey, fileManager) {
133
137
  return zipper.process();
134
138
  }
135
139
  function extractFilesFromData(data, files = []) {
136
- // Base case: termination
137
140
  if (!data || typeof data !== "object") {
138
141
  return files;
139
142
  }
143
+
140
144
  // Recursively call function for each element
141
145
  if (Array.isArray(data)) {
142
146
  for (let i = 0; i < data.length; i++) {
@@ -150,7 +154,6 @@ function extractFilesFromData(data, files = []) {
150
154
  const tuple = Object.entries(data);
151
155
  for (let i = 0; i < tuple.length; i++) {
152
156
  const [key, value] = tuple[i];
153
- // TODO: @ashutosh extract it to plugins, so that, we can handle cases for other components too.
154
157
  if (key === "file" && value) {
155
158
  files.push(value);
156
159
  } else if (key === "images" && Array.isArray(value)) {
@@ -162,27 +165,5 @@ function extractFilesFromData(data, files = []) {
162
165
  }
163
166
  return files;
164
167
  }
165
- async function exportForm(form, exportFormsDataKey) {
166
- // Extract the form data in a json file and upload it to S3
167
- const formData = {
168
- form: {
169
- name: form.name,
170
- status: form.status,
171
- version: form.version,
172
- fields: form.fields,
173
- layout: form.layout,
174
- settings: form.settings,
175
- triggers: form.triggers
176
- }
177
- };
178
- const formDataBuffer = Buffer.from(JSON.stringify(formData));
179
- const zipper = new _zipper.default({
180
- exportInfo: {
181
- files: [],
182
- name: form.name,
183
- dataBuffer: formDataBuffer
184
- },
185
- archiveFileKey: exportFormsDataKey
186
- });
187
- return zipper.process();
188
- }
168
+
169
+ //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["EXPORT_PAGES_FOLDER_KEY","EXPORT_BLOCKS_FOLDER_KEY","EXPORT_TEMPLATES_FOLDER_KEY","EXPORT_FORMS_FOLDER_KEY","exportPage","page","exportPagesDataKey","fileManager","files","extractFilesFromData","content","pageSettingsImages","get","filter","image","src","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","ids","push","pageData","title","path","version","status","settings","pageDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exportBlock","block","exportBlocksDataKey","preview","getFile","blockData","blockDataBuffer","exportTemplate","template","exportTemplatesDataKey","templateData","slug","tags","description","layout","pageCategory","templateDataBuffer","data","Array","isArray","i","element","tuple","Object","entries","key","value","exportForm","form","exportFormsDataKey","formData","fields","triggers","formDataBuffer"],"sources":["utils.ts"],"sourcesContent":["import S3 from \"aws-sdk/clients/s3\";\nimport { Page, PageBlock, PageTemplate } from \"@webiny/api-page-builder/types\";\nimport { FbForm } from \"@webiny/api-form-builder/types\";\nimport { FileManagerContext, File } from \"@webiny/api-file-manager/types\";\nimport get from \"lodash/get\";\nimport Zipper from \"./zipper\";\n\nexport const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\nexport const EXPORT_BLOCKS_FOLDER_KEY = \"WEBINY_PB_EXPORT_BLOCK\";\nexport const EXPORT_TEMPLATES_FOLDER_KEY = \"WEBINY_PB_EXPORT_TEMPLATE\";\nexport const EXPORT_FORMS_FOLDER_KEY = \"WEBINY_FB_EXPORT_FORM\";\n\nexport interface ExportedPageData {\n page: Pick<Page, \"content\" | \"title\" | \"version\" | \"status\" | \"settings\" | \"path\">;\n files: File[];\n}\n\nexport async function exportPage(\n page: Page,\n exportPagesDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<S3.ManagedUpload.SendData> {\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 = [];\n if (fileIds.length > 0) {\n const [filesData] = await fileManager.listFiles({ ids: fileIds });\n imageFilesData.push(...filesData);\n }\n\n // Extract the page data in a json file and upload it to S3\n const pageData = {\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\nexport interface ExportedBlockData {\n block: Pick<PageBlock, \"name\" | \"content\" | \"preview\">;\n files: File[];\n}\n\nexport async function exportBlock(\n block: PageBlock,\n exportBlocksDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<S3.ManagedUpload.SendData> {\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 fileManager.listFiles({ ids: fileIds });\n imageFilesData.push(...filesData);\n }\n // Add block preview image file data\n if (block.preview.id) {\n imageFilesData.push(await fileManager.getFile(block.preview.id));\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 preview: block.preview\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\nexport interface ExportedTemplateData {\n template: Pick<\n PageTemplate,\n \"title\" | \"slug\" | \"tags\" | \"description\" | \"content\" | \"layout\" | \"pageCategory\"\n >;\n files: File[];\n}\n\nexport async function exportTemplate(\n template: PageTemplate,\n exportTemplatesDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<S3.ManagedUpload.SendData> {\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 fileManager.listFiles({ ids: 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\nexport function extractFilesFromData(data: Record<string, any>, files: any[] = []): File[] {\n // Base case: termination\n if (!data || typeof data !== \"object\") {\n return files;\n }\n // Recursively call function for each element\n if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n const element = data[i];\n extractFilesFromData(element, files);\n }\n return files;\n }\n\n // Main\n const tuple = Object.entries(data);\n for (let i = 0; i < tuple.length; i++) {\n const [key, value] = tuple[i];\n // TODO: @ashutosh extract it to plugins, so that, we can handle cases for other components too.\n if (key === \"file\" && value) {\n files.push(value);\n } else if (key === \"images\" && Array.isArray(value)) {\n // Handle case for \"images-list\" component\n files.push(...value);\n } else {\n extractFilesFromData(value, files);\n }\n }\n return files;\n}\n\nexport interface ExportedFormData {\n form: Pick<\n FbForm,\n \"name\" | \"status\" | \"version\" | \"fields\" | \"layout\" | \"settings\" | \"triggers\"\n >;\n files: File[];\n}\n\nexport async function exportForm(\n form: FbForm,\n exportFormsDataKey: string\n): Promise<S3.ManagedUpload.SendData> {\n // Extract the form data in a json file and upload it to S3\n const formData = {\n form: {\n name: form.name,\n status: form.status,\n version: form.version,\n fields: form.fields,\n layout: form.layout,\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"],"mappings":";;;;;;;;;;;;AAIA;AACA;AAEO,MAAMA,uBAAuB,GAAG,wBAAwB;AAAC;AACzD,MAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,MAAMC,2BAA2B,GAAG,2BAA2B;AAAC;AAChE,MAAMC,uBAAuB,GAAG,uBAAuB;AAAC;AAOxD,eAAeC,UAAU,CAC5BC,IAAU,EACVC,kBAA0B,EAC1BC,WAA8C,EACZ;EAClC;EACA,MAAMC,KAAK,GAAGC,oBAAoB,CAACJ,IAAI,CAACK,OAAO,IAAI,CAAC,CAAC,CAAC;EACtD;EACA,MAAMC,kBAAkB,GAAG,CACvB,IAAAC,YAAG,EAACP,IAAI,EAAE,wBAAwB,CAAC,EACnC,IAAAO,YAAG,EAACP,IAAI,EAAE,uBAAuB,CAAC,CACrC,CAACQ,MAAM,CAACC,KAAK,IAAIA,KAAK,IAAIA,KAAK,CAACC,GAAG,CAAC;EAErC,MAAMC,OA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Q,EAAEJ,IAAI,CAACI;IACnB;EACJ,CAAC;EACD,MAAMC,cAAc,GAAG5C,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACsC,QAAQ,CAAC,CAAC;EAE5D,MAAMrC,MAAM,GAAG,IAAIC,eAAM,CAAC;IACtBC,UAAU,EAAE;MACR/B,KAAK,EAAE,EAAE;MACTgC,IAAI,EAAEgC,IAAI,CAAChC,IAAI;MACfC,UAAU,EAAEoC;IAChB,CAAC;IACDnC,cAAc,EAAE+B;EACpB,CAAC,CAAC;EAEF,OAAOpC,MAAM,CAACM,OAAO,EAAE;AAC3B"}
1
+ {"version":3,"names":["_get","_interopRequireDefault","require","_zipper","EXPORT_PAGES_FOLDER_KEY","exports","EXPORT_BLOCKS_FOLDER_KEY","EXPORT_TEMPLATES_FOLDER_KEY","EXPORT_FORMS_FOLDER_KEY","exportPage","page","exportPagesDataKey","fileManager","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","exportBlock","block","blockCategory","exportBlocksDataKey","blockData","category","slug","icon","description","blockDataBuffer","exportTemplate","template","exportTemplatesDataKey","templateData","tags","layout","pageCategory","dataSources","dataBindings","templateDataBuffer","data","Array","isArray","i","element","tuple","Object","entries","key","value"],"sources":["utils.ts"],"sourcesContent":["import type { CompleteMultipartUploadOutput } from \"@webiny/aws-sdk/client-s3\";\nimport type {\n BlockCategory,\n Page,\n PageBlock,\n PageTemplate,\n PageTemplateInput\n} from \"@webiny/api-page-builder/types\";\nimport type { FileManagerContext, File } from \"@webiny/api-file-manager/types\";\nimport get from \"lodash/get\";\nimport Zipper from \"./zipper\";\n\nexport const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\nexport const EXPORT_BLOCKS_FOLDER_KEY = \"WEBINY_PB_EXPORT_BLOCK\";\nexport const EXPORT_TEMPLATES_FOLDER_KEY = \"WEBINY_PB_EXPORT_TEMPLATE\";\nexport const EXPORT_FORMS_FOLDER_KEY = \"WEBINY_FB_EXPORT_FORM\";\n\nexport interface ExportedPageData {\n page: Pick<Page, \"content\" | \"title\" | \"version\" | \"status\" | \"settings\" | \"path\">;\n files: File[];\n}\n\nexport async function exportPage(\n page: Page,\n exportPagesDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<CompleteMultipartUploadOutput> {\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 = [];\n if (fileIds.length > 0) {\n const [filesData] = await 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 = {\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\nexport interface ExportedBlockData {\n block: Pick<PageBlock, \"name\" | \"content\">;\n category: BlockCategory;\n files: File[];\n}\n\nexport async function exportBlock(\n block: PageBlock,\n blockCategory: BlockCategory,\n exportBlocksDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<CompleteMultipartUploadOutput> {\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 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\nexport interface ExportedTemplateData {\n template: Pick<\n PageTemplate,\n | \"title\"\n | \"slug\"\n | \"tags\"\n | \"description\"\n | \"content\"\n | \"layout\"\n | \"pageCategory\"\n | \"dataSources\"\n | \"dataBindings\"\n >;\n files: File[];\n}\n\nexport async function exportTemplate(\n template: PageTemplate,\n exportTemplatesDataKey: string,\n fileManager: FileManagerContext[\"fileManager\"]\n): Promise<CompleteMultipartUploadOutput> {\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 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: { template: PageTemplateInput; files: File[] } = {\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 dataSources: template.dataSources,\n dataBindings: template.dataBindings\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\nexport function extractFilesFromData(data: Record<string, any>, files: File[] = []) {\n if (!data || typeof data !== \"object\") {\n return files;\n }\n\n // Recursively call function for each element\n if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n const element = data[i];\n extractFilesFromData(element, files);\n }\n return files;\n }\n\n // Main\n const tuple = Object.entries(data);\n for (let i = 0; i < tuple.length; i++) {\n const [key, value] = tuple[i];\n if (key === \"file\" && value) {\n files.push(value);\n } else if (key === \"images\" && Array.isArray(value)) {\n // Handle case for \"images-list\" component\n files.push(...value);\n } else {\n extractFilesFromData(value, files);\n }\n }\n return files;\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,MAAME,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,wBAAwB;AACxD,MAAME,wBAAwB,GAAAD,OAAA,CAAAC,wBAAA,GAAG,wBAAwB;AACzD,MAAMC,2BAA2B,GAAAF,OAAA,CAAAE,2BAAA,GAAG,2BAA2B;AAC/D,MAAMC,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAG,uBAAuB;AAOvD,eAAeC,UAAUA,CAC5BC,IAAU,EACVC,kBAA0B,EAC1BC,WAA8C,EACR;EACtC;EACA,MAAMC,KAAK,GAAGC,oBAAoB,CAACJ,IAAI,CAACK,OAAO,IAAI,CAAC,CAAC,CAAC;EACtD;EACA,MAAMC,kBAAkB,GAAG,CACvB,IAAAC,YAAG,EAACP,IAAI,EAAE,wBAAwB,CAAC,EACnC,IAAAO,YAAG,EAACP,IAAI,EAAE,uBAAuB,CAAC,CACrC,CAACQ,MAAM,CAACC,KAAK,IAAIA,KAAK,IAAIA,KAAK,CAACC,GAAG,CAAC;EAErC,MAAMC,OAAO,GAAG,CAAC,GAAGR,KAAK,EAAE,GAAGG,kBAAkB,CAAC,CAACM,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC;EAChF;EACA,MAAMC,cAAc,GAAG,EAAE;EACzB,IAAIJ,OAAO,CAACK,MAAM,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AC,EAAE;IACrB,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAAC5C,MAAM,EAAE+C,CAAC,EAAE,EAAE;MAClC,MAAMC,OAAO,GAAGJ,IAAI,CAACG,CAAC,CAAC;MACvB3D,oBAAoB,CAAC4D,OAAO,EAAE7D,KAAK,CAAC;IACxC;IACA,OAAOA,KAAK;EAChB;;EAEA;EACA,MAAM8D,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACP,IAAI,CAAC;EAClC,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGE,KAAK,CAACjD,MAAM,EAAE+C,CAAC,EAAE,EAAE;IACnC,MAAM,CAACK,GAAG,EAAEC,KAAK,CAAC,GAAGJ,KAAK,CAACF,CAAC,CAAC;IAC7B,IAAIK,GAAG,KAAK,MAAM,IAAIC,KAAK,EAAE;MACzBlE,KAAK,CAACkB,IAAI,CAACgD,KAAK,CAAC;IACrB,CAAC,MAAM,IAAID,GAAG,KAAK,QAAQ,IAAIP,KAAK,CAACC,OAAO,CAACO,KAAK,CAAC,EAAE;MACjD;MACAlE,KAAK,CAACkB,IAAI,CAAC,GAAGgD,KAAK,CAAC;IACxB,CAAC,MAAM;MACHjE,oBAAoB,CAACiE,KAAK,EAAElE,KAAK,CAAC;IACtC;EACJ;EACA,OAAOA,KAAK;AAChB","ignoreList":[]}
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import S3 from "aws-sdk/clients/s3";
3
+ /// <reference types="node" />
4
+ import type { CompleteMultipartUploadOutput } from "@webiny/aws-sdk/client-s3";
4
5
  import { Readable } from "stream";
5
- import { File } from "@webiny/api-file-manager/types";
6
+ import type { File } from "@webiny/api-file-manager/types";
6
7
  interface FileStreamDetails {
7
8
  stream: Readable;
8
9
  filename: string;
@@ -22,8 +23,8 @@ export default class Zipper {
22
23
  private readonly archiveFileName;
23
24
  config: ZipperConfig;
24
25
  constructor(config: ZipperConfig);
25
- s3DownloadStreams(): FileStreamDetails[];
26
- process(): Promise<S3.ManagedUpload.SendData>;
26
+ s3DownloadStreams(): Promise<FileStreamDetails[]>;
27
+ process(): Promise<CompleteMultipartUploadOutput>;
27
28
  }
28
29
  export declare class ZipOfZip {
29
30
  private readonly archiveFormat;
@@ -31,7 +32,7 @@ export declare class ZipOfZip {
31
32
  keys: string[];
32
33
  filename: string;
33
34
  constructor(keys: string[], filename: string);
34
- getFileStreams(): FileStreamDetails[];
35
- process(): Promise<S3.ManagedUpload.SendData>;
35
+ getFileStreams(): Promise<FileStreamDetails[]>;
36
+ process(): Promise<CompleteMultipartUploadOutput>;
36
37
  }
37
38
  export {};
package/export/zipper.js CHANGED
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = exports.ZipOfZip = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _archiver = _interopRequireDefault(require("archiver"));
11
10
  var _stream = require("stream");
12
11
  var path = _interopRequireWildcard(require("path"));
@@ -16,38 +15,36 @@ var _s3Stream = require("./s3Stream");
16
15
  // TODO: Move "archive" in layer
17
16
 
18
17
  class Zipper {
18
+ archiveFormat = "zip";
19
+ filesDirName = "assets";
19
20
  constructor(config) {
20
- (0, _defineProperty2.default)(this, "archiveFormat", "zip");
21
- (0, _defineProperty2.default)(this, "filesDirName", "assets");
22
- (0, _defineProperty2.default)(this, "archiveFileName", void 0);
23
- (0, _defineProperty2.default)(this, "config", void 0);
24
21
  this.config = config;
25
22
  this.archiveFileName = (0, _uniqid.default)(`${this.config.archiveFileKey}/`, `-${(0, _kebabCase.default)(this.config.exportInfo.name)}.zip`);
26
23
  }
27
- s3DownloadStreams() {
24
+ async s3DownloadStreams() {
28
25
  const exportInfo = this.config.exportInfo;
29
26
  const prefix = (0, _uniqid.default)("", `-${(0, _kebabCase.default)(exportInfo.name)}`);
30
- const files = exportInfo.files.map(({
27
+ const files = await Promise.all(exportInfo.files.map(async ({
31
28
  key
32
29
  }) => {
33
30
  return {
34
- stream: _s3Stream.s3Stream.readStream(key),
31
+ stream: await _s3Stream.s3Stream.readStream(key),
35
32
  filename: `${prefix}\\${this.filesDirName}\\${key}`
36
33
  };
37
- });
34
+ }));
38
35
  return [...files, {
39
36
  stream: _stream.Readable.from(exportInfo.dataBuffer),
40
37
  filename: `${prefix}\\${exportInfo.name}.json`
41
38
  }];
42
39
  }
43
- process() {
40
+ async process() {
44
41
  const {
45
42
  streamPassThrough,
46
43
  streamPassThroughUploadPromise
47
44
  } = _s3Stream.s3Stream.writeStream(this.archiveFileName);
48
45
 
49
46
  // 1. Read all files from S3 using stream.
50
- const s3FilesStreams = this.s3DownloadStreams();
47
+ const s3FilesStreams = await this.s3DownloadStreams();
51
48
 
52
49
  // 2. Prepare zip from the file stream.
53
50
  const archive = _archiver.default.create(this.archiveFormat);
@@ -73,31 +70,28 @@ class Zipper {
73
70
  }
74
71
  exports.default = Zipper;
75
72
  class ZipOfZip {
73
+ archiveFormat = "zip";
76
74
  constructor(keys, filename) {
77
- (0, _defineProperty2.default)(this, "archiveFormat", "zip");
78
- (0, _defineProperty2.default)(this, "archiveFileName", void 0);
79
- (0, _defineProperty2.default)(this, "keys", void 0);
80
- (0, _defineProperty2.default)(this, "filename", void 0);
81
75
  this.keys = keys;
82
76
  this.filename = filename;
83
77
  this.archiveFileName = (0, _uniqid.default)("EXPORTS/", `-${filename}`);
84
78
  }
85
- getFileStreams() {
86
- return this.keys.map(key => {
79
+ async getFileStreams() {
80
+ return await Promise.all(this.keys.map(async key => {
87
81
  return {
88
- stream: _s3Stream.s3Stream.readStream(key),
82
+ stream: await _s3Stream.s3Stream.readStream(key),
89
83
  filename: `${path.basename(key)}`
90
84
  };
91
- });
85
+ }));
92
86
  }
93
- process() {
87
+ async process() {
94
88
  const {
95
89
  streamPassThrough,
96
90
  streamPassThroughUploadPromise
97
91
  } = _s3Stream.s3Stream.writeStream(this.archiveFileName);
98
92
 
99
93
  // 1. Read all files from S3 using stream.
100
- const fileStreamDetails = this.getFileStreams();
94
+ const fileStreamDetails = await this.getFileStreams();
101
95
 
102
96
  // 2. Prepare zip from the file stream.
103
97
  const archive = _archiver.default.create(this.archiveFormat);
@@ -121,4 +115,6 @@ class ZipOfZip {
121
115
  return streamPassThroughUploadPromise;
122
116
  }
123
117
  }
124
- exports.ZipOfZip = ZipOfZip;
118
+ exports.ZipOfZip = ZipOfZip;
119
+
120
+ //# sourceMappingURL=zipper.js.map