@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.97a151f74d
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 +40 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +40 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +40 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +40 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +1 -1
- package/crud/createChangeRequestMethods.js +21 -18
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +21 -18
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +60 -50
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +21 -18
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +42 -20
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +3 -7
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -8
- package/crud/utils.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +8 -4
- package/index.js.map +1 -1
- package/package.json +38 -37
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -1
- package/plugins/cms/apwEntryPlugins.js +4 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +9 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -4
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +5 -5
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +35 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +35 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +35 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +60 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +3 -3
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +10 -14
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +4 -8
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -1
- package/plugins/graphql/comment.gql.js +1 -1
- package/plugins/graphql/contentReview.gql.js +4 -4
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -1
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -1
- package/plugins/graphql.js +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +28 -8
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +6 -0
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +5 -8
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +20 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +10 -0
- package/plugins/hooks/listContentReviews.js +68 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +22 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +31 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +29 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +51 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +7 -11
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +14 -18
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +30 -5
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +14 -4
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -2
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -1
- package/plugins/pageBuilder/index.js +9 -1
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +41 -29
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +18 -6
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +3 -3
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -14
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -1
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +4 -14
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +17 -14
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +8 -9
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +5 -9
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +1 -1
- package/storageOperations/changeRequestStorageOperations.js +5 -9
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +4 -8
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +5 -9
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +5 -9
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +3 -7
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +6 -5
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +1 -1
- package/storageOperations/models/reviewer.model.js +18 -2
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +3 -2
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +18 -14
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +8 -12
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +99 -84
- package/types.js.map +1 -1
- package/utils/errors.js +1 -1
- package/utils/fieldResolver.js +3 -9
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
@@ -7,25 +7,44 @@ exports.createWorkflowMethods = createWorkflowMethods;
|
|
7
7
|
|
8
8
|
var _pubsub = require("@webiny/pubsub");
|
9
9
|
|
10
|
+
var _apiSecurity = require("@webiny/api-security");
|
11
|
+
|
10
12
|
function createWorkflowMethods({
|
11
|
-
storageOperations
|
13
|
+
storageOperations,
|
14
|
+
getPermission
|
12
15
|
}) {
|
13
|
-
|
14
|
-
const
|
15
|
-
const
|
16
|
-
|
17
|
-
const
|
18
|
-
const
|
16
|
+
// create
|
17
|
+
const onWorkflowBeforeCreate = (0, _pubsub.createTopic)("apw.onWorkflowBeforeCreate");
|
18
|
+
const onWorkflowAfterCreate = (0, _pubsub.createTopic)("apw.onWorkflowAfterCreate"); // update
|
19
|
+
|
20
|
+
const onWorkflowBeforeUpdate = (0, _pubsub.createTopic)("apw.onWorkflowBeforeUpdate");
|
21
|
+
const onWorkflowAfterUpdate = (0, _pubsub.createTopic)("apw.onWorkflowAfterUpdate"); // delete
|
22
|
+
|
23
|
+
const onWorkflowBeforeDelete = (0, _pubsub.createTopic)("apw.onWorkflowBeforeDelete");
|
24
|
+
const onWorkflowAfterDelete = (0, _pubsub.createTopic)("apw.onWorkflowAfterDelete");
|
25
|
+
|
26
|
+
const validateAccess = async () => {
|
27
|
+
const permission = await getPermission("apw.publishingWorkflows");
|
28
|
+
|
29
|
+
if (!!permission) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
throw new _apiSecurity.NotAuthorizedError({
|
34
|
+
message: "Not authorized to access publishing workflows."
|
35
|
+
});
|
36
|
+
};
|
37
|
+
|
19
38
|
return {
|
20
39
|
/**
|
21
40
|
* Lifecycle events
|
22
41
|
*/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
42
|
+
onWorkflowBeforeCreate,
|
43
|
+
onWorkflowAfterCreate,
|
44
|
+
onWorkflowBeforeUpdate,
|
45
|
+
onWorkflowAfterUpdate,
|
46
|
+
onWorkflowBeforeDelete,
|
47
|
+
onWorkflowAfterDelete,
|
29
48
|
|
30
49
|
async get(id) {
|
31
50
|
return storageOperations.getWorkflow({
|
@@ -34,27 +53,29 @@ function createWorkflowMethods({
|
|
34
53
|
},
|
35
54
|
|
36
55
|
async list(params) {
|
37
|
-
return storageOperations.listWorkflows(params);
|
56
|
+
return storageOperations.listWorkflows(params || {});
|
38
57
|
},
|
39
58
|
|
40
59
|
async create(data) {
|
41
|
-
await
|
60
|
+
await validateAccess();
|
61
|
+
await onWorkflowBeforeCreate.publish({
|
42
62
|
input: data
|
43
63
|
});
|
44
64
|
const workflow = await storageOperations.createWorkflow({
|
45
65
|
data
|
46
66
|
});
|
47
|
-
await
|
67
|
+
await onWorkflowAfterCreate.publish({
|
48
68
|
workflow
|
49
69
|
});
|
50
70
|
return workflow;
|
51
71
|
},
|
52
72
|
|
53
73
|
async update(id, data) {
|
74
|
+
await validateAccess();
|
54
75
|
const original = await storageOperations.getWorkflow({
|
55
76
|
id
|
56
77
|
});
|
57
|
-
await
|
78
|
+
await onWorkflowBeforeUpdate.publish({
|
58
79
|
original,
|
59
80
|
input: {
|
60
81
|
id,
|
@@ -65,7 +86,7 @@ function createWorkflowMethods({
|
|
65
86
|
id,
|
66
87
|
data
|
67
88
|
});
|
68
|
-
await
|
89
|
+
await onWorkflowAfterUpdate.publish({
|
69
90
|
original,
|
70
91
|
input: {
|
71
92
|
id,
|
@@ -77,16 +98,17 @@ function createWorkflowMethods({
|
|
77
98
|
},
|
78
99
|
|
79
100
|
async delete(id) {
|
101
|
+
await validateAccess();
|
80
102
|
const workflow = await storageOperations.getWorkflow({
|
81
103
|
id
|
82
104
|
});
|
83
|
-
await
|
105
|
+
await onWorkflowBeforeDelete.publish({
|
84
106
|
workflow
|
85
107
|
});
|
86
108
|
await storageOperations.deleteWorkflow({
|
87
109
|
id
|
88
110
|
});
|
89
|
-
await
|
111
|
+
await onWorkflowAfterDelete.publish({
|
90
112
|
workflow
|
91
113
|
});
|
92
114
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createWorkflowMethods","storageOperations","
|
1
|
+
{"version":3,"names":["createWorkflowMethods","storageOperations","getPermission","onWorkflowBeforeCreate","createTopic","onWorkflowAfterCreate","onWorkflowBeforeUpdate","onWorkflowAfterUpdate","onWorkflowBeforeDelete","onWorkflowAfterDelete","validateAccess","permission","NotAuthorizedError","message","get","id","getWorkflow","list","params","listWorkflows","create","data","publish","input","workflow","createWorkflow","update","original","updateWorkflow","delete","deleteWorkflow"],"sources":["createWorkflowMethods.ts"],"sourcesContent":["import {\n ApwWorkflowCrud,\n CreateApwParams,\n OnWorkflowAfterCreateTopicParams,\n OnWorkflowAfterDeleteTopicParams,\n OnWorkflowAfterUpdateTopicParams,\n OnWorkflowBeforeCreateTopicParams,\n OnWorkflowBeforeDeleteTopicParams,\n OnWorkflowBeforeUpdateTopicParams\n} from \"~/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport function createWorkflowMethods({\n storageOperations,\n getPermission\n}: CreateApwParams): ApwWorkflowCrud {\n // create\n const onWorkflowBeforeCreate = createTopic<OnWorkflowBeforeCreateTopicParams>(\n \"apw.onWorkflowBeforeCreate\"\n );\n const onWorkflowAfterCreate = createTopic<OnWorkflowAfterCreateTopicParams>(\n \"apw.onWorkflowAfterCreate\"\n );\n // update\n const onWorkflowBeforeUpdate = createTopic<OnWorkflowBeforeUpdateTopicParams>(\n \"apw.onWorkflowBeforeUpdate\"\n );\n const onWorkflowAfterUpdate = createTopic<OnWorkflowAfterUpdateTopicParams>(\n \"apw.onWorkflowAfterUpdate\"\n );\n // delete\n const onWorkflowBeforeDelete = createTopic<OnWorkflowBeforeDeleteTopicParams>(\n \"apw.onWorkflowBeforeDelete\"\n );\n const onWorkflowAfterDelete = createTopic<OnWorkflowAfterDeleteTopicParams>(\n \"apw.onWorkflowAfterDelete\"\n );\n\n const validateAccess = async (): Promise<void> => {\n const permission = await getPermission(\"apw.publishingWorkflows\");\n if (!!permission) {\n return;\n }\n throw new NotAuthorizedError({\n message: \"Not authorized to access publishing workflows.\"\n });\n };\n\n return {\n /**\n * Lifecycle events\n */\n onWorkflowBeforeCreate,\n onWorkflowAfterCreate,\n onWorkflowBeforeUpdate,\n onWorkflowAfterUpdate,\n onWorkflowBeforeDelete,\n onWorkflowAfterDelete,\n async get(id) {\n return storageOperations.getWorkflow({ id });\n },\n async list(params) {\n return storageOperations.listWorkflows(params || {});\n },\n async create(data) {\n await validateAccess();\n await onWorkflowBeforeCreate.publish({ input: data });\n\n const workflow = await storageOperations.createWorkflow({ data });\n\n await onWorkflowAfterCreate.publish({ workflow });\n\n return workflow;\n },\n async update(id, data) {\n await validateAccess();\n const original = await storageOperations.getWorkflow({ id });\n\n await onWorkflowBeforeUpdate.publish({ original, input: { id, data } });\n\n const workflow = await storageOperations.updateWorkflow({ id, data });\n\n await onWorkflowAfterUpdate.publish({ original, input: { id, data }, workflow });\n\n return workflow;\n },\n async delete(id: string) {\n await validateAccess();\n const workflow = await storageOperations.getWorkflow({ id });\n\n await onWorkflowBeforeDelete.publish({ workflow });\n\n await storageOperations.deleteWorkflow({ id });\n\n await onWorkflowAfterDelete.publish({ workflow });\n\n return true;\n }\n };\n}\n"],"mappings":"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"}
|
package/crud/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports.createApw = void 0;
|
9
9
|
|
10
|
-
var
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
11
|
|
12
12
|
var _createWorkflowMethods = require("./createWorkflowMethods");
|
13
13
|
|
@@ -19,10 +19,6 @@ var _createChangeRequestMethods = require("./createChangeRequestMethods");
|
|
19
19
|
|
20
20
|
var _createContentReviewMethods = require("./createContentReviewMethods");
|
21
21
|
|
22
|
-
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; }
|
23
|
-
|
24
|
-
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; }
|
25
|
-
|
26
22
|
const createApw = params => {
|
27
23
|
const contentGetters = new Map();
|
28
24
|
const contentPublisher = new Map();
|
@@ -83,7 +79,7 @@ const createApw = params => {
|
|
83
79
|
reviewer: reviewerMethods,
|
84
80
|
changeRequest: changeRequestMethods,
|
85
81
|
comment: (0, _createCommentMethods.createCommentMethods)(params),
|
86
|
-
contentReview: (0, _createContentReviewMethods.createContentReviewMethods)(
|
82
|
+
contentReview: (0, _createContentReviewMethods.createContentReviewMethods)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
87
83
|
getReviewer: reviewerMethods.get.bind(reviewerMethods),
|
88
84
|
getContentGetter,
|
89
85
|
getContentPublisher,
|
package/crud/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createApw","params","contentGetters","Map","contentPublisher","contentUnPublisher","workflowMethods","createWorkflowMethods","reviewerMethods","createReviewerMethods","changeRequestMethods","createChangeRequestMethods","getContentGetter","type","getter","get","Error","getContentUnPublisher","getContentPublisher","addContentPublisher","func","set","addContentGetter","addContentUnPublisher","workflow","reviewer","changeRequest","comment","createCommentMethods","contentReview","createContentReviewMethods","getReviewer","bind","scheduleAction","scheduler"],"sources":["index.ts"],"sourcesContent":["import { createWorkflowMethods } from \"./createWorkflowMethods\";\nimport { createReviewerMethods } from \"./createReviewerMethods\";\nimport { createCommentMethods } from \"./createCommentMethods\";\nimport { createChangeRequestMethods } from \"./createChangeRequestMethods\";\nimport { createContentReviewMethods } from \"./createContentReviewMethods\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentTypes,\n ContentGetter,\n ContentPublisher,\n ContentUnPublisher,\n CreateApwParams\n} from \"~/types\";\n\nexport const createApw = (params: CreateApwParams): AdvancedPublishingWorkflow => {\n const contentGetters = new Map<ApwContentTypes, ContentGetter>();\n const contentPublisher = new Map<ApwContentTypes, ContentPublisher>();\n const contentUnPublisher = new Map<ApwContentTypes, ContentUnPublisher>();\n\n const workflowMethods = createWorkflowMethods(params);\n const reviewerMethods = createReviewerMethods(params);\n const changeRequestMethods = createChangeRequestMethods(params);\n\n function getContentGetter(type: ApwContentTypes) {\n const getter = contentGetters.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentGetter\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentUnPublisher(type: ApwContentTypes) {\n const getter = contentUnPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"Content UnPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentPublisher(type: ApwContentTypes) {\n const getter = contentPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n return {\n addContentPublisher(type, func) {\n contentPublisher.set(type, func);\n },\n getContentPublisher,\n addContentGetter(type, func) {\n contentGetters.set(type, func);\n },\n getContentGetter,\n addContentUnPublisher(type, func) {\n contentUnPublisher.set(type, func);\n },\n getContentUnPublisher,\n workflow: workflowMethods,\n reviewer: reviewerMethods,\n changeRequest: changeRequestMethods,\n comment: createCommentMethods(params),\n contentReview: createContentReviewMethods({\n ...params,\n getReviewer: reviewerMethods.get.bind(reviewerMethods),\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher\n }),\n /**\n * Add scheduler to context so that we can access it later. For example, during testing.\n */\n scheduleAction: params.scheduler\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA
|
1
|
+
{"version":3,"names":["createApw","params","contentGetters","Map","contentPublisher","contentUnPublisher","workflowMethods","createWorkflowMethods","reviewerMethods","createReviewerMethods","changeRequestMethods","createChangeRequestMethods","getContentGetter","type","getter","get","Error","getContentUnPublisher","getContentPublisher","addContentPublisher","func","set","addContentGetter","addContentUnPublisher","workflow","reviewer","changeRequest","comment","createCommentMethods","contentReview","createContentReviewMethods","getReviewer","bind","scheduleAction","scheduler"],"sources":["index.ts"],"sourcesContent":["import { createWorkflowMethods } from \"./createWorkflowMethods\";\nimport { createReviewerMethods } from \"./createReviewerMethods\";\nimport { createCommentMethods } from \"./createCommentMethods\";\nimport { createChangeRequestMethods } from \"./createChangeRequestMethods\";\nimport { createContentReviewMethods } from \"./createContentReviewMethods\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentTypes,\n ContentGetter,\n ContentPublisher,\n ContentUnPublisher,\n CreateApwParams\n} from \"~/types\";\n\nexport const createApw = (params: CreateApwParams): AdvancedPublishingWorkflow => {\n const contentGetters = new Map<ApwContentTypes, ContentGetter>();\n const contentPublisher = new Map<ApwContentTypes, ContentPublisher>();\n const contentUnPublisher = new Map<ApwContentTypes, ContentUnPublisher>();\n\n const workflowMethods = createWorkflowMethods(params);\n const reviewerMethods = createReviewerMethods(params);\n const changeRequestMethods = createChangeRequestMethods(params);\n\n function getContentGetter(type: ApwContentTypes) {\n const getter = contentGetters.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentGetter\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentUnPublisher(type: ApwContentTypes) {\n const getter = contentUnPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"Content UnPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n function getContentPublisher(type: ApwContentTypes) {\n const getter = contentPublisher.get(type);\n if (!getter) {\n throw new Error(\n `No \"ContentPublisher\" loader found for type: \"${type}\". You must define a loader.`\n );\n }\n return getter;\n }\n\n return {\n addContentPublisher(type, func) {\n contentPublisher.set(type, func);\n },\n getContentPublisher,\n addContentGetter(type, func) {\n contentGetters.set(type, func);\n },\n getContentGetter,\n addContentUnPublisher(type, func) {\n contentUnPublisher.set(type, func);\n },\n getContentUnPublisher,\n workflow: workflowMethods,\n reviewer: reviewerMethods,\n changeRequest: changeRequestMethods,\n comment: createCommentMethods(params),\n contentReview: createContentReviewMethods({\n ...params,\n getReviewer: reviewerMethods.get.bind(reviewerMethods),\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher\n }),\n /**\n * Add scheduler to context so that we can access it later. For example, during testing.\n */\n scheduleAction: params.scheduler\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAUO,MAAMA,SAAS,GAAIC,MAAD,IAAyD;EAC9E,MAAMC,cAAc,GAAG,IAAIC,GAAJ,EAAvB;EACA,MAAMC,gBAAgB,GAAG,IAAID,GAAJ,EAAzB;EACA,MAAME,kBAAkB,GAAG,IAAIF,GAAJ,EAA3B;EAEA,MAAMG,eAAe,GAAG,IAAAC,4CAAA,EAAsBN,MAAtB,CAAxB;EACA,MAAMO,eAAe,GAAG,IAAAC,4CAAA,EAAsBR,MAAtB,CAAxB;EACA,MAAMS,oBAAoB,GAAG,IAAAC,sDAAA,EAA2BV,MAA3B,CAA7B;;EAEA,SAASW,gBAAT,CAA0BC,IAA1B,EAAiD;IAC7C,MAAMC,MAAM,GAAGZ,cAAc,CAACa,GAAf,CAAmBF,IAAnB,CAAf;;IACA,IAAI,CAACC,MAAL,EAAa;MACT,MAAM,IAAIE,KAAJ,CACD,8CAA6CH,IAAK,8BADjD,CAAN;IAGH;;IACD,OAAOC,MAAP;EACH;;EAED,SAASG,qBAAT,CAA+BJ,IAA/B,EAAsD;IAClD,MAAMC,MAAM,GAAGT,kBAAkB,CAACU,GAAnB,CAAuBF,IAAvB,CAAf;;IACA,IAAI,CAACC,MAAL,EAAa;MACT,MAAM,IAAIE,KAAJ,CACD,oDAAmDH,IAAK,8BADvD,CAAN;IAGH;;IACD,OAAOC,MAAP;EACH;;EAED,SAASI,mBAAT,CAA6BL,IAA7B,EAAoD;IAChD,MAAMC,MAAM,GAAGV,gBAAgB,CAACW,GAAjB,CAAqBF,IAArB,CAAf;;IACA,IAAI,CAACC,MAAL,EAAa;MACT,MAAM,IAAIE,KAAJ,CACD,iDAAgDH,IAAK,8BADpD,CAAN;IAGH;;IACD,OAAOC,MAAP;EACH;;EAED,OAAO;IACHK,mBAAmB,CAACN,IAAD,EAAOO,IAAP,EAAa;MAC5BhB,gBAAgB,CAACiB,GAAjB,CAAqBR,IAArB,EAA2BO,IAA3B;IACH,CAHE;;IAIHF,mBAJG;;IAKHI,gBAAgB,CAACT,IAAD,EAAOO,IAAP,EAAa;MACzBlB,cAAc,CAACmB,GAAf,CAAmBR,IAAnB,EAAyBO,IAAzB;IACH,CAPE;;IAQHR,gBARG;;IASHW,qBAAqB,CAACV,IAAD,EAAOO,IAAP,EAAa;MAC9Bf,kBAAkB,CAACgB,GAAnB,CAAuBR,IAAvB,EAA6BO,IAA7B;IACH,CAXE;;IAYHH,qBAZG;IAaHO,QAAQ,EAAElB,eAbP;IAcHmB,QAAQ,EAAEjB,eAdP;IAeHkB,aAAa,EAAEhB,oBAfZ;IAgBHiB,OAAO,EAAE,IAAAC,0CAAA,EAAqB3B,MAArB,CAhBN;IAiBH4B,aAAa,EAAE,IAAAC,sDAAA,8DACR7B,MADQ;MAEX8B,WAAW,EAAEvB,eAAe,CAACO,GAAhB,CAAoBiB,IAApB,CAAyBxB,eAAzB,CAFF;MAGXI,gBAHW;MAIXM,mBAJW;MAKXD;IALW,GAjBZ;;IAwBH;AACR;AACA;IACQgB,cAAc,EAAEhC,MAAM,CAACiC;EA3BpB,CAAP;AA6BH,CApEM"}
|
package/crud/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -9,7 +9,7 @@ exports.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META = void 0;
|
|
9
9
|
exports.checkValidDateTime = checkValidDateTime;
|
10
10
|
exports.getPendingRequiredSteps = exports.filterContentReviewsByRequiresMyAttention = void 0;
|
11
11
|
|
12
|
-
var
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
13
13
|
|
14
14
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
15
15
|
|
@@ -23,10 +23,6 @@ var _set = _interopRequireDefault(require("lodash/set"));
|
|
23
23
|
|
24
24
|
var _types = require("../types");
|
25
25
|
|
26
|
-
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; }
|
27
|
-
|
28
|
-
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; }
|
29
|
-
|
30
26
|
_dayjs.default.extend(_utc.default);
|
31
27
|
|
32
28
|
function checkValidDateTime(datetime) {
|
@@ -92,7 +88,7 @@ const filterContentReviewsByRequiresMyAttention = async params => {
|
|
92
88
|
* Get all "content reviews" with status "underReview"
|
93
89
|
*/
|
94
90
|
|
95
|
-
const newListParams = (0, _set.default)((0, _cloneDeep.default)(listParams), "where.
|
91
|
+
const newListParams = (0, _set.default)((0, _cloneDeep.default)(listParams), "where.reviewStatus", _types.ApwContentReviewStatus.UNDER_REVIEW);
|
96
92
|
const [contentReviews, meta] = await listContentReviews(newListParams);
|
97
93
|
const identity = getIdentity();
|
98
94
|
const filteredItems = [];
|
@@ -134,7 +130,7 @@ const filterContentReviewsByRequiresMyAttention = async params => {
|
|
134
130
|
}
|
135
131
|
}
|
136
132
|
|
137
|
-
return [filteredItems,
|
133
|
+
return [filteredItems, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, meta), {}, {
|
138
134
|
totalCount: filteredItems.length
|
139
135
|
})];
|
140
136
|
};
|
package/crud/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["dayjs","extend","utc","checkValidDateTime","datetime","isValid","Error","message","code","data","today","isBefore","getPendingRequiredSteps","steps","predicate","filter","step","isRequiredStep","ApwWorkflowStepTypes","MANDATORY_BLOCKING","MANDATORY_NON_BLOCKING","includes","type","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","scheduledOn","scheduledBy","scheduledActionId","filterContentReviewsByRequiresMyAttention","params","listContentReviews","listParams","getIdentity","getReviewer","newListParams","set","cloneDeep","ApwContentReviewStatus","UNDER_REVIEW","contentReviews","meta","identity","filteredItems","i","length","contentReview","activeStep","find","status","ApwContentReviewStepStatus","ACTIVE","requiresMyAttention","j","reviewers","id","reviewer","identityId","push","totalCount"],"sources":["utils.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport set from \"lodash/set\";\nimport {\n ApwContentReview,\n ApwContentReviewListParams,\n ApwContentReviewStatus,\n ApwContentReviewStep,\n ApwContentReviewStepStatus,\n ApwWorkflowStepTypes,\n ListMeta\n} from \"~/types\";\nimport { CreateContentReviewMethodsParams } from \"./createContentReviewMethods\";\n\ndayjs.extend(utc);\n\nexport function checkValidDateTime(datetime: string | undefined): void {\n if (typeof datetime !== \"string\") {\n return;\n }\n\n if (!dayjs(datetime).isValid()) {\n throw new Error({\n message: `Invalid input \"datetime\" should be an ISO string.`,\n code: \"INVALID_DATETIME_FORMAT\",\n data: {\n datetime\n }\n });\n }\n const today = dayjs.utc();\n\n if (dayjs(datetime).isBefore(today)) {\n throw new Error({\n message: `Cannot schedule for a past \"datetime\".`,\n code: \"PAST_DATETIME\",\n data: {\n datetime\n }\n });\n }\n}\n\nexport interface GetPendingRequiredSteps {\n (\n steps: ApwContentReviewStep[],\n predicate: (step: ApwContentReviewStep) => boolean\n ): ApwContentReviewStep[];\n}\n\nexport const getPendingRequiredSteps: GetPendingRequiredSteps = (steps, predicate) => {\n return steps.filter(step => {\n const isRequiredStep = [\n ApwWorkflowStepTypes.MANDATORY_BLOCKING,\n ApwWorkflowStepTypes.MANDATORY_NON_BLOCKING\n ].includes(step.type);\n\n if (!isRequiredStep) {\n return false;\n }\n\n return predicate(step);\n });\n};\n\nexport const INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META = {\n scheduledOn: null,\n scheduledBy: null,\n scheduledActionId: null\n};\n\nexport interface FilterContentReviewsParams\n extends Pick<CreateContentReviewMethodsParams, \"getReviewer\" | \"getIdentity\"> {\n listParams: ApwContentReviewListParams;\n listContentReviews: CreateContentReviewMethodsParams[\"storageOperations\"][\"listContentReviews\"];\n}\n\n/**\n * Filter \"content reviews\" that are \"underReview\" and current user is a reviewer for the active step.\n * That is the user is able to provide sign-off or comment.\n */\nexport const filterContentReviewsByRequiresMyAttention = async (\n params: FilterContentReviewsParams\n): Promise<[ApwContentReview[], ListMeta]> => {\n const { listContentReviews, listParams, getIdentity, getReviewer } = params;\n /**\n * Get all \"content reviews\" with status \"underReview\"\n */\n const newListParams = set(\n cloneDeep(listParams),\n \"where.
|
1
|
+
{"version":3,"names":["dayjs","extend","utc","checkValidDateTime","datetime","isValid","Error","message","code","data","today","isBefore","getPendingRequiredSteps","steps","predicate","filter","step","isRequiredStep","ApwWorkflowStepTypes","MANDATORY_BLOCKING","MANDATORY_NON_BLOCKING","includes","type","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","scheduledOn","scheduledBy","scheduledActionId","filterContentReviewsByRequiresMyAttention","params","listContentReviews","listParams","getIdentity","getReviewer","newListParams","set","cloneDeep","ApwContentReviewStatus","UNDER_REVIEW","contentReviews","meta","identity","filteredItems","i","length","contentReview","activeStep","find","status","ApwContentReviewStepStatus","ACTIVE","requiresMyAttention","j","reviewers","id","reviewer","identityId","push","totalCount"],"sources":["utils.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport set from \"lodash/set\";\nimport {\n ApwContentReview,\n ApwContentReviewListParams,\n ApwContentReviewStatus,\n ApwContentReviewStep,\n ApwContentReviewStepStatus,\n ApwWorkflowStepTypes,\n ListMeta\n} from \"~/types\";\nimport { CreateContentReviewMethodsParams } from \"./createContentReviewMethods\";\n\ndayjs.extend(utc);\n\nexport function checkValidDateTime(datetime: string | undefined): void {\n if (typeof datetime !== \"string\") {\n return;\n }\n\n if (!dayjs(datetime).isValid()) {\n throw new Error({\n message: `Invalid input \"datetime\" should be an ISO string.`,\n code: \"INVALID_DATETIME_FORMAT\",\n data: {\n datetime\n }\n });\n }\n const today = dayjs.utc();\n\n if (dayjs(datetime).isBefore(today)) {\n throw new Error({\n message: `Cannot schedule for a past \"datetime\".`,\n code: \"PAST_DATETIME\",\n data: {\n datetime\n }\n });\n }\n}\n\nexport interface GetPendingRequiredSteps {\n (\n steps: ApwContentReviewStep[],\n predicate: (step: ApwContentReviewStep) => boolean\n ): ApwContentReviewStep[];\n}\n\nexport const getPendingRequiredSteps: GetPendingRequiredSteps = (steps, predicate) => {\n return steps.filter(step => {\n const isRequiredStep = [\n ApwWorkflowStepTypes.MANDATORY_BLOCKING,\n ApwWorkflowStepTypes.MANDATORY_NON_BLOCKING\n ].includes(step.type);\n\n if (!isRequiredStep) {\n return false;\n }\n\n return predicate(step);\n });\n};\n\nexport const INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META = {\n scheduledOn: null,\n scheduledBy: null,\n scheduledActionId: null\n};\n\nexport interface FilterContentReviewsParams\n extends Pick<CreateContentReviewMethodsParams, \"getReviewer\" | \"getIdentity\"> {\n listParams: ApwContentReviewListParams;\n listContentReviews: CreateContentReviewMethodsParams[\"storageOperations\"][\"listContentReviews\"];\n}\n\n/**\n * Filter \"content reviews\" that are \"underReview\" and current user is a reviewer for the active step.\n * That is the user is able to provide sign-off or comment.\n */\nexport const filterContentReviewsByRequiresMyAttention = async (\n params: FilterContentReviewsParams\n): Promise<[ApwContentReview[], ListMeta]> => {\n const { listContentReviews, listParams, getIdentity, getReviewer } = params;\n /**\n * Get all \"content reviews\" with status \"underReview\"\n */\n const newListParams = set(\n cloneDeep(listParams),\n \"where.reviewStatus\",\n ApwContentReviewStatus.UNDER_REVIEW\n );\n const [contentReviews, meta] = await listContentReviews(newListParams);\n\n const identity = getIdentity();\n const filteredItems = [];\n /**\n * Filter items where current user is a reviewer for the active step.\n */\n for (let i = 0; i < contentReviews.length; i++) {\n const contentReview = contentReviews[i];\n\n const activeStep = contentReview.steps.find(\n step => step.status === ApwContentReviewStepStatus.ACTIVE\n );\n\n if (!activeStep) {\n continue;\n }\n\n let requiresMyAttention = false;\n\n for (let j = 0; j < activeStep.reviewers.length; j++) {\n const { id } = activeStep.reviewers[j];\n /**\n * Load reviewer\n */\n const reviewer = await getReviewer(id);\n /**\n * Check if the current logged in user is the reviewer.\n */\n if (reviewer.identityId === identity.id) {\n requiresMyAttention = true;\n break;\n }\n }\n\n if (requiresMyAttention) {\n filteredItems.push(contentReview);\n }\n }\n\n return [\n filteredItems,\n {\n ...meta,\n totalCount: filteredItems.length\n }\n ];\n};\n"],"mappings":"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"}
|
package/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { CreateApwContextParams } from "./scheduler/types";
|
2
|
-
export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => import("@webiny/api").ContextPlugin<import("./types").ApwContext
|
3
|
-
export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => import("@webiny/api").ContextPlugin<import("./types").ApwContext
|
4
|
-
export declare const createApwGraphQL: () => import("@webiny/api").ContextPlugin<import("./types").ApwContext
|
2
|
+
export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => (import("@webiny/api").ContextPlugin<import("./types").ApwContext> | import("@webiny/plugins/types").Plugin<Record<string, any>> | import("@webiny/plugins/types").PluginCollection)[];
|
3
|
+
export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => (import("@webiny/api").ContextPlugin<import("./types").ApwContext> | import("@webiny/plugins/types").Plugin<Record<string, any>> | import("@webiny/plugins/types").PluginCollection | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("@webiny/api-mailer/types").MailerContext>)[];
|
4
|
+
export declare const createApwGraphQL: () => import("@webiny/api").ContextPlugin<import("./types").ApwContext>[];
|
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -11,24 +11,28 @@ var _graphql = _interopRequireDefault(require("./plugins/graphql"));
|
|
11
11
|
|
12
12
|
var _context = require("./plugins/context");
|
13
13
|
|
14
|
+
var _apiMailer = require("@webiny/api-mailer");
|
15
|
+
|
16
|
+
var _apiAdminSettings = require("@webiny/api-admin-settings");
|
17
|
+
|
14
18
|
/**
|
15
19
|
* We have separated context and GraphQL creation so user can initialize only context if required.
|
16
20
|
* GraphQL will not work without context, but context will without GraphQL.
|
17
21
|
*/
|
18
22
|
const createApwHeadlessCmsContext = params => {
|
19
|
-
return (0, _context.createApwHeadlessCmsContext)(params);
|
23
|
+
return [...(0, _apiAdminSettings.createAdminSettingsContext)(), ...(0, _apiMailer.createMailerContext)(), (0, _context.createApwHeadlessCmsContext)(params)];
|
20
24
|
};
|
21
25
|
|
22
26
|
exports.createApwHeadlessCmsContext = createApwHeadlessCmsContext;
|
23
27
|
|
24
28
|
const createApwPageBuilderContext = params => {
|
25
|
-
return (0, _context.createApwPageBuilderContext)(params);
|
29
|
+
return [...(0, _apiAdminSettings.createAdminSettingsContext)(), ...(0, _apiMailer.createMailerContext)(), ...(0, _apiMailer.createMailerGraphQL)(), (0, _context.createApwPageBuilderContext)(params)];
|
26
30
|
};
|
27
31
|
|
28
32
|
exports.createApwPageBuilderContext = createApwPageBuilderContext;
|
29
33
|
|
30
34
|
const createApwGraphQL = () => {
|
31
|
-
return (0, _graphql.default)();
|
35
|
+
return [(0, _graphql.default)()];
|
32
36
|
};
|
33
37
|
|
34
38
|
exports.createApwGraphQL = createApwGraphQL;
|
package/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createApwHeadlessCmsContext","params","createHeadlessCms","createApwPageBuilderContext","createPageBuilder","createApwGraphQL","graphql"],"sources":["index.ts"],"sourcesContent":["/**\n * We have separated context and GraphQL creation so user can initialize only context if required.\n * GraphQL will not work without context, but context will without GraphQL.\n */\nimport graphql from \"~/plugins/graphql\";\nimport {\n createApwHeadlessCmsContext as createHeadlessCms,\n createApwPageBuilderContext as createPageBuilder\n} from \"./plugins/context\";\nimport { CreateApwContextParams } from \"./scheduler/types\";\n\nexport const createApwHeadlessCmsContext = (params: CreateApwContextParams) => {\n return createHeadlessCms(params);\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return createPageBuilder(params);\n};\n\nexport const createApwGraphQL = () => {\n return graphql();\n};\n"],"mappings":";;;;;;;;;AAIA;;AACA;;
|
1
|
+
{"version":3,"names":["createApwHeadlessCmsContext","params","createAdminSettingsContext","createMailerContext","createHeadlessCms","createApwPageBuilderContext","createMailerGraphQL","createPageBuilder","createApwGraphQL","graphql"],"sources":["index.ts"],"sourcesContent":["/**\n * We have separated context and GraphQL creation so user can initialize only context if required.\n * GraphQL will not work without context, but context will without GraphQL.\n */\nimport graphql from \"~/plugins/graphql\";\nimport {\n createApwHeadlessCmsContext as createHeadlessCms,\n createApwPageBuilderContext as createPageBuilder\n} from \"./plugins/context\";\nimport { CreateApwContextParams } from \"./scheduler/types\";\nimport { createMailerContext, createMailerGraphQL } from \"@webiny/api-mailer\";\nimport { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nexport const createApwHeadlessCmsContext = (params: CreateApwContextParams) => {\n return [...createAdminSettingsContext(), ...createMailerContext(), createHeadlessCms(params)];\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return [\n ...createAdminSettingsContext(),\n ...createMailerContext(),\n ...createMailerGraphQL(),\n createPageBuilder(params)\n ];\n};\n\nexport const createApwGraphQL = () => {\n return [graphql()];\n};\n"],"mappings":";;;;;;;;;AAIA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;AACA;AAUO,MAAMA,2BAA2B,GAAIC,MAAD,IAAoC;EAC3E,OAAO,CAAC,GAAG,IAAAC,4CAAA,GAAJ,EAAkC,GAAG,IAAAC,8BAAA,GAArC,EAA4D,IAAAC,oCAAA,EAAkBH,MAAlB,CAA5D,CAAP;AACH,CAFM;;;;AAIA,MAAMI,2BAA2B,GAAIJ,MAAD,IAAoC;EAC3E,OAAO,CACH,GAAG,IAAAC,4CAAA,GADA,EAEH,GAAG,IAAAC,8BAAA,GAFA,EAGH,GAAG,IAAAG,8BAAA,GAHA,EAIH,IAAAC,oCAAA,EAAkBN,MAAlB,CAJG,CAAP;AAMH,CAPM;;;;AASA,MAAMO,gBAAgB,GAAG,MAAM;EAClC,OAAO,CAAC,IAAAC,gBAAA,GAAD,CAAP;AACH,CAFM"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@webiny/api-apw",
|
3
|
-
"version": "0.0.0-unstable.
|
3
|
+
"version": "0.0.0-unstable.97a151f74d",
|
4
4
|
"keywords": [
|
5
5
|
"apw:base"
|
6
6
|
],
|
@@ -14,45 +14,46 @@
|
|
14
14
|
"author": "Webiny Ltd",
|
15
15
|
"license": "MIT",
|
16
16
|
"dependencies": {
|
17
|
-
"@aws-sdk/client-cloudwatch-events": "3.
|
18
|
-
"@babel/runtime": "7.
|
17
|
+
"@aws-sdk/client-cloudwatch-events": "3.186.0",
|
18
|
+
"@babel/runtime": "7.19.0",
|
19
19
|
"@commodo/fields": "1.1.2-beta.20",
|
20
|
-
"@webiny/api": "0.0.0-unstable.
|
21
|
-
"@webiny/api-
|
22
|
-
"@webiny/api-
|
23
|
-
"@webiny/api-i18n
|
24
|
-
"@webiny/api-
|
25
|
-
"@webiny/api-
|
26
|
-
"@webiny/api-
|
27
|
-
"@webiny/api-
|
28
|
-
"@webiny/
|
29
|
-
"@webiny/
|
30
|
-
"@webiny/
|
31
|
-
"@webiny/
|
32
|
-
"@webiny/handler
|
33
|
-
"@webiny/handler-
|
34
|
-
"@webiny/handler-
|
35
|
-
"@webiny/
|
36
|
-
"@webiny/
|
37
|
-
"@webiny/
|
38
|
-
"
|
20
|
+
"@webiny/api": "0.0.0-unstable.97a151f74d",
|
21
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.97a151f74d",
|
22
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.97a151f74d",
|
23
|
+
"@webiny/api-i18n": "0.0.0-unstable.97a151f74d",
|
24
|
+
"@webiny/api-i18n-ddb": "0.0.0-unstable.97a151f74d",
|
25
|
+
"@webiny/api-mailer": "0.0.0-unstable.97a151f74d",
|
26
|
+
"@webiny/api-page-builder": "0.0.0-unstable.97a151f74d",
|
27
|
+
"@webiny/api-security": "0.0.0-unstable.97a151f74d",
|
28
|
+
"@webiny/api-tenancy": "0.0.0-unstable.97a151f74d",
|
29
|
+
"@webiny/api-wcp": "0.0.0-unstable.97a151f74d",
|
30
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.97a151f74d",
|
31
|
+
"@webiny/error": "0.0.0-unstable.97a151f74d",
|
32
|
+
"@webiny/handler": "0.0.0-unstable.97a151f74d",
|
33
|
+
"@webiny/handler-client": "0.0.0-unstable.97a151f74d",
|
34
|
+
"@webiny/handler-db": "0.0.0-unstable.97a151f74d",
|
35
|
+
"@webiny/handler-graphql": "0.0.0-unstable.97a151f74d",
|
36
|
+
"@webiny/handler-logs": "0.0.0-unstable.97a151f74d",
|
37
|
+
"@webiny/plugins": "0.0.0-unstable.97a151f74d",
|
38
|
+
"@webiny/pubsub": "0.0.0-unstable.97a151f74d",
|
39
|
+
"@webiny/utils": "0.0.0-unstable.97a151f74d",
|
40
|
+
"@webiny/validation": "0.0.0-unstable.97a151f74d",
|
41
|
+
"dayjs": "1.11.5",
|
39
42
|
"lodash": "4.17.21",
|
40
|
-
"mdbid": "1.0.0"
|
41
|
-
"nanoid": "3.3.4"
|
43
|
+
"mdbid": "1.0.0"
|
42
44
|
},
|
43
45
|
"devDependencies": {
|
44
|
-
"@babel/cli": "^7.
|
45
|
-
"@babel/core": "^7.
|
46
|
-
"@babel/preset-env": "^7.
|
47
|
-
"@
|
48
|
-
"@webiny/api-
|
49
|
-
"@webiny/api-
|
50
|
-
"@webiny/api-
|
51
|
-
"@webiny/
|
52
|
-
"@webiny/
|
53
|
-
"@webiny/
|
54
|
-
"@webiny/
|
55
|
-
"@webiny/wcp": "^0.0.0-unstable.8c4d9f045a",
|
46
|
+
"@babel/cli": "^7.19.3",
|
47
|
+
"@babel/core": "^7.19.3",
|
48
|
+
"@babel/preset-env": "^7.19.4",
|
49
|
+
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.97a151f74d",
|
50
|
+
"@webiny/api-page-builder-so-ddb": "^0.0.0-unstable.97a151f74d",
|
51
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.97a151f74d",
|
52
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.97a151f74d",
|
53
|
+
"@webiny/cli": "^0.0.0-unstable.97a151f74d",
|
54
|
+
"@webiny/handler-aws": "^0.0.0-unstable.97a151f74d",
|
55
|
+
"@webiny/project-utils": "^0.0.0-unstable.97a151f74d",
|
56
|
+
"@webiny/wcp": "^0.0.0-unstable.97a151f74d",
|
56
57
|
"get-yarn-workspaces": "^1.0.2",
|
57
58
|
"graphql": "^15.7.2",
|
58
59
|
"jest": "^28.1.0",
|
@@ -71,5 +72,5 @@
|
|
71
72
|
"build": "yarn webiny run build",
|
72
73
|
"watch": "yarn webiny run watch"
|
73
74
|
},
|
74
|
-
"gitHead": "
|
75
|
+
"gitHead": "97a151f74d8c5679323989fcc8cc7036be0f150e"
|
75
76
|
}
|
@@ -1,22 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports.apwEntryPlugins = void 0;
|
9
9
|
|
10
|
-
var
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
11
|
|
12
12
|
var _types = require("../../types");
|
13
13
|
|
14
14
|
var _utils = require("./utils");
|
15
15
|
|
16
|
-
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; }
|
17
|
-
|
18
|
-
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; }
|
19
|
-
|
20
16
|
const apwEntryPlugins = params => {
|
21
17
|
const {
|
22
18
|
cms,
|
@@ -30,8 +26,8 @@ const apwEntryPlugins = params => {
|
|
30
26
|
return null;
|
31
27
|
}
|
32
28
|
|
33
|
-
return
|
34
|
-
meta:
|
29
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
|
30
|
+
meta: (0, _objectSpread2.default)({}, item.meta || {}),
|
35
31
|
title: (0, _utils.getEntryTitle)(model, item)
|
36
32
|
});
|
37
33
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["apwEntryPlugins","params","cms","apw","addContentGetter","ApwContentTypes","CMS_ENTRY","id","settings","model","fetchModel","item","getEntryById","meta","title","getEntryTitle","addContentPublisher","publishEntry","addContentUnPublisher","unpublishEntry"],"sources":["apwEntryPlugins.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, getEntryTitle } from \"./utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface ApwEntryPlugins {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const apwEntryPlugins = (params: ApwEntryPlugins) => {\n const { cms, apw } = params;\n\n apw.addContentGetter(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n\n const item = await cms.getEntryById(model, id);\n\n if (!item) {\n return null;\n }\n\n return {\n ...item,\n meta: {\n ...(item.meta || {})\n },\n title: getEntryTitle(model, item)\n };\n });\n\n apw.addContentPublisher(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n await cms.publishEntry(model, id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n await cms.unpublishEntry(model, id);\n return true;\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA
|
1
|
+
{"version":3,"names":["apwEntryPlugins","params","cms","apw","addContentGetter","ApwContentTypes","CMS_ENTRY","id","settings","model","fetchModel","item","getEntryById","meta","title","getEntryTitle","addContentPublisher","publishEntry","addContentUnPublisher","unpublishEntry"],"sources":["apwEntryPlugins.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, getEntryTitle } from \"./utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface ApwEntryPlugins {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const apwEntryPlugins = (params: ApwEntryPlugins) => {\n const { cms, apw } = params;\n\n apw.addContentGetter(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n\n const item = await cms.getEntryById(model, id);\n\n if (!item) {\n return null;\n }\n\n return {\n ...item,\n meta: {\n ...(item.meta || {})\n },\n title: getEntryTitle(model, item)\n };\n });\n\n apw.addContentPublisher(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n await cms.publishEntry(model, id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.CMS_ENTRY, async (id, settings) => {\n const model = await fetchModel(cms, id, settings);\n await cms.unpublishEntry(model, id);\n return true;\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAOO,MAAMA,eAAe,GAAIC,MAAD,IAA6B;EACxD,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;EAEAE,GAAG,CAACC,gBAAJ,CAAqBC,sBAAA,CAAgBC,SAArC,EAAgD,OAAOC,EAAP,EAAWC,QAAX,KAAwB;IACpE,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWR,GAAX,EAAgBK,EAAhB,EAAoBC,QAApB,CAApB;IAEA,MAAMG,IAAI,GAAG,MAAMT,GAAG,CAACU,YAAJ,CAAiBH,KAAjB,EAAwBF,EAAxB,CAAnB;;IAEA,IAAI,CAACI,IAAL,EAAW;MACP,OAAO,IAAP;IACH;;IAED,mEACOA,IADP;MAEIE,IAAI,kCACIF,IAAI,CAACE,IAAL,IAAa,EADjB,CAFR;MAKIC,KAAK,EAAE,IAAAC,oBAAA,EAAcN,KAAd,EAAqBE,IAArB;IALX;EAOH,CAhBD;EAkBAR,GAAG,CAACa,mBAAJ,CAAwBX,sBAAA,CAAgBC,SAAxC,EAAmD,OAAOC,EAAP,EAAWC,QAAX,KAAwB;IACvE,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWR,GAAX,EAAgBK,EAAhB,EAAoBC,QAApB,CAApB;IACA,MAAMN,GAAG,CAACe,YAAJ,CAAiBR,KAAjB,EAAwBF,EAAxB,CAAN;IACA,OAAO,IAAP;EACH,CAJD;EAMAJ,GAAG,CAACe,qBAAJ,CAA0Bb,sBAAA,CAAgBC,SAA1C,EAAqD,OAAOC,EAAP,EAAWC,QAAX,KAAwB;IACzE,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWR,GAAX,EAAgBK,EAAhB,EAAoBC,QAApB,CAApB;IACA,MAAMN,GAAG,CAACiB,cAAJ,CAAmBV,KAAnB,EAA0BF,EAA1B,CAAN;IACA,OAAO,IAAP;EACH,CAJD;AAKH,CAhCM"}
|
package/plugins/cms/index.js
CHANGED
@@ -17,6 +17,14 @@ var _updateContentReviewStatus = require("./updateContentReviewStatus");
|
|
17
17
|
|
18
18
|
var _CmsEntryApwSettingsGetterPlugin = require("./CmsEntryApwSettingsGetterPlugin");
|
19
19
|
|
20
|
+
var _commentNotification = require("./notifications/commentNotification");
|
21
|
+
|
22
|
+
var _contentUrl = require("./notifications/contentUrl");
|
23
|
+
|
24
|
+
var _changeRequestNotification = require("./notifications/changeRequestNotification");
|
25
|
+
|
26
|
+
var _contentReviewNotification = require("./notifications/contentReviewNotification");
|
27
|
+
|
20
28
|
const apwCmsHooks = params => {
|
21
29
|
/**
|
22
30
|
* We do not need to assign anything if no apw or cms in the context.
|
@@ -26,7 +34,7 @@ const apwCmsHooks = params => {
|
|
26
34
|
return;
|
27
35
|
}
|
28
36
|
|
29
|
-
params.plugins.register(new _CmsEntryApwSettingsGetterPlugin.CmsEntryApwSettingsGetterPlugin());
|
37
|
+
params.plugins.register([new _CmsEntryApwSettingsGetterPlugin.CmsEntryApwSettingsGetterPlugin(), (0, _commentNotification.createCommentNotification)(), (0, _changeRequestNotification.createChangeRequestNotification)(), (0, _contentUrl.createContentUrlPlugin)(), (0, _contentReviewNotification.createContentReviewNotification)()]);
|
30
38
|
(0, _apwEntryPlugins.apwEntryPlugins)(params);
|
31
39
|
(0, _linkContentReviewToEntry.linkContentReviewToEntry)(params);
|
32
40
|
(0, _linkWorkflowToEntry.linkWorkflowToEntry)(params);
|
package/plugins/cms/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["apwCmsHooks","params","apw","cms","plugins","register","CmsEntryApwSettingsGetterPlugin","apwEntryPlugins","linkContentReviewToEntry","linkWorkflowToEntry","triggerContentReview","updateContentReviewStatus"],"sources":["index.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { apwEntryPlugins } from \"
|
1
|
+
{"version":3,"names":["apwCmsHooks","params","apw","cms","plugins","register","CmsEntryApwSettingsGetterPlugin","createCommentNotification","createChangeRequestNotification","createContentUrlPlugin","createContentReviewNotification","apwEntryPlugins","linkContentReviewToEntry","linkWorkflowToEntry","triggerContentReview","updateContentReviewStatus"],"sources":["index.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { apwEntryPlugins } from \"./apwEntryPlugins\";\nimport { linkContentReviewToEntry } from \"./linkContentReviewToEntry\";\nimport { linkWorkflowToEntry } from \"./linkWorkflowToEntry\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryApwSettingsGetterPlugin } from \"./CmsEntryApwSettingsGetterPlugin\";\nimport { createCommentNotification } from \"./notifications/commentNotification\";\nimport { createContentUrlPlugin } from \"./notifications/contentUrl\";\nimport { createChangeRequestNotification } from \"./notifications/changeRequestNotification\";\nimport { createContentReviewNotification } from \"./notifications/contentReviewNotification\";\n\ninterface ApwCmsHooksParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n plugins: PluginsContainer;\n security: Security;\n}\nexport const apwCmsHooks = (params: ApwCmsHooksParams) => {\n /**\n * We do not need to assign anything if no apw or cms in the context.\n * This might happen on options request.\n */\n if (!params.apw || !params.cms) {\n return;\n }\n\n params.plugins.register([\n new CmsEntryApwSettingsGetterPlugin(),\n createCommentNotification(),\n createChangeRequestNotification(),\n createContentUrlPlugin(),\n createContentReviewNotification()\n ]);\n\n apwEntryPlugins(params);\n\n linkContentReviewToEntry(params);\n\n linkWorkflowToEntry(params);\n\n triggerContentReview(params);\n\n updateContentReviewStatus(params);\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAQO,MAAMA,WAAW,GAAIC,MAAD,IAA+B;EACtD;AACJ;AACA;AACA;EACI,IAAI,CAACA,MAAM,CAACC,GAAR,IAAe,CAACD,MAAM,CAACE,GAA3B,EAAgC;IAC5B;EACH;;EAEDF,MAAM,CAACG,OAAP,CAAeC,QAAf,CAAwB,CACpB,IAAIC,gEAAJ,EADoB,EAEpB,IAAAC,8CAAA,GAFoB,EAGpB,IAAAC,0DAAA,GAHoB,EAIpB,IAAAC,kCAAA,GAJoB,EAKpB,IAAAC,0DAAA,GALoB,CAAxB;EAQA,IAAAC,gCAAA,EAAgBV,MAAhB;EAEA,IAAAW,kDAAA,EAAyBX,MAAzB;EAEA,IAAAY,wCAAA,EAAoBZ,MAApB;EAEA,IAAAa,0CAAA,EAAqBb,MAArB;EAEA,IAAAc,oDAAA,EAA0Bd,MAA1B;AACH,CA1BM"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -18,7 +18,7 @@ const linkContentReviewToEntry = params => {
|
|
18
18
|
apw,
|
19
19
|
cms
|
20
20
|
} = params;
|
21
|
-
apw.contentReview.
|
21
|
+
apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
|
22
22
|
contentReview
|
23
23
|
}) => {
|
24
24
|
const {
|
@@ -41,7 +41,7 @@ const linkContentReviewToEntry = params => {
|
|
41
41
|
entryId: content.id
|
42
42
|
});
|
43
43
|
});
|
44
|
-
apw.contentReview.
|
44
|
+
apw.contentReview.onContentReviewAfterDelete.subscribe(async ({
|
45
45
|
contentReview
|
46
46
|
}) => {
|
47
47
|
const {
|
@@ -64,7 +64,7 @@ const linkContentReviewToEntry = params => {
|
|
64
64
|
entryId: content.id
|
65
65
|
});
|
66
66
|
});
|
67
|
-
cms.
|
67
|
+
cms.onEntryBeforeDelete.subscribe(async ({
|
68
68
|
entry,
|
69
69
|
model
|
70
70
|
}) => {
|