@webiny/api-page-builder-import-export 0.0.0-unstable.6e5425ee89 → 0.0.0-unstable.7c9e8fbfd6

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 (274) hide show
  1. package/client.d.ts +2 -2
  2. package/client.js +12 -21
  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 -23
  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/{exportPages → export}/zipper.js +26 -29
  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 +238 -117
  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 +8 -3
  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 +103 -20
  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 +16 -5
  117. package/graphql/graphql/utils/resolve.js.map +1 -1
  118. package/graphql/graphql.d.ts +1 -1
  119. package/graphql/graphql.js +7 -3
  120. package/graphql/graphql.js.map +1 -1
  121. package/graphql/index.d.ts +2 -2
  122. package/graphql/index.js +5 -2
  123. package/graphql/index.js.map +1 -1
  124. package/graphql/types.d.ts +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 +3 -2
  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 +69 -17
  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 -106
  252. package/exportPages/combine/index.js.map +0 -1
  253. package/exportPages/process/index.js +0 -192
  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 -100
  259. package/exportPages/utils.js.map +0 -1
  260. package/exportPages/zipper.js.map +0 -1
  261. package/graphql/crud/pageImportExportTasks.crud.d.ts +0 -5
  262. package/graphql/crud/pageImportExportTasks.crud.js +0 -363
  263. package/graphql/crud/pageImportExportTasks.crud.js.map +0 -1
  264. package/graphql/graphql/pageImportExportTasks.gql.d.ts +0 -4
  265. package/graphql/graphql/pageImportExportTasks.gql.js +0 -75
  266. package/graphql/graphql/pageImportExportTasks.gql.js.map +0 -1
  267. package/importPages/create/index.d.ts +0 -22
  268. package/importPages/create/index.js +0 -107
  269. package/importPages/create/index.js.map +0 -1
  270. package/importPages/process/index.js +0 -180
  271. package/importPages/process/index.js.map +0 -1
  272. package/importPages/utils.d.ts +0 -50
  273. package/importPages/utils.js +0 -488
  274. package/importPages/utils.js.map +0 -1
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uploadAssets = void 0;
7
+ var _utils = require("@webiny/utils");
8
+ var _uploadFilesFromS = require("./uploadFilesFromS3");
9
+ function notAPreviouslyImportedFile(importedImages) {
10
+ return file => {
11
+ return !importedImages.some(existingImportedImage => existingImportedImage.meta.originalKey === file.key);
12
+ };
13
+ }
14
+ function notAnExistingFile(existingFiles) {
15
+ return file => {
16
+ return !existingFiles.some(existingFile => existingFile.key === file.key);
17
+ };
18
+ }
19
+ const uploadAssets = async params => {
20
+ const {
21
+ context,
22
+ files,
23
+ fileUploadsData
24
+ } = params;
25
+ const oldIdToNewFileMap = new Map();
26
+
27
+ /**
28
+ * This function contains logic of file download from S3.
29
+ * Current we're not mocking zip file download from S3 in tests at the moment.
30
+ * So, we're manually mocking it in case of test just by returning an empty object.
31
+ */
32
+ if (process.env.NODE_ENV === "test") {
33
+ return oldIdToNewFileMap;
34
+ }
35
+
36
+ // Check if the requested files were already imported in the past.
37
+ const [importedImages] = await context.fileManager.listFiles({
38
+ where: {
39
+ meta: {
40
+ originalKey_in: files.map(file => file.key)
41
+ }
42
+ }
43
+ });
44
+
45
+ // Link files that were already imported.
46
+ for (const importedImage of importedImages) {
47
+ const fileBeingImported = files.find(file => file.key === importedImage.meta.originalKey);
48
+ if (fileBeingImported) {
49
+ oldIdToNewFileMap.set(fileBeingImported.id, importedImage);
50
+ }
51
+ }
52
+
53
+ // Check if files with such IDs already exist.
54
+ const [existingFiles] = await context.fileManager.listFiles({
55
+ where: {
56
+ id_in: files.map(file => file.id)
57
+ }
58
+ });
59
+ const newFilesToImport = files.filter(notAnExistingFile(existingFiles)).filter(notAPreviouslyImportedFile(importedImages));
60
+
61
+ // A map of temporary file keys (created during ZIP upload) to permanent file keys.
62
+ const uploadFileMap = new Map();
63
+
64
+ // Array of file inputs, to insert into the DB.
65
+ const createFilesInput = [];
66
+ for (const toImport of newFilesToImport) {
67
+ // We generate a new file id, key, and add `meta.originalKey` property to prevent duplicates on future imports.
68
+ const id = (0, _utils.mdbid)();
69
+ const newKey = `${id}/${toImport.key.replace(`${toImport.id}/`, "")}`;
70
+ const newFile = {
71
+ ...toImport,
72
+ id,
73
+ location: {
74
+ folderId: "root"
75
+ },
76
+ key: newKey,
77
+ meta: {
78
+ ...toImport.meta,
79
+ originalKey: toImport.key
80
+ }
81
+ };
82
+ createFilesInput.push(newFile);
83
+ oldIdToNewFileMap.set(toImport.id, newFile);
84
+ uploadFileMap.set(fileUploadsData.assets[toImport.key], newFile);
85
+ }
86
+ await (0, _uploadFilesFromS.uploadFilesFromS3)(uploadFileMap);
87
+ await context.fileManager.createFilesInBatch(createFilesInput);
88
+ return oldIdToNewFileMap;
89
+ };
90
+ exports.uploadAssets = uploadAssets;
91
+
92
+ //# sourceMappingURL=uploadAssets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","_uploadFilesFromS","notAPreviouslyImportedFile","importedImages","file","some","existingImportedImage","meta","originalKey","key","notAnExistingFile","existingFiles","existingFile","uploadAssets","params","context","files","fileUploadsData","oldIdToNewFileMap","Map","process","env","NODE_ENV","fileManager","listFiles","where","originalKey_in","map","importedImage","fileBeingImported","find","set","id","id_in","newFilesToImport","filter","uploadFileMap","createFilesInput","toImport","mdbid","newKey","replace","newFile","location","folderId","push","assets","uploadFilesFromS3","createFilesInBatch","exports"],"sources":["uploadAssets.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport type { PbImportExportContext } from \"~/graphql/types\";\nimport type { File, FileInput } from \"@webiny/api-file-manager/types\";\nimport type { UploadFileMap } from \"~/import/utils/uploadFilesFromS3\";\nimport { uploadFilesFromS3 } from \"~/import/utils/uploadFilesFromS3\";\nimport type { FileUploadsData } from \"~/types\";\n\ninterface UploadAssetsParams {\n context: PbImportExportContext;\n files: File[];\n fileUploadsData: FileUploadsData;\n}\n\nfunction notAPreviouslyImportedFile(importedImages: File[]) {\n return (file: File) => {\n return !importedImages.some(\n existingImportedImage => existingImportedImage.meta.originalKey === file.key\n );\n };\n}\n\nfunction notAnExistingFile(existingFiles: File[]) {\n return (file: File) => {\n return !existingFiles.some(existingFile => existingFile.key === file.key);\n };\n}\n\nexport const uploadAssets = async (params: UploadAssetsParams) => {\n const { context, files, fileUploadsData } = params;\n\n const oldIdToNewFileMap = new Map<string, FileInput>();\n\n /**\n * This function contains logic of file download from S3.\n * Current we're not mocking zip file download from S3 in tests at the moment.\n * So, we're manually mocking it in case of test just by returning an empty object.\n */\n if (process.env.NODE_ENV === \"test\") {\n return oldIdToNewFileMap;\n }\n\n // Check if the requested files were already imported in the past.\n const [importedImages] = await context.fileManager.listFiles({\n where: { meta: { originalKey_in: files.map(file => file.key) } }\n });\n\n // Link files that were already imported.\n for (const importedImage of importedImages) {\n const fileBeingImported = files.find(file => file.key === importedImage.meta.originalKey);\n\n if (fileBeingImported) {\n oldIdToNewFileMap.set(fileBeingImported.id, importedImage);\n }\n }\n\n // Check if files with such IDs already exist.\n const [existingFiles] = await context.fileManager.listFiles({\n where: { id_in: files.map(file => file.id) }\n });\n\n const newFilesToImport = files\n .filter(notAnExistingFile(existingFiles))\n .filter(notAPreviouslyImportedFile(importedImages));\n\n // A map of temporary file keys (created during ZIP upload) to permanent file keys.\n const uploadFileMap: UploadFileMap = new Map();\n\n // Array of file inputs, to insert into the DB.\n const createFilesInput: FileInput[] = [];\n\n for (const toImport of newFilesToImport) {\n // We generate a new file id, key, and add `meta.originalKey` property to prevent duplicates on future imports.\n const id = mdbid();\n const newKey = `${id}/${toImport.key.replace(`${toImport.id}/`, \"\")}`;\n const newFile: FileInput = {\n ...toImport,\n id,\n location: {\n folderId: \"root\"\n },\n key: newKey,\n meta: { ...toImport.meta, originalKey: toImport.key }\n };\n\n createFilesInput.push(newFile);\n oldIdToNewFileMap.set(toImport.id, newFile);\n uploadFileMap.set(fileUploadsData.assets[toImport.key], newFile);\n }\n\n await uploadFilesFromS3(uploadFileMap);\n\n await context.fileManager.createFilesInBatch(createFilesInput);\n\n return oldIdToNewFileMap;\n};\n"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { FileInput } from "@webiny/api-file-manager/types";
2
+ export type UploadFileMap = Map<string, FileInput>;
3
+ export declare function uploadFilesFromS3(fileMap: UploadFileMap): Promise<import("@aws-sdk/client-s3").CompleteMultipartUploadCommandOutput[]>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uploadFilesFromS3 = uploadFilesFromS3;
7
+ var _s3Stream = require("../../export/s3Stream");
8
+ async function uploadFilesFromS3(fileMap) {
9
+ const promises = [];
10
+ for (const [source, target] of Array.from(fileMap.entries())) {
11
+ // Read file.
12
+ const readStream = await _s3Stream.s3Stream.readStream(source);
13
+ const ws = _s3Stream.s3Stream.writeStream(target.key, target.type);
14
+ readStream.pipe(ws.streamPassThrough);
15
+ promises.push(ws.streamPassThroughUploadPromise);
16
+ console.log(`Successfully queued file "${target.key}"`);
17
+ }
18
+ return Promise.all(promises);
19
+ }
20
+
21
+ //# sourceMappingURL=uploadFilesFromS3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_s3Stream","require","uploadFilesFromS3","fileMap","promises","source","target","Array","from","entries","readStream","s3Stream","ws","writeStream","key","type","pipe","streamPassThrough","push","streamPassThroughUploadPromise","console","log","Promise","all"],"sources":["uploadFilesFromS3.ts"],"sourcesContent":["import { s3Stream } from \"~/export/s3Stream\";\nimport type { FileInput } from \"@webiny/api-file-manager/types\";\n\nexport type UploadFileMap = Map<string, FileInput>;\n\nexport async function uploadFilesFromS3(fileMap: UploadFileMap) {\n const promises = [];\n for (const [source, target] of Array.from(fileMap.entries())) {\n // Read file.\n const readStream = await s3Stream.readStream(source);\n\n const ws = s3Stream.writeStream(target.key, target.type);\n readStream.pipe(ws.streamPassThrough);\n promises.push(ws.streamPassThroughUploadPromise);\n\n console.log(`Successfully queued file \"${target.key}\"`);\n }\n\n return Promise.all(promises);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAKO,eAAeC,iBAAiBA,CAACC,OAAsB,EAAE;EAC5D,MAAMC,QAAQ,GAAG,EAAE;EACnB,KAAK,MAAM,CAACC,MAAM,EAAEC,MAAM,CAAC,IAAIC,KAAK,CAACC,IAAI,CAACL,OAAO,CAACM,OAAO,CAAC,CAAC,CAAC,EAAE;IAC1D;IACA,MAAMC,UAAU,GAAG,MAAMC,kBAAQ,CAACD,UAAU,CAACL,MAAM,CAAC;IAEpD,MAAMO,EAAE,GAAGD,kBAAQ,CAACE,WAAW,CAACP,MAAM,CAACQ,GAAG,EAAER,MAAM,CAACS,IAAI,CAAC;IACxDL,UAAU,CAACM,IAAI,CAACJ,EAAE,CAACK,iBAAiB,CAAC;IACrCb,QAAQ,CAACc,IAAI,CAACN,EAAE,CAACO,8BAA8B,CAAC;IAEhDC,OAAO,CAACC,GAAG,CAAC,6BAA6Bf,MAAM,CAACQ,GAAG,GAAG,CAAC;EAC3D;EAEA,OAAOQ,OAAO,CAACC,GAAG,CAACnB,QAAQ,CAAC;AAChC","ignoreList":[]}
package/mockSecurity.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { SecurityContext, SecurityIdentity } from "@webiny/api-security/types";
1
+ import type { SecurityContext, SecurityIdentity } from "@webiny/api-security/types";
2
2
  export declare const mockSecurity: (identity: SecurityIdentity, context: SecurityContext) => void;
package/mockSecurity.js CHANGED
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.mockSecurity = void 0;
7
7
  const mockSecurity = (identity, context) => {
8
- context.security.disableAuthorization();
9
8
  context.security.setIdentity(identity);
10
9
  };
11
- exports.mockSecurity = mockSecurity;
10
+ exports.mockSecurity = mockSecurity;
11
+
12
+ //# sourceMappingURL=mockSecurity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["mockSecurity","identity","context","security","disableAuthorization","setIdentity"],"sources":["mockSecurity.ts"],"sourcesContent":["import { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport const mockSecurity = (identity: SecurityIdentity, context: SecurityContext) => {\n context.security.disableAuthorization();\n context.security.setIdentity(identity);\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAG,CAACC,QAA0B,EAAEC,OAAwB,KAAK;EAClFA,OAAO,CAACC,QAAQ,CAACC,oBAAoB,EAAE;EACvCF,OAAO,CAACC,QAAQ,CAACE,WAAW,CAACJ,QAAQ,CAAC;AAC1C,CAAC;AAAC"}
1
+ {"version":3,"names":["mockSecurity","identity","context","security","setIdentity","exports"],"sources":["mockSecurity.ts"],"sourcesContent":["import type { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport const mockSecurity = (identity: SecurityIdentity, context: SecurityContext) => {\n context.security.setIdentity(identity);\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAGA,CAACC,QAA0B,EAAEC,OAAwB,KAAK;EAClFA,OAAO,CAACC,QAAQ,CAACC,WAAW,CAACH,QAAQ,CAAC;AAC1C,CAAC;AAACI,OAAA,CAAAL,YAAA,GAAAA,YAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-page-builder-import-export",
3
- "version": "0.0.0-unstable.6e5425ee89",
3
+ "version": "0.0.0-unstable.7c9e8fbfd6",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "pbie:base"
@@ -14,69 +14,53 @@
14
14
  "author": "Webiny Ltd",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "7.20.1",
18
- "@commodo/fields": "1.1.2-beta.20",
19
- "@webiny/api": "0.0.0-unstable.6e5425ee89",
20
- "@webiny/api-file-manager": "0.0.0-unstable.6e5425ee89",
21
- "@webiny/api-page-builder": "0.0.0-unstable.6e5425ee89",
22
- "@webiny/api-security": "0.0.0-unstable.6e5425ee89",
23
- "@webiny/error": "0.0.0-unstable.6e5425ee89",
24
- "@webiny/handler": "0.0.0-unstable.6e5425ee89",
25
- "@webiny/handler-aws": "0.0.0-unstable.6e5425ee89",
26
- "@webiny/handler-graphql": "0.0.0-unstable.6e5425ee89",
27
- "@webiny/utils": "0.0.0-unstable.6e5425ee89",
28
- "@webiny/validation": "0.0.0-unstable.6e5425ee89",
29
- "archiver": "5.3.1",
30
- "commodo-fields-object": "1.0.6",
17
+ "@smithy/node-http-handler": "2.1.6",
18
+ "@webiny/api": "0.0.0-unstable.7c9e8fbfd6",
19
+ "@webiny/api-file-manager": "0.0.0-unstable.7c9e8fbfd6",
20
+ "@webiny/api-form-builder": "0.0.0-unstable.7c9e8fbfd6",
21
+ "@webiny/api-page-builder": "0.0.0-unstable.7c9e8fbfd6",
22
+ "@webiny/api-security": "0.0.0-unstable.7c9e8fbfd6",
23
+ "@webiny/aws-sdk": "0.0.0-unstable.7c9e8fbfd6",
24
+ "@webiny/error": "0.0.0-unstable.7c9e8fbfd6",
25
+ "@webiny/handler": "0.0.0-unstable.7c9e8fbfd6",
26
+ "@webiny/handler-aws": "0.0.0-unstable.7c9e8fbfd6",
27
+ "@webiny/handler-graphql": "0.0.0-unstable.7c9e8fbfd6",
28
+ "@webiny/pubsub": "0.0.0-unstable.7c9e8fbfd6",
29
+ "@webiny/tasks": "0.0.0-unstable.7c9e8fbfd6",
30
+ "@webiny/utils": "0.0.0-unstable.7c9e8fbfd6",
31
+ "archiver": "7.0.1",
31
32
  "dot-prop-immutable": "2.1.1",
32
- "fs-extra": "9.1.0",
33
+ "fs-extra": "11.2.0",
33
34
  "load-json-file": "6.2.0",
34
35
  "lodash": "4.17.21",
35
- "mdbid": "1.0.0",
36
36
  "node-fetch": "2.6.7",
37
- "stream": "0.0.2",
37
+ "stream": "0.0.3",
38
38
  "uniqid": "5.4.0",
39
- "yauzl": "2.10.0"
39
+ "yauzl": "2.10.0",
40
+ "zod": "3.23.8"
40
41
  },
41
42
  "devDependencies": {
42
- "@babel/cli": "^7.19.3",
43
- "@babel/core": "^7.19.3",
44
- "@babel/plugin-proposal-export-default-from": "^7.16.0",
45
- "@babel/preset-env": "^7.19.4",
46
- "@babel/preset-typescript": "^7.18.6",
47
- "@types/archiver": "^5.3.1",
48
- "@types/node-fetch": "^2.6.1",
49
- "@types/yauzl": "^2.9.2",
50
- "@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.6e5425ee89",
51
- "@webiny/api-file-manager-ddb-es": "^0.0.0-unstable.6e5425ee89",
52
- "@webiny/api-i18n-ddb": "^0.0.0-unstable.6e5425ee89",
53
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.6e5425ee89",
54
- "@webiny/api-tenancy": "^0.0.0-unstable.6e5425ee89",
55
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.6e5425ee89",
56
- "@webiny/api-wcp": "^0.0.0-unstable.6e5425ee89",
57
- "@webiny/cli": "^0.0.0-unstable.6e5425ee89",
58
- "@webiny/db": "^0.0.0-unstable.6e5425ee89",
59
- "@webiny/project-utils": "^0.0.0-unstable.6e5425ee89",
60
- "jest": "^28.1.0",
61
- "jest-dynalite": "^3.2.0",
62
- "rimraf": "^3.0.2",
63
- "ttypescript": "^1.5.12",
64
- "typescript": "4.7.4"
43
+ "@types/archiver": "5.3.1",
44
+ "@types/node-fetch": "2.6.2",
45
+ "@types/yauzl": "2.10.0",
46
+ "@webiny/api-authentication": "0.0.0-unstable.7c9e8fbfd6",
47
+ "@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.7c9e8fbfd6",
48
+ "@webiny/api-tenancy": "0.0.0-unstable.7c9e8fbfd6",
49
+ "@webiny/api-wcp": "0.0.0-unstable.7c9e8fbfd6",
50
+ "@webiny/db": "0.0.0-unstable.7c9e8fbfd6",
51
+ "@webiny/project-utils": "0.0.0-unstable.7c9e8fbfd6",
52
+ "jest": "29.7.0",
53
+ "jest-dynalite": "3.6.1",
54
+ "rimraf": "6.0.1",
55
+ "typescript": "5.3.3"
65
56
  },
66
57
  "publishConfig": {
67
58
  "access": "public",
68
59
  "directory": "dist"
69
60
  },
70
61
  "scripts": {
71
- "build": "yarn webiny run build",
72
- "watch": "yarn webiny run watch"
62
+ "build": "node ../cli/bin.js run build",
63
+ "watch": "node ../cli/bin.js run watch"
73
64
  },
74
- "adio": {
75
- "ignore": {
76
- "src": [
77
- "aws-sdk"
78
- ]
79
- }
80
- },
81
- "gitHead": "1e49c5d4b72b2f00661572464188f53b42ed7745"
65
+ "gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
82
66
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Cleanup of the child tasks.
3
+ * This code will remove all the child tasks and their logs, which have no errors in them.
4
+ */
5
+ import type { ITask, Context } from "@webiny/tasks";
6
+ export interface IChildTasksCleanupExecuteParams {
7
+ context: Context;
8
+ task: ITask;
9
+ }
10
+ export declare class ChildTasksCleanup {
11
+ execute(params: IChildTasksCleanupExecuteParams): Promise<void>;
12
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ChildTasksCleanup = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ /**
9
+ * Cleanup of the child tasks.
10
+ * This code will remove all the child tasks and their logs, which have no errors in them.
11
+ */
12
+
13
+ class ChildTasksCleanup {
14
+ async execute(params) {
15
+ const {
16
+ context,
17
+ task
18
+ } = params;
19
+ const {
20
+ items: childTasks
21
+ } = await context.tasks.listTasks({
22
+ where: {
23
+ parentId: task.id
24
+ },
25
+ // Really doubtful there will be more than 10k of child tasks.
26
+ limit: 100000
27
+ });
28
+ if (childTasks.length === 0) {
29
+ return;
30
+ }
31
+ const childTaskIdList = childTasks.map(childTask => childTask.id);
32
+ const {
33
+ items: childLogs
34
+ } = await context.tasks.listLogs({
35
+ where: {
36
+ task_in: childTaskIdList
37
+ },
38
+ limit: 100000
39
+ });
40
+ const deletedChildTaskLogIdList = [];
41
+ /**
42
+ * First, we need to remove all the logs which have no errors.
43
+ */
44
+ for (const log of childLogs) {
45
+ if (log.items.some(item => item.type === _tasks.TaskLogItemType.ERROR)) {
46
+ continue;
47
+ }
48
+ await context.tasks.deleteLog(log.id);
49
+ if (deletedChildTaskLogIdList.includes(log.task)) {
50
+ continue;
51
+ }
52
+ deletedChildTaskLogIdList.push(log.task);
53
+ }
54
+ /**
55
+ * Now we can remove the tasks.
56
+ */
57
+ for (const childTaskId of deletedChildTaskLogIdList) {
58
+ await context.tasks.deleteTask(childTaskId);
59
+ }
60
+ }
61
+ }
62
+ exports.ChildTasksCleanup = ChildTasksCleanup;
63
+
64
+ //# sourceMappingURL=ChildTasksCleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","ChildTasksCleanup","execute","params","context","task","items","childTasks","tasks","listTasks","where","parentId","id","limit","length","childTaskIdList","map","childTask","childLogs","listLogs","task_in","deletedChildTaskLogIdList","log","some","item","type","TaskLogItemType","ERROR","deleteLog","includes","push","childTaskId","deleteTask","exports"],"sources":["ChildTasksCleanup.ts"],"sourcesContent":["/**\n * Cleanup of the child tasks.\n * This code will remove all the child tasks and their logs, which have no errors in them.\n */\nimport type { ITask, Context } from \"@webiny/tasks\";\nimport { TaskLogItemType } from \"@webiny/tasks\";\n\nexport interface IChildTasksCleanupExecuteParams {\n context: Context;\n task: ITask;\n}\nexport class ChildTasksCleanup {\n public async execute(params: IChildTasksCleanupExecuteParams): Promise<void> {\n const { context, task } = params;\n\n const { items: childTasks } = await context.tasks.listTasks({\n where: {\n parentId: task.id\n },\n // Really doubtful there will be more than 10k of child tasks.\n limit: 100000\n });\n if (childTasks.length === 0) {\n return;\n }\n\n const childTaskIdList = childTasks.map(childTask => childTask.id);\n\n const { items: childLogs } = await context.tasks.listLogs({\n where: {\n task_in: childTaskIdList\n },\n limit: 100000\n });\n\n const deletedChildTaskLogIdList: string[] = [];\n /**\n * First, we need to remove all the logs which have no errors.\n */\n for (const log of childLogs) {\n if (log.items.some(item => item.type === TaskLogItemType.ERROR)) {\n continue;\n }\n await context.tasks.deleteLog(log.id);\n if (deletedChildTaskLogIdList.includes(log.task)) {\n continue;\n }\n deletedChildTaskLogIdList.push(log.task);\n }\n /**\n * Now we can remove the tasks.\n */\n for (const childTaskId of deletedChildTaskLogIdList) {\n await context.tasks.deleteTask(childTaskId);\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AALA;AACA;AACA;AACA;;AAQO,MAAMC,iBAAiB,CAAC;EAC3B,MAAaC,OAAOA,CAACC,MAAuC,EAAiB;IACzE,MAAM;MAAEC,OAAO;MAAEC;IAAK,CAAC,GAAGF,MAAM;IAEhC,MAAM;MAAEG,KAAK,EAAEC;IAAW,CAAC,GAAG,MAAMH,OAAO,CAACI,KAAK,CAACC,SAAS,CAAC;MACxDC,KAAK,EAAE;QACHC,QAAQ,EAAEN,IAAI,CAACO;MACnB,CAAC;MACD;MACAC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAIN,UAAU,CAACO,MAAM,KAAK,CAAC,EAAE;MACzB;IACJ;IAEA,MAAMC,eAAe,GAAGR,UAAU,CAACS,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACL,EAAE,CAAC;IAEjE,MAAM;MAAEN,KAAK,EAAEY;IAAU,CAAC,GAAG,MAAMd,OAAO,CAACI,KAAK,CAACW,QAAQ,CAAC;MACtDT,KAAK,EAAE;QACHU,OAAO,EAAEL;MACb,CAAC;MACDF,KAAK,EAAE;IACX,CAAC,CAAC;IAEF,MAAMQ,yBAAmC,GAAG,EAAE;IAC9C;AACR;AACA;IACQ,KAAK,MAAMC,GAAG,IAAIJ,SAAS,EAAE;MACzB,IAAII,GAAG,CAAChB,KAAK,CAACiB,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,IAAI,KAAKC,sBAAe,CAACC,KAAK,CAAC,EAAE;QAC7D;MACJ;MACA,MAAMvB,OAAO,CAACI,KAAK,CAACoB,SAAS,CAACN,GAAG,CAACV,EAAE,CAAC;MACrC,IAAIS,yBAAyB,CAACQ,QAAQ,CAACP,GAAG,CAACjB,IAAI,CAAC,EAAE;QAC9C;MACJ;MACAgB,yBAAyB,CAACS,IAAI,CAACR,GAAG,CAACjB,IAAI,CAAC;IAC5C;IACA;AACR;AACA;IACQ,KAAK,MAAM0B,WAAW,IAAIV,yBAAyB,EAAE;MACjD,MAAMjB,OAAO,CAACI,KAAK,CAACwB,UAAU,CAACD,WAAW,CAAC;IAC/C;EACJ;AACJ;AAACE,OAAA,CAAAhC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const createTasks: () => (import("@webiny/tasks").TaskDefinitionPlugin<import("../types").PbImportExportContext, import("../export/pages/types").IExportPagesControllerInput, import("../export/pages/types").IExportPagesControllerOutput> | import("@webiny/tasks").TaskDefinitionPlugin<import("../types").PbImportExportContext, import("../import/pages/types").IImportPagesControllerInput, import("../import/pages/types").IImportPagesControllerOutput> | import("@webiny/tasks").TaskDefinitionPlugin<import("../types").PbImportExportContext, import("../export/pages/types").IExportPagesZipPagesInput, import("../export/pages/types").IExportPagesZipPagesOutput> | import("@webiny/tasks").TaskDefinitionPlugin<import("../types").PbImportExportContext, import("../export/pages/types").IExportPagesCleanupInput, import("@webiny/tasks").ITaskResponseDoneResultOutput> | import("@webiny/tasks").TaskDefinitionPlugin<import("../types").PbImportExportContext, import("../import/pages/types").IImportPagesProcessPagesInput, import("../import/pages/types").IImportPagesProcessPagesOutput>)[][];
package/tasks/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createTasks = void 0;
7
+ var _pages = require("./pages");
8
+ const createTasks = () => {
9
+ return [(0, _pages.createPagesTasks)()];
10
+ };
11
+ exports.createTasks = createTasks;
12
+
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_pages","require","createTasks","createPagesTasks","exports"],"sources":["index.ts"],"sourcesContent":["import { createPagesTasks } from \"./pages\";\n\nexport const createTasks = () => {\n return [createPagesTasks()];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CAAA,KAAM;EAC7B,OAAO,CAAC,IAAAC,uBAAgB,EAAC,CAAC,CAAC;AAC/B,CAAC;AAACC,OAAA,CAAAF,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { IExportPagesCleanupInput } from "../../export/pages/types";
2
+ import type { PbImportExportContext } from "../../graphql/types";
3
+ export declare const createExportPagesCleanupTask: () => import("@webiny/tasks").TaskDefinitionPlugin<PbImportExportContext, IExportPagesCleanupInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createExportPagesCleanupTask = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ var _types = require("../../export/pages/types");
9
+ const createExportPagesCleanupTask = () => {
10
+ return (0, _tasks.createPrivateTaskDefinition)({
11
+ id: _types.PageExportTask.Cleanup,
12
+ title: "Page Builder - Export Pages Cleanup",
13
+ description: "Export pages from the Page Builder - cleanup.",
14
+ maxIterations: 1,
15
+ run: async param => {
16
+ const {
17
+ response,
18
+ isAborted
19
+ } = param;
20
+ /**
21
+ * We always need to check task status.
22
+ */
23
+ if (isAborted()) {
24
+ return response.aborted();
25
+ }
26
+ const {
27
+ ExportPagesCleanup
28
+ } = await import(/* webpackChunkName: "ExportPagesCleanup" */"../../export/pages/ExportPagesCleanup");
29
+ const exportPagesCleanup = new ExportPagesCleanup();
30
+ return await exportPagesCleanup.execute(param);
31
+ }
32
+ });
33
+ };
34
+ exports.createExportPagesCleanupTask = createExportPagesCleanupTask;
35
+
36
+ //# sourceMappingURL=exportPagesCleanupTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","_types","createExportPagesCleanupTask","createPrivateTaskDefinition","id","PageExportTask","Cleanup","title","description","maxIterations","run","param","response","isAborted","aborted","ExportPagesCleanup","exportPagesCleanup","execute","exports"],"sources":["exportPagesCleanupTask.ts"],"sourcesContent":["import { createPrivateTaskDefinition } from \"@webiny/tasks\";\nimport type { IExportPagesCleanupInput } from \"~/export/pages/types\";\nimport { PageExportTask } from \"~/export/pages/types\";\nimport type { PbImportExportContext } from \"~/graphql/types\";\n\nexport const createExportPagesCleanupTask = () => {\n return createPrivateTaskDefinition<PbImportExportContext, IExportPagesCleanupInput>({\n id: PageExportTask.Cleanup,\n title: \"Page Builder - Export Pages Cleanup\",\n description: \"Export pages from the Page Builder - cleanup.\",\n maxIterations: 1,\n run: async param => {\n const { response, isAborted } = param;\n /**\n * We always need to check task status.\n */\n if (isAborted()) {\n return response.aborted();\n }\n\n const { ExportPagesCleanup } = await import(\n /* webpackChunkName: \"ExportPagesCleanup\" */ \"~/export/pages/ExportPagesCleanup\"\n );\n\n const exportPagesCleanup = new ExportPagesCleanup();\n return await exportPagesCleanup.execute(param);\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,4BAA4B,GAAGA,CAAA,KAAM;EAC9C,OAAO,IAAAC,kCAA2B,EAAkD;IAChFC,EAAE,EAAEC,qBAAc,CAACC,OAAO;IAC1BC,KAAK,EAAE,qCAAqC;IAC5CC,WAAW,EAAE,+CAA+C;IAC5DC,aAAa,EAAE,CAAC;IAChBC,GAAG,EAAE,MAAMC,KAAK,IAAI;MAChB,MAAM;QAAEC,QAAQ;QAAEC;MAAU,CAAC,GAAGF,KAAK;MACrC;AACZ;AACA;MACY,IAAIE,SAAS,CAAC,CAAC,EAAE;QACb,OAAOD,QAAQ,CAACE,OAAO,CAAC,CAAC;MAC7B;MAEA,MAAM;QAAEC;MAAmB,CAAC,GAAG,MAAM,MAAM,CACvC,mFACJ,CAAC;MAED,MAAMC,kBAAkB,GAAG,IAAID,kBAAkB,CAAC,CAAC;MACnD,OAAO,MAAMC,kBAAkB,CAACC,OAAO,CAACN,KAAK,CAAC;IAClD;EACJ,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAAhB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { PbImportExportContext } from "../../graphql/types";
2
+ import type { IExportPagesControllerInput, IExportPagesControllerOutput } from "../../export/pages/types";
3
+ export declare const createExportPagesControllerTask: () => import("@webiny/tasks").TaskDefinitionPlugin<PbImportExportContext, IExportPagesControllerInput, IExportPagesControllerOutput>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createExportPagesControllerTask = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ var _types = require("../../export/pages/types");
9
+ var _ChildTasksCleanup = require("../common/ChildTasksCleanup");
10
+ const createExportPagesControllerTask = () => {
11
+ // TODO make the task private with createPrivateTaskDefinition
12
+ return (0, _tasks.createTaskDefinition)({
13
+ isPrivate: true,
14
+ id: _types.PageExportTask.Controller,
15
+ title: "Page Builder - Export Pages - Controller",
16
+ description: "Export pages from the Page Builder - controller.",
17
+ /**
18
+ * We want to have a lot of executions because we need to pool the subtasks all the time.
19
+ */
20
+ maxIterations: 500,
21
+ run: async params => {
22
+ const {
23
+ response,
24
+ isAborted
25
+ } = params;
26
+ /**
27
+ * We always need to check task status.
28
+ */
29
+ if (isAborted()) {
30
+ return response.aborted();
31
+ }
32
+ const {
33
+ ExportPagesController
34
+ } = await import(/* webpackChunkName: "ExportPagesController" */"../../export/pages/ExportPagesController");
35
+ const exportPagesController = new ExportPagesController();
36
+ return await exportPagesController.execute(params);
37
+ },
38
+ onDone: async ({
39
+ context,
40
+ task
41
+ }) => {
42
+ await context.tasks.trigger({
43
+ definition: _types.PageExportTask.Cleanup,
44
+ parent: task,
45
+ // delay cleanup for 25hrs
46
+ delay: 25 * 60 * 60
47
+ });
48
+ /**
49
+ * We want to clean all child tasks and logs, which have no errors.
50
+ */
51
+ const childTasksCleanup = new _ChildTasksCleanup.ChildTasksCleanup();
52
+ try {
53
+ await childTasksCleanup.execute({
54
+ context,
55
+ task
56
+ });
57
+ } catch (ex) {
58
+ console.error("Error while cleaning child tasks.", ex);
59
+ }
60
+ },
61
+ onError: async ({
62
+ context,
63
+ task
64
+ }) => {
65
+ await context.tasks.trigger({
66
+ definition: _types.PageExportTask.Cleanup,
67
+ parent: task
68
+ });
69
+ },
70
+ onAbort: async ({
71
+ context,
72
+ task
73
+ }) => {
74
+ await context.tasks.trigger({
75
+ definition: _types.PageExportTask.Cleanup,
76
+ parent: task
77
+ });
78
+ }
79
+ });
80
+ };
81
+ exports.createExportPagesControllerTask = createExportPagesControllerTask;
82
+
83
+ //# sourceMappingURL=exportPagesControllerTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","_types","_ChildTasksCleanup","createExportPagesControllerTask","createTaskDefinition","isPrivate","id","PageExportTask","Controller","title","description","maxIterations","run","params","response","isAborted","aborted","ExportPagesController","exportPagesController","execute","onDone","context","task","tasks","trigger","definition","Cleanup","parent","delay","childTasksCleanup","ChildTasksCleanup","ex","console","error","onError","onAbort","exports"],"sources":["exportPagesControllerTask.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport type { PbImportExportContext } from \"~/graphql/types\";\nimport type {\n IExportPagesControllerInput,\n IExportPagesControllerOutput\n} from \"~/export/pages/types\";\nimport { PageExportTask } from \"~/export/pages/types\";\nimport { ChildTasksCleanup } from \"../common/ChildTasksCleanup\";\n\nexport const createExportPagesControllerTask = () => {\n // TODO make the task private with createPrivateTaskDefinition\n return createTaskDefinition<\n PbImportExportContext,\n IExportPagesControllerInput,\n IExportPagesControllerOutput\n >({\n isPrivate: true,\n id: PageExportTask.Controller,\n title: \"Page Builder - Export Pages - Controller\",\n description: \"Export pages from the Page Builder - controller.\",\n /**\n * We want to have a lot of executions because we need to pool the subtasks all the time.\n */\n maxIterations: 500,\n run: async params => {\n const { response, isAborted } = params;\n /**\n * We always need to check task status.\n */\n if (isAborted()) {\n return response.aborted();\n }\n\n const { ExportPagesController } = await import(\n /* webpackChunkName: \"ExportPagesController\" */ \"~/export/pages/ExportPagesController\"\n );\n\n const exportPagesController = new ExportPagesController();\n return await exportPagesController.execute(params);\n },\n onDone: async ({ context, task }) => {\n await context.tasks.trigger({\n definition: PageExportTask.Cleanup,\n parent: task,\n // delay cleanup for 25hrs\n delay: 25 * 60 * 60\n });\n /**\n * We want to clean all child tasks and logs, which have no errors.\n */\n const childTasksCleanup = new ChildTasksCleanup();\n try {\n await childTasksCleanup.execute({\n context,\n task\n });\n } catch (ex) {\n console.error(\"Error while cleaning child tasks.\", ex);\n }\n },\n onError: async ({ context, task }) => {\n await context.tasks.trigger({\n definition: PageExportTask.Cleanup,\n parent: task\n });\n },\n onAbort: async ({ context, task }) => {\n await context.tasks.trigger({\n definition: PageExportTask.Cleanup,\n parent: task\n });\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAEO,MAAMG,+BAA+B,GAAGA,CAAA,KAAM;EACjD;EACA,OAAO,IAAAC,2BAAoB,EAIzB;IACEC,SAAS,EAAE,IAAI;IACfC,EAAE,EAAEC,qBAAc,CAACC,UAAU;IAC7BC,KAAK,EAAE,0CAA0C;IACjDC,WAAW,EAAE,kDAAkD;IAC/D;AACR;AACA;IACQC,aAAa,EAAE,GAAG;IAClBC,GAAG,EAAE,MAAMC,MAAM,IAAI;MACjB,MAAM;QAAEC,QAAQ;QAAEC;MAAU,CAAC,GAAGF,MAAM;MACtC;AACZ;AACA;MACY,IAAIE,SAAS,CAAC,CAAC,EAAE;QACb,OAAOD,QAAQ,CAACE,OAAO,CAAC,CAAC;MAC7B;MAEA,MAAM;QAAEC;MAAsB,CAAC,GAAG,MAAM,MAAM,CAC1C,yFACJ,CAAC;MAED,MAAMC,qBAAqB,GAAG,IAAID,qBAAqB,CAAC,CAAC;MACzD,OAAO,MAAMC,qBAAqB,CAACC,OAAO,CAACN,MAAM,CAAC;IACtD,CAAC;IACDO,MAAM,EAAE,MAAAA,CAAO;MAAEC,OAAO;MAAEC;IAAK,CAAC,KAAK;MACjC,MAAMD,OAAO,CAACE,KAAK,CAACC,OAAO,CAAC;QACxBC,UAAU,EAAElB,qBAAc,CAACmB,OAAO;QAClCC,MAAM,EAAEL,IAAI;QACZ;QACAM,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG;MACrB,CAAC,CAAC;MACF;AACZ;AACA;MACY,MAAMC,iBAAiB,GAAG,IAAIC,oCAAiB,CAAC,CAAC;MACjD,IAAI;QACA,MAAMD,iBAAiB,CAACV,OAAO,CAAC;UAC5BE,OAAO;UACPC;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOS,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,mCAAmC,EAAEF,EAAE,CAAC;MAC1D;IACJ,CAAC;IACDG,OAAO,EAAE,MAAAA,CAAO;MAAEb,OAAO;MAAEC;IAAK,CAAC,KAAK;MAClC,MAAMD,OAAO,CAACE,KAAK,CAACC,OAAO,CAAC;QACxBC,UAAU,EAAElB,qBAAc,CAACmB,OAAO;QAClCC,MAAM,EAAEL;MACZ,CAAC,CAAC;IACN,CAAC;IACDa,OAAO,EAAE,MAAAA,CAAO;MAAEd,OAAO;MAAEC;IAAK,CAAC,KAAK;MAClC,MAAMD,OAAO,CAACE,KAAK,CAACC,OAAO,CAAC;QACxBC,UAAU,EAAElB,qBAAc,CAACmB,OAAO;QAClCC,MAAM,EAAEL;MACZ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAjC,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { IExportPagesZipPagesInput, IExportPagesZipPagesOutput } from "../../export/pages/types";
2
+ import type { PbImportExportContext } from "../../graphql/types";
3
+ export declare const createExportPagesZipPagesTask: () => import("@webiny/tasks").TaskDefinitionPlugin<PbImportExportContext, IExportPagesZipPagesInput, IExportPagesZipPagesOutput>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createExportPagesZipPagesTask = void 0;
7
+ var _tasks = require("@webiny/tasks");
8
+ var _types = require("../../export/pages/types");
9
+ const createExportPagesZipPagesTask = () => {
10
+ return (0, _tasks.createPrivateTaskDefinition)({
11
+ id: _types.PageExportTask.ZipPages,
12
+ title: "Page Builder - Export Pages - Zip Pages",
13
+ description: "Export pages from the Page Builder - zip pages.",
14
+ /**
15
+ * If we ever hit the max iterations limit, we should decrease the number of pages being zipped in one task execution.
16
+ */
17
+ maxIterations: 10,
18
+ run: async params => {
19
+ const {
20
+ response,
21
+ isAborted
22
+ } = params;
23
+ /**
24
+ * We always need to check task status.
25
+ */
26
+ if (isAborted()) {
27
+ return response.aborted();
28
+ }
29
+ const {
30
+ ExportPagesZipPages
31
+ } = await import(/* webpackChunkName: "ExportPagesZipPages" */"../../export/pages/ExportPagesZipPages");
32
+ const exportPagesZipPages = new ExportPagesZipPages();
33
+ return await exportPagesZipPages.execute(params);
34
+ }
35
+ });
36
+ };
37
+ exports.createExportPagesZipPagesTask = createExportPagesZipPagesTask;
38
+
39
+ //# sourceMappingURL=exportPagesZipPagesTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_tasks","require","_types","createExportPagesZipPagesTask","createPrivateTaskDefinition","id","PageExportTask","ZipPages","title","description","maxIterations","run","params","response","isAborted","aborted","ExportPagesZipPages","exportPagesZipPages","execute","exports"],"sources":["exportPagesZipPagesTask.ts"],"sourcesContent":["import { createPrivateTaskDefinition } from \"@webiny/tasks\";\nimport type { IExportPagesZipPagesInput, IExportPagesZipPagesOutput } from \"~/export/pages/types\";\nimport { PageExportTask } from \"~/export/pages/types\";\nimport type { PbImportExportContext } from \"~/graphql/types\";\n\nexport const createExportPagesZipPagesTask = () => {\n return createPrivateTaskDefinition<\n PbImportExportContext,\n IExportPagesZipPagesInput,\n IExportPagesZipPagesOutput\n >({\n id: PageExportTask.ZipPages,\n title: \"Page Builder - Export Pages - Zip Pages\",\n description: \"Export pages from the Page Builder - zip pages.\",\n /**\n * If we ever hit the max iterations limit, we should decrease the number of pages being zipped in one task execution.\n */\n maxIterations: 10,\n run: async params => {\n const { response, isAborted } = params;\n /**\n * We always need to check task status.\n */\n if (isAborted()) {\n return response.aborted();\n }\n\n const { ExportPagesZipPages } = await import(\n /* webpackChunkName: \"ExportPagesZipPages\" */ \"~/export/pages/ExportPagesZipPages\"\n );\n\n const exportPagesZipPages = new ExportPagesZipPages();\n return await exportPagesZipPages.execute(params);\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,6BAA6B,GAAGA,CAAA,KAAM;EAC/C,OAAO,IAAAC,kCAA2B,EAIhC;IACEC,EAAE,EAAEC,qBAAc,CAACC,QAAQ;IAC3BC,KAAK,EAAE,yCAAyC;IAChDC,WAAW,EAAE,iDAAiD;IAC9D;AACR;AACA;IACQC,aAAa,EAAE,EAAE;IACjBC,GAAG,EAAE,MAAMC,MAAM,IAAI;MACjB,MAAM;QAAEC,QAAQ;QAAEC;MAAU,CAAC,GAAGF,MAAM;MACtC;AACZ;AACA;MACY,IAAIE,SAAS,CAAC,CAAC,EAAE;QACb,OAAOD,QAAQ,CAACE,OAAO,CAAC,CAAC;MAC7B;MAEA,MAAM;QAAEC;MAAoB,CAAC,GAAG,MAAM,MAAM,CACxC,qFACJ,CAAC;MAED,MAAMC,mBAAmB,GAAG,IAAID,mBAAmB,CAAC,CAAC;MACrD,OAAO,MAAMC,mBAAmB,CAACC,OAAO,CAACN,MAAM,CAAC;IACpD;EACJ,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAAhB,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { PbImportExportContext } from "../../graphql/types";
2
+ import type { IImportPagesControllerInput, IImportPagesControllerOutput } from "../../import/pages/types";
3
+ export declare const createImportPagesControllerTask: () => import("@webiny/tasks").TaskDefinitionPlugin<PbImportExportContext, IImportPagesControllerInput, IImportPagesControllerOutput>;