@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
@@ -4,29 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.attachApwHooks = void 0;
7
-
8
7
  var _api = require("@webiny/api");
9
-
10
8
  var _deleteCommentsAfterChangeRequest = require("./deleteCommentsAfterChangeRequest");
11
-
12
9
  var _deleteChangeRequestsAfterContentReview = require("./deleteChangeRequestsAfterContentReview");
13
-
14
10
  var _createReviewerFromIdentity = require("./createReviewerFromIdentity");
15
-
16
11
  var _initializeContentReviewSteps = require("./initializeContentReviewSteps");
17
-
18
12
  var _updatePendingChangeRequests = require("./updatePendingChangeRequests");
19
-
20
13
  var _updateTotalComments = require("./updateTotalComments");
21
-
22
14
  var _validateChangeRequest = require("./validateChangeRequest");
23
-
24
15
  var _validateContentReview = require("./validateContentReview");
25
-
26
16
  var _validateComment = require("./validateComment");
27
-
28
17
  var _listContentReviews = require("./listContentReviews");
29
-
18
+ var _initializeNotifications = require("./initializeNotifications");
30
19
  const attachApwHooks = () =>
31
20
  /**
32
21
  * Hook into CMS events and execute business logic.
@@ -66,6 +55,8 @@ new _api.ContextPlugin(async context => {
66
55
  apw
67
56
  });
68
57
  (0, _listContentReviews.listContentReviews)(context);
58
+ (0, _initializeNotifications.initializeNotifications)(context);
69
59
  });
60
+ exports.attachApwHooks = attachApwHooks;
70
61
 
71
- exports.attachApwHooks = attachApwHooks;
62
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview","listContentReviews"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { deleteCommentsAfterChangeRequest } from \"./deleteCommentsAfterChangeRequest\";\nimport { deleteChangeRequestsWithContentReview } from \"./deleteChangeRequestsAfterContentReview\";\nimport { createReviewerFromIdentity } from \"./createReviewerFromIdentity\";\nimport { initializeContentReviewSteps } from \"./initializeContentReviewSteps\";\nimport { updatePendingChangeRequestsCount } from \"./updatePendingChangeRequests\";\nimport { updateTotalCommentsCount, updateLatestCommentId } from \"./updateTotalComments\";\nimport { validateChangeRequest } from \"./validateChangeRequest\";\nimport { validateContentReview } from \"./validateContentReview\";\nimport { validateComment } from \"./validateComment\";\nimport { listContentReviews } from \"~/plugins/hooks/listContentReviews\";\n\nexport const attachApwHooks = () =>\n /**\n * Hook into CMS events and execute business logic.\n */\n new ContextPlugin<ApwContext>(async context => {\n const { security, apw } = context;\n\n validateContentReview({ apw });\n\n validateChangeRequest({ apw });\n\n validateComment({ apw });\n\n createReviewerFromIdentity({ security, apw });\n\n initializeContentReviewSteps(context);\n\n updatePendingChangeRequestsCount({ apw });\n\n updateTotalCommentsCount({ apw });\n\n updateLatestCommentId({ apw });\n\n deleteCommentsAfterChangeRequest({ apw });\n\n deleteChangeRequestsWithContentReview({ apw });\n\n listContentReviews(context);\n });\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,cAAc,GAAG;AAC1B;AACJ;AACA;AACI,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAAoBF,OAA1B;EAEA,IAAAG,4CAAA,EAAsB;IAAED;EAAF,CAAtB;EAEA,IAAAE,4CAAA,EAAsB;IAAEF;EAAF,CAAtB;EAEA,IAAAG,gCAAA,EAAgB;IAAEH;EAAF,CAAhB;EAEA,IAAAI,sDAAA,EAA2B;IAAEL,QAAF;IAAYC;EAAZ,CAA3B;EAEA,IAAAK,0DAAA,EAA6BP,OAA7B;EAEA,IAAAQ,6DAAA,EAAiC;IAAEN;EAAF,CAAjC;EAEA,IAAAO,6CAAA,EAAyB;IAAEP;EAAF,CAAzB;EAEA,IAAAQ,0CAAA,EAAsB;IAAER;EAAF,CAAtB;EAEA,IAAAS,kEAAA,EAAiC;IAAET;EAAF,CAAjC;EAEA,IAAAU,6EAAA,EAAsC;IAAEV;EAAF,CAAtC;EAEA,IAAAW,sCAAA,EAAmBb,OAAnB;AACH,CAxBD,CAJG"}
1
+ {"version":3,"names":["_api","require","_deleteCommentsAfterChangeRequest","_deleteChangeRequestsAfterContentReview","_createReviewerFromIdentity","_initializeContentReviewSteps","_updatePendingChangeRequests","_updateTotalComments","_validateChangeRequest","_validateContentReview","_validateComment","_listContentReviews","_initializeNotifications","attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview","listContentReviews","initializeNotifications","exports"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApwContext } from \"~/types\";\nimport { deleteCommentsAfterChangeRequest } from \"./deleteCommentsAfterChangeRequest\";\nimport { deleteChangeRequestsWithContentReview } from \"./deleteChangeRequestsAfterContentReview\";\nimport { createReviewerFromIdentity } from \"./createReviewerFromIdentity\";\nimport { initializeContentReviewSteps } from \"./initializeContentReviewSteps\";\nimport { updatePendingChangeRequestsCount } from \"./updatePendingChangeRequests\";\nimport { updateTotalCommentsCount, updateLatestCommentId } from \"./updateTotalComments\";\nimport { validateChangeRequest } from \"./validateChangeRequest\";\nimport { validateContentReview } from \"./validateContentReview\";\nimport { validateComment } from \"./validateComment\";\nimport { listContentReviews } from \"./listContentReviews\";\nimport { initializeNotifications } from \"./initializeNotifications\";\n\nexport const attachApwHooks = () =>\n /**\n * Hook into CMS events and execute business logic.\n */\n new ContextPlugin<ApwContext>(async context => {\n const { security, apw } = context;\n\n validateContentReview({ apw });\n\n validateChangeRequest({ apw });\n\n validateComment({ apw });\n\n createReviewerFromIdentity({ security, apw });\n\n initializeContentReviewSteps(context);\n\n updatePendingChangeRequestsCount({ apw });\n\n updateTotalCommentsCount({ apw });\n\n updateLatestCommentId({ apw });\n\n deleteCommentsAfterChangeRequest({ apw });\n\n deleteChangeRequestsWithContentReview({ apw });\n\n listContentReviews(context);\n\n initializeNotifications(context);\n });\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,iCAAA,GAAAD,OAAA;AACA,IAAAE,uCAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,6BAAA,GAAAJ,OAAA;AACA,IAAAK,4BAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AACA,IAAAQ,sBAAA,GAAAR,OAAA;AACA,IAAAS,gBAAA,GAAAT,OAAA;AACA,IAAAU,mBAAA,GAAAV,OAAA;AACA,IAAAW,wBAAA,GAAAX,OAAA;AAEO,MAAMY,cAAc,GAAGA,CAAA;AAC1B;AACJ;AACA;AACI,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,QAAQ;IAAEC;EAAI,CAAC,GAAGF,OAAO;EAEjC,IAAAG,4CAAqB,EAAC;IAAED;EAAI,CAAC,CAAC;EAE9B,IAAAE,4CAAqB,EAAC;IAAEF;EAAI,CAAC,CAAC;EAE9B,IAAAG,gCAAe,EAAC;IAAEH;EAAI,CAAC,CAAC;EAExB,IAAAI,sDAA0B,EAAC;IAAEL,QAAQ;IAAEC;EAAI,CAAC,CAAC;EAE7C,IAAAK,0DAA4B,EAACP,OAAO,CAAC;EAErC,IAAAQ,6DAAgC,EAAC;IAAEN;EAAI,CAAC,CAAC;EAEzC,IAAAO,6CAAwB,EAAC;IAAEP;EAAI,CAAC,CAAC;EAEjC,IAAAQ,0CAAqB,EAAC;IAAER;EAAI,CAAC,CAAC;EAE9B,IAAAS,kEAAgC,EAAC;IAAET;EAAI,CAAC,CAAC;EAEzC,IAAAU,6EAAqC,EAAC;IAAEV;EAAI,CAAC,CAAC;EAE9C,IAAAW,sCAAkB,EAACb,OAAO,CAAC;EAE3B,IAAAc,gDAAuB,EAACd,OAAO,CAAC;AACpC,CAAC,CAAC;AAACe,OAAA,CAAAjB,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ApwContext } from "../../types";
1
+ import type { ApwContext } from "../../types";
2
2
  export declare const initializeContentReviewSteps: ({ apw, plugins }: ApwContext) => void;
@@ -1,22 +1,15 @@
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.initializeContentReviewSteps = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
8
  var _set = _interopRequireDefault(require("lodash/set"));
13
-
9
+ var _types = require("../../types");
14
10
  var _utils = require("../utils");
15
-
16
11
  var _handlerGraphql = require("@webiny/handler-graphql");
17
-
18
12
  var _contentApwSettingsPlugin = require("../../utils/contentApwSettingsPlugin");
19
-
20
13
  const initializeContentReviewSteps = ({
21
14
  apw,
22
15
  plugins
@@ -32,35 +25,31 @@ const initializeContentReviewSteps = ({
32
25
  /*
33
26
  * Let's set "title" field value.
34
27
  */
35
-
36
28
  const getContent = apw.getContentGetter(type);
37
29
  const content = await getContent(id, settings);
38
-
39
30
  if (!content) {
40
31
  throw new _handlerGraphql.NotFoundError(`Content "${type}" with id ${id} not found.`);
41
32
  }
42
-
43
33
  const {
44
34
  title
45
35
  } = content;
46
36
  input = (0, _set.default)(input, "title", title);
37
+
47
38
  /**
48
39
  * We need to find a plugin which can get a workflow ID for the given type of content.
49
40
  */
50
-
51
41
  const contentApwSettingsPlugin = (0, _contentApwSettingsPlugin.getContentApwSettingsPlugin)({
52
42
  plugins,
53
43
  type
54
44
  });
55
45
  const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
46
+
56
47
  /**
57
48
  * Let's initialize the "ContentReview" steps.
58
49
  */
59
-
60
50
  if (!workflowId) {
61
51
  throw new _handlerGraphql.NotFoundError(`Unable to initiate a "Content review". No workflow found!`);
62
52
  }
63
-
64
53
  input.workflowId = workflowId;
65
54
  const workflow = await apw.workflow.get(workflowId);
66
55
  const workflowSteps = workflow.steps;
@@ -68,19 +57,25 @@ const initializeContentReviewSteps = ({
68
57
  const updatedSteps = workflow.steps.map((step, index) => {
69
58
  const status = (0, _utils.getContentReviewStepInitialStatus)(workflowSteps, index, previousStepStatus);
70
59
  previousStepStatus = status;
71
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
60
+ return {
61
+ ...step,
72
62
  status,
73
63
  pendingChangeRequests: 0,
74
64
  totalComments: 0
75
- });
65
+ };
76
66
  });
77
67
  /**
78
- * TODO Figure our what does this actually do?
79
- * There is no steps property on CreateApwContentReviewParams
68
+ * If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED.
80
69
  */
81
-
70
+ const isNonMandatory = updatedSteps.every(step => {
71
+ return step.type === _types.ApwWorkflowStepTypes.NON_MANDATORY;
72
+ });
73
+ if (isNonMandatory) {
74
+ input.reviewStatus = _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED;
75
+ }
82
76
  input = (0, _set.default)(input, "steps", updatedSteps);
83
77
  });
84
78
  };
79
+ exports.initializeContentReviewSteps = initializeContentReviewSteps;
85
80
 
86
- exports.initializeContentReviewSteps = initializeContentReviewSteps;
81
+ //# sourceMappingURL=initializeContentReviewSteps.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["initializeContentReviewSteps","apw","plugins","contentReview","onContentReviewBeforeCreate","subscribe","input","type","id","settings","content","getContent","getContentGetter","NotFoundError","title","lodashSet","contentApwSettingsPlugin","getContentApwSettingsPlugin","workflowId","getWorkflowId","workflow","get","workflowSteps","steps","previousStepStatus","undefined","updatedSteps","map","step","index","status","getContentReviewStepInitialStatus","pendingChangeRequests","totalComments"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport { ApwContentReviewStepStatus, ApwContext } from \"~/types\";\nimport { getContentReviewStepInitialStatus } from \"~/plugins/utils\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\n\nexport const initializeContentReviewSteps = ({ apw, plugins }: ApwContext) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { type, id, settings } = input.content;\n /*\n * Let's set \"title\" field value.\n */\n const getContent = apw.getContentGetter(type);\n const content = await getContent(id, settings);\n if (!content) {\n throw new NotFoundError(`Content \"${type}\" with id ${id} not found.`);\n }\n\n const { title } = content;\n input = lodashSet(input, \"title\", title);\n\n /**\n * We need to find a plugin which can get a workflow ID for the given type of content.\n */\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type\n });\n\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n\n /**\n * Let's initialize the \"ContentReview\" steps.\n */\n if (!workflowId) {\n throw new NotFoundError(`Unable to initiate a \"Content review\". No workflow found!`);\n }\n\n input.workflowId = workflowId;\n\n const workflow = await apw.workflow.get(workflowId);\n const workflowSteps = workflow.steps;\n\n let previousStepStatus: ApwContentReviewStepStatus | undefined = undefined;\n const updatedSteps = workflow.steps.map((step, index) => {\n const status = getContentReviewStepInitialStatus(\n workflowSteps,\n index,\n previousStepStatus\n );\n previousStepStatus = status;\n return {\n ...step,\n status,\n pendingChangeRequests: 0,\n totalComments: 0\n };\n });\n /**\n * TODO Figure our what does this actually do?\n * There is no steps property on CreateApwContentReviewParams\n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MC,YAAY,GAAGN,QAAQ,CAACG,KAAT,CAAeI,GAAf,CAAmB,CAACC,IAAD,EAAOC,KAAP,KAAiB;MACrD,MAAMC,MAAM,GAAG,IAAAC,wCAAA,EACXT,aADW,EAEXO,KAFW,EAGXL,kBAHW,CAAf;MAKAA,kBAAkB,GAAGM,MAArB;MACA,mEACOF,IADP;QAEIE,MAFJ;QAGIE,qBAAqB,EAAE,CAH3B;QAIIC,aAAa,EAAE;MAJnB;IAMH,CAboB,CAArB;IAcA;AACR;AACA;AACA;;IACQ3B,KAAK,GAAG,IAAAS,YAAA,EAAUT,KAAV,EAAiB,OAAjB,EAA0BoB,YAA1B,CAAR;EACH,CAxDD;AAyDH,CA1DM"}
1
+ {"version":3,"names":["_set","_interopRequireDefault","require","_types","_utils","_handlerGraphql","_contentApwSettingsPlugin","initializeContentReviewSteps","apw","plugins","contentReview","onContentReviewBeforeCreate","subscribe","input","type","id","settings","content","getContent","getContentGetter","NotFoundError","title","lodashSet","contentApwSettingsPlugin","getContentApwSettingsPlugin","workflowId","getWorkflowId","workflow","get","workflowSteps","steps","previousStepStatus","undefined","updatedSteps","map","step","index","status","getContentReviewStepInitialStatus","pendingChangeRequests","totalComments","isNonMandatory","every","ApwWorkflowStepTypes","NON_MANDATORY","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","exports"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport type { ApwContentReviewStepStatus, ApwContext } from \"~/types\";\nimport { ApwContentReviewStatus, ApwWorkflowStepTypes } from \"~/types\";\nimport { getContentReviewStepInitialStatus } from \"~/plugins/utils\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\n\nexport const initializeContentReviewSteps = ({ apw, plugins }: ApwContext) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { type, id, settings } = input.content;\n /*\n * Let's set \"title\" field value.\n */\n const getContent = apw.getContentGetter(type);\n const content = await getContent(id, settings);\n if (!content) {\n throw new NotFoundError(`Content \"${type}\" with id ${id} not found.`);\n }\n\n const { title } = content;\n input = lodashSet(input, \"title\", title);\n\n /**\n * We need to find a plugin which can get a workflow ID for the given type of content.\n */\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type\n });\n\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n\n /**\n * Let's initialize the \"ContentReview\" steps.\n */\n if (!workflowId) {\n throw new NotFoundError(`Unable to initiate a \"Content review\". No workflow found!`);\n }\n\n input.workflowId = workflowId;\n\n const workflow = await apw.workflow.get(workflowId);\n const workflowSteps = workflow.steps;\n\n let previousStepStatus: ApwContentReviewStepStatus | undefined = undefined;\n const updatedSteps = workflow.steps.map((step, index) => {\n const status = getContentReviewStepInitialStatus(\n workflowSteps,\n index,\n previousStepStatus\n );\n previousStepStatus = status;\n return {\n ...step,\n status,\n pendingChangeRequests: 0,\n totalComments: 0\n };\n });\n /**\n * If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED.\n */\n const isNonMandatory = updatedSteps.every(step => {\n return step.type === ApwWorkflowStepTypes.NON_MANDATORY;\n });\n if (isNonMandatory) {\n input.reviewStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,yBAAA,GAAAJ,OAAA;AAEO,MAAMK,4BAA4B,GAAGA,CAAC;EAAEC,GAAG;EAAEC;AAAoB,CAAC,KAAK;EAC1ED,GAAG,CAACE,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAA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AAa,EAAE;MACnB,CAAC;IACL,CAAC,CAAC;IACF;AACR;AACA;IACQ,MAAMC,cAAc,GAAGR,YAAY,CAACS,KAAK,CAACP,IAAI,IAAI;MAC9C,OAAOA,IAAI,CAACrB,IAAI,KAAK6B,2BAAoB,CAACC,aAAa;IAC3D,CAAC,CAAC;IACF,IAAIH,cAAc,EAAE;MAChB5B,KAAK,CAACgC,YAAY,GAAGC,6BAAsB,CAACC,qBAAqB;IACrE;IAEAlC,KAAK,GAAG,IAAAS,YAAS,EAACT,KAAK,EAAE,OAAO,EAAEoB,YAAY,CAAC;EACnD,CAAC,CAAC;AACN,CAAC;AAACe,OAAA,CAAAzC,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwContext } from "../../types";
2
+ export declare const initializeNotifications: (context: ApwContext) => void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initializeNotifications = void 0;
7
+ var _contentReviewAfterCreate = require("./notifications/contentReviewAfterCreate");
8
+ var _commentAfterCreate = require("./notifications/commentAfterCreate");
9
+ var _changeRequestAfterCreate = require("./notifications/changeRequestAfterCreate");
10
+ const initializeNotifications = context => {
11
+ (0, _contentReviewAfterCreate.attachContentReviewAfterCreate)(context);
12
+ (0, _commentAfterCreate.attachCommentAfterCreate)(context);
13
+ (0, _changeRequestAfterCreate.attachChangeRequestAfterCreate)(context);
14
+ };
15
+ exports.initializeNotifications = initializeNotifications;
16
+
17
+ //# sourceMappingURL=initializeNotifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_contentReviewAfterCreate","require","_commentAfterCreate","_changeRequestAfterCreate","initializeNotifications","context","attachContentReviewAfterCreate","attachCommentAfterCreate","attachChangeRequestAfterCreate","exports"],"sources":["initializeNotifications.ts"],"sourcesContent":["import type { ApwContext } from \"~/types\";\nimport { attachContentReviewAfterCreate } from \"./notifications/contentReviewAfterCreate\";\nimport { attachCommentAfterCreate } from \"./notifications/commentAfterCreate\";\nimport { attachChangeRequestAfterCreate } from \"./notifications/changeRequestAfterCreate\";\n\nexport const initializeNotifications = (context: ApwContext) => {\n attachContentReviewAfterCreate(context);\n attachCommentAfterCreate(context);\n attachChangeRequestAfterCreate(context);\n};\n"],"mappings":";;;;;;AACA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAF,OAAA;AAEO,MAAMG,uBAAuB,GAAIC,OAAmB,IAAK;EAC5D,IAAAC,wDAA8B,EAACD,OAAO,CAAC;EACvC,IAAAE,4CAAwB,EAACF,OAAO,CAAC;EACjC,IAAAG,wDAA8B,EAACH,OAAO,CAAC;AAC3C,CAAC;AAACI,OAAA,CAAAL,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import { AdvancedPublishingWorkflow } from "../../types";
2
- import { HeadlessCms } from "@webiny/api-headless-cms/types";
3
- import { Security } from "@webiny/api-security/types";
1
+ import type { AdvancedPublishingWorkflow } from "../../types";
2
+ import type { HeadlessCms } from "@webiny/api-headless-cms/types";
3
+ import type { Security } from "@webiny/api-security/types";
4
4
  interface ListWorkflowsParams {
5
5
  apw: AdvancedPublishingWorkflow;
6
6
  cms: HeadlessCms;
7
7
  security: Security;
8
8
  }
9
- export declare const listContentReviews: ({ apw, cms, security }: ListWorkflowsParams) => void;
9
+ export declare const listContentReviews: ({ apw, security }: ListWorkflowsParams) => void;
10
10
  export {};
@@ -4,66 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.listContentReviews = void 0;
7
-
8
- var _contentReview = require("../../storageOperations/models/contentReview.model");
9
-
10
7
  const listContentReviews = ({
11
8
  apw,
12
- cms,
13
9
  security
14
10
  }) => {
15
11
  /**
16
12
  * We need to hook into listing the content review entries.
17
13
  * When listing content review entries, we need to check which ones current user can actually see.
18
14
  */
19
- cms.onEntryBeforeList.subscribe(async ({
20
- model,
15
+ apw.contentReview.onContentReviewBeforeList.subscribe(async ({
21
16
  where
22
17
  }) => {
18
+ /**
19
+ * If there is workflowId_in attached on where, we will not change it.
20
+ */
21
+ if (where.workflowId_in) {
22
+ return;
23
+ }
23
24
  const identity = security.getIdentity();
24
-
25
- if (!(identity !== null && identity !== void 0 && identity.id) || model.modelId !== _contentReview.CONTENT_REVIEW_MODEL_ID) {
25
+ if (!identity?.id) {
26
26
  return;
27
27
  }
28
28
  /**
29
29
  * Find all available workflows.
30
30
  */
31
-
32
-
33
31
  const [workflows] = await apw.workflow.list();
34
-
35
32
  if (workflows.length === 0) {
36
33
  return;
37
34
  }
38
- /**
39
- * We need to find the reviewer entryId to be able to match it to the reviewer entryId in the workflow steps.
40
- */
41
-
42
-
43
- const [reviewers] = await apw.reviewer.list({
44
- where: {
45
- identityId: identity.id
46
- }
47
- });
48
-
49
- if (reviewers.length === 0) {
50
- return;
51
- }
52
-
53
- const reviewerList = reviewers.map(reviewer => reviewer.entryId);
54
35
  /**
55
36
  * Find all workflows which user has access to.
56
37
  * User access is buried quite deep in the workflow data, so we need to do some traversing.
57
38
  */
58
-
59
39
  const userWorkflows = workflows.filter(workflow => {
60
40
  return workflow.steps.some(step => {
61
41
  return step.reviewers.some(reviewer => {
62
- return reviewerList.includes(reviewer.entryId);
42
+ return identity.id === reviewer.identityId;
63
43
  });
64
44
  });
65
45
  });
66
-
67
46
  if (userWorkflows.length === 0) {
68
47
  return;
69
48
  }
@@ -71,10 +50,9 @@ const listContentReviews = ({
71
50
  * In the end, we need to attach the workflow filter by the entryId.
72
51
  * Just in case we add versioning at some point...
73
52
  */
74
-
75
-
76
53
  where.workflowId_in = userWorkflows.map(workflow => workflow.id);
77
54
  });
78
55
  };
56
+ exports.listContentReviews = listContentReviews;
79
57
 
80
- exports.listContentReviews = listContentReviews;
58
+ //# sourceMappingURL=listContentReviews.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["listContentReviews","apw","cms","security","onEntryBeforeList","subscribe","model","where","identity","getIdentity","id","modelId","CONTENT_REVIEW_MODEL_ID","workflows","workflow","list","length","reviewers","reviewer","identityId","reviewerList","map","entryId","userWorkflows","filter","steps","some","step","includes","workflowId_in"],"sources":["listContentReviews.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface ListWorkflowsParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\nexport const listContentReviews = ({ apw, cms, security }: ListWorkflowsParams) => {\n /**\n * We need to hook into listing the content review entries.\n * When listing content review entries, we need to check which ones current user can actually see.\n */\n cms.onEntryBeforeList.subscribe(async ({ model, where }) => {\n const identity = security.getIdentity();\n if (!identity?.id || model.modelId !== CONTENT_REVIEW_MODEL_ID) {\n return;\n }\n /**\n * Find all available workflows.\n */\n const [workflows] = await apw.workflow.list();\n if (workflows.length === 0) {\n return;\n }\n /**\n * We need to find the reviewer entryId to be able to match it to the reviewer entryId in the workflow steps.\n */\n const [reviewers] = await apw.reviewer.list({\n where: {\n identityId: identity.id\n }\n });\n if (reviewers.length === 0) {\n return;\n }\n const reviewerList = reviewers.map(reviewer => reviewer.entryId);\n /**\n * Find all workflows which user has access to.\n * User access is buried quite deep in the workflow data, so we need to do some traversing.\n */\n const userWorkflows = workflows.filter(workflow => {\n return workflow.steps.some(step => {\n return step.reviewers.some(reviewer => {\n return reviewerList.includes(reviewer.entryId);\n });\n });\n });\n if (userWorkflows.length === 0) {\n return;\n }\n /**\n * In the end, we need to attach the workflow filter by the entryId.\n * Just in case we add versioning at some point...\n */\n where.workflowId_in = userWorkflows.map(workflow => workflow.id);\n });\n};\n"],"mappings":";;;;;;;AAEA;;AAQO,MAAMA,kBAAkB,GAAG,CAAC;EAAEC,GAAF;EAAOC,G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;AACR;AACA;AACA;;;IACQT,KAAK,CAACsB,aAAN,GAAsBN,aAAa,CAACF,GAAd,CAAkBP,QAAQ,IAAIA,QAAQ,CAACJ,EAAvC,CAAtB;EACH,CA3CD;AA4CH,CAjDM"}
1
+ {"version":3,"names":["listContentReviews","apw","security","contentReview","onContentReviewBeforeList","subscribe","where","workflowId_in","identity","getIdentity","id","workflows","workflow","list","length","userWorkflows","filter","steps","some","step","reviewers","reviewer","identityId","map","exports"],"sources":["listContentReviews.ts"],"sourcesContent":["import type { AdvancedPublishingWorkflow } from \"~/types\";\nimport type { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport type { Security } from \"@webiny/api-security/types\";\n\ninterface ListWorkflowsParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\nexport const listContentReviews = ({ apw, security }: ListWorkflowsParams) => {\n /**\n * We need to hook into listing the content review entries.\n * When listing content review entries, we need to check which ones current user can actually see.\n */\n apw.contentReview.onContentReviewBeforeList.subscribe(async ({ where }) => {\n /**\n * If there is workflowId_in attached on where, we will not change it.\n */\n if (where.workflowId_in) {\n return;\n }\n const identity = security.getIdentity();\n if (!identity?.id) {\n return;\n }\n /**\n * Find all available workflows.\n */\n const [workflows] = await apw.workflow.list();\n if (workflows.length === 0) {\n return;\n }\n /**\n * Find all workflows which user has access to.\n * User access is buried quite deep in the workflow data, so we need to do some traversing.\n */\n const userWorkflows = workflows.filter(workflow => {\n return workflow.steps.some(step => {\n return step.reviewers.some(reviewer => {\n return identity.id === reviewer.identityId;\n });\n });\n });\n if (userWorkflows.length === 0) {\n return;\n }\n /**\n * In the end, we need to attach the workflow filter by the entryId.\n * Just in case we add versioning at some point...\n */\n where.workflowId_in = userWorkflows.map(workflow => workflow.id);\n });\n};\n"],"mappings":";;;;;;AASO,MAAMA,kBAAkB,GAAGA,CAAC;EAAEC,GAAG;EAAEC;AAA8B,CAAC,KAAK;EAC1E;AACJ;AACA;AACA;EACID,GAAG,CAACE,aAAa,CAACC,yBAAyB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACvE;AACR;AACA;IACQ,IAAIA,KAAK,CAACC,aAAa,EAAE;MACrB;IACJ;IACA,MAAMC,QAAQ,GAAGN,QAAQ,CAACO,WAAW,CAAC,CAAC;IACvC,IAAI,CAACD,QAAQ,EAAEE,EAAE,EAAE;MACf;IACJ;IACA;AACR;AACA;IACQ,MAAM,CAACC,SAAS,CAAC,GAAG,MAAMV,GAAG,CAACW,QAAQ,CAACC,IAAI,CAAC,CAAC;IAC7C,IAAIF,SAAS,CAACG,MAAM,KAAK,CAAC,EAAE;MACxB;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMC,aAAa,GAAGJ,SAAS,CAACK,MAAM,CAACJ,QAAQ,IAAI;MAC/C,OAAOA,QAAQ,CAACK,KAAK,CAACC,IAAI,CAACC,IAAI,IAAI;QAC/B,OAAOA,IAAI,CAACC,SAAS,CAACF,IAAI,CAACG,QAAQ,IAAI;UACnC,OAAOb,QAAQ,CAACE,EAAE,KAAKW,QAAQ,CAACC,UAAU;QAC9C,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,CAAC;IACF,IAAIP,aAAa,CAACD,MAAM,KAAK,CAAC,EAAE;MAC5B;IACJ;IACA;AACR;AACA;AACA;IACQR,KAAK,CAACC,aAAa,GAAGQ,aAAa,CAACQ,GAAG,CAACX,QAAQ,IAAIA,QAAQ,CAACF,EAAE,CAAC;EACpE,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAxB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwContext } from "../../../types";
2
+ export declare const attachChangeRequestAfterCreate: (context: ApwContext) => void;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.attachChangeRequestAfterCreate = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _utils = require("../../utils");
10
+ var _contentUrl = require("./contentUrl");
11
+ var _sendChangeRequestNotification = require("./sendChangeRequestNotification");
12
+ var _reviewers = require("./reviewers");
13
+ var _changeRequestUrl = require("./changeRequestUrl");
14
+ var _getAppUrl = require("./getAppUrl");
15
+ const attachChangeRequestAfterCreate = context => {
16
+ context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
17
+ changeRequest
18
+ }) => {
19
+ const execute = async () => {
20
+ const {
21
+ id: contentReviewId,
22
+ stepId
23
+ } = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
24
+ if (!stepId) {
25
+ throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
26
+ step: changeRequest.step
27
+ });
28
+ }
29
+ const settings = await (0, _getAppUrl.getAppUrl)(context);
30
+ if (!settings) {
31
+ return;
32
+ }
33
+ /**
34
+ * We will check if we can create a comment url before we go digging further into the database.
35
+ */
36
+ const changeRequestUrl = (0, _changeRequestUrl.createChangeRequestUrl)({
37
+ baseUrl: settings.appUrl,
38
+ changeRequestId: changeRequest.id,
39
+ contentReviewId,
40
+ stepId
41
+ });
42
+ if (!changeRequestUrl) {
43
+ return;
44
+ }
45
+ /**
46
+ * Let's see if content review exists.
47
+ */
48
+ const contentReview = await context.apw.contentReview.get(contentReviewId);
49
+ if (!contentReview) {
50
+ throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
51
+ contentReviewId
52
+ });
53
+ }
54
+ /**
55
+ * We go and check the workflow.
56
+ */
57
+ const workflow = await context.apw.workflow.get(contentReview.workflowId);
58
+ if (!workflow) {
59
+ throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
60
+ workflowId: contentReview.workflowId
61
+ });
62
+ }
63
+ const contentUrl = (0, _contentUrl.createContentUrl)({
64
+ plugins: context.plugins,
65
+ baseUrl: settings.appUrl,
66
+ contentReview,
67
+ workflow
68
+ });
69
+ if (!contentUrl) {
70
+ return;
71
+ }
72
+ const reviewers = await (0, _reviewers.fetchReviewers)({
73
+ context,
74
+ workflow,
75
+ exclude: [changeRequest.createdBy.id]
76
+ });
77
+ if (reviewers.length === 0) {
78
+ return;
79
+ }
80
+ try {
81
+ await (0, _sendChangeRequestNotification.sendChangeRequestNotification)({
82
+ context,
83
+ reviewers,
84
+ changeRequest,
85
+ contentReview,
86
+ workflow,
87
+ changeRequestUrl,
88
+ contentUrl
89
+ });
90
+ } catch (ex) {
91
+ throw new _error.default(`Could not send change request notifications.`, "CHANGE_REQUEST_NOTIFICATIONS_NOT_SENT", {
92
+ workflowId: workflow.id,
93
+ changeRequestId: changeRequest.id,
94
+ contentReviewId,
95
+ changeRequestUrl,
96
+ contentUrl,
97
+ error: {
98
+ message: ex.message,
99
+ code: ex.code,
100
+ data: ex.data,
101
+ stack: ex.stack
102
+ }
103
+ });
104
+ }
105
+ };
106
+ await context.security.withoutAuthorization(async () => {
107
+ return execute();
108
+ });
109
+ });
110
+ };
111
+ exports.attachChangeRequestAfterCreate = attachChangeRequestAfterCreate;
112
+
113
+ //# sourceMappingURL=changeRequestAfterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_utils","_contentUrl","_sendChangeRequestNotification","_reviewers","_changeRequestUrl","_getAppUrl","attachChangeRequestAfterCreate","context","apw","changeRequest","onChangeRequestAfterCreate","subscribe","execute","id","contentReviewId","stepId","extractContentReviewIdAndStep","step","WebinyError","settings","getAppUrl","changeRequestUrl","createChangeRequestUrl","baseUrl","appUrl","changeRequestId","contentReview","get","workflow","workflowId","contentUrl","createContentUrl","plugins","reviewers","fetchReviewers","exclude","createdBy","length","sendChangeRequestNotification","ex","error","message","code","data","stack","security","withoutAuthorization","exports"],"sources":["changeRequestAfterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ApwContext } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { createContentUrl } from \"./contentUrl\";\nimport { sendChangeRequestNotification } from \"./sendChangeRequestNotification\";\nimport { fetchReviewers } from \"./reviewers\";\nimport { createChangeRequestUrl } from \"./changeRequestUrl\";\nimport { getAppUrl } from \"~/plugins/hooks/notifications/getAppUrl\";\n\nexport const attachChangeRequestAfterCreate = (context: ApwContext): void => {\n context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({ changeRequest }) => {\n const execute = async () => {\n const { id: contentReviewId, stepId } = extractContentReviewIdAndStep(\n changeRequest.step\n );\n if (!stepId) {\n throw new WebinyError(\"Malformed changeRequest.step value.\", \"MALFORMED_VALUE\", {\n step: changeRequest.step\n });\n }\n\n const settings = await getAppUrl(context);\n if (!settings) {\n return;\n }\n /**\n * We will check if we can create a comment url before we go digging further into the database.\n */\n const changeRequestUrl = createChangeRequestUrl({\n baseUrl: settings.appUrl,\n changeRequestId: changeRequest.id,\n contentReviewId,\n stepId\n });\n if (!changeRequestUrl) {\n return;\n }\n /**\n * Let's see if content review exists.\n */\n const contentReview = await context.apw.contentReview.get(contentReviewId);\n if (!contentReview) {\n throw new WebinyError(\n `There is no contentReview with id \"${contentReviewId}\".`,\n \"CONTENT_REVIEW_NOT_FOUND\",\n {\n contentReviewId\n }\n );\n }\n /**\n * We go and check the workflow.\n */\n const workflow = await context.apw.workflow.get(contentReview.workflowId);\n if (!workflow) {\n throw new WebinyError(\n `There is no workflow with workflowId \"${contentReview.workflowId}\".`,\n \"WORKFLOW_NOT_FOUND\",\n {\n workflowId: contentReview.workflowId\n }\n );\n }\n\n const contentUrl = createContentUrl({\n plugins: context.plugins,\n baseUrl: settings.appUrl,\n contentReview,\n workflow\n });\n if (!contentUrl) {\n return;\n }\n\n const reviewers = await fetchReviewers({\n context,\n workflow,\n exclude: [changeRequest.createdBy.id]\n });\n if (reviewers.length === 0) {\n return;\n }\n\n try {\n await sendChangeRequestNotification({\n context,\n reviewers,\n changeRequest,\n contentReview,\n workflow,\n changeRequestUrl,\n contentUrl\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not send change request notifications.`,\n \"CHANGE_REQUEST_NOTIFICATIONS_NOT_SENT\",\n {\n workflowId: workflow.id,\n changeRequestId: changeRequest.id,\n contentReviewId,\n changeRequestUrl,\n contentUrl,\n error: {\n message: ex.message,\n code: ex.code,\n data: ex.data,\n stack: ex.stack\n }\n }\n );\n }\n };\n\n 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,8BAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAEO,MAAMO,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,MAAM;QAAEC,EAAE,EAAEC,eAAe;QAAEC;MAAO,CAAC,GAAG,IAAAC,oCAA6B,EACjEP,aAAa,CAACQ,IAClB,CAAC;MACD,IAAI,CAACF,MAAM,EAAE;QACT,MAAM,IAAIG,cAAW,CAAC,qCAAqC,EAAE,iBAAiB,EAAE;UAC5ED,IAAI,EAAER,aAAa,CAACQ;QACxB,CAAC,CAAC;MACN;MAEA,MAAME,QAAQ,GAAG,MAAM,IAAAC,oBAAS,EAACb,OAAO,CAAC;MACzC,IAAI,CAACY,QAAQ,EAAE;QACX;MACJ;MACA;AACZ;AACA;MACY,MAAME,gBAAgB,GAAG,IAAAC,wCAAsB,EAAC;QAC5CC,OAAO,EAAEJ,QAAQ,CAACK,M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CAAC,CAAC;MACN,CAAC,CAAC,OAAOS,EAAE,EAAE;QACT,MAAM,IAAIrB,cAAW,CACjB,8CAA8C,EAC9C,uCAAuC,EACvC;UACIW,UAAU,EAAED,QAAQ,CAACf,EAAE;UACvBY,eAAe,EAAEhB,aAAa,CAACI,EAAE;UACjCC,eAAe;UACfO,gBAAgB;UAChBS,UAAU;UACVU,KAAK,EAAE;YACHC,OAAO,EAAEF,EAAE,CAACE,OAAO;YACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;YACbC,IAAI,EAAEJ,EAAE,CAACI,IAAI;YACbC,KAAK,EAAEL,EAAE,CAACK;UACd;QACJ,CACJ,CAAC;MACL;IACJ,CAAC;IAED,MAAMrC,OAAO,CAACsC,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,OAAOlC,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACmC,OAAA,CAAAzC,8BAAA,GAAAA,8BAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ interface Params {
2
+ baseUrl?: string;
3
+ changeRequestId: string;
4
+ contentReviewId: string;
5
+ stepId: string;
6
+ }
7
+ export declare const createChangeRequestUrl: (params: Params) => string | null;
8
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestUrl = void 0;
7
+ const createChangeRequestUrl = params => {
8
+ /**
9
+ * All variables must exist for URL to be created.
10
+ * We go through all vars and throw a log if it does not exist.
11
+ */
12
+ for (const key in params) {
13
+ if (!!key) {
14
+ continue;
15
+ }
16
+ console.log(`Missing variable "${key}", which we use to create a comment URL.`);
17
+ return null;
18
+ }
19
+ const {
20
+ baseUrl,
21
+ changeRequestId,
22
+ contentReviewId,
23
+ stepId
24
+ } = params;
25
+ return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;
26
+ };
27
+ exports.createChangeRequestUrl = createChangeRequestUrl;
28
+
29
+ //# sourceMappingURL=changeRequestUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createChangeRequestUrl","params","key","console","log","baseUrl","changeRequestId","contentReviewId","stepId","exports"],"sources":["changeRequestUrl.ts"],"sourcesContent":["interface Params {\n baseUrl?: string;\n changeRequestId: string;\n contentReviewId: string;\n stepId: string;\n}\nexport const createChangeRequestUrl = (params: Params) => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a comment URL.`);\n return null;\n }\n const { baseUrl, changeRequestId, contentReviewId, stepId } = params;\n\n return `${baseUrl}/apw/content-reviews/${contentReviewId}/${stepId}/${changeRequestId}`;\n};\n"],"mappings":";;;;;;AAMO,MAAMA,sBAAsB,GAAIC,MAAc,IAAK;EACtD;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,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,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { ApwContext } from "../../../types";
2
+ export declare const attachCommentAfterCreate: (context: ApwContext) => void;