@webiny/api-page-builder-import-export 0.0.0-unstable.97a151f74d → 0.0.0-unstable.98511f29f1

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 (198) hide show
  1. package/client.d.ts +2 -2
  2. package/client.js +2 -6
  3. package/client.js.map +1 -1
  4. package/export/combine/blocksHandler.d.ts +6 -0
  5. package/export/combine/blocksHandler.js +99 -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 +99 -0
  9. package/export/combine/formsHandler.js.map +1 -0
  10. package/{exportPages → export}/combine/index.d.ts +3 -2
  11. package/export/combine/index.js +42 -0
  12. package/export/combine/index.js.map +1 -0
  13. package/export/combine/pagesHandler.d.ts +6 -0
  14. package/export/combine/pagesHandler.js +99 -0
  15. package/export/combine/pagesHandler.js.map +1 -0
  16. package/export/combine/templatesHandler.d.ts +6 -0
  17. package/export/combine/templatesHandler.js +99 -0
  18. package/export/combine/templatesHandler.js.map +1 -0
  19. package/export/process/blocksHandler.d.ts +6 -0
  20. package/export/process/blocksHandler.js +167 -0
  21. package/export/process/blocksHandler.js.map +1 -0
  22. package/export/process/exporters/BlockExporter.d.ts +13 -0
  23. package/export/process/exporters/BlockExporter.js +81 -0
  24. package/export/process/exporters/BlockExporter.js.map +1 -0
  25. package/export/process/exporters/FormExporter.d.ts +9 -0
  26. package/export/process/exporters/FormExporter.js +34 -0
  27. package/export/process/exporters/FormExporter.js.map +1 -0
  28. package/export/process/exporters/PageExporter.d.ts +11 -0
  29. package/export/process/exporters/PageExporter.js +58 -0
  30. package/export/process/exporters/PageExporter.js.map +1 -0
  31. package/export/process/exporters/PageTemplateExporter.d.ts +11 -0
  32. package/export/process/exporters/PageTemplateExporter.js +56 -0
  33. package/export/process/exporters/PageTemplateExporter.js.map +1 -0
  34. package/export/process/formsHandler.d.ts +6 -0
  35. package/export/process/formsHandler.js +187 -0
  36. package/export/process/formsHandler.js.map +1 -0
  37. package/{exportPages → export}/process/index.d.ts +4 -6
  38. package/export/process/index.js +39 -0
  39. package/export/process/index.js.map +1 -0
  40. package/export/process/pagesHandler.d.ts +6 -0
  41. package/export/process/pagesHandler.js +189 -0
  42. package/export/process/pagesHandler.js.map +1 -0
  43. package/export/process/templatesHandler.d.ts +6 -0
  44. package/export/process/templatesHandler.js +166 -0
  45. package/export/process/templatesHandler.js.map +1 -0
  46. package/{exportPages → export}/s3Stream.d.ts +5 -2
  47. package/{exportPages → export}/s3Stream.js +1 -20
  48. package/export/s3Stream.js.map +1 -0
  49. package/export/utils.d.ts +2 -0
  50. package/export/utils.js +35 -0
  51. package/export/utils.js.map +1 -0
  52. package/{exportPages → export}/zipper.d.ts +6 -5
  53. package/{exportPages → export}/zipper.js +38 -49
  54. package/export/zipper.js.map +1 -0
  55. package/graphql/crud/blocks.crud.d.ts +4 -0
  56. package/graphql/crud/blocks.crud.js +130 -0
  57. package/graphql/crud/blocks.crud.js.map +1 -0
  58. package/graphql/crud/forms.crud.d.ts +4 -0
  59. package/graphql/crud/forms.crud.js +134 -0
  60. package/graphql/crud/forms.crud.js.map +1 -0
  61. package/graphql/crud/importExportTasks.crud.d.ts +5 -0
  62. package/graphql/crud/{pageImportExportTasks.crud.js → importExportTasks.crud.js} +92 -139
  63. package/graphql/crud/importExportTasks.crud.js.map +1 -0
  64. package/graphql/crud/pages.crud.d.ts +3 -2
  65. package/graphql/crud/pages.crud.js +50 -59
  66. package/graphql/crud/pages.crud.js.map +1 -1
  67. package/graphql/crud/templates.crud.d.ts +4 -0
  68. package/graphql/crud/templates.crud.js +128 -0
  69. package/graphql/crud/templates.crud.js.map +1 -0
  70. package/graphql/crud.d.ts +2 -2
  71. package/graphql/crud.js +5 -7
  72. package/graphql/crud.js.map +1 -1
  73. package/graphql/graphql/blocks.gql.d.ts +4 -0
  74. package/graphql/graphql/blocks.gql.js +52 -0
  75. package/graphql/graphql/blocks.gql.js.map +1 -0
  76. package/graphql/graphql/forms.gql.d.ts +4 -0
  77. package/graphql/graphql/forms.gql.js +60 -0
  78. package/graphql/graphql/forms.gql.js.map +1 -0
  79. package/graphql/graphql/importExportTasks.gql.d.ts +4 -0
  80. package/graphql/graphql/{pageImportExportTasks.gql.js → importExportTasks.gql.js} +18 -23
  81. package/graphql/graphql/importExportTasks.gql.js.map +1 -0
  82. package/graphql/graphql/pages.gql.d.ts +2 -2
  83. package/graphql/graphql/pages.gql.js +4 -15
  84. package/graphql/graphql/pages.gql.js.map +1 -1
  85. package/graphql/graphql/templates.gql.d.ts +4 -0
  86. package/graphql/graphql/templates.gql.js +52 -0
  87. package/graphql/graphql/templates.gql.js.map +1 -0
  88. package/graphql/graphql/utils/resolve.d.ts +1 -1
  89. package/graphql/graphql/utils/resolve.js +0 -3
  90. package/graphql/graphql/utils/resolve.js.map +1 -1
  91. package/graphql/graphql.js +5 -6
  92. package/graphql/graphql.js.map +1 -1
  93. package/graphql/index.d.ts +2 -2
  94. package/graphql/index.js +0 -5
  95. package/graphql/index.js.map +1 -1
  96. package/graphql/types.d.ts +82 -23
  97. package/graphql/types.js.map +1 -1
  98. package/import/constants.d.ts +3 -0
  99. package/import/constants.js +14 -0
  100. package/import/constants.js.map +1 -0
  101. package/import/create/blocksHandler.d.ts +3 -0
  102. package/import/create/blocksHandler.js +99 -0
  103. package/import/create/blocksHandler.js.map +1 -0
  104. package/import/create/formsHandler.d.ts +3 -0
  105. package/import/create/formsHandler.js +103 -0
  106. package/import/create/formsHandler.js.map +1 -0
  107. package/{importPages → import}/create/index.d.ts +7 -5
  108. package/import/create/index.js +42 -0
  109. package/import/create/index.js.map +1 -0
  110. package/import/create/pagesHandler.d.ts +3 -0
  111. package/import/create/pagesHandler.js +103 -0
  112. package/import/create/pagesHandler.js.map +1 -0
  113. package/import/create/templatesHandler.d.ts +3 -0
  114. package/import/create/templatesHandler.js +99 -0
  115. package/import/create/templatesHandler.js.map +1 -0
  116. package/import/process/blocks/blocksHandler.d.ts +3 -0
  117. package/import/process/blocks/blocksHandler.js +168 -0
  118. package/import/process/blocks/blocksHandler.js.map +1 -0
  119. package/import/process/blocks/importBlock.d.ts +11 -0
  120. package/import/process/blocks/importBlock.js +106 -0
  121. package/import/process/blocks/importBlock.js.map +1 -0
  122. package/import/process/forms/formsHandler.d.ts +3 -0
  123. package/import/process/forms/formsHandler.js +176 -0
  124. package/import/process/forms/formsHandler.js.map +1 -0
  125. package/import/process/forms/importForm.d.ts +9 -0
  126. package/import/process/forms/importForm.js +43 -0
  127. package/import/process/forms/importForm.js.map +1 -0
  128. package/{importPages → import}/process/index.d.ts +5 -3
  129. package/import/process/index.js +39 -0
  130. package/import/process/index.js.map +1 -0
  131. package/import/process/pages/importPage.d.ts +11 -0
  132. package/import/process/pages/importPage.js +92 -0
  133. package/import/process/pages/importPage.js.map +1 -0
  134. package/import/process/pages/pagesHandler.d.ts +3 -0
  135. package/import/process/pages/pagesHandler.js +183 -0
  136. package/import/process/pages/pagesHandler.js.map +1 -0
  137. package/import/process/templates/importTemplate.d.ts +11 -0
  138. package/import/process/templates/importTemplate.js +66 -0
  139. package/import/process/templates/importTemplate.js.map +1 -0
  140. package/import/process/templates/templatesHandler.d.ts +3 -0
  141. package/import/process/templates/templatesHandler.js +170 -0
  142. package/import/process/templates/templatesHandler.js.map +1 -0
  143. package/import/utils/deleteS3Folder.d.ts +1 -0
  144. package/import/utils/deleteS3Folder.js +19 -0
  145. package/import/utils/deleteS3Folder.js.map +1 -0
  146. package/import/utils/extractAndUploadZipFileContents.d.ts +7 -0
  147. package/import/utils/extractAndUploadZipFileContents.js +122 -0
  148. package/import/utils/extractAndUploadZipFileContents.js.map +1 -0
  149. package/import/utils/extractZipAndUploadToS3.d.ts +2 -0
  150. package/import/utils/extractZipAndUploadToS3.js +98 -0
  151. package/import/utils/extractZipAndUploadToS3.js.map +1 -0
  152. package/import/utils/getFileNameWithoutExt.d.ts +1 -0
  153. package/import/utils/getFileNameWithoutExt.js +11 -0
  154. package/import/utils/getFileNameWithoutExt.js.map +1 -0
  155. package/import/utils/index.d.ts +9 -0
  156. package/import/utils/index.js +104 -0
  157. package/import/utils/index.js.map +1 -0
  158. package/import/utils/initialStats.d.ts +7 -0
  159. package/import/utils/initialStats.js +16 -0
  160. package/import/utils/initialStats.js.map +1 -0
  161. package/import/utils/prepareDataDirMap.d.ts +6 -0
  162. package/import/utils/prepareDataDirMap.js +29 -0
  163. package/import/utils/prepareDataDirMap.js.map +1 -0
  164. package/import/utils/updateFilesInData.d.ts +8 -0
  165. package/import/utils/updateFilesInData.js +49 -0
  166. package/import/utils/updateFilesInData.js.map +1 -0
  167. package/import/utils/uploadAssets.d.ts +10 -0
  168. package/import/utils/uploadAssets.js +87 -0
  169. package/import/utils/uploadAssets.js.map +1 -0
  170. package/import/utils/uploadFilesFromS3.d.ts +3 -0
  171. package/import/utils/uploadFilesFromS3.js +19 -0
  172. package/import/utils/uploadFilesFromS3.js.map +1 -0
  173. package/mockSecurity.js +0 -3
  174. package/mockSecurity.js.map +1 -1
  175. package/package.json +34 -37
  176. package/types.d.ts +83 -65
  177. package/types.js +69 -22
  178. package/types.js.map +1 -1
  179. package/exportPages/combine/index.js +0 -114
  180. package/exportPages/combine/index.js.map +0 -1
  181. package/exportPages/process/index.js +0 -208
  182. package/exportPages/process/index.js.map +0 -1
  183. package/exportPages/s3Stream.js.map +0 -1
  184. package/exportPages/utils.d.ts +0 -13
  185. package/exportPages/utils.js +0 -113
  186. package/exportPages/utils.js.map +0 -1
  187. package/exportPages/zipper.js.map +0 -1
  188. package/graphql/crud/pageImportExportTasks.crud.d.ts +0 -5
  189. package/graphql/crud/pageImportExportTasks.crud.js.map +0 -1
  190. package/graphql/graphql/pageImportExportTasks.gql.d.ts +0 -4
  191. package/graphql/graphql/pageImportExportTasks.gql.js.map +0 -1
  192. package/importPages/create/index.js +0 -118
  193. package/importPages/create/index.js.map +0 -1
  194. package/importPages/process/index.js +0 -185
  195. package/importPages/process/index.js.map +0 -1
  196. package/importPages/utils.d.ts +0 -50
  197. package/importPages/utils.js +0 -570
  198. package/importPages/utils.js.map +0 -1
@@ -1,53 +1,47 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.default = void 0;
9
-
7
+ exports.default = exports.EXPORT_PAGES_FOLDER_KEY = void 0;
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _handlerGraphql = require("@webiny/handler-graphql");
13
-
14
10
  var _api = require("@webiny/api");
15
-
16
- var _checkBasePermissions = _interopRequireDefault(require("@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions"));
17
-
18
11
  var _types = require("../../types");
19
-
20
12
  var _client = require("../../client");
21
-
22
- var _utils = require("../../importPages/utils");
23
-
24
- var _utils2 = require("../../exportPages/utils");
25
-
26
- var _utils3 = require("@webiny/utils");
27
-
28
- const PERMISSION_NAME = "pb.page";
29
- const EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PAGES_PROCESS_HANDLER;
30
- const IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_PAGES_CREATE_HANDLER;
31
-
13
+ var _utils = require("../../import/utils");
14
+ var _utils2 = require("@webiny/utils");
15
+ var _PagesPermissions = require("@webiny/api-page-builder/graphql/crud/permissions/PagesPermissions");
16
+ const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
17
+ exports.EXPORT_PAGES_FOLDER_KEY = EXPORT_PAGES_FOLDER_KEY;
18
+ const EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER;
19
+ const IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER;
32
20
  var _default = new _api.ContextPlugin(context => {
21
+ const pagesPermissions = new _PagesPermissions.PagesPermissions({
22
+ getPermissions: () => context.security.getPermissions("pb.page"),
23
+ getIdentity: context.security.getIdentity,
24
+ fullAccessPermissionName: "pb.*"
25
+ });
33
26
  const importExportCrud = {
34
27
  async importPages({
35
28
  category: categorySlug,
36
- zipFileUrl
29
+ zipFileUrl,
30
+ meta
37
31
  }) {
38
- await (0, _checkBasePermissions.default)(context, PERMISSION_NAME, {
32
+ await pagesPermissions.ensure({
39
33
  rwd: "w"
40
- }); // Bail out early if category not found
34
+ });
41
35
 
36
+ // Bail out early if category not found
42
37
  const category = await context.pageBuilder.getCategory(categorySlug);
43
-
44
38
  if (!category) {
45
39
  throw new _handlerGraphql.NotFoundError(`Category with slug "${categorySlug}" not found.`);
46
- } // Create a task for import page
47
-
40
+ }
48
41
 
49
- const task = await context.pageBuilder.pageImportExportTask.createTask({
50
- status: _types.PageImportExportTaskStatus.PENDING,
42
+ // Create a task for import page
43
+ const task = await context.pageBuilder.importExportTask.createTask({
44
+ status: _types.ImportExportTaskStatus.PENDING,
51
45
  input: {
52
46
  category: categorySlug,
53
47
  zipFileUrl
@@ -58,7 +52,6 @@ var _default = new _api.ContextPlugin(context => {
58
52
  * ImportPages
59
53
  * importPages
60
54
  */
61
-
62
55
  await (0, _client.invokeHandlerClient)({
63
56
  context,
64
57
  name: IMPORT_PAGES_CREATE_HANDLER,
@@ -66,7 +59,9 @@ var _default = new _api.ContextPlugin(context => {
66
59
  category: categorySlug,
67
60
  zipFileUrl,
68
61
  task,
69
- identity: context.security.getIdentity()
62
+ type: "page",
63
+ identity: context.security.getIdentity(),
64
+ meta
70
65
  },
71
66
  description: "Import Pages - create"
72
67
  });
@@ -74,7 +69,6 @@ var _default = new _api.ContextPlugin(context => {
74
69
  task
75
70
  };
76
71
  },
77
-
78
72
  async exportPages({
79
73
  ids: initialPageIds,
80
74
  revisionType,
@@ -82,11 +76,11 @@ var _default = new _api.ContextPlugin(context => {
82
76
  sort,
83
77
  search
84
78
  }) {
85
- await (0, _checkBasePermissions.default)(context, PERMISSION_NAME, {
79
+ await pagesPermissions.ensure({
86
80
  rwd: "w"
87
81
  });
88
- let pageIds = initialPageIds || []; // If no ids are provided then it means we want to export all pages
89
-
82
+ let pageIds = initialPageIds || [];
83
+ // If no ids are provided then it means we want to export all pages
90
84
  if (!initialPageIds || Array.isArray(initialPageIds) && initialPageIds.length === 0) {
91
85
  pageIds = [];
92
86
  let pages = [];
@@ -94,65 +88,64 @@ var _default = new _api.ContextPlugin(context => {
94
88
  hasMoreItems: true,
95
89
  cursor: null,
96
90
  totalCount: 0
97
- }; // Paginate pages
98
-
91
+ };
92
+ // Paginate pages
99
93
  while (meta.hasMoreItems) {
100
94
  [pages, meta] = await context.pageBuilder.listLatestPages({
101
95
  after: meta.cursor,
102
96
  where: where,
103
97
  sort: sort,
104
98
  search: search
105
- }); // Save page ids
106
-
99
+ });
100
+ // Save page ids
107
101
  pages.forEach(page => pageIds.push(page.id));
108
102
  }
109
103
  }
110
-
111
104
  if (pageIds.length === 0) {
112
105
  throw new _error.default("Cannot export pages - no pages found for provided inputs.", "EMPTY_EXPORT_NO_PAGES_FOUND");
113
- } // Create the main task for page export.
114
-
106
+ }
115
107
 
116
- const task = await context.pageBuilder.pageImportExportTask.createTask({
117
- status: _types.PageImportExportTaskStatus.PENDING
108
+ // Create the main task for page export.
109
+ const task = await context.pageBuilder.importExportTask.createTask({
110
+ status: _types.ImportExportTaskStatus.PENDING
118
111
  });
119
- const exportPagesDataKey = `${_utils2.EXPORT_PAGES_FOLDER_KEY}/${task.id}`; // For each page create a sub task and invoke the process handler.
120
-
112
+ const exportPagesDataKey = `${EXPORT_PAGES_FOLDER_KEY}/${task.id}`;
113
+ // For each page create a sub-task and invoke the process handler.
121
114
  for (let i = 0; i < pageIds.length; i++) {
122
- const pageId = pageIds[i]; // Create sub task.
123
-
124
- await context.pageBuilder.pageImportExportTask.createSubTask(task.id, (0, _utils3.zeroPad)(i + 1, 5), {
125
- status: _types.PageImportExportTaskStatus.PENDING,
115
+ const pageId = pageIds[i];
116
+ // Create sub-task.
117
+ await context.pageBuilder.importExportTask.createSubTask(task.id, (0, _utils2.zeroPad)(i + 1, 5), {
118
+ status: _types.ImportExportTaskStatus.PENDING,
126
119
  input: {
127
120
  pageId,
128
121
  exportPagesDataKey,
129
122
  revisionType
130
123
  }
131
124
  });
132
- } // Update main task status.
133
-
134
-
135
- await context.pageBuilder.pageImportExportTask.updateTask(task.id, {
136
- status: _types.PageImportExportTaskStatus.PROCESSING,
125
+ }
126
+ // Update main task status.
127
+ await context.pageBuilder.importExportTask.updateTask(task.id, {
128
+ status: _types.ImportExportTaskStatus.PROCESSING,
137
129
  stats: (0, _utils.initialStats)(pageIds.length),
138
130
  input: {
139
131
  exportPagesDataKey,
140
132
  revisionType
141
133
  }
142
134
  });
135
+
143
136
  /**
144
137
  * Export Pages
145
138
  * ExportPages
146
139
  * exportPages
147
140
  */
148
141
  // Invoke handler.
149
-
150
142
  await (0, _client.invokeHandlerClient)({
151
143
  context,
152
144
  name: EXPORT_PAGES_PROCESS_HANDLER,
153
145
  payload: {
154
146
  taskId: task.id,
155
147
  subTaskIndex: 1,
148
+ type: "page",
156
149
  identity: context.security.getIdentity()
157
150
  },
158
151
  description: "Export pages - process"
@@ -161,10 +154,8 @@ var _default = new _api.ContextPlugin(context => {
161
154
  task
162
155
  };
163
156
  }
164
-
165
- }; // Modify context
166
-
157
+ };
158
+ // Modify context
167
159
  context.pageBuilder.pages = importExportCrud;
168
160
  });
169
-
170
161
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["PERMISSION_NAME","EXPORT_PAGES_PROCESS_HANDLER","process","env","IMPORT_PAGES_CREATE_HANDLER","ContextPlugin","context","importExportCrud","importPages","category","categorySlug","zipFileUrl","checkBasePermissions","rwd","pageBuilder","getCategory","NotFoundError","task","pageImportExportTask","createTask","status","PageImportExportTaskStatus","PENDING","input","invokeHandlerClient","name","payload","identity","security","getIdentity","description","exportPages","ids","initialPageIds","revisionType","where","sort","search","pageIds","Array","isArray","length","pages","meta","hasMoreItems","cursor","totalCount","listLatestPages","after","forEach","page","push","id","WebinyError","exportPagesDataKey","EXPORT_PAGES_FOLDER_KEY","i","pageId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex"],"sources":["pages.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport checkBasePermissions from \"@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions\";\nimport {\n PageImportExportTaskStatus,\n PagesImportExportCrud,\n PbPageImportExportContext\n} from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/importPages/create\";\nimport { initialStats } from \"~/importPages/utils\";\nimport { Payload as ExportPagesProcessHandlerPayload } from \"~/exportPages/process\";\nimport { EXPORT_PAGES_FOLDER_KEY } from \"~/exportPages/utils\";\nimport { MetaResponse } from \"@webiny/api-page-builder/types\";\nimport { zeroPad } from \"@webiny/utils\";\n\nconst PERMISSION_NAME = \"pb.page\";\nconst EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PAGES_PROCESS_HANDLER as string;\nconst IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_PAGES_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbPageImportExportContext>(context => {\n const importExportCrud: PagesImportExportCrud = {\n async importPages({ category: categorySlug, zipFileUrl }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n\n // Bail out early if category not found\n const category = await context.pageBuilder.getCategory(categorySlug);\n if (!category) {\n throw new NotFoundError(`Category with slug \"${categorySlug}\" not found.`);\n }\n\n // Create a task for import page\n const task = await context.pageBuilder.pageImportExportTask.createTask({\n status: PageImportExportTaskStatus.PENDING,\n input: {\n category: categorySlug,\n zipFileUrl\n }\n });\n /**\n * Import Pages\n * ImportPages\n * importPages\n */\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_PAGES_CREATE_HANDLER,\n payload: {\n category: categorySlug,\n zipFileUrl,\n task,\n identity: context.security.getIdentity()\n },\n description: \"Import Pages - create\"\n });\n\n return {\n task\n };\n },\n\n async exportPages({ ids: initialPageIds, revisionType, where, sort, search }) {\n await checkBasePermissions(context, PERMISSION_NAME, {\n rwd: \"w\"\n });\n let pageIds: string[] = initialPageIds || [];\n // If no ids are provided then it means we want to export all pages\n if (!initialPageIds || (Array.isArray(initialPageIds) && initialPageIds.length === 0)) {\n pageIds = [];\n let pages = [];\n let meta: MetaResponse = {\n hasMoreItems: true,\n cursor: null,\n totalCount: 0\n };\n // Paginate pages\n while (meta.hasMoreItems) {\n [pages, meta] = await context.pageBuilder.listLatestPages({\n after: meta.cursor,\n where: where,\n sort: sort,\n search: search\n });\n // Save page ids\n pages.forEach(page => pageIds.push(page.id));\n }\n }\n\n if (pageIds.length === 0) {\n throw new WebinyError(\n \"Cannot export pages - no pages found for provided inputs.\",\n \"EMPTY_EXPORT_NO_PAGES_FOUND\"\n );\n }\n\n // Create the main task for page export.\n const task = await context.pageBuilder.pageImportExportTask.createTask({\n status: PageImportExportTaskStatus.PENDING\n });\n const exportPagesDataKey = `${EXPORT_PAGES_FOLDER_KEY}/${task.id}`;\n // For each page create a sub task and invoke the process handler.\n for (let i = 0; i < pageIds.length; i++) {\n const pageId = pageIds[i];\n // Create sub task.\n await context.pageBuilder.pageImportExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: PageImportExportTaskStatus.PENDING,\n input: {\n pageId,\n exportPagesDataKey,\n revisionType\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.pageImportExportTask.updateTask(task.id, {\n status: PageImportExportTaskStatus.PROCESSING,\n stats: initialStats(pageIds.length),\n input: {\n exportPagesDataKey,\n revisionType\n }\n });\n\n /**\n * Export Pages\n * ExportPages\n * exportPages\n */\n // Invoke handler.\n await invokeHandlerClient<ExportPagesProcessHandlerPayload>({\n context,\n name: EXPORT_PAGES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n identity: context.security.getIdentity()\n },\n description: \"Export pages - process\"\n });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.pages = importExportCrud;\n});\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AAEA;;AAEA;;AAEA,MAAMA,eAAe,GAAG,SAAxB;AACA,MAAMC,4BAA4B,GAAGC,OAAO,CAACC,GAAR,CAAYF,4BAAjD;AACA,MAAMG,2BAA2B,GAAGF,OAAO,CAACC,GAAR,CAAYC,2BAAhD;;eAEe,IAAIC,kBAAJ,CAA6CC,OAAO,IAAI;EACnE,MAAMC,gBAAuC,GAAG;IAC5C,MAAMC,WAAN,CAAkB;MAAEC,QAAQ,EAAEC,YAAZ;MAA0BC;IAA1B,CAAlB,EAA0D;MACtD,MAAM,IAAAC,6BAAA,EAAqBN,OAArB,EAA8BN,eAA9B,EAA+C;QACjDa,GAAG,EAAE;MAD4C,CAA/C,CAAN,CADsD,CAKtD;;MACA,MAAMJ,QAAQ,GAAG,MAAMH,OAAO,CAACQ,WAAR,CAAoBC,WAApB,CAAgCL,YAAhC,CAAvB;;MACA,IAAI,CAACD,QAAL,EAAe;QACX,MAAM,IAAIO,6BAAJ,CAAmB,uBAAsBN,YAAa,cAAtD,CAAN;MACH,CATqD,CAWtD;;;MACA,MAAMO,IAAI,GAAG,MAAMX,OAAO,CAACQ,WAAR,CAAoBI,oBAApB,CAAyCC,UAAzC,CAAoD;QACnEC,MAAM,EAAEC,iCAAA,CAA2BC,OADgC;QAEnEC,KAAK,EAAE;UACHd,QAAQ,EAAEC,YADP;UAEHC;QAFG;MAF4D,CAApD,CAAnB;MAOA;AACZ;AACA;AACA;AACA;;MACY,MAAM,IAAAa,2BAAA,EAA0C;QAC5ClB,OAD4C;QAE5CmB,IAAI,EAAErB,2BAFsC;QAG5CsB,OAAO,EAAE;UACLjB,QAAQ,EAAEC,YADL;UAELC,UAFK;UAGLM,IAHK;UAILU,QAAQ,EAAErB,O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,EAAErB,OAAO,CAACsB,QAAR,CAAiBC,WAAjB;QAHL,CAH+C;QAQxDC,WAAW,EAAE;MAR2C,CAAtD,CAAN;MAWA,OAAO;QAAEb;MAAF,CAAP;IACH;;EA9H2C,CAAhD,CADmE,CAiInE;;EACAX,OAAO,CAACQ,WAAR,CAAoB4B,KAApB,GAA4BnC,gBAA5B;AACH,CAnIc,C"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_handlerGraphql","_api","_types","_client","_utils","_utils2","_PagesPermissions","EXPORT_PAGES_FOLDER_KEY","exports","EXPORT_PAGES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_PAGES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","_default","ContextPlugin","context","pagesPermissions","PagesPermissions","getPermissions","security","getIdentity","fullAccessPermissionName","importExportCrud","importPages","category","categorySlug","zipFileUrl","meta","ensure","rwd","pageBuilder","getCategory","NotFoundError","task","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","invokeHandlerClient","name","payload","type","identity","description","exportPages","ids","initialPageIds","revisionType","where","sort","search","pageIds","Array","isArray","length","pages","hasMoreItems","cursor","totalCount","listLatestPages","after","forEach","page","push","id","WebinyError","exportPagesDataKey","i","pageId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex","default"],"sources":["pages.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ImportExportTaskStatus, PagesImportExportCrud, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportPagesProcessHandlerPayload } from \"~/export/process\";\nimport { MetaResponse } from \"@webiny/api-page-builder/types\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { PagesPermissions } from \"@webiny/api-page-builder/graphql/crud/permissions/PagesPermissions\";\n\nexport const EXPORT_PAGES_FOLDER_KEY = \"WEBINY_PB_EXPORT_PAGES\";\nconst EXPORT_PAGES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_PAGES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const pagesPermissions = new PagesPermissions({\n getPermissions: () => context.security.getPermissions(\"pb.page\"),\n getIdentity: context.security.getIdentity,\n fullAccessPermissionName: \"pb.*\"\n });\n\n const importExportCrud: PagesImportExportCrud = {\n async importPages({ category: categorySlug, zipFileUrl, meta }) {\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n // Bail out early if category not found\n const category = await context.pageBuilder.getCategory(categorySlug);\n if (!category) {\n throw new NotFoundError(`Category with slug \"${categorySlug}\" not found.`);\n }\n\n // Create a task for import page\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n category: categorySlug,\n zipFileUrl\n }\n });\n /**\n * Import Pages\n * ImportPages\n * importPages\n */\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_PAGES_CREATE_HANDLER,\n payload: {\n category: categorySlug,\n zipFileUrl,\n task,\n type: \"page\",\n identity: context.security.getIdentity(),\n meta\n },\n description: \"Import Pages - create\"\n });\n\n return {\n task\n };\n },\n\n async exportPages({ ids: initialPageIds, revisionType, where, sort, search }) {\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n let pageIds: string[] = initialPageIds || [];\n // If no ids are provided then it means we want to export all pages\n if (!initialPageIds || (Array.isArray(initialPageIds) && initialPageIds.length === 0)) {\n pageIds = [];\n let pages = [];\n let meta: MetaResponse = {\n hasMoreItems: true,\n cursor: null,\n totalCount: 0\n };\n // Paginate pages\n while (meta.hasMoreItems) {\n [pages, meta] = await context.pageBuilder.listLatestPages({\n after: meta.cursor,\n where: where,\n sort: sort,\n search: search\n });\n // Save page ids\n pages.forEach(page => pageIds.push(page.id));\n }\n }\n\n if (pageIds.length === 0) {\n throw new WebinyError(\n \"Cannot export pages - no pages found for provided inputs.\",\n \"EMPTY_EXPORT_NO_PAGES_FOUND\"\n );\n }\n\n // Create the main task for page export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportPagesDataKey = `${EXPORT_PAGES_FOLDER_KEY}/${task.id}`;\n // For each page create a sub-task and invoke the process handler.\n for (let i = 0; i < pageIds.length; i++) {\n const pageId = pageIds[i];\n // Create sub-task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n pageId,\n exportPagesDataKey,\n revisionType\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(pageIds.length),\n input: {\n exportPagesDataKey,\n revisionType\n }\n });\n\n /**\n * Export Pages\n * ExportPages\n * exportPages\n */\n // Invoke handler.\n await invokeHandlerClient<ExportPagesProcessHandlerPayload>({\n context,\n name: EXPORT_PAGES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"page\",\n identity: context.security.getIdentity()\n },\n description: \"Export pages - process\"\n });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.pages = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAGA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAEO,MAAMQ,uBAAuB,GAAG,wBAAwB;AAACC,OAAA,CAAAD,uBAAA,GAAAA,u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,CAAC;IACnB;EACJ,CAAC;EACD;EACAlB,OAAO,CAACe,WAAW,CAAC2B,KAAK,GAAGnC,gBAAgB;AAChD,CAAC,CAAC;AAAAhB,OAAA,CAAAyE,OAAA,GAAAlE,QAAA"}
@@ -0,0 +1,4 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { PbImportExportContext } from "../../types";
3
+ declare const _default: ContextPlugin<PbImportExportContext>;
4
+ export default _default;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _api = require("@webiny/api");
10
+ var _types = require("../../types");
11
+ var _client = require("../../client");
12
+ var _utils = require("../../import/utils");
13
+ var _utils2 = require("@webiny/utils");
14
+ var _PageTemplatesPermissions = require("@webiny/api-page-builder/graphql/crud/permissions/PageTemplatesPermissions");
15
+ const EXPORT_TEMPLATES_FOLDER_KEY = "WEBINY_PB_EXPORT_TEMPLATE";
16
+ const EXPORT_TEMPLATES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER;
17
+ const IMPORT_TEMPLATES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER;
18
+ var _default = new _api.ContextPlugin(context => {
19
+ const pagesPermissions = new _PageTemplatesPermissions.PageTemplatesPermissions({
20
+ getPermissions: () => context.security.getPermissions("pb.template"),
21
+ getIdentity: context.security.getIdentity,
22
+ fullAccessPermissionName: "pb.*"
23
+ });
24
+ const importExportCrud = {
25
+ async importTemplates({
26
+ zipFileUrl
27
+ }) {
28
+ await pagesPermissions.ensure({
29
+ rwd: "w"
30
+ });
31
+
32
+ // Create a task for import template
33
+ const task = await context.pageBuilder.importExportTask.createTask({
34
+ status: _types.ImportExportTaskStatus.PENDING,
35
+ input: {
36
+ zipFileUrl
37
+ }
38
+ });
39
+ /**
40
+ * Import Templates
41
+ * ImportTemplates
42
+ * importTemplates
43
+ */
44
+ await (0, _client.invokeHandlerClient)({
45
+ context,
46
+ name: IMPORT_TEMPLATES_CREATE_HANDLER,
47
+ payload: {
48
+ zipFileUrl,
49
+ task,
50
+ type: "template",
51
+ identity: context.security.getIdentity()
52
+ },
53
+ description: "Import Templates - create"
54
+ });
55
+ return {
56
+ task
57
+ };
58
+ },
59
+ async exportTemplates({
60
+ ids: initialTemplateIds
61
+ }) {
62
+ await pagesPermissions.ensure({
63
+ rwd: "w"
64
+ });
65
+ let templateIds = initialTemplateIds || [];
66
+ // If no ids are provided then it means we want to export all templates
67
+ if (!initialTemplateIds || Array.isArray(initialTemplateIds) && initialTemplateIds.length === 0) {
68
+ templateIds = [];
69
+ const templates = await context.pageBuilder.listPageTemplates();
70
+ // Save template ids
71
+ templates.forEach(template => templateIds.push(template.id));
72
+ }
73
+ if (templateIds.length === 0) {
74
+ throw new _error.default("Cannot export templates - no templates found for provided inputs.", "EMPTY_EXPORT_NO_TEMPLATES_FOUND");
75
+ }
76
+
77
+ // Create the main task for templates export.
78
+ const task = await context.pageBuilder.importExportTask.createTask({
79
+ status: _types.ImportExportTaskStatus.PENDING
80
+ });
81
+ const exportTemplatesDataKey = `${EXPORT_TEMPLATES_FOLDER_KEY}/${task.id}`;
82
+ // For each template create a sub task and invoke the process handler.
83
+ for (let i = 0; i < templateIds.length; i++) {
84
+ const templateId = templateIds[i];
85
+ // Create sub task.
86
+ await context.pageBuilder.importExportTask.createSubTask(task.id, (0, _utils2.zeroPad)(i + 1, 5), {
87
+ status: _types.ImportExportTaskStatus.PENDING,
88
+ input: {
89
+ templateId,
90
+ exportTemplatesDataKey
91
+ }
92
+ });
93
+ }
94
+ // Update main task status.
95
+ await context.pageBuilder.importExportTask.updateTask(task.id, {
96
+ status: _types.ImportExportTaskStatus.PROCESSING,
97
+ stats: (0, _utils.initialStats)(templateIds.length),
98
+ input: {
99
+ exportTemplatesDataKey
100
+ }
101
+ });
102
+
103
+ /**
104
+ * Export Templates
105
+ * ExportTemplates
106
+ * exportTemplates
107
+ */
108
+ // Invoke handler.
109
+ await (0, _client.invokeHandlerClient)({
110
+ context,
111
+ name: EXPORT_TEMPLATES_PROCESS_HANDLER,
112
+ payload: {
113
+ taskId: task.id,
114
+ subTaskIndex: 1,
115
+ type: "template",
116
+ identity: context.security.getIdentity()
117
+ },
118
+ description: "Export templates - process"
119
+ });
120
+ return {
121
+ task
122
+ };
123
+ }
124
+ };
125
+ // Modify context
126
+ context.pageBuilder.templates = importExportCrud;
127
+ });
128
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_api","_types","_client","_utils","_utils2","_PageTemplatesPermissions","EXPORT_TEMPLATES_FOLDER_KEY","EXPORT_TEMPLATES_PROCESS_HANDLER","process","env","EXPORT_PROCESS_HANDLER","IMPORT_TEMPLATES_CREATE_HANDLER","IMPORT_CREATE_HANDLER","_default","ContextPlugin","context","pagesPermissions","PageTemplatesPermissions","getPermissions","security","getIdentity","fullAccessPermissionName","importExportCrud","importTemplates","zipFileUrl","ensure","rwd","task","pageBuilder","importExportTask","createTask","status","ImportExportTaskStatus","PENDING","input","invokeHandlerClient","name","payload","type","identity","description","exportTemplates","ids","initialTemplateIds","templateIds","Array","isArray","length","templates","listPageTemplates","forEach","template","push","id","WebinyError","exportTemplatesDataKey","i","templateId","createSubTask","zeroPad","updateTask","PROCESSING","stats","initialStats","taskId","subTaskIndex","exports","default"],"sources":["templates.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ImportExportTaskStatus, TemplatesImportExportCrud, PbImportExportContext } from \"~/types\";\nimport { invokeHandlerClient } from \"~/client\";\nimport { Payload as CreateHandlerPayload } from \"~/import/create\";\nimport { initialStats } from \"~/import/utils\";\nimport { Payload as ExportTemplatesProcessHandlerPayload } from \"~/export/process\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { PageTemplatesPermissions } from \"@webiny/api-page-builder/graphql/crud/permissions/PageTemplatesPermissions\";\n\nconst EXPORT_TEMPLATES_FOLDER_KEY = \"WEBINY_PB_EXPORT_TEMPLATE\";\nconst EXPORT_TEMPLATES_PROCESS_HANDLER = process.env.EXPORT_PROCESS_HANDLER as string;\nconst IMPORT_TEMPLATES_CREATE_HANDLER = process.env.IMPORT_CREATE_HANDLER as string;\n\nexport default new ContextPlugin<PbImportExportContext>(context => {\n const pagesPermissions = new PageTemplatesPermissions({\n getPermissions: () => context.security.getPermissions(\"pb.template\"),\n getIdentity: context.security.getIdentity,\n fullAccessPermissionName: \"pb.*\"\n });\n\n const importExportCrud: TemplatesImportExportCrud = {\n async importTemplates({ zipFileUrl }) {\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n // Create a task for import template\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING,\n input: {\n zipFileUrl\n }\n });\n /**\n * Import Templates\n * ImportTemplates\n * importTemplates\n */\n await invokeHandlerClient<CreateHandlerPayload>({\n context,\n name: IMPORT_TEMPLATES_CREATE_HANDLER,\n payload: {\n zipFileUrl,\n task,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Import Templates - create\"\n });\n\n return {\n task\n };\n },\n\n async exportTemplates({ ids: initialTemplateIds }) {\n await pagesPermissions.ensure({ rwd: \"w\" });\n\n let templateIds: string[] = initialTemplateIds || [];\n // If no ids are provided then it means we want to export all templates\n if (\n !initialTemplateIds ||\n (Array.isArray(initialTemplateIds) && initialTemplateIds.length === 0)\n ) {\n templateIds = [];\n const templates = await context.pageBuilder.listPageTemplates();\n // Save template ids\n templates.forEach(template => templateIds.push(template.id));\n }\n\n if (templateIds.length === 0) {\n throw new WebinyError(\n \"Cannot export templates - no templates found for provided inputs.\",\n \"EMPTY_EXPORT_NO_TEMPLATES_FOUND\"\n );\n }\n\n // Create the main task for templates export.\n const task = await context.pageBuilder.importExportTask.createTask({\n status: ImportExportTaskStatus.PENDING\n });\n const exportTemplatesDataKey = `${EXPORT_TEMPLATES_FOLDER_KEY}/${task.id}`;\n // For each template create a sub task and invoke the process handler.\n for (let i = 0; i < templateIds.length; i++) {\n const templateId = templateIds[i];\n // Create sub task.\n await context.pageBuilder.importExportTask.createSubTask(\n task.id,\n zeroPad(i + 1, 5),\n {\n status: ImportExportTaskStatus.PENDING,\n input: {\n templateId,\n exportTemplatesDataKey\n }\n }\n );\n }\n // Update main task status.\n await context.pageBuilder.importExportTask.updateTask(task.id, {\n status: ImportExportTaskStatus.PROCESSING,\n stats: initialStats(templateIds.length),\n input: {\n exportTemplatesDataKey\n }\n });\n\n /**\n * Export Templates\n * ExportTemplates\n * exportTemplates\n */\n // Invoke handler.\n await invokeHandlerClient<ExportTemplatesProcessHandlerPayload>({\n context,\n name: EXPORT_TEMPLATES_PROCESS_HANDLER,\n payload: {\n taskId: task.id,\n subTaskIndex: 1,\n type: \"template\",\n identity: context.security.getIdentity()\n },\n description: \"Export templates - process\"\n });\n\n return { task };\n }\n };\n // Modify context\n context.pageBuilder.templates = importExportCrud;\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAN,OAAA;AAEA,MAAMO,2BAA2B,GAAG,2BAA2B;AAC/D,MAAMC,gCAAgC,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAgC;AACrF,MAAMC,+BAA+B,GAAGH,OAAO,CAACC,GAAG,CAACG,qBAA+B;AAAC,IAAAC,QAAA,GAErE,IAAIC,kBAAa,CAAwBC,OAAO,IAAI;EAC/D,MAAMC,gBAAgB,GAAG,IAAIC,kDAAwB,CAAC;IAClDC,cAAc,EAAEA,CAAA,KAAMH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AE7B,gCAAgC;QACtC8B,OAAO,EAAE;UACL2B,MAAM,EAAErC,IAAI,CAAC0B,EAAE;UACfY,YAAY,EAAE,CAAC;UACf3B,IAAI,EAAE,UAAU;UAChBC,QAAQ,EAAExB,OAAO,CAACI,QAAQ,CAACC,WAAW,CAAC;QAC3C,CAAC;QACDoB,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,OAAO;QAAEb;MAAK,CAAC;IACnB;EACJ,CAAC;EACD;EACAZ,OAAO,CAACa,WAAW,CAACoB,SAAS,GAAG1B,gBAAgB;AACpD,CAAC,CAAC;AAAA4C,OAAA,CAAAC,OAAA,GAAAtD,QAAA"}
package/graphql/crud.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { PageImportExportPluginsParams } from "./types";
2
- declare const _default: (params: PageImportExportPluginsParams) => import("@webiny/api").ContextPlugin<import("~/graphql/types").PbPageImportExportContext>[];
1
+ import { ImportExportPluginsParams } from "./types";
2
+ declare const _default: (params: ImportExportPluginsParams) => import("@webiny/api").ContextPlugin<import("~/graphql/types").PbImportExportContext>[];
3
3
  export default _default;
package/graphql/crud.js CHANGED
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
8
+ var _blocks = _interopRequireDefault(require("./crud/blocks.crud"));
9
+ var _forms = _interopRequireDefault(require("./crud/forms.crud"));
10
10
  var _pages = _interopRequireDefault(require("./crud/pages.crud"));
11
-
12
- var _pageImportExportTasks = _interopRequireDefault(require("./crud/pageImportExportTasks.crud"));
13
-
14
- var _default = params => [_pages.default, (0, _pageImportExportTasks.default)(params)];
15
-
11
+ var _templates = _interopRequireDefault(require("./crud/templates.crud"));
12
+ var _importExportTasks = _interopRequireDefault(require("./crud/importExportTasks.crud"));
13
+ var _default = params => [_blocks.default, _forms.default, _pages.default, _templates.default, (0, _importExportTasks.default)(params)];
16
14
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["params","pages","pageImportExportTask"],"sources":["crud.ts"],"sourcesContent":["import pages from \"./crud/pages.crud\";\nimport pageImportExportTask from \"./crud/pageImportExportTasks.crud\";\nimport { PageImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: PageImportExportPluginsParams) => [pages, pageImportExportTask(params)];\n"],"mappings":";;;;;;;;;AAAA;;AACA;;eAGgBA,MAAD,IAA2C,CAACC,cAAD,EAAQ,IAAAC,8BAAA,EAAqBF,MAArB,CAAR,C"}
1
+ {"version":3,"names":["_blocks","_interopRequireDefault","require","_forms","_pages","_templates","_importExportTasks","_default","params","blocks","forms","pages","templates","importExportTask","exports","default"],"sources":["crud.ts"],"sourcesContent":["import blocks from \"./crud/blocks.crud\";\nimport forms from \"./crud/forms.crud\";\nimport pages from \"./crud/pages.crud\";\nimport templates from \"./crud/templates.crud\";\nimport importExportTask from \"./crud/importExportTasks.crud\";\nimport { ImportExportPluginsParams } from \"~/graphql/types\";\n\nexport default (params: ImportExportPluginsParams) => [\n blocks,\n forms,\n pages,\n templates,\n importExportTask(params as ImportExportPluginsParams)\n];\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,kBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAA6D,IAAAK,QAAA,GAG7CC,MAAiC,IAAK,CAClDC,eAAM,EACNC,cAAK,EACLC,cAAK,EACLC,kBAAS,EACT,IAAAC,0BAAgB,EAACL,MAAmC,CAAC,CACxD;AAAAM,OAAA,CAAAC,OAAA,GAAAR,QAAA"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
2
+ import { PbImportExportContext } from "../types";
3
+ declare const plugin: GraphQLSchemaPlugin<PbImportExportContext>;
4
+ export default plugin;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _resolve = _interopRequireDefault(require("./utils/resolve"));
9
+ const plugin = {
10
+ type: "graphql-schema",
11
+ schema: {
12
+ typeDefs: /* GraphQL */`
13
+ type PbExportBlockData {
14
+ task: PbImportExportTask
15
+ }
16
+
17
+ type PbExportBlockResponse {
18
+ data: PbExportBlockData
19
+ error: PbError
20
+ }
21
+
22
+ type PbImportBlockData {
23
+ task: PbImportExportTask
24
+ }
25
+
26
+ type PbImportBlockResponse {
27
+ data: PbImportBlockData
28
+ error: PbError
29
+ }
30
+
31
+ extend type PbMutation {
32
+ # Export blocks
33
+ exportBlocks(ids: [ID!], where: PbListPageBlocksWhereInput): PbExportBlockResponse
34
+
35
+ # Import blocks
36
+ importBlocks(zipFileUrl: String): PbImportBlockResponse
37
+ }
38
+ `,
39
+ resolvers: {
40
+ PbMutation: {
41
+ exportBlocks: async (_, args, context) => {
42
+ return (0, _resolve.default)(() => context.pageBuilder.blocks.exportBlocks(args));
43
+ },
44
+ importBlocks: async (_, args, context) => {
45
+ return (0, _resolve.default)(() => context.pageBuilder.blocks.importBlocks(args));
46
+ }
47
+ }
48
+ }
49
+ }
50
+ };
51
+ var _default = plugin;
52
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","PbMutation","exportBlocks","_","args","context","resolve","pageBuilder","blocks","importBlocks","_default","exports","default"],"sources":["blocks.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type PbExportBlockData {\n task: PbImportExportTask\n }\n\n type PbExportBlockResponse {\n data: PbExportBlockData\n error: PbError\n }\n\n type PbImportBlockData {\n task: PbImportExportTask\n }\n\n type PbImportBlockResponse {\n data: PbImportBlockData\n error: PbError\n }\n\n extend type PbMutation {\n # Export blocks\n exportBlocks(ids: [ID!], where: PbListPageBlocksWhereInput): PbExportBlockResponse\n\n # Import blocks\n importBlocks(zipFileUrl: String): PbImportBlockResponse\n }\n `,\n resolvers: {\n PbMutation: {\n exportBlocks: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.blocks.exportBlocks(args));\n },\n\n importBlocks: async (_, args: any, context) => {\n return resolve(() => context.pageBuilder.blocks.importBlocks(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,YAAY,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC3C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,MAAM,CAACN,YAAY,CAACE,IAAI,CAAC,CAAC;QACvE,CAAC;QAEDK,YAAY,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC3C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,MAAM,CAACC,YAAY,CAACL,IAAI,CAAC,CAAC;QACvE;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
2
+ import { PbImportExportContext } from "../types";
3
+ declare const plugin: GraphQLSchemaPlugin<PbImportExportContext>;
4
+ export default plugin;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _resolve = _interopRequireDefault(require("./utils/resolve"));
9
+ const plugin = {
10
+ type: "graphql-schema",
11
+ schema: {
12
+ typeDefs: /* GraphQL */`
13
+ type FbExportFormData {
14
+ task: PbImportExportTask
15
+ }
16
+
17
+ type FbExportFormResponse {
18
+ data: FbExportFormData
19
+ error: FbError
20
+ }
21
+
22
+ type FbImportFormData {
23
+ task: PbImportExportTask
24
+ }
25
+
26
+ type FbImportFormResponse {
27
+ data: FbImportFormData
28
+ error: FbError
29
+ }
30
+
31
+ enum FbExportFormRevisionType {
32
+ published
33
+ latest
34
+ }
35
+
36
+ extend type FbMutation {
37
+ # Export forms
38
+ exportForms(
39
+ ids: [ID!]
40
+ revisionType: FbExportFormRevisionType!
41
+ ): FbExportFormResponse
42
+
43
+ # Import forms
44
+ importForms(zipFileUrl: String, meta: JSON): FbImportFormResponse
45
+ }
46
+ `,
47
+ resolvers: {
48
+ FbMutation: {
49
+ exportForms: async (_, args, context) => {
50
+ return (0, _resolve.default)(() => context.formBuilder.forms.exportForms(args));
51
+ },
52
+ importForms: async (_, args, context) => {
53
+ return (0, _resolve.default)(() => context.formBuilder.forms.importForms(args));
54
+ }
55
+ }
56
+ }
57
+ }
58
+ };
59
+ var _default = plugin;
60
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_resolve","_interopRequireDefault","require","plugin","type","schema","typeDefs","resolvers","FbMutation","exportForms","_","args","context","resolve","formBuilder","forms","importForms","_default","exports","default"],"sources":["forms.gql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { PbImportExportContext } from \"../types\";\nimport resolve from \"./utils/resolve\";\n\nconst plugin: GraphQLSchemaPlugin<PbImportExportContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type FbExportFormData {\n task: PbImportExportTask\n }\n\n type FbExportFormResponse {\n data: FbExportFormData\n error: FbError\n }\n\n type FbImportFormData {\n task: PbImportExportTask\n }\n\n type FbImportFormResponse {\n data: FbImportFormData\n error: FbError\n }\n\n enum FbExportFormRevisionType {\n published\n latest\n }\n\n extend type FbMutation {\n # Export forms\n exportForms(\n ids: [ID!]\n revisionType: FbExportFormRevisionType!\n ): FbExportFormResponse\n\n # Import forms\n importForms(zipFileUrl: String, meta: JSON): FbImportFormResponse\n }\n `,\n resolvers: {\n FbMutation: {\n exportForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.exportForms(args));\n },\n\n importForms: async (_, args: any, context) => {\n return resolve(() => context.formBuilder.forms.importForms(args));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,MAAkD,GAAG;EACvDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,UAAU,EAAE;QACRC,WAAW,EAAE,MAAAA,CAAOC,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACN,WAAW,CAACE,IAAI,CAAC,CAAC;QACrE,CAAC;QAEDK,WAAW,EAAE,MAAAA,CAAON,CAAC,EAAEC,IAAS,EAAEC,OAAO,KAAK;UAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,WAAW,CAACC,KAAK,CAACC,WAAW,CAACL,IAAI,CAAC,CAAC;QACrE;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,IAAAM,QAAA,GAEad,MAAM;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -0,0 +1,4 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
2
+ import { PbImportExportContext } from "../types";
3
+ declare const plugin: GraphQLSchemaPlugin<PbImportExportContext>;
4
+ export default plugin;