@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2aaa1916d9

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 (307) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +28 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +28 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +28 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +28 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  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 +84 -113
  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 +3 -4
  39. package/index.js +7 -18
  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 +7 -10
  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.d.ts +1 -0
  58. package/plugins/cms/notifications/changeRequestNotification.js +33 -0
  59. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  60. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  61. package/plugins/cms/notifications/commentNotification.js +33 -0
  62. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  63. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  64. package/plugins/cms/notifications/contentReviewNotification.js +33 -0
  65. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  66. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  67. package/plugins/cms/notifications/contentUrl.js +55 -0
  68. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  69. package/plugins/cms/triggerContentReview.d.ts +2 -2
  70. package/plugins/cms/triggerContentReview.js +5 -18
  71. package/plugins/cms/triggerContentReview.js.map +1 -1
  72. package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
  73. package/plugins/cms/updateContentReviewStatus.js +14 -30
  74. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  75. package/plugins/cms/utils.d.ts +5 -4
  76. package/plugins/cms/utils.js +20 -59
  77. package/plugins/cms/utils.js.map +1 -1
  78. package/plugins/context.d.ts +3 -4
  79. package/plugins/context.js +4 -58
  80. package/plugins/context.js.map +1 -1
  81. package/plugins/graphql/changeRequest.gql.d.ts +1 -1
  82. package/plugins/graphql/changeRequest.gql.js +16 -20
  83. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  84. package/plugins/graphql/comment.gql.d.ts +1 -1
  85. package/plugins/graphql/comment.gql.js +41 -43
  86. package/plugins/graphql/comment.gql.js.map +1 -1
  87. package/plugins/graphql/contentReview.gql.d.ts +1 -1
  88. package/plugins/graphql/contentReview.gql.js +25 -35
  89. package/plugins/graphql/contentReview.gql.js.map +1 -1
  90. package/plugins/graphql/reviewer.gql.d.ts +1 -1
  91. package/plugins/graphql/reviewer.gql.js +17 -20
  92. package/plugins/graphql/reviewer.gql.js.map +1 -1
  93. package/plugins/graphql/utils.d.ts +2 -0
  94. package/plugins/graphql/utils.js +10 -0
  95. package/plugins/graphql/utils.js.map +1 -0
  96. package/plugins/graphql/workflow.gql.d.ts +1 -1
  97. package/plugins/graphql/workflow.gql.js +15 -20
  98. package/plugins/graphql/workflow.gql.js.map +1 -1
  99. package/plugins/graphql.d.ts +1 -1
  100. package/plugins/graphql.js +5 -18
  101. package/plugins/graphql.js.map +1 -1
  102. package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
  103. package/plugins/hooks/createReviewerFromIdentity.js +28 -15
  104. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  105. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
  106. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
  107. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  108. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
  109. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
  110. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  111. package/plugins/hooks/index.d.ts +1 -1
  112. package/plugins/hooks/index.js +4 -13
  113. package/plugins/hooks/index.js.map +1 -1
  114. package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
  115. package/plugins/hooks/initializeContentReviewSteps.js +15 -20
  116. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  117. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  118. package/plugins/hooks/initializeNotifications.js +17 -0
  119. package/plugins/hooks/initializeNotifications.js.map +1 -0
  120. package/plugins/hooks/listContentReviews.d.ts +4 -4
  121. package/plugins/hooks/listContentReviews.js +11 -33
  122. package/plugins/hooks/listContentReviews.js.map +1 -1
  123. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  124. package/plugins/hooks/notifications/changeRequestAfterCreate.js +113 -0
  125. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  126. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  127. package/plugins/hooks/notifications/changeRequestUrl.js +29 -0
  128. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  129. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  130. package/plugins/hooks/notifications/commentAfterCreate.js +124 -0
  131. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  132. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  133. package/plugins/hooks/notifications/commentUrl.js +29 -0
  134. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  135. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  136. package/plugins/hooks/notifications/contentReviewAfterCreate.js +96 -0
  137. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  138. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  139. package/plugins/hooks/notifications/contentReviewUrl.js +28 -0
  140. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  141. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  142. package/plugins/hooks/notifications/contentUrl.js +26 -0
  143. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  144. package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
  145. package/plugins/hooks/notifications/getAppUrl.js +19 -0
  146. package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
  147. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  148. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +23 -0
  149. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  150. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  151. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +23 -0
  152. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  153. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  154. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +23 -0
  155. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  156. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  157. package/plugins/hooks/notifications/reviewers.js +47 -0
  158. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  159. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  160. package/plugins/hooks/notifications/sendChangeRequestNotification.js +43 -0
  161. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  162. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  163. package/plugins/hooks/notifications/sendCommentNotification.js +43 -0
  164. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  165. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  166. package/plugins/hooks/notifications/sendContentReviewNotification.js +43 -0
  167. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  168. package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
  169. package/plugins/hooks/updatePendingChangeRequests.js +7 -13
  170. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  171. package/plugins/hooks/updateTotalComments.d.ts +1 -1
  172. package/plugins/hooks/updateTotalComments.js +21 -23
  173. package/plugins/hooks/updateTotalComments.js.map +1 -1
  174. package/plugins/hooks/validateChangeRequest.d.ts +1 -1
  175. package/plugins/hooks/validateChangeRequest.js +27 -16
  176. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  177. package/plugins/hooks/validateComment.d.ts +1 -1
  178. package/plugins/hooks/validateComment.js +13 -12
  179. package/plugins/hooks/validateComment.js.map +1 -1
  180. package/plugins/hooks/validateContentReview.d.ts +1 -1
  181. package/plugins/hooks/validateContentReview.js +2 -6
  182. package/plugins/hooks/validateContentReview.js.map +1 -1
  183. package/plugins/utils.d.ts +7 -7
  184. package/plugins/utils.js +12 -57
  185. package/plugins/utils.js.map +1 -1
  186. package/scheduler/createScheduleActionMethods.d.ts +1 -1
  187. package/scheduler/createScheduleActionMethods.js +105 -85
  188. package/scheduler/createScheduleActionMethods.js.map +1 -1
  189. package/scheduler/handlers/executeAction/index.d.ts +2 -2
  190. package/scheduler/handlers/executeAction/index.js +47 -41
  191. package/scheduler/handlers/executeAction/index.js.map +1 -1
  192. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  193. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +19 -9
  194. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  195. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +3 -3
  196. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +11 -28
  197. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  198. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +4 -3
  199. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
  200. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  201. package/scheduler/handlers/executeAction/security.d.ts +2 -2
  202. package/scheduler/handlers/executeAction/security.js +2 -11
  203. package/scheduler/handlers/executeAction/security.js.map +1 -1
  204. package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
  205. package/scheduler/handlers/scheduleAction/index.js +23 -38
  206. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  207. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
  208. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
  209. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  210. package/scheduler/handlers/utils.d.ts +2 -4
  211. package/scheduler/handlers/utils.js +22 -53
  212. package/scheduler/handlers/utils.js.map +1 -1
  213. package/scheduler/index.d.ts +1 -1
  214. package/scheduler/index.js +2 -3
  215. package/scheduler/index.js.map +1 -1
  216. package/scheduler/types.d.ts +20 -36
  217. package/scheduler/types.js +11 -23
  218. package/scheduler/types.js.map +1 -1
  219. package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
  220. package/storageOperations/changeRequestStorageOperations.js +43 -41
  221. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  222. package/storageOperations/commentStorageOperations.d.ts +3 -3
  223. package/storageOperations/commentStorageOperations.js +16 -44
  224. package/storageOperations/commentStorageOperations.js.map +1 -1
  225. package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
  226. package/storageOperations/contentReviewStorageOperations.js +19 -41
  227. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  228. package/storageOperations/index.d.ts +3 -9
  229. package/storageOperations/index.js +10 -29
  230. package/storageOperations/index.js.map +1 -1
  231. package/storageOperations/models/changeRequest.model.d.ts +1 -2
  232. package/storageOperations/models/changeRequest.model.js +9 -19
  233. package/storageOperations/models/changeRequest.model.js.map +1 -1
  234. package/storageOperations/models/comment.model.d.ts +1 -2
  235. package/storageOperations/models/comment.model.js +9 -18
  236. package/storageOperations/models/comment.model.js.map +1 -1
  237. package/storageOperations/models/contentReview.model.d.ts +1 -2
  238. package/storageOperations/models/contentReview.model.js +16 -41
  239. package/storageOperations/models/contentReview.model.js.map +1 -1
  240. package/storageOperations/models/index.d.ts +1 -1
  241. package/storageOperations/models/index.js +11 -55
  242. package/storageOperations/models/index.js.map +1 -1
  243. package/storageOperations/models/reviewer.model.d.ts +1 -2
  244. package/storageOperations/models/reviewer.model.js +25 -18
  245. package/storageOperations/models/reviewer.model.js.map +1 -1
  246. package/storageOperations/models/utils.d.ts +2 -2
  247. package/storageOperations/models/utils.js +2 -4
  248. package/storageOperations/models/utils.js.map +1 -1
  249. package/storageOperations/models/workflow.model.d.ts +2 -3
  250. package/storageOperations/models/workflow.model.js +22 -46
  251. package/storageOperations/models/workflow.model.js.map +1 -1
  252. package/storageOperations/reviewerStorageOperations.d.ts +3 -3
  253. package/storageOperations/reviewerStorageOperations.js +19 -38
  254. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  255. package/storageOperations/types.d.ts +2 -2
  256. package/storageOperations/types.js +3 -1
  257. package/storageOperations/types.js.map +1 -1
  258. package/storageOperations/workflowStorageOperations.d.ts +2 -2
  259. package/storageOperations/workflowStorageOperations.js +24 -44
  260. package/storageOperations/workflowStorageOperations.js.map +1 -1
  261. package/types.d.ts +66 -69
  262. package/types.js +121 -43
  263. package/types.js.map +1 -1
  264. package/utils/contentApwSettingsPlugin.d.ts +2 -2
  265. package/utils/contentApwSettingsPlugin.js +2 -6
  266. package/utils/contentApwSettingsPlugin.js.map +1 -1
  267. package/utils/errors.js +2 -17
  268. package/utils/errors.js.map +1 -1
  269. package/utils/fieldResolver.d.ts +2 -2
  270. package/utils/fieldResolver.js +8 -18
  271. package/utils/fieldResolver.js.map +1 -1
  272. package/utils/pickEntryFieldValues.d.ts +3 -0
  273. package/utils/pickEntryFieldValues.js +30 -0
  274. package/utils/pickEntryFieldValues.js.map +1 -0
  275. package/utils/resolve.d.ts +1 -1
  276. package/utils/resolve.js +2 -3
  277. package/utils/resolve.js.map +1 -1
  278. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
  279. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -51
  280. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
  281. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
  282. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -30
  283. package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
  284. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
  285. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -25
  286. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
  287. package/plugins/pageBuilder/index.d.ts +0 -11
  288. package/plugins/pageBuilder/index.js +0 -45
  289. package/plugins/pageBuilder/index.js.map +0 -1
  290. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
  291. package/plugins/pageBuilder/linkContentReviewToPage.js +0 -105
  292. package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
  293. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
  294. package/plugins/pageBuilder/linkWorkflowToPage.js +0 -194
  295. package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
  296. package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
  297. package/plugins/pageBuilder/triggerContentReview.js +0 -50
  298. package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
  299. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
  300. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -79
  301. package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
  302. package/plugins/pageBuilder/utils.d.ts +0 -22
  303. package/plugins/pageBuilder/utils.js +0 -184
  304. package/plugins/pageBuilder/utils.js.map +0 -1
  305. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
  306. package/storageOperations/models/contentModelPluginFactory.js +0 -28
  307. package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachCommentAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _utils = require("../../utils");
10
+ var _contentUrl = require("./contentUrl");
11
+ var _commentUrl = require("./commentUrl");
12
+ var _reviewers = require("./reviewers");
13
+ var _sendCommentNotification = require("./sendCommentNotification");
14
+ var _getAppUrl = require("./getAppUrl");
15
+ const attachCommentAfterCreate = context => {
16
+ context.apw.comment.onCommentAfterCreate.subscribe(async ({
17
+ comment
18
+ }) => {
19
+ const execute = async () => {
20
+ const changeRequest = await context.apw.changeRequest.get(comment.changeRequest);
21
+ if (!changeRequest) {
22
+ throw new _error.default("Missing change request.", "CHANGE_REQUEST_NOT_FOUND", {
23
+ changeRequest: comment.changeRequest,
24
+ comment: comment.id
25
+ });
26
+ }
27
+ const {
28
+ id: contentReviewId,
29
+ stepId
30
+ } = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
31
+ if (!stepId) {
32
+ throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
33
+ step: changeRequest.step
34
+ });
35
+ }
36
+ const settings = await (0, _getAppUrl.getAppUrl)(context);
37
+ if (!settings) {
38
+ return;
39
+ }
40
+ /**
41
+ * We will check if we can create a comment url before we go digging further into the database.
42
+ */
43
+ const commentUrl = (0, _commentUrl.createCommentUrl)({
44
+ baseUrl: settings.appUrl,
45
+ changeRequestId: changeRequest.id,
46
+ contentReviewId,
47
+ stepId
48
+ });
49
+ if (!commentUrl) {
50
+ console.log("No comment url.");
51
+ return;
52
+ }
53
+ /**
54
+ * Let's see if content review exists.
55
+ */
56
+ const contentReview = await context.apw.contentReview.get(contentReviewId);
57
+ if (!contentReview) {
58
+ throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
59
+ contentReviewId
60
+ });
61
+ }
62
+ /**
63
+ * We go and check the workflow.
64
+ */
65
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
66
+ if (!workflow) {
67
+ throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
68
+ workflowId: contentReview.workflowId
69
+ });
70
+ }
71
+ const contentUrl = (0, _contentUrl.createContentUrl)({
72
+ plugins: context.plugins,
73
+ baseUrl: settings.appUrl,
74
+ contentReview,
75
+ workflow
76
+ });
77
+ if (!contentUrl) {
78
+ console.log("No content url.");
79
+ return;
80
+ }
81
+ const reviewers = await (0, _reviewers.fetchReviewers)({
82
+ context,
83
+ workflow,
84
+ exclude: [comment.createdBy.id]
85
+ });
86
+ if (reviewers.length === 0) {
87
+ console.log("No reviewers to send the e-mail notification to.");
88
+ return;
89
+ }
90
+ try {
91
+ await (0, _sendCommentNotification.sendCommentNotification)({
92
+ context,
93
+ reviewers,
94
+ changeRequest,
95
+ contentReview,
96
+ workflow,
97
+ commentUrl,
98
+ contentUrl
99
+ });
100
+ } catch (ex) {
101
+ throw new _error.default(`Could not send comment notifications.`, "COMMENT_NOTIFICATIONS_NOT_SENT", {
102
+ commentId: comment.id,
103
+ workflowId: workflow.id,
104
+ changeRequestId: changeRequest.id,
105
+ contentReviewId,
106
+ commentUrl,
107
+ contentUrl,
108
+ error: {
109
+ message: ex.message,
110
+ code: ex.code,
111
+ data: ex.data,
112
+ stack: ex.stack
113
+ }
114
+ });
115
+ }
116
+ };
117
+ await context.security.withoutAuthorization(async () => {
118
+ return execute();
119
+ });
120
+ });
121
+ };
122
+ exports.attachCommentAfterCreate = attachCommentAfterCreate;
123
+
124
+ //# sourceMappingURL=commentAfterCreate.js.map
@@ -0,0 +1 @@
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,OAAO,EAAEA,OAAO,CAACO;QACrB,CAAC,CAAC;MACN;MAEA,MAAM;QAAEA,EAAE,EAAEC,eAAe;QAAEC;MAAO,CAAC,GAAG,IAAAC,oCAA6B,EACjEN,aAAa,CAACO,IAClB,CAAC;MACD,IAAI,CAACF,MAAM,EAAE;QACT,MAAM,IAAIH,cAAW,CAAC,qCAAqC,EAAE,iBAAiB,EAAE;UAC5EK,IAAI,EAAEP,aAAa,CAACO;QACxB,CAAC,CAAC;MACN;MAEA,MAAMC,QAAQ,GAAG,MAAM,IAAAC,oBAAS,EAACf,OAAO,CAAC;MACzC,IAAI,CAACc,QAAQ,EAAE;QACX;MACJ;MACA;AACZ;AACA;MACY,MAAME,UAAU,GAAG,IAAAC,4BAAgB,EAAC;QAChCC,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBC,eAAe,EAAEd,aAAa,CAACG,EAAE;QACjCC,eAAe;QACfC;MACJ,CAAC,CAAC;MACF,IAAI,CAACK,UAAU,EAAE;QACbK,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC;QAC9B;MACJ;MACA;AACZ;AACA;MACY,MAAMC,aAAa,GAAG,MAAMvB,OAAO,CAACC,GAAG,CAACsB,aAAa,CAAChB,GAAG,CAACG,eAAe,CAAC;MAC1E,IAAI,CAACa,aAAa,EAAE;QAChB,MAAM,IAAIf,cAAW,CACjB,sCAAsCE,eAAe,IAAI,EACzD,0BAA0B,EAC1B;UACIA;QACJ,CACJ,CAAC;MACL;MACA;AACZ;AACA;MACY,MAAMc,QAAQ,GAAG,MAAMxB,OAAO,CAACC,GAAG,CAACuB,QAAQ,CAACjB,GAAG,CAACgB,aAAa,CAACE,UAAU,CAAC;MACzE,IAAI,CAACD,QAAQ,EAAE;QACX,MAAM,IAAIhB,cAAW,CACjB,yCAAyCe,aAAa,CAACE,UAAU,IAAI,EACrE,oBAAoB,EACpB;UACIA,UAAU,EAAEF,aAAa,CAACE;QAC9B,CACJ,CAAC;MACL;MAEA,MAAMC,UAAU,GAAG,IAAAC,4BAAgB,EAAC;QAChCC,OAAO,EAAE5B,OAAO,CAAC4B,OAAO;QACxBV,OAAO,EAAEJ,QAAQ,CAACK,MAAM;QACxBI,aAAa;QACbC;MACJ,CAAC,CAAC;MACF,IAAI,CAACE,UAAU,EAAE;QACbL,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC;QAC9B;MACJ;MAEA,MAAMO,SAAS,GAAG,MAAM,IAAAC,yBAAc,EAAC;QACnC9B,OAAO;QACPwB,QAAQ;QACRO,OAAO,EAAE,CAAC7B,OAAO,CAAC8B,SAAS,CAACvB,EAAE;MAClC,CAAC,CAAC;MAEF,IAAIoB,SAAS,CAACI,MAAM,KAAK,CAAC,EAAE;QACxBZ,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;QAC/D;MACJ;MAEA,IAAI;QACA,MAAM,IAAAY,gDAAuB,EAAC;UAC1BlC,OAAO;UACP6B,SAAS;UACTvB,aAAa;UACbiB,aAAa;UACbC,QAAQ;UACRR,UAAU;UACVU;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOS,EAAE,EAAE;QACT,MAAM,IAAI3B,cAAW,CACjB,uCAAuC,EACvC,gCAAgC,EAChC;UACI4B,SAAS,EAAElC,OAAO,CAACO,EAAE;UACrBgB,UAAU,EAAED,QAAQ,CAACf,EAAE;UACvBW,eAAe,EAAEd,aAAa,CAACG,EAAE;UACjCC,eAAe;UACfM,UAAU;UACVU,UAAU;UACVW,KAAK,EAAE;YACHC,OAAO,EAAEH,EAAE,CAACG,OAAO;YACnBC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,IAAI,EAAEL,EAAE,CAACK,IAAI;YACbC,KAAK,EAAEN,EAAE,CAACM;UACd;QACJ,CACJ,CAAC;MACL;IACJ,CAAC;IAED,MAAMzC,OAAO,CAAC0C,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOtC,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACuC,OAAA,CAAA7C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ interface CreateCommentUrlParams {
2
+ baseUrl?: string;
3
+ changeRequestId: string;
4
+ contentReviewId: string;
5
+ stepId: string;
6
+ }
7
+ export declare const createCommentUrl: (params: CreateCommentUrlParams) => string | null;
8
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentUrl = void 0;
7
+ const createCommentUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ changeRequestId,
22
+ contentReviewId,
23
+ stepId
24
+ } = params;
25
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
26
+ };
27
+ exports.createCommentUrl = createCommentUrl;
28
+
29
+ //# sourceMappingURL=commentUrl.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwContext } from "../../../types";
2
+ export declare const attachContentReviewAfterCreate: (context: ApwContext) => void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachContentReviewAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _getAppUrl = require("./getAppUrl");
10
+ var _contentReviewUrl = require("./contentReviewUrl");
11
+ var _contentUrl = require("./contentUrl");
12
+ var _reviewers = require("./reviewers");
13
+ var _sendContentReviewNotification = require("./sendContentReviewNotification");
14
+ const attachContentReviewAfterCreate = context => {
15
+ context.apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
16
+ contentReview
17
+ }) => {
18
+ const execute = async () => {
19
+ if (contentReview.steps.length === 0) {
20
+ return;
21
+ }
22
+ const [step] = contentReview.steps;
23
+ if (!step?.id) {
24
+ return;
25
+ }
26
+ const settings = await (0, _getAppUrl.getAppUrl)(context);
27
+ if (!settings) {
28
+ return;
29
+ }
30
+ const contentReviewUrl = (0, _contentReviewUrl.createContentReviewUrl)({
31
+ baseUrl: settings.appUrl,
32
+ contentReviewId: contentReview.id,
33
+ stepId: step.id
34
+ });
35
+ if (!contentReviewUrl) {
36
+ return;
37
+ }
38
+
39
+ /**
40
+ * We go and check the workflow.
41
+ */
42
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
43
+ if (!workflow) {
44
+ throw new _error.default(`There is no workflow with Id "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
45
+ workflowId: contentReview.workflowId
46
+ });
47
+ }
48
+ const contentUrl = (0, _contentUrl.createContentUrl)({
49
+ plugins: context.plugins,
50
+ baseUrl: settings.appUrl,
51
+ contentReview,
52
+ workflow
53
+ });
54
+ if (!contentUrl) {
55
+ return;
56
+ }
57
+ const reviewers = await (0, _reviewers.fetchReviewers)({
58
+ context,
59
+ workflow,
60
+ exclude: [contentReview.createdBy.id]
61
+ });
62
+ if (reviewers.length === 0) {
63
+ return;
64
+ }
65
+ try {
66
+ await (0, _sendContentReviewNotification.sendContentReviewNotification)({
67
+ context,
68
+ reviewers,
69
+ contentReview,
70
+ workflow,
71
+ contentReviewUrl,
72
+ contentUrl
73
+ });
74
+ } catch (ex) {
75
+ throw new _error.default(`Could not send content review notifications.`, "CONTENT_REVIEW_NOTIFICATIONS_NOT_SENT", {
76
+ workflowId: workflow.id,
77
+ contentReviewId: contentReview.id,
78
+ contentReviewUrl,
79
+ contentUrl,
80
+ error: {
81
+ message: ex.message,
82
+ code: ex.code,
83
+ data: ex.data,
84
+ stack: ex.stack
85
+ }
86
+ });
87
+ }
88
+ };
89
+ await context.security.withoutAuthorization(async () => {
90
+ return execute();
91
+ });
92
+ });
93
+ };
94
+ exports.attachContentReviewAfterCreate = attachContentReviewAfterCreate;
95
+
96
+ //# sourceMappingURL=contentReviewAfterCreate.js.map
@@ -0,0 +1 @@
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":"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","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ interface Params {
2
+ baseUrl?: string;
3
+ contentReviewId: string;
4
+ stepId: string;
5
+ }
6
+ export declare const createContentReviewUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewUrl = void 0;
7
+ const createContentReviewUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ contentReviewId,
22
+ stepId
23
+ } = params;
24
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}`;
25
+ };
26
+ exports.createContentReviewUrl = createContentReviewUrl;
27
+
28
+ //# sourceMappingURL=contentReviewUrl.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,7 @@
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ import type { ApwContentUrlPluginCbParams } from "../../../ApwContentUrlPlugin";
3
+ interface Params extends ApwContentUrlPluginCbParams {
4
+ plugins: PluginsContainer;
5
+ }
6
+ export declare const createContentUrl: (params: Params) => string | null;
7
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrl = void 0;
7
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
8
+ const createContentUrl = params => {
9
+ const {
10
+ plugins,
11
+ contentReview
12
+ } = params;
13
+ const {
14
+ type: contentType
15
+ } = contentReview.content;
16
+ const [contentUrlPlugin] = plugins.byType(_ApwContentUrlPlugin.ApwContentUrlPlugin.type).filter(plugin => {
17
+ return plugin.canUse(contentType);
18
+ }).reverse();
19
+ if (!contentUrlPlugin) {
20
+ return null;
21
+ }
22
+ return contentUrlPlugin.create(params);
23
+ };
24
+ exports.createContentUrl = createContentUrl;
25
+
26
+ //# sourceMappingURL=contentUrl.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,11 @@
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwChangeRequestNotification } from "../../../ApwChangeRequestNotification";
3
+ interface GetLastChangeRequestNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastChangeRequestNotificationPlugin {
8
+ (params: GetLastChangeRequestNotificationPluginParams): ApwChangeRequestNotification | undefined;
9
+ }
10
+ export declare const getLastChangeRequestNotificationPlugin: GetLastChangeRequestNotificationPlugin;
11
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastChangeRequestNotificationPlugin = void 0;
7
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
8
+ const getLastChangeRequestNotificationPlugin = params => {
9
+ const {
10
+ context,
11
+ type
12
+ } = params;
13
+ /**
14
+ * We need the plugin to create the notification text.
15
+ */
16
+ const plugins = context.plugins.byType(_ApwChangeRequestNotification.ApwChangeRequestNotification.type).filter(plugin => {
17
+ return plugin.canUse(type);
18
+ });
19
+ return plugins.shift();
20
+ };
21
+ exports.getLastChangeRequestNotificationPlugin = getLastChangeRequestNotificationPlugin;
22
+
23
+ //# sourceMappingURL=lastChangeRequestNotificationPlugin.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,11 @@
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwCommentNotification } from "../../../ApwCommentNotification";
3
+ interface GetLastCommentNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastCommentNotificationPlugin {
8
+ (params: GetLastCommentNotificationPluginParams): ApwCommentNotification | undefined;
9
+ }
10
+ export declare const getLastCommentNotificationPlugin: GetLastCommentNotificationPlugin;
11
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastCommentNotificationPlugin = void 0;
7
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
8
+ const getLastCommentNotificationPlugin = params => {
9
+ const {
10
+ context,
11
+ type
12
+ } = params;
13
+ /**
14
+ * We need the plugin to create the notification text.
15
+ */
16
+ const plugins = context.plugins.byType(_ApwCommentNotification.ApwCommentNotification.type).filter(plugin => {
17
+ return plugin.canUse(type);
18
+ });
19
+ return plugins.shift();
20
+ };
21
+ exports.getLastCommentNotificationPlugin = getLastCommentNotificationPlugin;
22
+
23
+ //# sourceMappingURL=lastCommentNotificationPlugin.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,11 @@
1
+ import type { ApwContentTypes, ApwContext } from "../../../types";
2
+ import { ApwContentReviewNotification } from "../../../ApwContentReviewNotification";
3
+ interface GetLastContentReviewNotificationPluginParams {
4
+ context: ApwContext;
5
+ type: ApwContentTypes;
6
+ }
7
+ interface GetLastContentReviewNotificationPlugin {
8
+ (params: GetLastContentReviewNotificationPluginParams): ApwContentReviewNotification | undefined;
9
+ }
10
+ export declare const getLastContentReviewNotificationPlugin: GetLastContentReviewNotificationPlugin;
11
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLastContentReviewNotificationPlugin = void 0;
7
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
8
+ const getLastContentReviewNotificationPlugin = params => {
9
+ const {
10
+ context,
11
+ type
12
+ } = params;
13
+ /**
14
+ * We need the plugin to create the notification text.
15
+ */
16
+ const plugins = context.plugins.byType(_ApwContentReviewNotification.ApwContentReviewNotification.type).filter(plugin => {
17
+ return plugin.canUse(type);
18
+ });
19
+ return plugins.shift();
20
+ };
21
+ exports.getLastContentReviewNotificationPlugin = getLastContentReviewNotificationPlugin;
22
+
23
+ //# sourceMappingURL=lastContentReviewNotificationPlugin.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,15 @@
1
+ import type { ApwContext, ApwReviewerWithEmail, ApwWorkflow, ApwWorkflowStep } from "../../../types";
2
+ interface GetReviewerIdListParams {
3
+ steps: ApwWorkflowStep[];
4
+ }
5
+ interface GetReviewerIdList {
6
+ (params: GetReviewerIdListParams): string[];
7
+ }
8
+ export declare const getReviewerIdList: GetReviewerIdList;
9
+ interface FetchReviewersParams {
10
+ context: ApwContext;
11
+ workflow: ApwWorkflow;
12
+ exclude: string[];
13
+ }
14
+ export declare const fetchReviewers: (params: FetchReviewersParams) => Promise<ApwReviewerWithEmail[]>;
15
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getReviewerIdList = exports.fetchReviewers = void 0;
7
+ const getReviewerIdList = ({
8
+ steps
9
+ }) => {
10
+ return steps.reduce((collection, step) => {
11
+ for (const reviewer of step.reviewers) {
12
+ if (collection.includes(reviewer.id)) {
13
+ return collection;
14
+ }
15
+ collection.push(reviewer.id);
16
+ }
17
+ return collection;
18
+ }, []);
19
+ };
20
+ exports.getReviewerIdList = getReviewerIdList;
21
+ const fetchReviewers = async params => {
22
+ const {
23
+ context,
24
+ workflow,
25
+ exclude
26
+ } = params;
27
+ const idList = getReviewerIdList(workflow);
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
+ });
43
+ });
44
+ };
45
+ exports.fetchReviewers = fetchReviewers;
46
+
47
+ //# sourceMappingURL=reviewers.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwChangeRequestNotificationCbParams } from "../../../ApwChangeRequestNotification";
2
+ export declare const sendChangeRequestNotification: (params: ApwChangeRequestNotificationCbParams) => Promise<void>;