@webiny/api-apw 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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 (315) hide show
  1. package/ApwChangeRequestNotification.d.ts +1 -1
  2. package/ApwChangeRequestNotification.js +3 -15
  3. package/ApwChangeRequestNotification.js.map +1 -1
  4. package/ApwCommentNotification.d.ts +1 -1
  5. package/ApwCommentNotification.js +3 -15
  6. package/ApwCommentNotification.js.map +1 -1
  7. package/ApwContentReviewNotification.d.ts +1 -1
  8. package/ApwContentReviewNotification.js +3 -15
  9. package/ApwContentReviewNotification.js.map +1 -1
  10. package/ApwContentUrlPlugin.d.ts +1 -1
  11. package/ApwContentUrlPlugin.js +3 -15
  12. package/ApwContentUrlPlugin.js.map +1 -1
  13. package/ContentApwSettingsPlugin.d.ts +1 -1
  14. package/ContentApwSettingsPlugin.js +5 -9
  15. package/ContentApwSettingsPlugin.js.map +1 -1
  16. package/README.md +3 -3
  17. package/crud/createChangeRequestMethods.d.ts +1 -1
  18. package/crud/createChangeRequestMethods.js +7 -12
  19. package/crud/createChangeRequestMethods.js.map +1 -1
  20. package/crud/createCommentMethods.d.ts +1 -1
  21. package/crud/createCommentMethods.js +7 -13
  22. package/crud/createCommentMethods.js.map +1 -1
  23. package/crud/createContentReviewMethods.d.ts +2 -2
  24. package/crud/createContentReviewMethods.js +76 -115
  25. package/crud/createContentReviewMethods.js.map +1 -1
  26. package/crud/createReviewerMethods.d.ts +1 -1
  27. package/crud/createReviewerMethods.js +7 -13
  28. package/crud/createReviewerMethods.js.map +1 -1
  29. package/crud/createWorkflowMethods.d.ts +1 -1
  30. package/crud/createWorkflowMethods.js +7 -18
  31. package/crud/createWorkflowMethods.js.map +1 -1
  32. package/crud/index.d.ts +1 -1
  33. package/crud/index.js +5 -29
  34. package/crud/index.js.map +1 -1
  35. package/crud/utils.d.ts +2 -2
  36. package/crud/utils.js +7 -35
  37. package/crud/utils.js.map +1 -1
  38. package/index.d.ts +2 -3
  39. package/index.js +6 -19
  40. package/index.js.map +1 -1
  41. package/package.json +32 -50
  42. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
  43. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
  44. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  45. package/plugins/cms/apwEntryPlugins.d.ts +2 -2
  46. package/plugins/cms/apwEntryPlugins.js +18 -14
  47. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  48. package/plugins/cms/index.d.ts +4 -4
  49. package/plugins/cms/index.js +2 -13
  50. package/plugins/cms/index.js.map +1 -1
  51. package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
  52. package/plugins/cms/linkContentReviewToEntry.js +4 -20
  53. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  54. package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
  55. package/plugins/cms/linkWorkflowToEntry.js +18 -46
  56. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  57. package/plugins/cms/notifications/changeRequestNotification.js +2 -4
  58. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
  59. package/plugins/cms/notifications/commentNotification.js +2 -4
  60. package/plugins/cms/notifications/commentNotification.js.map +1 -1
  61. package/plugins/cms/notifications/contentReviewNotification.js +2 -4
  62. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
  63. package/plugins/cms/notifications/contentUrl.js +3 -8
  64. package/plugins/cms/notifications/contentUrl.js.map +1 -1
  65. package/plugins/cms/triggerContentReview.d.ts +2 -2
  66. package/plugins/cms/triggerContentReview.js +5 -18
  67. package/plugins/cms/triggerContentReview.js.map +1 -1
  68. package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
  69. package/plugins/cms/updateContentReviewStatus.js +14 -30
  70. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  71. package/plugins/cms/utils.d.ts +5 -4
  72. package/plugins/cms/utils.js +20 -59
  73. package/plugins/cms/utils.js.map +1 -1
  74. package/plugins/context.d.ts +3 -4
  75. package/plugins/context.js +4 -58
  76. package/plugins/context.js.map +1 -1
  77. package/plugins/graphql/changeRequest.gql.d.ts +1 -1
  78. package/plugins/graphql/changeRequest.gql.js +16 -20
  79. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  80. package/plugins/graphql/comment.gql.d.ts +1 -1
  81. package/plugins/graphql/comment.gql.js +41 -43
  82. package/plugins/graphql/comment.gql.js.map +1 -1
  83. package/plugins/graphql/contentReview.gql.d.ts +1 -1
  84. package/plugins/graphql/contentReview.gql.js +25 -35
  85. package/plugins/graphql/contentReview.gql.js.map +1 -1
  86. package/plugins/graphql/reviewer.gql.d.ts +1 -1
  87. package/plugins/graphql/reviewer.gql.js +15 -20
  88. package/plugins/graphql/reviewer.gql.js.map +1 -1
  89. package/plugins/graphql/utils.d.ts +2 -0
  90. package/plugins/graphql/utils.js +10 -0
  91. package/plugins/graphql/utils.js.map +1 -0
  92. package/plugins/graphql/workflow.gql.d.ts +1 -1
  93. package/plugins/graphql/workflow.gql.js +15 -20
  94. package/plugins/graphql/workflow.gql.js.map +1 -1
  95. package/plugins/graphql.d.ts +1 -1
  96. package/plugins/graphql.js +5 -18
  97. package/plugins/graphql.js.map +1 -1
  98. package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
  99. package/plugins/hooks/createReviewerFromIdentity.js +5 -12
  100. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  101. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
  102. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
  103. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  104. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
  105. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
  106. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  107. package/plugins/hooks/index.d.ts +1 -1
  108. package/plugins/hooks/index.js +2 -14
  109. package/plugins/hooks/index.js.map +1 -1
  110. package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
  111. package/plugins/hooks/initializeContentReviewSteps.js +15 -20
  112. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  113. package/plugins/hooks/initializeNotifications.d.ts +1 -1
  114. package/plugins/hooks/initializeNotifications.js +2 -5
  115. package/plugins/hooks/initializeNotifications.js.map +1 -1
  116. package/plugins/hooks/listContentReviews.d.ts +3 -3
  117. package/plugins/hooks/listContentReviews.js +3 -13
  118. package/plugins/hooks/listContentReviews.js.map +1 -1
  119. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
  120. package/plugins/hooks/notifications/changeRequestAfterCreate.js +7 -38
  121. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
  122. package/plugins/hooks/notifications/changeRequestUrl.js +2 -4
  123. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
  124. package/plugins/hooks/notifications/commentAfterCreate.d.ts +1 -1
  125. package/plugins/hooks/notifications/commentAfterCreate.js +7 -40
  126. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
  127. package/plugins/hooks/notifications/commentUrl.js +2 -4
  128. package/plugins/hooks/notifications/commentUrl.js.map +1 -1
  129. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +1 -1
  130. package/plugins/hooks/notifications/contentReviewAfterCreate.js +9 -35
  131. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
  132. package/plugins/hooks/notifications/contentReviewUrl.js +2 -4
  133. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
  134. package/plugins/hooks/notifications/contentUrl.d.ts +2 -2
  135. package/plugins/hooks/notifications/contentUrl.js +2 -5
  136. package/plugins/hooks/notifications/contentUrl.js.map +1 -1
  137. package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
  138. package/plugins/hooks/notifications/getAppUrl.js +19 -0
  139. package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
  140. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +1 -1
  141. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +2 -4
  142. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
  143. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
  144. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +2 -4
  145. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
  146. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
  147. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +2 -4
  148. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
  149. package/plugins/hooks/notifications/reviewers.d.ts +1 -1
  150. package/plugins/hooks/notifications/reviewers.js +17 -21
  151. package/plugins/hooks/notifications/reviewers.js.map +1 -1
  152. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
  153. package/plugins/hooks/notifications/sendChangeRequestNotification.js +2 -11
  154. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
  155. package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
  156. package/plugins/hooks/notifications/sendCommentNotification.js +2 -11
  157. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
  158. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
  159. package/plugins/hooks/notifications/sendContentReviewNotification.js +2 -11
  160. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
  161. package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
  162. package/plugins/hooks/updatePendingChangeRequests.js +7 -13
  163. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  164. package/plugins/hooks/updateTotalComments.d.ts +1 -1
  165. package/plugins/hooks/updateTotalComments.js +21 -23
  166. package/plugins/hooks/updateTotalComments.js.map +1 -1
  167. package/plugins/hooks/validateChangeRequest.d.ts +1 -1
  168. package/plugins/hooks/validateChangeRequest.js +2 -16
  169. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  170. package/plugins/hooks/validateComment.d.ts +1 -1
  171. package/plugins/hooks/validateComment.js +3 -12
  172. package/plugins/hooks/validateComment.js.map +1 -1
  173. package/plugins/hooks/validateContentReview.d.ts +1 -1
  174. package/plugins/hooks/validateContentReview.js +2 -6
  175. package/plugins/hooks/validateContentReview.js.map +1 -1
  176. package/plugins/utils.d.ts +7 -6
  177. package/plugins/utils.js +11 -50
  178. package/plugins/utils.js.map +1 -1
  179. package/scheduler/createScheduleActionMethods.d.ts +1 -1
  180. package/scheduler/createScheduleActionMethods.js +105 -85
  181. package/scheduler/createScheduleActionMethods.js.map +1 -1
  182. package/scheduler/handlers/executeAction/index.d.ts +2 -2
  183. package/scheduler/handlers/executeAction/index.js +47 -41
  184. package/scheduler/handlers/executeAction/index.js.map +1 -1
  185. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  186. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +19 -9
  187. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  188. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +3 -3
  189. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +11 -28
  190. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  191. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +4 -3
  192. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
  193. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  194. package/scheduler/handlers/executeAction/security.d.ts +2 -2
  195. package/scheduler/handlers/executeAction/security.js +2 -11
  196. package/scheduler/handlers/executeAction/security.js.map +1 -1
  197. package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
  198. package/scheduler/handlers/scheduleAction/index.js +23 -38
  199. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  200. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
  201. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
  202. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  203. package/scheduler/handlers/utils.d.ts +2 -4
  204. package/scheduler/handlers/utils.js +22 -53
  205. package/scheduler/handlers/utils.js.map +1 -1
  206. package/scheduler/index.d.ts +1 -1
  207. package/scheduler/index.js +2 -3
  208. package/scheduler/index.js.map +1 -1
  209. package/scheduler/types.d.ts +20 -36
  210. package/scheduler/types.js +11 -23
  211. package/scheduler/types.js.map +1 -1
  212. package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
  213. package/storageOperations/changeRequestStorageOperations.js +43 -41
  214. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  215. package/storageOperations/commentStorageOperations.d.ts +3 -3
  216. package/storageOperations/commentStorageOperations.js +16 -44
  217. package/storageOperations/commentStorageOperations.js.map +1 -1
  218. package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
  219. package/storageOperations/contentReviewStorageOperations.js +19 -41
  220. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  221. package/storageOperations/index.d.ts +3 -9
  222. package/storageOperations/index.js +10 -29
  223. package/storageOperations/index.js.map +1 -1
  224. package/storageOperations/models/changeRequest.model.d.ts +1 -2
  225. package/storageOperations/models/changeRequest.model.js +9 -19
  226. package/storageOperations/models/changeRequest.model.js.map +1 -1
  227. package/storageOperations/models/comment.model.d.ts +1 -2
  228. package/storageOperations/models/comment.model.js +9 -18
  229. package/storageOperations/models/comment.model.js.map +1 -1
  230. package/storageOperations/models/contentReview.model.d.ts +1 -2
  231. package/storageOperations/models/contentReview.model.js +16 -41
  232. package/storageOperations/models/contentReview.model.js.map +1 -1
  233. package/storageOperations/models/index.d.ts +1 -1
  234. package/storageOperations/models/index.js +11 -55
  235. package/storageOperations/models/index.js.map +1 -1
  236. package/storageOperations/models/reviewer.model.d.ts +1 -2
  237. package/storageOperations/models/reviewer.model.js +10 -19
  238. package/storageOperations/models/reviewer.model.js.map +1 -1
  239. package/storageOperations/models/utils.d.ts +2 -2
  240. package/storageOperations/models/utils.js +2 -4
  241. package/storageOperations/models/utils.js.map +1 -1
  242. package/storageOperations/models/workflow.model.d.ts +2 -3
  243. package/storageOperations/models/workflow.model.js +22 -46
  244. package/storageOperations/models/workflow.model.js.map +1 -1
  245. package/storageOperations/reviewerStorageOperations.d.ts +3 -3
  246. package/storageOperations/reviewerStorageOperations.js +23 -50
  247. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  248. package/storageOperations/types.d.ts +2 -2
  249. package/storageOperations/types.js +3 -1
  250. package/storageOperations/types.js.map +1 -1
  251. package/storageOperations/workflowStorageOperations.d.ts +2 -2
  252. package/storageOperations/workflowStorageOperations.js +24 -44
  253. package/storageOperations/workflowStorageOperations.js.map +1 -1
  254. package/types.d.ts +49 -64
  255. package/types.js +121 -43
  256. package/types.js.map +1 -1
  257. package/utils/contentApwSettingsPlugin.d.ts +2 -2
  258. package/utils/contentApwSettingsPlugin.js +2 -6
  259. package/utils/contentApwSettingsPlugin.js.map +1 -1
  260. package/utils/errors.js +2 -17
  261. package/utils/errors.js.map +1 -1
  262. package/utils/fieldResolver.d.ts +2 -2
  263. package/utils/fieldResolver.js +8 -18
  264. package/utils/fieldResolver.js.map +1 -1
  265. package/utils/pickEntryFieldValues.d.ts +3 -0
  266. package/utils/pickEntryFieldValues.js +30 -0
  267. package/utils/pickEntryFieldValues.js.map +1 -0
  268. package/utils/resolve.d.ts +1 -1
  269. package/utils/resolve.js +2 -3
  270. package/utils/resolve.js.map +1 -1
  271. package/plugins/hooks/notifications/appUrl.d.ts +0 -2
  272. package/plugins/hooks/notifications/appUrl.js +0 -22
  273. package/plugins/hooks/notifications/appUrl.js.map +0 -1
  274. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
  275. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -51
  276. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
  277. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
  278. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -30
  279. package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
  280. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
  281. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -25
  282. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
  283. package/plugins/pageBuilder/index.d.ts +0 -11
  284. package/plugins/pageBuilder/index.js +0 -53
  285. package/plugins/pageBuilder/index.js.map +0 -1
  286. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
  287. package/plugins/pageBuilder/linkContentReviewToPage.js +0 -105
  288. package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
  289. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
  290. package/plugins/pageBuilder/linkWorkflowToPage.js +0 -194
  291. package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
  292. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +0 -1
  293. package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -35
  294. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +0 -1
  295. package/plugins/pageBuilder/notifications/commentNotification.d.ts +0 -1
  296. package/plugins/pageBuilder/notifications/commentNotification.js +0 -35
  297. package/plugins/pageBuilder/notifications/commentNotification.js.map +0 -1
  298. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +0 -1
  299. package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -35
  300. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +0 -1
  301. package/plugins/pageBuilder/notifications/contentUrl.d.ts +0 -1
  302. package/plugins/pageBuilder/notifications/contentUrl.js +0 -53
  303. package/plugins/pageBuilder/notifications/contentUrl.js.map +0 -1
  304. package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
  305. package/plugins/pageBuilder/triggerContentReview.js +0 -50
  306. package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
  307. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
  308. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -79
  309. package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
  310. package/plugins/pageBuilder/utils.d.ts +0 -22
  311. package/plugins/pageBuilder/utils.js +0 -184
  312. package/plugins/pageBuilder/utils.js.map +0 -1
  313. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
  314. package/storageOperations/models/contentModelPluginFactory.js +0 -28
  315. package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","disableAuthorization","enableAuthorization"],"sources":["commentAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { createCommentUrl } from \"./commentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendCommentNotification } from \"./sendCommentNotification\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/appUrl\";\n\nexport const attachCommentAfterCreate = (context: ApwContext): void => {\n context.apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n const execute = async () => {\n const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);\n if (!changeRequest) {\n throw new WebinyError(\"Missing change request.\", \"CHANGE_REQUEST_NOT_FOUND\", {\n changeRequest: comment.changeRequest,\n comment: comment.id\n });\n }\n\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const commentUrl = createCommentUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!commentUrl) {\n console.log(\"No comment url.\");\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n console.log(\"No content url.\");\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [comment.createdBy.id]\n });\n\n if (reviewers.length === 0) {\n console.log(\"No reviewers to send the e-mail notification to.\");\n return;\n }\n\n try {\n await sendCommentNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n commentUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send comment notifications.`,\n \"COMMENT_NOTIFICATIONS_NOT_SENT\",\n {\n commentId: comment.id,\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n commentUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,wBAAwB,GAAIC,OAAD,IAA+B;EACnEA,OAAO,CAACC,GAAR,CAAYC,OAAZ,CAAoBC,oBAApB,CAAyCC,SAAzC,CAAmD,OAAO;IAAEF;EAAF,CAAP,KAAuB;IACtE,MAAMG,OAAO,GAAG,YAAY;MACxB,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACC,GAAR,CAAYK,aAAZ,CAA0BC,GAA1B,CAA8BL,OAAO,CAACI,aAAtC,CAA5B;;MACA,IAAI,CAACA,aAAL,EAAoB;QAChB,MAAM,IAAIE,cAAJ,CAAgB,yBAAhB,EAA2C,0BAA3C,EAAuE;UACzEF,aAAa,EAAEJ,OAAO,CAACI,aADkD;UAEzEJ,OAAO,EAAEA,OAAO,CAACO;QAFwD,CAAvE,CAAN;MAIH;;MAED,MAAM;QAAEA,EAAE,EAAEC,eAAN;QAAuBC;MAAvB,IAAkC,IAAAC,oCAAA,EACpCN,aAAa,CAACO,IADsB,CAAxC;;MAGA,IAAI,CAACF,MAAL,EAAa;QACT,MAAM,IAAIH,cAAJ,CAAgB,qCAAhB,EAAuD,iBAAvD,EAA0E;UAC5EK,IAAI,EAAEP,aAAa,CAACO;QADwD,CAA1E,CAAN;MAGH;;MAED,MAAMC,QAAQ,GAAG,MAAM,IAAAC,iBAAA,EAAUf,OAAV,CAAvB;;MACA,IAAI,CAACc,QAAL,EAAe;QACX;MACH;MACD;AACZ;AACA;;;MACY,MAAME,UAAU,GAAG,IAAAC,4BAAA,EAAiB;QAChCC,OAAO,EAAEJ,QAAQ,CAACK,MADc;QAEhCC,eAAe,EAAEd,aAAa,CAACG,EAFC;QAGhCC,eAH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AM,IAAAY,gDAAA,EAAwB;UAC1BlC,OAD0B;UAE1B6B,SAF0B;UAG1BvB,aAH0B;UAI1BiB,aAJ0B;UAK1BC,QAL0B;UAM1BR,UAN0B;UAO1BU;QAP0B,CAAxB,CAAN;MASH,CAVD,CAUE,OAAOS,EAAP,EAAW;QACT,MAAM,IAAI3B,cAAJ,CACD,uCADC,EAEF,gCAFE,EAGF;UACI4B,SAAS,EAAElC,OAAO,CAACO,EADvB;UAEIgB,UAAU,EAAED,QAAQ,CAACf,EAFzB;UAGIW,eAAe,EAAEd,aAAa,CAACG,EAHnC;UAIIC,eAJJ;UAKIM,UALJ;UAMIU,UANJ;UAOIW,KAAK,EAAE;YACHC,OAAO,EAAEH,EAAE,CAACG,OADT;YAEHC,IAAI,EAAEJ,EAAE,CAACI,IAFN;YAGHC,IAAI,EAAEL,EAAE,CAACK,IAHN;YAIHC,KAAK,EAAEN,EAAE,CAACM;UAJP;QAPX,CAHE,CAAN;MAkBH;IACJ,CAlHD;;IAoHA,IAAI;MACAzC,OAAO,CAAC0C,QAAR,CAAiBC,oBAAjB;MACA,MAAMtC,OAAO,EAAb;IACH,CAHD,CAGE,OAAO8B,EAAP,EAAW;MACT,MAAMA,EAAN;IACH,CALD,SAKU;MACNnC,OAAO,CAAC0C,QAAR,CAAiBE,mBAAjB;IACH;EACJ,CA7HD;AA8HH,CA/HM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_utils","_contentUrl","_commentUrl","_reviewers","_sendCommentNotification","_getAppUrl","attachCommentAfterCreate","context","apw","comment","onCommentAfterCreate","subscribe","execute","changeRequest","get","WebinyError","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","settings","getAppUrl","commentUrl","createCommentUrl","baseUrl","appUrl","changeRequestId","console","log","contentReview","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendCommentNotification","ex","commentId","error","message","code","data","stack","security","withoutAuthorization","exports"],"sources":["commentAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { createCommentUrl } from \"./commentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendCommentNotification } from \"./sendCommentNotification\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/getAppUrl\";\n\nexport const attachCommentAfterCreate = (context: ApwContext): void => {\n context.apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n const execute = async () => {\n const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);\n if (!changeRequest) {\n throw new WebinyError(\"Missing change request.\", \"CHANGE_REQUEST_NOT_FOUND\", {\n changeRequest: comment.changeRequest,\n comment: comment.id\n });\n }\n\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const commentUrl = createCommentUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!commentUrl) {\n console.log(\"No comment url.\");\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n console.log(\"No content url.\");\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [comment.createdBy.id]\n });\n\n if (reviewers.length === 0) {\n console.log(\"No reviewers to send the e-mail notification to.\");\n return;\n }\n\n try {\n await sendCommentNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n commentUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send comment notifications.`,\n \"COMMENT_NOTIFICATIONS_NOT_SENT\",\n {\n commentId: comment.id,\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n commentUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAEO,MAAMO,wBAAwB,GAAIC,OAAmB,IAAW;EACnEA,OAAO,CAACC,GAAG,CAACC,OAAO,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAQ,CAAC,KAAK;IACtE,MAAMG,OAAO,GAAG,MAAAA,CAAA,KAAY;MACxB,MAAMC,aAAa,GAAG,MAAMN,OAAO,CAACC,GAAG,CAACK,aAAa,CAACC,GAAG,CAACL,OAAO,CAACI,aAAa,CAAC;MAChF,IAAI,CAACA,aAAa,EAAE;QAChB,MAAM,IAAIE,cAAW,CAAC,yBAAyB,EAAE,0BAA0B,EAAE;UACzEF,aAAa,EAAEJ,OAAO,CAACI,aAAa;UACpCJ,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C,CAAC;AACN,CAAC;AAACuC,OAAA,CAAA7C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createCommentUrl = void 0;
7
-
8
7
  const createCommentUrl = params => {
9
8
  /**
10
9
  * All variables must exist for URL to be created.
@@ -14,11 +13,9 @@ const createCommentUrl = params => {
14
13
  if (!!key) {
15
14
  continue;
16
15
  }
17
-
18
16
  console.log(`Missing variable "${key}", which we use to create a comment URL.`);
19
17
  return null;
20
18
  }
21
-
22
19
  const {
23
20
  baseUrl,
24
21
  changeRequestId,
@@ -27,5 +24,6 @@ const createCommentUrl = params => {
27
24
  } = params;
28
25
  return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
29
26
  };
27
+ exports.createCommentUrl = createCommentUrl;
30
28
 
31
- exports.createCommentUrl = createCommentUrl;
29
+ //# sourceMappingURL=commentUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createCommentUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId"],"sources":["commentUrl.ts"],"sourcesContent":["interface CreateCommentUrlParams {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createCommentUrl = (params: CreateCommentUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":";;;;;;;AAMO,MAAMA,gBAAgB,GAAIC,MAAD,IAAmD;EAC/E;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,0CAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC,eAAX;IAA4BC,eAA5B;IAA6CC;EAA7C,IAAwDP,MAA9D;EAEA,OAAQ,GAAEI,OAAQ,wBAAuBE,eAAgB,IAAGC,MAAO,IAAGF,eAAgB,EAAtF;AACH,CAfM"}
1
+ {"version":3,"names":["createCommentUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId","exports"],"sources":["commentUrl.ts"],"sourcesContent":["interface CreateCommentUrlParams {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createCommentUrl = (params: CreateCommentUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":";;;;;;AAMO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAC,qBAAqBF,GAAG,0CAA0C,CAAC;IAC/E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,eAAe;IAAEC,eAAe;IAAEC;EAAO,CAAC,GAAGP,MAAM;EAEpE,OAAO,GAAGI,OAAO,wBAAwBE,eAAe,IAAIC,MAAM,IAAIF,eAAe,EAAE;AAC3F,CAAC;AAACG,OAAA,CAAAT,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ApwContext } from "../../../types";
1
+ import type { ApwContext } from "../../../types";
2
2
  export declare const attachContentReviewAfterCreate: (context: ApwContext) => void;
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.attachContentReviewAfterCreate = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _appUrl = require("./appUrl");
13
-
9
+ var _getAppUrl = require("./getAppUrl");
14
10
  var _contentReviewUrl = require("./contentReviewUrl");
15
-
16
11
  var _contentUrl = require("./contentUrl");
17
-
18
12
  var _reviewers = require("./reviewers");
19
-
20
13
  var _sendContentReviewNotification = require("./sendContentReviewNotification");
21
-
22
14
  const attachContentReviewAfterCreate = context => {
23
15
  context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
24
16
  contentReview
@@ -27,62 +19,49 @@ const attachContentReviewAfterCreate = context => {
27
19
  if (contentReview.steps.length === 0) {
28
20
  return;
29
21
  }
30
-
31
22
  const [step] = contentReview.steps;
32
-
33
- if (!(step !== null && step !== void 0 && step.id)) {
23
+ if (!step?.id) {
34
24
  return;
35
25
  }
36
-
37
- const settings = await (0, _appUrl.getAppUrl)(context);
38
-
26
+ const settings = await (0, _getAppUrl.getAppUrl)(context);
39
27
  if (!settings) {
40
28
  return;
41
29
  }
42
-
43
30
  const contentReviewUrl = (0, _contentReviewUrl.createContentReviewUrl)({
44
31
  baseUrl: settings.appUrl,
45
32
  contentReviewId: contentReview.id,
46
33
  stepId: step.id
47
34
  });
48
-
49
35
  if (!contentReviewUrl) {
50
36
  return;
51
37
  }
38
+
52
39
  /**
53
40
  * We go and check the workflow.
54
41
  */
55
-
56
-
57
42
  const workflow = await context.apw.workflow.get(contentReview.workflowId);
58
-
59
43
  if (!workflow) {
60
44
  throw new _error.default(`There is no workflow with Id "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
61
45
  workflowId: contentReview.workflowId
62
46
  });
63
47
  }
64
-
65
48
  const contentUrl = (0, _contentUrl.createContentUrl)({
66
49
  plugins: context.plugins,
67
50
  baseUrl: settings.appUrl,
68
51
  contentReview,
69
52
  workflow
70
53
  });
71
-
72
54
  if (!contentUrl) {
73
55
  return;
74
56
  }
75
-
76
57
  const reviewers = await (0, _reviewers.fetchReviewers)({
77
58
  context,
78
59
  workflow,
79
60
  exclude: [contentReview.createdBy.id]
80
61
  });
81
-
82
62
  if (reviewers.length === 0) {
83
63
  return;
84
64
  }
85
-
86
65
  try {
87
66
  await (0, _sendContentReviewNotification.sendContentReviewNotification)({
88
67
  context,
@@ -107,16 +86,11 @@ const attachContentReviewAfterCreate = context => {
107
86
  });
108
87
  }
109
88
  };
110
-
111
- try {
112
- context.security.disableAuthorization();
113
- await execute();
114
- } catch (ex) {
115
- throw ex;
116
- } finally {
117
- context.security.enableAuthorization();
118
- }
89
+ await context.security.withoutAuthorization(async () => {
90
+ return execute();
91
+ });
119
92
  });
120
93
  };
94
+ exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
121
95
 
122
- exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
96
+ //# sourceMappingURL=contentReviewAfterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","disableAuthorization","enableAuthorization"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./appUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n try {\n context.security.disableAuthorization();\n await execute();\n } catch (ex) {\n throw ex;\n } finally {\n context.security.enableAuthorization();\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,8BAA8B,GAAIC,OAAD,IAA+B;EACzEA,OAAO,CAACC,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AAC,yBAAA,EAAe;QACnC1B,OADmC;QAEnCkB,QAFmC;QAGnCS,OAAO,EAAE,CAACzB,aAAa,CAAC0B,SAAd,CAAwBnB,EAAzB;MAH0B,CAAf,CAAxB;;MAKA,IAAIgB,SAAS,CAAClB,MAAV,KAAqB,CAAzB,EAA4B;QACxB;MACH;;MAED,IAAI;QACA,MAAM,IAAAsB,4DAAA,EAA8B;UAChC7B,OADgC;UAEhCyB,SAFgC;UAGhCvB,aAHgC;UAIhCgB,QAJgC;UAKhCN,gBALgC;UAMhCU;QANgC,CAA9B,CAAN;MAQH,CATD,CASE,OAAOQ,EAAP,EAAW;QACT,MAAM,IAAIT,cAAJ,CACD,8CADC,EAEF,uCAFE,EAGF;UACID,UAAU,EAAEF,QAAQ,CAACT,EADzB;UAEIO,eAAe,EAAEd,aAAa,CAACO,EAFnC;UAGIG,gBAHJ;UAIIU,UAJJ;UAKIS,KAAK,EAAE;YACHC,OAAO,EAAEF,EAAE,CAACE,OADT;YAEHC,IAAI,EAAEH,EAAE,CAACG,IAFN;YAGHC,IAAI,EAAEJ,EAAE,CAACI,IAHN;YAIHC,KAAK,EAAEL,EAAE,CAACK;UAJP;QALX,CAHE,CAAN;MAgBH;IACJ,CAlFD;;IAoFA,IAAI;MACAnC,OAAO,CAACoC,QAAR,CAAiBC,oBAAjB;MACA,MAAMhC,OAAO,EAAb;IACH,CAHD,CAGE,OAAOyB,EAAP,EAAW;MACT,MAAMA,EAAN;IACH,CALD,SAKU;MACN9B,OAAO,CAACoC,QAAR,CAAiBE,mBAAjB;IACH;EACJ,CA7FD;AA8FH,CA/FM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_getAppUrl","_contentReviewUrl","_contentUrl","_reviewers","_sendContentReviewNotification","attachContentReviewAfterCreate","context","apw","contentReview","onContentReviewAfterCreate","subscribe","execute","steps","length","step","id","settings","getAppUrl","contentReviewUrl","createContentReviewUrl","baseUrl","appUrl","contentReviewId","stepId","workflow","get","workflowId","WebinyError","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","sendContentReviewNotification","ex","error","message","code","data","stack","security","withoutAuthorization","exports"],"sources":["contentReviewAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ApwContext } from \"~/types\";\nimport { getAppUrl } from \"./getAppUrl\";\nimport { createContentReviewUrl } from \"./contentReviewUrl\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { sendContentReviewNotification } from \"./sendContentReviewNotification\";\n\nexport const attachContentReviewAfterCreate = (context: ApwContext): void => {\n context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const execute = async () => {\n if (contentReview.steps.length === 0) {\n return;\n }\n const [step] = contentReview.steps;\n if (!step?.id) {\n return;\n }\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n\n const contentReviewUrl = createContentReviewUrl({\n baseUrl: settings.appUrl,\n contentReviewId: contentReview.id,\n stepId: step.id\n });\n if (!contentReviewUrl) {\n return;\n }\n\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with Id \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [contentReview.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendContentReviewNotification({\n context,\n reviewers,\n contentReview,\n workflow,\n contentReviewUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send content review notifications.`,\n \"CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n contentReviewId: contentReview.id,\n contentReviewUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n await context.security.withoutAuthorization(async () => {\n return execute();\n });\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,8BAAA,GAAAL,OAAA;AAEO,MAAMM,8BAA8B,GAAIC,OAAmB,IAAW;EACzEA,OAAO,CAACC,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IACxF,MAAMG,OAAO,GAAG,MAAAA,CAAA,KAAY;MACxB,IAAIH,aAAa,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;QAClC;MACJ;MACA,MAAM,CAACC,IAAI,CAAC,GAAGN,aAAa,CAACI,KAAK;MAClC,IAAI,CAACE,IAAI,EAAEC,EAAE,EAAE;QACX;MACJ;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,oBAAS,EAACX,OAAO,CAAC;MACzC,IAAI,CAACU,QAAQ,EAAE;QACX;MACJ;MAEA,MAAME,gBAAgB,GAAG,IAAAC,wCAAsB,EAAC;QAC5CC,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBC,eAAe,EAAEd,aAAa,CAACO,EAAE;QACjCQ,MAAM,EAAET,IAAI,CAACC;MACjB,CAAC,CAAC;MACF,IAAI,CAACG,gBAAgB,EAAE;QACnB;MACJ;;MAEA;AACZ;AACA;MACY,MAAMM,QAAQ,GAAG,MAAMlB,OAAO,CAACC,GAAG,CAACiB,QAAQ,CAACC,GAAG,CAACjB,aAAa,CAACkB,UAAU,CAAC;MACzE,IAAI,CAACF,QAAQ,EAAE;QACX,MAAM,IAAIG,cAAW,C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iC,OAAA,CAAAvC,8BAAA,GAAAA,8BAAA","ignoreList":[]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createContentReviewUrl = void 0;
7
-
8
7
  const createContentReviewUrl = params => {
9
8
  /**
10
9
  * All variables must exist for URL to be created.
@@ -14,11 +13,9 @@ const createContentReviewUrl = params => {
14
13
  if (!!key) {
15
14
  continue;
16
15
  }
17
-
18
16
  console.log(`Missing variable "${key}", which we use to create a comment URL.`);
19
17
  return null;
20
18
  }
21
-
22
19
  const {
23
20
  baseUrl,
24
21
  contentReviewId,
@@ -26,5 +23,6 @@ const createContentReviewUrl = params => {
26
23
  } = params;
27
24
  return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;
28
25
  };
26
+ exports.createContentReviewUrl = createContentReviewUrl;
29
27
 
30
- exports.createContentReviewUrl = createContentReviewUrl;
28
+ //# sourceMappingURL=contentReviewUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createContentReviewUrl","params","key","console","log","baseUrl","contentReviewId","stepId"],"sources":["contentReviewUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createContentReviewUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;\n};\n"],"mappings":";;;;;;;AAKO,MAAMA,sBAAsB,GAAIC,MAAD,IAAoB;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,0CAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC,eAAX;IAA4BC;EAA5B,IAAuCN,MAA7C;EAEA,OAAQ,GAAEI,OAAQ,wBAAuBC,eAAgB,IAAGC,MAAO,EAAnE;AACH,CAfM"}
1
+ {"version":3,"names":["createContentReviewUrl","params","key","console","log","baseUrl","contentReviewId","stepId","exports"],"sources":["contentReviewUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createContentReviewUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;\n};\n"],"mappings":";;;;;;AAKO,MAAMA,sBAAsB,GAAIC,MAAc,IAAK;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAC,qBAAqBF,GAAG,0CAA0C,CAAC;IAC/E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,eAAe;IAAEC;EAAO,CAAC,GAAGN,MAAM;EAEnD,OAAO,GAAGI,OAAO,wBAAwBC,eAAe,IAAIC,MAAM,EAAE;AACxE,CAAC;AAACC,OAAA,CAAAR,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { PluginsContainer } from "@webiny/plugins";
2
- import { ApwContentUrlPluginCbParams } from "../../../ApwContentUrlPlugin";
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ import type { ApwContentUrlPluginCbParams } from "../../../ApwContentUrlPlugin";
3
3
  interface Params extends ApwContentUrlPluginCbParams {
4
4
  plugins: PluginsContainer;
5
5
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createContentUrl = void 0;
7
-
8
7
  var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
9
-
10
8
  const createContentUrl = params => {
11
9
  const {
12
10
  plugins,
@@ -18,12 +16,11 @@ const createContentUrl = params => {
18
16
  const [contentUrlPlugin] = plugins.byType(_ApwContentUrlPlugin.ApwContentUrlPlugin.type).filter(plugin => {
19
17
  return plugin.canUse(contentType);
20
18
  }).reverse();
21
-
22
19
  if (!contentUrlPlugin) {
23
20
  return null;
24
21
  }
25
-
26
22
  return contentUrlPlugin.create(params);
27
23
  };
24
+ exports.createContentUrl = createContentUrl;
28
25
 
29
- exports.createContentUrl = createContentUrl;
26
+ //# sourceMappingURL=contentUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createContentUrl","params","plugins","contentReview","type","contentType","content","contentUrlPlugin","byType","ApwContentUrlPlugin","filter","plugin","canUse","reverse","create"],"sources":["contentUrl.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ApwContentUrlPlugin, ApwContentUrlPluginCbParams } from \"~/ApwContentUrlPlugin\";\n\ninterface Params extends ApwContentUrlPluginCbParams {\n plugins: PluginsContainer;\n}\n\nexport const createContentUrl = (params: Params): string | null => {\n const { plugins, contentReview } = params;\n\n const { type: contentType } = contentReview.content;\n\n const [contentUrlPlugin] = plugins\n .byType<ApwContentUrlPlugin>(ApwContentUrlPlugin.type)\n .filter(plugin => {\n return plugin.canUse(contentType);\n })\n .reverse();\n if (!contentUrlPlugin) {\n return null;\n }\n\n return contentUrlPlugin.create(params);\n};\n"],"mappings":";;;;;;;AACA;;AAMO,MAAMA,gBAAgB,GAAIC,MAAD,IAAmC;EAC/D,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAA6BF,MAAnC;EAEA,MAAM;IAAEG,IAAI,EAAEC;EAAR,IAAwBF,aAAa,CAACG,OAA5C;EAEA,MAAM,CAACC,gBAAD,IAAqBL,OAAO,CAC7BM,MADsB,CACMC,wCAAA,CAAoBL,IAD1B,EAEtBM,MAFsB,CAEfC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcP,WAAd,CAAP;EACH,CAJsB,EAKtBQ,OALsB,EAA3B;;EAMA,IAAI,CAACN,gBAAL,EAAuB;IACnB,OAAO,IAAP;EACH;;EAED,OAAOA,gBAAgB,CAACO,MAAjB,CAAwBb,MAAxB,CAAP;AACH,CAhBM"}
1
+ {"version":3,"names":["_ApwContentUrlPlugin","require","createContentUrl","params","plugins","contentReview","type","contentType","content","contentUrlPlugin","byType","ApwContentUrlPlugin","filter","plugin","canUse","reverse","create","exports"],"sources":["contentUrl.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type { ApwContentUrlPluginCbParams } from \"~/ApwContentUrlPlugin\";\nimport { ApwContentUrlPlugin } from \"~/ApwContentUrlPlugin\";\n\ninterface Params extends ApwContentUrlPluginCbParams {\n plugins: PluginsContainer;\n}\n\nexport const createContentUrl = (params: Params): string | null => {\n const { plugins, contentReview } = params;\n\n const { type: contentType } = contentReview.content;\n\n const [contentUrlPlugin] = plugins\n .byType<ApwContentUrlPlugin>(ApwContentUrlPlugin.type)\n .filter(plugin => {\n return plugin.canUse(contentType);\n })\n .reverse();\n if (!contentUrlPlugin) {\n return null;\n }\n\n return contentUrlPlugin.create(params);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,oBAAA,GAAAC,OAAA;AAMO,MAAMC,gBAAgB,GAAIC,MAAc,IAAoB;EAC/D,MAAM;IAAEC,OAAO;IAAEC;EAAc,CAAC,GAAGF,MAAM;EAEzC,MAAM;IAAEG,IAAI,EAAEC;EAAY,CAAC,GAAGF,aAAa,CAACG,OAAO;EAEnD,MAAM,CAACC,gBAAgB,CAAC,GAAGL,OAAO,CAC7BM,MAAM,CAAsBC,wCAAmB,CAACL,IAAI,CAAC,CACrDM,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACP,WAAW,CAAC;EACrC,CAAC,CAAC,CACDQ,OAAO,CAAC,CAAC;EACd,IAAI,CAACN,gBAAgB,EAAE;IACnB,OAAO,IAAI;EACf;EAEA,OAAOA,gBAAgB,CAACO,MAAM,CAACb,MAAM,CAAC;AAC1C,CAAC;AAACc,OAAA,CAAAf,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwContext } from "../../../types.js";
2
+ export declare const getAppUrl: (context: Pick<ApwContext, "db">) => Promise<any>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAppUrl = void 0;
7
+ var _api = require("@webiny/api");
8
+ const getAppUrl = async context => {
9
+ const client = context.db.driver.getClient();
10
+ _api.ServiceDiscovery.setDocumentClient(client);
11
+ const manifest = await _api.ServiceDiscovery.load();
12
+ if (!manifest) {
13
+ return null;
14
+ }
15
+ return manifest.admin?.cloudfront?.domainName;
16
+ };
17
+ exports.getAppUrl = getAppUrl;
18
+
19
+ //# sourceMappingURL=getAppUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_api","require","getAppUrl","context","client","db","driver","getClient","ServiceDiscovery","setDocumentClient","manifest","load","admin","cloudfront","domainName","exports"],"sources":["getAppUrl.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { ApwContext } from \"~/types.js\";\n\nexport const getAppUrl = async (context: Pick<ApwContext, \"db\">) => {\n const client = context.db.driver.getClient() as DynamoDBDocument;\n ServiceDiscovery.setDocumentClient(client);\n const manifest = await ServiceDiscovery.load();\n if (!manifest) {\n return null;\n }\n return manifest.admin?.cloudfront?.domainName;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAIO,MAAMC,SAAS,GAAG,MAAOC,OAA+B,IAAK;EAChE,MAAMC,MAAM,GAAGD,OAAO,CAACE,EAAE,CAACC,MAAM,CAACC,SAAS,CAAC,CAAqB;EAChEC,qBAAgB,CAACC,iBAAiB,CAACL,MAAM,CAAC;EAC1C,MAAMM,QAAQ,GAAG,MAAMF,qBAAgB,CAACG,IAAI,CAAC,CAAC;EAC9C,IAAI,CAACD,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,OAAOA,QAAQ,CAACE,KAAK,EAAEC,UAAU,EAAEC,UAAU;AACjD,CAAC;AAACC,OAAA,CAAAb,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApwContentTypes, ApwContext } from "../../../types";
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
2
  import { ApwChangeRequestNotification } from "../../../ApwChangeRequestNotification";
3
3
  interface GetLastChangeRequestNotificationPluginParams {
4
4
  context: ApwContext;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLastChangeRequestNotificationPlugin = void 0;
7
-
8
7
  var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
9
-
10
8
  const getLastChangeRequestNotificationPlugin = params => {
11
9
  const {
12
10
  context,
@@ -15,11 +13,11 @@ const getLastChangeRequestNotificationPlugin = params => {
15
13
  /**
16
14
  * We need the plugin to create the notification text.
17
15
  */
18
-
19
16
  const plugins = context.plugins.byType(_ApwChangeRequestNotification.ApwChangeRequestNotification.type).filter(plugin => {
20
17
  return plugin.canUse(type);
21
18
  });
22
19
  return plugins.shift();
23
20
  };
21
+ exports.getLastChangeRequestNotificationPlugin = getLastChangeRequestNotificationPlugin;
24
22
 
25
- exports.getLastChangeRequestNotificationPlugin = getLastChangeRequestNotificationPlugin;
23
+ //# sourceMappingURL=lastChangeRequestNotificationPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLastChangeRequestNotificationPlugin","params","context","type","plugins","byType","ApwChangeRequestNotification","filter","plugin","canUse","shift"],"sources":["lastChangeRequestNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\ninterface GetLastChangeRequestNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastChangeRequestNotificationPlugin {\n (params: GetLastChangeRequestNotificationPluginParams):\n | ApwChangeRequestNotification\n | undefined;\n}\nexport const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwChangeRequestNotification>(ApwChangeRequestNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;;AACA;;AAWO,MAAMA,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACR;AACA;;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CAC0BC,0DAAA,CAA6BH,IADvD,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAbE"}
1
+ {"version":3,"names":["_ApwChangeRequestNotification","require","getLastChangeRequestNotificationPlugin","params","context","type","plugins","byType","ApwChangeRequestNotification","filter","plugin","canUse","shift","exports"],"sources":["lastChangeRequestNotificationPlugin.ts"],"sourcesContent":["import type { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\ninterface GetLastChangeRequestNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastChangeRequestNotificationPlugin {\n (params: GetLastChangeRequestNotificationPluginParams):\n | ApwChangeRequestNotification\n | undefined;\n}\nexport const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwChangeRequestNotification>(ApwChangeRequestNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;AACA,IAAAA,6BAAA,GAAAC,OAAA;AAWO,MAAMC,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAO;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAChC;AACR;AACA;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAA+BC,0DAA4B,CAACH,IAAI,CAAC,CACvEI,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACN,IAAI,CAAC;EAC9B,CAAC,CAAC;EAEN,OAAOC,OAAO,CAACM,KAAK,CAAC,CAAC;AAC1B,CAAC;AAACC,OAAA,CAAAX,sCAAA,GAAAA,sCAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApwContentTypes, ApwContext } from "../../../types";
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
2
  import { ApwCommentNotification } from "../../../ApwCommentNotification";
3
3
  interface GetLastCommentNotificationPluginParams {
4
4
  context: ApwContext;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLastCommentNotificationPlugin = void 0;
7
-
8
7
  var _ApwCommentNotification = require("../../../ApwCommentNotification");
9
-
10
8
  const getLastCommentNotificationPlugin = params => {
11
9
  const {
12
10
  context,
@@ -15,11 +13,11 @@ const getLastCommentNotificationPlugin = params => {
15
13
  /**
16
14
  * We need the plugin to create the notification text.
17
15
  */
18
-
19
16
  const plugins = context.plugins.byType(_ApwCommentNotification.ApwCommentNotification.type).filter(plugin => {
20
17
  return plugin.canUse(type);
21
18
  });
22
19
  return plugins.shift();
23
20
  };
21
+ exports.getLastCommentNotificationPlugin = getLastCommentNotificationPlugin;
24
22
 
25
- exports.getLastCommentNotificationPlugin = getLastCommentNotificationPlugin;
23
+ //# sourceMappingURL=lastCommentNotificationPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLastCommentNotificationPlugin","params","context","type","plugins","byType","ApwCommentNotification","filter","plugin","canUse","shift"],"sources":["lastCommentNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwCommentNotification } from \"~/ApwCommentNotification\";\n\ninterface GetLastCommentNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastCommentNotificationPlugin {\n (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;\n}\nexport const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin = params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwCommentNotification>(ApwCommentNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n};\n"],"mappings":";;;;;;;AACA;;AASO,MAAMA,gCAAkE,GAAGC,MAAM,IAAI;EACxF,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACJ;AACA;;EACI,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CACoBC,8CAAA,CAAuBH,IAD3C,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAZM"}
1
+ {"version":3,"names":["_ApwCommentNotification","require","getLastCommentNotificationPlugin","params","context","type","plugins","byType","ApwCommentNotification","filter","plugin","canUse","shift","exports"],"sources":["lastCommentNotificationPlugin.ts"],"sourcesContent":["import type { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwCommentNotification } from \"~/ApwCommentNotification\";\n\ninterface GetLastCommentNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastCommentNotificationPlugin {\n (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;\n}\nexport const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin = params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwCommentNotification>(ApwCommentNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n};\n"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,OAAA;AASO,MAAMC,gCAAkE,GAAGC,MAAM,IAAI;EACxF,MAAM;IAAEC,OAAO;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAChC;AACJ;AACA;EACI,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACH,IAAI,CAAC,CAC3DI,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACN,IAAI,CAAC;EAC9B,CAAC,CAAC;EAEN,OAAOC,OAAO,CAACM,KAAK,CAAC,CAAC;AAC1B,CAAC;AAACC,OAAA,CAAAX,gCAAA,GAAAA,gCAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApwContentTypes, ApwContext } from "../../../types";
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
2
  import { ApwContentReviewNotification } from "../../../ApwContentReviewNotification";
3
3
  interface GetLastContentReviewNotificationPluginParams {
4
4
  context: ApwContext;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getLastContentReviewNotificationPlugin = void 0;
7
-
8
7
  var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
9
-
10
8
  const getLastContentReviewNotificationPlugin = params => {
11
9
  const {
12
10
  context,
@@ -15,11 +13,11 @@ const getLastContentReviewNotificationPlugin = params => {
15
13
  /**
16
14
  * We need the plugin to create the notification text.
17
15
  */
18
-
19
16
  const plugins = context.plugins.byType(_ApwContentReviewNotification.ApwContentReviewNotification.type).filter(plugin => {
20
17
  return plugin.canUse(type);
21
18
  });
22
19
  return plugins.shift();
23
20
  };
21
+ exports.getLastContentReviewNotificationPlugin = getLastContentReviewNotificationPlugin;
24
22
 
25
- exports.getLastContentReviewNotificationPlugin = getLastContentReviewNotificationPlugin;
23
+ //# sourceMappingURL=lastContentReviewNotificationPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLastContentReviewNotificationPlugin","params","context","type","plugins","byType","ApwContentReviewNotification","filter","plugin","canUse","shift"],"sources":["lastContentReviewNotificationPlugin.ts"],"sourcesContent":["import { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\ninterface GetLastContentReviewNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastContentReviewNotificationPlugin {\n (params: GetLastContentReviewNotificationPluginParams):\n | ApwContentReviewNotification\n | undefined;\n}\nexport const getLastContentReviewNotificationPlugin: GetLastContentReviewNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwContentReviewNotification>(ApwContentReviewNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;;AACA;;AAWO,MAAMA,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoBF,MAA1B;EACA;AACR;AACA;;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAR,CACXC,MADW,CAC0BC,0DAAA,CAA6BH,IADvD,EAEXI,MAFW,CAEJC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAP,CAAcN,IAAd,CAAP;EACH,CAJW,CAAhB;EAMA,OAAOC,OAAO,CAACM,KAAR,EAAP;AACH,CAbE"}
1
+ {"version":3,"names":["_ApwContentReviewNotification","require","getLastContentReviewNotificationPlugin","params","context","type","plugins","byType","ApwContentReviewNotification","filter","plugin","canUse","shift","exports"],"sources":["lastContentReviewNotificationPlugin.ts"],"sourcesContent":["import type { ApwContentTypes, ApwContext } from \"~/types\";\nimport { ApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\ninterface GetLastContentReviewNotificationPluginParams {\n context: ApwContext;\n type: ApwContentTypes;\n}\ninterface GetLastContentReviewNotificationPlugin {\n (params: GetLastContentReviewNotificationPluginParams):\n | ApwContentReviewNotification\n | undefined;\n}\nexport const getLastContentReviewNotificationPlugin: GetLastContentReviewNotificationPlugin =\n params => {\n const { context, type } = params;\n /**\n * We need the plugin to create the notification text.\n */\n const plugins = context.plugins\n .byType<ApwContentReviewNotification>(ApwContentReviewNotification.type)\n .filter(plugin => {\n return plugin.canUse(type);\n });\n\n return plugins.shift();\n };\n"],"mappings":";;;;;;AACA,IAAAA,6BAAA,GAAAC,OAAA;AAWO,MAAMC,sCAA8E,GACvFC,MAAM,IAAI;EACN,MAAM;IAAEC,OAAO;IAAEC;EAAK,CAAC,GAAGF,MAAM;EAChC;AACR;AACA;EACQ,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAA+BC,0DAA4B,CAACH,IAAI,CAAC,CACvEI,MAAM,CAACC,MAAM,IAAI;IACd,OAAOA,MAAM,CAACC,MAAM,CAACN,IAAI,CAAC;EAC9B,CAAC,CAAC;EAEN,OAAOC,OAAO,CAACM,KAAK,CAAC,CAAC;AAC1B,CAAC;AAACC,OAAA,CAAAX,sCAAA,GAAAA,sCAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from "../../../types";
1
+ import type { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from "../../../types";
2
2
  interface GetReviewerIdListParams {
3
3
  steps: ApwWorkflowStep[];
4
4
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getReviewerIdList = exports.fetchReviewers = void 0;
7
-
8
7
  const getReviewerIdList = ({
9
8
  steps
10
9
  }) => {
@@ -13,16 +12,12 @@ const getReviewerIdList = ({
13
12
  if (collection.includes(reviewer.id)) {
14
13
  return collection;
15
14
  }
16
-
17
15
  collection.push(reviewer.id);
18
16
  }
19
-
20
17
  return collection;
21
18
  }, []);
22
19
  };
23
-
24
20
  exports.getReviewerIdList = getReviewerIdList;
25
-
26
21
  const fetchReviewers = async params => {
27
22
  const {
28
23
  context,
@@ -30,22 +25,23 @@ const fetchReviewers = async params => {
30
25
  exclude
31
26
  } = params;
32
27
  const idList = getReviewerIdList(workflow);
33
- context.security.disableAuthorization();
34
- const [reviewers] = await context.apw.reviewer.list({
35
- where: {
36
- id_in: idList
37
- },
38
- limit: 10000
39
- });
40
- return reviewers.filter(item => {
41
- if (!item.email) {
42
- return false;
43
- } else if (exclude.includes(item.identityId)) {
44
- return false;
45
- }
46
-
47
- return true;
28
+ return context.security.withoutAuthorization(async () => {
29
+ const [reviewers] = await context.apw.reviewer.list({
30
+ where: {
31
+ id_in: idList
32
+ },
33
+ limit: 10000
34
+ });
35
+ return reviewers.filter(item => {
36
+ if (!item.email) {
37
+ return false;
38
+ } else if (exclude.includes(item.identityId)) {
39
+ return false;
40
+ }
41
+ return true;
42
+ });
48
43
  });
49
44
  };
45
+ exports.fetchReviewers = fetchReviewers;
50
46
 
51
- exports.fetchReviewers = fetchReviewers;
47
+ //# sourceMappingURL=reviewers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getReviewerIdList","steps","reduce","collection","step","reviewer","reviewers","includes","id","push","fetchReviewers","params","context","workflow","exclude","idList","security","disableAuthorization","apw","list","where","id_in","limit","filter","item","email","identityId"],"sources":["reviewers.ts"],"sourcesContent":["import { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from \"~/types\";\n\ninterface GetReviewerIdListParams {\n steps: ApwWorkflowStep[];\n}\ninterface GetReviewerIdList {\n (params: GetReviewerIdListParams): string[];\n}\nexport const getReviewerIdList: GetReviewerIdList = ({ steps }) => {\n return steps.reduce<string[]>((collection, step) => {\n for (const reviewer of step.reviewers) {\n if (collection.includes(reviewer.id)) {\n return collection;\n }\n collection.push(reviewer.id);\n }\n\n return collection;\n }, []);\n};\n\ninterface FetchReviewersParams {\n context: ApwContext;\n workflow: ApwWorkflow;\n exclude: string[];\n}\nexport const fetchReviewers = async (\n params: FetchReviewersParams\n): Promise<ApwReviewerWithEmail[]> => {\n const { context, workflow, exclude } = params;\n\n const idList = getReviewerIdList(workflow);\n\n context.security.disableAuthorization();\n\n const [reviewers] = await context.apw.reviewer.list({\n where: {\n id_in: idList\n },\n limit: 10000\n });\n return reviewers.filter(item => {\n if (!item.email) {\n return false;\n } else if (exclude.includes(item.identityId)) {\n return false;\n }\n\n return true;\n }) as ApwReviewerWithEmail[];\n};\n"],"mappings":";;;;;;;AAQO,MAAMA,iBAAoC,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAe;EAC/D,OAAOA,KAAK,CAACC,MAAN,CAAuB,CAACC,UAAD,EAAaC,IAAb,KAAsB;IAChD,KAAK,MAAMC,QAAX,IAAuBD,IAAI,CAACE,SAA5B,EAAuC;MACnC,IAAIH,UAAU,CAACI,QAAX,CAAoBF,QAAQ,CAACG,EAA7B,CAAJ,EAAsC;QAClC,OAAOL,UAAP;MACH;;MACDA,UAAU,CAACM,IAAX,CAAgBJ,QAAQ,CAACG,EAAzB;IACH;;IAED,OAAOL,UAAP;EACH,CATM,EASJ,EATI,CAAP;AAUH,CAXM;;;;AAkBA,MAAMO,cAAc,GAAG,MAC1BC,MAD0B,IAEQ;EAClC,MAAM;IAAEC,OAAF;IAAWC,QAAX;IAAqBC;EAArB,IAAiCH,MAAvC;EAEA,MAAMI,MAAM,GAAGf,iBAAiB,CAACa,QAAD,CAAhC;EAEAD,OAAO,CAACI,QAAR,CAAiBC,oBAAjB;EAEA,MAAM,CAACX,SAAD,IAAc,MAAMM,OAAO,CAACM,GAAR,CAAYb,QAAZ,CAAqBc,IAArB,CAA0B;IAChDC,KAAK,EAAE;MACHC,KAAK,EAAEN;IADJ,CADyC;IAIhDO,KAAK,EAAE;EAJyC,CAA1B,CAA1B;EAMA,OAAOhB,SAAS,CAACiB,MAAV,CAAiBC,IAAI,IAAI;IAC5B,IAAI,CAACA,IAAI,CAACC,KAAV,EAAiB;MACb,OAAO,KAAP;IACH,CAFD,MAEO,IAAIX,OAAO,CAACP,QAAR,CAAiBiB,IAAI,CAACE,UAAtB,CAAJ,EAAuC;MAC1C,OAAO,KAAP;IACH;;IAED,OAAO,IAAP;EACH,CARM,CAAP;AASH,CAxBM"}
1
+ {"version":3,"names":["getReviewerIdList","steps","reduce","collection","step","reviewer","reviewers","includes","id","push","exports","fetchReviewers","params","context","workflow","exclude","idList","security","withoutAuthorization","apw","list","where","id_in","limit","filter","item","email","identityId"],"sources":["reviewers.ts"],"sourcesContent":["import type { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from \"~/types\";\n\ninterface GetReviewerIdListParams {\n steps: ApwWorkflowStep[];\n}\n\ninterface GetReviewerIdList {\n (params: GetReviewerIdListParams): string[];\n}\n\nexport const getReviewerIdList: GetReviewerIdList = ({ steps }) => {\n return steps.reduce<string[]>((collection, step) => {\n for (const reviewer of step.reviewers) {\n if (collection.includes(reviewer.id)) {\n return collection;\n }\n collection.push(reviewer.id);\n }\n\n return collection;\n }, []);\n};\n\ninterface FetchReviewersParams {\n context: ApwContext;\n workflow: ApwWorkflow;\n exclude: string[];\n}\n\nexport const fetchReviewers = async (\n params: FetchReviewersParams\n): Promise<ApwReviewerWithEmail[]> => {\n const { context, workflow, exclude } = params;\n\n const idList = getReviewerIdList(workflow);\n\n return context.security.withoutAuthorization(async () => {\n const [reviewers] = await context.apw.reviewer.list({\n where: {\n id_in: idList\n },\n limit: 10000\n });\n return reviewers.filter((item): item is ApwReviewerWithEmail => {\n if (!item.email) {\n return false;\n } else if (exclude.includes(item.identityId)) {\n return false;\n }\n\n return true;\n });\n });\n};\n"],"mappings":";;;;;;AAUO,MAAMA,iBAAoC,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EAC/D,OAAOA,KAAK,CAACC,MAAM,CAAW,CAACC,UAAU,EAAEC,IAAI,KAAK;IAChD,KAAK,MAAMC,QAAQ,IAAID,IAAI,CAACE,SAAS,EAAE;MACnC,IAAIH,UAAU,CAACI,QAAQ,CAACF,QAAQ,CAACG,EAAE,CAAC,EAAE;QAClC,OAAOL,UAAU;MACrB;MACAA,UAAU,CAACM,IAAI,CAACJ,QAAQ,CAACG,EAAE,CAAC;IAChC;IAEA,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAACO,OAAA,CAAAV,iBAAA,GAAAA,iBAAA;AAQK,MAAMW,cAAc,GAAG,MAC1BC,MAA4B,IACM;EAClC,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,MAAMI,MAAM,GAAGhB,iBAAiB,CAACc,QAAQ,CAAC;EAE1C,OAAOD,OAAO,CAACI,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACrD,MAAM,CAACZ,SAAS,CAAC,GAAG,MAAMO,OAAO,CAACM,GAAG,CAACd,QAAQ,CAACe,IAAI,CAAC;MAChDC,KAAK,EAAE;QACHC,KAAK,EAAEN;MACX,CAAC;MACDO,KAAK,EAAE;IACX,CAAC,CAAC;IACF,OAAOjB,SAAS,CAACkB,MAAM,CAAEC,IAAI,IAAmC;MAC5D,IAAI,CAACA,IAAI,CAACC,KAAK,EAAE;QACb,OAAO,KAAK;MAChB,CAAC,MAAM,IAAIX,OAAO,CAACR,QAAQ,CAACkB,IAAI,CAACE,UAAU,CAAC,EAAE;QAC1C,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI;IACf,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACjB,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ApwChangeRequestNotificationCbParams } from "../../../ApwChangeRequestNotification";
1
+ import type { ApwChangeRequestNotificationCbParams } from "../../../ApwChangeRequestNotification";
2
2
  export declare const sendChangeRequestNotification: (params: ApwChangeRequestNotificationCbParams) => Promise<void>;