@webiny/api-page-builder-import-export 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959
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 +12 -21
- package/client.js.map +1 -1
- package/export/combine/blocksHandler.js +4 -2
- package/export/combine/blocksHandler.js.map +1 -1
- package/export/combine/formsHandler.d.ts +6 -0
- package/export/combine/formsHandler.js +101 -0
- package/export/combine/formsHandler.js.map +1 -0
- package/export/combine/index.js +24 -15
- package/export/combine/index.js.map +1 -1
- package/export/combine/pagesHandler.js +4 -2
- package/export/combine/pagesHandler.js.map +1 -1
- package/export/combine/templatesHandler.js +4 -2
- package/export/combine/templatesHandler.js.map +1 -1
- package/export/process/blocksHandler.js +13 -6
- package/export/process/blocksHandler.js.map +1 -1
- package/export/process/exporters/BlockExporter.d.ts +12 -0
- package/export/process/exporters/BlockExporter.js +57 -0
- package/export/process/exporters/BlockExporter.js.map +1 -0
- package/export/process/exporters/FormExporter.d.ts +9 -0
- package/export/process/exporters/FormExporter.js +36 -0
- package/export/process/exporters/FormExporter.js.map +1 -0
- package/export/process/exporters/PageExporter.d.ts +11 -0
- package/export/process/exporters/PageExporter.js +58 -0
- package/export/process/exporters/PageExporter.js.map +1 -0
- package/export/process/exporters/PageTemplateExporter.d.ts +11 -0
- package/export/process/exporters/PageTemplateExporter.js +56 -0
- package/export/process/exporters/PageTemplateExporter.js.map +1 -0
- package/export/process/formsHandler.d.ts +6 -0
- package/export/process/formsHandler.js +189 -0
- package/export/process/formsHandler.js.map +1 -0
- package/export/process/index.js +24 -15
- package/export/process/index.js.map +1 -1
- package/export/process/pagesHandler.js +8 -6
- package/export/process/pagesHandler.js.map +1 -1
- package/export/process/templatesHandler.js +8 -6
- package/export/process/templatesHandler.js.map +1 -1
- package/export/s3Stream.d.ts +13 -10
- package/export/s3Stream.js +27 -22
- package/export/s3Stream.js.map +1 -1
- package/export/utils.d.ts +10 -8
- package/export/utils.js +29 -18
- package/export/utils.js.map +1 -1
- package/export/zipper.d.ts +5 -5
- package/export/zipper.js +20 -24
- package/export/zipper.js.map +1 -1
- package/graphql/crud/blocks.crud.js +50 -28
- package/graphql/crud/blocks.crud.js.map +1 -1
- package/graphql/crud/forms.crud.d.ts +4 -0
- package/graphql/crud/forms.crud.js +163 -0
- package/graphql/crud/forms.crud.js.map +1 -0
- package/graphql/crud/importExportTasks.crud.js +81 -63
- package/graphql/crud/importExportTasks.crud.js.map +1 -1
- package/graphql/crud/pages.crud.d.ts +1 -0
- package/graphql/crud/pages.crud.js +58 -24
- package/graphql/crud/pages.crud.js.map +1 -1
- package/graphql/crud/templates.crud.js +48 -15
- package/graphql/crud/templates.crud.js.map +1 -1
- package/graphql/crud.js +5 -2
- package/graphql/crud.js.map +1 -1
- package/graphql/graphql/blocks.gql.js +4 -2
- package/graphql/graphql/blocks.gql.js.map +1 -1
- package/graphql/graphql/forms.gql.d.ts +4 -0
- package/graphql/graphql/forms.gql.js +62 -0
- package/graphql/graphql/forms.gql.js.map +1 -0
- package/graphql/graphql/importExportTasks.gql.js +3 -1
- package/graphql/graphql/importExportTasks.gql.js.map +1 -1
- package/graphql/graphql/pages.gql.js +3 -1
- package/graphql/graphql/pages.gql.js.map +1 -1
- package/graphql/graphql/templates.gql.js +3 -1
- package/graphql/graphql/templates.gql.js.map +1 -1
- package/graphql/graphql/utils/resolve.d.ts +1 -1
- package/graphql/graphql/utils/resolve.js +3 -1
- package/graphql/graphql/utils/resolve.js.map +1 -1
- package/graphql/graphql.js +5 -2
- package/graphql/graphql.js.map +1 -1
- package/graphql/index.js +3 -1
- package/graphql/index.js.map +1 -1
- package/graphql/types.d.ts +136 -1
- package/graphql/types.js +3 -1
- package/graphql/types.js.map +1 -1
- package/import/constants.d.ts +3 -0
- package/import/constants.js +16 -0
- package/import/constants.js.map +1 -0
- package/import/create/blocksHandler.js +7 -6
- package/import/create/blocksHandler.js.map +1 -1
- package/import/{process/pagesHandler.d.ts → create/formsHandler.d.ts} +1 -1
- package/import/create/formsHandler.js +105 -0
- package/import/create/formsHandler.js.map +1 -0
- package/import/create/index.js +24 -15
- package/import/create/index.js.map +1 -1
- package/import/create/pagesHandler.js +6 -3
- package/import/create/pagesHandler.js.map +1 -1
- package/import/create/templatesHandler.js +5 -2
- package/import/create/templatesHandler.js.map +1 -1
- package/import/process/{blocksHandler.d.ts → blocks/blocksHandler.d.ts} +2 -2
- package/import/process/{blocksHandler.js → blocks/blocksHandler.js} +13 -13
- package/import/process/blocks/blocksHandler.js.map +1 -0
- package/import/process/blocks/importBlock.d.ts +11 -0
- package/import/process/blocks/importBlock.js +98 -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 +178 -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 +47 -0
- package/import/process/forms/importForm.js.map +1 -0
- package/import/process/index.js +27 -18
- package/import/process/index.js.map +1 -1
- package/import/process/pages/importPage.d.ts +11 -0
- package/import/process/pages/importPage.js +94 -0
- package/import/process/pages/importPage.js.map +1 -0
- package/import/process/pages/pagesHandler.d.ts +3 -0
- package/import/process/{pagesHandler.js → pages/pagesHandler.js} +16 -8
- package/import/process/pages/pagesHandler.js.map +1 -0
- package/import/process/templates/importTemplate.d.ts +11 -0
- package/import/process/templates/importTemplate.js +70 -0
- package/import/process/templates/importTemplate.js.map +1 -0
- package/import/process/{templatesHandler.d.ts → templates/templatesHandler.d.ts} +2 -2
- package/import/process/{templatesHandler.js → templates/templatesHandler.js} +11 -8
- package/import/process/templates/templatesHandler.js.map +1 -0
- package/import/utils/deleteS3Folder.d.ts +1 -0
- package/import/utils/deleteS3Folder.js +21 -0
- package/import/utils/deleteS3Folder.js.map +1 -0
- package/import/utils/extractAndUploadZipFileContents.d.ts +7 -0
- package/import/utils/extractAndUploadZipFileContents.js +123 -0
- package/import/utils/extractAndUploadZipFileContents.js.map +1 -0
- package/import/utils/extractZipAndUploadToS3.d.ts +2 -0
- package/import/utils/extractZipAndUploadToS3.js +100 -0
- package/import/utils/extractZipAndUploadToS3.js.map +1 -0
- package/import/utils/getFileNameWithoutExt.d.ts +1 -0
- package/import/utils/getFileNameWithoutExt.js +13 -0
- package/import/utils/getFileNameWithoutExt.js.map +1 -0
- package/import/utils/index.d.ts +9 -0
- package/import/utils/index.js +106 -0
- package/import/utils/index.js.map +1 -0
- package/import/utils/initialStats.d.ts +7 -0
- package/import/utils/initialStats.js +18 -0
- package/import/utils/initialStats.js.map +1 -0
- package/import/utils/prepareDataDirMap.d.ts +6 -0
- package/import/utils/prepareDataDirMap.js +31 -0
- package/import/utils/prepareDataDirMap.js.map +1 -0
- package/import/utils/updateFilesInData.d.ts +8 -0
- package/import/utils/updateFilesInData.js +51 -0
- package/import/utils/updateFilesInData.js.map +1 -0
- package/import/utils/uploadAssets.d.ts +10 -0
- package/import/utils/uploadAssets.js +92 -0
- package/import/utils/uploadAssets.js.map +1 -0
- package/import/utils/uploadFilesFromS3.d.ts +3 -0
- package/import/utils/uploadFilesFromS3.js +21 -0
- package/import/utils/uploadFilesFromS3.js.map +1 -0
- package/mockSecurity.js +3 -2
- package/mockSecurity.js.map +1 -1
- package/package.json +35 -43
- package/types.d.ts +21 -0
- package/types.js +62 -8
- package/types.js.map +1 -1
- package/import/process/blocksHandler.js.map +0 -1
- package/import/process/pagesHandler.js.map +0 -1
- package/import/process/templatesHandler.js.map +0 -1
- package/import/utils.d.ts +0 -56
- package/import/utils.js +0 -607
- package/import/utils.js.map +0 -1
@@ -0,0 +1,100 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.extractZipAndUploadToS3 = extractZipAndUploadToS3;
|
8
|
+
var _yauzl = _interopRequireDefault(require("yauzl"));
|
9
|
+
var _stream = require("stream");
|
10
|
+
var _util = require("util");
|
11
|
+
var _s3Stream = require("../../export/s3Stream");
|
12
|
+
var _getFileNameWithoutExt = require("./getFileNameWithoutExt");
|
13
|
+
var _prepareDataDirMap = require("./prepareDataDirMap");
|
14
|
+
const FILE_CONTENT_TYPE = "application/octet-stream";
|
15
|
+
const streamPipeline = (0, _util.promisify)(_stream.pipeline);
|
16
|
+
function extractZipAndUploadToS3(dataZipFilePath, uniquePath) {
|
17
|
+
return new Promise((resolve, reject) => {
|
18
|
+
const filePaths = [];
|
19
|
+
const fileUploadPromises = [];
|
20
|
+
const uniqueKey = (0, _getFileNameWithoutExt.getFileNameWithoutExt)(dataZipFilePath);
|
21
|
+
let dataMap = {
|
22
|
+
key: uniqueKey,
|
23
|
+
assets: {},
|
24
|
+
data: ""
|
25
|
+
};
|
26
|
+
_yauzl.default.open(dataZipFilePath, {
|
27
|
+
lazyEntries: true
|
28
|
+
}, function (err, zipFile) {
|
29
|
+
if (err) {
|
30
|
+
console.warn("ERROR: Failed to extract zip: ", dataZipFilePath, err);
|
31
|
+
reject(err);
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
if (!zipFile) {
|
35
|
+
console.log("ERROR: Probably failed to extract zip: " + dataZipFilePath);
|
36
|
+
reject("Missing Zip File Resource.");
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
console.info(`The ZIP file contains ${zipFile.entryCount} entries.`);
|
40
|
+
zipFile.on("end", function (err) {
|
41
|
+
if (err) {
|
42
|
+
console.warn('ERROR: Failed on "END" for file: ', dataZipFilePath, err);
|
43
|
+
reject(err);
|
44
|
+
}
|
45
|
+
Promise.all(fileUploadPromises).then(res => {
|
46
|
+
res.forEach(r => {
|
47
|
+
console.info("Done uploading... ", r);
|
48
|
+
});
|
49
|
+
resolve(dataMap);
|
50
|
+
});
|
51
|
+
});
|
52
|
+
zipFile.readEntry();
|
53
|
+
zipFile.on("entry", function (entry) {
|
54
|
+
console.info(`Processing entry: "${entry.fileName}"`);
|
55
|
+
if (/\/$/.test(entry.fileName)) {
|
56
|
+
// Directory file names end with '/'.
|
57
|
+
// Note that entries for directories themselves are optional.
|
58
|
+
// An entry's fileName implicitly requires its parent directories to exist.
|
59
|
+
zipFile.readEntry();
|
60
|
+
} else {
|
61
|
+
// file entry
|
62
|
+
zipFile.openReadStream(entry, function (err, readStream) {
|
63
|
+
if (err) {
|
64
|
+
console.warn("ERROR: Failed while performing [openReadStream] for file: ", entry.fileName, err);
|
65
|
+
reject(err);
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
if (!readStream) {
|
69
|
+
console.log("ERROR: Missing Read Stream while importing.");
|
70
|
+
reject("Missing Read Strea Resource.");
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
readStream.on("end", function () {
|
74
|
+
filePaths.push(entry.fileName);
|
75
|
+
zipFile.readEntry();
|
76
|
+
});
|
77
|
+
const newKey = `${uniquePath}/${uniqueKey}/${entry.fileName}`;
|
78
|
+
// Modify in place
|
79
|
+
dataMap = (0, _prepareDataDirMap.prepareDataDirMap)({
|
80
|
+
map: dataMap,
|
81
|
+
filePath: entry.fileName,
|
82
|
+
newKey
|
83
|
+
});
|
84
|
+
const {
|
85
|
+
streamPassThrough,
|
86
|
+
streamPassThroughUploadPromise: promise
|
87
|
+
} = _s3Stream.s3Stream.writeStream(newKey, FILE_CONTENT_TYPE);
|
88
|
+
streamPipeline(readStream, streamPassThrough).then(() => {
|
89
|
+
fileUploadPromises.push(promise);
|
90
|
+
}).catch(error => {
|
91
|
+
reject(error);
|
92
|
+
});
|
93
|
+
});
|
94
|
+
}
|
95
|
+
});
|
96
|
+
});
|
97
|
+
});
|
98
|
+
}
|
99
|
+
|
100
|
+
//# sourceMappingURL=extractZipAndUploadToS3.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_yauzl","_interopRequireDefault","require","_stream","_util","_s3Stream","_getFileNameWithoutExt","_prepareDataDirMap","FILE_CONTENT_TYPE","streamPipeline","promisify","pipeline","extractZipAndUploadToS3","dataZipFilePath","uniquePath","Promise","resolve","reject","filePaths","fileUploadPromises","uniqueKey","getFileNameWithoutExt","dataMap","key","assets","data","yauzl","open","lazyEntries","err","zipFile","console","warn","log","info","entryCount","on","all","then","res","forEach","r","readEntry","entry","fileName","test","openReadStream","readStream","push","newKey","prepareDataDirMap","map","filePath","streamPassThrough","streamPassThroughUploadPromise","promise","s3Stream","writeStream","catch","error"],"sources":["extractZipAndUploadToS3.ts"],"sourcesContent":["import yauzl from \"yauzl\";\nimport { pipeline } from \"stream\";\nimport { promisify } from \"util\";\nimport { CompleteMultipartUploadOutput } from \"@webiny/aws-sdk/client-s3\";\nimport { s3Stream } from \"~/export/s3Stream\";\nimport { getFileNameWithoutExt } from \"./getFileNameWithoutExt\";\nimport { ImportData } from \"~/types\";\nimport { prepareDataDirMap } from \"~/import/utils/prepareDataDirMap\";\n\nconst FILE_CONTENT_TYPE = \"application/octet-stream\";\nconst streamPipeline = promisify(pipeline);\n\nexport function extractZipAndUploadToS3(\n dataZipFilePath: string,\n uniquePath: string\n): Promise<ImportData> {\n return new Promise((resolve, reject) => {\n const filePaths = [];\n const fileUploadPromises: Promise<CompleteMultipartUploadOutput>[] = [];\n const uniqueKey = getFileNameWithoutExt(dataZipFilePath);\n let dataMap: ImportData = {\n key: uniqueKey,\n assets: {},\n data: \"\"\n };\n yauzl.open(dataZipFilePath, { lazyEntries: true }, function (err, zipFile) {\n if (err) {\n console.warn(\"ERROR: Failed to extract zip: \", dataZipFilePath, err);\n reject(err);\n return;\n }\n if (!zipFile) {\n console.log(\"ERROR: Probably failed to extract zip: \" + dataZipFilePath);\n reject(\"Missing Zip File Resource.\");\n return;\n }\n console.info(`The ZIP file contains ${zipFile.entryCount} entries.`);\n zipFile.on(\"end\", function (err) {\n if (err) {\n console.warn('ERROR: Failed on \"END\" for file: ', dataZipFilePath, err);\n reject(err);\n }\n\n Promise.all(fileUploadPromises).then(res => {\n res.forEach(r => {\n console.info(\"Done uploading... \", r);\n });\n resolve(dataMap);\n });\n });\n\n zipFile.readEntry();\n\n zipFile.on(\"entry\", function (entry) {\n console.info(`Processing entry: \"${entry.fileName}\"`);\n if (/\\/$/.test(entry.fileName)) {\n // Directory file names end with '/'.\n // Note that entries for directories themselves are optional.\n // An entry's fileName implicitly requires its parent directories to exist.\n zipFile.readEntry();\n } else {\n // file entry\n zipFile.openReadStream(entry, function (err, readStream) {\n if (err) {\n console.warn(\n \"ERROR: Failed while performing [openReadStream] for file: \",\n entry.fileName,\n err\n );\n reject(err);\n return;\n }\n if (!readStream) {\n console.log(\"ERROR: Missing Read Stream while importing.\");\n reject(\"Missing Read Strea Resource.\");\n return;\n }\n readStream.on(\"end\", function () {\n filePaths.push(entry.fileName);\n zipFile.readEntry();\n });\n\n const newKey = `${uniquePath}/${uniqueKey}/${entry.fileName}`;\n // Modify in place\n dataMap = prepareDataDirMap({\n map: dataMap,\n filePath: entry.fileName,\n newKey\n });\n\n const { streamPassThrough, streamPassThroughUploadPromise: promise } =\n s3Stream.writeStream(newKey, FILE_CONTENT_TYPE);\n\n streamPipeline(readStream, streamPassThrough)\n .then(() => {\n fileUploadPromises.push(promise);\n })\n .catch(error => {\n reject(error);\n });\n });\n }\n });\n });\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AAEA,IAAAK,kBAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAG,0BAA0B;AACpD,MAAMC,cAAc,GAAG,IAAAC,eAAS,EAACC,gBAAQ,CAAC;AAEnC,SAASC,uBAAuBA,CACnCC,eAAuB,EACvBC,UAAkB,EACC;EACnB,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACpC,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CAAC;YACpC,CAAC,CAAC,CACDG,KAAK,CAACC,KAAK,IAAI;cACZ1C,MAAM,CAAC0C,KAAK,CAAC;YACjB,CAAC,CAAC;UACV,CAAC,CAAC;QACN;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function getFileNameWithoutExt(fileName: string): string;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.getFileNameWithoutExt = getFileNameWithoutExt;
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
function getFileNameWithoutExt(fileName) {
|
10
|
+
return _path.default.basename(fileName).replace(_path.default.extname(fileName), "");
|
11
|
+
}
|
12
|
+
|
13
|
+
//# sourceMappingURL=getFileNameWithoutExt.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_path","_interopRequireDefault","require","getFileNameWithoutExt","fileName","path","basename","replace","extname"],"sources":["getFileNameWithoutExt.ts"],"sourcesContent":["import path from \"path\";\n\nexport function getFileNameWithoutExt(fileName: string): string {\n return path.basename(fileName).replace(path.extname(fileName), \"\");\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,SAASC,qBAAqBA,CAACC,QAAgB,EAAU;EAC5D,OAAOC,aAAI,CAACC,QAAQ,CAACF,QAAQ,CAAC,CAACG,OAAO,CAACF,aAAI,CAACG,OAAO,CAACJ,QAAQ,CAAC,EAAE,EAAE,CAAC;AACtE"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from "./initialStats";
|
2
|
+
export * from "./uploadFilesFromS3";
|
3
|
+
export * from "./uploadAssets";
|
4
|
+
export * from "./updateFilesInData";
|
5
|
+
export * from "./prepareDataDirMap";
|
6
|
+
export * from "./getFileNameWithoutExt";
|
7
|
+
export * from "./extractZipAndUploadToS3";
|
8
|
+
export * from "./extractAndUploadZipFileContents";
|
9
|
+
export * from "./deleteS3Folder";
|
@@ -0,0 +1,106 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
var _initialStats = require("./initialStats");
|
7
|
+
Object.keys(_initialStats).forEach(function (key) {
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
9
|
+
if (key in exports && exports[key] === _initialStats[key]) return;
|
10
|
+
Object.defineProperty(exports, key, {
|
11
|
+
enumerable: true,
|
12
|
+
get: function () {
|
13
|
+
return _initialStats[key];
|
14
|
+
}
|
15
|
+
});
|
16
|
+
});
|
17
|
+
var _uploadFilesFromS = require("./uploadFilesFromS3");
|
18
|
+
Object.keys(_uploadFilesFromS).forEach(function (key) {
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
20
|
+
if (key in exports && exports[key] === _uploadFilesFromS[key]) return;
|
21
|
+
Object.defineProperty(exports, key, {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return _uploadFilesFromS[key];
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
28
|
+
var _uploadAssets = require("./uploadAssets");
|
29
|
+
Object.keys(_uploadAssets).forEach(function (key) {
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
31
|
+
if (key in exports && exports[key] === _uploadAssets[key]) return;
|
32
|
+
Object.defineProperty(exports, key, {
|
33
|
+
enumerable: true,
|
34
|
+
get: function () {
|
35
|
+
return _uploadAssets[key];
|
36
|
+
}
|
37
|
+
});
|
38
|
+
});
|
39
|
+
var _updateFilesInData = require("./updateFilesInData");
|
40
|
+
Object.keys(_updateFilesInData).forEach(function (key) {
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
42
|
+
if (key in exports && exports[key] === _updateFilesInData[key]) return;
|
43
|
+
Object.defineProperty(exports, key, {
|
44
|
+
enumerable: true,
|
45
|
+
get: function () {
|
46
|
+
return _updateFilesInData[key];
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
var _prepareDataDirMap = require("./prepareDataDirMap");
|
51
|
+
Object.keys(_prepareDataDirMap).forEach(function (key) {
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
53
|
+
if (key in exports && exports[key] === _prepareDataDirMap[key]) return;
|
54
|
+
Object.defineProperty(exports, key, {
|
55
|
+
enumerable: true,
|
56
|
+
get: function () {
|
57
|
+
return _prepareDataDirMap[key];
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
61
|
+
var _getFileNameWithoutExt = require("./getFileNameWithoutExt");
|
62
|
+
Object.keys(_getFileNameWithoutExt).forEach(function (key) {
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
64
|
+
if (key in exports && exports[key] === _getFileNameWithoutExt[key]) return;
|
65
|
+
Object.defineProperty(exports, key, {
|
66
|
+
enumerable: true,
|
67
|
+
get: function () {
|
68
|
+
return _getFileNameWithoutExt[key];
|
69
|
+
}
|
70
|
+
});
|
71
|
+
});
|
72
|
+
var _extractZipAndUploadToS = require("./extractZipAndUploadToS3");
|
73
|
+
Object.keys(_extractZipAndUploadToS).forEach(function (key) {
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
75
|
+
if (key in exports && exports[key] === _extractZipAndUploadToS[key]) return;
|
76
|
+
Object.defineProperty(exports, key, {
|
77
|
+
enumerable: true,
|
78
|
+
get: function () {
|
79
|
+
return _extractZipAndUploadToS[key];
|
80
|
+
}
|
81
|
+
});
|
82
|
+
});
|
83
|
+
var _extractAndUploadZipFileContents = require("./extractAndUploadZipFileContents");
|
84
|
+
Object.keys(_extractAndUploadZipFileContents).forEach(function (key) {
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
86
|
+
if (key in exports && exports[key] === _extractAndUploadZipFileContents[key]) return;
|
87
|
+
Object.defineProperty(exports, key, {
|
88
|
+
enumerable: true,
|
89
|
+
get: function () {
|
90
|
+
return _extractAndUploadZipFileContents[key];
|
91
|
+
}
|
92
|
+
});
|
93
|
+
});
|
94
|
+
var _deleteS3Folder = require("./deleteS3Folder");
|
95
|
+
Object.keys(_deleteS3Folder).forEach(function (key) {
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
97
|
+
if (key in exports && exports[key] === _deleteS3Folder[key]) return;
|
98
|
+
Object.defineProperty(exports, key, {
|
99
|
+
enumerable: true,
|
100
|
+
get: function () {
|
101
|
+
return _deleteS3Folder[key];
|
102
|
+
}
|
103
|
+
});
|
104
|
+
});
|
105
|
+
|
106
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_initialStats","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_uploadFilesFromS","_uploadAssets","_updateFilesInData","_prepareDataDirMap","_getFileNameWithoutExt","_extractZipAndUploadToS","_extractAndUploadZipFileContents","_deleteS3Folder"],"sources":["index.ts"],"sourcesContent":["export * from \"./initialStats\";\nexport * from \"./uploadFilesFromS3\";\nexport * from \"./uploadAssets\";\nexport * from \"./updateFilesInData\";\nexport * from \"./prepareDataDirMap\";\nexport * from \"./getFileNameWithoutExt\";\nexport * from \"./extractZipAndUploadToS3\";\nexport * from \"./extractAndUploadZipFileContents\";\nexport * from \"./deleteS3Folder\";\n"],"mappings":";;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,aAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,aAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,aAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA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,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,gCAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,eAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,eAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,eAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,eAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA"}
|
@@ -0,0 +1,18 @@
|
|
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
|
+
}
|
17
|
+
|
18
|
+
//# sourceMappingURL=initialStats.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_types","require","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,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,YAAYA,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,31 @@
|
|
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
|
+
}
|
30
|
+
|
31
|
+
//# sourceMappingURL=prepareDataDirMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_dotPropImmutable","_interopRequireDefault","require","_constants","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,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEO,SAASE,iBAAiBA,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,CAAC,CAAW;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,51 @@
|
|
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 an 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.id = newFile.id;
|
38
|
+
value.key = newFile.key;
|
39
|
+
value.name = newFile.name;
|
40
|
+
value.src = `${cleanSrcPrefix}/${newFile.key}`;
|
41
|
+
} else {
|
42
|
+
updateFilesInData({
|
43
|
+
data: value,
|
44
|
+
srcPrefix,
|
45
|
+
fileIdToNewFileMap
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
//# sourceMappingURL=updateFilesInData.js.map
|
@@ -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 an 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.id = newFile.id;\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,iBAAiBA,CAAC;EAC9BC,IAAI;EACJC,kBAAkB;EAClBC;AACqB,CAAC,EAAE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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,92 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.uploadAssets = void 0;
|
7
|
+
var _utils = require("@webiny/utils");
|
8
|
+
var _uploadFilesFromS = require("./uploadFilesFromS3");
|
9
|
+
function notAPreviouslyImportedFile(importedImages) {
|
10
|
+
return file => {
|
11
|
+
return !importedImages.some(existingImportedImage => existingImportedImage.meta.originalKey === file.key);
|
12
|
+
};
|
13
|
+
}
|
14
|
+
function notAnExistingFile(existingFiles) {
|
15
|
+
return file => {
|
16
|
+
return !existingFiles.some(existingFile => existingFile.key === file.key);
|
17
|
+
};
|
18
|
+
}
|
19
|
+
const uploadAssets = async params => {
|
20
|
+
const {
|
21
|
+
context,
|
22
|
+
files,
|
23
|
+
fileUploadsData
|
24
|
+
} = params;
|
25
|
+
const oldIdToNewFileMap = new Map();
|
26
|
+
|
27
|
+
/**
|
28
|
+
* This function contains logic of file download from S3.
|
29
|
+
* Current we're not mocking zip file download from S3 in tests at the moment.
|
30
|
+
* So, we're manually mocking it in case of test just by returning an empty object.
|
31
|
+
*/
|
32
|
+
if (process.env.NODE_ENV === "test") {
|
33
|
+
return oldIdToNewFileMap;
|
34
|
+
}
|
35
|
+
|
36
|
+
// Check if the requested files were already imported in the past.
|
37
|
+
const [importedImages] = await context.fileManager.listFiles({
|
38
|
+
where: {
|
39
|
+
meta: {
|
40
|
+
originalKey_in: files.map(file => file.key)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
// Link files that were already imported.
|
46
|
+
for (const importedImage of importedImages) {
|
47
|
+
const fileBeingImported = files.find(file => file.key === importedImage.meta.originalKey);
|
48
|
+
if (fileBeingImported) {
|
49
|
+
oldIdToNewFileMap.set(fileBeingImported.id, importedImage);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
// Check if files with such IDs already exist.
|
54
|
+
const [existingFiles] = await context.fileManager.listFiles({
|
55
|
+
where: {
|
56
|
+
id_in: files.map(file => file.id)
|
57
|
+
}
|
58
|
+
});
|
59
|
+
const newFilesToImport = files.filter(notAnExistingFile(existingFiles)).filter(notAPreviouslyImportedFile(importedImages));
|
60
|
+
|
61
|
+
// A map of temporary file keys (created during ZIP upload) to permanent file keys.
|
62
|
+
const uploadFileMap = new Map();
|
63
|
+
|
64
|
+
// Array of file inputs, to insert into the DB.
|
65
|
+
const createFilesInput = [];
|
66
|
+
for (const toImport of newFilesToImport) {
|
67
|
+
// We generate a new file id, key, and add `meta.originalKey` property to prevent duplicates on future imports.
|
68
|
+
const id = (0, _utils.mdbid)();
|
69
|
+
const newKey = `${id}/${toImport.key.replace(`${toImport.id}/`, "")}`;
|
70
|
+
const newFile = {
|
71
|
+
...toImport,
|
72
|
+
id,
|
73
|
+
location: {
|
74
|
+
folderId: "root"
|
75
|
+
},
|
76
|
+
key: newKey,
|
77
|
+
meta: {
|
78
|
+
...toImport.meta,
|
79
|
+
originalKey: toImport.key
|
80
|
+
}
|
81
|
+
};
|
82
|
+
createFilesInput.push(newFile);
|
83
|
+
oldIdToNewFileMap.set(toImport.id, newFile);
|
84
|
+
uploadFileMap.set(fileUploadsData.assets[toImport.key], newFile);
|
85
|
+
}
|
86
|
+
await (0, _uploadFilesFromS.uploadFilesFromS3)(uploadFileMap);
|
87
|
+
await context.fileManager.createFilesInBatch(createFilesInput);
|
88
|
+
return oldIdToNewFileMap;
|
89
|
+
};
|
90
|
+
exports.uploadAssets = uploadAssets;
|
91
|
+
|
92
|
+
//# sourceMappingURL=uploadAssets.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_utils","require","_uploadFilesFromS","notAPreviouslyImportedFile","importedImages","file","some","existingImportedImage","meta","originalKey","key","notAnExistingFile","existingFiles","existingFile","uploadAssets","params","context","files","fileUploadsData","oldIdToNewFileMap","Map","process","env","NODE_ENV","fileManager","listFiles","where","originalKey_in","map","importedImage","fileBeingImported","find","set","id","id_in","newFilesToImport","filter","uploadFileMap","createFilesInput","toImport","mdbid","newKey","replace","newFile","location","folderId","push","assets","uploadFilesFromS3","createFilesInBatch","exports"],"sources":["uploadAssets.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { 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\nfunction notAPreviouslyImportedFile(importedImages: File[]) {\n return (file: File) => {\n return !importedImages.some(\n existingImportedImage => existingImportedImage.meta.originalKey === file.key\n );\n };\n}\n\nfunction notAnExistingFile(existingFiles: File[]) {\n return (file: File) => {\n return !existingFiles.some(existingFile => existingFile.key === file.key);\n };\n}\n\nexport const uploadAssets = async (params: UploadAssetsParams) => {\n const { context, files, fileUploadsData } = params;\n\n const oldIdToNewFileMap = new Map<string, FileInput>();\n\n /**\n * This function contains logic of file download from S3.\n * Current we're not mocking zip file download from S3 in tests at the moment.\n * So, we're manually mocking it in case of test just by returning an empty object.\n */\n if (process.env.NODE_ENV === \"test\") {\n return oldIdToNewFileMap;\n }\n\n // Check if the requested files were already imported in the past.\n const [importedImages] = await context.fileManager.listFiles({\n where: { meta: { originalKey_in: files.map(file => file.key) } }\n });\n\n // Link files that were already imported.\n for (const importedImage of importedImages) {\n const fileBeingImported = files.find(file => file.key === importedImage.meta.originalKey);\n\n if (fileBeingImported) {\n oldIdToNewFileMap.set(fileBeingImported.id, importedImage);\n }\n }\n\n // Check if files with such IDs already exist.\n const [existingFiles] = await context.fileManager.listFiles({\n where: { id_in: files.map(file => file.id) }\n });\n\n const newFilesToImport = files\n .filter(notAnExistingFile(existingFiles))\n .filter(notAPreviouslyImportedFile(importedImages));\n\n // A map of temporary file keys (created during ZIP upload) to permanent file keys.\n const uploadFileMap: UploadFileMap = new Map();\n\n // Array of file inputs, to insert into the DB.\n const createFilesInput: FileInput[] = [];\n\n for (const toImport of newFilesToImport) {\n // We generate a new file id, key, and add `meta.originalKey` property to prevent duplicates on future imports.\n const id = mdbid();\n const newKey = `${id}/${toImport.key.replace(`${toImport.id}/`, \"\")}`;\n const newFile: FileInput = {\n ...toImport,\n id,\n location: {\n folderId: \"root\"\n },\n key: newKey,\n meta: { ...toImport.meta, originalKey: toImport.key }\n };\n\n createFilesInput.push(newFile);\n oldIdToNewFileMap.set(toImport.id, newFile);\n uploadFileMap.set(fileUploadsData.assets[toImport.key], newFile);\n }\n\n await uploadFilesFromS3(uploadFileMap);\n\n await context.fileManager.createFilesInBatch(createFilesInput);\n\n return oldIdToNewFileMap;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAD,OAAA;AASA,SAASE,0BAA0BA,CAACC,cAAsB,EAAE;EACxD,OAAQC,IAAU,IAAK;IACnB,OAAO,CAACD,cAAc,CAACE,IAAI,CACvBC,qBAAqB,IAAIA,qBAAqB,CAACC,IAAI,CAACC,WAAW,KAAKJ,IAAI,CAACK,GAC7E,CAAC;EACL,CAAC;AACL;AAEA,SAASC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
|
+
export declare type UploadFileMap = Map<string, FileInput>;
|
3
|
+
export declare function uploadFilesFromS3(fileMap: UploadFileMap): Promise<(import("@aws-sdk/client-s3").AbortMultipartUploadCommandOutput | import("@aws-sdk/client-s3").CompleteMultipartUploadCommandOutput)[]>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.uploadFilesFromS3 = uploadFilesFromS3;
|
7
|
+
var _s3Stream = require("../../export/s3Stream");
|
8
|
+
async function uploadFilesFromS3(fileMap) {
|
9
|
+
const promises = [];
|
10
|
+
for (const [source, target] of Array.from(fileMap.entries())) {
|
11
|
+
// Read file.
|
12
|
+
const readStream = await _s3Stream.s3Stream.readStream(source);
|
13
|
+
const ws = _s3Stream.s3Stream.writeStream(target.key, target.type);
|
14
|
+
readStream.pipe(ws.streamPassThrough);
|
15
|
+
promises.push(ws.streamPassThroughUploadPromise);
|
16
|
+
console.log(`Successfully queued file "${target.key}"`);
|
17
|
+
}
|
18
|
+
return Promise.all(promises);
|
19
|
+
}
|
20
|
+
|
21
|
+
//# sourceMappingURL=uploadFilesFromS3.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_s3Stream","require","uploadFilesFromS3","fileMap","promises","source","target","Array","from","entries","readStream","s3Stream","ws","writeStream","key","type","pipe","streamPassThrough","push","streamPassThroughUploadPromise","console","log","Promise","all"],"sources":["uploadFilesFromS3.ts"],"sourcesContent":["import { s3Stream } from \"~/export/s3Stream\";\nimport { FileInput } from \"@webiny/api-file-manager/types\";\n\nexport type UploadFileMap = Map<string, FileInput>;\n\nexport async function uploadFilesFromS3(fileMap: UploadFileMap) {\n const promises = [];\n for (const [source, target] of Array.from(fileMap.entries())) {\n // Read file.\n const readStream = await s3Stream.readStream(source);\n\n const ws = s3Stream.writeStream(target.key, target.type);\n readStream.pipe(ws.streamPassThrough);\n promises.push(ws.streamPassThroughUploadPromise);\n\n console.log(`Successfully queued file \"${target.key}\"`);\n }\n\n return Promise.all(promises);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAKO,eAAeC,iBAAiBA,CAACC,OAAsB,EAAE;EAC5D,MAAMC,QAAQ,GAAG,EAAE;EACnB,KAAK,MAAM,CAACC,MAAM,EAAEC,MAAM,CAAC,IAAIC,KAAK,CAACC,IAAI,CAACL,OAAO,CAACM,OAAO,CAAC,CAAC,CAAC,EAAE;IAC1D;IACA,MAAMC,UAAU,GAAG,MAAMC,kBAAQ,CAACD,UAAU,CAACL,MAAM,CAAC;IAEpD,MAAMO,EAAE,GAAGD,kBAAQ,CAACE,WAAW,CAACP,MAAM,CAACQ,GAAG,EAAER,MAAM,CAACS,IAAI,CAAC;IACxDL,UAAU,CAACM,IAAI,CAACJ,EAAE,CAACK,iBAAiB,CAAC;IACrCb,QAAQ,CAACc,IAAI,CAACN,EAAE,CAACO,8BAA8B,CAAC;IAEhDC,OAAO,CAACC,GAAG,CAAE,6BAA4Bf,MAAM,CAACQ,GAAI,GAAE,CAAC;EAC3D;EAEA,OAAOQ,OAAO,CAACC,GAAG,CAACnB,QAAQ,CAAC;AAChC"}
|
package/mockSecurity.js
CHANGED
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.mockSecurity = void 0;
|
7
7
|
const mockSecurity = (identity, context) => {
|
8
|
-
context.security.disableAuthorization();
|
9
8
|
context.security.setIdentity(identity);
|
10
9
|
};
|
11
|
-
exports.mockSecurity = mockSecurity;
|
10
|
+
exports.mockSecurity = mockSecurity;
|
11
|
+
|
12
|
+
//# sourceMappingURL=mockSecurity.js.map
|
package/mockSecurity.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mockSecurity","identity","context","security","
|
1
|
+
{"version":3,"names":["mockSecurity","identity","context","security","setIdentity","exports"],"sources":["mockSecurity.ts"],"sourcesContent":["import { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport const mockSecurity = (identity: SecurityIdentity, context: SecurityContext) => {\n context.security.setIdentity(identity);\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAGA,CAACC,QAA0B,EAAEC,OAAwB,KAAK;EAClFA,OAAO,CAACC,QAAQ,CAACC,WAAW,CAACH,QAAQ,CAAC;AAC1C,CAAC;AAACI,OAAA,CAAAL,YAAA,GAAAA,YAAA"}
|