@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.611c5af35e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +30 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +30 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +30 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +30 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +0 -5
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +4 -11
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +4 -12
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +32 -86
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +4 -12
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.js +4 -17
  24. package/crud/createWorkflowMethods.js.map +1 -1
  25. package/crud/index.js +0 -25
  26. package/crud/index.js.map +1 -1
  27. package/crud/utils.js +0 -28
  28. package/crud/utils.js.map +1 -1
  29. package/index.d.ts +3 -3
  30. package/index.js +5 -13
  31. package/index.js.map +1 -1
  32. package/package.json +35 -35
  33. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  35. package/plugins/cms/apwEntryPlugins.js +0 -8
  36. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  37. package/plugins/cms/index.js +5 -10
  38. package/plugins/cms/index.js.map +1 -1
  39. package/plugins/cms/linkContentReviewToEntry.js +0 -17
  40. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  41. package/plugins/cms/linkWorkflowToEntry.js +2 -31
  42. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  43. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  44. package/plugins/cms/notifications/changeRequestNotification.js +31 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  46. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  47. package/plugins/cms/notifications/commentNotification.js +31 -0
  48. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  49. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.js +31 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  52. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  53. package/plugins/cms/notifications/contentUrl.js +53 -0
  54. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  55. package/plugins/cms/triggerContentReview.js +0 -14
  56. package/plugins/cms/triggerContentReview.js.map +1 -1
  57. package/plugins/cms/updateContentReviewStatus.js +0 -18
  58. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  59. package/plugins/cms/utils.js +2 -47
  60. package/plugins/cms/utils.js.map +1 -1
  61. package/plugins/context.js +0 -31
  62. package/plugins/context.js.map +1 -1
  63. package/plugins/graphql/changeRequest.gql.js +1 -8
  64. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  65. package/plugins/graphql/comment.gql.js +1 -8
  66. package/plugins/graphql/comment.gql.js.map +1 -1
  67. package/plugins/graphql/contentReview.gql.js +1 -20
  68. package/plugins/graphql/contentReview.gql.js.map +1 -1
  69. package/plugins/graphql/reviewer.gql.js +3 -8
  70. package/plugins/graphql/reviewer.gql.js.map +1 -1
  71. package/plugins/graphql/workflow.gql.js +1 -8
  72. package/plugins/graphql/workflow.gql.js.map +1 -1
  73. package/plugins/graphql.js +1 -16
  74. package/plugins/graphql.js.map +1 -1
  75. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  76. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  77. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
  78. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  79. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
  80. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  81. package/plugins/hooks/index.js +2 -13
  82. package/plugins/hooks/index.js.map +1 -1
  83. package/plugins/hooks/initializeContentReviewSteps.js +2 -15
  84. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  85. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  86. package/plugins/hooks/initializeNotifications.js +15 -0
  87. package/plugins/hooks/initializeNotifications.js.map +1 -0
  88. package/plugins/hooks/listContentReviews.d.ts +1 -1
  89. package/plugins/hooks/listContentReviews.js +9 -33
  90. package/plugins/hooks/listContentReviews.js.map +1 -1
  91. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  92. package/plugins/hooks/notifications/appUrl.js +18 -0
  93. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  94. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  95. package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  97. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  98. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  100. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  101. package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  103. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  104. package/plugins/hooks/notifications/commentUrl.js +27 -0
  105. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  106. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  107. package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  109. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  110. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  112. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  113. package/plugins/hooks/notifications/contentUrl.js +24 -0
  114. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  115. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  116. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  118. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  119. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  121. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  122. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  124. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  125. package/plugins/hooks/notifications/reviewers.js +44 -0
  126. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  127. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  128. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  130. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  131. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  133. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  134. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  136. package/plugins/hooks/updatePendingChangeRequests.js +0 -8
  137. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  138. package/plugins/hooks/updateTotalComments.js +0 -9
  139. package/plugins/hooks/updateTotalComments.js.map +1 -1
  140. package/plugins/hooks/validateChangeRequest.js +25 -16
  141. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  142. package/plugins/hooks/validateComment.js +11 -12
  143. package/plugins/hooks/validateComment.js.map +1 -1
  144. package/plugins/hooks/validateContentReview.js +0 -6
  145. package/plugins/hooks/validateContentReview.js.map +1 -1
  146. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
  147. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  148. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  149. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  150. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  151. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  152. package/plugins/pageBuilder/index.js +5 -8
  153. package/plugins/pageBuilder/index.js.map +1 -1
  154. package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
  155. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  156. package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
  157. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  158. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  159. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  161. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  162. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  164. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  165. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  167. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  168. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  170. package/plugins/pageBuilder/triggerContentReview.js +0 -11
  171. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  172. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
  173. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  174. package/plugins/pageBuilder/utils.js +1 -35
  175. package/plugins/pageBuilder/utils.js.map +1 -1
  176. package/plugins/utils.d.ts +0 -1
  177. package/plugins/utils.js +1 -50
  178. package/plugins/utils.js.map +1 -1
  179. package/scheduler/createScheduleActionMethods.js +1 -20
  180. package/scheduler/createScheduleActionMethods.js.map +1 -1
  181. package/scheduler/handlers/executeAction/index.js +9 -33
  182. package/scheduler/handlers/executeAction/index.js.map +1 -1
  183. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -5
  184. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  185. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +0 -21
  186. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  187. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -27
  188. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  189. package/scheduler/handlers/executeAction/security.js +0 -11
  190. package/scheduler/handlers/executeAction/security.js.map +1 -1
  191. package/scheduler/handlers/scheduleAction/index.js +5 -25
  192. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  193. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
  194. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  195. package/scheduler/handlers/utils.js +3 -40
  196. package/scheduler/handlers/utils.js.map +1 -1
  197. package/scheduler/index.js +0 -3
  198. package/scheduler/index.js.map +1 -1
  199. package/scheduler/types.js +0 -6
  200. package/scheduler/types.js.map +1 -1
  201. package/storageOperations/changeRequestStorageOperations.js +0 -19
  202. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  203. package/storageOperations/commentStorageOperations.js +0 -21
  204. package/storageOperations/commentStorageOperations.js.map +1 -1
  205. package/storageOperations/contentReviewStorageOperations.js +0 -17
  206. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  207. package/storageOperations/index.js +0 -14
  208. package/storageOperations/index.js.map +1 -1
  209. package/storageOperations/models/changeRequest.model.js +0 -9
  210. package/storageOperations/models/changeRequest.model.js.map +1 -1
  211. package/storageOperations/models/comment.model.js +0 -8
  212. package/storageOperations/models/comment.model.js.map +1 -1
  213. package/storageOperations/models/contentModelPluginFactory.js +0 -5
  214. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  215. package/storageOperations/models/contentReview.model.js +0 -26
  216. package/storageOperations/models/contentReview.model.js.map +1 -1
  217. package/storageOperations/models/index.js +2 -24
  218. package/storageOperations/models/index.js.map +1 -1
  219. package/storageOperations/models/reviewer.model.js +17 -9
  220. package/storageOperations/models/reviewer.model.js.map +1 -1
  221. package/storageOperations/models/utils.js +0 -4
  222. package/storageOperations/models/utils.js.map +1 -1
  223. package/storageOperations/models/workflow.model.js +0 -23
  224. package/storageOperations/models/workflow.model.js.map +1 -1
  225. package/storageOperations/reviewerStorageOperations.js +11 -20
  226. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  227. package/storageOperations/workflowStorageOperations.js +0 -19
  228. package/storageOperations/workflowStorageOperations.js.map +1 -1
  229. package/types.d.ts +21 -9
  230. package/types.js +0 -14
  231. package/types.js.map +1 -1
  232. package/utils/contentApwSettingsPlugin.js +0 -6
  233. package/utils/contentApwSettingsPlugin.js.map +1 -1
  234. package/utils/errors.js +0 -17
  235. package/utils/errors.js.map +1 -1
  236. package/utils/fieldResolver.js +2 -12
  237. package/utils/fieldResolver.js.map +1 -1
  238. package/utils/resolve.js +0 -3
  239. package/utils/resolve.js.map +1 -1
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachChangeRequestAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _utils = require("../../utils");
10
+ var _contentUrl = require("./contentUrl");
11
+ var _sendChangeRequestNotification = require("./sendChangeRequestNotification");
12
+ var _reviewers = require("./reviewers");
13
+ var _changeRequestUrl = require("./changeRequestUrl");
14
+ var _appUrl = require("./appUrl");
15
+ const attachChangeRequestAfterCreate = context => {
16
+ context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
17
+ changeRequest
18
+ }) => {
19
+ const execute = async () => {
20
+ const {
21
+ id: contentReviewId,
22
+ stepId
23
+ } = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
24
+ if (!stepId) {
25
+ throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
26
+ step: changeRequest.step
27
+ });
28
+ }
29
+ const settings = await (0, _appUrl.getAppUrl)(context);
30
+ if (!settings) {
31
+ return;
32
+ }
33
+ /**
34
+ * We will check if we can create a comment url before we go digging further into the database.
35
+ */
36
+ const changeRequestUrl = (0, _changeRequestUrl.createChangeRequestUrl)({
37
+ baseUrl: settings.appUrl,
38
+ changeRequestId: changeRequest.id,
39
+ contentReviewId,
40
+ stepId
41
+ });
42
+ if (!changeRequestUrl) {
43
+ return;
44
+ }
45
+ /**
46
+ * Let's see if content review exists.
47
+ */
48
+ const contentReview = await context.apw.contentReview.get(contentReviewId);
49
+ if (!contentReview) {
50
+ throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
51
+ contentReviewId
52
+ });
53
+ }
54
+ /**
55
+ * We go and check the workflow.
56
+ */
57
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
58
+ if (!workflow) {
59
+ throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
60
+ workflowId: contentReview.workflowId
61
+ });
62
+ }
63
+ const contentUrl = (0, _contentUrl.createContentUrl)({
64
+ plugins: context.plugins,
65
+ baseUrl: settings.appUrl,
66
+ contentReview,
67
+ workflow
68
+ });
69
+ if (!contentUrl) {
70
+ return;
71
+ }
72
+ const reviewers = await (0, _reviewers.fetchReviewers)({
73
+ context,
74
+ workflow,
75
+ exclude: [changeRequest.createdBy.id]
76
+ });
77
+ if (reviewers.length === 0) {
78
+ return;
79
+ }
80
+ try {
81
+ await (0, _sendChangeRequestNotification.sendChangeRequestNotification)({
82
+ context,
83
+ reviewers,
84
+ changeRequest,
85
+ contentReview,
86
+ workflow,
87
+ changeRequestUrl,
88
+ contentUrl
89
+ });
90
+ } catch (ex) {
91
+ throw new _error.default(`Could not send change request notifications.`, "CHANGE_REQUEST_NOTIFICATIONS_NOT_SENT", {
92
+ workflowId: workflow.id,
93
+ changeRequestId: changeRequest.id,
94
+ contentReviewId,
95
+ changeRequestUrl,
96
+ contentUrl,
97
+ error: {
98
+ message: ex.message,
99
+ code: ex.code,
100
+ data: ex.data,
101
+ stack: ex.stack
102
+ }
103
+ });
104
+ }
105
+ };
106
+ try {
107
+ context.security.disableAuthorization();
108
+ await execute();
109
+ } catch (ex) {
110
+ throw ex;
111
+ } finally {
112
+ context.security.enableAuthorization();
113
+ }
114
+ });
115
+ };
116
+ exports.attachChangeRequestAfterCreate = attachChangeRequestAfterCreate;
@@ -0,0 +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","disableAuthorization","enableAuthorization"],"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 try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\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,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IACxF,MAAMG,OAAO,GAAG,YAAY;MACxB,MAAM;QAAEC,EAAE,EAAEC,eAAe;QAAEC;MAAO,CAAC,GAAG,IAAAC,oCAA6B,EACjEP,aAAa,CAACQ,IAAI,CACrB;MACD,IAAI,CAACF,MAAM,EAAE;QACT,MAAM,IAAIG,cAAW,CAAC,qCAAqC,EAAE,iBAAiB,EAAE;UAC5ED,IAAI,EAAER,aAAa,CAACQ;QACxB,CAAC,CAAC;MACN;MAEA,MAAME,QAAQ,GAAG,MAAM,IAAAC,iBAAS,EAACb,OAAO,CAAC;MACzC,IAAI,CAACY,QAAQ,EAAE;QACX;MACJ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B,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,IAAI;MACArC,OAAO,CAACsC,QAAQ,CAACC,oBAAoB,EAAE;MACvC,MAAMlC,OAAO,EAAE;IACnB,CAAC,CAAC,OAAO2B,EAAE,EAAE;MACT,MAAMA,EAAE;IACZ,CAAC,SAAS;MACNhC,OAAO,CAACsC,QAAQ,CAACE,mBAAmB,EAAE;IAC1C;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -0,0 +1,8 @@
1
+ interface Params {
2
+ baseUrl?: string;
3
+ changeRequestId: string;
4
+ contentReviewId: string;
5
+ stepId: string;
6
+ }
7
+ export declare const createChangeRequestUrl: (params: Params) => string | null;
8
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestUrl = void 0;
7
+ const createChangeRequestUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ changeRequestId,
22
+ contentReviewId,
23
+ stepId
24
+ } = params;
25
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
26
+ };
27
+ exports.createChangeRequestUrl = createChangeRequestUrl;
@@ -0,0 +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":";;;;;;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"}
@@ -0,0 +1,2 @@
1
+ import { ApwContext } from "../../../types";
2
+ export declare const attachCommentAfterCreate: (context: ApwContext) => void;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachCommentAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _utils = require("../../utils");
10
+ var _contentUrl = require("./contentUrl");
11
+ var _commentUrl = require("./commentUrl");
12
+ var _reviewers = require("./reviewers");
13
+ var _sendCommentNotification = require("./sendCommentNotification");
14
+ var _appUrl = require("./appUrl");
15
+ const attachCommentAfterCreate = context => {
16
+ context.apw.comment.onCommentAfterCreate.subscribe(async ({
17
+ comment
18
+ }) => {
19
+ const execute = async () => {
20
+ const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);
21
+ if (!changeRequest) {
22
+ throw new _error.default("Missing change request.", "CHANGE_REQUEST_NOT_FOUND", {
23
+ changeRequest: comment.changeRequest,
24
+ comment: comment.id
25
+ });
26
+ }
27
+ const {
28
+ id: contentReviewId,
29
+ stepId
30
+ } = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
31
+ if (!stepId) {
32
+ throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
33
+ step: changeRequest.step
34
+ });
35
+ }
36
+ const settings = await (0, _appUrl.getAppUrl)(context);
37
+ if (!settings) {
38
+ return;
39
+ }
40
+ /**
41
+ * We will check if we can create a comment url before we go digging further into the database.
42
+ */
43
+ const commentUrl = (0, _commentUrl.createCommentUrl)({
44
+ baseUrl: settings.appUrl,
45
+ changeRequestId: changeRequest.id,
46
+ contentReviewId,
47
+ stepId
48
+ });
49
+ if (!commentUrl) {
50
+ console.log("No comment url.");
51
+ return;
52
+ }
53
+ /**
54
+ * Let's see if content review exists.
55
+ */
56
+ const contentReview = await context.apw.contentReview.get(contentReviewId);
57
+ if (!contentReview) {
58
+ throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
59
+ contentReviewId
60
+ });
61
+ }
62
+ /**
63
+ * We go and check the workflow.
64
+ */
65
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
66
+ if (!workflow) {
67
+ throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
68
+ workflowId: contentReview.workflowId
69
+ });
70
+ }
71
+ const contentUrl = (0, _contentUrl.createContentUrl)({
72
+ plugins: context.plugins,
73
+ baseUrl: settings.appUrl,
74
+ contentReview,
75
+ workflow
76
+ });
77
+ if (!contentUrl) {
78
+ console.log("No content url.");
79
+ return;
80
+ }
81
+ const reviewers = await (0, _reviewers.fetchReviewers)({
82
+ context,
83
+ workflow,
84
+ exclude: [comment.createdBy.id]
85
+ });
86
+ if (reviewers.length === 0) {
87
+ console.log("No reviewers to send the e-mail notification to.");
88
+ return;
89
+ }
90
+ try {
91
+ await (0, _sendCommentNotification.sendCommentNotification)({
92
+ context,
93
+ reviewers,
94
+ changeRequest,
95
+ contentReview,
96
+ workflow,
97
+ commentUrl,
98
+ contentUrl
99
+ });
100
+ } catch (ex) {
101
+ throw new _error.default(`Could not send comment notifications.`, "COMMENT_NOTIFICATIONS_NOT_SENT", {
102
+ commentId: comment.id,
103
+ workflowId: workflow.id,
104
+ changeRequestId: changeRequest.id,
105
+ contentReviewId,
106
+ commentUrl,
107
+ contentUrl,
108
+ error: {
109
+ message: ex.message,
110
+ code: ex.code,
111
+ data: ex.data,
112
+ stack: ex.stack
113
+ }
114
+ });
115
+ }
116
+ };
117
+ try {
118
+ context.security.disableAuthorization();
119
+ await execute();
120
+ } catch (ex) {
121
+ throw ex;
122
+ } finally {
123
+ context.security.enableAuthorization();
124
+ }
125
+ });
126
+ };
127
+ exports.attachCommentAfterCreate = attachCommentAfterCreate;
@@ -0,0 +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","disableAuthorization","enableAuthorization"],"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 try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\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,CAACC,GAAG,CAACK,aAAa,CAACC,GAAG,CAACL,OAAO,CAACI,aAAa,CAAC;MAChF,IAAI,CAACA,aAAa,EAAE;QAChB,MAAM,IAAIE,cAAW,CAAC,yBAAyB,EAAE,0BAA0B,EAAE;UACzEF,aAAa,EAAEJ,OAAO,CAACI,aAAa;UACpCJ,OAAO,EAAEA,OAAO,CAACO;QACrB,CAAC,CAAC;MACN;MAEA,MAAM;QAAEA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AQ,CAACE,mBAAmB,EAAE;IAC1C;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -0,0 +1,8 @@
1
+ interface CreateCommentUrlParams {
2
+ baseUrl?: string;
3
+ changeRequestId: string;
4
+ contentReviewId: string;
5
+ stepId: string;
6
+ }
7
+ export declare const createCommentUrl: (params: CreateCommentUrlParams) => string | null;
8
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentUrl = void 0;
7
+ const createCommentUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ changeRequestId,
22
+ contentReviewId,
23
+ stepId
24
+ } = params;
25
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
26
+ };
27
+ exports.createCommentUrl = createCommentUrl;
@@ -0,0 +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":";;;;;;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"}
@@ -0,0 +1,2 @@
1
+ import { ApwContext } from "../../../types";
2
+ export declare const attachContentReviewAfterCreate: (context: ApwContext) => void;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachContentReviewAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _appUrl = require("./appUrl");
10
+ var _contentReviewUrl = require("./contentReviewUrl");
11
+ var _contentUrl = require("./contentUrl");
12
+ var _reviewers = require("./reviewers");
13
+ var _sendContentReviewNotification = require("./sendContentReviewNotification");
14
+ const attachContentReviewAfterCreate = context => {
15
+ context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
16
+ contentReview
17
+ }) => {
18
+ const execute = async () => {
19
+ if (contentReview.steps.length === 0) {
20
+ return;
21
+ }
22
+ const [step] = contentReview.steps;
23
+ if (!(step !== null && step !== void 0 && step.id)) {
24
+ return;
25
+ }
26
+ const settings = await (0, _appUrl.getAppUrl)(context);
27
+ if (!settings) {
28
+ return;
29
+ }
30
+ const contentReviewUrl = (0, _contentReviewUrl.createContentReviewUrl)({
31
+ baseUrl: settings.appUrl,
32
+ contentReviewId: contentReview.id,
33
+ stepId: step.id
34
+ });
35
+ if (!contentReviewUrl) {
36
+ return;
37
+ }
38
+
39
+ /**
40
+ * We go and check the workflow.
41
+ */
42
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
43
+ if (!workflow) {
44
+ throw new _error.default(`There is no workflow with Id "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
45
+ workflowId: contentReview.workflowId
46
+ });
47
+ }
48
+ const contentUrl = (0, _contentUrl.createContentUrl)({
49
+ plugins: context.plugins,
50
+ baseUrl: settings.appUrl,
51
+ contentReview,
52
+ workflow
53
+ });
54
+ if (!contentUrl) {
55
+ return;
56
+ }
57
+ const reviewers = await (0, _reviewers.fetchReviewers)({
58
+ context,
59
+ workflow,
60
+ exclude: [contentReview.createdBy.id]
61
+ });
62
+ if (reviewers.length === 0) {
63
+ return;
64
+ }
65
+ try {
66
+ await (0, _sendContentReviewNotification.sendContentReviewNotification)({
67
+ context,
68
+ reviewers,
69
+ contentReview,
70
+ workflow,
71
+ contentReviewUrl,
72
+ contentUrl
73
+ });
74
+ } catch (ex) {
75
+ throw new _error.default(`Could not send content review notifications.`, "CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT", {
76
+ workflowId: workflow.id,
77
+ contentReviewId: contentReview.id,
78
+ contentReviewUrl,
79
+ contentUrl,
80
+ error: {
81
+ message: ex.message,
82
+ code: ex.code,
83
+ data: ex.data,
84
+ stack: ex.stack
85
+ }
86
+ });
87
+ }
88
+ };
89
+ try {
90
+ context.security.disableAuthorization();
91
+ await execute();
92
+ } catch (ex) {
93
+ throw ex;
94
+ } finally {
95
+ context.security.enableAuthorization();
96
+ }
97
+ });
98
+ };
99
+ exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
@@ -0,0 +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","disableAuthorization","enableAuthorization"],"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 try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAMA,8BAA8B,GAAIC,OAAmB,IAAW;EACzEA,OAAO,CAACC,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IACxF,MAAMG,OAAO,GAAG,YAAY;MACxB,IAAIH,aAAa,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;QAClC;MACJ;MACA,MAAM,CAACC,IAAI,CAAC,GAAGN,aAAa,CAACI,KAAK;MAClC,IAAI,EAACE,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEC,EAAE,GAAE;QACX;MACJ;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAS,EAACX,OAAO,CAAC;MACzC,IAAI,CAACU,QAAQ,EAAE;QACX;MACJ;MAEA,MAAME,gBAAgB,GAAG,IAAAC,wCAAsB,EAAC;QAC5CC,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBC,eAAe,EAAEd,aAAa,CAACO,EAAE;QACjCQ,MAAM,EAAET,IAAI,CAACC;MACjB,CAAC,CAAC;MACF,IAAI,CAACG,gBAAgB,EAAE;QACnB;MACJ;;MAEA;AACZ;AACA;MACY,MAAMM,QAAQ,GAAG,MAAMlB,OAAO,CAACC,GAAG,CAACiB,QAAQ,CAACC,GAAG,CAACjB,aAAa,CAACkB,UAAU,CAAC;MACzE,IAAI,CAACF,QAAQ,EAAE;QACX,MAAM,IAAIG,cAAW,CAChB,iCAAgCnB,aAAa,CAACkB,UAAW,IAAG,EAC7D,oBAAoB,EACpB;UACIA,UAAU,EAAElB,aAAa,CAACkB;QAC9B,CAAC,CACJ;MACL;MAEA,MAAME,UAAU,GAAG,IAAAC,4BAAgB,E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
+ contentReviewId: string;
4
+ stepId: string;
5
+ }
6
+ export declare const createContentReviewUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewUrl = void 0;
7
+ const createContentReviewUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ contentReviewId,
22
+ stepId
23
+ } = params;
24
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;
25
+ };
26
+ exports.createContentReviewUrl = createContentReviewUrl;
@@ -0,0 +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":";;;;;;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"}
@@ -0,0 +1,7 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ApwContentUrlPluginCbParams } from "../../../ApwContentUrlPlugin";
3
+ interface Params extends ApwContentUrlPluginCbParams {
4
+ plugins: PluginsContainer;
5
+ }
6
+ export declare const createContentUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrl = void 0;
7
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
8
+ const createContentUrl = params => {
9
+ const {
10
+ plugins,
11
+ contentReview
12
+ } = params;
13
+ const {
14
+ type: contentType
15
+ } = contentReview.content;
16
+ const [contentUrlPlugin] = plugins.byType(_ApwContentUrlPlugin.ApwContentUrlPlugin.type).filter(plugin => {
17
+ return plugin.canUse(contentType);
18
+ }).reverse();
19
+ if (!contentUrlPlugin) {
20
+ return null;
21
+ }
22
+ return contentUrlPlugin.create(params);
23
+ };
24
+ exports.createContentUrl = createContentUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentUrl","params","plugins","contentReview","type","contentType","content","contentUrlPlugin","byType","ApwContentUrlPlugin","filter","plugin","canUse","reverse","create"],"sources":["contentUrl.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ApwContentUrlPlugin, ApwContentUrlPluginCbParams } from \"~/ApwContentUrlPlugin\";\n\ninterface Params extends ApwContentUrlPluginCbParams {\n plugins: PluginsContainer;\n}\n\nexport const createContentUrl = (params: Params): string | null => {\n const { plugins, contentReview } = params;\n\n const { type: contentType } = contentReview.content;\n\n const [contentUrlPlugin] = plugins\n .byType<ApwContentUrlPlugin>(ApwContentUrlPlugin.type)\n .filter(plugin => {\n return plugin.canUse(contentType);\n })\n .reverse();\n if (!contentUrlPlugin) {\n return null;\n }\n\n return contentUrlPlugin.create(params);\n};\n"],"mappings":";;;;;;AACA;AAMO,MAAMA,gBAAgB,GAAIC,MAAc,IAAoB;EAC/D,MAAM;IAAEC,OAAO;IAAEC;EAAc,CAAC,GAAGF,MAAM;EAEzC,MAAM;IAAEG,IAAI,EAAEC;EAAY,CAAC,GAAGF,aAAa,CAACG,OAAO;EAEnD,MAAM,CAACC,gBAAgB,CAAC,GAAGL,OAAO,CAC7BM,MAAM,CAAsBC,wCAAmB,CAACL,IAAI,CAAC,CACrDM,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACP,WAAW,CAAC;EACrC,CAAC,CAAC,CACDQ,OAAO,EAAE;EACd,IAAI,CAACN,gBAAgB,EAAE;IACnB,OAAO,IAAI;EACf;EAEA,OAAOA,gBAAgB,CAACO,MAAM,CAACb,MAAM,CAAC;AAC1C,CAAC;AAAC"}
@@ -0,0 +1,11 @@
1
+ import { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwChangeRequestNotification } from "../../../ApwChangeRequestNotification";
3
+ interface GetLastChangeRequestNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastChangeRequestNotificationPlugin {
8
+ (params: GetLastChangeRequestNotificationPluginParams): ApwChangeRequestNotification | undefined;
9
+ }
10
+ export declare const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin;
11
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastChangeRequestNotificationPlugin = void 0;
7
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
8
+ const getLastChangeRequestNotificationPlugin = params => {
9
+ const {
10
+ context,
11
+ type
12
+ } = params;
13
+ /**
14
+ * We need the plugin to create the notification text.
15
+ */
16
+ const plugins = context.plugins.byType(_ApwChangeRequestNotification.ApwChangeRequestNotification.type).filter(plugin => {
17
+ return plugin.canUse(type);
18
+ });
19
+ return plugins.shift();
20
+ };
21
+ exports.getLastChangeRequestNotificationPlugin = getLastChangeRequestNotificationPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLastChangeRequestNotificationPlugin","params","context","type","plugins","byType","ApwChangeRequestNotification","filter","plugin","canUse","shift"],"sources":["lastChangeRequestNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\ninterface GetLastChangeRequestNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastChangeRequestNotificationPlugin {\n (params: GetLastChangeRequestNotificationPluginParams):\n | ApwChangeRequestNotification\n | undefined;\n}\nexport const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwChangeRequestNotification>(ApwChangeRequestNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;AACA;AAWO,MAAMA,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAO;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAChC;AACR;AACA;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAA+BC,0DAA4B,CAACH,IAAI,CAAC,CACvEI,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACN,IAAI,CAAC;EAC9B,CAAC,CAAC;EAEN,OAAOC,OAAO,CAACM,KAAK,EAAE;AAC1B,CAAC;AAAC"}
@@ -0,0 +1,11 @@
1
+ import { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwCommentNotification } from "../../../ApwCommentNotification";
3
+ interface GetLastCommentNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastCommentNotificationPlugin {
8
+ (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;
9
+ }
10
+ export declare const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin;
11
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastCommentNotificationPlugin = void 0;
7
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
8
+ const getLastCommentNotificationPlugin = params => {
9
+ const {
10
+ context,
11
+ type
12
+ } = params;
13
+ /**
14
+ * We need the plugin to create the notification text.
15
+ */
16
+ const plugins = context.plugins.byType(_ApwCommentNotification.ApwCommentNotification.type).filter(plugin => {
17
+ return plugin.canUse(type);
18
+ });
19
+ return plugins.shift();
20
+ };
21
+ exports.getLastCommentNotificationPlugin = getLastCommentNotificationPlugin;