@webiny/api-apw 5.34.8-beta.1 → 5.35.0-beta.0
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.js +0 -10
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +0 -10
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +0 -10
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +0 -10
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +0 -5
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +4 -11
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +4 -12
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +20 -84
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +4 -12
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +4 -17
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +0 -25
- package/crud/index.js.map +1 -1
- package/crud/utils.js +0 -28
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +1 -15
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +0 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +0 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +0 -17
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +2 -31
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +0 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +0 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +0 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +1 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +0 -14
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +0 -18
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +2 -47
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -47
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +3 -10
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +3 -10
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +6 -25
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -10
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +3 -10
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +3 -18
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +2 -11
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +0 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +2 -18
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +0 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +0 -12
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +0 -4
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -36
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +0 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +3 -38
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +0 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +4 -32
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +0 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +0 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +15 -21
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +0 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +0 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +0 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +0 -8
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +0 -9
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +0 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +1 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +0 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +0 -11
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -4
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -4
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -4
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +1 -7
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +0 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.js +0 -43
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +1 -20
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +9 -40
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -7
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -23
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -28
- 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.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -25
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -2
- package/scheduler/handlers/utils.js +3 -41
- 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 +0 -11
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +20 -39
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +23 -44
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +20 -37
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +0 -14
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +0 -9
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +0 -8
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
- package/storageOperations/models/contentModelPluginFactory.js +3 -11
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +0 -26
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +2 -28
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +0 -8
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +0 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +0 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +23 -45
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +20 -39
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +6 -5
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +0 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +2 -12
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -1,26 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.attachChangeRequestAfterCreate = void 0;
|
9
|
-
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
-
|
12
9
|
var _utils = require("../../utils");
|
13
|
-
|
14
10
|
var _contentUrl = require("./contentUrl");
|
15
|
-
|
16
11
|
var _sendChangeRequestNotification = require("./sendChangeRequestNotification");
|
17
|
-
|
18
12
|
var _reviewers = require("./reviewers");
|
19
|
-
|
20
13
|
var _changeRequestUrl = require("./changeRequestUrl");
|
21
|
-
|
22
14
|
var _appUrl = require("./appUrl");
|
23
|
-
|
24
15
|
const attachChangeRequestAfterCreate = context => {
|
25
16
|
context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
|
26
17
|
changeRequest
|
@@ -30,40 +21,31 @@ const attachChangeRequestAfterCreate = context => {
|
|
30
21
|
id: contentReviewId,
|
31
22
|
stepId
|
32
23
|
} = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
|
33
|
-
|
34
24
|
if (!stepId) {
|
35
25
|
throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
|
36
26
|
step: changeRequest.step
|
37
27
|
});
|
38
28
|
}
|
39
|
-
|
40
29
|
const settings = await (0, _appUrl.getAppUrl)(context);
|
41
|
-
|
42
30
|
if (!settings) {
|
43
31
|
return;
|
44
32
|
}
|
45
33
|
/**
|
46
34
|
* We will check if we can create a comment url before we go digging further into the database.
|
47
35
|
*/
|
48
|
-
|
49
|
-
|
50
36
|
const changeRequestUrl = (0, _changeRequestUrl.createChangeRequestUrl)({
|
51
37
|
baseUrl: settings.appUrl,
|
52
38
|
changeRequestId: changeRequest.id,
|
53
39
|
contentReviewId,
|
54
40
|
stepId
|
55
41
|
});
|
56
|
-
|
57
42
|
if (!changeRequestUrl) {
|
58
43
|
return;
|
59
44
|
}
|
60
45
|
/**
|
61
46
|
* Let's see if content review exists.
|
62
47
|
*/
|
63
|
-
|
64
|
-
|
65
48
|
const contentReview = await context.apw.contentReview.get(contentReviewId);
|
66
|
-
|
67
49
|
if (!contentReview) {
|
68
50
|
throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
|
69
51
|
contentReviewId
|
@@ -72,37 +54,29 @@ const attachChangeRequestAfterCreate = context => {
|
|
72
54
|
/**
|
73
55
|
* We go and check the workflow.
|
74
56
|
*/
|
75
|
-
|
76
|
-
|
77
57
|
const workflow = await context.apw.workflow.get(contentReview.workflowId);
|
78
|
-
|
79
58
|
if (!workflow) {
|
80
59
|
throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
|
81
60
|
workflowId: contentReview.workflowId
|
82
61
|
});
|
83
62
|
}
|
84
|
-
|
85
63
|
const contentUrl = (0, _contentUrl.createContentUrl)({
|
86
64
|
plugins: context.plugins,
|
87
65
|
baseUrl: settings.appUrl,
|
88
66
|
contentReview,
|
89
67
|
workflow
|
90
68
|
});
|
91
|
-
|
92
69
|
if (!contentUrl) {
|
93
70
|
return;
|
94
71
|
}
|
95
|
-
|
96
72
|
const reviewers = await (0, _reviewers.fetchReviewers)({
|
97
73
|
context,
|
98
74
|
workflow,
|
99
75
|
exclude: [changeRequest.createdBy.id]
|
100
76
|
});
|
101
|
-
|
102
77
|
if (reviewers.length === 0) {
|
103
78
|
return;
|
104
79
|
}
|
105
|
-
|
106
80
|
try {
|
107
81
|
await (0, _sendChangeRequestNotification.sendChangeRequestNotification)({
|
108
82
|
context,
|
@@ -129,16 +103,9 @@ const attachChangeRequestAfterCreate = context => {
|
|
129
103
|
});
|
130
104
|
}
|
131
105
|
};
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
await execute();
|
136
|
-
} catch (ex) {
|
137
|
-
throw ex;
|
138
|
-
} finally {
|
139
|
-
context.security.enableAuthorization();
|
140
|
-
}
|
106
|
+
await context.security.withoutAuthorization(async () => {
|
107
|
+
return execute();
|
108
|
+
});
|
141
109
|
});
|
142
110
|
};
|
143
|
-
|
144
111
|
exports.attachChangeRequestAfterCreate = attachChangeRequestAfterCreate;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["attachChangeRequestAfterCreate","context","apw","changeRequest","onChangeRequestAfterCreate","subscribe","execute","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","WebinyError","settings","getAppUrl","changeRequestUrl","createChangeRequestUrl","baseUrl","appUrl","changeRequestId","contentReview","get","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendChangeRequestNotification","ex","error","message","code","data","stack","security","
|
1
|
+
{"version":3,"names":["attachChangeRequestAfterCreate","context","apw","changeRequest","onChangeRequestAfterCreate","subscribe","execute","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","WebinyError","settings","getAppUrl","changeRequestUrl","createChangeRequestUrl","baseUrl","appUrl","changeRequestId","contentReview","get","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendChangeRequestNotification","ex","error","message","code","data","stack","security","withoutAuthorization"],"sources":["changeRequestAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { sendChangeRequestNotification } from \"./sendChangeRequestNotification\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { createChangeRequestUrl } from \"./changeRequestUrl\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/appUrl\";\n\nexport const attachChangeRequestAfterCreate = (context: ApwContext): void => {\n context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({ changeRequest }) => {\n const execute = async () => {\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const changeRequestUrl = createChangeRequestUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!changeRequestUrl) {\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [changeRequest.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendChangeRequestNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n changeRequestUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send change request notifications.`,\n \"CHANGE_REQUEST_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n changeRequestUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,8BAA8B,GAAIC,OAAmB,IAAW;EACzEA,OAAO,CAACC,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,C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AAgB,EAAC;QAChCC,OAAO,EAAEzB,OAAO,CAACyB,OAAO;QACxBT,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBE,aAAa;QACbE;MACJ,CAAC,CAAC;MACF,IAAI,CAACE,UAAU,EAAE;QACb;MACJ;MAEA,MAAMG,SAAS,GAAG,MAAM,IAAAC,yBAAc,EAAC;QACnC3B,OAAO;QACPqB,QAAQ;QACRO,OAAO,EAAE,CAAC1B,aAAa,CAAC2B,SAAS,CAACvB,EAAE;MACxC,CAAC,CAAC;MACF,IAAIoB,SAAS,CAACI,MAAM,KAAK,CAAC,EAAE;QACxB;MACJ;MAEA,IAAI;QACA,MAAM,IAAAC,4DAA6B,EAAC;UAChC/B,OAAO;UACP0B,SAAS;UACTxB,aAAa;UACbiB,aAAa;UACbE,QAAQ;UACRP,gBAAgB;UAChBS;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOS,EAAE,EAAE;QACT,MAAM,IAAIrB,cAAW,CAChB,8CAA6C,EAC9C,uCAAuC,EACvC;UACIW,UAAU,EAAED,QAAQ,CAACf,EAAE;UACvBY,eAAe,EAAEhB,aAAa,CAACI,EAAE;UACjCC,eAAe;UACfO,gBAAgB;UAChBS,UAAU;UACVU,KAAK,EAAE;YACHC,OAAO,EAAEF,EAAE,CAACE,OAAO;YACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;YACbC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,KAAK,EAAEL,EAAE,CAACK;UACd;QACJ,CAAC,CACJ;MACL;IACJ,CAAC;IAED,MAAMrC,OAAO,CAACsC,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOlC,OAAO,EAAE;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createChangeRequestUrl = void 0;
|
7
|
-
|
8
7
|
const createChangeRequestUrl = params => {
|
9
8
|
/**
|
10
9
|
* All variables must exist for URL to be created.
|
@@ -14,11 +13,9 @@ const createChangeRequestUrl = params => {
|
|
14
13
|
if (!!key) {
|
15
14
|
continue;
|
16
15
|
}
|
17
|
-
|
18
16
|
console.log(`Missing variable "${key}", which we use to create a comment URL.`);
|
19
17
|
return null;
|
20
18
|
}
|
21
|
-
|
22
19
|
const {
|
23
20
|
baseUrl,
|
24
21
|
changeRequestId,
|
@@ -27,5 +24,4 @@ const createChangeRequestUrl = params => {
|
|
27
24
|
} = params;
|
28
25
|
return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
|
29
26
|
};
|
30
|
-
|
31
27
|
exports.createChangeRequestUrl = createChangeRequestUrl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createChangeRequestUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId"],"sources":["changeRequestUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createChangeRequestUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["createChangeRequestUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId"],"sources":["changeRequestUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createChangeRequestUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":";;;;;;AAMO,MAAMA,sBAAsB,GAAIC,MAAc,IAAK;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,0CAAyC,CAAC;IAC/E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,eAAe;IAAEC,eAAe;IAAEC;EAAO,CAAC,GAAGP,MAAM;EAEpE,OAAQ,GAAEI,OAAQ,wBAAuBE,eAAgB,IAAGC,MAAO,IAAGF,eAAgB,EAAC;AAC3F,CAAC;AAAC"}
|
@@ -1,68 +1,51 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.attachCommentAfterCreate = void 0;
|
9
|
-
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
-
|
12
9
|
var _utils = require("../../utils");
|
13
|
-
|
14
10
|
var _contentUrl = require("./contentUrl");
|
15
|
-
|
16
11
|
var _commentUrl = require("./commentUrl");
|
17
|
-
|
18
12
|
var _reviewers = require("./reviewers");
|
19
|
-
|
20
13
|
var _sendCommentNotification = require("./sendCommentNotification");
|
21
|
-
|
22
14
|
var _appUrl = require("./appUrl");
|
23
|
-
|
24
15
|
const attachCommentAfterCreate = context => {
|
25
16
|
context.apw.comment.onCommentAfterCreate.subscribe(async ({
|
26
17
|
comment
|
27
18
|
}) => {
|
28
19
|
const execute = async () => {
|
29
20
|
const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);
|
30
|
-
|
31
21
|
if (!changeRequest) {
|
32
22
|
throw new _error.default("Missing change request.", "CHANGE_REQUEST_NOT_FOUND", {
|
33
23
|
changeRequest: comment.changeRequest,
|
34
24
|
comment: comment.id
|
35
25
|
});
|
36
26
|
}
|
37
|
-
|
38
27
|
const {
|
39
28
|
id: contentReviewId,
|
40
29
|
stepId
|
41
30
|
} = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
|
42
|
-
|
43
31
|
if (!stepId) {
|
44
32
|
throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
|
45
33
|
step: changeRequest.step
|
46
34
|
});
|
47
35
|
}
|
48
|
-
|
49
36
|
const settings = await (0, _appUrl.getAppUrl)(context);
|
50
|
-
|
51
37
|
if (!settings) {
|
52
38
|
return;
|
53
39
|
}
|
54
40
|
/**
|
55
41
|
* We will check if we can create a comment url before we go digging further into the database.
|
56
42
|
*/
|
57
|
-
|
58
|
-
|
59
43
|
const commentUrl = (0, _commentUrl.createCommentUrl)({
|
60
44
|
baseUrl: settings.appUrl,
|
61
45
|
changeRequestId: changeRequest.id,
|
62
46
|
contentReviewId,
|
63
47
|
stepId
|
64
48
|
});
|
65
|
-
|
66
49
|
if (!commentUrl) {
|
67
50
|
console.log("No comment url.");
|
68
51
|
return;
|
@@ -70,10 +53,7 @@ const attachCommentAfterCreate = context => {
|
|
70
53
|
/**
|
71
54
|
* Let's see if content review exists.
|
72
55
|
*/
|
73
|
-
|
74
|
-
|
75
56
|
const contentReview = await context.apw.contentReview.get(contentReviewId);
|
76
|
-
|
77
57
|
if (!contentReview) {
|
78
58
|
throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
|
79
59
|
contentReviewId
|
@@ -82,39 +62,31 @@ const attachCommentAfterCreate = context => {
|
|
82
62
|
/**
|
83
63
|
* We go and check the workflow.
|
84
64
|
*/
|
85
|
-
|
86
|
-
|
87
65
|
const workflow = await context.apw.workflow.get(contentReview.workflowId);
|
88
|
-
|
89
66
|
if (!workflow) {
|
90
67
|
throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
|
91
68
|
workflowId: contentReview.workflowId
|
92
69
|
});
|
93
70
|
}
|
94
|
-
|
95
71
|
const contentUrl = (0, _contentUrl.createContentUrl)({
|
96
72
|
plugins: context.plugins,
|
97
73
|
baseUrl: settings.appUrl,
|
98
74
|
contentReview,
|
99
75
|
workflow
|
100
76
|
});
|
101
|
-
|
102
77
|
if (!contentUrl) {
|
103
78
|
console.log("No content url.");
|
104
79
|
return;
|
105
80
|
}
|
106
|
-
|
107
81
|
const reviewers = await (0, _reviewers.fetchReviewers)({
|
108
82
|
context,
|
109
83
|
workflow,
|
110
84
|
exclude: [comment.createdBy.id]
|
111
85
|
});
|
112
|
-
|
113
86
|
if (reviewers.length === 0) {
|
114
87
|
console.log("No reviewers to send the e-mail notification to.");
|
115
88
|
return;
|
116
89
|
}
|
117
|
-
|
118
90
|
try {
|
119
91
|
await (0, _sendCommentNotification.sendCommentNotification)({
|
120
92
|
context,
|
@@ -142,16 +114,9 @@ const attachCommentAfterCreate = context => {
|
|
142
114
|
});
|
143
115
|
}
|
144
116
|
};
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
await execute();
|
149
|
-
} catch (ex) {
|
150
|
-
throw ex;
|
151
|
-
} finally {
|
152
|
-
context.security.enableAuthorization();
|
153
|
-
}
|
117
|
+
await context.security.withoutAuthorization(async () => {
|
118
|
+
return execute();
|
119
|
+
});
|
154
120
|
});
|
155
121
|
};
|
156
|
-
|
157
122
|
exports.attachCommentAfterCreate = attachCommentAfterCreate;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","
|
1
|
+
{"version":3,"names":["attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","withoutAuthorization"],"sources":["commentAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { createCommentUrl } from \"./commentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendCommentNotification } from \"./sendCommentNotification\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/appUrl\";\n\nexport const attachCommentAfterCreate = (context: ApwContext): void => {\n context.apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n const execute = async () => {\n const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);\n if (!changeRequest) {\n throw new WebinyError(\"Missing change request.\", \"CHANGE_REQUEST_NOT_FOUND\", {\n changeRequest: comment.changeRequest,\n comment: comment.id\n });\n }\n\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const commentUrl = createCommentUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!commentUrl) {\n console.log(\"No comment url.\");\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n console.log(\"No content url.\");\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [comment.createdBy.id]\n });\n\n if (reviewers.length === 0) {\n console.log(\"No reviewers to send the e-mail notification to.\");\n return;\n }\n\n try {\n await sendCommentNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n commentUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send comment notifications.`,\n \"COMMENT_NOTIFICATIONS_NOT_SENT\",\n {\n commentId: comment.id,\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n commentUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,wBAAwB,GAAIC,OAAmB,IAAW;EACnEA,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAQ,CAAC,KAAK;IACtE,MAAMG,OAAO,GAAG,YAAY;MACxB,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAAC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AACK,IAAI;YACbC,KAAK,EAAEN,EAAE,CAACM;UACd;QACJ,CAAC,CACJ;MACL;IACJ,CAAC;IAED,MAAMzC,OAAO,CAAC0C,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOtC,OAAO,EAAE;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createCommentUrl = void 0;
|
7
|
-
|
8
7
|
const createCommentUrl = params => {
|
9
8
|
/**
|
10
9
|
* All variables must exist for URL to be created.
|
@@ -14,11 +13,9 @@ const createCommentUrl = params => {
|
|
14
13
|
if (!!key) {
|
15
14
|
continue;
|
16
15
|
}
|
17
|
-
|
18
16
|
console.log(`Missing variable "${key}", which we use to create a comment URL.`);
|
19
17
|
return null;
|
20
18
|
}
|
21
|
-
|
22
19
|
const {
|
23
20
|
baseUrl,
|
24
21
|
changeRequestId,
|
@@ -27,5 +24,4 @@ const createCommentUrl = params => {
|
|
27
24
|
} = params;
|
28
25
|
return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
|
29
26
|
};
|
30
|
-
|
31
27
|
exports.createCommentUrl = createCommentUrl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createCommentUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId"],"sources":["commentUrl.ts"],"sourcesContent":["interface CreateCommentUrlParams {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createCommentUrl = (params: CreateCommentUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["createCommentUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId"],"sources":["commentUrl.ts"],"sourcesContent":["interface CreateCommentUrlParams {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createCommentUrl = (params: CreateCommentUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":";;;;;;AAMO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,0CAAyC,CAAC;IAC/E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,eAAe;IAAEC,eAAe;IAAEC;EAAO,CAAC,GAAGP,MAAM;EAEpE,OAAQ,GAAEI,OAAQ,wBAAuBE,eAAgB,IAAGC,MAAO,IAAGF,eAAgB,EAAC;AAC3F,CAAC;AAAC"}
|
@@ -1,24 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.attachContentReviewAfterCreate = void 0;
|
9
|
-
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
-
|
12
9
|
var _appUrl = require("./appUrl");
|
13
|
-
|
14
10
|
var _contentReviewUrl = require("./contentReviewUrl");
|
15
|
-
|
16
11
|
var _contentUrl = require("./contentUrl");
|
17
|
-
|
18
12
|
var _reviewers = require("./reviewers");
|
19
|
-
|
20
13
|
var _sendContentReviewNotification = require("./sendContentReviewNotification");
|
21
|
-
|
22
14
|
const attachContentReviewAfterCreate = context => {
|
23
15
|
context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
|
24
16
|
contentReview
|
@@ -27,62 +19,49 @@ const attachContentReviewAfterCreate = context => {
|
|
27
19
|
if (contentReview.steps.length === 0) {
|
28
20
|
return;
|
29
21
|
}
|
30
|
-
|
31
22
|
const [step] = contentReview.steps;
|
32
|
-
|
33
23
|
if (!(step !== null && step !== void 0 && step.id)) {
|
34
24
|
return;
|
35
25
|
}
|
36
|
-
|
37
26
|
const settings = await (0, _appUrl.getAppUrl)(context);
|
38
|
-
|
39
27
|
if (!settings) {
|
40
28
|
return;
|
41
29
|
}
|
42
|
-
|
43
30
|
const contentReviewUrl = (0, _contentReviewUrl.createContentReviewUrl)({
|
44
31
|
baseUrl: settings.appUrl,
|
45
32
|
contentReviewId: contentReview.id,
|
46
33
|
stepId: step.id
|
47
34
|
});
|
48
|
-
|
49
35
|
if (!contentReviewUrl) {
|
50
36
|
return;
|
51
37
|
}
|
38
|
+
|
52
39
|
/**
|
53
40
|
* We go and check the workflow.
|
54
41
|
*/
|
55
|
-
|
56
|
-
|
57
42
|
const workflow = await context.apw.workflow.get(contentReview.workflowId);
|
58
|
-
|
59
43
|
if (!workflow) {
|
60
44
|
throw new _error.default(`There is no workflow with Id "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
|
61
45
|
workflowId: contentReview.workflowId
|
62
46
|
});
|
63
47
|
}
|
64
|
-
|
65
48
|
const contentUrl = (0, _contentUrl.createContentUrl)({
|
66
49
|
plugins: context.plugins,
|
67
50
|
baseUrl: settings.appUrl,
|
68
51
|
contentReview,
|
69
52
|
workflow
|
70
53
|
});
|
71
|
-
|
72
54
|
if (!contentUrl) {
|
73
55
|
return;
|
74
56
|
}
|
75
|
-
|
76
57
|
const reviewers = await (0, _reviewers.fetchReviewers)({
|
77
58
|
context,
|
78
59
|
workflow,
|
79
60
|
exclude: [contentReview.createdBy.id]
|
80
61
|
});
|
81
|
-
|
82
62
|
if (reviewers.length === 0) {
|
83
63
|
return;
|
84
64
|
}
|
85
|
-
|
86
65
|
try {
|
87
66
|
await (0, _sendContentReviewNotification.sendContentReviewNotification)({
|
88
67
|
context,
|
@@ -107,16 +86,9 @@ const attachContentReviewAfterCreate = context => {
|
|
107
86
|
});
|
108
87
|
}
|
109
88
|
};
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
await execute();
|
114
|
-
} catch (ex) {
|
115
|
-
throw ex;
|
116
|
-
} finally {
|
117
|
-
context.security.enableAuthorization();
|
118
|
-
}
|
89
|
+
await context.security.withoutAuthorization(async () => {
|
90
|
+
return execute();
|
91
|
+
});
|
119
92
|
});
|
120
93
|
};
|
121
|
-
|
122
94
|
exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","
|
1
|
+
{"version":3,"names":["attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","withoutAuthorization"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./appUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\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F,IAAI,CAACI,UAAU,EAAE;QACb;MACJ;MAEA,MAAMG,SAAS,GAAG,MAAM,IAAAC,yBAAc,EAAC;QACnC1B,OAAO;QACPkB,QAAQ;QACRS,OAAO,EAAE,CAACzB,aAAa,CAAC0B,SAAS,CAACnB,EAAE;MACxC,CAAC,CAAC;MACF,IAAIgB,SAAS,CAAClB,MAAM,KAAK,CAAC,EAAE;QACxB;MACJ;MAEA,IAAI;QACA,MAAM,IAAAsB,4DAA6B,EAAC;UAChC7B,OAAO;UACPyB,SAAS;UACTvB,aAAa;UACbgB,QAAQ;UACRN,gBAAgB;UAChBU;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOQ,EAAE,EAAE;QACT,MAAM,IAAIT,cAAW,CAChB,8CAA6C,EAC9C,uCAAuC,EACvC;UACID,UAAU,EAAEF,QAAQ,CAACT,EAAE;UACvBO,eAAe,EAAEd,aAAa,CAACO,EAAE;UACjCG,gBAAgB;UAChBU,UAAU;UACVS,KAAK,EAAE;YACHC,OAAO,EAAEF,EAAE,CAACE,OAAO;YACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;YACbC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,KAAK,EAAEL,EAAE,CAACK;UACd;QACJ,CAAC,CACJ;MACL;IACJ,CAAC;IAED,MAAMnC,OAAO,CAACoC,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOhC,OAAO,EAAE;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createContentReviewUrl = void 0;
|
7
|
-
|
8
7
|
const createContentReviewUrl = params => {
|
9
8
|
/**
|
10
9
|
* All variables must exist for URL to be created.
|
@@ -14,11 +13,9 @@ const createContentReviewUrl = params => {
|
|
14
13
|
if (!!key) {
|
15
14
|
continue;
|
16
15
|
}
|
17
|
-
|
18
16
|
console.log(`Missing variable "${key}", which we use to create a comment URL.`);
|
19
17
|
return null;
|
20
18
|
}
|
21
|
-
|
22
19
|
const {
|
23
20
|
baseUrl,
|
24
21
|
contentReviewId,
|
@@ -26,5 +23,4 @@ const createContentReviewUrl = params => {
|
|
26
23
|
} = params;
|
27
24
|
return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;
|
28
25
|
};
|
29
|
-
|
30
26
|
exports.createContentReviewUrl = createContentReviewUrl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContentReviewUrl","params","key","console","log","baseUrl","contentReviewId","stepId"],"sources":["contentReviewUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createContentReviewUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["createContentReviewUrl","params","key","console","log","baseUrl","contentReviewId","stepId"],"sources":["contentReviewUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createContentReviewUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;\n};\n"],"mappings":";;;;;;AAKO,MAAMA,sBAAsB,GAAIC,MAAc,IAAK;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,0CAAyC,CAAC;IAC/E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,eAAe;IAAEC;EAAO,CAAC,GAAGN,MAAM;EAEnD,OAAQ,GAAEI,OAAQ,wBAAuBC,eAAgB,IAAGC,MAAO,EAAC;AACxE,CAAC;AAAC"}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createContentUrl = void 0;
|
7
|
-
|
8
7
|
var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
|
9
|
-
|
10
8
|
const createContentUrl = params => {
|
11
9
|
const {
|
12
10
|
plugins,
|
@@ -18,12 +16,9 @@ const createContentUrl = params => {
|
|
18
16
|
const [contentUrlPlugin] = plugins.byType(_ApwContentUrlPlugin.ApwContentUrlPlugin.type).filter(plugin => {
|
19
17
|
return plugin.canUse(contentType);
|
20
18
|
}).reverse();
|
21
|
-
|
22
19
|
if (!contentUrlPlugin) {
|
23
20
|
return null;
|
24
21
|
}
|
25
|
-
|
26
22
|
return contentUrlPlugin.create(params);
|
27
23
|
};
|
28
|
-
|
29
24
|
exports.createContentUrl = createContentUrl;
|