@webiny/api-apw 5.33.5 → 5.34.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +40 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +40 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +40 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +40 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +1 -1
- package/crud/createChangeRequestMethods.js +21 -18
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +21 -18
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +60 -50
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +21 -18
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +42 -20
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +3 -7
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -8
- package/crud/utils.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +8 -4
- package/index.js.map +1 -1
- package/package.json +38 -37
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -1
- package/plugins/cms/apwEntryPlugins.js +4 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +9 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -4
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +5 -5
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +35 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +35 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +35 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +60 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +3 -3
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +10 -14
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +4 -8
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -1
- package/plugins/graphql/comment.gql.js +1 -1
- package/plugins/graphql/contentReview.gql.js +4 -4
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -1
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -1
- package/plugins/graphql.js +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +28 -8
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +6 -0
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +5 -8
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +20 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +10 -0
- package/plugins/hooks/listContentReviews.js +68 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +22 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +31 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +29 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +51 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +7 -11
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +14 -18
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +30 -5
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +14 -4
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -2
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -1
- package/plugins/pageBuilder/index.js +9 -1
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +41 -29
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +18 -6
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +3 -3
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -14
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -1
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +4 -14
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +17 -14
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +8 -9
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +5 -9
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +1 -1
- package/storageOperations/changeRequestStorageOperations.js +5 -9
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +4 -8
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +5 -9
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +5 -9
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +3 -7
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +6 -5
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +1 -1
- package/storageOperations/models/reviewer.model.js +18 -2
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +3 -2
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +18 -14
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +8 -12
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +99 -84
- package/types.js.map +1 -1
- package/utils/errors.js +1 -1
- package/utils/fieldResolver.js +3 -9
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
@@ -1,13 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports.createContentReviewMethods = createContentReviewMethods;
|
9
9
|
|
10
|
-
var
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
11
|
|
12
12
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
13
|
|
@@ -27,10 +27,6 @@ var _utils2 = require("./utils");
|
|
27
27
|
|
28
28
|
var _contentApwSettingsPlugin = require("../utils/contentApwSettingsPlugin");
|
29
29
|
|
30
|
-
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; }
|
31
|
-
|
32
|
-
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; }
|
33
|
-
|
34
30
|
function createContentReviewMethods(params) {
|
35
31
|
const {
|
36
32
|
getIdentity,
|
@@ -44,23 +40,29 @@ function createContentReviewMethods(params) {
|
|
44
40
|
getTenant,
|
45
41
|
getLocale,
|
46
42
|
plugins
|
47
|
-
} = params;
|
48
|
-
|
49
|
-
const
|
50
|
-
const
|
51
|
-
|
52
|
-
const
|
53
|
-
const
|
43
|
+
} = params; // create
|
44
|
+
|
45
|
+
const onContentReviewBeforeCreate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeCreate");
|
46
|
+
const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate"); // update
|
47
|
+
|
48
|
+
const onContentReviewBeforeUpdate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeUpdate");
|
49
|
+
const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate"); // delete
|
50
|
+
|
51
|
+
const onContentReviewBeforeDelete = (0, _pubsub.createTopic)("apw.onContentReviewBeforeDelete");
|
52
|
+
const onContentReviewAfterDelete = (0, _pubsub.createTopic)("apw.onContentReviewAfterDelete"); // list
|
53
|
+
|
54
|
+
const onContentReviewBeforeList = (0, _pubsub.createTopic)("apw.onContentReviewBeforeList");
|
54
55
|
return {
|
55
56
|
/**
|
56
57
|
* Lifecycle events
|
57
58
|
*/
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
onContentReviewBeforeCreate,
|
60
|
+
onContentReviewAfterCreate,
|
61
|
+
onContentReviewBeforeUpdate,
|
62
|
+
onContentReviewAfterUpdate,
|
63
|
+
onContentReviewBeforeDelete,
|
64
|
+
onContentReviewAfterDelete,
|
65
|
+
onContentReviewBeforeList,
|
64
66
|
|
65
67
|
async get(id) {
|
66
68
|
return storageOperations.getContentReview({
|
@@ -69,30 +71,38 @@ function createContentReviewMethods(params) {
|
|
69
71
|
},
|
70
72
|
|
71
73
|
async list(params) {
|
72
|
-
|
74
|
+
const where = params.where || {};
|
75
|
+
await onContentReviewBeforeList.publish({
|
76
|
+
where
|
77
|
+
});
|
78
|
+
|
79
|
+
if (where.reviewStatus === "requiresMyAttention") {
|
73
80
|
return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
|
74
|
-
listParams: params,
|
81
|
+
listParams: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
82
|
+
where
|
83
|
+
}),
|
75
84
|
listContentReviews: storageOperations.listContentReviews,
|
76
85
|
getReviewer,
|
77
86
|
getIdentity
|
78
87
|
});
|
79
88
|
}
|
80
89
|
|
81
|
-
return storageOperations.listContentReviews(params)
|
90
|
+
return storageOperations.listContentReviews((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
91
|
+
where
|
92
|
+
}));
|
82
93
|
},
|
83
94
|
|
84
95
|
async create(data) {
|
85
|
-
const input =
|
86
|
-
|
96
|
+
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
97
|
+
reviewStatus: _types.ApwContentReviewStatus.UNDER_REVIEW
|
87
98
|
});
|
88
|
-
|
89
|
-
await onBeforeContentReviewCreate.publish({
|
99
|
+
await onContentReviewBeforeCreate.publish({
|
90
100
|
input
|
91
101
|
});
|
92
102
|
const contentReview = await storageOperations.createContentReview({
|
93
103
|
data: input
|
94
104
|
});
|
95
|
-
await
|
105
|
+
await onContentReviewAfterCreate.publish({
|
96
106
|
contentReview
|
97
107
|
});
|
98
108
|
return contentReview;
|
@@ -102,7 +112,7 @@ function createContentReviewMethods(params) {
|
|
102
112
|
const original = await storageOperations.getContentReview({
|
103
113
|
id
|
104
114
|
});
|
105
|
-
await
|
115
|
+
await onContentReviewBeforeUpdate.publish({
|
106
116
|
original,
|
107
117
|
input: {
|
108
118
|
id,
|
@@ -113,7 +123,7 @@ function createContentReviewMethods(params) {
|
|
113
123
|
id,
|
114
124
|
data
|
115
125
|
});
|
116
|
-
await
|
126
|
+
await onContentReviewAfterUpdate.publish({
|
117
127
|
original,
|
118
128
|
input: {
|
119
129
|
id,
|
@@ -128,13 +138,13 @@ function createContentReviewMethods(params) {
|
|
128
138
|
const contentReview = await storageOperations.getContentReview({
|
129
139
|
id
|
130
140
|
});
|
131
|
-
await
|
141
|
+
await onContentReviewBeforeDelete.publish({
|
132
142
|
contentReview
|
133
143
|
});
|
134
144
|
await storageOperations.deleteContentReview({
|
135
145
|
id
|
136
146
|
});
|
137
|
-
await
|
147
|
+
await onContentReviewAfterDelete.publish({
|
138
148
|
contentReview
|
139
149
|
});
|
140
150
|
return true;
|
@@ -144,7 +154,7 @@ function createContentReviewMethods(params) {
|
|
144
154
|
const entry = await this.get(id);
|
145
155
|
const {
|
146
156
|
steps,
|
147
|
-
|
157
|
+
reviewStatus
|
148
158
|
} = entry;
|
149
159
|
const stepIndex = steps.findIndex(step => step.id === stepId);
|
150
160
|
const currentStep = steps[stepIndex];
|
@@ -219,7 +229,7 @@ function createContentReviewMethods(params) {
|
|
219
229
|
const updatedSteps = steps.map((step, index) => {
|
220
230
|
if (index === stepIndex) {
|
221
231
|
previousStepStatus = _types.ApwContentReviewStepStatus.DONE;
|
222
|
-
return
|
232
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
223
233
|
status: _types.ApwContentReviewStepStatus.DONE,
|
224
234
|
signOffProvidedOn: new Date().toISOString(),
|
225
235
|
signOffProvidedBy: identity
|
@@ -233,7 +243,7 @@ function createContentReviewMethods(params) {
|
|
233
243
|
if (index > stepIndex) {
|
234
244
|
const previousStep = steps[index - 1];
|
235
245
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
236
|
-
return
|
246
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
237
247
|
status: previousStepStatus
|
238
248
|
});
|
239
249
|
}
|
@@ -244,7 +254,7 @@ function createContentReviewMethods(params) {
|
|
244
254
|
* Check for pending steps
|
245
255
|
*/
|
246
256
|
|
247
|
-
let newStatus =
|
257
|
+
let newStatus = reviewStatus;
|
248
258
|
const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => typeof step.signOffProvidedOn !== "string");
|
249
259
|
/**
|
250
260
|
* If there are no required steps that are pending, set the status to "READY_TO_BE_PUBLISHED".
|
@@ -260,7 +270,7 @@ function createContentReviewMethods(params) {
|
|
260
270
|
|
261
271
|
await this.update(id, {
|
262
272
|
steps: updatedSteps,
|
263
|
-
|
273
|
+
reviewStatus: newStatus
|
264
274
|
});
|
265
275
|
return true;
|
266
276
|
},
|
@@ -269,7 +279,7 @@ function createContentReviewMethods(params) {
|
|
269
279
|
const entry = await this.get(id);
|
270
280
|
const {
|
271
281
|
steps,
|
272
|
-
|
282
|
+
reviewStatus
|
273
283
|
} = entry;
|
274
284
|
const stepIndex = steps.findIndex(step => step.id === stepId);
|
275
285
|
const currentStep = steps[stepIndex];
|
@@ -315,7 +325,7 @@ function createContentReviewMethods(params) {
|
|
315
325
|
const updatedSteps = steps.map((step, index) => {
|
316
326
|
if (index === stepIndex) {
|
317
327
|
previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
|
318
|
-
return
|
328
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
319
329
|
status: previousStepStatus,
|
320
330
|
signOffProvidedOn: null,
|
321
331
|
signOffProvidedBy: null
|
@@ -329,7 +339,7 @@ function createContentReviewMethods(params) {
|
|
329
339
|
if (index > stepIndex) {
|
330
340
|
const previousStep = steps[index - 1];
|
331
341
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
332
|
-
return
|
342
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
333
343
|
status: previousStepStatus
|
334
344
|
});
|
335
345
|
}
|
@@ -340,7 +350,7 @@ function createContentReviewMethods(params) {
|
|
340
350
|
* Check for pending steps
|
341
351
|
*/
|
342
352
|
|
343
|
-
let newStatus =
|
353
|
+
let newStatus = reviewStatus;
|
344
354
|
const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => step.signOffProvidedOn === null);
|
345
355
|
/**
|
346
356
|
* If there are required steps that are pending, set the status to "UNDER_REVIEW".
|
@@ -352,7 +362,7 @@ function createContentReviewMethods(params) {
|
|
352
362
|
|
353
363
|
await this.update(id, {
|
354
364
|
steps: updatedSteps,
|
355
|
-
|
365
|
+
reviewStatus: newStatus
|
356
366
|
});
|
357
367
|
return true;
|
358
368
|
},
|
@@ -387,17 +397,17 @@ function createContentReviewMethods(params) {
|
|
387
397
|
|
388
398
|
const {
|
389
399
|
content,
|
390
|
-
|
400
|
+
reviewStatus
|
391
401
|
} = await this.get(id);
|
392
402
|
const identity = getIdentity();
|
393
403
|
|
394
|
-
if (
|
404
|
+
if (reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
395
405
|
throw new _error.default({
|
396
406
|
message: `Cannot publish content because it is not yet ready to be published.`,
|
397
407
|
code: "NOT_READY_TO_BE_PUBLISHED",
|
398
408
|
data: {
|
399
409
|
id,
|
400
|
-
status,
|
410
|
+
status: reviewStatus,
|
401
411
|
content
|
402
412
|
}
|
403
413
|
});
|
@@ -428,7 +438,7 @@ function createContentReviewMethods(params) {
|
|
428
438
|
*/
|
429
439
|
|
430
440
|
await this.update(id, {
|
431
|
-
content:
|
441
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
432
442
|
scheduledOn: datetime,
|
433
443
|
scheduledBy: identity.id,
|
434
444
|
scheduledActionId
|
@@ -442,17 +452,17 @@ function createContentReviewMethods(params) {
|
|
442
452
|
|
443
453
|
const {
|
444
454
|
content,
|
445
|
-
|
455
|
+
reviewStatus
|
446
456
|
} = await this.get(id);
|
447
457
|
const identity = getIdentity();
|
448
458
|
|
449
|
-
if (
|
459
|
+
if (reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
|
450
460
|
throw new _error.default({
|
451
461
|
message: `Cannot unpublish content because it is not yet published.`,
|
452
462
|
code: "NOT_YET_PUBLISHED",
|
453
463
|
data: {
|
454
464
|
id,
|
455
|
-
status,
|
465
|
+
status: reviewStatus,
|
456
466
|
content
|
457
467
|
}
|
458
468
|
});
|
@@ -482,7 +492,7 @@ function createContentReviewMethods(params) {
|
|
482
492
|
*/
|
483
493
|
|
484
494
|
await this.update(id, {
|
485
|
-
content:
|
495
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
486
496
|
scheduledOn: datetime,
|
487
497
|
scheduledBy: identity.id,
|
488
498
|
scheduledActionId
|
@@ -543,7 +553,7 @@ function createContentReviewMethods(params) {
|
|
543
553
|
*/
|
544
554
|
|
545
555
|
await this.update(id, {
|
546
|
-
content:
|
556
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META)
|
547
557
|
});
|
548
558
|
return true;
|
549
559
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onBeforeContentReviewCreate","createTopic","onAfterContentReviewCreate","onBeforeContentReviewUpdate","onAfterContentReviewUpdate","onBeforeContentReviewDelete","onAfterContentReviewDelete","get","id","getContentReview","list","where","status","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","publish","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","NoSignOffProvidedError","isReviewRequired","contentGetter","content","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduledActionId","scheduleAction","scheduledOn","scheduledBy","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwParams,\n OnAfterContentReviewCreateTopicParams,\n OnAfterContentReviewDeleteTopicParams,\n OnAfterContentReviewUpdateTopicParams,\n OnBeforeContentReviewCreateTopicParams,\n OnBeforeContentReviewDeleteTopicParams,\n OnBeforeContentReviewUpdateTopicParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n const onBeforeContentReviewCreate = createTopic<OnBeforeContentReviewCreateTopicParams>();\n const onAfterContentReviewCreate = createTopic<OnAfterContentReviewCreateTopicParams>();\n const onBeforeContentReviewUpdate = createTopic<OnBeforeContentReviewUpdateTopicParams>();\n const onAfterContentReviewUpdate = createTopic<OnAfterContentReviewUpdateTopicParams>();\n const onBeforeContentReviewDelete = createTopic<OnBeforeContentReviewDeleteTopicParams>();\n const onAfterContentReviewDelete = createTopic<OnAfterContentReviewDeleteTopicParams>();\n return {\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate,\n onAfterContentReviewCreate,\n onBeforeContentReviewUpdate,\n onAfterContentReviewUpdate,\n onBeforeContentReviewDelete,\n onAfterContentReviewDelete,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n if (params.where && params.where.status === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: params,\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews(params);\n },\n async create(data) {\n const input = {\n ...data,\n status: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onBeforeContentReviewCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onAfterContentReviewCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data) {\n const original = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onAfterContentReviewUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onAfterContentReviewDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAiBA;;AACA;;AAOA;;AACA;;AAMA;;;;;;AAWO,SAASA,0BAAT,CACHC,MADG,EAEiB;EACpB,MAAM;IACFC,WADE;IAEFC,iBAFE;IAGFC,WAHE;IAIFC,gBAJE;IAKFC,mBALE;IAMFC,qBANE;IAOFC,SAPE;IAQFC,aARE;IASFC,SATE;IAUFC,SAVE;IAWFC;EAXE,IAYFX,MAZJ;EAcA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAA,GAApC;EACA,MAAMC,0BAA0B,GAAG,IAAAD,mBAAA,GAAnC;EACA,MAAME,2BAA2B,GA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H"}
|
1
|
+
{"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onContentReviewBeforeCreate","createTopic","onContentReviewAfterCreate","onContentReviewBeforeUpdate","onContentReviewAfterUpdate","onContentReviewBeforeDelete","onContentReviewAfterDelete","onContentReviewBeforeList","get","id","getContentReview","list","where","publish","reviewStatus","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","status","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","NoSignOffProvidedError","isReviewRequired","contentGetter","content","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduledActionId","scheduleAction","scheduledOn","scheduledBy","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwContentReviewParams,\n CreateApwParams,\n OnContentReviewAfterCreateTopicParams,\n OnContentReviewAfterDeleteTopicParams,\n OnContentReviewAfterUpdateTopicParams,\n OnContentReviewBeforeCreateTopicParams,\n OnContentReviewBeforeDeleteTopicParams,\n OnContentReviewBeforeListTopicParams,\n OnContentReviewBeforeUpdateTopicParams,\n UpdateApwContentReviewParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n // create\n const onContentReviewBeforeCreate = createTopic<OnContentReviewBeforeCreateTopicParams>(\n \"apw.onContentReviewBeforeCreate\"\n );\n const onContentReviewAfterCreate = createTopic<OnContentReviewAfterCreateTopicParams>(\n \"apw.onContentReviewAfterCreate\"\n );\n // update\n const onContentReviewBeforeUpdate = createTopic<OnContentReviewBeforeUpdateTopicParams>(\n \"apw.onContentReviewBeforeUpdate\"\n );\n const onContentReviewAfterUpdate = createTopic<OnContentReviewAfterUpdateTopicParams>(\n \"apw.onContentReviewAfterUpdate\"\n );\n // delete\n const onContentReviewBeforeDelete = createTopic<OnContentReviewBeforeDeleteTopicParams>(\n \"apw.onContentReviewBeforeDelete\"\n );\n const onContentReviewAfterDelete = createTopic<OnContentReviewAfterDeleteTopicParams>(\n \"apw.onContentReviewAfterDelete\"\n );\n // list\n const onContentReviewBeforeList = createTopic<OnContentReviewBeforeListTopicParams>(\n \"apw.onContentReviewBeforeList\"\n );\n return {\n /**\n * Lifecycle events\n */\n onContentReviewBeforeCreate,\n onContentReviewAfterCreate,\n onContentReviewBeforeUpdate,\n onContentReviewAfterUpdate,\n onContentReviewBeforeDelete,\n onContentReviewAfterDelete,\n onContentReviewBeforeList,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n const where = params.where || {};\n\n await onContentReviewBeforeList.publish({\n where\n });\n\n if (where.reviewStatus === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: {\n ...params,\n where\n },\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews({\n ...params,\n where\n });\n },\n async create(data: Omit<CreateApwContentReviewParams, \"reviewStatus\">) {\n const input: CreateApwContentReviewParams = {\n ...data,\n reviewStatus: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onContentReviewBeforeCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onContentReviewAfterCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data: UpdateApwContentReviewParams) {\n const original = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onContentReviewAfterUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onContentReviewBeforeDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onContentReviewAfterDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, reviewStatus } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, reviewStatus } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = reviewStatus;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n await this.update(id, {\n steps: updatedSteps,\n reviewStatus: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, reviewStatus } = await this.get(id);\n const identity = getIdentity();\n\n if (reviewStatus !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status: reviewStatus,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\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,OAAO,EAAE;UACLC,MAAM,EAAEhH,SAAS,GAAGY,EADf;UAELqG,MAAM,EAAEhH,SAAS,GAAGsF;QAFf,CAFc;QAMvB2B,KAAK,EAAE,KANgB;QAOvBC,WAAW,EAAE;MAPU,CAArB,CAAN;MASA,OAAOZ,eAAe,CAAC3F,EAAvB;IACH,CArZE;;IAsZH,MAAMwG,qBAAN,CAA4BxG,EAA5B,EAAgC;MAC5B,MAAMc,aAAa,GAAG,MAAM,KAAKf,GAAL,CAASC,EAAT,CAA5B;MACA,MAAMmF,iBAAiB,GAAG,IAAApF,YAAA,EAAIe,aAAJ,EAAmB,2BAAnB,CAA1B;MAEA;AACZ;AACA;;MACY,IAAI,CAACqE,iBAAL,EAAwB;QACpB,MAAM,IAAIV,cAAJ,CAAU;UACZC,OAAO,EAAG,kDADE;UAEZC,IAAI,EAAE,qBAFM;UAGZjE,IAAI,EAAE;YACFV;UADE;QAHM,CAAV,CAAN;MAOH;MACD;AACZ;AACA;;;MACY,MAAMd,SAAS,CAACiC,MAAV,CAAiBgE,iBAAjB,CAAN;MAEA;AACZ;AACA;;MACY,MAAM,KAAKnE,MAAL,CAAYhB,EAAZ,EAAgB;QAClB+D,OAAO,8DACAjD,aAAa,CAACiD,OADd,GAEA0C,oDAFA;MADW,CAAhB,CAAN;MAOA,OAAO,IAAP;IACH;;EAtbE,CAAP;AAwbH"}
|
@@ -10,22 +10,25 @@ var _pubsub = require("@webiny/pubsub");
|
|
10
10
|
function createReviewerMethods({
|
11
11
|
storageOperations
|
12
12
|
}) {
|
13
|
-
|
14
|
-
const
|
15
|
-
const
|
16
|
-
|
17
|
-
const
|
18
|
-
const
|
13
|
+
// create
|
14
|
+
const onReviewerBeforeCreate = (0, _pubsub.createTopic)("apw.onReviewerBeforeCreate");
|
15
|
+
const onReviewerAfterCreate = (0, _pubsub.createTopic)("apw.onReviewerAfterCreate"); // update
|
16
|
+
|
17
|
+
const onReviewerBeforeUpdate = (0, _pubsub.createTopic)("apw.onReviewerBeforeUpdate");
|
18
|
+
const onReviewerAfterUpdate = (0, _pubsub.createTopic)("apw.onReviewerAfterUpdate"); // delete
|
19
|
+
|
20
|
+
const onReviewerBeforeDelete = (0, _pubsub.createTopic)("apw.onReviewerBeforeDelete");
|
21
|
+
const onReviewerAfterDelete = (0, _pubsub.createTopic)("apw.onReviewerAfterDelete");
|
19
22
|
return {
|
20
23
|
/**
|
21
24
|
* Lifecycle events
|
22
25
|
*/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
onReviewerBeforeCreate,
|
27
|
+
onReviewerAfterCreate,
|
28
|
+
onReviewerBeforeUpdate,
|
29
|
+
onReviewerAfterUpdate,
|
30
|
+
onReviewerBeforeDelete,
|
31
|
+
onReviewerAfterDelete,
|
29
32
|
|
30
33
|
async get(id) {
|
31
34
|
return storageOperations.getReviewer({
|
@@ -38,13 +41,13 @@ function createReviewerMethods({
|
|
38
41
|
},
|
39
42
|
|
40
43
|
async create(data) {
|
41
|
-
await
|
44
|
+
await onReviewerBeforeCreate.publish({
|
42
45
|
input: data
|
43
46
|
});
|
44
47
|
const reviewer = await storageOperations.createReviewer({
|
45
48
|
data
|
46
49
|
});
|
47
|
-
await
|
50
|
+
await onReviewerAfterCreate.publish({
|
48
51
|
reviewer
|
49
52
|
});
|
50
53
|
return reviewer;
|
@@ -54,7 +57,7 @@ function createReviewerMethods({
|
|
54
57
|
const original = await storageOperations.getReviewer({
|
55
58
|
id
|
56
59
|
});
|
57
|
-
await
|
60
|
+
await onReviewerBeforeUpdate.publish({
|
58
61
|
original,
|
59
62
|
input: {
|
60
63
|
id,
|
@@ -65,7 +68,7 @@ function createReviewerMethods({
|
|
65
68
|
id,
|
66
69
|
data
|
67
70
|
});
|
68
|
-
await
|
71
|
+
await onReviewerAfterUpdate.publish({
|
69
72
|
original,
|
70
73
|
input: {
|
71
74
|
id,
|
@@ -80,13 +83,13 @@ function createReviewerMethods({
|
|
80
83
|
const reviewer = await storageOperations.getReviewer({
|
81
84
|
id
|
82
85
|
});
|
83
|
-
await
|
86
|
+
await onReviewerBeforeDelete.publish({
|
84
87
|
reviewer
|
85
88
|
});
|
86
89
|
await storageOperations.deleteReviewer({
|
87
90
|
id
|
88
91
|
});
|
89
|
-
await
|
92
|
+
await onReviewerAfterDelete.publish({
|
90
93
|
reviewer
|
91
94
|
});
|
92
95
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createReviewerMethods","storageOperations","
|
1
|
+
{"version":3,"names":["createReviewerMethods","storageOperations","onReviewerBeforeCreate","createTopic","onReviewerAfterCreate","onReviewerBeforeUpdate","onReviewerAfterUpdate","onReviewerBeforeDelete","onReviewerAfterDelete","get","id","getReviewer","list","params","listReviewers","create","data","publish","input","reviewer","createReviewer","update","original","updateReviewer","delete","deleteReviewer"],"sources":["createReviewerMethods.ts"],"sourcesContent":["import {\n ApwReviewerCrud,\n CreateApwParams,\n OnReviewerAfterCreateTopicParams,\n OnReviewerAfterDeleteTopicParams,\n OnReviewerAfterUpdateTopicParams,\n OnReviewerBeforeCreateTopicParams,\n OnReviewerBeforeDeleteTopicParams,\n OnReviewerBeforeUpdateTopicParams\n} from \"~/types\";\nimport { createTopic } from \"@webiny/pubsub\";\n\nexport function createReviewerMethods({ storageOperations }: CreateApwParams): ApwReviewerCrud {\n // create\n const onReviewerBeforeCreate = createTopic<OnReviewerBeforeCreateTopicParams>(\n \"apw.onReviewerBeforeCreate\"\n );\n const onReviewerAfterCreate = createTopic<OnReviewerAfterCreateTopicParams>(\n \"apw.onReviewerAfterCreate\"\n );\n // update\n const onReviewerBeforeUpdate = createTopic<OnReviewerBeforeUpdateTopicParams>(\n \"apw.onReviewerBeforeUpdate\"\n );\n const onReviewerAfterUpdate = createTopic<OnReviewerAfterUpdateTopicParams>(\n \"apw.onReviewerAfterUpdate\"\n );\n // delete\n const onReviewerBeforeDelete = createTopic<OnReviewerBeforeDeleteTopicParams>(\n \"apw.onReviewerBeforeDelete\"\n );\n const onReviewerAfterDelete = createTopic<OnReviewerAfterDeleteTopicParams>(\n \"apw.onReviewerAfterDelete\"\n );\n return {\n /**\n * Lifecycle events\n */\n onReviewerBeforeCreate,\n onReviewerAfterCreate,\n onReviewerBeforeUpdate,\n onReviewerAfterUpdate,\n onReviewerBeforeDelete,\n onReviewerAfterDelete,\n async get(id) {\n return storageOperations.getReviewer({ id });\n },\n async list(params) {\n return storageOperations.listReviewers(params);\n },\n async create(data) {\n await onReviewerBeforeCreate.publish({ input: data });\n\n const reviewer = await storageOperations.createReviewer({ data });\n\n await onReviewerAfterCreate.publish({ reviewer });\n\n return reviewer;\n },\n async update(id, data) {\n const original = await storageOperations.getReviewer({ id });\n\n await onReviewerBeforeUpdate.publish({ original, input: { id, data } });\n\n const reviewer = await storageOperations.updateReviewer({ id, data });\n\n await onReviewerAfterUpdate.publish({ original, input: { id, data }, reviewer });\n\n return reviewer;\n },\n async delete(id: string) {\n const reviewer = await storageOperations.getReviewer({ id });\n\n await onReviewerBeforeDelete.publish({ reviewer });\n\n await storageOperations.deleteReviewer({ id });\n\n await onReviewerAfterDelete.publish({ reviewer });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;AAUA;;AAEO,SAASA,qBAAT,CAA+B;EAAEC;AAAF,CAA/B,EAAwF;EAC3F;EACA,MAAMC,sBAAsB,GAAG,IAAAC,mBAAA,EAC3B,4BAD2B,CAA/B;EAGA,MAAMC,qBAAqB,GAAG,IAAAD,mBAAA,EAC1B,2BAD0B,CAA9B,CAL2F,CAQ3F;;EACA,MAAME,sBAAsB,GAAG,IAAAF,mBAAA,EAC3B,4BAD2B,CAA/B;EAGA,MAAMG,qBAAqB,GAAG,IAAAH,mBAAA,EAC1B,2BAD0B,CAA9B,CAZ2F,CAe3F;;EACA,MAAMI,sBAAsB,GAAG,IAAAJ,mBAAA,EAC3B,4BAD2B,CAA/B;EAGA,MAAMK,qBAAqB,GAAG,IAAAL,mBAAA,EAC1B,2BAD0B,CAA9B;E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,MAAMS,QAAQ,GAAG,MAAMlB,iBAAiB,CAACU,WAAlB,CAA8B;QAAED;MAAF,CAA9B,CAAvB;MAEA,MAAMH,sBAAsB,CAACU,OAAvB,CAA+B;QAAEE;MAAF,CAA/B,CAAN;MAEA,MAAMlB,iBAAiB,CAACwB,cAAlB,CAAiC;QAAEf;MAAF,CAAjC,CAAN;MAEA,MAAMF,qBAAqB,CAACS,OAAtB,CAA8B;QAAEE;MAAF,CAA9B,CAAN;MAEA,OAAO,IAAP;IACH;;EA9CE,CAAP;AAgDH"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { ApwWorkflowCrud, CreateApwParams } from "../types";
|
2
|
-
export declare function createWorkflowMethods({ storageOperations }: CreateApwParams): ApwWorkflowCrud;
|
2
|
+
export declare function createWorkflowMethods({ storageOperations, getPermission }: CreateApwParams): ApwWorkflowCrud;
|