@webiny/api-apw 0.0.0-unstable.5e7233243f → 0.0.0-unstable.6e5425ee89

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 (240) 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 +1 -6
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +21 -25
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +21 -26
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +71 -125
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +21 -26
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.d.ts +1 -1
  24. package/crud/createWorkflowMethods.js +37 -28
  25. package/crud/createWorkflowMethods.js.map +1 -1
  26. package/crud/index.js +3 -32
  27. package/crud/index.js.map +1 -1
  28. package/crud/utils.js +4 -36
  29. package/crud/utils.js.map +1 -1
  30. package/index.d.ts +3 -3
  31. package/index.js +7 -13
  32. package/index.js.map +1 -1
  33. package/package.json +38 -37
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
  35. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  36. package/plugins/cms/apwEntryPlugins.js +4 -16
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  38. package/plugins/cms/index.js +5 -10
  39. package/plugins/cms/index.js.map +1 -1
  40. package/plugins/cms/linkContentReviewToEntry.js +4 -21
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +7 -36
  43. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  44. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js +31 -0
  46. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  47. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  48. package/plugins/cms/notifications/commentNotification.js +31 -0
  49. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js +31 -0
  52. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  53. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  54. package/plugins/cms/notifications/contentUrl.js +53 -0
  55. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  56. package/plugins/cms/triggerContentReview.js +3 -17
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +10 -32
  59. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  60. package/plugins/cms/utils.js +6 -55
  61. package/plugins/cms/utils.js.map +1 -1
  62. package/plugins/context.js +1 -32
  63. package/plugins/context.js.map +1 -1
  64. package/plugins/graphql/changeRequest.gql.js +2 -9
  65. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  66. package/plugins/graphql/comment.gql.js +2 -9
  67. package/plugins/graphql/comment.gql.js.map +1 -1
  68. package/plugins/graphql/contentReview.gql.js +5 -24
  69. package/plugins/graphql/contentReview.gql.js.map +1 -1
  70. package/plugins/graphql/reviewer.gql.js +4 -9
  71. package/plugins/graphql/reviewer.gql.js.map +1 -1
  72. package/plugins/graphql/workflow.gql.js +2 -9
  73. package/plugins/graphql/workflow.gql.js.map +1 -1
  74. package/plugins/graphql.js +2 -17
  75. package/plugins/graphql.js.map +1 -1
  76. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  77. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  78. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  80. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  82. package/plugins/hooks/index.js +4 -12
  83. package/plugins/hooks/index.js.map +1 -1
  84. package/plugins/hooks/initializeContentReviewSteps.js +7 -23
  85. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  86. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  87. package/plugins/hooks/initializeNotifications.js +15 -0
  88. package/plugins/hooks/initializeNotifications.js.map +1 -0
  89. package/plugins/hooks/listContentReviews.d.ts +10 -0
  90. package/plugins/hooks/listContentReviews.js +56 -0
  91. package/plugins/hooks/listContentReviews.js.map +1 -0
  92. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  93. package/plugins/hooks/notifications/appUrl.js +18 -0
  94. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  95. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  98. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  101. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  104. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  105. package/plugins/hooks/notifications/commentUrl.js +27 -0
  106. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  107. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  110. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  113. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  114. package/plugins/hooks/notifications/contentUrl.js +24 -0
  115. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  116. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  119. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  122. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  125. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  126. package/plugins/hooks/notifications/reviewers.js +44 -0
  127. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  128. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  131. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  134. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  137. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  138. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  139. package/plugins/hooks/updateTotalComments.js +14 -27
  140. package/plugins/hooks/updateTotalComments.js.map +1 -1
  141. package/plugins/hooks/validateChangeRequest.js +27 -18
  142. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  143. package/plugins/hooks/validateComment.js +13 -14
  144. package/plugins/hooks/validateComment.js.map +1 -1
  145. package/plugins/hooks/validateContentReview.js +2 -8
  146. package/plugins/hooks/validateContentReview.js.map +1 -1
  147. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  149. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  150. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  151. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  153. package/plugins/pageBuilder/index.js +5 -8
  154. package/plugins/pageBuilder/index.js.map +1 -1
  155. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  156. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  157. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  158. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  159. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  162. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  165. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  168. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  171. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  172. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  173. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  174. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  175. package/plugins/pageBuilder/utils.js +2 -36
  176. package/plugins/pageBuilder/utils.js.map +1 -1
  177. package/plugins/utils.d.ts +1 -1
  178. package/plugins/utils.js +4 -57
  179. package/plugins/utils.js.map +1 -1
  180. package/scheduler/createScheduleActionMethods.js +17 -33
  181. package/scheduler/createScheduleActionMethods.js.map +1 -1
  182. package/scheduler/handlers/executeAction/index.js +9 -33
  183. package/scheduler/handlers/executeAction/index.js.map +1 -1
  184. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -6
  185. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -22
  187. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  188. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +5 -28
  189. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  190. package/scheduler/handlers/executeAction/security.js +0 -11
  191. package/scheduler/handlers/executeAction/security.js.map +1 -1
  192. package/scheduler/handlers/scheduleAction/index.js +13 -34
  193. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  194. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +7 -32
  195. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  196. package/scheduler/handlers/utils.js +4 -41
  197. package/scheduler/handlers/utils.js.map +1 -1
  198. package/scheduler/index.js +0 -3
  199. package/scheduler/index.js.map +1 -1
  200. package/scheduler/types.js +0 -6
  201. package/scheduler/types.js.map +1 -1
  202. package/storageOperations/changeRequestStorageOperations.js +5 -28
  203. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  204. package/storageOperations/commentStorageOperations.js +4 -29
  205. package/storageOperations/commentStorageOperations.js.map +1 -1
  206. package/storageOperations/contentReviewStorageOperations.js +5 -26
  207. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  208. package/storageOperations/index.js +5 -23
  209. package/storageOperations/index.js.map +1 -1
  210. package/storageOperations/models/changeRequest.model.js +0 -9
  211. package/storageOperations/models/changeRequest.model.js.map +1 -1
  212. package/storageOperations/models/comment.model.js +0 -8
  213. package/storageOperations/models/comment.model.js.map +1 -1
  214. package/storageOperations/models/contentModelPluginFactory.js +3 -12
  215. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  216. package/storageOperations/models/contentReview.model.js +6 -31
  217. package/storageOperations/models/contentReview.model.js.map +1 -1
  218. package/storageOperations/models/index.js +3 -25
  219. package/storageOperations/models/index.js.map +1 -1
  220. package/storageOperations/models/reviewer.model.js +17 -9
  221. package/storageOperations/models/reviewer.model.js.map +1 -1
  222. package/storageOperations/models/utils.js +3 -6
  223. package/storageOperations/models/utils.js.map +1 -1
  224. package/storageOperations/models/workflow.model.js +0 -23
  225. package/storageOperations/models/workflow.model.js.map +1 -1
  226. package/storageOperations/reviewerStorageOperations.js +16 -29
  227. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  228. package/storageOperations/workflowStorageOperations.js +6 -31
  229. package/storageOperations/workflowStorageOperations.js.map +1 -1
  230. package/types.d.ts +99 -84
  231. package/types.js +0 -14
  232. package/types.js.map +1 -1
  233. package/utils/contentApwSettingsPlugin.js +0 -6
  234. package/utils/contentApwSettingsPlugin.js.map +1 -1
  235. package/utils/errors.js +1 -18
  236. package/utils/errors.js.map +1 -1
  237. package/utils/fieldResolver.js +5 -21
  238. package/utils/fieldResolver.js.map +1 -1
  239. package/utils/resolve.js +0 -3
  240. package/utils/resolve.js.map +1 -1
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendChangeRequestNotification = void 0;
7
+ var _lastChangeRequestNotificationPlugin = require("./lastChangeRequestNotificationPlugin");
8
+ const sendChangeRequestNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const changeRequestPlugin = (0, _lastChangeRequestNotificationPlugin.getLastChangeRequestNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!changeRequestPlugin) {
22
+ console.log("No e-mail body change request plugin.");
23
+ return;
24
+ }
25
+ const body = changeRequestPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new change request on the Content Review you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendChangeRequestNotification = sendChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendChangeRequestNotification","params","context","reviewers","contentReview","length","changeRequestPlugin","getLastChangeRequestNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendChangeRequestNotification.ts"],"sourcesContent":["import { getLastChangeRequestNotificationPlugin } from \"./lastChangeRequestNotificationPlugin\";\nimport { ApwChangeRequestNotificationCbParams } from \"~/ApwChangeRequestNotification\";\n\nexport const sendChangeRequestNotification = async (\n params: ApwChangeRequestNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const changeRequestPlugin = getLastChangeRequestNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!changeRequestPlugin) {\n console.log(\"No e-mail body change request plugin.\");\n return;\n }\n\n const body = changeRequestPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new change request on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,6BAA6B,GAAG,MACzCC,MAA4C,IAC5B;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,mBAAmB,GAAG,IAAAC,2EAAsC,EAAC;IAC/DL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,mBAAmB,EAAE;IACtBI,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;IACpD;EACJ;EAEA,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAAM,CAACZ,MAAM,CAAC;EAC/C,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAC,CAAC;IACzF;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,0EAA0E;IACnFC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApwCommentNotificationCbParams } from "../../../ApwCommentNotification";
2
+ export declare const sendCommentNotification: (params: ApwCommentNotificationCbParams) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendCommentNotification = void 0;
7
+ var _lastCommentNotificationPlugin = require("./lastCommentNotificationPlugin");
8
+ const sendCommentNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const commentPlugin = (0, _lastCommentNotificationPlugin.getLastCommentNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!commentPlugin) {
22
+ console.log("No e-mail body comment plugin.");
23
+ return;
24
+ }
25
+ const body = commentPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new comment on the Content Review you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendCommentNotification = sendCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendCommentNotification","params","context","reviewers","contentReview","length","commentPlugin","getLastCommentNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendCommentNotification.ts"],"sourcesContent":["import { getLastCommentNotificationPlugin } from \"./lastCommentNotificationPlugin\";\nimport { ApwCommentNotificationCbParams } from \"~/ApwCommentNotification\";\n\nexport const sendCommentNotification = async (\n params: ApwCommentNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const commentPlugin = getLastCommentNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!commentPlugin) {\n console.log(\"No e-mail body comment plugin.\");\n return;\n }\n\n const body = commentPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new comment on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,uBAAuB,GAAG,MACnCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,aAAa,GAAG,IAAAC,+DAAgC,EAAC;IACnDL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,aAAa,EAAE;IAChBI,OAAO,CAACC,GAAG,CAAC,gCAAgC,CAAC;IAC7C;EACJ;EAEA,MAAMC,IAAI,GAAGN,aAAa,CAACO,MAAM,CAACZ,MAAM,CAAC;EACzC,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,2CAA0CL,aAAa,CAACQ,IAAK,EAAC,CAAC;IAC5E;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,mEAAmE;IAC5EC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApwContentReviewNotificationCbParams } from "../../../ApwContentReviewNotification";
2
+ export declare const sendContentReviewNotification: (params: ApwContentReviewNotificationCbParams) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendContentReviewNotification = void 0;
7
+ var _lastContentReviewNotificationPlugin = require("./lastContentReviewNotificationPlugin");
8
+ const sendContentReviewNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const contentReviewPlugin = (0, _lastContentReviewNotificationPlugin.getLastContentReviewNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!contentReviewPlugin) {
22
+ console.log("No e-mail body content review plugin.");
23
+ return;
24
+ }
25
+ const body = contentReviewPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new content review which you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendContentReviewNotification = sendContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sendContentReviewNotification","params","context","reviewers","contentReview","length","contentReviewPlugin","getLastContentReviewNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify"],"sources":["sendContentReviewNotification.ts"],"sourcesContent":["import { getLastContentReviewNotificationPlugin } from \"./lastContentReviewNotificationPlugin\";\nimport { ApwContentReviewNotificationCbParams } from \"~/ApwContentReviewNotification\";\n\nexport const sendContentReviewNotification = async (\n params: ApwContentReviewNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const contentReviewPlugin = getLastContentReviewNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!contentReviewPlugin) {\n console.log(\"No e-mail body content review plugin.\");\n return;\n }\n\n const body = contentReviewPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new content review which you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,6BAA6B,GAAG,MACzCC,MAA4C,IAC5B;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,mBAAmB,GAAG,IAAAC,2EAAsC,EAAC;IAC/DL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,mBAAmB,EAAE;IACtBI,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;IACpD;EACJ;EAEA,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAAM,CAACZ,MAAM,CAAC;EAC/C,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAC,CAAC;IACzF;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,0DAA0D;IACnEC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAAC"}
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.updatePendingChangeRequestsCount = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _utils = require("../utils");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
10
  const updatePendingChangeRequests = async ({
19
11
  contentReviewMethods,
20
12
  step,
@@ -28,19 +20,18 @@ const updatePendingChangeRequests = async ({
28
20
  contentReviewMethods,
29
21
  id,
30
22
  getNewContentReviewData: data => {
31
- return _objectSpread(_objectSpread({}, data), {}, {
32
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
23
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
24
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
33
25
  pendingChangeRequests: step.pendingChangeRequests + delta
34
26
  }))
35
27
  });
36
28
  }
37
29
  });
38
30
  };
39
-
40
31
  const updatePendingChangeRequestsCount = ({
41
32
  apw
42
33
  }) => {
43
- apw.changeRequest.onAfterChangeRequestDelete.subscribe(async ({
34
+ apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({
44
35
  changeRequest
45
36
  }) => {
46
37
  /**
@@ -54,15 +45,13 @@ const updatePendingChangeRequestsCount = ({
54
45
  * After a "changeRequest" is deleted, decrement the "pendingChangeRequests" count
55
46
  * in the corresponding step of the content review entry.
56
47
  */
57
-
58
-
59
48
  await updatePendingChangeRequests({
60
49
  contentReviewMethods: apw.contentReview,
61
50
  step: changeRequest.step,
62
51
  delta: -1
63
52
  });
64
53
  });
65
- apw.changeRequest.onAfterChangeRequestCreate.subscribe(async ({
54
+ apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
66
55
  changeRequest
67
56
  }) => {
68
57
  /**
@@ -75,7 +64,7 @@ const updatePendingChangeRequestsCount = ({
75
64
  delta: 1
76
65
  });
77
66
  });
78
- apw.changeRequest.onAfterChangeRequestUpdate.subscribe(async ({
67
+ apw.changeRequest.onChangeRequestAfterUpdate.subscribe(async ({
79
68
  changeRequest,
80
69
  original
81
70
  }) => {
@@ -94,5 +83,4 @@ const updatePendingChangeRequestsCount = ({
94
83
  }
95
84
  });
96
85
  };
97
-
98
86
  exports.updatePendingChangeRequestsCount = updatePendingChangeRequestsCount;
@@ -1 +1 @@
1
- {"version":3,"names":["updatePendingChangeRequests","contentReviewMethods","step","delta","id","stepId","extractContentReviewIdAndStep","updateContentReview","getNewContentReviewData","data","steps","updateContentReviewStep","pendingChangeRequests","updatePendingChangeRequestsCount","apw","changeRequest","onAfterChangeRequestDelete","subscribe","resolved","contentReview","onAfterChangeRequestCreate","onAfterChangeRequestUpdate","original"],"sources":["updatePendingChangeRequests.ts"],"sourcesContent":["import { ApwChangeRequest, ApwContentReviewCrud, LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\ninterface UpdatePendingChangeRequestsParams {\n contentReviewMethods: ApwContentReviewCrud;\n delta: number;\n step: ApwChangeRequest[\"step\"];\n}\n\nconst updatePendingChangeRequests = async ({\n contentReviewMethods,\n step,\n delta\n}: UpdatePendingChangeRequestsParams): Promise<void> => {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n pendingChangeRequests: step.pendingChangeRequests + delta\n }))\n };\n }\n });\n};\n\nexport const updatePendingChangeRequestsCount = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onAfterChangeRequestDelete.subscribe(async ({ changeRequest }) => {\n /**\n * If the deleted changeRequest was marked as resolved. We don't need to do anything here,\n * because \"pendingChangeRequests has been already updated in \"onAfterChangeRequestUpdate\" hook.\n */\n if (changeRequest.resolved === true) {\n return;\n }\n /**\n * After a \"changeRequest\" is deleted, decrement the \"pendingChangeRequests\" count\n * in the corresponding step of the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: -1\n });\n });\n\n apw.changeRequest.onAfterChangeRequestCreate.subscribe(async ({ changeRequest }) => {\n /**\n * After a \"changeRequest\" is created, increment the \"pendingChangeRequests\" count\n * of the corresponding step in the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: 1\n });\n });\n\n apw.changeRequest.onAfterChangeRequestUpdate.subscribe(async ({ changeRequest, original }) => {\n /**\n * After a \"changeRequest\" is created, and the value of \"resolved\" field has changed;\n * then we also need to update the \"pendingChangeRequests\" count of the corresponding step in the content review entry.\n */\n if (original.resolved !== changeRequest.resolved) {\n const resolved = changeRequest.resolved;\n const delta = resolved === true ? -1 : 1;\n\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;;;;;AAYA,MAAMA,2BAA2B,GAAG,OAAO;EACvCC,oBADuC;EAEvCC,IAFuC;EAGvCC;AAHuC,CAAP,KAIoB;EACpD,MAAM;IAAEC,EAAF;IAAMC;EAAN,IAAiB,IAAAC,oCAAA,EAA8BJ,IAA9B,CAAvB;EAEA,MAAM,IAAAK,0BAAA,EAAoB;IACtBN,oBADsB;IAEtBG,EAFsB;I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AACG,QAA/B;MACA,MAAMf,KAAK,GAAGe,QAAQ,KAAK,IAAb,GAAoB,CAAC,CAArB,GAAyB,CAAvC;MAEA,MAAMlB,2BAA2B,CAAC;QAC9BC,oBAAoB,EAAEa,GAAG,CAACK,aADI;QAE9BjB,IAAI,EAAEa,aAAa,CAACb,IAFU;QAG9BC;MAH8B,CAAD,CAAjC;IAKH;EACJ,CAfD;AAgBH,CAlDM"}
1
+ {"version":3,"names":["updatePendingChangeRequests","contentReviewMethods","step","delta","id","stepId","extractContentReviewIdAndStep","updateContentReview","getNewContentReviewData","data","steps","updateContentReviewStep","pendingChangeRequests","updatePendingChangeRequestsCount","apw","changeRequest","onChangeRequestAfterDelete","subscribe","resolved","contentReview","onChangeRequestAfterCreate","onChangeRequestAfterUpdate","original"],"sources":["updatePendingChangeRequests.ts"],"sourcesContent":["import { ApwChangeRequest, ApwContentReviewCrud, LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\ninterface UpdatePendingChangeRequestsParams {\n contentReviewMethods: ApwContentReviewCrud;\n delta: number;\n step: ApwChangeRequest[\"step\"];\n}\n\nconst updatePendingChangeRequests = async ({\n contentReviewMethods,\n step,\n delta\n}: UpdatePendingChangeRequestsParams): Promise<void> => {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n pendingChangeRequests: step.pendingChangeRequests + delta\n }))\n };\n }\n });\n};\n\nexport const updatePendingChangeRequestsCount = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * If the deleted changeRequest was marked as resolved. We don't need to do anything here,\n * because \"pendingChangeRequests has been already updated in \"onAfterChangeRequestUpdate\" hook.\n */\n if (changeRequest.resolved === true) {\n return;\n }\n /**\n * After a \"changeRequest\" is deleted, decrement the \"pendingChangeRequests\" count\n * in the corresponding step of the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: -1\n });\n });\n\n apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({ changeRequest }) => {\n /**\n * After a \"changeRequest\" is created, increment the \"pendingChangeRequests\" count\n * of the corresponding step in the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: 1\n });\n });\n\n apw.changeRequest.onChangeRequestAfterUpdate.subscribe(async ({ changeRequest, original }) => {\n /**\n * After a \"changeRequest\" is created, and the value of \"resolved\" field has changed;\n * then we also need to update the \"pendingChangeRequests\" count of the corresponding step in the content review entry.\n */\n if (original.resolved !== changeRequest.resolved) {\n const resolved = changeRequest.resolved;\n const delta = resolved === true ? -1 : 1;\n\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AACA;AAYA,MAAMA,2BAA2B,GAAG,OAAO;EACvCC,oBAAoB;EACpBC,IAAI;EACJC;AAC+B,CAAC,KAAoB;EACpD,MAAM;IAAEC,EAAE;IAAEC;EAAO,CAAC,GAAG,IAAAC,oCAA6B,EAACJ,IAAI,CAAC;EAE1D,MAAM,IAAAK,0BAAmB,EAAC;IACtBN,oBAAoB;IACpBG,EAAE;IACFI,uBAAuB,EAAEC,IAAI,IAAI;MAC7B,mEACOA,IAAI;QACPC,KAAK,EAAE,IAAAC,8BAAuB,EAACF,IAAI,CAACC,KAAK,EAAEL,MAAM,EAAEH,IAAI,gEAChDA,IAAI;UACPU,qBAAqB,EAAEV,IAAI,CAACU,qBAAqB,GAAGT;QAAK,EAC3D;MAAC;IAEX;EACJ,CAAC,CAAC;AACN,CAAC;AAEM,MAAMU,gCAAgC,GAAG,CAAC;EAC7CC;AACsC,CA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+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.updateTotalCommentsCount = exports.updateLatestCommentId = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _utils = require("../utils");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
10
  const updateTotalCommentsCount = ({
19
11
  apw
20
12
  }) => {
21
- apw.comment.onAfterCommentDelete.subscribe(async ({
13
+ apw.comment.onCommentAfterDelete.subscribe(async ({
22
14
  comment
23
15
  }) => {
24
16
  const {
@@ -28,7 +20,6 @@ const updateTotalCommentsCount = ({
28
20
  * After a "comment" is deleted, decrement the "totalComments" count
29
21
  * in the corresponding step of the content review entry.
30
22
  */
31
-
32
23
  if (step) {
33
24
  const {
34
25
  id,
@@ -38,8 +29,8 @@ const updateTotalCommentsCount = ({
38
29
  contentReviewMethods: apw.contentReview,
39
30
  id,
40
31
  getNewContentReviewData: data => {
41
- return _objectSpread(_objectSpread({}, data), {}, {
42
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
32
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
33
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
43
34
  totalComments: step.totalComments - 1
44
35
  }))
45
36
  });
@@ -47,7 +38,7 @@ const updateTotalCommentsCount = ({
47
38
  });
48
39
  }
49
40
  });
50
- apw.comment.onAfterCommentCreate.subscribe(async ({
41
+ apw.comment.onCommentAfterCreate.subscribe(async ({
51
42
  comment
52
43
  }) => {
53
44
  /**
@@ -62,8 +53,8 @@ const updateTotalCommentsCount = ({
62
53
  contentReviewMethods: apw.contentReview,
63
54
  id,
64
55
  getNewContentReviewData: data => {
65
- return _objectSpread(_objectSpread({}, data), {}, {
66
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
56
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
57
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
67
58
  totalComments: step.totalComments + 1
68
59
  }))
69
60
  });
@@ -71,13 +62,11 @@ const updateTotalCommentsCount = ({
71
62
  });
72
63
  });
73
64
  };
74
-
75
65
  exports.updateTotalCommentsCount = updateTotalCommentsCount;
76
-
77
66
  const updateLatestCommentId = ({
78
67
  apw
79
68
  }) => {
80
- apw.comment.onAfterCommentCreate.subscribe(async ({
69
+ apw.comment.onCommentAfterCreate.subscribe(async ({
81
70
  comment
82
71
  }) => {
83
72
  /**
@@ -91,13 +80,13 @@ const updateLatestCommentId = ({
91
80
  contentReviewMethods: apw.contentReview,
92
81
  id,
93
82
  getNewContentReviewData: contentReview => {
94
- return _objectSpread(_objectSpread({}, contentReview), {}, {
83
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
95
84
  latestCommentId: comment.id
96
85
  });
97
86
  }
98
87
  });
99
88
  });
100
- apw.comment.onAfterCommentUpdate.subscribe(async ({
89
+ apw.comment.onCommentAfterUpdate.subscribe(async ({
101
90
  comment
102
91
  }) => {
103
92
  /**
@@ -111,13 +100,13 @@ const updateLatestCommentId = ({
111
100
  contentReviewMethods: apw.contentReview,
112
101
  id,
113
102
  getNewContentReviewData: contentReview => {
114
- return _objectSpread(_objectSpread({}, contentReview), {}, {
103
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
115
104
  latestCommentId: comment.id
116
105
  });
117
106
  }
118
107
  });
119
108
  });
120
- apw.comment.onAfterCommentDelete.subscribe(async ({
109
+ apw.comment.onCommentAfterDelete.subscribe(async ({
121
110
  comment
122
111
  }) => {
123
112
  /**
@@ -131,7 +120,6 @@ const updateLatestCommentId = ({
131
120
  id,
132
121
  contentReviewMethods: apw.contentReview
133
122
  });
134
-
135
123
  if (contentReview && contentReview.latestCommentId === comment.id) {
136
124
  const [[latestComment]] = await apw.comment.list({
137
125
  where: {
@@ -145,7 +133,7 @@ const updateLatestCommentId = ({
145
133
  contentReviewMethods: apw.contentReview,
146
134
  id,
147
135
  getNewContentReviewData: contentReview => {
148
- return _objectSpread(_objectSpread({}, contentReview), {}, {
136
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
149
137
  latestCommentId: latestComment ? latestComment.id : null
150
138
  });
151
139
  }
@@ -153,5 +141,4 @@ const updateLatestCommentId = ({
153
141
  }
154
142
  });
155
143
  };
156
-
157
144
  exports.updateLatestCommentId = updateLatestCommentId;
@@ -1 +1 @@
1
- {"version":3,"names":["updateTotalCommentsCount","apw","comment","onAfterCommentDelete","subscribe","step","id","stepId","extractContentReviewIdAndStep","updateContentReview","contentReviewMethods","contentReview","getNewContentReviewData","data","steps","updateContentReviewStep","totalComments","onAfterCommentCreate","updateLatestCommentId","latestCommentId","onAfterCommentUpdate","safelyGetContentReview","latestComment","list","where","changeRequest","sort"],"sources":["updateTotalComments.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n safelyGetContentReview,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\nexport const updateTotalCommentsCount = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onAfterCommentDelete.subscribe(async ({ comment }) => {\n const { step } = comment;\n /**\n * After a \"comment\" is deleted, decrement the \"totalComments\" count\n * in the corresponding step of the content review entry.\n */\n if (step) {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments - 1\n }))\n };\n }\n });\n }\n });\n\n apw.comment.onAfterCommentCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, increment the \"totalComments\" count\n * of the corresponding step in the content review entry.\n */\n const { id, stepId } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments + 1\n }))\n };\n }\n });\n });\n};\n\nexport const updateLatestCommentId = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onAfterCommentCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onAfterCommentUpdate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onAfterCommentDelete.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n const contentReview = await safelyGetContentReview({\n id,\n contentReviewMethods: apw.contentReview\n });\n\n if (contentReview && contentReview.latestCommentId === comment.id) {\n const [[latestComment]] = await apw.comment.list({\n where: { changeRequest: { id: comment.changeRequest } },\n sort: [\"createdOn_DESC\"]\n });\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: latestComment ? latestComment.id : null\n };\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;;;;;AAOO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAC3FA,GAAG,CAACC,OAAJ,CAAYC,oBAAZ,CAAiCC,SAAjC,CAA2C,OAAO;IAAEF;EAAF,CAAP,KAAuB;IAC9D,MAAM;MAAEG;IAAF,IAAWH,OAAjB;IACA;AACR;AACA;AACA;;IACQ,IAAIG,IAAJ,EAAU;MACN,MAAM;QAAEC,EAAF;QAAMC;MAAN,IAAiB,IAAAC,oCAAA,EAA8BH,IAA9B,CAAvB;MAEA,MAAM,IAAAI,0BAAA,EAAoB;QACtBC,oBAAoB,EAAET,GAAG,CAACU,aADJ;QAEtBL,EAFsB;QAGtBM,uBAAuB,EAAEC,IAAI,IAAI;UAC7B,uCACOA,IADP;YAEIC,KAAK,EAAE,IAAAC,8BAAA,EAAwBF,IAAI,CAACC,KAA7B,EAAoCP,MAApC,EAA4CF,IAAI,oCAChDA,IADgD;cAEnDW,aAAa,EAAEX,IAAI,CAACW,aAAL,GAAqB;YAFe,EAAhD;UAFX;QAOH;MAXqB,CAApB,CAAN;IA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","apw","comment","onCommentAfterDelete","subscribe","step","id","stepId","extractContentReviewIdAndStep","updateContentReview","contentReviewMethods","contentReview","getNewContentReviewData","data","steps","updateContentReviewStep","totalComments","onCommentAfterCreate","updateLatestCommentId","latestCommentId","onCommentAfterUpdate","safelyGetContentReview","latestComment","list","where","changeRequest","sort"],"sources":["updateTotalComments.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n safelyGetContentReview,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\nexport const updateTotalCommentsCount = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n const { step } = comment;\n /**\n * After a \"comment\" is deleted, decrement the \"totalComments\" count\n * in the corresponding step of the content review entry.\n */\n if (step) {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments - 1\n }))\n };\n }\n });\n }\n });\n\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, increment the \"totalComments\" count\n * of the corresponding step in the content review entry.\n */\n const { id, stepId } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments + 1\n }))\n };\n }\n });\n });\n};\n\nexport const updateLatestCommentId = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterUpdate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n const contentReview = await safelyGetContentReview({\n id,\n contentReviewMethods: apw.contentReview\n });\n\n if (contentReview && contentReview.latestCommentId === comment.id) {\n const [[latestComment]] = await apw.comment.list({\n where: { changeRequest: { id: comment.changeRequest } },\n sort: [\"createdOn_DESC\"]\n });\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: latestComment ? latestComment.id : null\n };\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AACA;AAOO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EAC3FA,GAAG,CAACC,OAAO,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAQ,CAAC,KAAK;IAC9D,MAAM;MAAEG;IAAK,CAAC,GAAGH,OAAO;IACxB;AACR;AACA;AACA;IACQ,IAAIG,IAAI,EAAE;MACN,MAAM;QAAEC,EAAE;QAAEC;MAAO,CAAC,GAAG,IAAAC,oCAA6B,EAACH,IAAI,CAAC;MAE1D,MAAM,IAAAI,0BAAmB,EAAC;QACtBC,oBAAoB,EAAET,GAAG,CAACU,aAAa;QACvCL,EAAE;QACFM,uBAAuB,EAAEC,IAAI,IAAI;UAC7B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AChBQ,eAAe,EAAEG,aAAa,GAAGA,aAAa,CAAChB,EAAE,GAAG;UAAI;QAEhE;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.validateChangeRequest = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _handlerGraphql = require("@webiny/handler-graphql");
13
-
10
+ var _utils = require("../utils");
11
+ var _utils2 = require("@webiny/utils");
14
12
  const validateChangeRequest = ({
15
13
  apw
16
14
  }) => {
17
- apw.changeRequest.onBeforeChangeRequestCreate.subscribe(async ({
15
+ apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({
18
16
  input
19
17
  }) => {
20
18
  const {
@@ -23,9 +21,14 @@ const validateChangeRequest = ({
23
21
  /**
24
22
  * We need step to be in a particular format i.e. "contentReviewId#version#stepId"
25
23
  */
26
-
27
- const [entryId, version, stepId] = step.split("#");
28
-
24
+ const {
25
+ id: revisionId,
26
+ stepId
27
+ } = (0, _utils.extractContentReviewIdAndStep)(step);
28
+ const {
29
+ id: entryId,
30
+ version
31
+ } = (0, _utils2.parseIdentifier)(revisionId);
29
32
  if (!entryId || !version || !stepId) {
30
33
  throw new _error.default(`The step property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_STEP", {
31
34
  step
@@ -34,24 +37,31 @@ const validateChangeRequest = ({
34
37
  /**
35
38
  * Check whether a contentReview entry exists with provided id.
36
39
  */
37
-
38
-
39
- const revisionId = `${entryId}#${version}`;
40
- const contentReview = await apw.contentReview.get(revisionId);
41
-
40
+ let contentReview = undefined;
41
+ try {
42
+ contentReview = await apw.contentReview.get(revisionId);
43
+ } catch (ex) {
44
+ /**
45
+ * There is no need to output the log if this is the test environment.
46
+ */
47
+ if (process.env.NODE_ENV !== "test") {
48
+ console.log({
49
+ message: ex.message,
50
+ code: ex.data,
51
+ data: ex.data
52
+ });
53
+ }
54
+ }
42
55
  if (!contentReview) {
43
56
  throw new _handlerGraphql.NotFoundError(`Unable to found "ContentReview" with given id "${revisionId}"`);
44
57
  }
45
58
  /**
46
59
  * Don't allow "change request" creation once the sign-off has been provided.
47
60
  */
48
-
49
-
50
61
  const {
51
62
  steps
52
63
  } = contentReview;
53
64
  const currentStep = steps.find(step => step.id === stepId);
54
-
55
65
  if (currentStep && currentStep.signOffProvidedOn) {
56
66
  throw new _error.default(`Please retract the sign-off before opening a new change request.`, "SIGN_OFF_PROVIDED", {
57
67
  step: currentStep,
@@ -60,5 +70,4 @@ const validateChangeRequest = ({
60
70
  }
61
71
  });
62
72
  };
63
-
64
73
  exports.validateChangeRequest = validateChangeRequest;
@@ -1 +1 @@
1
- {"version":3,"names":["validateChangeRequest","apw","changeRequest","onBeforeChangeRequestCreate","subscribe","input","step","entryId","version","stepId","split","WebinyError","revisionId","contentReview","get","NotFoundError","steps","currentStep","find","id","signOffProvidedOn"],"sources":["validateChangeRequest.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateChangeRequest = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onBeforeChangeRequestCreate.subscribe(async ({ input }) => {\n const { step } = input;\n /**\n * We need step to be in a particular format i.e. \"contentReviewId#version#stepId\"\n */\n const [entryId, version, stepId] = step.split(\"#\");\n if (!entryId || !version || !stepId) {\n throw new WebinyError(\n `The step property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_STEP\",\n {\n step\n }\n );\n }\n /**\n * Check whether a contentReview entry exists with provided id.\n */\n const revisionId = `${entryId}#${version}`;\n\n const contentReview = await apw.contentReview.get(revisionId);\n if (!contentReview) {\n throw new NotFoundError(\n `Unable to found \"ContentReview\" with given id \"${revisionId}\"`\n );\n }\n /**\n * Don't allow \"change request\" creation once the sign-off has been provided.\n */\n const { steps } = contentReview;\n const currentStep = steps.find(step => step.id === stepId);\n\n if (currentStep && currentStep.signOffProvidedOn) {\n throw new WebinyError(\n `Please retract the sign-off before opening a new change request.`,\n \"SIGN_OFF_PROVIDED\",\n {\n step: currentStep,\n stepId: stepId\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAWD,KAAjB;IACA;AACR;AACA;;IACQ,MAAM,CAACE,OAAD,EAAUC,OAAV,EAAmBC,MAAnB,IAA6BH,IAAI,CAACI,KAAL,CAAW,GAAX,CAAnC;;IACA,IAAI,CAACH,OAAD,IAAY,CAACC,OAAb,IAAwB,CAACC,MAA7B,EAAqC;MACjC,MAAM,IAAIE,cAAJ,CACD,uDADC,EAEF,+BAFE,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;IACD;AACR;AACA;;;IACQ,MAAMM,UAAU,GAAI,GAAEL,OAAQ,IAAGC,OAAQ,EAAzC;IAEA,MAAMK,aAAa,GAAG,MAAMZ,GAAG,CAACY,aAAJ,CAAkBC,GAAlB,CAAsBF,UAAtB,CAA5B;;IACA,IAAI,CAACC,aAAL,EAAoB;MAChB,MAAM,IAAIE,6BAAJ,CACD,kDAAiDH,UAAW,GAD3D,CAAN;IAGH;IACD;AACR;AACA;;;IACQ,MAAM;MAAEI;IAAF,IAAYH,aAAlB;IACA,MAAMI,WAAW,GAAGD,KAAK,CAACE,IAAN,CAAWZ,IAAI,IAAIA,IAAI,CAACa,EAAL,KAAYV,MAA/B,CAApB;;IAEA,IAAIQ,WAAW,IAAIA,WAAW,CAACG,iBAA/B,EAAkD;MAC9C,MAAM,IAAIT,cAAJ,CACD,kEADC,EAEF,mBAFE,EAGF;QACIL,IAAI,EAAEW,WADV;QAEIR,MAAM,EAAEA;MAFZ,CAHE,CAAN;IAQH;EACJ,CA1CD;AA2CH,CA5CM"}
1
+ {"version":3,"names":["validateChangeRequest","apw","changeRequest","onChangeRequestBeforeCreate","subscribe","input","step","id","revisionId","stepId","extractContentReviewIdAndStep","entryId","version","parseIdentifier","WebinyError","contentReview","undefined","get","ex","process","env","NODE_ENV","console","log","message","code","data","NotFoundError","steps","currentStep","find","signOffProvidedOn"],"sources":["validateChangeRequest.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ApwContentReview, LifeCycleHookCallbackParams } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const validateChangeRequest = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({ input }) => {\n const { step } = input;\n /**\n * We need step to be in a particular format i.e. \"contentReviewId#version#stepId\"\n */\n const { id: revisionId, stepId } = extractContentReviewIdAndStep(step);\n\n const { id: entryId, version } = parseIdentifier(revisionId);\n if (!entryId || !version || !stepId) {\n throw new WebinyError(\n `The step property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_STEP\",\n {\n step\n }\n );\n }\n /**\n * Check whether a contentReview entry exists with provided id.\n */\n let contentReview: ApwContentReview | undefined = undefined;\n try {\n contentReview = await apw.contentReview.get(revisionId);\n } catch (ex) {\n /**\n * There is no need to output the log if this is the test environment.\n */\n if (process.env.NODE_ENV !== \"test\") {\n console.log({\n message: ex.message,\n code: ex.data,\n data: ex.data\n });\n }\n }\n if (!contentReview) {\n throw new NotFoundError(\n `Unable to found \"ContentReview\" with given id \"${revisionId}\"`\n );\n }\n /**\n * Don't allow \"change request\" creation once the sign-off has been provided.\n */\n const { steps } = contentReview;\n const currentStep = steps.find(step => step.id === stepId);\n\n if (currentStep && currentStep.signOffProvidedOn) {\n throw new WebinyError(\n `Please retract the sign-off before opening a new change request.`,\n \"SIGN_OFF_PROVIDED\",\n {\n step: currentStep,\n stepId: stepId\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AAEO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EACxFA,GAAG,CAACC,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACzE,MAAM;MAAEC;IAAK,CAAC,GAAGD,KAAK;IACtB;AACR;AACA;IACQ,MAAM;MAAEE,EAAE,EAAEC,UAAU;MAAEC;IAAO,CAAC,GAAG,IAAAC,oCAA6B,EAACJ,IAAI,CAAC;IAEtE,MAAM;MAAEC,EAAE,EAAEI,OAAO;MAAEC;IAAQ,CAAC,GAAG,IAAAC,uBAAe,EAACL,UAAU,CAAC;IAC5D,IAAI,CAACG,OAAO,IAAI,CAACC,OAAO,IAAI,CAACH,MAAM,EAAE;MACjC,MAAM,IAAIK,cAAW,CAChB,uDAAsD,EACvD,+BAA+B,EAC/B;QACIR;MACJ,CAAC,CACJ;IACL;IACA;AACR;AACA;IACQ,IAAIS,aAA2C,GAAGC,SAAS;IAC3D,IAAI;MACAD,aAAa,GAAG,MAAMd,GAAG,CAACc,aAAa,CAACE,GAAG,CAACT,UAAU,CAAC;IAC3D,CAAC,CAAC,OAAOU,EAAE,EAAE;MACT;AACZ;AACA;MACY,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,EAAE;QACjCC,OAAO,CAACC,GAAG,CAAC;UACRC,OAAO,EAAEN,EAAE,CAACM,OAAO;UACnBC,IAAI,EAAEP,EAAE,CAACQ,IAAI;UACbA,IAAI,EAAER,EAAE,CAACQ;QACb,CAAC,CAAC;MACN;IACJ;IACA,IAAI,CAACX,aAAa,EAAE;MAChB,MAAM,IAAIY,6BAAa,CAClB,kDAAiDnB,UAAW,GAAE,CAClE;IACL;IACA;AACR;AACA;IACQ,MAAM;MAAEoB;IAAM,CAAC,GAAGb,aAAa;IAC/B,MAAMc,WAAW,GAAGD,KAAK,CAACE,IAAI,CAACxB,IAAI,IAAIA,IAAI,CAACC,EAAE,KAAKE,MAAM,CAAC;IAE1D,IAAIoB,WAAW,IAAIA,WAAW,CAACE,iBAAiB,EAAE;MAC9C,MAAM,IAAIjB,cAAW,CAChB,kEAAiE,EAClE,mBAAmB,EACnB;QACIR,IAAI,EAAEuB,WAAW;QACjBpB,MAAM,EAAEA;MACZ,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.validateComment = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
9
+ var _utils = require("@webiny/utils");
12
10
  const validateComment = ({
13
11
  apw
14
12
  }) => {
15
- apw.comment.onBeforeCommentCreate.subscribe(async ({
13
+ apw.comment.onCommentBeforeCreate.subscribe(async ({
16
14
  input
17
15
  }) => {
18
16
  const {
@@ -21,27 +19,28 @@ const validateComment = ({
21
19
  /**
22
20
  * We need changeRequest to be in a particular format i.e. "contentReviewUniqueId#version"
23
21
  */
24
-
25
- const [entryId, version] = changeRequestId.split("#");
26
-
27
- if (!entryId || !version) {
22
+ let result;
23
+ try {
24
+ result = (0, _utils.parseIdentifier)(changeRequestId);
25
+ if (!result) {
26
+ throw new _error.default("Could not parse changeRequestId.", "MALFORMED_CHANGE_REQUEST_ID", {
27
+ changeRequestId
28
+ });
29
+ }
30
+ } catch (ex) {
28
31
  throw new _error.default(`The"changeRequest" property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_ID", {
29
32
  input
30
33
  });
31
34
  }
35
+
32
36
  /**
33
37
  * Assign value for "step" field from "changeRequest".
34
38
  */
35
-
36
-
37
39
  const changeRequest = await apw.changeRequest.get(changeRequestId);
38
-
39
40
  if (!changeRequest) {
40
41
  return;
41
42
  }
42
-
43
43
  input.step = changeRequest.step;
44
44
  });
45
45
  };
46
-
47
46
  exports.validateComment = validateComment;