@webiny/api-apw 0.0.0-unstable.5e7233243f
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/ContentApwSettingsPlugin.d.ts +10 -0
- package/ContentApwSettingsPlugin.js +17 -0
- package/ContentApwSettingsPlugin.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/crud/createChangeRequestMethods.d.ts +2 -0
- package/crud/createChangeRequestMethods.js +95 -0
- package/crud/createChangeRequestMethods.js.map +1 -0
- package/crud/createCommentMethods.d.ts +2 -0
- package/crud/createCommentMethods.js +96 -0
- package/crud/createCommentMethods.js.map +1 -0
- package/crud/createContentReviewMethods.d.ts +10 -0
- package/crud/createContentReviewMethods.js +552 -0
- package/crud/createContentReviewMethods.js.map +1 -0
- package/crud/createReviewerMethods.d.ts +2 -0
- package/crud/createReviewerMethods.js +96 -0
- package/crud/createReviewerMethods.js.map +1 -0
- package/crud/createWorkflowMethods.d.ts +2 -0
- package/crud/createWorkflowMethods.js +96 -0
- package/crud/createWorkflowMethods.js.map +1 -0
- package/crud/index.d.ts +2 -0
- package/crud/index.js +100 -0
- package/crud/index.js.map +1 -0
- package/crud/utils.d.ts +21 -0
- package/crud/utils.js +142 -0
- package/crud/utils.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +34 -0
- package/index.js.map +1 -0
- package/package.json +75 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
- package/plugins/cms/README.md +49 -0
- package/plugins/cms/apwEntryPlugins.d.ts +8 -0
- package/plugins/cms/apwEntryPlugins.js +50 -0
- package/plugins/cms/apwEntryPlugins.js.map +1 -0
- package/plugins/cms/index.d.ts +12 -0
- package/plugins/cms/index.js +37 -0
- package/plugins/cms/index.js.map +1 -0
- package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
- package/plugins/cms/linkContentReviewToEntry.js +108 -0
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
- package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
- package/plugins/cms/linkWorkflowToEntry.js +166 -0
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
- package/plugins/cms/triggerContentReview.d.ts +8 -0
- package/plugins/cms/triggerContentReview.js +59 -0
- package/plugins/cms/triggerContentReview.js.map +1 -0
- package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
- package/plugins/cms/updateContentReviewStatus.js +101 -0
- package/plugins/cms/updateContentReviewStatus.js.map +1 -0
- package/plugins/cms/utils.d.ts +27 -0
- package/plugins/cms/utils.js +211 -0
- package/plugins/cms/utils.js.map +1 -0
- package/plugins/context.d.ts +5 -0
- package/plugins/context.js +146 -0
- package/plugins/context.js.map +1 -0
- package/plugins/graphql/changeRequest.gql.d.ts +4 -0
- package/plugins/graphql/changeRequest.gql.js +155 -0
- package/plugins/graphql/changeRequest.gql.js.map +1 -0
- package/plugins/graphql/comment.gql.d.ts +4 -0
- package/plugins/graphql/comment.gql.js +160 -0
- package/plugins/graphql/comment.gql.js.map +1 -0
- package/plugins/graphql/contentReview.gql.d.ts +4 -0
- package/plugins/graphql/contentReview.gql.js +382 -0
- package/plugins/graphql/contentReview.gql.js.map +1 -0
- package/plugins/graphql/reviewer.gql.d.ts +4 -0
- package/plugins/graphql/reviewer.gql.js +114 -0
- package/plugins/graphql/reviewer.gql.js.map +1 -0
- package/plugins/graphql/workflow.gql.d.ts +4 -0
- package/plugins/graphql/workflow.gql.js +205 -0
- package/plugins/graphql/workflow.gql.js.map +1 -0
- package/plugins/graphql.d.ts +4 -0
- package/plugins/graphql.js +95 -0
- package/plugins/graphql.js.map +1 -0
- package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
- package/plugins/hooks/createReviewerFromIdentity.js +62 -0
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
- package/plugins/hooks/index.d.ts +3 -0
- package/plugins/hooks/index.js +68 -0
- package/plugins/hooks/index.js.map +1 -0
- package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
- package/plugins/hooks/initializeContentReviewSteps.js +89 -0
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
- package/plugins/hooks/updatePendingChangeRequests.js +98 -0
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
- package/plugins/hooks/updateTotalComments.d.ts +3 -0
- package/plugins/hooks/updateTotalComments.js +157 -0
- package/plugins/hooks/updateTotalComments.js.map +1 -0
- package/plugins/hooks/validateChangeRequest.d.ts +2 -0
- package/plugins/hooks/validateChangeRequest.js +64 -0
- package/plugins/hooks/validateChangeRequest.js.map +1 -0
- package/plugins/hooks/validateComment.d.ts +2 -0
- package/plugins/hooks/validateComment.js +47 -0
- package/plugins/hooks/validateComment.js.map +1 -0
- package/plugins/hooks/validateContentReview.d.ts +2 -0
- package/plugins/hooks/validateContentReview.js +38 -0
- package/plugins/hooks/validateContentReview.js.map +1 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
- package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
- package/plugins/pageBuilder/index.d.ts +11 -0
- package/plugins/pageBuilder/index.js +45 -0
- package/plugins/pageBuilder/index.js.map +1 -0
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
- package/plugins/pageBuilder/linkContentReviewToPage.js +93 -0
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
- package/plugins/pageBuilder/linkWorkflowToPage.js +182 -0
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
- package/plugins/pageBuilder/triggerContentReview.js +50 -0
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
- package/plugins/pageBuilder/updateContentReviewStatus.js +83 -0
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
- package/plugins/pageBuilder/utils.d.ts +22 -0
- package/plugins/pageBuilder/utils.js +184 -0
- package/plugins/pageBuilder/utils.js.map +1 -0
- package/plugins/utils.d.ts +35 -0
- package/plugins/utils.js +197 -0
- package/plugins/utils.js.map +1 -0
- package/scheduler/createScheduleActionMethods.d.ts +2 -0
- package/scheduler/createScheduleActionMethods.js +146 -0
- package/scheduler/createScheduleActionMethods.js.map +1 -0
- package/scheduler/handlers/executeAction/index.d.ts +13 -0
- package/scheduler/handlers/executeAction/index.js +172 -0
- package/scheduler/handlers/executeAction/index.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/security.d.ts +4 -0
- package/scheduler/handlers/executeAction/security.js +68 -0
- package/scheduler/handlers/executeAction/security.js.map +1 -0
- package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
- package/scheduler/handlers/scheduleAction/index.js +165 -0
- package/scheduler/handlers/scheduleAction/index.js.map +1 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +176 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
- package/scheduler/handlers/utils.d.ts +33 -0
- package/scheduler/handlers/utils.js +168 -0
- package/scheduler/handlers/utils.js.map +1 -0
- package/scheduler/index.d.ts +2 -0
- package/scheduler/index.js +27 -0
- package/scheduler/index.js.map +1 -0
- package/scheduler/types.d.ts +171 -0
- package/scheduler/types.js +34 -0
- package/scheduler/types.js.map +1 -0
- package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
- package/storageOperations/changeRequestStorageOperations.js +126 -0
- package/storageOperations/changeRequestStorageOperations.js.map +1 -0
- package/storageOperations/commentStorageOperations.d.ts +3 -0
- package/storageOperations/commentStorageOperations.js +142 -0
- package/storageOperations/commentStorageOperations.js.map +1 -0
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
- package/storageOperations/contentReviewStorageOperations.js +97 -0
- package/storageOperations/contentReviewStorageOperations.js.map +1 -0
- package/storageOperations/index.d.ts +15 -0
- package/storageOperations/index.js +52 -0
- package/storageOperations/index.js.map +1 -0
- package/storageOperations/models/changeRequest.model.d.ts +3 -0
- package/storageOperations/models/changeRequest.model.js +59 -0
- package/storageOperations/models/changeRequest.model.js.map +1 -0
- package/storageOperations/models/comment.model.d.ts +7 -0
- package/storageOperations/models/comment.model.js +60 -0
- package/storageOperations/models/comment.model.js.map +1 -0
- package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
- package/storageOperations/models/contentModelPluginFactory.js +32 -0
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
- package/storageOperations/models/contentReview.model.d.ts +7 -0
- package/storageOperations/models/contentReview.model.js +257 -0
- package/storageOperations/models/contentReview.model.js.map +1 -0
- package/storageOperations/models/index.d.ts +2 -0
- package/storageOperations/models/index.js +115 -0
- package/storageOperations/models/index.js.map +1 -0
- package/storageOperations/models/reviewer.model.d.ts +3 -0
- package/storageOperations/models/reviewer.model.js +55 -0
- package/storageOperations/models/reviewer.model.js.map +1 -0
- package/storageOperations/models/utils.d.ts +3 -0
- package/storageOperations/models/utils.js +36 -0
- package/storageOperations/models/utils.js.map +1 -0
- package/storageOperations/models/workflow.model.d.ts +12 -0
- package/storageOperations/models/workflow.model.js +208 -0
- package/storageOperations/models/workflow.model.js.map +1 -0
- package/storageOperations/reviewerStorageOperations.d.ts +3 -0
- package/storageOperations/reviewerStorageOperations.js +93 -0
- package/storageOperations/reviewerStorageOperations.js.map +1 -0
- package/storageOperations/types.d.ts +34 -0
- package/storageOperations/types.js +5 -0
- package/storageOperations/types.js.map +1 -0
- package/storageOperations/workflowStorageOperations.d.ts +3 -0
- package/storageOperations/workflowStorageOperations.js +115 -0
- package/storageOperations/workflowStorageOperations.js.map +1 -0
- package/types.d.ts +737 -0
- package/types.js +69 -0
- package/types.js.map +1 -0
- package/utils/contentApwSettingsPlugin.d.ts +9 -0
- package/utils/contentApwSettingsPlugin.js +26 -0
- package/utils/contentApwSettingsPlugin.js.map +1 -0
- package/utils/errors.d.ts +16 -0
- package/utils/errors.js +75 -0
- package/utils/errors.js.map +1 -0
- package/utils/fieldResolver.d.ts +16 -0
- package/utils/fieldResolver.js +60 -0
- package/utils/fieldResolver.js.map +1 -0
- package/utils/resolve.d.ts +3 -0
- package/utils/resolve.js +18 -0
- package/utils/resolve.js.map +1 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
2
|
+
import { ApwReviewerStorageOperations as BaseApwReviewerStorageOperations, ApwWorkflowStorageOperations as BaseApwWorkflowStorageOperations, ApwContentReviewStorageOperations as BaseApwContentReviewStorageOperations, ApwChangeRequestStorageOperations as BaseApwChangeRequestStorageOperations, ApwCommentStorageOperations as BaseApwCommentStorageOperations } from "../types";
|
3
|
+
export interface ApwCommentStorageOperations extends BaseApwCommentStorageOperations {
|
4
|
+
/**
|
5
|
+
* @internal
|
6
|
+
*/
|
7
|
+
getCommentModel(): Promise<CmsModel>;
|
8
|
+
}
|
9
|
+
export interface ApwReviewerStorageOperations extends BaseApwReviewerStorageOperations {
|
10
|
+
/**
|
11
|
+
* @internal
|
12
|
+
*/
|
13
|
+
getReviewerModel(): Promise<CmsModel>;
|
14
|
+
}
|
15
|
+
export interface ApwWorkflowStorageOperations extends BaseApwWorkflowStorageOperations {
|
16
|
+
/**
|
17
|
+
* @internal
|
18
|
+
*/
|
19
|
+
getWorkflowModel(): Promise<CmsModel>;
|
20
|
+
}
|
21
|
+
export interface ApwContentReviewStorageOperations extends BaseApwContentReviewStorageOperations {
|
22
|
+
/**
|
23
|
+
* @internal
|
24
|
+
*/
|
25
|
+
getContentReviewModel(): Promise<CmsModel>;
|
26
|
+
}
|
27
|
+
export interface ApwChangeRequestStorageOperations extends BaseApwChangeRequestStorageOperations {
|
28
|
+
/**
|
29
|
+
* @internal
|
30
|
+
*/
|
31
|
+
getChangeRequestModel(): Promise<CmsModel>;
|
32
|
+
}
|
33
|
+
export interface ApwStorageOperations extends ApwReviewerStorageOperations, ApwWorkflowStorageOperations, ApwContentReviewStorageOperations, ApwChangeRequestStorageOperations, ApwCommentStorageOperations {
|
34
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport {\n ApwReviewerStorageOperations as BaseApwReviewerStorageOperations,\n ApwWorkflowStorageOperations as BaseApwWorkflowStorageOperations,\n ApwContentReviewStorageOperations as BaseApwContentReviewStorageOperations,\n ApwChangeRequestStorageOperations as BaseApwChangeRequestStorageOperations,\n ApwCommentStorageOperations as BaseApwCommentStorageOperations\n} from \"~/types\";\n\nexport interface ApwCommentStorageOperations extends BaseApwCommentStorageOperations {\n /**\n * @internal\n */\n getCommentModel(): Promise<CmsModel>;\n}\n\nexport interface ApwReviewerStorageOperations extends BaseApwReviewerStorageOperations {\n /**\n * @internal\n */\n getReviewerModel(): Promise<CmsModel>;\n}\n\nexport interface ApwWorkflowStorageOperations extends BaseApwWorkflowStorageOperations {\n /**\n * @internal\n */\n getWorkflowModel(): Promise<CmsModel>;\n}\n\nexport interface ApwContentReviewStorageOperations extends BaseApwContentReviewStorageOperations {\n /**\n * @internal\n */\n getContentReviewModel(): Promise<CmsModel>;\n}\n\nexport interface ApwChangeRequestStorageOperations extends BaseApwChangeRequestStorageOperations {\n /**\n * @internal\n */\n getChangeRequestModel(): Promise<CmsModel>;\n}\n\nexport interface ApwStorageOperations\n extends ApwReviewerStorageOperations,\n ApwWorkflowStorageOperations,\n ApwContentReviewStorageOperations,\n ApwChangeRequestStorageOperations,\n ApwCommentStorageOperations {}\n"],"mappings":""}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.createWorkflowStorageOperations = void 0;
|
9
|
+
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
|
12
|
+
var _index = require("./index");
|
13
|
+
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
15
|
+
|
16
|
+
var _workflow = require("./models/workflow.model");
|
17
|
+
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
19
|
+
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
21
|
+
|
22
|
+
const formatReviewersForRefInput = (data, modelId) => {
|
23
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
24
|
+
steps: data.steps.map(step => _objectSpread(_objectSpread({}, step), {}, {
|
25
|
+
reviewers: step.reviewers.map(id => ({
|
26
|
+
id,
|
27
|
+
modelId
|
28
|
+
}))
|
29
|
+
}))
|
30
|
+
});
|
31
|
+
};
|
32
|
+
|
33
|
+
const createWorkflowStorageOperations = params => {
|
34
|
+
const {
|
35
|
+
cms,
|
36
|
+
security
|
37
|
+
} = params;
|
38
|
+
|
39
|
+
const getWorkflowModel = async () => {
|
40
|
+
security.disableAuthorization();
|
41
|
+
const model = await cms.getModel(_workflow.WORKFLOW_MODEL_ID);
|
42
|
+
security.enableAuthorization();
|
43
|
+
|
44
|
+
if (!model) {
|
45
|
+
throw new _error.default(`Could not find "${_workflow.WORKFLOW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
|
46
|
+
}
|
47
|
+
|
48
|
+
return model;
|
49
|
+
};
|
50
|
+
|
51
|
+
const getWorkflow = async ({
|
52
|
+
id
|
53
|
+
}) => {
|
54
|
+
const model = await getWorkflowModel();
|
55
|
+
security.disableAuthorization();
|
56
|
+
const entry = await cms.getEntryById(model, id);
|
57
|
+
security.enableAuthorization();
|
58
|
+
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
59
|
+
};
|
60
|
+
|
61
|
+
return {
|
62
|
+
getWorkflowModel,
|
63
|
+
getWorkflow,
|
64
|
+
|
65
|
+
async listWorkflows(params) {
|
66
|
+
const model = await getWorkflowModel();
|
67
|
+
security.disableAuthorization();
|
68
|
+
const [entries, meta] = await cms.listLatestEntries(model, _objectSpread({}, params));
|
69
|
+
security.enableAuthorization();
|
70
|
+
return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
|
71
|
+
},
|
72
|
+
|
73
|
+
async createWorkflow(params) {
|
74
|
+
const model = await getWorkflowModel();
|
75
|
+
const reviewerModel = await this.getReviewerModel();
|
76
|
+
const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);
|
77
|
+
security.disableAuthorization();
|
78
|
+
const entry = await cms.createEntry(model, data);
|
79
|
+
security.enableAuthorization();
|
80
|
+
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
81
|
+
},
|
82
|
+
|
83
|
+
async updateWorkflow(params) {
|
84
|
+
const model = await getWorkflowModel();
|
85
|
+
const reviewerModel = await this.getReviewerModel();
|
86
|
+
/**
|
87
|
+
* We're fetching the existing entry here because we're not accepting "app" field as input,
|
88
|
+
* but, we still need to retain its value after the "update" operation.
|
89
|
+
*/
|
90
|
+
|
91
|
+
const existingEntry = await getWorkflow({
|
92
|
+
id: params.id
|
93
|
+
});
|
94
|
+
|
95
|
+
const input = _objectSpread(_objectSpread({}, existingEntry), params.data);
|
96
|
+
|
97
|
+
const data = formatReviewersForRefInput(input, reviewerModel.modelId);
|
98
|
+
security.disableAuthorization();
|
99
|
+
const entry = await cms.updateEntry(model, params.id, data);
|
100
|
+
security.enableAuthorization();
|
101
|
+
return (0, _index.getFieldValues)(entry, _index.baseFields);
|
102
|
+
},
|
103
|
+
|
104
|
+
async deleteWorkflow(params) {
|
105
|
+
const model = await getWorkflowModel();
|
106
|
+
security.disableAuthorization();
|
107
|
+
await cms.deleteEntry(model, params.id);
|
108
|
+
security.enableAuthorization();
|
109
|
+
return true;
|
110
|
+
}
|
111
|
+
|
112
|
+
};
|
113
|
+
};
|
114
|
+
|
115
|
+
exports.createWorkflowStorageOperations = createWorkflowStorageOperations;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","security","getWorkflowModel","disableAuthorization","model","getModel","WORKFLOW_MODEL_ID","enableAuthorization","WebinyError","getWorkflow","entry","getEntryById","getFieldValues","baseFields","listWorkflows","entries","meta","listLatestEntries","createWorkflow","reviewerModel","getReviewerModel","createEntry","updateWorkflow","existingEntry","input","updateEntry","deleteWorkflow","deleteEntry"],"sources":["workflowStorageOperations.ts"],"sourcesContent":["import { CreateApwWorkflowParams } from \"~/types\";\nimport { ApwStorageOperations, ApwWorkflowStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\ntype ReviewersRefInput = CreateApwWorkflowParams<{ modelId: string; id: string }>;\n\nconst formatReviewersForRefInput = (\n data: CreateApwWorkflowParams,\n modelId: string\n): ReviewersRefInput => {\n return {\n ...data,\n steps: data.steps.map(step => ({\n ...step,\n reviewers: step.reviewers.map(id => ({\n id,\n modelId\n }))\n }))\n };\n};\n\nexport const createWorkflowStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwWorkflowStorageOperations => {\n const { cms, security } = params;\n const getWorkflowModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(WORKFLOW_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${WORKFLOW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getWorkflow: ApwWorkflowStorageOperations[\"getWorkflow\"] = async ({ id }) => {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n return {\n getWorkflowModel,\n getWorkflow,\n async listWorkflows(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params\n });\n security.enableAuthorization();\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n\n const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);\n security.disableAuthorization();\n const entry = await cms.createEntry(model, data);\n security.enableAuthorization();\n\n return getFieldValues(entry, baseFields);\n },\n async updateWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getWorkflow({ id: params.id });\n const input = {\n ...existingEntry,\n ...params.data\n };\n const data = formatReviewersForRefInput(\n input as CreateApwWorkflowParams,\n reviewerModel.modelId\n );\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, data);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteWorkflow(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAKA;;AACA;;;;;;AAIA,MAAMA,0BAA0B,GAAG,CAC/BC,IAD+B,EAE/BC,OAF+B,KAGX;EACpB,uCACOD,IADP;IAEIE,KAAK,EAAEF,I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