@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.8feaff8c32
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 +1 -6
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +21 -25
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +21 -26
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +89 -128
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +21 -26
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +37 -28
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +3 -32
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -36
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +6 -16
- package/index.js.map +1 -1
- package/package.json +40 -46
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +4 -16
- 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 +6 -23
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +14 -43
- 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 +6 -20
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +14 -36
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +6 -55
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +3 -48
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +4 -11
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +4 -11
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +10 -29
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +6 -11
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +4 -11
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +4 -19
- 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 +2 -10
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +4 -12
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +15 -25
- 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 +10 -0
- package/plugins/hooks/listContentReviews.js +56 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- 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 +111 -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 +122 -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 +94 -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 +45 -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 +7 -19
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +14 -27
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +27 -18
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +13 -14
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -8
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
- 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 +38 -42
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
- 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 +3 -14
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +2 -36
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +4 -57
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +15 -36
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +45 -39
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +15 -6
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +8 -24
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +8 -87
- 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 +21 -38
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +9 -32
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +0 -1
- package/scheduler/handlers/utils.js +4 -42
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +2 -20
- package/scheduler/types.js +12 -23
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +22 -45
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +25 -50
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +22 -43
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +5 -23
- 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.d.ts +3 -10
- package/storageOperations/models/contentModelPluginFactory.js +5 -17
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +6 -31
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +3 -29
- 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 +3 -6
- 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 +22 -40
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +25 -48
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +104 -88
- package/types.js +124 -42
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +1 -18
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +5 -21
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -1,36 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.createContentReviewMethods = createContentReviewMethods;
|
9
|
-
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
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
|
-
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
18
|
function createContentReviewMethods(params) {
|
35
19
|
const {
|
36
20
|
getIdentity,
|
@@ -45,64 +29,73 @@ function createContentReviewMethods(params) {
|
|
45
29
|
getLocale,
|
46
30
|
plugins
|
47
31
|
} = params;
|
48
|
-
|
49
|
-
|
50
|
-
const
|
51
|
-
const
|
52
|
-
|
53
|
-
const
|
32
|
+
|
33
|
+
// create
|
34
|
+
const onContentReviewBeforeCreate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeCreate");
|
35
|
+
const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate");
|
36
|
+
// update
|
37
|
+
const onContentReviewBeforeUpdate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeUpdate");
|
38
|
+
const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate");
|
39
|
+
// delete
|
40
|
+
const onContentReviewBeforeDelete = (0, _pubsub.createTopic)("apw.onContentReviewBeforeDelete");
|
41
|
+
const onContentReviewAfterDelete = (0, _pubsub.createTopic)("apw.onContentReviewAfterDelete");
|
42
|
+
// list
|
43
|
+
const onContentReviewBeforeList = (0, _pubsub.createTopic)("apw.onContentReviewBeforeList");
|
54
44
|
return {
|
55
45
|
/**
|
56
46
|
* Lifecycle events
|
57
47
|
*/
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
48
|
+
onContentReviewBeforeCreate,
|
49
|
+
onContentReviewAfterCreate,
|
50
|
+
onContentReviewBeforeUpdate,
|
51
|
+
onContentReviewAfterUpdate,
|
52
|
+
onContentReviewBeforeDelete,
|
53
|
+
onContentReviewAfterDelete,
|
54
|
+
onContentReviewBeforeList,
|
65
55
|
async get(id) {
|
66
56
|
return storageOperations.getContentReview({
|
67
57
|
id
|
68
58
|
});
|
69
59
|
},
|
70
|
-
|
71
60
|
async list(params) {
|
72
|
-
|
61
|
+
const where = params.where || {};
|
62
|
+
await onContentReviewBeforeList.publish({
|
63
|
+
where
|
64
|
+
});
|
65
|
+
if (where.reviewStatus === "requiresMyAttention") {
|
73
66
|
return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
|
74
|
-
listParams: params,
|
67
|
+
listParams: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
68
|
+
where
|
69
|
+
}),
|
75
70
|
listContentReviews: storageOperations.listContentReviews,
|
76
71
|
getReviewer,
|
77
72
|
getIdentity
|
78
73
|
});
|
79
74
|
}
|
80
|
-
|
81
|
-
|
75
|
+
return storageOperations.listContentReviews((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
76
|
+
where
|
77
|
+
}));
|
82
78
|
},
|
83
|
-
|
84
79
|
async create(data) {
|
85
|
-
const input =
|
86
|
-
|
80
|
+
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
81
|
+
reviewStatus: _types.ApwContentReviewStatus.UNDER_REVIEW
|
87
82
|
});
|
88
|
-
|
89
|
-
await onBeforeContentReviewCreate.publish({
|
83
|
+
await onContentReviewBeforeCreate.publish({
|
90
84
|
input
|
91
85
|
});
|
92
86
|
const contentReview = await storageOperations.createContentReview({
|
93
87
|
data: input
|
94
88
|
});
|
95
|
-
await
|
89
|
+
await onContentReviewAfterCreate.publish({
|
96
90
|
contentReview
|
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
|
104
97
|
});
|
105
|
-
await
|
98
|
+
await onContentReviewBeforeUpdate.publish({
|
106
99
|
original,
|
107
100
|
input: {
|
108
101
|
id,
|
@@ -113,7 +106,7 @@ function createContentReviewMethods(params) {
|
|
113
106
|
id,
|
114
107
|
data
|
115
108
|
});
|
116
|
-
await
|
109
|
+
await onContentReviewAfterUpdate.publish({
|
117
110
|
original,
|
118
111
|
input: {
|
119
112
|
id,
|
@@ -123,28 +116,26 @@ 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
|
130
122
|
});
|
131
|
-
await
|
123
|
+
await onContentReviewBeforeDelete.publish({
|
132
124
|
contentReview
|
133
125
|
});
|
134
126
|
await storageOperations.deleteContentReview({
|
135
127
|
id
|
136
128
|
});
|
137
|
-
await
|
129
|
+
await onContentReviewAfterDelete.publish({
|
138
130
|
contentReview
|
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 {
|
146
137
|
steps,
|
147
|
-
|
138
|
+
reviewStatus
|
148
139
|
} = entry;
|
149
140
|
const stepIndex = steps.findIndex(step => step.id === stepId);
|
150
141
|
const currentStep = steps[stepIndex];
|
@@ -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,16 +195,14 @@ 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;
|
222
|
-
return
|
205
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
223
206
|
status: _types.ApwContentReviewStepStatus.DONE,
|
224
207
|
signOffProvidedOn: new Date().toISOString(),
|
225
208
|
signOffProvidedBy: identity
|
@@ -228,49 +211,45 @@ 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);
|
236
|
-
return
|
217
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
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
|
-
let newStatus = status;
|
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
|
+
var _contentReview$conten;
|
247
|
+
const contentReview = await this.get(id);
|
270
248
|
const {
|
271
249
|
steps,
|
272
|
-
|
273
|
-
|
250
|
+
reviewStatus,
|
251
|
+
content
|
252
|
+
} = contentReview;
|
274
253
|
const stepIndex = steps.findIndex(step => step.id === stepId);
|
275
254
|
const currentStep = steps[stepIndex];
|
276
255
|
const identity = getIdentity();
|
@@ -279,13 +258,13 @@ function createContentReviewMethods(params) {
|
|
279
258
|
identity,
|
280
259
|
step: currentStep
|
281
260
|
});
|
261
|
+
|
282
262
|
/**
|
283
263
|
* Check whether the retract sign-off is requested by a reviewer.
|
284
264
|
*/
|
285
|
-
|
286
265
|
if (!hasPermission) {
|
287
266
|
throw new _errors.NotAuthorizedError({
|
288
|
-
entry,
|
267
|
+
entry: contentReview,
|
289
268
|
input: {
|
290
269
|
id,
|
291
270
|
step: stepId
|
@@ -295,27 +274,24 @@ function createContentReviewMethods(params) {
|
|
295
274
|
/**
|
296
275
|
* Don't allow, if step in not "done" i.e. no sign-off was provided for it.
|
297
276
|
*/
|
298
|
-
|
299
|
-
|
300
277
|
if (currentStep.status !== _types.ApwContentReviewStepStatus.DONE) {
|
301
278
|
throw new _errors.NoSignOffProvidedError({
|
302
|
-
entry,
|
279
|
+
entry: contentReview,
|
303
280
|
input: {
|
304
281
|
id,
|
305
282
|
step: stepId
|
306
283
|
}
|
307
284
|
});
|
308
285
|
}
|
309
|
-
|
310
286
|
let previousStepStatus;
|
287
|
+
|
311
288
|
/*
|
312
289
|
* Retract sign-off for give step.
|
313
290
|
*/
|
314
|
-
|
315
291
|
const updatedSteps = steps.map((step, index) => {
|
316
292
|
if (index === stepIndex) {
|
317
293
|
previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
|
318
|
-
return
|
294
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
319
295
|
status: previousStepStatus,
|
320
296
|
signOffProvidedOn: null,
|
321
297
|
signOffProvidedBy: null
|
@@ -324,39 +300,46 @@ function createContentReviewMethods(params) {
|
|
324
300
|
/**
|
325
301
|
* Set next step status as "inactive".
|
326
302
|
*/
|
327
|
-
|
328
|
-
|
329
303
|
if (index > stepIndex) {
|
330
304
|
const previousStep = steps[index - 1];
|
331
305
|
previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
|
332
|
-
return
|
306
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
|
333
307
|
status: previousStepStatus
|
334
308
|
});
|
335
309
|
}
|
336
|
-
|
337
310
|
return step;
|
338
311
|
});
|
312
|
+
|
339
313
|
/**
|
340
314
|
* Check for pending steps
|
341
315
|
*/
|
342
|
-
|
343
|
-
let newStatus = status;
|
316
|
+
let newStatus = reviewStatus;
|
344
317
|
const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => step.signOffProvidedOn === null);
|
345
318
|
/**
|
346
319
|
* If there are required steps that are pending, set the status to "UNDER_REVIEW".
|
347
320
|
*/
|
348
|
-
|
349
321
|
if (pendingRequiredSteps.length !== 0) {
|
350
322
|
newStatus = _types.ApwContentReviewStatus.UNDER_REVIEW;
|
351
323
|
}
|
352
324
|
|
325
|
+
/**
|
326
|
+
* We need to delete the scheduled action if one was created.
|
327
|
+
*/
|
328
|
+
const scheduledActionId = (_contentReview$conten = contentReview.content) === null || _contentReview$conten === void 0 ? void 0 : _contentReview$conten.scheduledActionId;
|
329
|
+
if (!!scheduledActionId) {
|
330
|
+
await scheduler.delete(scheduledActionId);
|
331
|
+
}
|
353
332
|
await this.update(id, {
|
333
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
334
|
+
scheduledOn: null,
|
335
|
+
scheduledBy: null,
|
336
|
+
scheduledActionId: null
|
337
|
+
}),
|
354
338
|
steps: updatedSteps,
|
355
|
-
|
339
|
+
reviewStatus: newStatus
|
356
340
|
});
|
357
341
|
return true;
|
358
342
|
},
|
359
|
-
|
360
343
|
async isReviewRequired(data) {
|
361
344
|
const contentGetter = getContentGetter(data.type);
|
362
345
|
const content = await contentGetter(data.id, data.settings);
|
@@ -366,55 +349,47 @@ function createContentReviewMethods(params) {
|
|
366
349
|
plugins,
|
367
350
|
type: data.type
|
368
351
|
});
|
369
|
-
|
370
352
|
if (contentApwSettingsPlugin) {
|
371
353
|
contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);
|
372
354
|
const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
|
373
|
-
|
374
355
|
if (workflowId) {
|
375
356
|
isReviewRequired = true;
|
376
357
|
}
|
377
358
|
}
|
378
|
-
|
379
359
|
return {
|
380
360
|
isReviewRequired,
|
381
361
|
contentReviewId
|
382
362
|
};
|
383
363
|
},
|
384
|
-
|
385
364
|
async publishContent(id, datetime) {
|
386
365
|
var _content$settings;
|
387
|
-
|
388
366
|
const {
|
389
367
|
content,
|
390
|
-
|
368
|
+
reviewStatus
|
391
369
|
} = await this.get(id);
|
392
370
|
const identity = getIdentity();
|
393
|
-
|
394
|
-
if (status !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
371
|
+
if (reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
395
372
|
throw new _error.default({
|
396
373
|
message: `Cannot publish content because it is not yet ready to be published.`,
|
397
374
|
code: "NOT_READY_TO_BE_PUBLISHED",
|
398
375
|
data: {
|
399
376
|
id,
|
400
|
-
status,
|
377
|
+
status: reviewStatus,
|
401
378
|
content
|
402
379
|
}
|
403
380
|
});
|
404
381
|
}
|
405
|
-
|
406
382
|
(0, _utils2.checkValidDateTime)(datetime);
|
383
|
+
|
407
384
|
/**
|
408
385
|
* If datetime is present it means we're scheduling this action.
|
409
386
|
* And if not, we are publishing immediately.
|
410
387
|
*/
|
411
|
-
|
412
388
|
if (!datetime) {
|
413
389
|
const contentPublisher = getContentPublisher(content.type);
|
414
390
|
await contentPublisher(content.id, content.settings);
|
415
391
|
return true;
|
416
392
|
}
|
417
|
-
|
418
393
|
const data = {
|
419
394
|
action: _types2.ApwScheduleActionTypes.PUBLISH,
|
420
395
|
type: content.type,
|
@@ -426,9 +401,8 @@ function createContentReviewMethods(params) {
|
|
426
401
|
/**
|
427
402
|
* Update scheduled related meta data.
|
428
403
|
*/
|
429
|
-
|
430
404
|
await this.update(id, {
|
431
|
-
content:
|
405
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
432
406
|
scheduledOn: datetime,
|
433
407
|
scheduledBy: identity.id,
|
434
408
|
scheduledActionId
|
@@ -436,40 +410,35 @@ function createContentReviewMethods(params) {
|
|
436
410
|
});
|
437
411
|
return true;
|
438
412
|
},
|
439
|
-
|
440
413
|
async unpublishContent(id, datetime) {
|
441
414
|
var _content$settings2;
|
442
|
-
|
443
415
|
const {
|
444
416
|
content,
|
445
|
-
|
417
|
+
reviewStatus
|
446
418
|
} = await this.get(id);
|
447
419
|
const identity = getIdentity();
|
448
|
-
|
449
|
-
if (status !== _types.ApwContentReviewStatus.PUBLISHED) {
|
420
|
+
if (reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
|
450
421
|
throw new _error.default({
|
451
422
|
message: `Cannot unpublish content because it is not yet published.`,
|
452
423
|
code: "NOT_YET_PUBLISHED",
|
453
424
|
data: {
|
454
425
|
id,
|
455
|
-
status,
|
426
|
+
status: reviewStatus,
|
456
427
|
content
|
457
428
|
}
|
458
429
|
});
|
459
430
|
}
|
460
|
-
|
461
431
|
(0, _utils2.checkValidDateTime)(datetime);
|
432
|
+
|
462
433
|
/**
|
463
434
|
* If datetime is present it means we're scheduling this action.
|
464
435
|
* If not, we are unpublishing immediately.
|
465
436
|
*/
|
466
|
-
|
467
437
|
if (!datetime) {
|
468
438
|
const contentUnPublisher = getContentUnPublisher(content.type);
|
469
439
|
await contentUnPublisher(content.id, content.settings);
|
470
440
|
return true;
|
471
441
|
}
|
472
|
-
|
473
442
|
const scheduledActionId = await this.scheduleAction({
|
474
443
|
action: _types2.ApwScheduleActionTypes.UNPUBLISH,
|
475
444
|
type: content.type,
|
@@ -480,9 +449,8 @@ function createContentReviewMethods(params) {
|
|
480
449
|
/**
|
481
450
|
* Update scheduled related meta data.
|
482
451
|
*/
|
483
|
-
|
484
452
|
await this.update(id, {
|
485
|
-
content:
|
453
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
|
486
454
|
scheduledOn: datetime,
|
487
455
|
scheduledBy: identity.id,
|
488
456
|
scheduledActionId
|
@@ -490,7 +458,6 @@ function createContentReviewMethods(params) {
|
|
490
458
|
});
|
491
459
|
return true;
|
492
460
|
},
|
493
|
-
|
494
461
|
async scheduleAction(data) {
|
495
462
|
// Save input in DB
|
496
463
|
const scheduledAction = await scheduler.create(data);
|
@@ -498,12 +465,10 @@ function createContentReviewMethods(params) {
|
|
498
465
|
* This function contains logic of lambda invocation.
|
499
466
|
* Current we're not mocking it, therefore, we're just returning true.
|
500
467
|
*/
|
501
|
-
|
502
468
|
if (process.env.NODE_ENV === "test") {
|
503
469
|
return scheduledAction.id;
|
504
|
-
}
|
505
|
-
|
506
|
-
|
470
|
+
}
|
471
|
+
// Invoke handler
|
507
472
|
await handlerClient.invoke({
|
508
473
|
name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),
|
509
474
|
payload: {
|
@@ -515,14 +480,13 @@ function createContentReviewMethods(params) {
|
|
515
480
|
});
|
516
481
|
return scheduledAction.id;
|
517
482
|
},
|
518
|
-
|
519
483
|
async deleteScheduledAction(id) {
|
520
484
|
const contentReview = await this.get(id);
|
521
485
|
const scheduledActionId = (0, _get.default)(contentReview, "content.scheduledActionId");
|
486
|
+
|
522
487
|
/**
|
523
488
|
* Check if there is any action scheduled for this "content review".
|
524
489
|
*/
|
525
|
-
|
526
490
|
if (!scheduledActionId) {
|
527
491
|
throw new _error.default({
|
528
492
|
message: `There is no action scheduled for content review.`,
|
@@ -535,18 +499,15 @@ function createContentReviewMethods(params) {
|
|
535
499
|
/**
|
536
500
|
* Delete scheduled action.
|
537
501
|
*/
|
538
|
-
|
539
|
-
|
540
502
|
await scheduler.delete(scheduledActionId);
|
503
|
+
|
541
504
|
/**
|
542
505
|
* Reset scheduled related meta data.
|
543
506
|
*/
|
544
|
-
|
545
507
|
await this.update(id, {
|
546
|
-
content:
|
508
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META)
|
547
509
|
});
|
548
510
|
return true;
|
549
511
|
}
|
550
|
-
|
551
512
|
};
|
552
513
|
}
|