@webiny/api-page-builder-import-export 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2696f9d9e8

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 (201) hide show
  1. package/client.d.ts +2 -2
  2. package/client.js +12 -25
  3. package/client.js.map +1 -1
  4. package/export/combine/blocksHandler.d.ts +6 -0
  5. package/export/combine/blocksHandler.js +101 -0
  6. package/export/combine/blocksHandler.js.map +1 -0
  7. package/export/combine/formsHandler.d.ts +6 -0
  8. package/export/combine/formsHandler.js +101 -0
  9. package/export/combine/formsHandler.js.map +1 -0
  10. package/{exportPages → export}/combine/index.d.ts +3 -2
  11. package/export/combine/index.js +44 -0
  12. package/export/combine/index.js.map +1 -0
  13. package/export/combine/pagesHandler.d.ts +6 -0
  14. package/export/combine/pagesHandler.js +101 -0
  15. package/export/combine/pagesHandler.js.map +1 -0
  16. package/export/combine/templatesHandler.d.ts +6 -0
  17. package/export/combine/templatesHandler.js +101 -0
  18. package/export/combine/templatesHandler.js.map +1 -0
  19. package/export/process/blocksHandler.d.ts +6 -0
  20. package/export/process/blocksHandler.js +169 -0
  21. package/export/process/blocksHandler.js.map +1 -0
  22. package/export/process/exporters/BlockExporter.d.ts +12 -0
  23. package/export/process/exporters/BlockExporter.js +57 -0
  24. package/export/process/exporters/BlockExporter.js.map +1 -0
  25. package/export/process/exporters/FormExporter.d.ts +9 -0
  26. package/export/process/exporters/FormExporter.js +36 -0
  27. package/export/process/exporters/FormExporter.js.map +1 -0
  28. package/export/process/exporters/PageExporter.d.ts +11 -0
  29. package/export/process/exporters/PageExporter.js +58 -0
  30. package/export/process/exporters/PageExporter.js.map +1 -0
  31. package/export/process/exporters/PageTemplateExporter.d.ts +11 -0
  32. package/export/process/exporters/PageTemplateExporter.js +56 -0
  33. package/export/process/exporters/PageTemplateExporter.js.map +1 -0
  34. package/export/process/formsHandler.d.ts +6 -0
  35. package/export/process/formsHandler.js +189 -0
  36. package/export/process/formsHandler.js.map +1 -0
  37. package/{exportPages → export}/process/index.d.ts +4 -6
  38. package/export/process/index.js +41 -0
  39. package/export/process/index.js.map +1 -0
  40. package/export/process/pagesHandler.d.ts +6 -0
  41. package/export/process/pagesHandler.js +191 -0
  42. package/export/process/pagesHandler.js.map +1 -0
  43. package/export/process/templatesHandler.d.ts +6 -0
  44. package/export/process/templatesHandler.js +168 -0
  45. package/export/process/templatesHandler.js.map +1 -0
  46. package/export/s3Stream.d.ts +34 -0
  47. package/{exportPages → export}/s3Stream.js +28 -42
  48. package/export/s3Stream.js.map +1 -0
  49. package/export/utils.d.ts +24 -0
  50. package/export/utils.js +171 -0
  51. package/export/utils.js.map +1 -0
  52. package/{exportPages → export}/zipper.d.ts +11 -10
  53. package/export/zipper.js +120 -0
  54. package/export/zipper.js.map +1 -0
  55. package/graphql/crud/blocks.crud.d.ts +4 -0
  56. package/graphql/crud/blocks.crud.js +159 -0
  57. package/graphql/crud/blocks.crud.js.map +1 -0
  58. package/graphql/crud/forms.crud.d.ts +4 -0
  59. package/graphql/crud/forms.crud.js +163 -0
  60. package/graphql/crud/forms.crud.js.map +1 -0
  61. package/graphql/crud/importExportTasks.crud.d.ts +5 -0
  62. package/graphql/crud/{pageImportExportTasks.crud.js → importExportTasks.crud.js} +121 -151
  63. package/graphql/crud/importExportTasks.crud.js.map +1 -0
  64. package/graphql/crud/pages.crud.d.ts +3 -2
  65. package/graphql/crud/pages.crud.js +89 -69
  66. package/graphql/crud/pages.crud.js.map +1 -1
  67. package/graphql/crud/templates.crud.d.ts +4 -0
  68. package/graphql/crud/templates.crud.js +157 -0
  69. package/graphql/crud/templates.crud.js.map +1 -0
  70. package/graphql/crud.d.ts +2 -2
  71. package/graphql/crud.js +7 -7
  72. package/graphql/crud.js.map +1 -1
  73. package/graphql/graphql/blocks.gql.d.ts +4 -0
  74. package/graphql/graphql/blocks.gql.js +54 -0
  75. package/graphql/graphql/blocks.gql.js.map +1 -0
  76. package/graphql/graphql/forms.gql.d.ts +4 -0
  77. package/graphql/graphql/forms.gql.js +62 -0
  78. package/graphql/graphql/forms.gql.js.map +1 -0
  79. package/graphql/graphql/importExportTasks.gql.d.ts +4 -0
  80. package/graphql/graphql/{pageImportExportTasks.gql.js → importExportTasks.gql.js} +21 -24
  81. package/graphql/graphql/importExportTasks.gql.js.map +1 -0
  82. package/graphql/graphql/pages.gql.d.ts +2 -2
  83. package/graphql/graphql/pages.gql.js +7 -16
  84. package/graphql/graphql/pages.gql.js.map +1 -1
  85. package/graphql/graphql/templates.gql.d.ts +4 -0
  86. package/graphql/graphql/templates.gql.js +54 -0
  87. package/graphql/graphql/templates.gql.js.map +1 -0
  88. package/graphql/graphql/utils/resolve.d.ts +1 -1
  89. package/graphql/graphql/utils/resolve.js +2 -3
  90. package/graphql/graphql/utils/resolve.js.map +1 -1
  91. package/graphql/graphql.js +7 -6
  92. package/graphql/graphql.js.map +1 -1
  93. package/graphql/index.d.ts +2 -2
  94. package/graphql/index.js +2 -5
  95. package/graphql/index.js.map +1 -1
  96. package/graphql/types.d.ts +195 -23
  97. package/graphql/types.js +3 -1
  98. package/graphql/types.js.map +1 -1
  99. package/import/constants.d.ts +3 -0
  100. package/import/constants.js +16 -0
  101. package/import/constants.js.map +1 -0
  102. package/import/create/blocksHandler.d.ts +3 -0
  103. package/import/create/blocksHandler.js +101 -0
  104. package/import/create/blocksHandler.js.map +1 -0
  105. package/import/create/formsHandler.d.ts +3 -0
  106. package/import/create/formsHandler.js +105 -0
  107. package/import/create/formsHandler.js.map +1 -0
  108. package/{importPages → import}/create/index.d.ts +7 -5
  109. package/import/create/index.js +44 -0
  110. package/import/create/index.js.map +1 -0
  111. package/import/create/pagesHandler.d.ts +3 -0
  112. package/import/create/pagesHandler.js +105 -0
  113. package/import/create/pagesHandler.js.map +1 -0
  114. package/import/create/templatesHandler.d.ts +3 -0
  115. package/import/create/templatesHandler.js +101 -0
  116. package/import/create/templatesHandler.js.map +1 -0
  117. package/import/process/blocks/blocksHandler.d.ts +3 -0
  118. package/import/process/blocks/blocksHandler.js +169 -0
  119. package/import/process/blocks/blocksHandler.js.map +1 -0
  120. package/import/process/blocks/importBlock.d.ts +11 -0
  121. package/import/process/blocks/importBlock.js +98 -0
  122. package/import/process/blocks/importBlock.js.map +1 -0
  123. package/import/process/forms/formsHandler.d.ts +3 -0
  124. package/import/process/forms/formsHandler.js +178 -0
  125. package/import/process/forms/formsHandler.js.map +1 -0
  126. package/import/process/forms/importForm.d.ts +9 -0
  127. package/import/process/forms/importForm.js +47 -0
  128. package/import/process/forms/importForm.js.map +1 -0
  129. package/{importPages → import}/process/index.d.ts +5 -3
  130. package/import/process/index.js +41 -0
  131. package/import/process/index.js.map +1 -0
  132. package/import/process/pages/importPage.d.ts +11 -0
  133. package/import/process/pages/importPage.js +94 -0
  134. package/import/process/pages/importPage.js.map +1 -0
  135. package/import/process/pages/pagesHandler.d.ts +3 -0
  136. package/import/process/pages/pagesHandler.js +185 -0
  137. package/import/process/pages/pagesHandler.js.map +1 -0
  138. package/import/process/templates/importTemplate.d.ts +11 -0
  139. package/import/process/templates/importTemplate.js +70 -0
  140. package/import/process/templates/importTemplate.js.map +1 -0
  141. package/import/process/templates/templatesHandler.d.ts +3 -0
  142. package/import/process/templates/templatesHandler.js +172 -0
  143. package/import/process/templates/templatesHandler.js.map +1 -0
  144. package/import/utils/deleteS3Folder.d.ts +1 -0
  145. package/import/utils/deleteS3Folder.js +21 -0
  146. package/import/utils/deleteS3Folder.js.map +1 -0
  147. package/import/utils/extractAndUploadZipFileContents.d.ts +7 -0
  148. package/import/utils/extractAndUploadZipFileContents.js +123 -0
  149. package/import/utils/extractAndUploadZipFileContents.js.map +1 -0
  150. package/import/utils/extractZipAndUploadToS3.d.ts +2 -0
  151. package/import/utils/extractZipAndUploadToS3.js +100 -0
  152. package/import/utils/extractZipAndUploadToS3.js.map +1 -0
  153. package/import/utils/getFileNameWithoutExt.d.ts +1 -0
  154. package/import/utils/getFileNameWithoutExt.js +13 -0
  155. package/import/utils/getFileNameWithoutExt.js.map +1 -0
  156. package/import/utils/index.d.ts +9 -0
  157. package/import/utils/index.js +106 -0
  158. package/import/utils/index.js.map +1 -0
  159. package/import/utils/initialStats.d.ts +7 -0
  160. package/import/utils/initialStats.js +18 -0
  161. package/import/utils/initialStats.js.map +1 -0
  162. package/import/utils/prepareDataDirMap.d.ts +6 -0
  163. package/import/utils/prepareDataDirMap.js +31 -0
  164. package/import/utils/prepareDataDirMap.js.map +1 -0
  165. package/import/utils/updateFilesInData.d.ts +8 -0
  166. package/import/utils/updateFilesInData.js +51 -0
  167. package/import/utils/updateFilesInData.js.map +1 -0
  168. package/import/utils/uploadAssets.d.ts +10 -0
  169. package/import/utils/uploadAssets.js +92 -0
  170. package/import/utils/uploadAssets.js.map +1 -0
  171. package/import/utils/uploadFilesFromS3.d.ts +3 -0
  172. package/import/utils/uploadFilesFromS3.js +21 -0
  173. package/import/utils/uploadFilesFromS3.js.map +1 -0
  174. package/mockSecurity.js +2 -3
  175. package/mockSecurity.js.map +1 -1
  176. package/package.json +36 -44
  177. package/types.d.ts +83 -65
  178. package/types.js +70 -21
  179. package/types.js.map +1 -1
  180. package/exportPages/combine/index.js +0 -114
  181. package/exportPages/combine/index.js.map +0 -1
  182. package/exportPages/process/index.js +0 -208
  183. package/exportPages/process/index.js.map +0 -1
  184. package/exportPages/s3Stream.d.ts +0 -31
  185. package/exportPages/s3Stream.js.map +0 -1
  186. package/exportPages/utils.d.ts +0 -13
  187. package/exportPages/utils.js +0 -113
  188. package/exportPages/utils.js.map +0 -1
  189. package/exportPages/zipper.js +0 -135
  190. package/exportPages/zipper.js.map +0 -1
  191. package/graphql/crud/pageImportExportTasks.crud.d.ts +0 -5
  192. package/graphql/crud/pageImportExportTasks.crud.js.map +0 -1
  193. package/graphql/graphql/pageImportExportTasks.gql.d.ts +0 -4
  194. package/graphql/graphql/pageImportExportTasks.gql.js.map +0 -1
  195. package/importPages/create/index.js +0 -118
  196. package/importPages/create/index.js.map +0 -1
  197. package/importPages/process/index.js +0 -185
  198. package/importPages/process/index.js.map +0 -1
  199. package/importPages/utils.d.ts +0 -50
  200. package/importPages/utils.js +0 -570
  201. package/importPages/utils.js.map +0 -1
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.templatesHandler = void 0;
7
+ var _types = require("../../types");
8
+ var _client = require("../../client");
9
+ var _handlerGraphql = require("@webiny/handler-graphql");
10
+ var _mockSecurity = require("../../mockSecurity");
11
+ var _utils = require("@webiny/utils");
12
+ var _PageTemplateExporter = require("./exporters/PageTemplateExporter");
13
+ /**
14
+ * Handles the export templates process workflow.
15
+ */
16
+ const templatesHandler = async (configuration, payload, context) => {
17
+ const log = console.log;
18
+ let subTask;
19
+ let noPendingTask = true;
20
+ let prevStatusOfSubTask = _types.ImportExportTaskStatus.PENDING;
21
+ log("RUNNING Export Templates Process Handler");
22
+ const {
23
+ pageBuilder,
24
+ fileManager
25
+ } = context;
26
+ const {
27
+ taskId,
28
+ subTaskIndex,
29
+ type,
30
+ identity
31
+ } = payload;
32
+ // Disable authorization; this is necessary because we call Page Builder CRUD methods which include authorization checks
33
+ // and this Lambda is invoked internally, without credentials.
34
+ (0, _mockSecurity.mockSecurity)(identity, context);
35
+ try {
36
+ /*
37
+ * Note: We're not going to DB for finding the next sub-task to process,
38
+ * because the data might be out of sync due to GSI eventual consistency.
39
+ */
40
+ subTask = await pageBuilder.importExportTask.getSubTask(taskId, (0, _utils.zeroPad)(subTaskIndex, 5));
41
+ /**
42
+ * Base condition!!
43
+ * Bail out early, if task not found or task's status is not "pending".
44
+ */
45
+ if (!subTask || subTask.status !== _types.ImportExportTaskStatus.PENDING) {
46
+ noPendingTask = true;
47
+ return {
48
+ data: "",
49
+ error: null
50
+ };
51
+ } else {
52
+ noPendingTask = false;
53
+ }
54
+ log(`Fetched sub task => ${subTask.id}`);
55
+ const {
56
+ input
57
+ } = subTask;
58
+ const {
59
+ templateId,
60
+ exportTemplatesDataKey
61
+ } = input;
62
+ const template = await pageBuilder.getPageTemplate({
63
+ where: {
64
+ id: templateId
65
+ }
66
+ });
67
+ if (!template) {
68
+ log(`Unable to load template "${templateId}"`);
69
+ throw new _handlerGraphql.NotFoundError(`Unable to load template "${templateId}"`);
70
+ }
71
+ log(`Processing template key "${templateId}"`);
72
+
73
+ // Mark task status as PROCESSING
74
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
75
+ status: _types.ImportExportTaskStatus.PROCESSING
76
+ });
77
+ // Update stats in main task
78
+ await pageBuilder.importExportTask.updateStats(taskId, {
79
+ prevStatus: prevStatusOfSubTask,
80
+ nextStatus: _types.ImportExportTaskStatus.PROCESSING
81
+ });
82
+ prevStatusOfSubTask = subTask.status;
83
+ log(`Extracting template data and uploading to storage...`);
84
+ const templateExporter = new _PageTemplateExporter.PageTemplateExporter(fileManager);
85
+ const templateDataZip = await templateExporter.execute(template, exportTemplatesDataKey);
86
+ log(`Finish uploading zip...`);
87
+ // Update task record in DB
88
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
89
+ status: _types.ImportExportTaskStatus.COMPLETED,
90
+ data: {
91
+ message: `Finish uploading data for template "${template.id}"`,
92
+ key: templateDataZip.Key
93
+ }
94
+ });
95
+ // Update stats in main task
96
+ await pageBuilder.importExportTask.updateStats(taskId, {
97
+ prevStatus: prevStatusOfSubTask,
98
+ nextStatus: _types.ImportExportTaskStatus.COMPLETED
99
+ });
100
+ prevStatusOfSubTask = subTask.status;
101
+ } catch (e) {
102
+ log("[EXPORT_TEMPLATES_PROCESS] Error => ", e.message);
103
+ if (subTask && subTask.id) {
104
+ /**
105
+ * In case of error, we'll update the task status to "failed",
106
+ * so that, client can show notify the user appropriately.
107
+ */
108
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
109
+ status: _types.ImportExportTaskStatus.FAILED,
110
+ error: {
111
+ name: e.name,
112
+ message: e.message,
113
+ code: "EXPORT_FAILED"
114
+ }
115
+ });
116
+
117
+ // Update stats in main task
118
+ await pageBuilder.importExportTask.updateStats(taskId, {
119
+ prevStatus: prevStatusOfSubTask,
120
+ nextStatus: _types.ImportExportTaskStatus.FAILED
121
+ });
122
+ prevStatusOfSubTask = subTask.status;
123
+ }
124
+ return {
125
+ data: null,
126
+ error: {
127
+ message: e.message
128
+ }
129
+ };
130
+ } finally {
131
+ // Base condition!
132
+ if (noPendingTask) {
133
+ log(`No pending sub-task for task ${taskId}`);
134
+ // Combine individual template zip files.
135
+ await (0, _client.invokeHandlerClient)({
136
+ context,
137
+ name: configuration.handlers.combine,
138
+ payload: {
139
+ taskId,
140
+ type,
141
+ identity: context.security.getIdentity()
142
+ },
143
+ description: "Export templates - combine"
144
+ });
145
+ } else {
146
+ console.log(`Invoking PROCESS for task "${subTaskIndex + 1}"`);
147
+ // We want to continue with Self invocation no matter if current template error out.
148
+ await (0, _client.invokeHandlerClient)({
149
+ context,
150
+ name: configuration.handlers.process,
151
+ payload: {
152
+ taskId,
153
+ subTaskIndex: subTaskIndex + 1,
154
+ type,
155
+ identity: context.security.getIdentity()
156
+ },
157
+ description: "Export templates - process - subtask"
158
+ });
159
+ }
160
+ }
161
+ return {
162
+ data: "",
163
+ error: null
164
+ };
165
+ };
166
+ exports.templatesHandler = templatesHandler;
167
+
168
+ //# sourceMappingURL=templatesHandler.js.map
@@ -0,0 +1 @@
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 { 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 { 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":";;;;;;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,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;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SAAS;IACN;IACA,IAAInC,aAAa,EAAE;MACfH,GAAG,CAAE,gCAA+BS,MAAO,EAAC,CAAC;MAC7C;MACA,MAAM,IAAAoC,2BAAmB,EAAiB;QACtC9C,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,CAAE,8BAA6BU,YAAY,GAAG,CAAE,GAAE,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"}
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Readable } from "stream";
4
+ import { S3, ListObjectsOutput, DeleteObjectOutput, HeadObjectOutput } from "@webiny/aws-sdk/client-s3";
5
+ declare class S3Stream {
6
+ s3: S3;
7
+ bucket: string;
8
+ constructor();
9
+ getPresignedUrl(key?: string): Promise<string>;
10
+ /**
11
+ * We're checking if the file is accessible on S3 by getting object meta data.
12
+ * It help us to filter files that we need to download as part of export data.
13
+ * @param Key {string}
14
+ */
15
+ isFileAccessible(Key: string): Promise<boolean>;
16
+ getObjectHead(Key: string): Promise<HeadObjectOutput>;
17
+ readStream(Key: string): Promise<Readable>;
18
+ writeStream(Key: string, contentType?: string): {
19
+ streamPassThrough: import("stream").PassThrough;
20
+ /**
21
+ * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.
22
+ */
23
+ streamPassThroughUploadPromise: Promise<import("@aws-sdk/client-s3").AbortMultipartUploadCommandOutput | import("@webiny/aws-sdk/client-s3").CompleteMultipartUploadCommandOutput>;
24
+ };
25
+ upload(params: {
26
+ Key: string;
27
+ ContentType: string;
28
+ Body: Buffer;
29
+ }): Promise<void>;
30
+ listObject(prefix: string): Promise<ListObjectsOutput>;
31
+ deleteObject(key: string): Promise<DeleteObjectOutput>;
32
+ }
33
+ export declare const s3Stream: S3Stream;
34
+ export {};
@@ -1,47 +1,34 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.s3Stream = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
7
  var _stream = require("stream");
15
-
16
- var _s = _interopRequireDefault(require("aws-sdk/clients/s3"));
17
-
8
+ var _clientS = require("@webiny/aws-sdk/client-s3");
9
+ var _libStorage = require("@webiny/aws-sdk/lib-storage");
18
10
  const ARCHIVE_CONTENT_TYPE = "application/zip";
19
-
20
11
  class S3Stream {
21
12
  constructor() {
22
- (0, _defineProperty2.default)(this, "s3", void 0);
23
- (0, _defineProperty2.default)(this, "bucket", void 0);
24
- this.s3 = new _s.default({
13
+ this.s3 = new _clientS.S3({
25
14
  region: process.env.AWS_REGION
26
15
  });
27
16
  this.bucket = process.env.S3_BUCKET;
28
17
  }
29
-
30
18
  getPresignedUrl(key) {
31
- return this.s3.getSignedUrl("getObject", {
19
+ return (0, _clientS.getSignedUrl)(this.s3, new _clientS.GetObjectCommand({
32
20
  Bucket: this.bucket,
33
- Key: key,
34
- Expires: 604800 // 1 week
35
-
21
+ Key: key
22
+ }), {
23
+ expiresIn: 604800 // 1 week
36
24
  });
37
25
  }
26
+
38
27
  /**
39
28
  * We're checking if the file is accessible on S3 by getting object meta data.
40
29
  * It help us to filter files that we need to download as part of export data.
41
30
  * @param Key {string}
42
31
  */
43
-
44
-
45
32
  async isFileAccessible(Key) {
46
33
  try {
47
34
  await this.getObjectHead(Key);
@@ -52,21 +39,19 @@ class S3Stream {
52
39
  return false;
53
40
  }
54
41
  }
55
-
56
42
  getObjectHead(Key) {
57
43
  return this.s3.headObject({
58
44
  Bucket: this.bucket,
59
45
  Key
60
- }).promise();
46
+ });
61
47
  }
62
-
63
- readStream(Key) {
64
- return this.s3.getObject({
48
+ async readStream(Key) {
49
+ const response = await this.s3.send(new _clientS.GetObjectCommand({
65
50
  Bucket: this.bucket,
66
51
  Key
67
- }).createReadStream();
52
+ }));
53
+ return response.Body;
68
54
  }
69
-
70
55
  writeStream(Key, contentType = ARCHIVE_CONTENT_TYPE) {
71
56
  const streamPassThrough = new _stream.Stream.PassThrough();
72
57
  const params = {
@@ -76,38 +61,39 @@ class S3Stream {
76
61
  ContentType: contentType,
77
62
  Key
78
63
  };
64
+ const upload = new _libStorage.Upload({
65
+ client: this.s3,
66
+ params
67
+ });
79
68
  return {
80
69
  streamPassThrough: streamPassThrough,
81
-
82
70
  /**
83
71
  * We're not using the `FileManager` storage plugin here because it currently doesn't support streams.
84
72
  */
85
- streamPassThroughUploadPromise: this.s3.upload(params).promise()
73
+ streamPassThroughUploadPromise: upload.done()
86
74
  };
87
75
  }
88
-
89
- upload(params) {
90
- return this.s3.upload((0, _objectSpread2.default)({
76
+ async upload(params) {
77
+ await this.s3.send(new _clientS.PutObjectCommand({
91
78
  ACL: "private",
92
- Bucket: this.bucket
93
- }, params)).promise();
79
+ Bucket: this.bucket,
80
+ ...params
81
+ }));
94
82
  }
95
-
96
83
  listObject(prefix) {
97
84
  return this.s3.listObjects({
98
85
  Bucket: this.bucket,
99
86
  Prefix: prefix
100
- }).promise();
87
+ });
101
88
  }
102
-
103
89
  deleteObject(key) {
104
90
  return this.s3.deleteObject({
105
91
  Key: key,
106
92
  Bucket: this.bucket
107
- }).promise();
93
+ });
108
94
  }
109
-
110
95
  }
111
-
112
96
  const s3Stream = new S3Stream();
113
- exports.s3Stream = s3Stream;
97
+ exports.s3Stream = s3Stream;
98
+
99
+ //# sourceMappingURL=s3Stream.js.map
@@ -0,0 +1 @@
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 { Stream, Readable } from \"stream\";\nimport {\n S3,\n ListObjectsOutput,\n DeleteObjectOutput,\n HeadObjectOutput,\n getSignedUrl,\n GetObjectCommand,\n PutObjectCommand,\n PutObjectCommandInput\n} from \"@webiny/aws-sdk/client-s3\";\nimport { Upload } from \"@webiny/aws-sdk/lib-storage\";\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":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAUA,IAAAE,WAAA,GAAAF,OAAA;AAEA,MAAMG,oBAAoB,GAAG,iBAAiB;AAE9C,MAAMC,QAAQ,CAAC;EAIXC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,EAAE,GAAG,IAAIC,WAAE,CAAC;MACbC,MAAM,EAAEC,OA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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,GAAG,IAAI/C,QAAQ,CAAC,CAAC;AAACgD,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,24 @@
1
+ import { CompleteMultipartUploadOutput } from "@webiny/aws-sdk/client-s3";
2
+ import { BlockCategory, Page, PageBlock, PageTemplate } from "@webiny/api-page-builder/types";
3
+ import { FileManagerContext, File } from "@webiny/api-file-manager/types";
4
+ export declare const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
5
+ export declare const EXPORT_BLOCKS_FOLDER_KEY = "WEBINY_PB_EXPORT_BLOCK";
6
+ export declare const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
7
+ export declare const EXPORT_FORMS_FOLDER_KEY = "WEBINY_FB_EXPORT_FORM";
8
+ export interface ExportedPageData {
9
+ page: Pick<Page, "content" | "title" | "version" | "status" | "settings" | "path">;
10
+ files: File[];
11
+ }
12
+ export declare function exportPage(page: Page, exportPagesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<CompleteMultipartUploadOutput>;
13
+ export interface ExportedBlockData {
14
+ block: Pick<PageBlock, "name" | "content">;
15
+ category: BlockCategory;
16
+ files: File[];
17
+ }
18
+ export declare function exportBlock(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<CompleteMultipartUploadOutput>;
19
+ export interface ExportedTemplateData {
20
+ template: Pick<PageTemplate, "title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory">;
21
+ files: File[];
22
+ }
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[];
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.EXPORT_TEMPLATES_FOLDER_KEY = exports.EXPORT_PAGES_FOLDER_KEY = exports.EXPORT_FORMS_FOLDER_KEY = exports.EXPORT_BLOCKS_FOLDER_KEY = void 0;
8
+ exports.exportBlock = exportBlock;
9
+ exports.exportPage = exportPage;
10
+ exports.exportTemplate = exportTemplate;
11
+ exports.extractFilesFromData = extractFilesFromData;
12
+ var _get = _interopRequireDefault(require("lodash/get"));
13
+ var _zipper = _interopRequireDefault(require("./zipper"));
14
+ const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
15
+ exports.EXPORT_PAGES_FOLDER_KEY = EXPORT_PAGES_FOLDER_KEY;
16
+ const EXPORT_BLOCKS_FOLDER_KEY = "WEBINY_PB_EXPORT_BLOCK";
17
+ exports.EXPORT_BLOCKS_FOLDER_KEY = EXPORT_BLOCKS_FOLDER_KEY;
18
+ const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
19
+ exports.EXPORT_TEMPLATES_FOLDER_KEY = EXPORT_TEMPLATES_FOLDER_KEY;
20
+ const EXPORT_FORMS_FOLDER_KEY = "WEBINY_FB_EXPORT_FORM";
21
+ exports.EXPORT_FORMS_FOLDER_KEY = EXPORT_FORMS_FOLDER_KEY;
22
+ async function exportPage(page, exportPagesDataKey, fileManager) {
23
+ // Extract all files
24
+ const files = extractFilesFromData(page.content || {});
25
+ // Extract images from page settings
26
+ const pageSettingsImages = [(0, _get.default)(page, "settings.general.image"), (0, _get.default)(page, "settings.social.image")].filter(image => image && image.src);
27
+ const fileIds = [...files, ...pageSettingsImages].map(imageFile => imageFile.id);
28
+ // Get file data for all images
29
+ const imageFilesData = [];
30
+ if (fileIds.length > 0) {
31
+ const [filesData] = await fileManager.listFiles({
32
+ where: {
33
+ id_in: fileIds
34
+ }
35
+ });
36
+ imageFilesData.push(...filesData);
37
+ }
38
+
39
+ // Extract the page data in a json file and upload it to S3
40
+ const pageData = {
41
+ page: {
42
+ content: page.content,
43
+ title: page.title,
44
+ path: page.path,
45
+ version: page.version,
46
+ status: page.status,
47
+ settings: page.settings
48
+ },
49
+ files: imageFilesData
50
+ };
51
+ const pageDataBuffer = Buffer.from(JSON.stringify(pageData));
52
+ const zipper = new _zipper.default({
53
+ exportInfo: {
54
+ files: imageFilesData,
55
+ name: page.title,
56
+ dataBuffer: pageDataBuffer
57
+ },
58
+ archiveFileKey: exportPagesDataKey
59
+ });
60
+ return zipper.process();
61
+ }
62
+ async function exportBlock(block, blockCategory, exportBlocksDataKey, fileManager) {
63
+ // Extract all files
64
+ const files = extractFilesFromData(block.content || {});
65
+ const fileIds = files.map(imageFile => imageFile.id);
66
+ // Get file data for all images
67
+ const imageFilesData = [];
68
+ if (fileIds.length > 0) {
69
+ const [filesData] = await fileManager.listFiles({
70
+ where: {
71
+ id_in: fileIds
72
+ }
73
+ });
74
+ imageFilesData.push(...filesData);
75
+ }
76
+
77
+ // Extract the block data in a json file and upload it to S3
78
+ const blockData = {
79
+ block: {
80
+ name: block.name,
81
+ content: block.content
82
+ },
83
+ category: {
84
+ name: blockCategory.name,
85
+ slug: blockCategory.slug,
86
+ icon: blockCategory.icon,
87
+ description: blockCategory.description
88
+ },
89
+ files: imageFilesData
90
+ };
91
+ const blockDataBuffer = Buffer.from(JSON.stringify(blockData));
92
+ const zipper = new _zipper.default({
93
+ exportInfo: {
94
+ files: imageFilesData,
95
+ name: block.name,
96
+ dataBuffer: blockDataBuffer
97
+ },
98
+ archiveFileKey: exportBlocksDataKey
99
+ });
100
+ return zipper.process();
101
+ }
102
+ async function exportTemplate(template, exportTemplatesDataKey, fileManager) {
103
+ // Extract all files
104
+ const files = extractFilesFromData(template.content || {});
105
+ const fileIds = files.map(imageFile => imageFile.id);
106
+ // Get file data for all images
107
+ const imageFilesData = [];
108
+ if (fileIds.length > 0) {
109
+ const [filesData] = await fileManager.listFiles({
110
+ where: {
111
+ id_in: fileIds
112
+ }
113
+ });
114
+ imageFilesData.push(...filesData);
115
+ }
116
+
117
+ // Extract the template data in a json file and upload it to S3
118
+ const templateData = {
119
+ template: {
120
+ title: template.title,
121
+ slug: template.slug,
122
+ tags: template.tags,
123
+ description: template.description,
124
+ content: template.content,
125
+ layout: template.layout,
126
+ pageCategory: template.pageCategory
127
+ },
128
+ files: imageFilesData
129
+ };
130
+ const templateDataBuffer = Buffer.from(JSON.stringify(templateData));
131
+ const zipper = new _zipper.default({
132
+ exportInfo: {
133
+ files: imageFilesData,
134
+ name: template.title,
135
+ dataBuffer: templateDataBuffer
136
+ },
137
+ archiveFileKey: exportTemplatesDataKey
138
+ });
139
+ return zipper.process();
140
+ }
141
+ function extractFilesFromData(data, files = []) {
142
+ if (!data || typeof data !== "object") {
143
+ return files;
144
+ }
145
+
146
+ // Recursively call function for each element
147
+ if (Array.isArray(data)) {
148
+ for (let i = 0; i < data.length; i++) {
149
+ const element = data[i];
150
+ extractFilesFromData(element, files);
151
+ }
152
+ return files;
153
+ }
154
+
155
+ // Main
156
+ const tuple = Object.entries(data);
157
+ for (let i = 0; i < tuple.length; i++) {
158
+ const [key, value] = tuple[i];
159
+ if (key === "file" && value) {
160
+ files.push(value);
161
+ } else if (key === "images" && Array.isArray(value)) {
162
+ // Handle case for "images-list" component
163
+ files.push(...value);
164
+ } else {
165
+ extractFilesFromData(value, files);
166
+ }
167
+ }
168
+ return files;
169
+ }
170
+
171
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
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","templateDataBuffer","data","Array","isArray","i","element","tuple","Object","entries","key","value"],"sources":["utils.ts"],"sourcesContent":["import { CompleteMultipartUploadOutput } from \"@webiny/aws-sdk/client-s3\";\nimport { BlockCategory, Page, PageBlock, PageTemplate } from \"@webiny/api-page-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<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\" | \"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<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 = {\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: 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":";;;;;;;;;;;AAGA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEO,MAAME,uBAAuB,GAAG,wBAAwB;AAACC,OAAA,CAAAD,uBAAA,GAAAA,uBAAA;AACzD,MAAME,wBAAwB,GAAG,wBAAwB;AAACD,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAC1D,MAAMC,2BAA2B,GAAG,2BAA2B;AAACF,OAAA,CAAAE,2BAAA,GAAAA,2BAAA;AAChE,MAAMC,uBAAuB,GAAG,uBAAuB;AAACH,OAAA,CAAAG,uBAAA,GAAAA,uBAAA;AAOxD,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,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wD,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC,EAAE;IACrB,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,CAAC1C,MAAM,EAAE6C,CAAC,EAAE,EAAE;MAClC,MAAMC,OAAO,GAAGJ,IAAI,CAACG,CAAC,CAAC;MACvBzD,oBAAoB,CAAC0D,OAAO,EAAE3D,KAAK,CAAC;IACxC;IACA,OAAOA,KAAK;EAChB;;EAEA;EACA,MAAM4D,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACP,IAAI,CAAC;EAClC,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGE,KAAK,CAAC/C,MAAM,EAAE6C,CAAC,EAAE,EAAE;IACnC,MAAM,CAACK,GAAG,EAAEC,KAAK,CAAC,GAAGJ,KAAK,CAACF,CAAC,CAAC;IAC7B,IAAIK,GAAG,KAAK,MAAM,IAAIC,KAAK,EAAE;MACzBhE,KAAK,CAACkB,IAAI,CAAC8C,KAAK,CAAC;IACrB,CAAC,MAAM,IAAID,GAAG,KAAK,QAAQ,IAAIP,KAAK,CAACC,OAAO,CAACO,KAAK,CAAC,EAAE;MACjD;MACAhE,KAAK,CAACkB,IAAI,CAAC,GAAG8C,KAAK,CAAC;IACxB,CAAC,MAAM;MACH/D,oBAAoB,CAAC+D,KAAK,EAAEhE,KAAK,CAAC;IACtC;EACJ;EACA,OAAOA,KAAK;AAChB"}
@@ -1,16 +1,16 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import S3 from "aws-sdk/clients/s3";
3
+ import { CompleteMultipartUploadOutput } from "@webiny/aws-sdk/client-s3";
4
4
  import { Readable } from "stream";
5
- import { ImageFile } from "./utils";
5
+ import { File } from "@webiny/api-file-manager/types";
6
6
  interface FileStreamDetails {
7
7
  stream: Readable;
8
8
  filename: string;
9
9
  }
10
10
  interface ExportInfo {
11
- files: ImageFile[];
12
- pageTitle: string;
13
- pageDataBuffer: Buffer;
11
+ files: File[];
12
+ name: string;
13
+ dataBuffer: Buffer;
14
14
  }
15
15
  export interface ZipperConfig {
16
16
  exportInfo: ExportInfo;
@@ -22,15 +22,16 @@ export default class Zipper {
22
22
  private readonly archiveFileName;
23
23
  config: ZipperConfig;
24
24
  constructor(config: ZipperConfig);
25
- s3DownloadStreams(): FileStreamDetails[];
26
- process(): Promise<S3.ManagedUpload.SendData>;
25
+ s3DownloadStreams(): Promise<FileStreamDetails[]>;
26
+ process(): Promise<CompleteMultipartUploadOutput>;
27
27
  }
28
28
  export declare class ZipOfZip {
29
29
  private readonly archiveFormat;
30
30
  private readonly archiveFileName;
31
31
  keys: string[];
32
- constructor(keys: string[]);
33
- getFileStreams(): FileStreamDetails[];
34
- process(): Promise<S3.ManagedUpload.SendData>;
32
+ filename: string;
33
+ constructor(keys: string[], filename: string);
34
+ getFileStreams(): Promise<FileStreamDetails[]>;
35
+ process(): Promise<CompleteMultipartUploadOutput>;
35
36
  }
36
37
  export {};