@webiny/api-page-builder-import-export 0.0.0-mt-3 → 0.0.0-unstable.085ff6572f
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.
- package/client.d.ts +8 -0
- package/client.js +43 -0
- package/client.js.map +1 -0
- package/export/combine/blocksHandler.d.ts +6 -0
- package/export/combine/blocksHandler.js +99 -0
- package/export/combine/blocksHandler.js.map +1 -0
- package/export/combine/formsHandler.d.ts +6 -0
- package/export/combine/formsHandler.js +99 -0
- package/export/combine/formsHandler.js.map +1 -0
- package/export/combine/index.d.ts +16 -0
- package/export/combine/index.js +42 -0
- package/export/combine/index.js.map +1 -0
- package/export/combine/pagesHandler.d.ts +6 -0
- package/export/combine/pagesHandler.js +99 -0
- package/export/combine/pagesHandler.js.map +1 -0
- package/export/combine/templatesHandler.d.ts +6 -0
- package/export/combine/templatesHandler.js +99 -0
- package/export/combine/templatesHandler.js.map +1 -0
- package/export/process/blocksHandler.d.ts +6 -0
- package/export/process/blocksHandler.js +162 -0
- package/export/process/blocksHandler.js.map +1 -0
- package/export/process/formsHandler.d.ts +6 -0
- package/export/process/formsHandler.js +187 -0
- package/export/process/formsHandler.js.map +1 -0
- package/export/process/index.d.ts +20 -0
- package/export/process/index.js +39 -0
- package/export/process/index.js.map +1 -0
- package/export/process/pagesHandler.d.ts +6 -0
- package/export/process/pagesHandler.js +189 -0
- package/export/process/pagesHandler.js.map +1 -0
- package/export/process/templatesHandler.d.ts +6 -0
- package/export/process/templatesHandler.js +166 -0
- package/export/process/templatesHandler.js.map +1 -0
- package/{exportPages → export}/s3Stream.d.ts +7 -2
- package/{exportPages → export}/s3Stream.js +12 -24
- package/export/s3Stream.js.map +1 -0
- package/export/utils.d.ts +29 -0
- package/export/utils.js +194 -0
- package/export/utils.js.map +1 -0
- package/{exportPages → export}/zipper.d.ts +7 -5
- package/{exportPages → export}/zipper.js +40 -53
- package/export/zipper.js.map +1 -0
- package/graphql/crud/blocks.crud.d.ts +4 -0
- package/graphql/crud/blocks.crud.js +140 -0
- package/graphql/crud/blocks.crud.js.map +1 -0
- package/graphql/crud/forms.crud.d.ts +4 -0
- package/graphql/crud/forms.crud.js +134 -0
- package/graphql/crud/forms.crud.js.map +1 -0
- package/graphql/crud/importExportTasks.crud.d.ts +5 -0
- package/graphql/crud/importExportTasks.crud.js +367 -0
- package/graphql/crud/importExportTasks.crud.js.map +1 -0
- package/graphql/crud/pages.crud.d.ts +3 -3
- package/graphql/crud/pages.crud.js +72 -74
- package/graphql/crud/pages.crud.js.map +1 -0
- package/graphql/crud/templates.crud.d.ts +4 -0
- package/graphql/crud/templates.crud.js +128 -0
- package/graphql/crud/templates.crud.js.map +1 -0
- package/graphql/crud.d.ts +2 -2
- package/graphql/crud.js +6 -8
- package/graphql/crud.js.map +1 -0
- package/graphql/graphql/blocks.gql.d.ts +4 -0
- package/graphql/graphql/blocks.gql.js +52 -0
- package/graphql/graphql/blocks.gql.js.map +1 -0
- package/graphql/graphql/forms.gql.d.ts +4 -0
- package/graphql/graphql/forms.gql.js +60 -0
- package/graphql/graphql/forms.gql.js.map +1 -0
- package/graphql/graphql/importExportTasks.gql.d.ts +4 -0
- package/graphql/graphql/{pageImportExportTasks.gql.js → importExportTasks.gql.js} +19 -24
- package/graphql/graphql/importExportTasks.gql.js.map +1 -0
- package/graphql/graphql/pages.gql.d.ts +2 -2
- package/graphql/graphql/pages.gql.js +5 -14
- package/graphql/graphql/pages.gql.js.map +1 -0
- package/graphql/graphql/templates.gql.d.ts +4 -0
- package/graphql/graphql/templates.gql.js +52 -0
- package/graphql/graphql/templates.gql.js.map +1 -0
- package/graphql/graphql/utils/resolve.d.ts +1 -1
- package/graphql/graphql/utils/resolve.js +0 -3
- package/graphql/graphql/utils/resolve.js.map +1 -0
- package/graphql/graphql.d.ts +1 -1
- package/graphql/graphql.js +6 -7
- package/graphql/graphql.js.map +1 -0
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +1 -6
- package/graphql/index.js.map +1 -0
- package/graphql/types.d.ts +86 -27
- package/graphql/types.js.map +1 -0
- package/import/constants.d.ts +3 -0
- package/import/constants.js +14 -0
- package/import/constants.js.map +1 -0
- package/import/create/blocksHandler.d.ts +3 -0
- package/import/create/blocksHandler.js +101 -0
- package/import/create/blocksHandler.js.map +1 -0
- package/import/create/formsHandler.d.ts +3 -0
- package/import/create/formsHandler.js +103 -0
- package/import/create/formsHandler.js.map +1 -0
- package/import/create/index.d.ts +24 -0
- package/import/create/index.js +42 -0
- package/import/create/index.js.map +1 -0
- package/import/create/pagesHandler.d.ts +3 -0
- package/import/create/pagesHandler.js +103 -0
- package/import/create/pagesHandler.js.map +1 -0
- package/import/create/templatesHandler.d.ts +3 -0
- package/import/create/templatesHandler.js +99 -0
- package/import/create/templatesHandler.js.map +1 -0
- package/import/process/blocks/blocksHandler.d.ts +3 -0
- package/import/process/blocks/blocksHandler.js +169 -0
- package/import/process/blocks/blocksHandler.js.map +1 -0
- package/import/process/blocks/importBlock.d.ts +11 -0
- package/import/process/blocks/importBlock.js +92 -0
- package/import/process/blocks/importBlock.js.map +1 -0
- package/import/process/forms/formsHandler.d.ts +3 -0
- package/import/process/forms/formsHandler.js +176 -0
- package/import/process/forms/formsHandler.js.map +1 -0
- package/import/process/forms/importForm.d.ts +9 -0
- package/import/process/forms/importForm.js +43 -0
- package/import/process/forms/importForm.js.map +1 -0
- package/import/process/index.d.ts +20 -0
- package/import/process/index.js +39 -0
- package/import/process/index.js.map +1 -0
- package/import/process/pages/importPage.d.ts +11 -0
- package/import/process/pages/importPage.js +92 -0
- package/import/process/pages/importPage.js.map +1 -0
- package/import/process/pages/pagesHandler.d.ts +3 -0
- package/import/process/pages/pagesHandler.js +183 -0
- package/import/process/pages/pagesHandler.js.map +1 -0
- package/import/process/templates/importTemplate.d.ts +11 -0
- package/import/process/templates/importTemplate.js +66 -0
- package/import/process/templates/importTemplate.js.map +1 -0
- package/import/process/templates/templatesHandler.d.ts +3 -0
- package/import/process/templates/templatesHandler.js +170 -0
- package/import/process/templates/templatesHandler.js.map +1 -0
- package/import/utils/deleteS3Folder.d.ts +1 -0
- package/import/utils/deleteS3Folder.js +19 -0
- package/import/utils/deleteS3Folder.js.map +1 -0
- package/import/utils/extractAndUploadZipFileContents.d.ts +7 -0
- package/import/utils/extractAndUploadZipFileContents.js +122 -0
- package/import/utils/extractAndUploadZipFileContents.js.map +1 -0
- package/import/utils/extractZipAndUploadToS3.d.ts +2 -0
- package/import/utils/extractZipAndUploadToS3.js +98 -0
- package/import/utils/extractZipAndUploadToS3.js.map +1 -0
- package/import/utils/getFileNameWithoutExt.d.ts +1 -0
- package/import/utils/getFileNameWithoutExt.js +11 -0
- package/import/utils/getFileNameWithoutExt.js.map +1 -0
- package/import/utils/index.d.ts +9 -0
- package/import/utils/index.js +104 -0
- package/import/utils/index.js.map +1 -0
- package/import/utils/initialStats.d.ts +7 -0
- package/import/utils/initialStats.js +16 -0
- package/import/utils/initialStats.js.map +1 -0
- package/import/utils/prepareDataDirMap.d.ts +6 -0
- package/import/utils/prepareDataDirMap.js +29 -0
- package/import/utils/prepareDataDirMap.js.map +1 -0
- package/import/utils/updateFilesInData.d.ts +8 -0
- package/import/utils/updateFilesInData.js +48 -0
- package/import/utils/updateFilesInData.js.map +1 -0
- package/import/utils/uploadAssets.d.ts +10 -0
- package/import/utils/uploadAssets.js +49 -0
- package/import/utils/uploadAssets.js.map +1 -0
- package/import/utils/uploadFilesFromS3.d.ts +3 -0
- package/import/utils/uploadFilesFromS3.js +19 -0
- package/import/utils/uploadFilesFromS3.js.map +1 -0
- package/mockSecurity.js +0 -3
- package/mockSecurity.js.map +1 -0
- package/package.json +37 -38
- package/types.d.ts +91 -72
- package/types.js +17 -22
- package/types.js.map +1 -0
- package/exportPages/combine/index.d.ts +0 -19
- package/exportPages/combine/index.js +0 -88
- package/exportPages/process/index.d.ts +0 -26
- package/exportPages/process/index.js +0 -204
- package/exportPages/utils.d.ts +0 -13
- package/exportPages/utils.js +0 -113
- package/graphql/crud/pageImportExportTasks.crud.d.ts +0 -5
- package/graphql/crud/pageImportExportTasks.crud.js +0 -394
- package/graphql/graphql/pageImportExportTasks.gql.d.ts +0 -4
- package/importPages/client.d.ts +0 -7
- package/importPages/client.js +0 -40
- package/importPages/create/index.d.ts +0 -27
- package/importPages/create/index.js +0 -109
- package/importPages/process/index.d.ts +0 -25
- package/importPages/process/index.js +0 -183
- package/importPages/utils.d.ts +0 -43
- package/importPages/utils.js +0 -539
@@ -1,204 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _types = require("../../types");
|
9
|
-
|
10
|
-
var _utils = require("../../importPages/utils");
|
11
|
-
|
12
|
-
var _client = require("../../importPages/client");
|
13
|
-
|
14
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
15
|
-
|
16
|
-
var _utils2 = require("../utils");
|
17
|
-
|
18
|
-
var _mockSecurity = require("../../mockSecurity");
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Handles the export pages process workflow.
|
22
|
-
*/
|
23
|
-
var _default = configuration => ({
|
24
|
-
type: "handler",
|
25
|
-
|
26
|
-
async handle(context) {
|
27
|
-
const log = console.log;
|
28
|
-
let subTask;
|
29
|
-
let noPendingTask = true;
|
30
|
-
let prevStatusOfSubTask = _types.PageImportExportTaskStatus.PENDING;
|
31
|
-
log("RUNNING Export Pages Process Handler");
|
32
|
-
const {
|
33
|
-
invocationArgs: args,
|
34
|
-
pageBuilder,
|
35
|
-
fileManager
|
36
|
-
} = context;
|
37
|
-
const {
|
38
|
-
taskId,
|
39
|
-
subTaskIndex,
|
40
|
-
identity
|
41
|
-
} = args; // Disable authorization; this is necessary because we call Page Builder CRUD methods which include authorization checks
|
42
|
-
// and this Lambda is invoked internally, without credentials.
|
43
|
-
|
44
|
-
(0, _mockSecurity.mockSecurity)(identity, context);
|
45
|
-
|
46
|
-
try {
|
47
|
-
/*
|
48
|
-
* Note: We're not going to DB for finding the next sub-task to process,
|
49
|
-
* because the data might be out of sync due to GSI eventual consistency.
|
50
|
-
*/
|
51
|
-
subTask = await pageBuilder.pageImportExportTask.getSubTask(taskId, (0, _utils.zeroPad)(subTaskIndex));
|
52
|
-
/**
|
53
|
-
* Base condition!!
|
54
|
-
* Bail out early, if task not found or task's status is not "pending".
|
55
|
-
*/
|
56
|
-
|
57
|
-
if (!subTask || subTask.status !== _types.PageImportExportTaskStatus.PENDING) {
|
58
|
-
noPendingTask = true;
|
59
|
-
return;
|
60
|
-
} else {
|
61
|
-
noPendingTask = false;
|
62
|
-
}
|
63
|
-
|
64
|
-
log(`Fetched sub task => ${subTask.id}`);
|
65
|
-
const {
|
66
|
-
input
|
67
|
-
} = subTask;
|
68
|
-
const {
|
69
|
-
pageId,
|
70
|
-
exportPagesDataKey,
|
71
|
-
revisionType
|
72
|
-
} = input;
|
73
|
-
/**
|
74
|
-
* At the moment, we only export a single revision of the page.
|
75
|
-
* It could be "published" or "latest" depending upon user input.
|
76
|
-
*
|
77
|
-
* Note: In case of no "published" revision available, we use the latest revision.
|
78
|
-
*/
|
79
|
-
|
80
|
-
let page;
|
81
|
-
|
82
|
-
try {
|
83
|
-
if (revisionType === _types.PageExportRevisionType.PUBLISHED) {
|
84
|
-
// Get "published" page.
|
85
|
-
page = await pageBuilder.pages.getPublishedById({
|
86
|
-
id: pageId
|
87
|
-
});
|
88
|
-
} else {
|
89
|
-
// Get "latest" page.
|
90
|
-
page = await pageBuilder.pages.get(pageId);
|
91
|
-
}
|
92
|
-
} catch (e) {
|
93
|
-
// If we're looking for "published" page and doesn't found it, get latest page.
|
94
|
-
if (revisionType === _types.PageExportRevisionType.PUBLISHED && e instanceof _handlerGraphql.NotFoundError) {
|
95
|
-
page = await pageBuilder.pages.get(pageId);
|
96
|
-
} else {
|
97
|
-
throw e;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
if (!page) {
|
102
|
-
log(`Unable to load page "${pageId}"`);
|
103
|
-
throw new _handlerGraphql.NotFoundError(`Unable to load page "${pageId}"`);
|
104
|
-
}
|
105
|
-
|
106
|
-
log(`Processing page key "${pageId}" | version ${page.version} | ${page.status}`); // Mark task status as PROCESSING
|
107
|
-
|
108
|
-
subTask = await pageBuilder.pageImportExportTask.updateSubTask(taskId, subTask.id, {
|
109
|
-
status: _types.PageImportExportTaskStatus.PROCESSING
|
110
|
-
}); // Update stats in main task
|
111
|
-
|
112
|
-
await pageBuilder.pageImportExportTask.updateStats(taskId, {
|
113
|
-
prevStatus: prevStatusOfSubTask,
|
114
|
-
nextStatus: _types.PageImportExportTaskStatus.PROCESSING
|
115
|
-
});
|
116
|
-
prevStatusOfSubTask = subTask.status;
|
117
|
-
log(`Extracting page data and uploading to storage...`); // Extract Page
|
118
|
-
|
119
|
-
const pageDataZip = await (0, _utils2.exportPage)(page, exportPagesDataKey, fileManager);
|
120
|
-
log(`Finish uploading zip...`); // Update task record in DB
|
121
|
-
|
122
|
-
subTask = await pageBuilder.pageImportExportTask.updateSubTask(taskId, subTask.id, {
|
123
|
-
status: _types.PageImportExportTaskStatus.COMPLETED,
|
124
|
-
data: {
|
125
|
-
message: `Finish uploading data for page "${page.id}" v${page.version} (${page.status}).`,
|
126
|
-
key: pageDataZip.Key
|
127
|
-
}
|
128
|
-
}); // Update stats in main task
|
129
|
-
|
130
|
-
await pageBuilder.pageImportExportTask.updateStats(taskId, {
|
131
|
-
prevStatus: prevStatusOfSubTask,
|
132
|
-
nextStatus: _types.PageImportExportTaskStatus.COMPLETED
|
133
|
-
});
|
134
|
-
prevStatusOfSubTask = subTask.status;
|
135
|
-
} catch (e) {
|
136
|
-
log("[EXPORT_PAGES_PROCESS] Error => ", e);
|
137
|
-
|
138
|
-
if (subTask && subTask.id) {
|
139
|
-
/**
|
140
|
-
* In case of error, we'll update the task status to "failed",
|
141
|
-
* so that, client can show notify the user appropriately.
|
142
|
-
*/
|
143
|
-
const {
|
144
|
-
invocationArgs: args,
|
145
|
-
pageBuilder
|
146
|
-
} = context;
|
147
|
-
const {
|
148
|
-
taskId
|
149
|
-
} = args;
|
150
|
-
subTask = await pageBuilder.pageImportExportTask.updateSubTask(taskId, subTask.id, {
|
151
|
-
status: _types.PageImportExportTaskStatus.FAILED,
|
152
|
-
error: {
|
153
|
-
name: e.name,
|
154
|
-
message: e.message,
|
155
|
-
stack: e.stack,
|
156
|
-
code: "IMPORT_FAILED"
|
157
|
-
}
|
158
|
-
}); // Update stats in main task
|
159
|
-
|
160
|
-
await pageBuilder.pageImportExportTask.updateStats(taskId, {
|
161
|
-
prevStatus: prevStatusOfSubTask,
|
162
|
-
nextStatus: _types.PageImportExportTaskStatus.FAILED
|
163
|
-
});
|
164
|
-
prevStatusOfSubTask = subTask.status;
|
165
|
-
}
|
166
|
-
|
167
|
-
return {
|
168
|
-
data: null,
|
169
|
-
error: {
|
170
|
-
message: e.message
|
171
|
-
}
|
172
|
-
};
|
173
|
-
} finally {
|
174
|
-
// Base condition!
|
175
|
-
if (noPendingTask) {
|
176
|
-
log(`No pending sub-task for task ${taskId}`); // Combine individual page zip files.
|
177
|
-
|
178
|
-
await (0, _client.invokeHandlerClient)({
|
179
|
-
context,
|
180
|
-
name: configuration.handlers.combine,
|
181
|
-
payload: {
|
182
|
-
taskId,
|
183
|
-
identity: context.security.getIdentity()
|
184
|
-
}
|
185
|
-
});
|
186
|
-
} else {
|
187
|
-
console.log(`Invoking PROCESS for task "${subTaskIndex + 1}"`); // We want to continue with Self invocation no matter if current page error out.
|
188
|
-
|
189
|
-
await (0, _client.invokeHandlerClient)({
|
190
|
-
context,
|
191
|
-
name: configuration.handlers.process,
|
192
|
-
payload: {
|
193
|
-
taskId,
|
194
|
-
subTaskIndex: subTaskIndex + 1,
|
195
|
-
identity: context.security.getIdentity()
|
196
|
-
}
|
197
|
-
});
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
|
202
|
-
});
|
203
|
-
|
204
|
-
exports.default = _default;
|
package/exportPages/utils.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import S3 from "aws-sdk/clients/s3";
|
2
|
-
import { Page, File } from "@webiny/api-page-builder/types";
|
3
|
-
import { FileManagerContext } from "@webiny/api-file-manager/types";
|
4
|
-
export declare const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
|
5
|
-
export interface ExportedPageData {
|
6
|
-
page: Pick<Page, "content" | "title" | "version" | "status" | "settings" | "path">;
|
7
|
-
files: ImageFile[];
|
8
|
-
}
|
9
|
-
export declare function exportPage(page: Page, exportPagesDataKey: string, fileManager: FileManagerContext["fileManager"]): Promise<S3.ManagedUpload.SendData>;
|
10
|
-
export interface ImageFile extends File {
|
11
|
-
key: string;
|
12
|
-
}
|
13
|
-
export declare function extractFilesFromPageData(data: Record<string, any>, files?: any[]): ImageFile[];
|
package/exportPages/utils.js
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
exports.EXPORT_PAGES_FOLDER_KEY = void 0;
|
9
|
-
exports.exportPage = exportPage;
|
10
|
-
exports.extractFilesFromPageData = extractFilesFromPageData;
|
11
|
-
|
12
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
-
|
14
|
-
var _s3Stream = require("./s3Stream");
|
15
|
-
|
16
|
-
var _zipper = _interopRequireDefault(require("./zipper"));
|
17
|
-
|
18
|
-
const EXPORT_PAGES_FOLDER_KEY = "WEBINY_PB_EXPORT_PAGES";
|
19
|
-
exports.EXPORT_PAGES_FOLDER_KEY = EXPORT_PAGES_FOLDER_KEY;
|
20
|
-
|
21
|
-
async function getFilteredFiles(files) {
|
22
|
-
const uniqueFileKeys = new Map();
|
23
|
-
const promises = files.map(file => _s3Stream.s3Stream.isFileAccessible(file.key));
|
24
|
-
const isFileAvailableResults = await Promise.all(promises);
|
25
|
-
const filesAvailableForDownload = []; // Filter files
|
26
|
-
|
27
|
-
for (let i = 0; i < files.length; i++) {
|
28
|
-
const file = files[i]; // Check file accessibility
|
29
|
-
|
30
|
-
if (isFileAvailableResults[i] && !uniqueFileKeys.has(file.key)) {
|
31
|
-
filesAvailableForDownload.push(file);
|
32
|
-
uniqueFileKeys.set(file.key, true);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
return filesAvailableForDownload;
|
37
|
-
}
|
38
|
-
|
39
|
-
async function exportPage(page, exportPagesDataKey, fileManager) {
|
40
|
-
// Extract all files
|
41
|
-
const files = extractFilesFromPageData(page.content); // Filter files
|
42
|
-
|
43
|
-
const filesAvailableForDownload = await getFilteredFiles(files); // Extract images from page settings
|
44
|
-
|
45
|
-
const pageSettingsImages = [(0, _get.default)(page, "settings.general.image"), (0, _get.default)(page, "settings.social.image")].filter(image => image && image.src);
|
46
|
-
const pageSettingsImagesData = []; // Get file data for all images inside "page.settings"
|
47
|
-
|
48
|
-
for (let i = 0; i < pageSettingsImages.length; i++) {
|
49
|
-
const {
|
50
|
-
id
|
51
|
-
} = pageSettingsImages[i];
|
52
|
-
const file = await fileManager.files.getFile(id);
|
53
|
-
pageSettingsImagesData.push(file);
|
54
|
-
} // Extract the page data in a json file and upload it to S3
|
55
|
-
|
56
|
-
|
57
|
-
const pageData = {
|
58
|
-
page: {
|
59
|
-
content: page.content,
|
60
|
-
title: page.title,
|
61
|
-
path: page.path,
|
62
|
-
version: page.version,
|
63
|
-
status: page.status,
|
64
|
-
settings: page.settings
|
65
|
-
},
|
66
|
-
files: [...filesAvailableForDownload, ...pageSettingsImagesData]
|
67
|
-
};
|
68
|
-
const pageDataBuffer = Buffer.from(JSON.stringify(pageData));
|
69
|
-
const zipper = new _zipper.default({
|
70
|
-
exportInfo: {
|
71
|
-
files: [...filesAvailableForDownload, ...pageSettingsImagesData],
|
72
|
-
pageTitle: page.title,
|
73
|
-
pageDataBuffer
|
74
|
-
},
|
75
|
-
archiveFileKey: exportPagesDataKey
|
76
|
-
});
|
77
|
-
return zipper.process();
|
78
|
-
}
|
79
|
-
|
80
|
-
function extractFilesFromPageData(data, files = []) {
|
81
|
-
// Base case: termination
|
82
|
-
if (!data || typeof data !== "object") {
|
83
|
-
return files;
|
84
|
-
} // Recursively call function for each element
|
85
|
-
|
86
|
-
|
87
|
-
if (Array.isArray(data)) {
|
88
|
-
for (let i = 0; i < data.length; i++) {
|
89
|
-
const element = data[i];
|
90
|
-
extractFilesFromPageData(element, files);
|
91
|
-
}
|
92
|
-
|
93
|
-
return files;
|
94
|
-
} // Main
|
95
|
-
|
96
|
-
|
97
|
-
const tuple = Object.entries(data);
|
98
|
-
|
99
|
-
for (let i = 0; i < tuple.length; i++) {
|
100
|
-
const [key, value] = tuple[i]; // TODO: @ashutosh extract it to plugins, so that, we can handle cases for other components too.
|
101
|
-
|
102
|
-
if (key === "file" && value) {
|
103
|
-
files.push(value);
|
104
|
-
} else if (key === "images" && Array.isArray(value)) {
|
105
|
-
// Handle case for "images-list" component
|
106
|
-
files.push(...value);
|
107
|
-
} else {
|
108
|
-
extractFilesFromPageData(value, files);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
return files;
|
113
|
-
}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
|
2
|
-
import { PageImportExportPluginsParams } from "../../types";
|
3
|
-
import { PbPageImportExportContext } from "../types";
|
4
|
-
declare const _default: ({ storageOperations }: PageImportExportPluginsParams) => ContextPlugin<PbPageImportExportContext>;
|
5
|
-
export default _default;
|