@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.611c5af35e
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/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +30 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +30 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +30 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +30 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +0 -5
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +4 -11
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +4 -12
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +32 -86
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +4 -12
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +4 -17
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +0 -25
- package/crud/index.js.map +1 -1
- package/crud/utils.js +0 -28
- package/crud/utils.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +5 -13
- package/index.js.map +1 -1
- package/package.json +35 -35
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +0 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +5 -10
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +0 -17
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +2 -31
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +31 -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 +31 -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 +31 -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 +53 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +0 -14
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +0 -18
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +2 -47
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +0 -31
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -8
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +1 -8
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +1 -20
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -8
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -8
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +1 -16
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +26 -15
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +2 -13
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +2 -15
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +15 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +1 -1
- package/plugins/hooks/listContentReviews.js +9 -33
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +18 -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 +116 -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 +27 -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 +127 -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 +27 -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 +99 -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 +26 -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 +24 -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 +21 -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 +21 -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 +21 -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 +44 -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 +41 -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 +41 -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 +41 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +0 -8
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +0 -9
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +25 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +11 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +0 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +5 -8
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -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 +31 -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 +31 -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 +47 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +0 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +0 -1
- package/plugins/utils.js +1 -50
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +1 -20
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.js +9 -33
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -5
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +0 -21
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -27
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +0 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -25
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.js +3 -40
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.js +0 -6
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +0 -19
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +0 -21
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +0 -17
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +0 -14
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +0 -9
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +0 -8
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +0 -5
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +0 -26
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +2 -24
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +17 -9
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +0 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +0 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +11 -20
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +0 -19
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +21 -9
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +0 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +2 -12
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -1,32 +1,20 @@
|
|
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.createContentReviewMethods = createContentReviewMethods;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
-
|
14
10
|
var _pubsub = require("@webiny/pubsub");
|
15
|
-
|
16
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
12
|
var _types = require("../types");
|
19
|
-
|
20
13
|
var _utils = require("../plugins/utils");
|
21
|
-
|
22
14
|
var _errors = require("../utils/errors");
|
23
|
-
|
24
15
|
var _types2 = require("../scheduler/types");
|
25
|
-
|
26
16
|
var _utils2 = require("./utils");
|
27
|
-
|
28
17
|
var _contentApwSettingsPlugin = require("../utils/contentApwSettingsPlugin");
|
29
|
-
|
30
18
|
function createContentReviewMethods(params) {
|
31
19
|
const {
|
32
20
|
getIdentity,
|
@@ -40,16 +28,19 @@ function createContentReviewMethods(params) {
|
|
40
28
|
getTenant,
|
41
29
|
getLocale,
|
42
30
|
plugins
|
43
|
-
} = params;
|
31
|
+
} = params;
|
44
32
|
|
33
|
+
// create
|
45
34
|
const onContentReviewBeforeCreate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeCreate");
|
46
|
-
const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate");
|
47
|
-
|
35
|
+
const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate");
|
36
|
+
// update
|
48
37
|
const onContentReviewBeforeUpdate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeUpdate");
|
49
|
-
const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate");
|
50
|
-
|
38
|
+
const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate");
|
39
|
+
// delete
|
51
40
|
const onContentReviewBeforeDelete = (0, _pubsub.createTopic)("apw.onContentReviewBeforeDelete");
|
52
41
|
const onContentReviewAfterDelete = (0, _pubsub.createTopic)("apw.onContentReviewAfterDelete");
|
42
|
+
// list
|
43
|
+
const onContentReviewBeforeList = (0, _pubsub.createTopic)("apw.onContentReviewBeforeList");
|
53
44
|
return {
|
54
45
|
/**
|
55
46
|
* Lifecycle events
|
@@ -60,28 +51,31 @@ function createContentReviewMethods(params) {
|
|
60
51
|
onContentReviewAfterUpdate,
|
61
52
|
onContentReviewBeforeDelete,
|
62
53
|
onContentReviewAfterDelete,
|
63
|
-
|
54
|
+
onContentReviewBeforeList,
|
64
55
|
async get(id) {
|
65
56
|
return storageOperations.getContentReview({
|
66
57
|
id
|
67
58
|
});
|
68
59
|
},
|
69
|
-
|
70
60
|
async list(params) {
|
71
|
-
|
72
|
-
|
73
|
-
|
61
|
+
const where = params.where || {};
|
62
|
+
await onContentReviewBeforeList.publish({
|
63
|
+
where
|
64
|
+
});
|
65
|
+
if (where.reviewStatus === "requiresMyAttention") {
|
74
66
|
return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
|
75
|
-
listParams: params,
|
67
|
+
listParams: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
68
|
+
where
|
69
|
+
}),
|
76
70
|
listContentReviews: storageOperations.listContentReviews,
|
77
71
|
getReviewer,
|
78
72
|
getIdentity
|
79
73
|
});
|
80
74
|
}
|
81
|
-
|
82
|
-
|
75
|
+
return storageOperations.listContentReviews((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
76
|
+
where
|
77
|
+
}));
|
83
78
|
},
|
84
|
-
|
85
79
|
async create(data) {
|
86
80
|
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
87
81
|
reviewStatus: _types.ApwContentReviewStatus.UNDER_REVIEW
|
@@ -97,7 +91,6 @@ function createContentReviewMethods(params) {
|
|
97
91
|
});
|
98
92
|
return contentReview;
|
99
93
|
},
|
100
|
-
|
101
94
|
async update(id, data) {
|
102
95
|
const original = await storageOperations.getContentReview({
|
103
96
|
id
|
@@ -123,7 +116,6 @@ function createContentReviewMethods(params) {
|
|
123
116
|
});
|
124
117
|
return contentReview;
|
125
118
|
},
|
126
|
-
|
127
119
|
async delete(id) {
|
128
120
|
const contentReview = await storageOperations.getContentReview({
|
129
121
|
id
|
@@ -139,7 +131,6 @@ function createContentReviewMethods(params) {
|
|
139
131
|
});
|
140
132
|
return true;
|
141
133
|
},
|
142
|
-
|
143
134
|
async provideSignOff(id, stepId) {
|
144
135
|
const entry = await this.get(id);
|
145
136
|
const {
|
@@ -155,10 +146,10 @@ function createContentReviewMethods(params) {
|
|
155
146
|
identity,
|
156
147
|
step: currentStep
|
157
148
|
});
|
149
|
+
|
158
150
|
/**
|
159
151
|
* Check whether the sign-off is requested by a reviewer.
|
160
152
|
*/
|
161
|
-
|
162
153
|
if (!hasPermission) {
|
163
154
|
throw new _errors.NotAuthorizedError({
|
164
155
|
entry,
|
@@ -171,8 +162,6 @@ function createContentReviewMethods(params) {
|
|
171
162
|
/**
|
172
163
|
* Don't allow sign off, if previous step is of "mandatory_blocking" type and undone.
|
173
164
|
*/
|
174
|
-
|
175
|
-
|
176
165
|
if (previousStep && previousStep.status !== _types.ApwContentReviewStepStatus.DONE && previousStep.type === _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
|
177
166
|
throw new _errors.StepMissingError({
|
178
167
|
entry,
|
@@ -185,8 +174,6 @@ function createContentReviewMethods(params) {
|
|
185
174
|
/**
|
186
175
|
* Don't allow sign off, if there are pending change requests.
|
187
176
|
*/
|
188
|
-
|
189
|
-
|
190
177
|
if (currentStep.pendingChangeRequests > 0) {
|
191
178
|
throw new _errors.PendingChangeRequestsError({
|
192
179
|
entry,
|
@@ -199,8 +186,6 @@ function createContentReviewMethods(params) {
|
|
199
186
|
/**
|
200
187
|
* Don't allow sign off, if current step is not in "active" state.
|
201
188
|
*/
|
202
|
-
|
203
|
-
|
204
189
|
if (currentStep.status !== _types.ApwContentReviewStepStatus.ACTIVE) {
|
205
190
|
throw new _errors.StepInActiveError({
|
206
191
|
entry,
|
@@ -210,12 +195,10 @@ function createContentReviewMethods(params) {
|
|
210
195
|
}
|
211
196
|
});
|
212
197
|
}
|
213
|
-
|
214
198
|
let previousStepStatus;
|
215
199
|
/*
|
216
200
|
* Provide sign-off for give step.
|
217
201
|
*/
|
218
|
-
|
219
202
|
const updatedSteps = steps.map((step, index) => {
|
220
203
|
if (index === stepIndex) {
|
221
204
|
previousStepStatus = _types.ApwContentReviewStepStatus.DONE;
|
@@ -228,8 +211,6 @@ function createContentReviewMethods(params) {
|
|
228
211
|
/**
|
229
212
|
* Update next steps status based on type.
|
230
213
|
*/
|
231
|
-
|
232
|
-
|
233
214
|
if (index > stepIndex) {
|
234
215
|
const previousStep = steps[index - 1];
|
235
216
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
@@ -237,34 +218,30 @@ function createContentReviewMethods(params) {
|
|
237
218
|
status: previousStepStatus
|
238
219
|
});
|
239
220
|
}
|
240
|
-
|
241
221
|
return step;
|
242
222
|
});
|
243
223
|
/**
|
244
224
|
* Check for pending steps
|
245
225
|
*/
|
246
|
-
|
247
226
|
let newStatus = reviewStatus;
|
248
227
|
const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => typeof step.signOffProvidedOn !== "string");
|
228
|
+
|
249
229
|
/**
|
250
230
|
* If there are no required steps that are pending, set the status to "READY_TO_BE_PUBLISHED".
|
251
231
|
*/
|
252
|
-
|
253
232
|
if (pendingRequiredSteps.length === 0) {
|
254
233
|
newStatus = _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED;
|
255
234
|
}
|
235
|
+
|
256
236
|
/**
|
257
237
|
* Save updated steps.
|
258
238
|
*/
|
259
|
-
|
260
|
-
|
261
239
|
await this.update(id, {
|
262
240
|
steps: updatedSteps,
|
263
241
|
reviewStatus: newStatus
|
264
242
|
});
|
265
243
|
return true;
|
266
244
|
},
|
267
|
-
|
268
245
|
async retractSignOff(id, stepId) {
|
269
246
|
const entry = await this.get(id);
|
270
247
|
const {
|
@@ -279,10 +256,10 @@ function createContentReviewMethods(params) {
|
|
279
256
|
identity,
|
280
257
|
step: currentStep
|
281
258
|
});
|
259
|
+
|
282
260
|
/**
|
283
261
|
* Check whether the retract sign-off is requested by a reviewer.
|
284
262
|
*/
|
285
|
-
|
286
263
|
if (!hasPermission) {
|
287
264
|
throw new _errors.NotAuthorizedError({
|
288
265
|
entry,
|
@@ -295,8 +272,6 @@ function createContentReviewMethods(params) {
|
|
295
272
|
/**
|
296
273
|
* Don't allow, if step in not "done" i.e. no sign-off was provided for it.
|
297
274
|
*/
|
298
|
-
|
299
|
-
|
300
275
|
if (currentStep.status !== _types.ApwContentReviewStepStatus.DONE) {
|
301
276
|
throw new _errors.NoSignOffProvidedError({
|
302
277
|
entry,
|
@@ -306,12 +281,11 @@ function createContentReviewMethods(params) {
|
|
306
281
|
}
|
307
282
|
});
|
308
283
|
}
|
309
|
-
|
310
284
|
let previousStepStatus;
|
285
|
+
|
311
286
|
/*
|
312
287
|
* Retract sign-off for give step.
|
313
288
|
*/
|
314
|
-
|
315
289
|
const updatedSteps = steps.map((step, index) => {
|
316
290
|
if (index === stepIndex) {
|
317
291
|
previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
|
@@ -324,8 +298,6 @@ function createContentReviewMethods(params) {
|
|
324
298
|
/**
|
325
299
|
* Set next step status as "inactive".
|
326
300
|
*/
|
327
|
-
|
328
|
-
|
329
301
|
if (index > stepIndex) {
|
330
302
|
const previousStep = steps[index - 1];
|
331
303
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
@@ -333,30 +305,26 @@ function createContentReviewMethods(params) {
|
|
333
305
|
status: previousStepStatus
|
334
306
|
});
|
335
307
|
}
|
336
|
-
|
337
308
|
return step;
|
338
309
|
});
|
310
|
+
|
339
311
|
/**
|
340
312
|
* Check for pending steps
|
341
313
|
*/
|
342
|
-
|
343
314
|
let newStatus = reviewStatus;
|
344
315
|
const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => step.signOffProvidedOn === null);
|
345
316
|
/**
|
346
317
|
* If there are required steps that are pending, set the status to "UNDER_REVIEW".
|
347
318
|
*/
|
348
|
-
|
349
319
|
if (pendingRequiredSteps.length !== 0) {
|
350
320
|
newStatus = _types.ApwContentReviewStatus.UNDER_REVIEW;
|
351
321
|
}
|
352
|
-
|
353
322
|
await this.update(id, {
|
354
323
|
steps: updatedSteps,
|
355
324
|
reviewStatus: newStatus
|
356
325
|
});
|
357
326
|
return true;
|
358
327
|
},
|
359
|
-
|
360
328
|
async isReviewRequired(data) {
|
361
329
|
const contentGetter = getContentGetter(data.type);
|
362
330
|
const content = await contentGetter(data.id, data.settings);
|
@@ -366,31 +334,25 @@ function createContentReviewMethods(params) {
|
|
366
334
|
plugins,
|
367
335
|
type: data.type
|
368
336
|
});
|
369
|
-
|
370
337
|
if (contentApwSettingsPlugin) {
|
371
338
|
contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);
|
372
339
|
const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
|
373
|
-
|
374
340
|
if (workflowId) {
|
375
341
|
isReviewRequired = true;
|
376
342
|
}
|
377
343
|
}
|
378
|
-
|
379
344
|
return {
|
380
345
|
isReviewRequired,
|
381
346
|
contentReviewId
|
382
347
|
};
|
383
348
|
},
|
384
|
-
|
385
349
|
async publishContent(id, datetime) {
|
386
350
|
var _content$settings;
|
387
|
-
|
388
351
|
const {
|
389
352
|
content,
|
390
353
|
reviewStatus
|
391
354
|
} = await this.get(id);
|
392
355
|
const identity = getIdentity();
|
393
|
-
|
394
356
|
if (reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
395
357
|
throw new _error.default({
|
396
358
|
message: `Cannot publish content because it is not yet ready to be published.`,
|
@@ -402,19 +364,17 @@ function createContentReviewMethods(params) {
|
|
402
364
|
}
|
403
365
|
});
|
404
366
|
}
|
405
|
-
|
406
367
|
(0, _utils2.checkValidDateTime)(datetime);
|
368
|
+
|
407
369
|
/**
|
408
370
|
* If datetime is present it means we're scheduling this action.
|
409
371
|
* And if not, we are publishing immediately.
|
410
372
|
*/
|
411
|
-
|
412
373
|
if (!datetime) {
|
413
374
|
const contentPublisher = getContentPublisher(content.type);
|
414
375
|
await contentPublisher(content.id, content.settings);
|
415
376
|
return true;
|
416
377
|
}
|
417
|
-
|
418
378
|
const data = {
|
419
379
|
action: _types2.ApwScheduleActionTypes.PUBLISH,
|
420
380
|
type: content.type,
|
@@ -426,7 +386,6 @@ function createContentReviewMethods(params) {
|
|
426
386
|
/**
|
427
387
|
* Update scheduled related meta data.
|
428
388
|
*/
|
429
|
-
|
430
389
|
await this.update(id, {
|
431
390
|
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
432
391
|
scheduledOn: datetime,
|
@@ -436,16 +395,13 @@ function createContentReviewMethods(params) {
|
|
436
395
|
});
|
437
396
|
return true;
|
438
397
|
},
|
439
|
-
|
440
398
|
async unpublishContent(id, datetime) {
|
441
399
|
var _content$settings2;
|
442
|
-
|
443
400
|
const {
|
444
401
|
content,
|
445
402
|
reviewStatus
|
446
403
|
} = await this.get(id);
|
447
404
|
const identity = getIdentity();
|
448
|
-
|
449
405
|
if (reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
|
450
406
|
throw new _error.default({
|
451
407
|
message: `Cannot unpublish content because it is not yet published.`,
|
@@ -457,19 +413,17 @@ function createContentReviewMethods(params) {
|
|
457
413
|
}
|
458
414
|
});
|
459
415
|
}
|
460
|
-
|
461
416
|
(0, _utils2.checkValidDateTime)(datetime);
|
417
|
+
|
462
418
|
/**
|
463
419
|
* If datetime is present it means we're scheduling this action.
|
464
420
|
* If not, we are unpublishing immediately.
|
465
421
|
*/
|
466
|
-
|
467
422
|
if (!datetime) {
|
468
423
|
const contentUnPublisher = getContentUnPublisher(content.type);
|
469
424
|
await contentUnPublisher(content.id, content.settings);
|
470
425
|
return true;
|
471
426
|
}
|
472
|
-
|
473
427
|
const scheduledActionId = await this.scheduleAction({
|
474
428
|
action: _types2.ApwScheduleActionTypes.UNPUBLISH,
|
475
429
|
type: content.type,
|
@@ -480,7 +434,6 @@ function createContentReviewMethods(params) {
|
|
480
434
|
/**
|
481
435
|
* Update scheduled related meta data.
|
482
436
|
*/
|
483
|
-
|
484
437
|
await this.update(id, {
|
485
438
|
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
486
439
|
scheduledOn: datetime,
|
@@ -490,7 +443,6 @@ function createContentReviewMethods(params) {
|
|
490
443
|
});
|
491
444
|
return true;
|
492
445
|
},
|
493
|
-
|
494
446
|
async scheduleAction(data) {
|
495
447
|
// Save input in DB
|
496
448
|
const scheduledAction = await scheduler.create(data);
|
@@ -498,12 +450,10 @@ function createContentReviewMethods(params) {
|
|
498
450
|
* This function contains logic of lambda invocation.
|
499
451
|
* Current we're not mocking it, therefore, we're just returning true.
|
500
452
|
*/
|
501
|
-
|
502
453
|
if (process.env.NODE_ENV === "test") {
|
503
454
|
return scheduledAction.id;
|
504
|
-
}
|
505
|
-
|
506
|
-
|
455
|
+
}
|
456
|
+
// Invoke handler
|
507
457
|
await handlerClient.invoke({
|
508
458
|
name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),
|
509
459
|
payload: {
|
@@ -515,14 +465,13 @@ function createContentReviewMethods(params) {
|
|
515
465
|
});
|
516
466
|
return scheduledAction.id;
|
517
467
|
},
|
518
|
-
|
519
468
|
async deleteScheduledAction(id) {
|
520
469
|
const contentReview = await this.get(id);
|
521
470
|
const scheduledActionId = (0, _get.default)(contentReview, "content.scheduledActionId");
|
471
|
+
|
522
472
|
/**
|
523
473
|
* Check if there is any action scheduled for this "content review".
|
524
474
|
*/
|
525
|
-
|
526
475
|
if (!scheduledActionId) {
|
527
476
|
throw new _error.default({
|
528
477
|
message: `There is no action scheduled for content review.`,
|
@@ -535,18 +484,15 @@ function createContentReviewMethods(params) {
|
|
535
484
|
/**
|
536
485
|
* Delete scheduled action.
|
537
486
|
*/
|
538
|
-
|
539
|
-
|
540
487
|
await scheduler.delete(scheduledActionId);
|
488
|
+
|
541
489
|
/**
|
542
490
|
* Reset scheduled related meta data.
|
543
491
|
*/
|
544
|
-
|
545
492
|
await this.update(id, {
|
546
493
|
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META)
|
547
494
|
});
|
548
495
|
return true;
|
549
496
|
}
|
550
|
-
|
551
497
|
};
|
552
498
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onContentReviewBeforeCreate","createTopic","onContentReviewAfterCreate","onContentReviewBeforeUpdate","onContentReviewAfterUpdate","onContentReviewBeforeDelete","onContentReviewAfterDelete","get","id","getContentReview","list","where","reviewStatus","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","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 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 return {\n /**\n * Lifecycle events\n */\n onContentReviewBeforeCreate,\n onContentReviewAfterCreate,\n onContentReviewBeforeUpdate,\n onContentReviewAfterUpdate,\n onContentReviewBeforeDelete,\n onContentReviewAfterDelete,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n if (params.where?.reviewStatus === \"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: 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,\n ...INITIAL_CONTENT_REVIEW_C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AAgC;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;UAGZlE,IAAI,EAAE;YACFT;UADE;QAHM,CAAV,CAAN;MAOH;MACD;AACZ;AACA;;;MACY,MAAMb,SAAS,CAACgC,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;;EAzaE,CAAP;AA2aH"}
|
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,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAoBA;AACA;AAOA;AACA;AAMA;AAWO,SAASA,0BAA0B,CACtCC,MAAwC,EACpB;EACpB,MAAM;IACFC,WAAW;IACXC,iBAAiB;IACjBC,WAAW;IACXC,gBAAgB;IAChBC,mBAAmB;IACnBC,qBAAqB;IACrBC,SAAS;IACTC,aAAa;IACbC,SAAS;IACTC,SAAS;IACTC;EACJ,CAAC,GAAGX,MAAM;;EAEV;EACA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAW,EAC3C,iCAAiC,CACpC;EACD,MAAMC,0BAA0B,GAAG,IAAAD,mBAAW,EAC1C,gCAAgC,CACnC;EACD;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAW,EAC3C,iCAAiC,CACpC;EACD,MAAMG,0BAA0B,GAAG,IAAAH,mBAAW,EAC1C,gCAAgC,CACnC;EACD;EACA,MAAMI,2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4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createReviewerMethods = createReviewerMethods;
|
7
|
-
|
8
7
|
var _pubsub = require("@webiny/pubsub");
|
9
|
-
|
10
8
|
function createReviewerMethods({
|
11
9
|
storageOperations
|
12
10
|
}) {
|
13
11
|
// create
|
14
12
|
const onReviewerBeforeCreate = (0, _pubsub.createTopic)("apw.onReviewerBeforeCreate");
|
15
|
-
const onReviewerAfterCreate = (0, _pubsub.createTopic)("apw.onReviewerAfterCreate");
|
16
|
-
|
13
|
+
const onReviewerAfterCreate = (0, _pubsub.createTopic)("apw.onReviewerAfterCreate");
|
14
|
+
// update
|
17
15
|
const onReviewerBeforeUpdate = (0, _pubsub.createTopic)("apw.onReviewerBeforeUpdate");
|
18
|
-
const onReviewerAfterUpdate = (0, _pubsub.createTopic)("apw.onReviewerAfterUpdate");
|
19
|
-
|
16
|
+
const onReviewerAfterUpdate = (0, _pubsub.createTopic)("apw.onReviewerAfterUpdate");
|
17
|
+
// delete
|
20
18
|
const onReviewerBeforeDelete = (0, _pubsub.createTopic)("apw.onReviewerBeforeDelete");
|
21
19
|
const onReviewerAfterDelete = (0, _pubsub.createTopic)("apw.onReviewerAfterDelete");
|
22
20
|
return {
|
@@ -29,17 +27,14 @@ function createReviewerMethods({
|
|
29
27
|
onReviewerAfterUpdate,
|
30
28
|
onReviewerBeforeDelete,
|
31
29
|
onReviewerAfterDelete,
|
32
|
-
|
33
30
|
async get(id) {
|
34
31
|
return storageOperations.getReviewer({
|
35
32
|
id
|
36
33
|
});
|
37
34
|
},
|
38
|
-
|
39
35
|
async list(params) {
|
40
36
|
return storageOperations.listReviewers(params);
|
41
37
|
},
|
42
|
-
|
43
38
|
async create(data) {
|
44
39
|
await onReviewerBeforeCreate.publish({
|
45
40
|
input: data
|
@@ -52,7 +47,6 @@ function createReviewerMethods({
|
|
52
47
|
});
|
53
48
|
return reviewer;
|
54
49
|
},
|
55
|
-
|
56
50
|
async update(id, data) {
|
57
51
|
const original = await storageOperations.getReviewer({
|
58
52
|
id
|
@@ -78,7 +72,6 @@ function createReviewerMethods({
|
|
78
72
|
});
|
79
73
|
return reviewer;
|
80
74
|
},
|
81
|
-
|
82
75
|
async delete(id) {
|
83
76
|
const reviewer = await storageOperations.getReviewer({
|
84
77
|
id
|
@@ -94,6 +87,5 @@ function createReviewerMethods({
|
|
94
87
|
});
|
95
88
|
return true;
|
96
89
|
}
|
97
|
-
|
98
90
|
};
|
99
91
|
}
|