@webiny/api-page-builder-import-export 5.34.8 → 5.35.0-beta.0
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.js +2 -6
- package/client.js.map +1 -1
- package/export/combine/blocksHandler.js +11 -18
- package/export/combine/blocksHandler.js.map +1 -1
- 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.js +19 -9
- package/export/combine/index.js.map +1 -1
- package/export/combine/pagesHandler.js +11 -18
- package/export/combine/pagesHandler.js.map +1 -1
- 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.js +18 -32
- package/export/process/blocksHandler.js.map +1 -1
- 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.js +19 -9
- package/export/process/index.js.map +1 -1
- package/export/process/pagesHandler.js +19 -34
- package/export/process/pagesHandler.js.map +1 -1
- package/export/process/templatesHandler.d.ts +6 -0
- package/export/process/templatesHandler.js +166 -0
- package/export/process/templatesHandler.js.map +1 -0
- package/export/s3Stream.d.ts +5 -2
- package/export/s3Stream.js +1 -20
- package/export/s3Stream.js.map +1 -1
- package/export/utils.d.ts +14 -1
- package/export/utils.js +88 -35
- package/export/utils.js.map +1 -1
- package/export/zipper.js +31 -43
- package/export/zipper.js.map +1 -1
- package/graphql/crud/blocks.crud.js +20 -39
- package/graphql/crud/blocks.crud.js.map +1 -1
- package/graphql/crud/forms.crud.d.ts +4 -0
- package/graphql/crud/forms.crud.js +129 -0
- package/graphql/crud/forms.crud.js.map +1 -0
- package/graphql/crud/importExportTasks.crud.js +9 -57
- package/graphql/crud/importExportTasks.crud.js.map +1 -1
- package/graphql/crud/pages.crud.js +25 -41
- package/graphql/crud/pages.crud.js.map +1 -1
- package/graphql/crud/templates.crud.d.ts +4 -0
- package/graphql/crud/templates.crud.js +124 -0
- package/graphql/crud/templates.crud.js.map +1 -0
- package/graphql/crud.js +3 -7
- package/graphql/crud.js.map +1 -1
- package/graphql/graphql/blocks.gql.js +1 -6
- package/graphql/graphql/blocks.gql.js.map +1 -1
- 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.js +1 -6
- package/graphql/graphql/importExportTasks.gql.js.map +1 -1
- package/graphql/graphql/pages.gql.js +2 -7
- package/graphql/graphql/pages.gql.js.map +1 -1
- 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 -1
- package/graphql/graphql.js +3 -6
- package/graphql/graphql.js.map +1 -1
- package/graphql/index.js +0 -5
- package/graphql/index.js.map +1 -1
- package/graphql/types.d.ts +40 -0
- package/graphql/types.js.map +1 -1
- package/import/constants.d.ts +3 -0
- package/import/constants.js +14 -0
- package/import/constants.js.map +1 -0
- package/import/create/blocksHandler.js +11 -20
- package/import/create/blocksHandler.js.map +1 -1
- 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 +2 -1
- package/import/create/index.js +19 -9
- package/import/create/index.js.map +1 -1
- package/import/create/pagesHandler.js +13 -20
- package/import/create/pagesHandler.js.map +1 -1
- 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 +1 -0
- package/import/process/index.js +21 -11
- package/import/process/index.js.map +1 -1
- 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 +51 -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 -2
- package/mockSecurity.js.map +1 -1
- package/package.json +25 -24
- package/types.d.ts +21 -0
- package/types.js +0 -5
- package/types.js.map +1 -1
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.initialStats = initialStats;
|
7
|
+
var _types = require("../../types");
|
8
|
+
function initialStats(total) {
|
9
|
+
return {
|
10
|
+
[_types.ImportExportTaskStatus.PENDING]: total,
|
11
|
+
[_types.ImportExportTaskStatus.PROCESSING]: 0,
|
12
|
+
[_types.ImportExportTaskStatus.COMPLETED]: 0,
|
13
|
+
[_types.ImportExportTaskStatus.FAILED]: 0,
|
14
|
+
total
|
15
|
+
};
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["initialStats","total","ImportExportTaskStatus","PENDING","PROCESSING","COMPLETED","FAILED"],"sources":["initialStats.ts"],"sourcesContent":["import { ImportExportTaskStatus } from \"~/types\";\n\nexport function initialStats(total: number) {\n return {\n [ImportExportTaskStatus.PENDING]: total,\n [ImportExportTaskStatus.PROCESSING]: 0,\n [ImportExportTaskStatus.COMPLETED]: 0,\n [ImportExportTaskStatus.FAILED]: 0,\n total\n };\n}\n"],"mappings":";;;;;;AAAA;AAEO,SAASA,YAAY,CAACC,KAAa,EAAE;EACxC,OAAO;IACH,CAACC,6BAAsB,CAACC,OAAO,GAAGF,KAAK;IACvC,CAACC,6BAAsB,CAACE,UAAU,GAAG,CAAC;IACtC,CAACF,6BAAsB,CAACG,SAAS,GAAG,CAAC;IACrC,CAACH,6BAAsB,CAACI,MAAM,GAAG,CAAC;IAClCL;EACJ,CAAC;AACL"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.prepareDataDirMap = prepareDataDirMap;
|
8
|
+
var _dotPropImmutable = _interopRequireDefault(require("dot-prop-immutable"));
|
9
|
+
var _constants = require("../constants");
|
10
|
+
function prepareDataDirMap({
|
11
|
+
map,
|
12
|
+
filePath,
|
13
|
+
newKey
|
14
|
+
}) {
|
15
|
+
const isAsset = filePath.includes(_constants.ASSETS_DIR_NAME);
|
16
|
+
if (isAsset) {
|
17
|
+
/*
|
18
|
+
* We want to use dot (.) as part of object key rather than creating nested object(s).
|
19
|
+
* Also, the file name might contain dots in it beside the extension, so, we are escaping them all.
|
20
|
+
*/
|
21
|
+
const assetKey = filePath.split(`${_constants.ASSETS_DIR_NAME}/`).pop();
|
22
|
+
const oldKey = assetKey.replace(/\./g, "\\.");
|
23
|
+
map = _dotPropImmutable.default.set(map, `assets.${oldKey}`, newKey);
|
24
|
+
} else {
|
25
|
+
// We only need to know the newKey for data file.
|
26
|
+
map = _dotPropImmutable.default.set(map, `data`, newKey);
|
27
|
+
}
|
28
|
+
return map;
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["prepareDataDirMap","map","filePath","newKey","isAsset","includes","ASSETS_DIR_NAME","assetKey","split","pop","oldKey","replace","dotProp","set"],"sources":["prepareDataDirMap.ts"],"sourcesContent":["import dotProp from \"dot-prop-immutable\";\nimport { ImportData } from \"~/types\";\nimport { ASSETS_DIR_NAME } from \"~/import/constants\";\n\nexport function prepareDataDirMap({\n map,\n filePath,\n newKey\n}: {\n map: ImportData;\n filePath: string;\n newKey: string;\n}): ImportData {\n const isAsset = filePath.includes(ASSETS_DIR_NAME);\n\n if (isAsset) {\n /*\n * We want to use dot (.) as part of object key rather than creating nested object(s).\n * Also, the file name might contain dots in it beside the extension, so, we are escaping them all.\n */\n const assetKey = filePath.split(`${ASSETS_DIR_NAME}/`).pop() as string;\n const oldKey = assetKey.replace(/\\./g, \"\\\\.\");\n\n map = dotProp.set(map, `assets.${oldKey}`, newKey);\n } else {\n // We only need to know the newKey for data file.\n map = dotProp.set(map, `data`, newKey);\n }\n\n return map;\n}\n"],"mappings":";;;;;;;AAAA;AAEA;AAEO,SAASA,iBAAiB,CAAC;EAC9BC,GAAG;EACHC,QAAQ;EACRC;AAKJ,CAAC,EAAc;EACX,MAAMC,OAAO,GAAGF,QAAQ,CAACG,QAAQ,CAACC,0BAAe,CAAC;EAElD,IAAIF,OAAO,EAAE;IACT;AACR;AACA;AACA;IACQ,MAAMG,QAAQ,GAAGL,QAAQ,CAACM,KAAK,CAAE,GAAEF,0BAAgB,GAAE,CAAC,CAACG,GAAG,EAAY;IACtE,MAAMC,MAAM,GAAGH,QAAQ,CAACI,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;IAE7CV,GAAG,GAAGW,yBAAO,CAACC,GAAG,CAACZ,GAAG,EAAG,UAASS,MAAO,EAAC,EAAEP,MAAM,CAAC;EACtD,CAAC,MAAM;IACH;IACAF,GAAG,GAAGW,yBAAO,CAACC,GAAG,CAACZ,GAAG,EAAG,MAAK,EAAEE,MAAM,CAAC;EAC1C;EAEA,OAAOF,GAAG;AACd"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { FileInput } from "@webiny/api-file-manager/types";
|
2
|
+
interface UpdateFilesInDataParams {
|
3
|
+
data: Record<string, any>;
|
4
|
+
fileIdToNewFileMap: Map<string, FileInput>;
|
5
|
+
srcPrefix: string;
|
6
|
+
}
|
7
|
+
export declare function updateFilesInData({ data, fileIdToNewFileMap, srcPrefix }: UpdateFilesInDataParams): void;
|
8
|
+
export {};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.updateFilesInData = updateFilesInData;
|
7
|
+
function updateFilesInData({
|
8
|
+
data,
|
9
|
+
fileIdToNewFileMap,
|
10
|
+
srcPrefix
|
11
|
+
}) {
|
12
|
+
if (!data || typeof data !== "object") {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
// Recursively call function if data is array
|
16
|
+
if (Array.isArray(data)) {
|
17
|
+
for (let i = 0; i < data.length; i++) {
|
18
|
+
const element = data[i];
|
19
|
+
updateFilesInData({
|
20
|
+
data: element,
|
21
|
+
fileIdToNewFileMap,
|
22
|
+
srcPrefix
|
23
|
+
});
|
24
|
+
}
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
// Main logic
|
28
|
+
const tuple = Object.entries(data);
|
29
|
+
for (let i = 0; i < tuple.length; i++) {
|
30
|
+
const [key, value] = tuple[i];
|
31
|
+
if (key === "file" && value && fileIdToNewFileMap.has(value.id)) {
|
32
|
+
const newFile = fileIdToNewFileMap.get(value.id);
|
33
|
+
if (!newFile) {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
const cleanSrcPrefix = srcPrefix.endsWith("/") ? srcPrefix.slice(0, -1) : srcPrefix;
|
37
|
+
value.key = newFile.key;
|
38
|
+
value.name = newFile.name;
|
39
|
+
value.src = `${cleanSrcPrefix}/${newFile.key}`;
|
40
|
+
} else {
|
41
|
+
updateFilesInData({
|
42
|
+
data: value,
|
43
|
+
srcPrefix,
|
44
|
+
fileIdToNewFileMap
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["updateFilesInData","data","fileIdToNewFileMap","srcPrefix","Array","isArray","i","length","element","tuple","Object","entries","key","value","has","id","newFile","get","cleanSrcPrefix","endsWith","slice","name","src"],"sources":["updateFilesInData.ts"],"sourcesContent":["import { FileInput } from \"@webiny/api-file-manager/types\";\n\ninterface UpdateFilesInDataParams {\n data: Record<string, any>;\n fileIdToNewFileMap: Map<string, FileInput>;\n srcPrefix: string;\n}\n\nexport function updateFilesInData({\n data,\n fileIdToNewFileMap,\n srcPrefix\n}: UpdateFilesInDataParams) {\n if (!data || typeof data !== \"object\") {\n return;\n }\n // Recursively call function if data is array\n if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n const element = data[i];\n updateFilesInData({ data: element, fileIdToNewFileMap, srcPrefix });\n }\n return;\n }\n // Main logic\n const tuple = Object.entries(data);\n for (let i = 0; i < tuple.length; i++) {\n const [key, value] = tuple[i];\n\n if (key === \"file\" && value && fileIdToNewFileMap.has(value.id)) {\n const newFile = fileIdToNewFileMap.get(value.id);\n if (!newFile) {\n continue;\n }\n\n const cleanSrcPrefix = srcPrefix.endsWith(\"/\") ? srcPrefix.slice(0, -1) : srcPrefix;\n\n value.key = newFile.key;\n value.name = newFile.name;\n value.src = `${cleanSrcPrefix}/${newFile.key}`;\n } else {\n updateFilesInData({ data: value, srcPrefix, fileIdToNewFileMap });\n }\n }\n}\n"],"mappings":";;;;;;AAQO,SAASA,iBAAiB,CAAC;EAC9BC,IAAI;EACJC,kBAAkB;EAClBC;AACqB,CAAC,EAAE;EACxB,IAAI,CAACF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACnC;EACJ;EACA;EACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,IAAI,CAAC,EAAE;IACrB,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,IAAI,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;MAClC,MAAME,OAAO,GAAGP,IAAI,CAACK,CAAC,CAAC;MACvBN,iBAAiB,CAAC;QAAEC,IAAI,EAAEO,OAAO;QAAEN,kBAAkB;QAAEC;MAAU,CAAC,CAAC;IACvE;IACA;EACJ;EACA;EACA,MAAMM,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACV,IAAI,CAAC;EAClC,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGG,KAAK,CAACF,MAAM,EAAED,CAAC,EAAE,EAAE;IACnC,MAAM,CAACM,GAAG,EAAEC,KAAK,CAAC,GAAGJ,KAAK,CAACH,CAAC,CAAC;IAE7B,IAAIM,GAAG,KAAK,MAAM,IAAIC,KAAK,IAAIX,kBAAkB,CAACY,GAAG,CAACD,KAAK,CAACE,EAAE,CAAC,EAAE;MAC7D,MAAMC,OAAO,GAAGd,kBAAkB,CAACe,GAAG,CAACJ,KAAK,CAACE,EAAE,CAAC;MAChD,IAAI,CAACC,OAAO,EAAE;QACV;MACJ;MAEA,MAAME,cAAc,GAAGf,SAAS,CAACgB,QAAQ,CAAC,GAAG,CAAC,GAAGhB,SAAS,CAACiB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGjB,SAAS;MAEnFU,KAAK,CAACD,GAAG,GAAGI,OAAO,CAACJ,GAAG;MACvBC,KAAK,CAACQ,IAAI,GAAGL,OAAO,CAACK,IAAI;MACzBR,KAAK,CAACS,GAAG,GAAI,GAAEJ,cAAe,IAAGF,OAAO,CAACJ,GAAI,EAAC;IAClD,CAAC,MAAM;MACHZ,iBAAiB,CAAC;QAAEC,IAAI,EAAEY,KAAK;QAAEV,SAAS;QAAED;MAAmB,CAAC,CAAC;IACrE;EACJ;AACJ"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { PbImportExportContext } from "../../graphql/types";
|
2
|
+
import { File, FileInput } from "@webiny/api-file-manager/types";
|
3
|
+
import { FileUploadsData } from "../../types";
|
4
|
+
interface UploadAssetsParams {
|
5
|
+
context: PbImportExportContext;
|
6
|
+
files: File[];
|
7
|
+
fileUploadsData: FileUploadsData;
|
8
|
+
}
|
9
|
+
export declare const uploadAssets: (params: UploadAssetsParams) => Promise<Map<string, FileInput>>;
|
10
|
+
export {};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.uploadAssets = void 0;
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
|
+
var _mdbid = _interopRequireDefault(require("mdbid"));
|
10
|
+
var _uploadFilesFromS = require("./uploadFilesFromS3");
|
11
|
+
// @ts-ignore
|
12
|
+
|
13
|
+
const uploadAssets = async params => {
|
14
|
+
const {
|
15
|
+
context,
|
16
|
+
files,
|
17
|
+
fileUploadsData
|
18
|
+
} = params;
|
19
|
+
const oldIdToNewFileMap = new Map();
|
20
|
+
|
21
|
+
/**
|
22
|
+
* This function contains logic of file download from S3.
|
23
|
+
* Current we're not mocking zip file download from S3 in tests at the moment.
|
24
|
+
* So, we're manually mocking it in case of test just by returning an empty object.
|
25
|
+
*/
|
26
|
+
if (process.env.NODE_ENV === "test") {
|
27
|
+
return oldIdToNewFileMap;
|
28
|
+
}
|
29
|
+
|
30
|
+
// A map of temporary file keys (created during ZIP upload) to permanent file keys.
|
31
|
+
const uploadFileMap = new Map();
|
32
|
+
|
33
|
+
// Array of file inputs, to insert into the DB.
|
34
|
+
const createFilesInput = [];
|
35
|
+
for (const oldFile of files) {
|
36
|
+
const id = (0, _mdbid.default)();
|
37
|
+
// We replace the old file ID with a new one.
|
38
|
+
const newKey = `${id}/${oldFile.key.replace(`${oldFile.id}/`, "")}`;
|
39
|
+
const newFile = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, oldFile), {}, {
|
40
|
+
id,
|
41
|
+
key: newKey
|
42
|
+
});
|
43
|
+
createFilesInput.push(newFile);
|
44
|
+
oldIdToNewFileMap.set(oldFile.id, newFile);
|
45
|
+
uploadFileMap.set(fileUploadsData.assets[oldFile.key], newFile);
|
46
|
+
}
|
47
|
+
await (0, _uploadFilesFromS.uploadFilesFromS3)(uploadFileMap);
|
48
|
+
await context.fileManager.createFilesInBatch(createFilesInput);
|
49
|
+
return oldIdToNewFileMap;
|
50
|
+
};
|
51
|
+
exports.uploadAssets = uploadAssets;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["uploadAssets","params","context","files","fileUploadsData","oldIdToNewFileMap","Map","process","env","NODE_ENV","uploadFileMap","createFilesInput","oldFile","id","mdbid","newKey","key","replace","newFile","push","set","assets","uploadFilesFromS3","fileManager","createFilesInBatch"],"sources":["uploadAssets.ts"],"sourcesContent":["// @ts-ignore\nimport mdbid from \"mdbid\";\nimport { PbImportExportContext } from \"~/graphql/types\";\nimport { File, FileInput } from \"@webiny/api-file-manager/types\";\nimport { UploadFileMap, uploadFilesFromS3 } from \"~/import/utils/uploadFilesFromS3\";\nimport { FileUploadsData } from \"~/types\";\n\ninterface UploadAssetsParams {\n context: PbImportExportContext;\n files: File[];\n fileUploadsData: FileUploadsData;\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 // 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 oldFile of files) {\n const id = mdbid();\n // We replace the old file ID with a new one.\n const newKey = `${id}/${oldFile.key.replace(`${oldFile.id}/`, \"\")}`;\n const newFile: FileInput = { ...oldFile, id, key: newKey };\n\n createFilesInput.push(newFile);\n oldIdToNewFileMap.set(oldFile.id, newFile);\n uploadFileMap.set(fileUploadsData.assets[oldFile.key], newFile);\n }\n\n await uploadFilesFromS3(uploadFileMap);\n\n await context.fileManager.createFilesInBatch(createFilesInput);\n\n return oldIdToNewFileMap;\n};\n"],"mappings":";;;;;;;;AACA;AAGA;AAJA;;AAaO,MAAMA,YAAY,GAAG,MAAOC,MAA0B,IAAK;EAC9D,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAGH,MAAM;EAElD,MAAMI,iBAAiB,GAAG,IAAIC,GAAG,EAAqB;;EAEtD;AACJ;AACA;AACA;AACA;EACI,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;IACjC,OAAOJ,iBAAiB;EAC5B;;EAEA;EACA,MAAMK,aAA4B,GAAG,IAAIJ,GAAG,EAAE;;EAE9C;EACA,MAAMK,gBAA6B,GAAG,EAAE;EAExC,KAAK,MAAMC,OAAO,IAAIT,KAAK,EAAE;IACzB,MAAMU,EAAE,GAAG,IAAAC,cAAK,GAAE;IAClB;IACA,MAAMC,MAAM,GAAI,GAAEF,EAAG,IAAGD,OAAO,CAACI,GAAG,CAACC,OAAO,CAAE,GAAEL,OAAO,CAACC,EAAG,GAAE,EAAE,EAAE,CAAE,EAAC;IACnE,MAAMK,OAAkB,+DAAQN,OAAO;MAAEC,EAAE;MAAEG,GAAG,EAAED;IAAM,EAAE;IAE1DJ,gBAAgB,CAACQ,IAAI,CAACD,OAAO,CAAC;IAC9Bb,iBAAiB,CAACe,GAAG,CAACR,OAAO,CAACC,EAAE,EAAEK,OAAO,CAAC;IAC1CR,aAAa,CAACU,GAAG,CAAChB,eAAe,CAACiB,MAAM,CAACT,OAAO,CAACI,GAAG,CAAC,EAAEE,OAAO,CAAC;EACnE;EAEA,MAAM,IAAAI,mCAAiB,EAACZ,aAAa,CAAC;EAEtC,MAAMR,OAAO,CAACqB,WAAW,CAACC,kBAAkB,CAACb,gBAAgB,CAAC;EAE9D,OAAON,iBAAiB;AAC5B,CAAC;AAAC"}
|
@@ -0,0 +1,19 @@
|
|
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 = _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
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["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 { 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 = 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;AAKO,eAAeA,iBAAiB,CAACC,OAAsB,EAAE;EAC5D,MAAMC,QAAQ,GAAG,EAAE;EACnB,KAAK,MAAM,CAACC,MAAM,EAAEC,MAAM,CAAC,IAAIC,KAAK,CAACC,IAAI,CAACL,OAAO,CAACM,OAAO,EAAE,CAAC,EAAE;IAC1D;IACA,MAAMC,UAAU,GAAGC,kBAAQ,CAACD,UAAU,CAACL,MAAM,CAAC;IAE9C,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,CAAE,6BAA4Bf,MAAM,CAACQ,GAAI,GAAE,CAAC;EAC3D;EAEA,OAAOQ,OAAO,CAACC,GAAG,CAACnB,QAAQ,CAAC;AAChC"}
|
package/mockSecurity.js
CHANGED
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.mockSecurity = void 0;
|
7
|
-
|
8
7
|
const mockSecurity = (identity, context) => {
|
9
8
|
context.security.disableAuthorization();
|
10
9
|
context.security.setIdentity(identity);
|
11
10
|
};
|
12
|
-
|
13
11
|
exports.mockSecurity = mockSecurity;
|
package/mockSecurity.js.map
CHANGED
@@ -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":"
|
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"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@webiny/api-page-builder-import-export",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.35.0-beta.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"keywords": [
|
6
6
|
"pbie:base"
|
@@ -14,18 +14,19 @@
|
|
14
14
|
"author": "Webiny Ltd",
|
15
15
|
"license": "MIT",
|
16
16
|
"dependencies": {
|
17
|
-
"@babel/runtime": "7.
|
17
|
+
"@babel/runtime": "7.20.13",
|
18
18
|
"@commodo/fields": "1.1.2-beta.20",
|
19
|
-
"@webiny/api": "5.
|
20
|
-
"@webiny/api-file-manager": "5.
|
21
|
-
"@webiny/api-
|
22
|
-
"@webiny/api-
|
23
|
-
"@webiny/
|
24
|
-
"@webiny/
|
25
|
-
"@webiny/handler
|
26
|
-
"@webiny/handler-
|
27
|
-
"@webiny/
|
28
|
-
"@webiny/
|
19
|
+
"@webiny/api": "5.35.0-beta.0",
|
20
|
+
"@webiny/api-file-manager": "5.35.0-beta.0",
|
21
|
+
"@webiny/api-form-builder": "5.35.0-beta.0",
|
22
|
+
"@webiny/api-page-builder": "5.35.0-beta.0",
|
23
|
+
"@webiny/api-security": "5.35.0-beta.0",
|
24
|
+
"@webiny/error": "5.35.0-beta.0",
|
25
|
+
"@webiny/handler": "5.35.0-beta.0",
|
26
|
+
"@webiny/handler-aws": "5.35.0-beta.0",
|
27
|
+
"@webiny/handler-graphql": "5.35.0-beta.0",
|
28
|
+
"@webiny/utils": "5.35.0-beta.0",
|
29
|
+
"@webiny/validation": "5.35.0-beta.0",
|
29
30
|
"archiver": "5.3.1",
|
30
31
|
"commodo-fields-object": "1.0.6",
|
31
32
|
"dot-prop-immutable": "2.1.1",
|
@@ -33,7 +34,7 @@
|
|
33
34
|
"load-json-file": "6.2.0",
|
34
35
|
"lodash": "4.17.21",
|
35
36
|
"mdbid": "1.0.0",
|
36
|
-
"node-fetch": "2.6.
|
37
|
+
"node-fetch": "2.6.9",
|
37
38
|
"stream": "0.0.2",
|
38
39
|
"uniqid": "5.4.0",
|
39
40
|
"yauzl": "2.10.0"
|
@@ -47,16 +48,16 @@
|
|
47
48
|
"@types/archiver": "^5.3.1",
|
48
49
|
"@types/node-fetch": "^2.6.1",
|
49
50
|
"@types/yauzl": "^2.9.2",
|
50
|
-
"@webiny/api-dynamodb-to-elasticsearch": "^5.
|
51
|
-
"@webiny/api-file-manager-ddb-es": "^5.
|
52
|
-
"@webiny/api-i18n-ddb": "^5.
|
53
|
-
"@webiny/api-security-so-ddb": "^5.
|
54
|
-
"@webiny/api-tenancy": "^5.
|
55
|
-
"@webiny/api-tenancy-so-ddb": "^5.
|
56
|
-
"@webiny/api-wcp": "^5.
|
57
|
-
"@webiny/cli": "^5.
|
58
|
-
"@webiny/db": "^5.
|
59
|
-
"@webiny/project-utils": "^5.
|
51
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^5.35.0-beta.0",
|
52
|
+
"@webiny/api-file-manager-ddb-es": "^5.35.0-beta.0",
|
53
|
+
"@webiny/api-i18n-ddb": "^5.35.0-beta.0",
|
54
|
+
"@webiny/api-security-so-ddb": "^5.35.0-beta.0",
|
55
|
+
"@webiny/api-tenancy": "^5.35.0-beta.0",
|
56
|
+
"@webiny/api-tenancy-so-ddb": "^5.35.0-beta.0",
|
57
|
+
"@webiny/api-wcp": "^5.35.0-beta.0",
|
58
|
+
"@webiny/cli": "^5.35.0-beta.0",
|
59
|
+
"@webiny/db": "^5.35.0-beta.0",
|
60
|
+
"@webiny/project-utils": "^5.35.0-beta.0",
|
60
61
|
"jest": "^28.1.0",
|
61
62
|
"jest-dynalite": "^3.2.0",
|
62
63
|
"rimraf": "^3.0.2",
|
@@ -78,5 +79,5 @@
|
|
78
79
|
]
|
79
80
|
}
|
80
81
|
},
|
81
|
-
"gitHead": "
|
82
|
+
"gitHead": "8acc9e8892842cabb3980ce0b6432fde55968d5b"
|
82
83
|
}
|
package/types.d.ts
CHANGED
@@ -188,3 +188,24 @@ export interface ImportExportTaskStorageOperations {
|
|
188
188
|
createSubTask(params: ImportExportTaskStorageOperationsCreateSubTaskParams): Promise<ImportExportTask>;
|
189
189
|
updateSubTask(params: ImportExportTaskStorageOperationsUpdateSubTaskParams): Promise<ImportExportTask>;
|
190
190
|
}
|
191
|
+
export interface FileUploadsData {
|
192
|
+
/**
|
193
|
+
* Location of export data file. Export data contains the relevant entity data (block, page, template), and an
|
194
|
+
* array of file objects, exported from the DB, that need to be imported.
|
195
|
+
*
|
196
|
+
* Example:
|
197
|
+
* 'IMPORTS/8lf6y7xp5/8lf6x9v68-header-1/8lf6x9v69-header-1/Header #1.json'
|
198
|
+
*/
|
199
|
+
data: string;
|
200
|
+
/**
|
201
|
+
* Example:
|
202
|
+
* '8ldspraka-9l9iaffak-1.jpeg': 'IMPORTS/8lf6y7xp5/8lf6x9v68-header-1/assets/8ldspraka-9l9iaffak-1.jpeg',
|
203
|
+
* '8ldwyq8ao-pb-editor-page-element-rzfKWtdTWN.png': 'IMPORTS/8lf6y7xp5/8lf6x9v69-header-1/assets/8ldwyq8ao-pb-editor-page-element-rzfKWtdTWN.png'
|
204
|
+
*/
|
205
|
+
assets: Record<string, string>;
|
206
|
+
}
|
207
|
+
export interface ImportData {
|
208
|
+
assets: Record<string, string>;
|
209
|
+
data: string;
|
210
|
+
key: string;
|
211
|
+
}
|
package/types.js
CHANGED
@@ -8,9 +8,7 @@ var _exportNames = {
|
|
8
8
|
ImportExportTaskStatus: true
|
9
9
|
};
|
10
10
|
exports.ImportExportTaskStatus = exports.ExportRevisionType = void 0;
|
11
|
-
|
12
11
|
var _types = require("./graphql/types");
|
13
|
-
|
14
12
|
Object.keys(_types).forEach(function (key) {
|
15
13
|
if (key === "default" || key === "__esModule") return;
|
16
14
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
@@ -25,15 +23,12 @@ Object.keys(_types).forEach(function (key) {
|
|
25
23
|
// Entities.
|
26
24
|
let ExportRevisionType;
|
27
25
|
exports.ExportRevisionType = ExportRevisionType;
|
28
|
-
|
29
26
|
(function (ExportRevisionType) {
|
30
27
|
ExportRevisionType["PUBLISHED"] = "published";
|
31
28
|
ExportRevisionType["LATEST"] = "latest";
|
32
29
|
})(ExportRevisionType || (exports.ExportRevisionType = ExportRevisionType = {}));
|
33
|
-
|
34
30
|
let ImportExportTaskStatus;
|
35
31
|
exports.ImportExportTaskStatus = ImportExportTaskStatus;
|
36
|
-
|
37
32
|
(function (ImportExportTaskStatus) {
|
38
33
|
ImportExportTaskStatus["PENDING"] = "pending";
|
39
34
|
ImportExportTaskStatus["PROCESSING"] = "processing";
|
package/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ExportRevisionType","ImportExportTaskStatus"],"sources":["types.ts"],"sourcesContent":["export * from \"./graphql/types\";\n\n// Entities.\nexport enum ExportRevisionType {\n PUBLISHED = \"published\",\n LATEST = \"latest\"\n}\n\nexport enum ImportExportTaskStatus {\n PENDING = \"pending\",\n PROCESSING = \"processing\",\n COMPLETED = \"completed\",\n FAILED = \"failed\"\n}\n\nexport interface ImportExportTaskStats {\n [ImportExportTaskStatus.PENDING]: number;\n [ImportExportTaskStatus.PROCESSING]: number;\n [ImportExportTaskStatus.COMPLETED]: number;\n [ImportExportTaskStatus.FAILED]: number;\n total: number;\n}\n\ninterface CreatedBy {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ImportExportTask {\n id: string;\n parent: string;\n status: ImportExportTaskStatus;\n data: Record<string, any>;\n stats: ImportExportTaskStats;\n error: Record<string, any>;\n input: Record<string, any>;\n createdOn: string;\n createdBy: CreatedBy;\n tenant: string;\n locale: string;\n}\n\nexport interface File {\n id: string;\n src: string;\n}\n\nexport interface MetaResponse {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsListParams {\n where: {\n tenant: string;\n locale: string;\n };\n sort?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport type ImportExportTaskStorageOperationsListResponse = [ImportExportTask[], MetaResponse];\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsCreateParams {\n input: Record<string, any>;\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateParams {\n input: Record<string, any>;\n original: ImportExportTask;\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsDeleteParams {\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsGetSubTaskParams {\n where: {\n id: string;\n parent: string;\n tenant: string;\n locale: string;\n };\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsListSubTaskParams {\n where: {\n tenant: string;\n locale: string;\n parent: string;\n status: ImportExportTaskStatus;\n createdBy?: string;\n };\n sort?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport type ImportExportTaskStorageOperationsListSubTaskResponse = [\n ImportExportTask[],\n MetaResponse\n];\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsCreateSubTaskParams {\n input: Record<string, any>;\n subTask: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateSubTaskParams {\n input: Record<string, any>;\n original: ImportExportTask;\n subTask: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateTaskStatsParams {\n input: {\n prevStatus: ImportExportTaskStatus;\n nextStatus: ImportExportTaskStatus;\n };\n original: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperations {\n /**\n * Get a single import export task item by given params.\n */\n getTask(params: ImportExportTaskStorageOperationsGetParams): Promise<ImportExportTask | null>;\n\n /**\n * Get all import export tasks by given params.\n */\n listTasks(\n params: ImportExportTaskStorageOperationsListParams\n ): Promise<ImportExportTaskStorageOperationsListResponse>;\n\n createTask(params: ImportExportTaskStorageOperationsCreateParams): Promise<ImportExportTask>;\n\n updateTask(params: ImportExportTaskStorageOperationsUpdateParams): Promise<ImportExportTask>;\n\n deleteTask(params: ImportExportTaskStorageOperationsDeleteParams): Promise<ImportExportTask>;\n\n updateTaskStats(\n params: ImportExportTaskStorageOperationsUpdateTaskStatsParams\n ): Promise<ImportExportTask>;\n\n /**\n * Get a single import export sub-task item by given params.\n */\n getSubTask(\n params: ImportExportTaskStorageOperationsGetSubTaskParams\n ): Promise<ImportExportTask | null>;\n\n /**\n * Get all import export sub-tasks by given params.\n */\n listSubTasks(\n params: ImportExportTaskStorageOperationsListSubTaskParams\n ): Promise<ImportExportTaskStorageOperationsListSubTaskResponse>;\n\n createSubTask(\n params: ImportExportTaskStorageOperationsCreateSubTaskParams\n ): Promise<ImportExportTask>;\n\n updateSubTask(\n params: ImportExportTaskStorageOperationsUpdateSubTaskParams\n ): Promise<ImportExportTask>;\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["ExportRevisionType","ImportExportTaskStatus"],"sources":["types.ts"],"sourcesContent":["export * from \"./graphql/types\";\n\n// Entities.\nexport enum ExportRevisionType {\n PUBLISHED = \"published\",\n LATEST = \"latest\"\n}\n\nexport enum ImportExportTaskStatus {\n PENDING = \"pending\",\n PROCESSING = \"processing\",\n COMPLETED = \"completed\",\n FAILED = \"failed\"\n}\n\nexport interface ImportExportTaskStats {\n [ImportExportTaskStatus.PENDING]: number;\n [ImportExportTaskStatus.PROCESSING]: number;\n [ImportExportTaskStatus.COMPLETED]: number;\n [ImportExportTaskStatus.FAILED]: number;\n total: number;\n}\n\ninterface CreatedBy {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ImportExportTask {\n id: string;\n parent: string;\n status: ImportExportTaskStatus;\n data: Record<string, any>;\n stats: ImportExportTaskStats;\n error: Record<string, any>;\n input: Record<string, any>;\n createdOn: string;\n createdBy: CreatedBy;\n tenant: string;\n locale: string;\n}\n\nexport interface File {\n id: string;\n src: string;\n}\n\nexport interface MetaResponse {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsListParams {\n where: {\n tenant: string;\n locale: string;\n };\n sort?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport type ImportExportTaskStorageOperationsListResponse = [ImportExportTask[], MetaResponse];\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsCreateParams {\n input: Record<string, any>;\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateParams {\n input: Record<string, any>;\n original: ImportExportTask;\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsDeleteParams {\n task: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsGetSubTaskParams {\n where: {\n id: string;\n parent: string;\n tenant: string;\n locale: string;\n };\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsListSubTaskParams {\n where: {\n tenant: string;\n locale: string;\n parent: string;\n status: ImportExportTaskStatus;\n createdBy?: string;\n };\n sort?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport type ImportExportTaskStorageOperationsListSubTaskResponse = [\n ImportExportTask[],\n MetaResponse\n];\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsCreateSubTaskParams {\n input: Record<string, any>;\n subTask: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateSubTaskParams {\n input: Record<string, any>;\n original: ImportExportTask;\n subTask: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperationsUpdateTaskStatsParams {\n input: {\n prevStatus: ImportExportTaskStatus;\n nextStatus: ImportExportTaskStatus;\n };\n original: ImportExportTask;\n}\n\n/**\n * @category StorageOperations\n * @category ImportExportTaskStorageOperations\n */\nexport interface ImportExportTaskStorageOperations {\n /**\n * Get a single import export task item by given params.\n */\n getTask(params: ImportExportTaskStorageOperationsGetParams): Promise<ImportExportTask | null>;\n\n /**\n * Get all import export tasks by given params.\n */\n listTasks(\n params: ImportExportTaskStorageOperationsListParams\n ): Promise<ImportExportTaskStorageOperationsListResponse>;\n\n createTask(params: ImportExportTaskStorageOperationsCreateParams): Promise<ImportExportTask>;\n\n updateTask(params: ImportExportTaskStorageOperationsUpdateParams): Promise<ImportExportTask>;\n\n deleteTask(params: ImportExportTaskStorageOperationsDeleteParams): Promise<ImportExportTask>;\n\n updateTaskStats(\n params: ImportExportTaskStorageOperationsUpdateTaskStatsParams\n ): Promise<ImportExportTask>;\n\n /**\n * Get a single import export sub-task item by given params.\n */\n getSubTask(\n params: ImportExportTaskStorageOperationsGetSubTaskParams\n ): Promise<ImportExportTask | null>;\n\n /**\n * Get all import export sub-tasks by given params.\n */\n listSubTasks(\n params: ImportExportTaskStorageOperationsListSubTaskParams\n ): Promise<ImportExportTaskStorageOperationsListSubTaskResponse>;\n\n createSubTask(\n params: ImportExportTaskStorageOperationsCreateSubTaskParams\n ): Promise<ImportExportTask>;\n\n updateSubTask(\n params: ImportExportTaskStorageOperationsUpdateSubTaskParams\n ): Promise<ImportExportTask>;\n}\n\nexport interface FileUploadsData {\n /**\n * Location of export data file. Export data contains the relevant entity data (block, page, template), and an\n * array of file objects, exported from the DB, that need to be imported.\n *\n * Example:\n * 'IMPORTS/8lf6y7xp5/8lf6x9v68-header-1/8lf6x9v69-header-1/Header #1.json'\n */\n data: string;\n /**\n * Example:\n * '8ldspraka-9l9iaffak-1.jpeg': 'IMPORTS/8lf6y7xp5/8lf6x9v68-header-1/assets/8ldspraka-9l9iaffak-1.jpeg',\n * '8ldwyq8ao-pb-editor-page-element-rzfKWtdTWN.png': 'IMPORTS/8lf6y7xp5/8lf6x9v69-header-1/assets/8ldwyq8ao-pb-editor-page-element-rzfKWtdTWN.png'\n */\n assets: Record<string, string>;\n}\n\nexport interface ImportData {\n assets: Record<string, string>;\n data: string;\n key: string;\n}\n"],"mappings":";;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA;AAAA,IACYA,kBAAkB;AAAA;AAAA,WAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;AAAA,GAAlBA,kBAAkB,kCAAlBA,kBAAkB;AAAA,IAKlBC,sBAAsB;AAAA;AAAA,WAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,sCAAtBA,sBAAsB"}
|