@webiny/api-page-builder-import-export 0.0.0-unstable.3386f66516 → 0.0.0-unstable.39223eb3c1
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 +1 -1
- package/client.js +12 -25
- package/client.js.map +1 -1
- package/export/combine/blocksHandler.d.ts +2 -2
- package/export/combine/blocksHandler.js +14 -19
- package/export/combine/blocksHandler.js.map +1 -1
- package/export/combine/formsHandler.d.ts +6 -0
- package/export/combine/{pagesHandler.js → formsHandler.js} +25 -30
- package/export/combine/formsHandler.js.map +1 -0
- package/export/combine/index.d.ts +2 -2
- package/export/combine/index.js +24 -23
- package/export/combine/index.js.map +1 -1
- package/export/combine/templatesHandler.d.ts +2 -2
- package/export/combine/templatesHandler.js +14 -19
- package/export/combine/templatesHandler.js.map +1 -1
- package/export/pages/ExportPagesCleanup.d.ts +5 -0
- package/export/pages/ExportPagesCleanup.js +82 -0
- package/export/pages/ExportPagesCleanup.js.map +1 -0
- package/export/pages/ExportPagesController.d.ts +5 -0
- package/export/pages/ExportPagesController.js +31 -0
- package/export/pages/ExportPagesController.js.map +1 -0
- package/export/pages/ExportPagesZipPages.d.ts +5 -0
- package/export/pages/ExportPagesZipPages.js +23 -0
- package/export/pages/ExportPagesZipPages.js.map +1 -0
- package/export/pages/controller/CombineZippedPages.d.ts +5 -0
- package/export/pages/controller/CombineZippedPages.js +75 -0
- package/export/pages/controller/CombineZippedPages.js.map +1 -0
- package/export/pages/controller/CreateZipPagesTasks.d.ts +8 -0
- package/export/pages/controller/CreateZipPagesTasks.js +103 -0
- package/export/pages/controller/CreateZipPagesTasks.js.map +1 -0
- package/export/pages/controller/ProcessZipPagesTasks.d.ts +6 -0
- package/export/pages/controller/ProcessZipPagesTasks.js +61 -0
- package/export/pages/controller/ProcessZipPagesTasks.js.map +1 -0
- package/export/pages/types.d.ts +53 -0
- package/export/pages/types.js +26 -0
- package/export/pages/types.js.map +1 -0
- package/export/pages/utils.d.ts +2 -0
- package/export/pages/utils.js +13 -0
- package/export/pages/utils.js.map +1 -0
- package/export/pages/zipPages/ZipPages.d.ts +5 -0
- package/export/pages/zipPages/ZipPages.js +100 -0
- package/export/pages/zipPages/ZipPages.js.map +1 -0
- package/export/pages/zipPages/ZipPagesDataManager.d.ts +14 -0
- package/export/pages/zipPages/ZipPagesDataManager.js +46 -0
- package/export/pages/zipPages/ZipPagesDataManager.js.map +1 -0
- package/export/pages/zipPages/getPageFactory.d.ts +4 -0
- package/export/pages/zipPages/getPageFactory.js +38 -0
- package/export/pages/zipPages/getPageFactory.js.map +1 -0
- package/export/process/blocksHandler.d.ts +2 -2
- package/export/process/blocksHandler.js +29 -36
- 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 +18 -0
- package/export/process/exporters/PageExporter.js +59 -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 +58 -0
- package/export/process/exporters/PageTemplateExporter.js.map +1 -0
- package/export/process/formsHandler.d.ts +6 -0
- package/export/process/{pagesHandler.js → formsHandler.js} +48 -63
- package/export/process/formsHandler.js.map +1 -0
- package/export/process/index.d.ts +2 -2
- package/export/process/index.js +24 -23
- package/export/process/index.js.map +1 -1
- package/export/process/templatesHandler.d.ts +2 -2
- package/export/process/templatesHandler.js +29 -37
- package/export/process/templatesHandler.js.map +1 -1
- package/export/s3Stream.d.ts +16 -11
- package/export/s3Stream.js +27 -42
- package/export/s3Stream.js.map +1 -1
- package/export/utils.d.ts +11 -9
- package/export/utils.js +54 -58
- package/export/utils.js.map +1 -1
- package/export/zipper.d.ts +7 -6
- package/export/zipper.js +46 -62
- package/export/zipper.js.map +1 -1
- package/graphql/crud/blocks.crud.d.ts +1 -1
- package/graphql/crud/blocks.crud.js +65 -62
- package/graphql/crud/blocks.crud.js.map +1 -1
- package/graphql/crud/forms.crud.d.ts +4 -0
- package/graphql/crud/forms.crud.js +162 -0
- package/graphql/crud/forms.crud.js.map +1 -0
- package/graphql/crud/importExportTasks.crud.d.ts +2 -2
- package/graphql/crud/importExportTasks.crud.js +150 -165
- package/graphql/crud/importExportTasks.crud.js.map +1 -1
- package/graphql/crud/pages.crud.d.ts +1 -1
- package/graphql/crud/pages.crud.js +241 -142
- package/graphql/crud/pages.crud.js.map +1 -1
- package/graphql/crud/templates.crud.d.ts +1 -1
- package/graphql/crud/templates.crud.js +63 -47
- package/graphql/crud/templates.crud.js.map +1 -1
- package/graphql/crud.d.ts +2 -2
- package/graphql/crud.js +4 -8
- package/graphql/crud.js.map +1 -1
- package/graphql/graphql/blocks.gql.d.ts +2 -2
- package/graphql/graphql/blocks.gql.js +8 -13
- 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.d.ts +2 -2
- package/graphql/graphql/importExportTasks.gql.js +8 -13
- package/graphql/graphql/importExportTasks.gql.js.map +1 -1
- package/graphql/graphql/pages.gql.d.ts +2 -2
- package/graphql/graphql/pages.gql.js +104 -20
- package/graphql/graphql/pages.gql.js.map +1 -1
- package/graphql/graphql/templates.gql.d.ts +2 -2
- package/graphql/graphql/templates.gql.js +7 -12
- package/graphql/graphql/templates.gql.js.map +1 -1
- package/graphql/graphql/utils/resolve.d.ts +3 -3
- package/graphql/graphql/utils/resolve.js +15 -7
- package/graphql/graphql/utils/resolve.js.map +1 -1
- package/graphql/graphql.d.ts +1 -1
- package/graphql/graphql.js +3 -7
- package/graphql/graphql.js.map +1 -1
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +4 -6
- package/graphql/index.js.map +1 -1
- package/graphql/types.d.ts +194 -31
- package/graphql/types.js +3 -1
- package/graphql/types.js.map +1 -1
- package/import/constants.d.ts +3 -0
- package/import/constants.js +13 -0
- package/import/constants.js.map +1 -0
- package/import/create/blocksHandler.d.ts +2 -2
- package/import/create/blocksHandler.js +13 -22
- package/import/create/blocksHandler.js.map +1 -1
- package/import/create/formsHandler.d.ts +3 -0
- package/import/create/formsHandler.js +105 -0
- package/import/create/formsHandler.js.map +1 -0
- package/import/create/index.d.ts +2 -2
- package/import/create/index.js +24 -23
- package/import/create/index.js.map +1 -1
- package/import/create/pagesHandler.d.ts +2 -2
- package/import/create/pagesHandler.js +12 -19
- package/import/create/pagesHandler.js.map +1 -1
- package/import/create/templatesHandler.d.ts +2 -2
- package/import/create/templatesHandler.js +12 -19
- package/import/create/templatesHandler.js.map +1 -1
- package/import/pages/ImportPagesController.d.ts +5 -0
- package/import/pages/ImportPagesController.js +29 -0
- package/import/pages/ImportPagesController.js.map +1 -0
- package/import/pages/ImportPagesProcessPages.d.ts +6 -0
- package/import/pages/ImportPagesProcessPages.js +112 -0
- package/import/pages/ImportPagesProcessPages.js.map +1 -0
- package/import/pages/controller/ImportPagesProcessPagesChecker.d.ts +6 -0
- package/import/pages/controller/ImportPagesProcessPagesChecker.js +40 -0
- package/import/pages/controller/ImportPagesProcessPagesChecker.js.map +1 -0
- package/import/pages/controller/ImportPagesProcessZipFile.d.ts +5 -0
- package/import/pages/controller/ImportPagesProcessZipFile.js +71 -0
- package/import/pages/controller/ImportPagesProcessZipFile.js.map +1 -0
- package/import/pages/process/importPage.d.ts +10 -0
- package/import/pages/process/importPage.js +94 -0
- package/import/pages/process/importPage.js.map +1 -0
- package/import/pages/types.d.ts +48 -0
- package/import/pages/types.js +20 -0
- package/import/pages/types.js.map +1 -0
- package/import/process/blocks/ElementIdsProcessor.d.ts +5 -0
- package/import/process/blocks/ElementIdsProcessor.js +26 -0
- package/import/process/blocks/ElementIdsProcessor.js.map +1 -0
- package/import/process/{blocksHandler.d.ts → blocks/blocksHandler.d.ts} +2 -2
- package/import/process/{blocksHandler.js → blocks/blocksHandler.js} +32 -38
- package/import/process/blocks/blocksHandler.js.map +1 -0
- package/import/process/blocks/importBlock.d.ts +11 -0
- package/import/process/blocks/importBlock.js +101 -0
- package/import/process/blocks/importBlock.js.map +1 -0
- package/import/process/forms/formsHandler.d.ts +3 -0
- package/import/process/{pagesHandler.js → forms/formsHandler.js} +54 -57
- 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.d.ts +2 -2
- package/import/process/index.js +26 -25
- package/import/process/index.js.map +1 -1
- 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} +36 -34
- 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 +126 -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.d.ts +1 -1
- package/mockSecurity.js +2 -3
- package/mockSecurity.js.map +1 -1
- package/package.json +36 -52
- package/tasks/common/ChildTasksCleanup.d.ts +12 -0
- package/tasks/common/ChildTasksCleanup.js +64 -0
- package/tasks/common/ChildTasksCleanup.js.map +1 -0
- package/tasks/index.d.ts +1 -0
- package/tasks/index.js +13 -0
- package/tasks/index.js.map +1 -0
- package/tasks/pages/exportPagesCleanupTask.d.ts +3 -0
- package/tasks/pages/exportPagesCleanupTask.js +36 -0
- package/tasks/pages/exportPagesCleanupTask.js.map +1 -0
- package/tasks/pages/exportPagesControllerTask.d.ts +3 -0
- package/tasks/pages/exportPagesControllerTask.js +83 -0
- package/tasks/pages/exportPagesControllerTask.js.map +1 -0
- package/tasks/pages/exportPagesZipPagesTask.d.ts +3 -0
- package/tasks/pages/exportPagesZipPagesTask.js +39 -0
- package/tasks/pages/exportPagesZipPagesTask.js.map +1 -0
- package/tasks/pages/importPagesControllerTask.d.ts +3 -0
- package/tasks/pages/importPagesControllerTask.js +39 -0
- package/tasks/pages/importPagesControllerTask.js.map +1 -0
- package/tasks/pages/importPagesProcessPageTask.d.ts +3 -0
- package/tasks/pages/importPagesProcessPageTask.js +39 -0
- package/tasks/pages/importPagesProcessPageTask.js.map +1 -0
- package/tasks/pages/index.d.ts +1 -0
- package/tasks/pages/index.js +17 -0
- package/tasks/pages/index.js.map +1 -0
- package/types.d.ts +23 -2
- package/types.js +60 -13
- package/types.js.map +1 -1
- package/utils/ZipFiles.d.ts +11 -0
- package/utils/ZipFiles.js +124 -0
- package/utils/ZipFiles.js.map +1 -0
- package/export/combine/pagesHandler.d.ts +0 -6
- package/export/combine/pagesHandler.js.map +0 -1
- package/export/process/pagesHandler.d.ts +0 -6
- package/export/process/pagesHandler.js.map +0 -1
- package/import/process/blocksHandler.js.map +0 -1
- package/import/process/pagesHandler.d.ts +0 -3
- 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 -696
- package/import/utils.js.map +0 -1
|
@@ -1,69 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _mdbid = _interopRequireDefault(require("mdbid"));
|
|
13
|
-
|
|
14
|
-
var _fields = require("@commodo/fields");
|
|
15
|
-
|
|
16
|
-
var _commodoFieldsObject = require("commodo-fields-object");
|
|
17
|
-
|
|
18
|
-
var _validation = require("@webiny/validation");
|
|
19
|
-
|
|
8
|
+
var _zod = _interopRequireDefault(require("zod"));
|
|
9
|
+
var _utils = require("@webiny/utils");
|
|
20
10
|
var _api = require("@webiny/api");
|
|
21
|
-
|
|
22
|
-
var _checkBasePermissions = _interopRequireDefault(require("@webiny/api-page-builder/graphql/crud/utils/checkBasePermissions"));
|
|
23
|
-
|
|
24
|
-
var _checkOwnPermissions = _interopRequireDefault(require("@webiny/api-page-builder/graphql/crud/utils/checkOwnPermissions"));
|
|
25
|
-
|
|
26
11
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
27
|
-
|
|
28
12
|
var _types = require("../../types");
|
|
29
|
-
|
|
30
13
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}),
|
|
60
|
-
data: (0, _commodoFieldsObject.object)(),
|
|
61
|
-
input: (0, _commodoFieldsObject.object)(),
|
|
62
|
-
stats: (0, _commodoFieldsObject.object)(),
|
|
63
|
-
error: (0, _commodoFieldsObject.object)()
|
|
64
|
-
})();
|
|
65
|
-
const PERMISSION_NAME = "pb.page";
|
|
66
|
-
|
|
14
|
+
var _PagesPermissions = require("@webiny/api-page-builder/graphql/crud/permissions/PagesPermissions");
|
|
15
|
+
const dataModelStats = _zod.default.object({
|
|
16
|
+
[_types.ImportExportTaskStatus.PENDING]: _zod.default.number().optional().default(0),
|
|
17
|
+
[_types.ImportExportTaskStatus.PROCESSING]: _zod.default.number().optional().default(0),
|
|
18
|
+
[_types.ImportExportTaskStatus.COMPLETED]: _zod.default.number().optional().default(0),
|
|
19
|
+
[_types.ImportExportTaskStatus.FAILED]: _zod.default.number().optional().default(0),
|
|
20
|
+
total: _zod.default.number().optional().default(0)
|
|
21
|
+
}).optional().default({
|
|
22
|
+
[_types.ImportExportTaskStatus.PENDING]: 0,
|
|
23
|
+
[_types.ImportExportTaskStatus.PROCESSING]: 0,
|
|
24
|
+
[_types.ImportExportTaskStatus.COMPLETED]: 0,
|
|
25
|
+
[_types.ImportExportTaskStatus.FAILED]: 0,
|
|
26
|
+
total: 0
|
|
27
|
+
});
|
|
28
|
+
const CreateDataModel = _zod.default.object({
|
|
29
|
+
status: _zod.default.enum([_types.ImportExportTaskStatus.PENDING, _types.ImportExportTaskStatus.PROCESSING, _types.ImportExportTaskStatus.COMPLETED, _types.ImportExportTaskStatus.FAILED]),
|
|
30
|
+
data: _zod.default.object({}).passthrough().default({}),
|
|
31
|
+
input: _zod.default.object({}).passthrough().default({}),
|
|
32
|
+
error: _zod.default.object({}).passthrough().default({}),
|
|
33
|
+
stats: dataModelStats
|
|
34
|
+
});
|
|
35
|
+
const UpdateDataModel = _zod.default.object({
|
|
36
|
+
status: _zod.default.enum([_types.ImportExportTaskStatus.PENDING, _types.ImportExportTaskStatus.PROCESSING, _types.ImportExportTaskStatus.COMPLETED, _types.ImportExportTaskStatus.FAILED]).optional(),
|
|
37
|
+
data: _zod.default.object({}).passthrough().default({}),
|
|
38
|
+
input: _zod.default.object({}).passthrough().default({}),
|
|
39
|
+
error: _zod.default.object({}).passthrough().default({}),
|
|
40
|
+
stats: dataModelStats
|
|
41
|
+
});
|
|
67
42
|
var _default = ({
|
|
68
43
|
storageOperations
|
|
69
44
|
}) => new _api.ContextPlugin(async context => {
|
|
@@ -74,23 +49,24 @@ var _default = ({
|
|
|
74
49
|
console.log("Missing pageBuilder on context. Skipping ImportExportTasks crud.");
|
|
75
50
|
return;
|
|
76
51
|
}
|
|
77
|
-
|
|
52
|
+
const pagesPermissions = new _PagesPermissions.PagesPermissions({
|
|
53
|
+
getPermissions: () => context.security.getPermissions("pb.page"),
|
|
54
|
+
getIdentity: context.security.getIdentity,
|
|
55
|
+
fullAccessPermissionName: "pb.*"
|
|
56
|
+
});
|
|
78
57
|
const getLocale = () => {
|
|
79
58
|
const locale = context.i18n.getContentLocale();
|
|
80
|
-
|
|
81
59
|
if (!locale) {
|
|
82
60
|
throw new _error.default("Missing content locale in importExportTasks.crud.ts", "LOCALE_ERROR");
|
|
83
61
|
}
|
|
84
|
-
|
|
85
62
|
return locale;
|
|
86
|
-
};
|
|
87
|
-
|
|
63
|
+
};
|
|
88
64
|
|
|
65
|
+
// Modify context
|
|
89
66
|
context.pageBuilder.importExportTask = {
|
|
90
67
|
storageOperations,
|
|
91
|
-
|
|
92
68
|
async getTask(id) {
|
|
93
|
-
|
|
69
|
+
await pagesPermissions.ensure({
|
|
94
70
|
rwd: "r"
|
|
95
71
|
});
|
|
96
72
|
const tenant = context.tenancy.getCurrentTenant();
|
|
@@ -103,26 +79,24 @@ var _default = ({
|
|
|
103
79
|
}
|
|
104
80
|
};
|
|
105
81
|
let importExportTask = null;
|
|
106
|
-
|
|
107
82
|
try {
|
|
108
83
|
importExportTask = await storageOperations.getTask(params);
|
|
109
|
-
|
|
110
84
|
if (!importExportTask) {
|
|
111
85
|
return null;
|
|
112
86
|
}
|
|
113
87
|
} catch (ex) {
|
|
114
|
-
throw new _error.default(ex.message || "Could not get importExportTask by id.", ex.code || "GET_IMPORT_EXPORT_TASK_ERROR",
|
|
88
|
+
throw new _error.default(ex.message || "Could not get importExportTask by id.", ex.code || "GET_IMPORT_EXPORT_TASK_ERROR", {
|
|
89
|
+
...(ex.data || {}),
|
|
115
90
|
params
|
|
116
|
-
})
|
|
91
|
+
});
|
|
117
92
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
await pagesPermissions.ensure({
|
|
94
|
+
owns: importExportTask.createdBy
|
|
95
|
+
});
|
|
121
96
|
return importExportTask;
|
|
122
97
|
},
|
|
123
|
-
|
|
124
98
|
async listTasks(params) {
|
|
125
|
-
|
|
99
|
+
await pagesPermissions.ensure({
|
|
126
100
|
rwd: "r"
|
|
127
101
|
});
|
|
128
102
|
const tenant = context.tenancy.getCurrentTenant();
|
|
@@ -138,13 +112,13 @@ var _default = ({
|
|
|
138
112
|
},
|
|
139
113
|
sort: Array.isArray(sort) && sort.length > 0 ? sort : ["createdOn_ASC"],
|
|
140
114
|
limit: limit
|
|
141
|
-
};
|
|
115
|
+
};
|
|
142
116
|
|
|
143
|
-
|
|
117
|
+
// If user can only manage own records, let's add that to the listing.
|
|
118
|
+
if (await pagesPermissions.canAccessOnlyOwnRecords) {
|
|
144
119
|
const identity = context.security.getIdentity();
|
|
145
120
|
listParams.where.createdBy = identity.id;
|
|
146
121
|
}
|
|
147
|
-
|
|
148
122
|
try {
|
|
149
123
|
const [items] = await storageOperations.listTasks(listParams);
|
|
150
124
|
return items;
|
|
@@ -154,17 +128,19 @@ var _default = ({
|
|
|
154
128
|
});
|
|
155
129
|
}
|
|
156
130
|
},
|
|
157
|
-
|
|
158
131
|
async createTask(input) {
|
|
159
|
-
await
|
|
132
|
+
await pagesPermissions.ensure({
|
|
160
133
|
rwd: "w"
|
|
161
134
|
});
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
135
|
+
const validation = CreateDataModel.safeParse(input);
|
|
136
|
+
if (!validation.success) {
|
|
137
|
+
throw (0, _utils.createZodError)(validation.error);
|
|
138
|
+
}
|
|
139
|
+
const id = (0, _utils.mdbid)();
|
|
165
140
|
const identity = context.security.getIdentity();
|
|
166
|
-
const
|
|
167
|
-
|
|
141
|
+
const importExportTask = {
|
|
142
|
+
...validation.data,
|
|
143
|
+
parent: "",
|
|
168
144
|
tenant: context.tenancy.getCurrentTenant().id,
|
|
169
145
|
locale: getLocale().code,
|
|
170
146
|
id,
|
|
@@ -174,171 +150,182 @@ var _default = ({
|
|
|
174
150
|
type: identity.type,
|
|
175
151
|
displayName: identity.displayName
|
|
176
152
|
}
|
|
177
|
-
}
|
|
178
|
-
|
|
153
|
+
};
|
|
179
154
|
try {
|
|
180
155
|
return await storageOperations.createTask({
|
|
181
|
-
input: data,
|
|
156
|
+
input: validation.data,
|
|
182
157
|
task: importExportTask
|
|
183
158
|
});
|
|
184
159
|
} catch (ex) {
|
|
185
|
-
throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "CREATE_IMPORT_EXPORT_TASK_ERROR",
|
|
160
|
+
throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "CREATE_IMPORT_EXPORT_TASK_ERROR", {
|
|
161
|
+
...(ex.data || {}),
|
|
186
162
|
importExportTask
|
|
187
|
-
})
|
|
163
|
+
});
|
|
188
164
|
}
|
|
189
165
|
},
|
|
190
|
-
|
|
191
166
|
async updateTask(id, input) {
|
|
192
|
-
|
|
167
|
+
await pagesPermissions.ensure({
|
|
193
168
|
rwd: "w"
|
|
194
169
|
});
|
|
195
170
|
const original = await context.pageBuilder.importExportTask.getTask(id);
|
|
196
|
-
|
|
197
171
|
if (!original) {
|
|
198
172
|
throw new _handlerGraphql.NotFoundError(`ImportExportTask "${id}" not found.`);
|
|
199
173
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
(0, _checkOwnPermissions.default)(identity, permission, original);
|
|
203
|
-
const updateDataModel = new UpdateDataModel().populate(input);
|
|
204
|
-
await updateDataModel.validate();
|
|
205
|
-
const data = await updateDataModel.toJSON({
|
|
206
|
-
onlyDirty: true
|
|
174
|
+
await pagesPermissions.ensure({
|
|
175
|
+
owns: original.createdBy
|
|
207
176
|
});
|
|
208
|
-
const
|
|
209
|
-
|
|
177
|
+
const validation = UpdateDataModel.safeParse(input);
|
|
178
|
+
if (!validation.success) {
|
|
179
|
+
throw (0, _utils.createZodError)(validation.error);
|
|
180
|
+
}
|
|
181
|
+
const importExportTask = {
|
|
182
|
+
...original
|
|
183
|
+
};
|
|
184
|
+
for (const key in validation.data) {
|
|
185
|
+
// @ts-expect-error
|
|
186
|
+
const value = validation.data[key];
|
|
187
|
+
if (value === undefined) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
// @ts-expect-error
|
|
191
|
+
importExportTask[key] = value;
|
|
192
|
+
}
|
|
210
193
|
try {
|
|
211
194
|
return await storageOperations.updateTask({
|
|
212
|
-
input: data,
|
|
195
|
+
input: validation.data,
|
|
213
196
|
original,
|
|
214
197
|
task: importExportTask
|
|
215
198
|
});
|
|
216
199
|
} catch (ex) {
|
|
217
|
-
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR",
|
|
200
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR", {
|
|
201
|
+
...(ex.data || {}),
|
|
218
202
|
original,
|
|
219
203
|
importExportTask
|
|
220
|
-
})
|
|
204
|
+
});
|
|
221
205
|
}
|
|
222
206
|
},
|
|
223
|
-
|
|
224
207
|
async deleteTask(id) {
|
|
225
|
-
|
|
208
|
+
await pagesPermissions.ensure({
|
|
226
209
|
rwd: "d"
|
|
227
210
|
});
|
|
228
211
|
const importExportTask = await context.pageBuilder.importExportTask.getTask(id);
|
|
229
|
-
|
|
230
212
|
if (!importExportTask) {
|
|
231
213
|
throw new _handlerGraphql.NotFoundError(`ImportExportTask "${id}" not found.`);
|
|
232
214
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
215
|
+
await pagesPermissions.ensure({
|
|
216
|
+
owns: importExportTask.createdBy
|
|
217
|
+
});
|
|
237
218
|
try {
|
|
238
219
|
return await storageOperations.deleteTask({
|
|
239
220
|
task: importExportTask
|
|
240
221
|
});
|
|
241
222
|
} catch (ex) {
|
|
242
|
-
throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "DELETE_IMPORT_EXPORT_TASK_ERROR",
|
|
223
|
+
throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "DELETE_IMPORT_EXPORT_TASK_ERROR", {
|
|
224
|
+
...(ex.data || {}),
|
|
243
225
|
importExportTask
|
|
244
|
-
})
|
|
226
|
+
});
|
|
245
227
|
}
|
|
246
228
|
},
|
|
247
|
-
|
|
248
229
|
async updateStats(id, input) {
|
|
249
|
-
|
|
230
|
+
await pagesPermissions.ensure({
|
|
250
231
|
rwd: "w"
|
|
251
232
|
});
|
|
252
233
|
const original = await context.pageBuilder.importExportTask.getTask(id);
|
|
253
|
-
|
|
254
234
|
if (!original) {
|
|
255
235
|
throw new _handlerGraphql.NotFoundError(`ImportExportTask "${id}" not found.`);
|
|
256
236
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
237
|
+
await pagesPermissions.ensure({
|
|
238
|
+
owns: original.createdBy
|
|
239
|
+
});
|
|
261
240
|
try {
|
|
262
241
|
return await storageOperations.updateTaskStats({
|
|
263
242
|
input,
|
|
264
243
|
original
|
|
265
244
|
});
|
|
266
245
|
} catch (ex) {
|
|
267
|
-
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR",
|
|
246
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR", {
|
|
247
|
+
...(ex.data || {}),
|
|
268
248
|
original
|
|
269
|
-
})
|
|
249
|
+
});
|
|
270
250
|
}
|
|
271
251
|
},
|
|
272
|
-
|
|
273
252
|
async createSubTask(parent, id, input) {
|
|
274
|
-
await
|
|
253
|
+
await pagesPermissions.ensure({
|
|
275
254
|
rwd: "w"
|
|
276
255
|
});
|
|
277
|
-
const
|
|
278
|
-
|
|
256
|
+
const validation = CreateDataModel.safeParse(input);
|
|
257
|
+
if (!validation.success) {
|
|
258
|
+
throw (0, _utils.createZodError)(validation.error);
|
|
259
|
+
}
|
|
279
260
|
const identity = context.security.getIdentity();
|
|
280
|
-
const
|
|
281
|
-
|
|
261
|
+
const importExportSubTask = {
|
|
262
|
+
...validation.data,
|
|
282
263
|
tenant: context.tenancy.getCurrentTenant().id,
|
|
283
264
|
locale: getLocale().code,
|
|
284
|
-
id
|
|
285
|
-
parent
|
|
265
|
+
id,
|
|
266
|
+
parent,
|
|
286
267
|
createdOn: new Date().toISOString(),
|
|
287
268
|
createdBy: {
|
|
288
269
|
id: identity.id,
|
|
289
270
|
type: identity.type,
|
|
290
271
|
displayName: identity.displayName
|
|
291
272
|
}
|
|
292
|
-
}
|
|
293
|
-
|
|
273
|
+
};
|
|
294
274
|
try {
|
|
295
275
|
return await storageOperations.createSubTask({
|
|
296
|
-
input: data,
|
|
276
|
+
input: validation.data,
|
|
297
277
|
subTask: importExportSubTask
|
|
298
278
|
});
|
|
299
279
|
} catch (ex) {
|
|
300
|
-
throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_TASK_ERROR",
|
|
280
|
+
throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_TASK_ERROR", {
|
|
281
|
+
...(ex.data || {}),
|
|
301
282
|
importExportSubTask
|
|
302
|
-
})
|
|
283
|
+
});
|
|
303
284
|
}
|
|
304
285
|
},
|
|
305
|
-
|
|
306
286
|
async updateSubTask(parent, subTaskId, input) {
|
|
307
|
-
|
|
287
|
+
await pagesPermissions.ensure({
|
|
308
288
|
rwd: "w"
|
|
309
289
|
});
|
|
310
290
|
const original = await context.pageBuilder.importExportTask.getSubTask(parent, subTaskId);
|
|
311
|
-
|
|
312
291
|
if (!original) {
|
|
313
292
|
throw new _handlerGraphql.NotFoundError(`ImportExportTask parent: "${parent}" and id: "${subTaskId}" not found.`);
|
|
314
293
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
294
|
+
await pagesPermissions.ensure({
|
|
295
|
+
owns: original.createdBy
|
|
296
|
+
});
|
|
297
|
+
const validation = UpdateDataModel.safeParse(input);
|
|
298
|
+
if (!validation.success) {
|
|
299
|
+
throw (0, _utils.createZodError)(validation.error);
|
|
300
|
+
}
|
|
301
|
+
const importExportSubTask = {
|
|
302
|
+
...original
|
|
303
|
+
};
|
|
304
|
+
for (const key in validation.data) {
|
|
305
|
+
// @ts-expect-error
|
|
306
|
+
const value = validation.data[key];
|
|
307
|
+
if (value === undefined) {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
// @ts-expect-error
|
|
311
|
+
importExportSubTask[key] = value;
|
|
312
|
+
}
|
|
326
313
|
try {
|
|
327
314
|
return await storageOperations.updateSubTask({
|
|
328
|
-
input: data,
|
|
315
|
+
input: validation.data,
|
|
329
316
|
original,
|
|
330
317
|
subTask: importExportSubTask
|
|
331
318
|
});
|
|
332
319
|
} catch (ex) {
|
|
333
|
-
throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR",
|
|
320
|
+
throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_TASK_ERROR", {
|
|
321
|
+
...(ex.data || {}),
|
|
334
322
|
importExportSubTask,
|
|
335
323
|
original
|
|
336
|
-
})
|
|
324
|
+
});
|
|
337
325
|
}
|
|
338
326
|
},
|
|
339
|
-
|
|
340
327
|
async getSubTask(parent, subTaskId) {
|
|
341
|
-
|
|
328
|
+
await pagesPermissions.ensure({
|
|
342
329
|
rwd: "r"
|
|
343
330
|
});
|
|
344
331
|
const tenant = context.tenancy.getCurrentTenant();
|
|
@@ -352,26 +339,24 @@ var _default = ({
|
|
|
352
339
|
}
|
|
353
340
|
};
|
|
354
341
|
let importExportSubTask = null;
|
|
355
|
-
|
|
356
342
|
try {
|
|
357
343
|
importExportSubTask = await storageOperations.getSubTask(params);
|
|
358
|
-
|
|
359
344
|
if (!importExportSubTask) {
|
|
360
345
|
return null;
|
|
361
346
|
}
|
|
362
347
|
} catch (ex) {
|
|
363
|
-
throw new _error.default(ex.message || "Could not get importExportSubTask by id.", ex.code || "GET_IMPORT_EXPORT_TASK_ERROR",
|
|
348
|
+
throw new _error.default(ex.message || "Could not get importExportSubTask by id.", ex.code || "GET_IMPORT_EXPORT_TASK_ERROR", {
|
|
349
|
+
...(ex.data || {}),
|
|
364
350
|
params
|
|
365
|
-
})
|
|
351
|
+
});
|
|
366
352
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
353
|
+
await pagesPermissions.ensure({
|
|
354
|
+
owns: importExportSubTask.createdBy
|
|
355
|
+
});
|
|
370
356
|
return importExportSubTask;
|
|
371
357
|
},
|
|
372
|
-
|
|
373
358
|
async listSubTasks(parent, status, limit) {
|
|
374
|
-
|
|
359
|
+
await pagesPermissions.ensure({
|
|
375
360
|
rwd: "r"
|
|
376
361
|
});
|
|
377
362
|
const tenant = context.tenancy.getCurrentTenant();
|
|
@@ -384,13 +369,13 @@ var _default = ({
|
|
|
384
369
|
status
|
|
385
370
|
},
|
|
386
371
|
limit
|
|
387
|
-
};
|
|
372
|
+
};
|
|
388
373
|
|
|
389
|
-
|
|
374
|
+
// If user can only manage own records, let's add that to the listing.
|
|
375
|
+
if (await pagesPermissions.canAccessOnlyOwnRecords()) {
|
|
390
376
|
const identity = context.security.getIdentity();
|
|
391
377
|
listParams.where.createdBy = identity.id;
|
|
392
378
|
}
|
|
393
|
-
|
|
394
379
|
try {
|
|
395
380
|
const [items] = await storageOperations.listSubTasks(listParams);
|
|
396
381
|
return items;
|
|
@@ -404,8 +389,8 @@ var _default = ({
|
|
|
404
389
|
});
|
|
405
390
|
}
|
|
406
391
|
}
|
|
407
|
-
|
|
408
392
|
};
|
|
409
393
|
});
|
|
394
|
+
exports.default = _default;
|
|
410
395
|
|
|
411
|
-
|
|
396
|
+
//# sourceMappingURL=importExportTasks.crud.js.map
|