@webiny/api-apw 0.0.0-ee-vpcs.549378cf03

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 (316) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +40 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +40 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +40 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +40 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.d.ts +10 -0
  14. package/ContentApwSettingsPlugin.js +17 -0
  15. package/ContentApwSettingsPlugin.js.map +1 -0
  16. package/LICENSE +21 -0
  17. package/README.md +34 -0
  18. package/crud/createChangeRequestMethods.d.ts +2 -0
  19. package/crud/createChangeRequestMethods.js +98 -0
  20. package/crud/createChangeRequestMethods.js.map +1 -0
  21. package/crud/createCommentMethods.d.ts +2 -0
  22. package/crud/createCommentMethods.js +99 -0
  23. package/crud/createCommentMethods.js.map +1 -0
  24. package/crud/createContentReviewMethods.d.ts +10 -0
  25. package/crud/createContentReviewMethods.js +562 -0
  26. package/crud/createContentReviewMethods.js.map +1 -0
  27. package/crud/createReviewerMethods.d.ts +2 -0
  28. package/crud/createReviewerMethods.js +99 -0
  29. package/crud/createReviewerMethods.js.map +1 -0
  30. package/crud/createWorkflowMethods.d.ts +2 -0
  31. package/crud/createWorkflowMethods.js +118 -0
  32. package/crud/createWorkflowMethods.js.map +1 -0
  33. package/crud/index.d.ts +2 -0
  34. package/crud/index.js +96 -0
  35. package/crud/index.js.map +1 -0
  36. package/crud/utils.d.ts +21 -0
  37. package/crud/utils.js +138 -0
  38. package/crud/utils.js.map +1 -0
  39. package/index.d.ts +4 -0
  40. package/index.js +38 -0
  41. package/index.js.map +1 -0
  42. package/package.json +76 -0
  43. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
  44. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
  45. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
  46. package/plugins/cms/README.md +49 -0
  47. package/plugins/cms/apwEntryPlugins.d.ts +8 -0
  48. package/plugins/cms/apwEntryPlugins.js +46 -0
  49. package/plugins/cms/apwEntryPlugins.js.map +1 -0
  50. package/plugins/cms/index.d.ts +12 -0
  51. package/plugins/cms/index.js +45 -0
  52. package/plugins/cms/index.js.map +1 -0
  53. package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
  54. package/plugins/cms/linkContentReviewToEntry.js +108 -0
  55. package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
  56. package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
  57. package/plugins/cms/linkWorkflowToEntry.js +166 -0
  58. package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
  59. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  60. package/plugins/cms/notifications/changeRequestNotification.js +35 -0
  61. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  62. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  63. package/plugins/cms/notifications/commentNotification.js +35 -0
  64. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  65. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  66. package/plugins/cms/notifications/contentReviewNotification.js +35 -0
  67. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  68. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  69. package/plugins/cms/notifications/contentUrl.js +60 -0
  70. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  71. package/plugins/cms/triggerContentReview.d.ts +8 -0
  72. package/plugins/cms/triggerContentReview.js +59 -0
  73. package/plugins/cms/triggerContentReview.js.map +1 -0
  74. package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
  75. package/plugins/cms/updateContentReviewStatus.js +97 -0
  76. package/plugins/cms/updateContentReviewStatus.js.map +1 -0
  77. package/plugins/cms/utils.d.ts +27 -0
  78. package/plugins/cms/utils.js +207 -0
  79. package/plugins/cms/utils.js.map +1 -0
  80. package/plugins/context.d.ts +5 -0
  81. package/plugins/context.js +146 -0
  82. package/plugins/context.js.map +1 -0
  83. package/plugins/graphql/changeRequest.gql.d.ts +4 -0
  84. package/plugins/graphql/changeRequest.gql.js +155 -0
  85. package/plugins/graphql/changeRequest.gql.js.map +1 -0
  86. package/plugins/graphql/comment.gql.d.ts +4 -0
  87. package/plugins/graphql/comment.gql.js +160 -0
  88. package/plugins/graphql/comment.gql.js.map +1 -0
  89. package/plugins/graphql/contentReview.gql.d.ts +4 -0
  90. package/plugins/graphql/contentReview.gql.js +382 -0
  91. package/plugins/graphql/contentReview.gql.js.map +1 -0
  92. package/plugins/graphql/reviewer.gql.d.ts +4 -0
  93. package/plugins/graphql/reviewer.gql.js +116 -0
  94. package/plugins/graphql/reviewer.gql.js.map +1 -0
  95. package/plugins/graphql/workflow.gql.d.ts +4 -0
  96. package/plugins/graphql/workflow.gql.js +205 -0
  97. package/plugins/graphql/workflow.gql.js.map +1 -0
  98. package/plugins/graphql.d.ts +4 -0
  99. package/plugins/graphql.js +95 -0
  100. package/plugins/graphql.js.map +1 -0
  101. package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
  102. package/plugins/hooks/createReviewerFromIdentity.js +82 -0
  103. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
  104. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
  105. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
  106. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
  107. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
  108. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
  109. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
  110. package/plugins/hooks/index.d.ts +3 -0
  111. package/plugins/hooks/index.js +74 -0
  112. package/plugins/hooks/index.js.map +1 -0
  113. package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
  114. package/plugins/hooks/initializeContentReviewSteps.js +86 -0
  115. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
  116. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  117. package/plugins/hooks/initializeNotifications.js +20 -0
  118. package/plugins/hooks/initializeNotifications.js.map +1 -0
  119. package/plugins/hooks/listContentReviews.d.ts +10 -0
  120. package/plugins/hooks/listContentReviews.js +68 -0
  121. package/plugins/hooks/listContentReviews.js.map +1 -0
  122. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  123. package/plugins/hooks/notifications/appUrl.js +22 -0
  124. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  125. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  126. package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
  127. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  128. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  129. package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
  130. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  131. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  132. package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
  133. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  134. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  135. package/plugins/hooks/notifications/commentUrl.js +31 -0
  136. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  137. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  138. package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
  139. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  140. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  141. package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
  142. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  143. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  144. package/plugins/hooks/notifications/contentUrl.js +29 -0
  145. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  146. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  147. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
  148. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  149. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  150. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
  151. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  152. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  153. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
  154. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  155. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  156. package/plugins/hooks/notifications/reviewers.js +51 -0
  157. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  158. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  159. package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
  160. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  161. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  162. package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
  163. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  164. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  165. package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
  166. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  167. package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
  168. package/plugins/hooks/updatePendingChangeRequests.js +94 -0
  169. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
  170. package/plugins/hooks/updateTotalComments.d.ts +3 -0
  171. package/plugins/hooks/updateTotalComments.js +153 -0
  172. package/plugins/hooks/updateTotalComments.js.map +1 -0
  173. package/plugins/hooks/validateChangeRequest.d.ts +2 -0
  174. package/plugins/hooks/validateChangeRequest.js +89 -0
  175. package/plugins/hooks/validateChangeRequest.js.map +1 -0
  176. package/plugins/hooks/validateComment.d.ts +2 -0
  177. package/plugins/hooks/validateComment.js +57 -0
  178. package/plugins/hooks/validateComment.js.map +1 -0
  179. package/plugins/hooks/validateContentReview.d.ts +2 -0
  180. package/plugins/hooks/validateContentReview.js +38 -0
  181. package/plugins/hooks/validateContentReview.js.map +1 -0
  182. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
  183. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
  184. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
  185. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
  186. package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
  187. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
  188. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
  189. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
  190. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
  191. package/plugins/pageBuilder/index.d.ts +11 -0
  192. package/plugins/pageBuilder/index.js +53 -0
  193. package/plugins/pageBuilder/index.js.map +1 -0
  194. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
  195. package/plugins/pageBuilder/linkContentReviewToPage.js +105 -0
  196. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
  197. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
  198. package/plugins/pageBuilder/linkWorkflowToPage.js +194 -0
  199. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
  200. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  201. package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
  202. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  203. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  204. package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
  205. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  206. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  207. package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
  208. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  209. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  210. package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
  211. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  212. package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
  213. package/plugins/pageBuilder/triggerContentReview.js +50 -0
  214. package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
  215. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
  216. package/plugins/pageBuilder/updateContentReviewStatus.js +79 -0
  217. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
  218. package/plugins/pageBuilder/utils.d.ts +22 -0
  219. package/plugins/pageBuilder/utils.js +184 -0
  220. package/plugins/pageBuilder/utils.js.map +1 -0
  221. package/plugins/utils.d.ts +35 -0
  222. package/plugins/utils.js +187 -0
  223. package/plugins/utils.js.map +1 -0
  224. package/scheduler/createScheduleActionMethods.d.ts +2 -0
  225. package/scheduler/createScheduleActionMethods.js +149 -0
  226. package/scheduler/createScheduleActionMethods.js.map +1 -0
  227. package/scheduler/handlers/executeAction/index.d.ts +13 -0
  228. package/scheduler/handlers/executeAction/index.js +172 -0
  229. package/scheduler/handlers/executeAction/index.js.map +1 -0
  230. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
  231. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
  232. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
  233. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
  234. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
  235. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
  236. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
  237. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
  238. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
  239. package/scheduler/handlers/executeAction/security.d.ts +4 -0
  240. package/scheduler/handlers/executeAction/security.js +68 -0
  241. package/scheduler/handlers/executeAction/security.js.map +1 -0
  242. package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
  243. package/scheduler/handlers/scheduleAction/index.js +164 -0
  244. package/scheduler/handlers/scheduleAction/index.js.map +1 -0
  245. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
  246. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +172 -0
  247. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
  248. package/scheduler/handlers/utils.d.ts +33 -0
  249. package/scheduler/handlers/utils.js +168 -0
  250. package/scheduler/handlers/utils.js.map +1 -0
  251. package/scheduler/index.d.ts +2 -0
  252. package/scheduler/index.js +27 -0
  253. package/scheduler/index.js.map +1 -0
  254. package/scheduler/types.d.ts +171 -0
  255. package/scheduler/types.js +34 -0
  256. package/scheduler/types.js.map +1 -0
  257. package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
  258. package/storageOperations/changeRequestStorageOperations.js +122 -0
  259. package/storageOperations/changeRequestStorageOperations.js.map +1 -0
  260. package/storageOperations/commentStorageOperations.d.ts +3 -0
  261. package/storageOperations/commentStorageOperations.js +138 -0
  262. package/storageOperations/commentStorageOperations.js.map +1 -0
  263. package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
  264. package/storageOperations/contentReviewStorageOperations.js +93 -0
  265. package/storageOperations/contentReviewStorageOperations.js.map +1 -0
  266. package/storageOperations/index.d.ts +15 -0
  267. package/storageOperations/index.js +48 -0
  268. package/storageOperations/index.js.map +1 -0
  269. package/storageOperations/models/changeRequest.model.d.ts +3 -0
  270. package/storageOperations/models/changeRequest.model.js +59 -0
  271. package/storageOperations/models/changeRequest.model.js.map +1 -0
  272. package/storageOperations/models/comment.model.d.ts +7 -0
  273. package/storageOperations/models/comment.model.js +60 -0
  274. package/storageOperations/models/comment.model.js.map +1 -0
  275. package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
  276. package/storageOperations/models/contentModelPluginFactory.js +28 -0
  277. package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
  278. package/storageOperations/models/contentReview.model.d.ts +7 -0
  279. package/storageOperations/models/contentReview.model.js +258 -0
  280. package/storageOperations/models/contentReview.model.js.map +1 -0
  281. package/storageOperations/models/index.d.ts +2 -0
  282. package/storageOperations/models/index.js +115 -0
  283. package/storageOperations/models/index.js.map +1 -0
  284. package/storageOperations/models/reviewer.model.d.ts +3 -0
  285. package/storageOperations/models/reviewer.model.js +71 -0
  286. package/storageOperations/models/reviewer.model.js.map +1 -0
  287. package/storageOperations/models/utils.d.ts +3 -0
  288. package/storageOperations/models/utils.js +37 -0
  289. package/storageOperations/models/utils.js.map +1 -0
  290. package/storageOperations/models/workflow.model.d.ts +12 -0
  291. package/storageOperations/models/workflow.model.js +208 -0
  292. package/storageOperations/models/workflow.model.js.map +1 -0
  293. package/storageOperations/reviewerStorageOperations.d.ts +3 -0
  294. package/storageOperations/reviewerStorageOperations.js +97 -0
  295. package/storageOperations/reviewerStorageOperations.js.map +1 -0
  296. package/storageOperations/types.d.ts +34 -0
  297. package/storageOperations/types.js +5 -0
  298. package/storageOperations/types.js.map +1 -0
  299. package/storageOperations/workflowStorageOperations.d.ts +3 -0
  300. package/storageOperations/workflowStorageOperations.js +111 -0
  301. package/storageOperations/workflowStorageOperations.js.map +1 -0
  302. package/types.d.ts +752 -0
  303. package/types.js +69 -0
  304. package/types.js.map +1 -0
  305. package/utils/contentApwSettingsPlugin.d.ts +9 -0
  306. package/utils/contentApwSettingsPlugin.js +26 -0
  307. package/utils/contentApwSettingsPlugin.js.map +1 -0
  308. package/utils/errors.d.ts +16 -0
  309. package/utils/errors.js +75 -0
  310. package/utils/errors.js.map +1 -0
  311. package/utils/fieldResolver.d.ts +16 -0
  312. package/utils/fieldResolver.js +54 -0
  313. package/utils/fieldResolver.js.map +1 -0
  314. package/utils/resolve.d.ts +3 -0
  315. package/utils/resolve.js +18 -0
  316. package/utils/resolve.js.map +1 -0
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendContentReviewNotification = void 0;
7
+
8
+ var _lastContentReviewNotificationPlugin = require("./lastContentReviewNotificationPlugin");
9
+
10
+ const sendContentReviewNotification = async params => {
11
+ const {
12
+ context,
13
+ reviewers,
14
+ contentReview
15
+ } = params;
16
+
17
+ if (reviewers.length === 0) {
18
+ return;
19
+ }
20
+
21
+ const contentReviewPlugin = (0, _lastContentReviewNotificationPlugin.getLastContentReviewNotificationPlugin)({
22
+ context,
23
+ type: contentReview.content.type
24
+ });
25
+
26
+ if (!contentReviewPlugin) {
27
+ console.log("No e-mail body content review plugin.");
28
+ return;
29
+ }
30
+
31
+ const body = contentReviewPlugin.create(params);
32
+
33
+ if (!body) {
34
+ console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);
35
+ return;
36
+ }
37
+
38
+ const result = await context.mailer.sendMail({
39
+ bcc: reviewers.map(r => r.email),
40
+ subject: "There is a new content review which you are assigned on.",
41
+ text: body.text,
42
+ html: body.html || body.text
43
+ });
44
+
45
+ if (!result.error) {
46
+ return;
47
+ }
48
+
49
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
50
+ };
51
+
52
+ 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,MADyC,IAEzB;EAChB,MAAM;IAAEC,OAAF;IAAWC,SAAX;IAAsBC;EAAtB,IAAwCH,MAA9C;;EACA,IAAIE,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B;IACxB;EACH;;EAED,MAAMC,mBAAmB,GAAG,IAAAC,2EAAA,EAAuC;IAC/DL,OAD+D;IAE/DM,IAAI,EAAEJ,aAAa,CAACK,OAAd,CAAsBD;EAFmC,CAAvC,CAA5B;;EAIA,IAAI,CAACF,mBAAL,EAA0B;IACtBI,OAAO,CAACC,GAAR,CAAY,uCAAZ;IACA;EACH;;EAED,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAApB,CAA2BZ,MAA3B,CAAb;;EACA,IAAI,CAACW,IAAL,EAAW;IACPF,OAAO,CAACC,GAAR,CAAa,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAvF;IACA;EACH;;EAED,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAR,CAAeC,QAAf,CAAwB;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAV,CAAcC,CAAC,IAAIA,CAAC,CAACC,KAArB,CADoC;IAEzCC,OAAO,EAAE,0DAFgC;IAGzCC,IAAI,EAAEX,IAAI,CAACW,IAH8B;IAIzCC,IAAI,EAAEZ,IAAI,CAACY,IAAL,IAAaZ,IAAI,CAACW;EAJiB,CAAxB,CAArB;;EAMA,IAAI,CAACR,MAAM,CAACU,KAAZ,EAAmB;IACf;EACH;;EACDf,OAAO,CAACC,GAAR,CAAY,4BAAZ,EAA0Ce,IAAI,CAACC,SAAL,CAAeZ,MAAM,CAACU,KAAtB,CAA1C;AACH,CAjCM"}
@@ -0,0 +1,2 @@
1
+ import { LifeCycleHookCallbackParams } from "../../types";
2
+ export declare const updatePendingChangeRequestsCount: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updatePendingChangeRequestsCount = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _utils = require("../utils");
13
+
14
+ const updatePendingChangeRequests = async ({
15
+ contentReviewMethods,
16
+ step,
17
+ delta
18
+ }) => {
19
+ const {
20
+ id,
21
+ stepId
22
+ } = (0, _utils.extractContentReviewIdAndStep)(step);
23
+ await (0, _utils.updateContentReview)({
24
+ contentReviewMethods,
25
+ id,
26
+ getNewContentReviewData: data => {
27
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
28
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
29
+ pendingChangeRequests: step.pendingChangeRequests + delta
30
+ }))
31
+ });
32
+ }
33
+ });
34
+ };
35
+
36
+ const updatePendingChangeRequestsCount = ({
37
+ apw
38
+ }) => {
39
+ apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({
40
+ changeRequest
41
+ }) => {
42
+ /**
43
+ * If the deleted changeRequest was marked as resolved. We don't need to do anything here,
44
+ * because "pendingChangeRequests has been already updated in "onAfterChangeRequestUpdate" hook.
45
+ */
46
+ if (changeRequest.resolved === true) {
47
+ return;
48
+ }
49
+ /**
50
+ * After a "changeRequest" is deleted, decrement the "pendingChangeRequests" count
51
+ * in the corresponding step of the content review entry.
52
+ */
53
+
54
+
55
+ await updatePendingChangeRequests({
56
+ contentReviewMethods: apw.contentReview,
57
+ step: changeRequest.step,
58
+ delta: -1
59
+ });
60
+ });
61
+ apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
62
+ changeRequest
63
+ }) => {
64
+ /**
65
+ * After a "changeRequest" is created, increment the "pendingChangeRequests" count
66
+ * of the corresponding step in the content review entry.
67
+ */
68
+ await updatePendingChangeRequests({
69
+ contentReviewMethods: apw.contentReview,
70
+ step: changeRequest.step,
71
+ delta: 1
72
+ });
73
+ });
74
+ apw.changeRequest.onChangeRequestAfterUpdate.subscribe(async ({
75
+ changeRequest,
76
+ original
77
+ }) => {
78
+ /**
79
+ * After a "changeRequest" is created, and the value of "resolved" field has changed;
80
+ * then we also need to update the "pendingChangeRequests" count of the corresponding step in the content review entry.
81
+ */
82
+ if (original.resolved !== changeRequest.resolved) {
83
+ const resolved = changeRequest.resolved;
84
+ const delta = resolved === true ? -1 : 1;
85
+ await updatePendingChangeRequests({
86
+ contentReviewMethods: apw.contentReview,
87
+ step: changeRequest.step,
88
+ delta
89
+ });
90
+ }
91
+ });
92
+ };
93
+
94
+ exports.updatePendingChangeRequestsCount = updatePendingChangeRequestsCount;
@@ -0,0 +1 @@
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,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;IAGtBI,uBAAuB,EAAEC,IAAI,IAAI;MAC7B,mEACOA,IADP;QAEIC,KAAK,EAAE,IAAAC,8BAAA,EAAwBF,IAAI,CAACC,KAA7B,EAAoCL,MAApC,EAA4CH,IAAI,gEAChDA,IADgD;UAEnDU,qBAAqB,EAAEV,IAAI,CAACU,qBAAL,GAA6BT;QAFD,EAAhD;MAFX;IAOH;EAXqB,CAApB,CAAN;AAaH,CApBD;;AAsBO,MAAMU,gCAAgC,GAAG,CAAC;EAC7CC;AAD6C,CAAD,KAEA;EAC5CA,GAAG,CAACC,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF;AACR;AACA;AACA;IACQ,IAAIA,aAAa,CAACG,QAAd,KAA2B,IAA/B,EAAqC;MACjC;IACH;IACD;AACR;AACA;AACA;;;IACQ,MAAMlB,2BAA2B,CAAC;MAC9BC,oBAAoB,EAAEa,GAAG,CAACK,aADI;MAE9BjB,IAAI,EAAEa,aAAa,CAACb,IAFU;MAG9BC,KAAK,EAAE,CAAC;IAHsB,CAAD,CAAjC;EAKH,CAjBD;EAmBAW,GAAG,CAACC,aAAJ,CAAkBK,0BAAlB,CAA6CH,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF;AACR;AACA;AACA;IACQ,MAAMf,2BAA2B,CAAC;MAC9BC,oBAAoB,EAAEa,GAAG,CAACK,aADI;MAE9BjB,IAAI,EAAEa,aAAa,CAACb,IAFU;MAG9BC,KAAK,EAAE;IAHuB,CAAD,CAAjC;EAKH,CAVD;EAYAW,GAAG,CAACC,aAAJ,CAAkBM,0BAAlB,CAA6CJ,SAA7C,CAAuD,OAAO;IAAEF,aAAF;IAAiBO;EAAjB,CAAP,KAAuC;IAC1F;AACR;AACA;AACA;IACQ,IAAIA,QAAQ,CAACJ,QAAT,KAAsBH,aAAa,CAACG,QAAxC,EAAkD;MAC9C,MAAMA,QAAQ,GAAGH,aAAa,CAACG,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"}
@@ -0,0 +1,3 @@
1
+ import { LifeCycleHookCallbackParams } from "../../types";
2
+ export declare const updateTotalCommentsCount: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
3
+ export declare const updateLatestCommentId: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updateTotalCommentsCount = exports.updateLatestCommentId = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _utils = require("../utils");
13
+
14
+ const updateTotalCommentsCount = ({
15
+ apw
16
+ }) => {
17
+ apw.comment.onCommentAfterDelete.subscribe(async ({
18
+ comment
19
+ }) => {
20
+ const {
21
+ step
22
+ } = comment;
23
+ /**
24
+ * After a "comment" is deleted, decrement the "totalComments" count
25
+ * in the corresponding step of the content review entry.
26
+ */
27
+
28
+ if (step) {
29
+ const {
30
+ id,
31
+ stepId
32
+ } = (0, _utils.extractContentReviewIdAndStep)(step);
33
+ await (0, _utils.updateContentReview)({
34
+ contentReviewMethods: apw.contentReview,
35
+ id,
36
+ getNewContentReviewData: data => {
37
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
38
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
39
+ totalComments: step.totalComments - 1
40
+ }))
41
+ });
42
+ }
43
+ });
44
+ }
45
+ });
46
+ apw.comment.onCommentAfterCreate.subscribe(async ({
47
+ comment
48
+ }) => {
49
+ /**
50
+ * After a "comment" is created, increment the "totalComments" count
51
+ * of the corresponding step in the content review entry.
52
+ */
53
+ const {
54
+ id,
55
+ stepId
56
+ } = (0, _utils.extractContentReviewIdAndStep)(comment.step);
57
+ await (0, _utils.updateContentReview)({
58
+ contentReviewMethods: apw.contentReview,
59
+ id,
60
+ getNewContentReviewData: data => {
61
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
62
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
63
+ totalComments: step.totalComments + 1
64
+ }))
65
+ });
66
+ }
67
+ });
68
+ });
69
+ };
70
+
71
+ exports.updateTotalCommentsCount = updateTotalCommentsCount;
72
+
73
+ const updateLatestCommentId = ({
74
+ apw
75
+ }) => {
76
+ apw.comment.onCommentAfterCreate.subscribe(async ({
77
+ comment
78
+ }) => {
79
+ /**
80
+ * After a "comment" is created, update the "latestCommentId" in
81
+ * the corresponding content review entry.
82
+ */
83
+ const {
84
+ id
85
+ } = (0, _utils.extractContentReviewIdAndStep)(comment.step);
86
+ await (0, _utils.updateContentReview)({
87
+ contentReviewMethods: apw.contentReview,
88
+ id,
89
+ getNewContentReviewData: contentReview => {
90
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
91
+ latestCommentId: comment.id
92
+ });
93
+ }
94
+ });
95
+ });
96
+ apw.comment.onCommentAfterUpdate.subscribe(async ({
97
+ comment
98
+ }) => {
99
+ /**
100
+ * After a "comment" is updated, update the "latestCommentId" in
101
+ * the corresponding content review entry.
102
+ */
103
+ const {
104
+ id
105
+ } = (0, _utils.extractContentReviewIdAndStep)(comment.step);
106
+ await (0, _utils.updateContentReview)({
107
+ contentReviewMethods: apw.contentReview,
108
+ id,
109
+ getNewContentReviewData: contentReview => {
110
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
111
+ latestCommentId: comment.id
112
+ });
113
+ }
114
+ });
115
+ });
116
+ apw.comment.onCommentAfterDelete.subscribe(async ({
117
+ comment
118
+ }) => {
119
+ /**
120
+ * After a "comment" is updated, update the "latestCommentId" in
121
+ * the corresponding content review entry.
122
+ */
123
+ const {
124
+ id
125
+ } = (0, _utils.extractContentReviewIdAndStep)(comment.step);
126
+ const contentReview = await (0, _utils.safelyGetContentReview)({
127
+ id,
128
+ contentReviewMethods: apw.contentReview
129
+ });
130
+
131
+ if (contentReview && contentReview.latestCommentId === comment.id) {
132
+ const [[latestComment]] = await apw.comment.list({
133
+ where: {
134
+ changeRequest: {
135
+ id: comment.changeRequest
136
+ }
137
+ },
138
+ sort: ["createdOn_DESC"]
139
+ });
140
+ await (0, _utils.updateContentReview)({
141
+ contentReviewMethods: apw.contentReview,
142
+ id,
143
+ getNewContentReviewData: contentReview => {
144
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
145
+ latestCommentId: latestComment ? latestComment.id : null
146
+ });
147
+ }
148
+ });
149
+ }
150
+ });
151
+ };
152
+
153
+ exports.updateLatestCommentId = updateLatestCommentId;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["updateTotalCommentsCount","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":"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"}
@@ -0,0 +1,2 @@
1
+ import { LifeCycleHookCallbackParams } from "../../types";
2
+ export declare const validateChangeRequest: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.validateChangeRequest = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _handlerGraphql = require("@webiny/handler-graphql");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ var _utils2 = require("@webiny/utils");
17
+
18
+ const validateChangeRequest = ({
19
+ apw
20
+ }) => {
21
+ apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({
22
+ input
23
+ }) => {
24
+ const {
25
+ step
26
+ } = input;
27
+ /**
28
+ * We need step to be in a particular format i.e. "contentReviewId#version#stepId"
29
+ */
30
+
31
+ const {
32
+ id: revisionId,
33
+ stepId
34
+ } = (0, _utils.extractContentReviewIdAndStep)(step);
35
+ const {
36
+ id: entryId,
37
+ version
38
+ } = (0, _utils2.parseIdentifier)(revisionId);
39
+
40
+ if (!entryId || !version || !stepId) {
41
+ throw new _error.default(`The step property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_STEP", {
42
+ step
43
+ });
44
+ }
45
+ /**
46
+ * Check whether a contentReview entry exists with provided id.
47
+ */
48
+
49
+
50
+ let contentReview = undefined;
51
+
52
+ try {
53
+ contentReview = await apw.contentReview.get(revisionId);
54
+ } catch (ex) {
55
+ /**
56
+ * There is no need to output the log if this is the test environment.
57
+ */
58
+ if (process.env.NODE_ENV !== "test") {
59
+ console.log({
60
+ message: ex.message,
61
+ code: ex.data,
62
+ data: ex.data
63
+ });
64
+ }
65
+ }
66
+
67
+ if (!contentReview) {
68
+ throw new _handlerGraphql.NotFoundError(`Unable to found "ContentReview" with given id "${revisionId}"`);
69
+ }
70
+ /**
71
+ * Don't allow "change request" creation once the sign-off has been provided.
72
+ */
73
+
74
+
75
+ const {
76
+ steps
77
+ } = contentReview;
78
+ const currentStep = steps.find(step => step.id === stepId);
79
+
80
+ if (currentStep && currentStep.signOffProvidedOn) {
81
+ throw new _error.default(`Please retract the sign-off before opening a new change request.`, "SIGN_OFF_PROVIDED", {
82
+ step: currentStep,
83
+ stepId: stepId
84
+ });
85
+ }
86
+ });
87
+ };
88
+
89
+ exports.validateChangeRequest = validateChangeRequest;
@@ -0,0 +1 @@
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;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;MAAEE,EAAE,EAAEC,UAAN;MAAkBC;IAAlB,IAA6B,IAAAC,oCAAA,EAA8BJ,IAA9B,CAAnC;IAEA,MAAM;MAAEC,EAAE,EAAEI,OAAN;MAAeC;IAAf,IAA2B,IAAAC,uBAAA,EAAgBL,UAAhB,CAAjC;;IACA,IAAI,CAACG,OAAD,IAAY,CAACC,OAAb,IAAwB,CAACH,MAA7B,EAAqC;MACjC,MAAM,IAAIK,cAAJ,CACD,uDADC,EAEF,+BAFE,EAGF;QACIR;MADJ,CAHE,CAAN;IAOH;IACD;AACR;AACA;;;IACQ,IAAIS,aAA2C,GAAGC,SAAlD;;IACA,IAAI;MACAD,aAAa,GAAG,MAAMd,GAAG,CAACc,aAAJ,CAAkBE,GAAlB,CAAsBT,UAAtB,CAAtB;IACH,CAFD,CAEE,OAAOU,EAAP,EAAW;MACT;AACZ;AACA;MACY,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAA7B,EAAqC;QACjCC,OAAO,CAACC,GAAR,CAAY;UACRC,OAAO,EAAEN,EAAE,CAACM,OADJ;UAERC,IAAI,EAAEP,EAAE,CAACQ,IAFD;UAGRA,IAAI,EAAER,EAAE,CAACQ;QAHD,CAAZ;MAKH;IACJ;;IACD,IAAI,CAACX,aAAL,EAAoB;MAChB,MAAM,IAAIY,6BAAJ,CACD,kDAAiDnB,UAAW,GAD3D,CAAN;IAGH;IACD;AACR;AACA;;;IACQ,MAAM;MAAEoB;IAAF,IAAYb,aAAlB;IACA,MAAMc,WAAW,GAAGD,KAAK,CAACE,IAAN,CAAWxB,IAAI,IAAIA,IAAI,CAACC,EAAL,KAAYE,MAA/B,CAApB;;IAEA,IAAIoB,WAAW,IAAIA,WAAW,CAACE,iBAA/B,EAAkD;MAC9C,MAAM,IAAIjB,cAAJ,CACD,kEADC,EAEF,mBAFE,EAGF;QACIR,IAAI,EAAEuB,WADV;QAEIpB,MAAM,EAAEA;MAFZ,CAHE,CAAN;IAQH;EACJ,CAxDD;AAyDH,CA1DM"}
@@ -0,0 +1,2 @@
1
+ import { LifeCycleHookCallbackParams } from "../../types";
2
+ export declare const validateComment: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.validateComment = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _utils = require("@webiny/utils");
13
+
14
+ const validateComment = ({
15
+ apw
16
+ }) => {
17
+ apw.comment.onCommentBeforeCreate.subscribe(async ({
18
+ input
19
+ }) => {
20
+ const {
21
+ changeRequest: changeRequestId
22
+ } = input;
23
+ /**
24
+ * We need changeRequest to be in a particular format i.e. "contentReviewUniqueId#version"
25
+ */
26
+
27
+ let result;
28
+
29
+ try {
30
+ result = (0, _utils.parseIdentifier)(changeRequestId);
31
+
32
+ if (!result) {
33
+ throw new _error.default("Could not parse changeRequestId.", "MALFORMED_CHANGE_REQUEST_ID", {
34
+ changeRequestId
35
+ });
36
+ }
37
+ } catch (ex) {
38
+ throw new _error.default(`The"changeRequest" property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_ID", {
39
+ input
40
+ });
41
+ }
42
+ /**
43
+ * Assign value for "step" field from "changeRequest".
44
+ */
45
+
46
+
47
+ const changeRequest = await apw.changeRequest.get(changeRequestId);
48
+
49
+ if (!changeRequest) {
50
+ return;
51
+ }
52
+
53
+ input.step = changeRequest.step;
54
+ });
55
+ };
56
+
57
+ exports.validateComment = validateComment;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateComment","apw","comment","onCommentBeforeCreate","subscribe","input","changeRequest","changeRequestId","result","parseIdentifier","WebinyError","ex","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\nimport { parseIdentifier, ParseIdentifierResult } from \"@webiny/utils\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentBeforeCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n let result: ParseIdentifierResult;\n try {\n result = parseIdentifier(changeRequestId);\n if (!result) {\n throw new WebinyError(\n \"Could not parse changeRequestId.\",\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n changeRequestId\n }\n );\n }\n } catch (ex) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAClFA,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,CAAkCC,SAAlC,CAA4C,OAAO;IAAEC;EAAF,CAAP,KAAqB;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAjB,IAAqCF,KAA3C;IACA;AACR;AACA;;IACQ,IAAIG,MAAJ;;IACA,IAAI;MACAA,MAAM,GAAG,IAAAC,sBAAA,EAAgBF,eAAhB,CAAT;;MACA,IAAI,CAACC,MAAL,EAAa;QACT,MAAM,IAAIE,cAAJ,CACF,kCADE,EAEF,6BAFE,EAGF;UACIH;QADJ,CAHE,CAAN;MAOH;IACJ,CAXD,CAWE,OAAOI,EAAP,EAAW;MACT,MAAM,IAAID,cAAJ,CACD,iEADC,EAEF,6BAFE,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;IAED;AACR;AACA;;;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAJ,CAAkBM,GAAlB,CAAsBL,eAAtB,CAA5B;;IACA,IAAI,CAACD,aAAL,EAAoB;MAChB;IACH;;IACDD,KAAK,CAACQ,IAAN,GAAaP,aAAa,CAACO,IAA3B;EACH,CAnCD;AAoCH,CArCM"}
@@ -0,0 +1,2 @@
1
+ import { LifeCycleHookCallbackParams } from "../../types";
2
+ export declare const validateContentReview: ({ apw }: Pick<LifeCycleHookCallbackParams, "apw">) => void;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.validateContentReview = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ const validateContentReview = ({
13
+ apw
14
+ }) => {
15
+ apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({
16
+ input
17
+ }) => {
18
+ const {
19
+ content
20
+ } = input;
21
+ /**
22
+ * Check whether a contentReview already exists for provided content.
23
+ */
24
+
25
+ const {
26
+ contentReviewId
27
+ } = await apw.contentReview.isReviewRequired(content);
28
+
29
+ if (contentReviewId) {
30
+ throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
31
+ contentReviewId,
32
+ content
33
+ });
34
+ }
35
+ });
36
+ };
37
+
38
+ exports.validateContentReview = validateContentReview;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateContentReview","apw","contentReview","onContentReviewBeforeCreate","subscribe","input","content","contentReviewId","isReviewRequired","WebinyError"],"sources":["validateContentReview.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateContentReview = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { content } = input;\n /**\n * Check whether a contentReview already exists for provided content.\n */\n const { contentReviewId } = await apw.contentReview.isReviewRequired(content);\n if (contentReviewId) {\n throw new WebinyError(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n content\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;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,IAAcD,KAApB;IACA;AACR;AACA;;IACQ,MAAM;MAAEE;IAAF,IAAsB,MAAMN,GAAG,CAACC,aAAJ,CAAkBM,gBAAlB,CAAmCF,OAAnC,CAAlC;;IACA,IAAIC,eAAJ,EAAqB;MACjB,MAAM,IAAIE,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;QACIF,eADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CAhBD;AAiBH,CAlBM"}
@@ -0,0 +1,9 @@
1
+ import { ContentApwSettingsPlugin } from "../../ContentApwSettingsPlugin";
2
+ import { ApwContentTypes, PageWithWorkflow } from "../../types";
3
+ export declare class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {
4
+ canUse(type: ApwContentTypes): boolean;
5
+ setWorkflowId(page: PageWithWorkflow, id: string | null): void;
6
+ getWorkflowId(page: PageWithWorkflow): string | null;
7
+ setContentReviewId(page: PageWithWorkflow, id: string | null): void;
8
+ getContentReviewId(page: PageWithWorkflow): string | null;
9
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PageApwSettingsGetterPlugin = void 0;
9
+
10
+ var _ContentApwSettingsPlugin = require("../../ContentApwSettingsPlugin");
11
+
12
+ var _types = require("../../types");
13
+
14
+ var _set = _interopRequireDefault(require("lodash/set"));
15
+
16
+ class PageApwSettingsGetterPlugin extends _ContentApwSettingsPlugin.ContentApwSettingsPlugin {
17
+ canUse(type) {
18
+ return type === _types.ApwContentTypes.PAGE;
19
+ }
20
+
21
+ setWorkflowId(page, id) {
22
+ page.settings = (0, _set.default)(page.settings || {}, "apw.workflowId", id);
23
+ }
24
+
25
+ getWorkflowId(page) {
26
+ var _page$settings$apw;
27
+
28
+ if (!page.settings) {
29
+ return null;
30
+ }
31
+
32
+ return ((_page$settings$apw = page.settings.apw) === null || _page$settings$apw === void 0 ? void 0 : _page$settings$apw.workflowId) || null;
33
+ }
34
+
35
+ setContentReviewId(page, id) {
36
+ page.settings = (0, _set.default)(page.settings || {}, "apw.contentReviewId", id);
37
+ }
38
+
39
+ getContentReviewId(page) {
40
+ var _page$settings$apw2;
41
+
42
+ if (!page.settings) {
43
+ return null;
44
+ }
45
+
46
+ return (_page$settings$apw2 = page.settings.apw) === null || _page$settings$apw2 === void 0 ? void 0 : _page$settings$apw2.contentReviewId;
47
+ }
48
+
49
+ }
50
+
51
+ exports.PageApwSettingsGetterPlugin = PageApwSettingsGetterPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PageApwSettingsGetterPlugin","ContentApwSettingsPlugin","canUse","type","ApwContentTypes","PAGE","setWorkflowId","page","id","settings","set","getWorkflowId","apw","workflowId","setContentReviewId","getContentReviewId","contentReviewId"],"sources":["PageApwSettingsGetterPlugin.ts"],"sourcesContent":["import { ContentApwSettingsPlugin } from \"~/ContentApwSettingsPlugin\";\nimport { ApwContentTypes, PageWithWorkflow } from \"~/types\";\nimport set from \"lodash/set\";\n\nexport class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {\n public override canUse(type: ApwContentTypes): boolean {\n return type === ApwContentTypes.PAGE;\n }\n\n public override setWorkflowId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.workflowId\", id);\n }\n\n public override getWorkflowId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.workflowId || null;\n }\n\n public override setContentReviewId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.contentReviewId\", id);\n }\n\n public override getContentReviewId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.contentReviewId;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,2BAAN,SAA0CC,kDAA1C,CAAmE;EACtDC,MAAM,CAACC,IAAD,EAAiC;IACnD,OAAOA,IAAI,KAAKC,sBAAA,CAAgBC,IAAhC;EACH;;EAEeC,aAAa,CAACC,IAAD,EAAyBC,EAAzB,EAA4C;IACrED,IAAI,CAACE,QAAL,GAAgB,IAAAC,YAAA,EAAIH,IAAI,CAACE,QAAL,IAAiB,EAArB,EAAyB,gBAAzB,EAA2CD,EAA3C,CAAhB;EACH;;EAEeG,aAAa,CAACJ,IAAD,EAAwC;IAAA;;IACjE,IAAI,CAACA,IAAI,CAACE,QAAV,EAAoB;MAChB,OAAO,IAAP;IACH;;IACD,OAAO,uBAAAF,IAAI,CAACE,QAAL,CAAcG,GAAd,0EAAmBC,UAAnB,KAAiC,IAAxC;EACH;;EAEeC,kBAAkB,CAACP,IAAD,EAAyBC,EAAzB,EAA4C;IAC1ED,IAAI,CAACE,QAAL,GAAgB,IAAAC,YAAA,EAAIH,IAAI,CAACE,QAAL,IAAiB,EAArB,EAAyB,qBAAzB,EAAgDD,EAAhD,CAAhB;EACH;;EAEeO,kBAAkB,CAACR,IAAD,EAAwC;IAAA;;IACtE,IAAI,CAACA,IAAI,CAACE,QAAV,EAAoB;MAChB,OAAO,IAAP;IACH;;IACD,8BAAOF,IAAI,CAACE,QAAL,CAAcG,GAArB,wDAAO,oBAAmBI,eAA1B;EACH;;AAzBqE"}
@@ -0,0 +1,3 @@
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { ApwContext } from "../../types";
3
+ export declare const apwContentPagePlugins: () => ContextPlugin<ApwContext>;