@webiny/api-page-builder-import-export 0.0.0-unstable.40876133bb → 0.0.0-unstable.461c047ab7

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 (275) 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 +4 -3
  11. package/export/combine/index.js +44 -0
  12. package/export/combine/index.js.map +1 -0
  13. package/export/combine/templatesHandler.d.ts +6 -0
  14. package/export/combine/templatesHandler.js +101 -0
  15. package/export/combine/templatesHandler.js.map +1 -0
  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 +6 -0
  50. package/export/process/blocksHandler.js +169 -0
  51. package/export/process/blocksHandler.js.map +1 -0
  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 +6 -0
  65. package/export/process/formsHandler.js +189 -0
  66. package/export/process/formsHandler.js.map +1 -0
  67. package/{exportPages → export}/process/index.d.ts +5 -7
  68. package/export/process/index.js +41 -0
  69. package/export/process/index.js.map +1 -0
  70. package/export/process/templatesHandler.d.ts +6 -0
  71. package/export/process/templatesHandler.js +168 -0
  72. package/export/process/templatesHandler.js.map +1 -0
  73. package/export/s3Stream.d.ts +36 -0
  74. package/{exportPages → export}/s3Stream.js +27 -42
  75. package/export/s3Stream.js.map +1 -0
  76. package/export/utils.d.ts +24 -0
  77. package/export/utils.js +169 -0
  78. package/export/utils.js.map +1 -0
  79. package/{exportPages → export}/zipper.d.ts +12 -10
  80. package/export/zipper.js +120 -0
  81. package/export/zipper.js.map +1 -0
  82. package/graphql/crud/blocks.crud.d.ts +4 -0
  83. package/graphql/crud/blocks.crud.js +158 -0
  84. package/graphql/crud/blocks.crud.js.map +1 -0
  85. package/graphql/crud/forms.crud.d.ts +4 -0
  86. package/graphql/crud/forms.crud.js +162 -0
  87. package/graphql/crud/forms.crud.js.map +1 -0
  88. package/graphql/crud/importExportTasks.crud.d.ts +5 -0
  89. package/graphql/crud/importExportTasks.crud.js +396 -0
  90. package/graphql/crud/importExportTasks.crud.js.map +1 -0
  91. package/graphql/crud/pages.crud.d.ts +2 -2
  92. package/graphql/crud/pages.crud.js +241 -138
  93. package/graphql/crud/pages.crud.js.map +1 -1
  94. package/graphql/crud/templates.crud.d.ts +4 -0
  95. package/graphql/crud/templates.crud.js +156 -0
  96. package/graphql/crud/templates.crud.js.map +1 -0
  97. package/graphql/crud.d.ts +2 -2
  98. package/graphql/crud.js +7 -7
  99. package/graphql/crud.js.map +1 -1
  100. package/graphql/graphql/blocks.gql.d.ts +4 -0
  101. package/graphql/graphql/blocks.gql.js +52 -0
  102. package/graphql/graphql/blocks.gql.js.map +1 -0
  103. package/graphql/graphql/forms.gql.d.ts +4 -0
  104. package/graphql/graphql/forms.gql.js +60 -0
  105. package/graphql/graphql/forms.gql.js.map +1 -0
  106. package/graphql/graphql/importExportTasks.gql.d.ts +4 -0
  107. package/graphql/graphql/importExportTasks.gql.js +75 -0
  108. package/graphql/graphql/importExportTasks.gql.js.map +1 -0
  109. package/graphql/graphql/pages.gql.d.ts +3 -3
  110. package/graphql/graphql/pages.gql.js +104 -26
  111. package/graphql/graphql/pages.gql.js.map +1 -1
  112. package/graphql/graphql/templates.gql.d.ts +4 -0
  113. package/graphql/graphql/templates.gql.js +52 -0
  114. package/graphql/graphql/templates.gql.js.map +1 -0
  115. package/graphql/graphql/utils/resolve.d.ts +3 -3
  116. package/graphql/graphql/utils/resolve.js +15 -7
  117. package/graphql/graphql/utils/resolve.js.map +1 -1
  118. package/graphql/graphql.d.ts +1 -1
  119. package/graphql/graphql.js +6 -6
  120. package/graphql/graphql.js.map +1 -1
  121. package/graphql/index.d.ts +2 -2
  122. package/graphql/index.js +4 -6
  123. package/graphql/index.js.map +1 -1
  124. package/graphql/types.d.ts +237 -37
  125. package/graphql/types.js +3 -1
  126. package/graphql/types.js.map +1 -1
  127. package/import/constants.d.ts +3 -0
  128. package/import/constants.js +13 -0
  129. package/import/constants.js.map +1 -0
  130. package/import/create/blocksHandler.d.ts +3 -0
  131. package/import/create/blocksHandler.js +101 -0
  132. package/import/create/blocksHandler.js.map +1 -0
  133. package/import/create/formsHandler.d.ts +3 -0
  134. package/import/create/formsHandler.js +105 -0
  135. package/import/create/formsHandler.js.map +1 -0
  136. package/import/create/index.d.ts +24 -0
  137. package/import/create/index.js +44 -0
  138. package/import/create/index.js.map +1 -0
  139. package/import/create/pagesHandler.d.ts +3 -0
  140. package/import/create/pagesHandler.js +105 -0
  141. package/import/create/pagesHandler.js.map +1 -0
  142. package/import/create/templatesHandler.d.ts +3 -0
  143. package/import/create/templatesHandler.js +101 -0
  144. package/import/create/templatesHandler.js.map +1 -0
  145. package/import/pages/ImportPagesController.d.ts +5 -0
  146. package/import/pages/ImportPagesController.js +29 -0
  147. package/import/pages/ImportPagesController.js.map +1 -0
  148. package/import/pages/ImportPagesProcessPages.d.ts +6 -0
  149. package/import/pages/ImportPagesProcessPages.js +112 -0
  150. package/import/pages/ImportPagesProcessPages.js.map +1 -0
  151. package/import/pages/controller/ImportPagesProcessPagesChecker.d.ts +6 -0
  152. package/import/pages/controller/ImportPagesProcessPagesChecker.js +40 -0
  153. package/import/pages/controller/ImportPagesProcessPagesChecker.js.map +1 -0
  154. package/import/pages/controller/ImportPagesProcessZipFile.d.ts +5 -0
  155. package/import/pages/controller/ImportPagesProcessZipFile.js +71 -0
  156. package/import/pages/controller/ImportPagesProcessZipFile.js.map +1 -0
  157. package/import/pages/process/importPage.d.ts +10 -0
  158. package/import/pages/process/importPage.js +94 -0
  159. package/import/pages/process/importPage.js.map +1 -0
  160. package/import/pages/types.d.ts +48 -0
  161. package/import/pages/types.js +20 -0
  162. package/import/pages/types.js.map +1 -0
  163. package/import/process/blocks/ElementIdsProcessor.d.ts +5 -0
  164. package/import/process/blocks/ElementIdsProcessor.js +26 -0
  165. package/import/process/blocks/ElementIdsProcessor.js.map +1 -0
  166. package/import/process/blocks/blocksHandler.d.ts +3 -0
  167. package/import/process/blocks/blocksHandler.js +169 -0
  168. package/import/process/blocks/blocksHandler.js.map +1 -0
  169. package/import/process/blocks/importBlock.d.ts +11 -0
  170. package/import/process/blocks/importBlock.js +101 -0
  171. package/import/process/blocks/importBlock.js.map +1 -0
  172. package/import/process/forms/formsHandler.d.ts +3 -0
  173. package/import/process/forms/formsHandler.js +178 -0
  174. package/import/process/forms/formsHandler.js.map +1 -0
  175. package/import/process/forms/importForm.d.ts +9 -0
  176. package/import/process/forms/importForm.js +47 -0
  177. package/import/process/forms/importForm.js.map +1 -0
  178. package/{importPages → import}/process/index.d.ts +6 -4
  179. package/import/process/index.js +41 -0
  180. package/import/process/index.js.map +1 -0
  181. package/import/process/templates/importTemplate.d.ts +11 -0
  182. package/import/process/templates/importTemplate.js +70 -0
  183. package/import/process/templates/importTemplate.js.map +1 -0
  184. package/import/process/templates/templatesHandler.d.ts +3 -0
  185. package/import/process/templates/templatesHandler.js +174 -0
  186. package/import/process/templates/templatesHandler.js.map +1 -0
  187. package/import/utils/deleteS3Folder.d.ts +1 -0
  188. package/import/utils/deleteS3Folder.js +21 -0
  189. package/import/utils/deleteS3Folder.js.map +1 -0
  190. package/import/utils/extractAndUploadZipFileContents.d.ts +7 -0
  191. package/import/utils/extractAndUploadZipFileContents.js +126 -0
  192. package/import/utils/extractAndUploadZipFileContents.js.map +1 -0
  193. package/import/utils/extractZipAndUploadToS3.d.ts +2 -0
  194. package/import/utils/extractZipAndUploadToS3.js +100 -0
  195. package/import/utils/extractZipAndUploadToS3.js.map +1 -0
  196. package/import/utils/getFileNameWithoutExt.d.ts +1 -0
  197. package/import/utils/getFileNameWithoutExt.js +13 -0
  198. package/import/utils/getFileNameWithoutExt.js.map +1 -0
  199. package/import/utils/index.d.ts +9 -0
  200. package/import/utils/index.js +106 -0
  201. package/import/utils/index.js.map +1 -0
  202. package/import/utils/initialStats.d.ts +7 -0
  203. package/import/utils/initialStats.js +18 -0
  204. package/import/utils/initialStats.js.map +1 -0
  205. package/import/utils/prepareDataDirMap.d.ts +6 -0
  206. package/import/utils/prepareDataDirMap.js +31 -0
  207. package/import/utils/prepareDataDirMap.js.map +1 -0
  208. package/import/utils/updateFilesInData.d.ts +8 -0
  209. package/import/utils/updateFilesInData.js +51 -0
  210. package/import/utils/updateFilesInData.js.map +1 -0
  211. package/import/utils/uploadAssets.d.ts +10 -0
  212. package/import/utils/uploadAssets.js +92 -0
  213. package/import/utils/uploadAssets.js.map +1 -0
  214. package/import/utils/uploadFilesFromS3.d.ts +3 -0
  215. package/import/utils/uploadFilesFromS3.js +21 -0
  216. package/import/utils/uploadFilesFromS3.js.map +1 -0
  217. package/mockSecurity.d.ts +1 -1
  218. package/mockSecurity.js +2 -3
  219. package/mockSecurity.js.map +1 -1
  220. package/package.json +36 -52
  221. package/tasks/common/ChildTasksCleanup.d.ts +12 -0
  222. package/tasks/common/ChildTasksCleanup.js +64 -0
  223. package/tasks/common/ChildTasksCleanup.js.map +1 -0
  224. package/tasks/index.d.ts +1 -0
  225. package/tasks/index.js +13 -0
  226. package/tasks/index.js.map +1 -0
  227. package/tasks/pages/exportPagesCleanupTask.d.ts +3 -0
  228. package/tasks/pages/exportPagesCleanupTask.js +36 -0
  229. package/tasks/pages/exportPagesCleanupTask.js.map +1 -0
  230. package/tasks/pages/exportPagesControllerTask.d.ts +3 -0
  231. package/tasks/pages/exportPagesControllerTask.js +83 -0
  232. package/tasks/pages/exportPagesControllerTask.js.map +1 -0
  233. package/tasks/pages/exportPagesZipPagesTask.d.ts +3 -0
  234. package/tasks/pages/exportPagesZipPagesTask.js +39 -0
  235. package/tasks/pages/exportPagesZipPagesTask.js.map +1 -0
  236. package/tasks/pages/importPagesControllerTask.d.ts +3 -0
  237. package/tasks/pages/importPagesControllerTask.js +39 -0
  238. package/tasks/pages/importPagesControllerTask.js.map +1 -0
  239. package/tasks/pages/importPagesProcessPageTask.d.ts +3 -0
  240. package/tasks/pages/importPagesProcessPageTask.js +39 -0
  241. package/tasks/pages/importPagesProcessPageTask.js.map +1 -0
  242. package/tasks/pages/index.d.ts +1 -0
  243. package/tasks/pages/index.js +17 -0
  244. package/tasks/pages/index.js.map +1 -0
  245. package/types.d.ts +83 -65
  246. package/types.js +68 -21
  247. package/types.js.map +1 -1
  248. package/utils/ZipFiles.d.ts +11 -0
  249. package/utils/ZipFiles.js +124 -0
  250. package/utils/ZipFiles.js.map +1 -0
  251. package/exportPages/combine/index.js +0 -114
  252. package/exportPages/combine/index.js.map +0 -1
  253. package/exportPages/process/index.js +0 -208
  254. package/exportPages/process/index.js.map +0 -1
  255. package/exportPages/s3Stream.d.ts +0 -31
  256. package/exportPages/s3Stream.js.map +0 -1
  257. package/exportPages/utils.d.ts +0 -13
  258. package/exportPages/utils.js +0 -113
  259. package/exportPages/utils.js.map +0 -1
  260. package/exportPages/zipper.js +0 -135
  261. package/exportPages/zipper.js.map +0 -1
  262. package/graphql/crud/pageImportExportTasks.crud.d.ts +0 -5
  263. package/graphql/crud/pageImportExportTasks.crud.js +0 -411
  264. package/graphql/crud/pageImportExportTasks.crud.js.map +0 -1
  265. package/graphql/graphql/pageImportExportTasks.gql.d.ts +0 -4
  266. package/graphql/graphql/pageImportExportTasks.gql.js +0 -80
  267. package/graphql/graphql/pageImportExportTasks.gql.js.map +0 -1
  268. package/importPages/create/index.d.ts +0 -22
  269. package/importPages/create/index.js +0 -118
  270. package/importPages/create/index.js.map +0 -1
  271. package/importPages/process/index.js +0 -185
  272. package/importPages/process/index.js.map +0 -1
  273. package/importPages/utils.d.ts +0 -50
  274. package/importPages/utils.js +0 -570
  275. package/importPages/utils.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ZipPagesDataManager = void 0;
7
+ class ZipPagesDataManager {
8
+ constructor(input) {
9
+ this.input = input;
10
+ this.queue = new Set(input.queue);
11
+ this.done = {
12
+ ...input.done
13
+ };
14
+ this.failed = new Set(input.failed || []);
15
+ }
16
+ hasMore() {
17
+ return this.queue.size > 0;
18
+ }
19
+ addDone(pageId, key) {
20
+ this.queue.delete(pageId);
21
+ this.failed.delete(pageId);
22
+ this.done[pageId] = key;
23
+ }
24
+ addFailed(pageId) {
25
+ this.queue.delete(pageId);
26
+ this.failed.add(pageId);
27
+ delete this.done[pageId];
28
+ }
29
+ getFailed() {
30
+ return Array.from(this.failed);
31
+ }
32
+ getDone() {
33
+ return this.done;
34
+ }
35
+ getInput() {
36
+ return {
37
+ ...this.input,
38
+ queue: Array.from(this.queue),
39
+ failed: Array.from(this.failed),
40
+ done: this.done
41
+ };
42
+ }
43
+ }
44
+ exports.ZipPagesDataManager = ZipPagesDataManager;
45
+
46
+ //# sourceMappingURL=ZipPagesDataManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ZipPagesDataManager","constructor","input","queue","Set","done","failed","hasMore","size","addDone","pageId","key","delete","addFailed","add","getFailed","Array","from","getDone","getInput","exports"],"sources":["ZipPagesDataManager.ts"],"sourcesContent":["import type { IExportPagesZipPagesDone, IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport class ZipPagesDataManager {\n private readonly input: IExportPagesZipPagesInput;\n private readonly queue: Set<string>;\n private readonly done: IExportPagesZipPagesDone;\n private readonly failed: Set<string>;\n\n public constructor(input: IExportPagesZipPagesInput) {\n this.input = input;\n this.queue = new Set(input.queue);\n this.done = {\n ...input.done\n };\n this.failed = new Set(input.failed || []);\n }\n\n public hasMore(): boolean {\n return this.queue.size > 0;\n }\n\n public addDone(pageId: string, key: string): void {\n this.queue.delete(pageId);\n this.failed.delete(pageId);\n this.done[pageId] = key;\n }\n\n public addFailed(pageId: string): void {\n this.queue.delete(pageId);\n this.failed.add(pageId);\n delete this.done[pageId];\n }\n\n public getFailed() {\n return Array.from(this.failed);\n }\n\n public getDone() {\n return this.done;\n }\n\n public getInput(): IExportPagesZipPagesInput {\n return {\n ...this.input,\n queue: Array.from(this.queue),\n failed: Array.from(this.failed),\n done: this.done\n };\n }\n}\n"],"mappings":";;;;;;AAEO,MAAMA,mBAAmB,CAAC;EAMtBC,WAAWA,CAACC,KAAgC,EAAE;IACjD,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,KAAK,GAAG,IAAIC,GAAG,CAACF,KAAK,CAACC,KAAK,CAAC;IACjC,IAAI,CAACE,IAAI,GAAG;MACR,GAAGH,KAAK,CAACG;IACb,CAAC;IACD,IAAI,CAACC,MAAM,GAAG,IAAIF,GAAG,CAACF,KAAK,CAACI,MAAM,IAAI,EAAE,CAAC;EAC7C;EAEOC,OAAOA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACJ,KAAK,CAACK,IAAI,GAAG,CAAC;EAC9B;EAEOC,OAAOA,CAACC,MAAc,EAAEC,GAAW,EAAQ;IAC9C,IAAI,CAACR,KAAK,CAACS,MAAM,CAACF,MAAM,CAAC;IACzB,IAAI,CAACJ,MAAM,CAACM,MAAM,CAACF,MAAM,CAAC;IAC1B,IAAI,CAACL,IAAI,CAACK,MAAM,CAAC,GAAGC,GAAG;EAC3B;EAEOE,SAASA,CAACH,MAAc,EAAQ;IACnC,IAAI,CAACP,KAAK,CAACS,MAAM,CAACF,MAAM,CAAC;IACzB,IAAI,CAACJ,MAAM,CAACQ,GAAG,CAACJ,MAAM,CAAC;IACvB,OAAO,IAAI,CAACL,IAAI,CAACK,MAAM,CAAC;EAC5B;EAEOK,SAASA,CAAA,EAAG;IACf,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACX,MAAM,CAAC;EAClC;EAEOY,OAAOA,CAAA,EAAG;IACb,OAAO,IAAI,CAACb,IAAI;EACpB;EAEOc,QAAQA,CAAA,EAA8B;IACzC,OAAO;MACH,GAAG,IAAI,CAACjB,KAAK;MACbC,KAAK,EAAEa,KAAK,CAACC,IAAI,CAAC,IAAI,CAACd,KAAK,CAAC;MAC7BG,MAAM,EAAEU,KAAK,CAACC,IAAI,CAAC,IAAI,CAACX,MAAM,CAAC;MAC/BD,IAAI,EAAE,IAAI,CAACA;IACf,CAAC;EACL;AACJ;AAACe,OAAA,CAAApB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { PbImportExportContext } from "../../../graphql/types";
2
+ import type { ITaskManagerStore } from "@webiny/tasks";
3
+ import type { IExportPagesZipPagesInput } from "../types";
4
+ export declare const getPageFactory: (context: PbImportExportContext, store: ITaskManagerStore<IExportPagesZipPagesInput>, published: boolean) => (pageId: string) => Promise<import("@webiny/api-page-builder/types").Page<Record<string, any> | null> | null>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPageFactory = void 0;
7
+ const getPageFactory = (context, store, published) => {
8
+ return async pageId => {
9
+ if (published) {
10
+ try {
11
+ return await context.pageBuilder.getPublishedPageById({
12
+ id: pageId
13
+ });
14
+ } catch (ex) {
15
+ /**
16
+ * We do not need to do anything on exception because we will fetch the latest version.
17
+ */
18
+ }
19
+ }
20
+ try {
21
+ return await context.pageBuilder.getPage(pageId);
22
+ } catch (ex) {
23
+ const message = `There is no page with ID ${pageId}.`;
24
+ try {
25
+ await store.addErrorLog({
26
+ message,
27
+ error: ex
28
+ });
29
+ } catch {
30
+ console.error(`Failed to add error log: "${message}"`);
31
+ }
32
+ return null;
33
+ }
34
+ };
35
+ };
36
+ exports.getPageFactory = getPageFactory;
37
+
38
+ //# sourceMappingURL=getPageFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPageFactory","context","store","published","pageId","pageBuilder","getPublishedPageById","id","ex","getPage","message","addErrorLog","error","console","exports"],"sources":["getPageFactory.ts"],"sourcesContent":["import type { PbImportExportContext } from \"~/graphql/types\";\nimport type { ITaskManagerStore } from \"@webiny/tasks\";\nimport type { IExportPagesZipPagesInput } from \"~/export/pages/types\";\n\nexport const getPageFactory = (\n context: PbImportExportContext,\n store: ITaskManagerStore<IExportPagesZipPagesInput>,\n published: boolean\n) => {\n return async (pageId: string) => {\n if (published) {\n try {\n return await context.pageBuilder.getPublishedPageById({\n id: pageId\n });\n } catch (ex) {\n /**\n * We do not need to do anything on exception because we will fetch the latest version.\n */\n }\n }\n try {\n return await context.pageBuilder.getPage(pageId);\n } catch (ex) {\n const message = `There is no page with ID ${pageId}.`;\n try {\n await store.addErrorLog({\n message,\n error: ex\n });\n } catch {\n console.error(`Failed to add error log: \"${message}\"`);\n }\n return null;\n }\n };\n};\n"],"mappings":";;;;;;AAIO,MAAMA,cAAc,GAAGA,CAC1BC,OAA8B,EAC9BC,KAAmD,EACnDC,SAAkB,KACjB;EACD,OAAO,MAAOC,MAAc,IAAK;IAC7B,IAAID,SAAS,EAAE;MACX,IAAI;QACA,OAAO,MAAMF,OAAO,CAACI,WAAW,CAACC,oBAAoB,CAAC;UAClDC,EAAE,EAAEH;QACR,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACT;AAChB;AACA;MAFgB;IAIR;IACA,IAAI;MACA,OAAO,MAAMP,OAAO,CAACI,WAAW,CAACI,OAAO,CAACL,MAAM,CAAC;IACpD,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAME,OAAO,GAAG,4BAA4BN,MAAM,GAAG;MACrD,IAAI;QACA,MAAMF,KAAK,CAACS,WAAW,CAAC;UACpBD,OAAO;UACPE,KAAK,EAAEJ;QACX,CAAC,CAAC;MACN,CAAC,CAAC,MAAM;QACJK,OAAO,CAACD,KAAK,CAAC,6BAA6BF,OAAO,GAAG,CAAC;MAC1D;MACA,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { PbImportExportContext } from "../../types";
2
+ import type { Configuration, Payload, Response } from "./";
3
+ /**
4
+ * Handles the export blocks process workflow.
5
+ */
6
+ export declare const blocksHandler: (configuration: Configuration, payload: Payload, context: PbImportExportContext) => Promise<Response>;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.blocksHandler = 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 _BlockExporter = require("./exporters/BlockExporter");
13
+ /**
14
+ * Handles the export blocks process workflow.
15
+ */
16
+ const blocksHandler = 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 Blocks 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
+ blockId,
60
+ exportBlocksDataKey
61
+ } = input;
62
+ const block = await pageBuilder.getPageBlock(blockId);
63
+ if (!block) {
64
+ log(`Unable to load block "${blockId}"`);
65
+ throw new _handlerGraphql.NotFoundError(`Unable to load block "${blockId}"`);
66
+ }
67
+ log(`Processing block key "${blockId}"`);
68
+ const blockCategory = await pageBuilder.getBlockCategory(block.blockCategory);
69
+ if (!blockCategory) {
70
+ log(`Unable to load block category "${block.blockCategory}"`);
71
+ throw new _handlerGraphql.NotFoundError(`Unable to load block category "${block.blockCategory}"`);
72
+ }
73
+
74
+ // Mark task status as PROCESSING
75
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
76
+ status: _types.ImportExportTaskStatus.PROCESSING
77
+ });
78
+ // Update stats in main task
79
+ await pageBuilder.importExportTask.updateStats(taskId, {
80
+ prevStatus: prevStatusOfSubTask,
81
+ nextStatus: _types.ImportExportTaskStatus.PROCESSING
82
+ });
83
+ prevStatusOfSubTask = subTask.status;
84
+ log(`Extracting block data and uploading to storage...`);
85
+ const blockExporter = new _BlockExporter.BlockExporter(fileManager);
86
+ const blockDataZip = await blockExporter.execute(block, blockCategory, exportBlocksDataKey);
87
+ log(`Finish uploading zip...`);
88
+ // Update task record in DB
89
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
90
+ status: _types.ImportExportTaskStatus.COMPLETED,
91
+ data: {
92
+ message: `Finish uploading data for block "${block.id}"`,
93
+ key: blockDataZip.Key
94
+ }
95
+ });
96
+ // Update stats in main task
97
+ await pageBuilder.importExportTask.updateStats(taskId, {
98
+ prevStatus: prevStatusOfSubTask,
99
+ nextStatus: _types.ImportExportTaskStatus.COMPLETED
100
+ });
101
+ prevStatusOfSubTask = subTask.status;
102
+ } catch (e) {
103
+ log("[EXPORT_BLOCKS_PROCESS] Error => ", e.message);
104
+ if (subTask && subTask.id) {
105
+ /**
106
+ * In case of error, we'll update the task status to "failed",
107
+ * so that, client can show notify the user appropriately.
108
+ */
109
+ subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {
110
+ status: _types.ImportExportTaskStatus.FAILED,
111
+ error: {
112
+ name: e.name,
113
+ message: e.message,
114
+ code: "EXPORT_FAILED"
115
+ }
116
+ });
117
+
118
+ // Update stats in main task
119
+ await pageBuilder.importExportTask.updateStats(taskId, {
120
+ prevStatus: prevStatusOfSubTask,
121
+ nextStatus: _types.ImportExportTaskStatus.FAILED
122
+ });
123
+ prevStatusOfSubTask = subTask.status;
124
+ }
125
+ return {
126
+ data: null,
127
+ error: {
128
+ message: e.message
129
+ }
130
+ };
131
+ } finally {
132
+ // Base condition!
133
+ if (noPendingTask) {
134
+ log(`No pending sub-task for task ${taskId}`);
135
+ // Combine individual block zip files.
136
+ await (0, _client.invokeHandlerClient)({
137
+ context,
138
+ name: configuration.handlers.combine,
139
+ payload: {
140
+ taskId,
141
+ type,
142
+ identity: context.security.getIdentity()
143
+ },
144
+ description: "Export blocks - combine"
145
+ });
146
+ } else {
147
+ console.log(`Invoking PROCESS for task "${subTaskIndex + 1}"`);
148
+ // We want to continue with Self invocation no matter if current block error out.
149
+ await (0, _client.invokeHandlerClient)({
150
+ context,
151
+ name: configuration.handlers.process,
152
+ payload: {
153
+ taskId,
154
+ subTaskIndex: subTaskIndex + 1,
155
+ type,
156
+ identity: context.security.getIdentity()
157
+ },
158
+ description: "Export blocks - process - subtask"
159
+ });
160
+ }
161
+ }
162
+ return {
163
+ data: "",
164
+ error: null
165
+ };
166
+ };
167
+ exports.blocksHandler = blocksHandler;
168
+
169
+ //# sourceMappingURL=blocksHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_client","_handlerGraphql","_mockSecurity","_utils","_BlockExporter","blocksHandler","configuration","payload","context","log","console","subTask","noPendingTask","prevStatusOfSubTask","ImportExportTaskStatus","PENDING","pageBuilder","fileManager","taskId","subTaskIndex","type","identity","mockSecurity","importExportTask","getSubTask","zeroPad","status","data","error","id","input","blockId","exportBlocksDataKey","block","getPageBlock","NotFoundError","blockCategory","getBlockCategory","updateSubTask","PROCESSING","updateStats","prevStatus","nextStatus","blockExporter","BlockExporter","blockDataZip","execute","COMPLETED","message","key","Key","e","FAILED","name","code","invokeHandlerClient","handlers","combine","security","getIdentity","description","process","exports"],"sources":["blocksHandler.ts"],"sourcesContent":["import 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 { BlockExporter } from \"./exporters/BlockExporter\";\n\n/**\n * Handles the export blocks process workflow.\n */\nexport const blocksHandler = async (\n configuration: Configuration,\n payload: Payload,\n context: PbImportExportContext\n): Promise<Response> => {\n const log = console.log;\n let subTask;\n let noPendingTask = true;\n let prevStatusOfSubTask = ImportExportTaskStatus.PENDING;\n\n log(\"RUNNING Export Blocks Process Handler\");\n const { pageBuilder, fileManager } = context;\n const { taskId, subTaskIndex, type, identity } = payload;\n // Disable authorization; this is necessary because we call Page Builder CRUD methods which include authorization checks\n // and this Lambda is invoked internally, without credentials.\n mockSecurity(identity as SecurityIdentity, context);\n try {\n /*\n * Note: We're not going to DB for finding the next sub-task to process,\n * because the data might be out of sync due to GSI eventual consistency.\n */\n subTask = await pageBuilder.importExportTask.getSubTask(taskId, zeroPad(subTaskIndex, 5));\n /**\n * Base condition!!\n * Bail out early, if task not found or task's status is not \"pending\".\n */\n if (!subTask || subTask.status !== ImportExportTaskStatus.PENDING) {\n noPendingTask = true;\n return {\n data: \"\",\n error: null\n };\n } else {\n noPendingTask = false;\n }\n\n log(`Fetched sub task => ${subTask.id}`);\n\n const { input } = subTask;\n const { blockId, exportBlocksDataKey } = input;\n\n const block = await pageBuilder.getPageBlock(blockId);\n\n if (!block) {\n log(`Unable to load block \"${blockId}\"`);\n throw new NotFoundError(`Unable to load block \"${blockId}\"`);\n }\n\n log(`Processing block key \"${blockId}\"`);\n\n const blockCategory = await pageBuilder.getBlockCategory(block.blockCategory);\n\n if (!blockCategory) {\n log(`Unable to load block category \"${block.blockCategory}\"`);\n throw new NotFoundError(`Unable to load block category \"${block.blockCategory}\"`);\n }\n\n // Mark task status as PROCESSING\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.PROCESSING\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.PROCESSING\n });\n prevStatusOfSubTask = subTask.status;\n\n log(`Extracting block data and uploading to storage...`);\n const blockExporter = new BlockExporter(fileManager);\n const blockDataZip = await blockExporter.execute(block, blockCategory, exportBlocksDataKey);\n\n log(`Finish uploading zip...`);\n // Update task record in DB\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.COMPLETED,\n data: {\n message: `Finish uploading data for block \"${block.id}\"`,\n key: blockDataZip.Key\n }\n });\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.COMPLETED\n });\n prevStatusOfSubTask = subTask.status;\n } catch (e) {\n log(\"[EXPORT_BLOCKS_PROCESS] Error => \", e.message);\n\n if (subTask && subTask.id) {\n /**\n * In case of error, we'll update the task status to \"failed\",\n * so that, client can show notify the user appropriately.\n */\n subTask = await pageBuilder.importExportTask.updateSubTask(taskId, subTask.id, {\n status: ImportExportTaskStatus.FAILED,\n error: {\n name: e.name,\n message: e.message,\n code: \"EXPORT_FAILED\"\n }\n });\n\n // Update stats in main task\n await pageBuilder.importExportTask.updateStats(taskId, {\n prevStatus: prevStatusOfSubTask,\n nextStatus: ImportExportTaskStatus.FAILED\n });\n prevStatusOfSubTask = subTask.status;\n }\n\n return {\n data: null,\n error: {\n message: e.message\n }\n };\n } finally {\n // Base condition!\n if (noPendingTask) {\n log(`No pending sub-task for task ${taskId}`);\n // Combine individual block zip files.\n await invokeHandlerClient<ExtractPayload>({\n context,\n name: configuration.handlers.combine,\n payload: {\n taskId,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - combine\"\n });\n } else {\n console.log(`Invoking PROCESS for task \"${subTaskIndex + 1}\"`);\n // We want to continue with Self invocation no matter if current block error out.\n await invokeHandlerClient<Payload>({\n context,\n name: configuration.handlers.process,\n payload: {\n taskId,\n subTaskIndex: subTaskIndex + 1,\n type,\n identity: context.security.getIdentity()\n },\n description: \"Export blocks - process - subtask\"\n });\n }\n }\n return {\n data: \"\",\n error: null\n };\n};\n"],"mappings":";;;;;;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,cAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACO,MAAMM,aAAa,GAAG,MAAAA,CACzBC,aAA4B,EAC5BC,OAAgB,EAChBC,OAA8B,KACV;EACpB,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;EACvB,IAAIE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U,YAAY,GAAG,CAAC,GAAG,CAAC;MAC9D;MACA,MAAM,IAAAoC,2BAAmB,EAAU;QAC/B/C,OAAO;QACP6C,IAAI,EAAE/C,aAAa,CAACkD,QAAQ,CAACK,OAAO;QACpCtD,OAAO,EAAE;UACLW,MAAM;UACNC,YAAY,EAAEA,YAAY,GAAG,CAAC;UAC9BC,IAAI;UACJC,QAAQ,EAAEb,OAAO,CAACkD,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDC,WAAW,EAAE;MACjB,CAAC,CAAC;IACN;EACJ;EACA,OAAO;IACHjC,IAAI,EAAE,EAAE;IACRC,KAAK,EAAE;EACX,CAAC;AACL,CAAC;AAACkC,OAAA,CAAAzD,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import type { BlockCategory, PageBlock } from "@webiny/api-page-builder/types";
2
+ import type { File, FileManagerContext } from "@webiny/api-file-manager/types";
3
+ export interface ExportedBlockData {
4
+ block: Pick<PageBlock, "name" | "content">;
5
+ category: BlockCategory;
6
+ files: File[];
7
+ }
8
+ export declare class BlockExporter {
9
+ private fileManager;
10
+ constructor(fileManager: FileManagerContext["fileManager"]);
11
+ execute(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string): Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadOutput>;
12
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.BlockExporter = void 0;
8
+ var _zipper = _interopRequireDefault(require("../../zipper"));
9
+ var _utils = require("../../utils");
10
+ class BlockExporter {
11
+ constructor(fileManager) {
12
+ this.fileManager = fileManager;
13
+ }
14
+ async execute(block, blockCategory, exportBlocksDataKey) {
15
+ // Extract all files
16
+ const files = (0, _utils.extractFilesFromData)(block.content || {});
17
+ const fileIds = files.map(imageFile => imageFile.id);
18
+ // Get file data for all images
19
+ const imageFilesData = [];
20
+ if (fileIds.length > 0) {
21
+ const [filesData] = await this.fileManager.listFiles({
22
+ where: {
23
+ id_in: fileIds
24
+ }
25
+ });
26
+ imageFilesData.push(...filesData);
27
+ }
28
+
29
+ // Extract the block data in a json file and upload it to S3
30
+ const blockData = {
31
+ block: {
32
+ name: block.name,
33
+ content: block.content
34
+ },
35
+ category: {
36
+ name: blockCategory.name,
37
+ slug: blockCategory.slug,
38
+ icon: blockCategory.icon,
39
+ description: blockCategory.description
40
+ },
41
+ files: imageFilesData
42
+ };
43
+ const blockDataBuffer = Buffer.from(JSON.stringify(blockData));
44
+ const zipper = new _zipper.default({
45
+ exportInfo: {
46
+ files: imageFilesData,
47
+ name: block.name,
48
+ dataBuffer: blockDataBuffer
49
+ },
50
+ archiveFileKey: exportBlocksDataKey
51
+ });
52
+ return zipper.process();
53
+ }
54
+ }
55
+ exports.BlockExporter = BlockExporter;
56
+
57
+ //# sourceMappingURL=BlockExporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","BlockExporter","constructor","fileManager","execute","block","blockCategory","exportBlocksDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","blockData","name","category","slug","icon","description","blockDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","dataBuffer","archiveFileKey","process","exports"],"sources":["BlockExporter.ts"],"sourcesContent":["import type { BlockCategory, PageBlock } from \"@webiny/api-page-builder/types\";\nimport type { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedBlockData {\n block: Pick<PageBlock, \"name\" | \"content\">;\n category: BlockCategory;\n files: File[];\n}\n\nexport class BlockExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(block: PageBlock, blockCategory: BlockCategory, exportBlocksDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(block.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the block data in a json file and upload it to S3\n const blockData = {\n block: {\n name: block.name,\n content: block.content\n },\n category: {\n name: blockCategory.name,\n slug: blockCategory.slug,\n icon: blockCategory.icon,\n description: blockCategory.description\n },\n files: imageFilesData\n };\n const blockDataBuffer = Buffer.from(JSON.stringify(blockData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: block.name,\n dataBuffer: blockDataBuffer\n },\n archiveFileKey: exportBlocksDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQO,MAAME,aAAa,CAAC;EAGvBC,WAAWA,CAACC,WAA8C,EAAE;IACxD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC;EAEA,MAAMC,OAAOA,CAACC,KAAgB,EAAEC,aAA4B,EAAEC,mBAA2B,EAAE;IACvF;IACA,MAAMC,KAAK,GAAG,IAAAC,2BAAoB,EAACJ,KAAK,CAACK,OAAO,IAAI,CAAC,CAAC,CAAC;IACvD,MAAMC,OAAO,GAAGH,KAAK,CAACI,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC;IACpD;IACA,MAAMC,cAAc,GAAG,EAAE;IACzB,IAAIJ,OAAO,CAACK,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,CAACC,SAAS,CAAC,GAAG,MAAM,IAAI,CAACd,WAAW,CAACe,SAAS,CAAC;QAAEC,KAAK,EAAE;UAAEC,KAAK,EAAET;QAAQ;MAAE,CAAC,CAAC;MACnFI,cAAc,CAACM,IAAI,CAAC,GAAGJ,SAAS,CAAC;IACrC;;IAEA;IACA,MAAMK,SAAS,GAAG;MACdjB,KAAK,EAAE;QACHkB,IAAI,EAAElB,KAAK,CAACkB,IAAI;QAChBb,OAAO,EAAEL,KAAK,CAACK;MACnB,CAAC;MACDc,QAAQ,EAAE;QACND,IAAI,EAAEjB,aAAa,CAACiB,IAAI;QACxBE,IAAI,EAAEnB,aAAa,CAACmB,IAAI;QACxBC,IAAI,EAAEpB,aAAa,CAACoB,IAAI;QACxBC,WAAW,EAAErB,aAAa,CAACqB;MAC/B,CAAC;MACDnB,KAAK,EAAEO;IACX,CAAC;IACD,MAAMa,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,SAAS,CAAC,CAAC;IAE9D,MAAMW,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACR3B,KAAK,EAAEO,cAAc;QACrBQ,IAAI,EAAElB,KAAK,CAACkB,IAAI;QAChBa,UAAU,EAAER;MAChB,CAAC;MACDS,cAAc,EAAE9B;IACpB,CAAC,CAAC;IAEF,OAAO0B,MAAM,CAACK,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAtC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import type { FbForm } from "@webiny/api-form-builder/types";
2
+ import type { File } from "@webiny/api-file-manager/types";
3
+ export interface ExportedFormData {
4
+ form: Pick<FbForm, "name" | "status" | "version" | "fields" | "steps" | "settings" | "triggers">;
5
+ files: File[];
6
+ }
7
+ export declare class FormExporter {
8
+ execute(form: FbForm, exportFormsDataKey: string): Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadOutput>;
9
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.FormExporter = void 0;
8
+ var _zipper = _interopRequireDefault(require("../../zipper"));
9
+ class FormExporter {
10
+ async execute(form, exportFormsDataKey) {
11
+ const formData = {
12
+ form: {
13
+ name: form.name,
14
+ status: form.status,
15
+ version: form.version,
16
+ fields: form.fields,
17
+ steps: form.steps,
18
+ settings: form.settings,
19
+ triggers: form.triggers
20
+ }
21
+ };
22
+ const formDataBuffer = Buffer.from(JSON.stringify(formData));
23
+ const zipper = new _zipper.default({
24
+ exportInfo: {
25
+ files: [],
26
+ name: form.name,
27
+ dataBuffer: formDataBuffer
28
+ },
29
+ archiveFileKey: exportFormsDataKey
30
+ });
31
+ return zipper.process();
32
+ }
33
+ }
34
+ exports.FormExporter = FormExporter;
35
+
36
+ //# sourceMappingURL=FormExporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_zipper","_interopRequireDefault","require","FormExporter","execute","form","exportFormsDataKey","formData","name","status","version","fields","steps","settings","triggers","formDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","files","dataBuffer","archiveFileKey","process","exports"],"sources":["FormExporter.ts"],"sourcesContent":["import Zipper from \"~/export/zipper\";\nimport type { FbForm } from \"@webiny/api-form-builder/types\";\nimport type { File } from \"@webiny/api-file-manager/types\";\n\nexport interface ExportedFormData {\n form: Pick<\n FbForm,\n \"name\" | \"status\" | \"version\" | \"fields\" | \"steps\" | \"settings\" | \"triggers\"\n >;\n files: File[];\n}\n\nexport class FormExporter {\n async execute(form: FbForm, exportFormsDataKey: string) {\n const formData = {\n form: {\n name: form.name,\n status: form.status,\n version: form.version,\n fields: form.fields,\n steps: form.steps,\n settings: form.settings,\n triggers: form.triggers\n }\n };\n const formDataBuffer = Buffer.from(JSON.stringify(formData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: [],\n name: form.name,\n dataBuffer: formDataBuffer\n },\n archiveFileKey: exportFormsDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAYO,MAAMC,YAAY,CAAC;EACtB,MAAMC,OAAOA,CAACC,IAAY,EAAEC,kBAA0B,EAAE;IACpD,MAAMC,QAAQ,GAAG;MACbF,IAAI,EAAE;QACFG,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfC,MAAM,EAAEJ,IAAI,CAACI,MAAM;QACnBC,OAAO,EAAEL,IAAI,CAACK,OAAO;QACrBC,MAAM,EAAEN,IAAI,CAACM,MAAM;QACnBC,KAAK,EAAEP,IAAI,CAACO,KAAK;QACjBC,QAAQ,EAAER,IAAI,CAACQ,QAAQ;QACvBC,QAAQ,EAAET,IAAI,CAACS;MACnB;IACJ,CAAC;IACD,MAAMC,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACZ,QAAQ,CAAC,CAAC;IAE5D,MAAMa,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRC,KAAK,EAAE,EAAE;QACTf,IAAI,EAAEH,IAAI,CAACG,IAAI;QACfgB,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAEnB;IACpB,CAAC,CAAC;IAEF,OAAOc,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAxB,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import type { Page } from "@webiny/api-page-builder/types";
2
+ import type { File, FileManagerContext } from "@webiny/api-file-manager/types";
3
+ export interface ExportedPageData {
4
+ /**
5
+ * TODO: is it really ok not to export whole page object?
6
+ * What if we add some new properties in the future?
7
+ *
8
+ * Type of the exported page data is now created by removing unnecessary properties from the Page type.
9
+ * This way TS will break if we add new property and forget to handle it in the export/import process.
10
+ */
11
+ page: Omit<Page, "id" | "pid" | "tenant" | "locale" | "editor" | "category" | "createdFrom" | "createdBy" | "createdOn" | "savedOn" | "publishedOn" | "locked" | "ownedBy" | "webinyVersion">;
12
+ files: File[];
13
+ }
14
+ export declare class PageExporter {
15
+ private fileManager;
16
+ constructor(fileManager: FileManagerContext["fileManager"]);
17
+ execute(page: Page, exportPagesDataKey: string): Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadOutput>;
18
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PageExporter = void 0;
8
+ var _get = _interopRequireDefault(require("lodash/get"));
9
+ var _zipper = _interopRequireDefault(require("../../zipper"));
10
+ var _utils = require("../../utils");
11
+ class PageExporter {
12
+ constructor(fileManager) {
13
+ this.fileManager = fileManager;
14
+ }
15
+ async execute(page, exportPagesDataKey) {
16
+ // Extract all files
17
+ const files = (0, _utils.extractFilesFromData)(page.content || {});
18
+ // Extract images from page settings
19
+ const pageSettingsImages = [(0, _get.default)(page, "settings.general.image"), (0, _get.default)(page, "settings.social.image")].filter(image => image && image.src);
20
+ const fileIds = [...files, ...pageSettingsImages].map(imageFile => imageFile.id);
21
+ // Get file data for all images
22
+ const imageFilesData = [];
23
+ if (fileIds.length > 0) {
24
+ const [filesData] = await this.fileManager.listFiles({
25
+ where: {
26
+ id_in: fileIds
27
+ },
28
+ limit: 10000
29
+ });
30
+ imageFilesData.push(...filesData);
31
+ }
32
+
33
+ // Extract the page data in a json file and upload it to S3
34
+ const pageData = {
35
+ page: {
36
+ content: page.content,
37
+ title: page.title,
38
+ path: page.path,
39
+ version: page.version,
40
+ status: page.status,
41
+ settings: page.settings
42
+ },
43
+ files: imageFilesData
44
+ };
45
+ const pageDataBuffer = Buffer.from(JSON.stringify(pageData));
46
+ const zipper = new _zipper.default({
47
+ exportInfo: {
48
+ files: imageFilesData,
49
+ name: page.title,
50
+ dataBuffer: pageDataBuffer
51
+ },
52
+ archiveFileKey: exportPagesDataKey
53
+ });
54
+ return zipper.process();
55
+ }
56
+ }
57
+ exports.PageExporter = PageExporter;
58
+
59
+ //# sourceMappingURL=PageExporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_get","_interopRequireDefault","require","_zipper","_utils","PageExporter","constructor","fileManager","execute","page","exportPagesDataKey","files","extractFilesFromData","content","pageSettingsImages","get","filter","image","src","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","limit","push","pageData","title","path","version","status","settings","pageDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageExporter.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport type { Page } from \"@webiny/api-page-builder/types\";\nimport type { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedPageData {\n /**\n * TODO: is it really ok not to export whole page object?\n * What if we add some new properties in the future?\n *\n * Type of the exported page data is now created by removing unnecessary properties from the Page type.\n * This way TS will break if we add new property and forget to handle it in the export/import process.\n */\n page: Omit<\n Page,\n | \"id\"\n | \"pid\"\n | \"tenant\"\n | \"locale\"\n | \"editor\"\n | \"category\"\n | \"createdFrom\"\n | \"createdBy\"\n | \"createdOn\"\n | \"savedOn\"\n | \"publishedOn\"\n | \"locked\"\n | \"ownedBy\"\n | \"webinyVersion\"\n >;\n files: File[];\n}\n\nexport class PageExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(page: Page, exportPagesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(page.content || {});\n // Extract images from page settings\n const pageSettingsImages = [\n get(page, \"settings.general.image\") as unknown as File,\n get(page, \"settings.social.image\") as unknown as File\n ].filter(image => image && image.src);\n\n const fileIds = [...files, ...pageSettingsImages].map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData: File[] = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({\n where: {\n id_in: fileIds\n },\n limit: 10000\n });\n imageFilesData.push(...filesData);\n }\n\n // Extract the page data in a json file and upload it to S3\n const pageData: ExportedPageData = {\n page: {\n content: page.content,\n title: page.title,\n path: page.path,\n version: page.version,\n status: page.status,\n settings: page.settings\n },\n files: imageFilesData\n };\n const pageDataBuffer = Buffer.from(JSON.stringify(pageData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: page.title,\n dataBuffer: pageDataBuffer\n },\n archiveFileKey: exportPagesDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AA8BO,MAAMG,YAAY,CAAC;EAGtBC,WAAWA,CAACC,WAA8C,EAAE;IACxD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC;EAEA,MAAMC,OAAOA,CAACC,IAAU,EAAEC,kBAA0B,EAAE;IAClD;IACA,MAAMC,KAAK,GAAG,IAAAC,2BAAoB,EAACH,IAAI,CAACI,OAAO,IAAI,CAAC,CAAC,CAAC;IACtD;IACA,MAAMC,kBAAkB,GAAG,CACvB,IAAAC,YAAG,EAACN,IAAI,EAAE,wBAAwB,CAAC,EACnC,IAAAM,YAAG,EAACN,IAAI,EAAE,uBAAuB,CAAC,CACrC,CAACO,MAAM,CAACC,KAAK,IAAIA,KAAK,IAAIA,KAAK,CAACC,GAAG,CAAC;IAErC,MAAMC,OAAO,GAAG,CAAC,GAAGR,KAAK,EAAE,GAAGG,kBAAkB,CAAC,CAACM,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC;IAChF;IACA,MAAMC,cAAsB,GAAG,EAAE;IACjC,IAAIJ,OAAO,CAACK,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,CAACC,SAAS,CAAC,GAAG,MAAM,IAAI,CAAClB,WAAW,CAACmB,SAAS,CAAC;QACjDC,KAAK,EAAE;UACHC,KAAK,EAAET;QACX,CAAC;QACDU,KAAK,EAAE;MACX,CAAC,CAAC;MACFN,cAAc,CAACO,IAAI,CAAC,GAAGL,SAAS,CAAC;IACrC;;IAEA;IACA,MAAMM,QAA0B,GAAG;MAC/BtB,IAAI,EAAE;QACFI,OAAO,EAAEJ,IAAI,CAACI,OAAO;QACrBmB,KAAK,EAAEvB,IAAI,CAACuB,KAAK;QACjBC,IAAI,EAAExB,IAAI,CAACwB,IAAI;QACfC,OAAO,EAAEzB,IAAI,CAACyB,OAAO;QACrBC,MAAM,EAAE1B,IAAI,CAAC0B,MAAM;QACnBC,QAAQ,EAAE3B,IAAI,CAAC2B;MACnB,CAAC;MACDzB,KAAK,EAAEY;IACX,CAAC;IACD,MAAMc,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACV,QAAQ,CAAC,CAAC;IAE5D,MAAMW,MAAM,GAAG,IAAIC,eAAM,CAAC;MACtBC,UAAU,EAAE;QACRjC,KAAK,EAAEY,cAAc;QACrBsB,IAAI,EAAEpC,IAAI,CAACuB,KAAK;QAChBc,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAErC;IACpB,CAAC,CAAC;IAEF,OAAOgC,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAA5C,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import type { PageTemplate } from "@webiny/api-page-builder/types";
2
+ import type { File, FileManagerContext } from "@webiny/api-file-manager/types";
3
+ export interface ExportedTemplateData {
4
+ template: Pick<PageTemplate, "title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory" | "dataBindings" | "dataSources">;
5
+ files: File[];
6
+ }
7
+ export declare class PageTemplateExporter {
8
+ private fileManager;
9
+ constructor(fileManager: FileManagerContext["fileManager"]);
10
+ execute(template: PageTemplate, exportTemplatesDataKey: string): Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadOutput>;
11
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PageTemplateExporter = void 0;
8
+ var _zipper = _interopRequireDefault(require("../../zipper"));
9
+ var _utils = require("../../utils");
10
+ class PageTemplateExporter {
11
+ constructor(fileManager) {
12
+ this.fileManager = fileManager;
13
+ }
14
+ async execute(template, exportTemplatesDataKey) {
15
+ // Extract all files
16
+ const files = (0, _utils.extractFilesFromData)(template.content || {});
17
+ const fileIds = files.map(imageFile => imageFile.id);
18
+ // Get file data for all images
19
+ const imageFilesData = [];
20
+ if (fileIds.length > 0) {
21
+ const [filesData] = await this.fileManager.listFiles({
22
+ where: {
23
+ id_in: fileIds
24
+ }
25
+ });
26
+ imageFilesData.push(...filesData);
27
+ }
28
+
29
+ // Extract the template data in a json file and upload it to S3
30
+ const templateData = {
31
+ template: {
32
+ title: template.title,
33
+ slug: template.slug,
34
+ tags: template.tags,
35
+ description: template.description,
36
+ content: template.content,
37
+ layout: template.layout,
38
+ pageCategory: template.pageCategory,
39
+ dataBindings: template.dataBindings,
40
+ dataSources: template.dataSources
41
+ },
42
+ files: imageFilesData
43
+ };
44
+ const templateDataBuffer = Buffer.from(JSON.stringify(templateData));
45
+ const zipper = new _zipper.default({
46
+ exportInfo: {
47
+ files: imageFilesData,
48
+ name: template.title,
49
+ dataBuffer: templateDataBuffer
50
+ },
51
+ archiveFileKey: exportTemplatesDataKey
52
+ });
53
+ return zipper.process();
54
+ }
55
+ }
56
+ exports.PageTemplateExporter = PageTemplateExporter;
57
+
58
+ //# sourceMappingURL=PageTemplateExporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_zipper","_interopRequireDefault","require","_utils","PageTemplateExporter","constructor","fileManager","execute","template","exportTemplatesDataKey","files","extractFilesFromData","content","fileIds","map","imageFile","id","imageFilesData","length","filesData","listFiles","where","id_in","push","templateData","title","slug","tags","description","layout","pageCategory","dataBindings","dataSources","templateDataBuffer","Buffer","from","JSON","stringify","zipper","Zipper","exportInfo","name","dataBuffer","archiveFileKey","process","exports"],"sources":["PageTemplateExporter.ts"],"sourcesContent":["import type { PageTemplate } from \"@webiny/api-page-builder/types\";\nimport type { File, FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport Zipper from \"~/export/zipper\";\nimport { extractFilesFromData } from \"~/export/utils\";\n\nexport interface ExportedTemplateData {\n template: Pick<\n PageTemplate,\n | \"title\"\n | \"slug\"\n | \"tags\"\n | \"description\"\n | \"content\"\n | \"layout\"\n | \"pageCategory\"\n | \"dataBindings\"\n | \"dataSources\"\n >;\n files: File[];\n}\n\nexport class PageTemplateExporter {\n private fileManager: FileManagerContext[\"fileManager\"];\n\n constructor(fileManager: FileManagerContext[\"fileManager\"]) {\n this.fileManager = fileManager;\n }\n\n async execute(template: PageTemplate, exportTemplatesDataKey: string) {\n // Extract all files\n const files = extractFilesFromData(template.content || {});\n const fileIds = files.map(imageFile => imageFile.id);\n // Get file data for all images\n const imageFilesData = [];\n if (fileIds.length > 0) {\n const [filesData] = await this.fileManager.listFiles({ where: { id_in: fileIds } });\n imageFilesData.push(...filesData);\n }\n\n // Extract the template data in a json file and upload it to S3\n const templateData = {\n template: {\n title: template.title,\n slug: template.slug,\n tags: template.tags,\n description: template.description,\n content: template.content,\n layout: template.layout,\n pageCategory: template.pageCategory,\n dataBindings: template.dataBindings,\n dataSources: template.dataSources\n },\n files: imageFilesData\n };\n const templateDataBuffer = Buffer.from(JSON.stringify(templateData));\n\n const zipper = new Zipper({\n exportInfo: {\n files: imageFilesData,\n name: template.title,\n dataBuffer: templateDataBuffer\n },\n archiveFileKey: exportTemplatesDataKey\n });\n\n return zipper.process();\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAkBO,MAAME,oBAAoB,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AAE;QACR9B,KAAK,EAAEO,cAAc;QACrBwB,IAAI,EAAEjC,QAAQ,CAACiB,KAAK;QACpBiB,UAAU,EAAET;MAChB,CAAC;MACDU,cAAc,EAAElC;IACpB,CAAC,CAAC;IAEF,OAAO6B,MAAM,CAACM,OAAO,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAzC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { PbImportExportContext } from "../../types";
2
+ import type { Configuration, Payload, Response } from "./";
3
+ /**
4
+ * Handles the export forms process workflow.
5
+ */
6
+ export declare const formsHandler: (configuration: Configuration, payload: Payload, context: PbImportExportContext) => Promise<Response>;