@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.8feaff8c32

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 (248) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +30 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +30 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +30 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +30 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +1 -6
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +21 -25
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +21 -26
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +89 -128
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +21 -26
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.d.ts +1 -1
  24. package/crud/createWorkflowMethods.js +37 -28
  25. package/crud/createWorkflowMethods.js.map +1 -1
  26. package/crud/index.js +3 -32
  27. package/crud/index.js.map +1 -1
  28. package/crud/utils.js +4 -36
  29. package/crud/utils.js.map +1 -1
  30. package/index.d.ts +2 -3
  31. package/index.js +6 -16
  32. package/index.js.map +1 -1
  33. package/package.json +40 -46
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
  35. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  36. package/plugins/cms/apwEntryPlugins.js +4 -16
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  38. package/plugins/cms/index.js +5 -10
  39. package/plugins/cms/index.js.map +1 -1
  40. package/plugins/cms/linkContentReviewToEntry.js +6 -23
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +14 -43
  43. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  44. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js +31 -0
  46. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  47. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  48. package/plugins/cms/notifications/commentNotification.js +31 -0
  49. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js +31 -0
  52. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  53. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  54. package/plugins/cms/notifications/contentUrl.js +53 -0
  55. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  56. package/plugins/cms/triggerContentReview.js +6 -20
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +14 -36
  59. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  60. package/plugins/cms/utils.js +6 -55
  61. package/plugins/cms/utils.js.map +1 -1
  62. package/plugins/context.d.ts +0 -1
  63. package/plugins/context.js +3 -48
  64. package/plugins/context.js.map +1 -1
  65. package/plugins/graphql/changeRequest.gql.js +4 -11
  66. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  67. package/plugins/graphql/comment.gql.js +4 -11
  68. package/plugins/graphql/comment.gql.js.map +1 -1
  69. package/plugins/graphql/contentReview.gql.js +10 -29
  70. package/plugins/graphql/contentReview.gql.js.map +1 -1
  71. package/plugins/graphql/reviewer.gql.js +6 -11
  72. package/plugins/graphql/reviewer.gql.js.map +1 -1
  73. package/plugins/graphql/workflow.gql.js +4 -11
  74. package/plugins/graphql/workflow.gql.js.map +1 -1
  75. package/plugins/graphql.js +4 -19
  76. package/plugins/graphql.js.map +1 -1
  77. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  78. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  80. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  82. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  83. package/plugins/hooks/index.js +4 -12
  84. package/plugins/hooks/index.js.map +1 -1
  85. package/plugins/hooks/initializeContentReviewSteps.js +15 -25
  86. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  87. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  88. package/plugins/hooks/initializeNotifications.js +15 -0
  89. package/plugins/hooks/initializeNotifications.js.map +1 -0
  90. package/plugins/hooks/listContentReviews.d.ts +10 -0
  91. package/plugins/hooks/listContentReviews.js +56 -0
  92. package/plugins/hooks/listContentReviews.js.map +1 -0
  93. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  94. package/plugins/hooks/notifications/appUrl.js +18 -0
  95. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js +111 -0
  98. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  101. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js +122 -0
  104. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  105. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  106. package/plugins/hooks/notifications/commentUrl.js +27 -0
  107. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js +94 -0
  110. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  113. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  114. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  115. package/plugins/hooks/notifications/contentUrl.js +24 -0
  116. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  119. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  122. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  125. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  126. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  127. package/plugins/hooks/notifications/reviewers.js +45 -0
  128. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  131. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  134. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  137. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  138. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  139. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  140. package/plugins/hooks/updateTotalComments.js +14 -27
  141. package/plugins/hooks/updateTotalComments.js.map +1 -1
  142. package/plugins/hooks/validateChangeRequest.js +27 -18
  143. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  144. package/plugins/hooks/validateComment.js +13 -14
  145. package/plugins/hooks/validateComment.js.map +1 -1
  146. package/plugins/hooks/validateContentReview.js +2 -8
  147. package/plugins/hooks/validateContentReview.js.map +1 -1
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  149. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  150. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  151. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  153. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  154. package/plugins/pageBuilder/index.js +5 -8
  155. package/plugins/pageBuilder/index.js.map +1 -1
  156. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  157. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  158. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  159. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  162. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  165. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  168. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  171. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  172. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  173. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  174. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  175. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  176. package/plugins/pageBuilder/utils.js +2 -36
  177. package/plugins/pageBuilder/utils.js.map +1 -1
  178. package/plugins/utils.d.ts +1 -1
  179. package/plugins/utils.js +4 -57
  180. package/plugins/utils.js.map +1 -1
  181. package/scheduler/createScheduleActionMethods.js +15 -36
  182. package/scheduler/createScheduleActionMethods.js.map +1 -1
  183. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  184. package/scheduler/handlers/executeAction/index.js +45 -39
  185. package/scheduler/handlers/executeAction/index.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  187. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +15 -6
  188. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  189. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  190. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +8 -24
  191. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  192. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  193. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +8 -87
  194. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  195. package/scheduler/handlers/executeAction/security.js +0 -11
  196. package/scheduler/handlers/executeAction/security.js.map +1 -1
  197. package/scheduler/handlers/scheduleAction/index.js +21 -38
  198. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  199. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +9 -32
  200. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  201. package/scheduler/handlers/utils.d.ts +0 -1
  202. package/scheduler/handlers/utils.js +4 -42
  203. package/scheduler/handlers/utils.js.map +1 -1
  204. package/scheduler/index.js +0 -3
  205. package/scheduler/index.js.map +1 -1
  206. package/scheduler/types.d.ts +2 -20
  207. package/scheduler/types.js +12 -23
  208. package/scheduler/types.js.map +1 -1
  209. package/storageOperations/changeRequestStorageOperations.js +22 -45
  210. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  211. package/storageOperations/commentStorageOperations.js +25 -50
  212. package/storageOperations/commentStorageOperations.js.map +1 -1
  213. package/storageOperations/contentReviewStorageOperations.js +22 -43
  214. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  215. package/storageOperations/index.js +5 -23
  216. package/storageOperations/index.js.map +1 -1
  217. package/storageOperations/models/changeRequest.model.js +0 -9
  218. package/storageOperations/models/changeRequest.model.js.map +1 -1
  219. package/storageOperations/models/comment.model.js +0 -8
  220. package/storageOperations/models/comment.model.js.map +1 -1
  221. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
  222. package/storageOperations/models/contentModelPluginFactory.js +5 -17
  223. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  224. package/storageOperations/models/contentReview.model.js +6 -31
  225. package/storageOperations/models/contentReview.model.js.map +1 -1
  226. package/storageOperations/models/index.js +3 -29
  227. package/storageOperations/models/index.js.map +1 -1
  228. package/storageOperations/models/reviewer.model.js +17 -9
  229. package/storageOperations/models/reviewer.model.js.map +1 -1
  230. package/storageOperations/models/utils.js +3 -6
  231. package/storageOperations/models/utils.js.map +1 -1
  232. package/storageOperations/models/workflow.model.js +0 -23
  233. package/storageOperations/models/workflow.model.js.map +1 -1
  234. package/storageOperations/reviewerStorageOperations.js +22 -40
  235. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  236. package/storageOperations/workflowStorageOperations.js +25 -48
  237. package/storageOperations/workflowStorageOperations.js.map +1 -1
  238. package/types.d.ts +104 -88
  239. package/types.js +124 -42
  240. package/types.js.map +1 -1
  241. package/utils/contentApwSettingsPlugin.js +0 -6
  242. package/utils/contentApwSettingsPlugin.js.map +1 -1
  243. package/utils/errors.js +1 -18
  244. package/utils/errors.js.map +1 -1
  245. package/utils/fieldResolver.js +5 -21
  246. package/utils/fieldResolver.js.map +1 -1
  247. package/utils/resolve.js +0 -3
  248. package/utils/resolve.js.map +1 -1
@@ -0,0 +1,11 @@
1
+ import { 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,21 @@
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;
@@ -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 { 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"}
@@ -0,0 +1,11 @@
1
+ import { 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,21 @@
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;
@@ -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 { 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"}
@@ -0,0 +1,15 @@
1
+ import { 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,45 @@
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;
@@ -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 { 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"}
@@ -0,0 +1,2 @@
1
+ import { ApwChangeRequestNotificationCbParams } from "../../../ApwChangeRequestNotification";
2
+ export declare const sendChangeRequestNotification: (params: ApwChangeRequestNotificationCbParams) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendChangeRequestNotification = void 0;
7
+ var _lastChangeRequestNotificationPlugin = require("./lastChangeRequestNotificationPlugin");
8
+ const sendChangeRequestNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const changeRequestPlugin = (0, _lastChangeRequestNotificationPlugin.getLastChangeRequestNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!changeRequestPlugin) {
22
+ console.log("No e-mail body change request plugin.");
23
+ return;
24
+ }
25
+ const body = changeRequestPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new change request on the Content Review you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendChangeRequestNotification = sendChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lastChangeRequestNotificationPlugin","require","sendChangeRequestNotification","params","context","reviewers","contentReview","length","changeRequestPlugin","getLastChangeRequestNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify","exports"],"sources":["sendChangeRequestNotification.ts"],"sourcesContent":["import { getLastChangeRequestNotificationPlugin } from \"./lastChangeRequestNotificationPlugin\";\nimport { ApwChangeRequestNotificationCbParams } from \"~/ApwChangeRequestNotification\";\n\nexport const sendChangeRequestNotification = async (\n params: ApwChangeRequestNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const changeRequestPlugin = getLastChangeRequestNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!changeRequestPlugin) {\n console.log(\"No e-mail body change request plugin.\");\n return;\n }\n\n const body = changeRequestPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the change request plugin: ${changeRequestPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new change request on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,oCAAA,GAAAC,OAAA;AAGO,MAAMC,6BAA6B,GAAG,MACzCC,MAA4C,IAC5B;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,mBAAmB,GAAG,IAAAC,2EAAsC,EAAC;IAC/DL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,mBAAmB,EAAE;IACtBI,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;IACpD;EACJ;EAEA,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAAM,CAACZ,MAAM,CAAC;EAC/C,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAC,CAAC;IACzF;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,0EAA0E;IACnFC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAACG,OAAA,CAAA5B,6BAAA,GAAAA,6BAAA"}
@@ -0,0 +1,2 @@
1
+ import { ApwCommentNotificationCbParams } from "../../../ApwCommentNotification";
2
+ export declare const sendCommentNotification: (params: ApwCommentNotificationCbParams) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendCommentNotification = void 0;
7
+ var _lastCommentNotificationPlugin = require("./lastCommentNotificationPlugin");
8
+ const sendCommentNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const commentPlugin = (0, _lastCommentNotificationPlugin.getLastCommentNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!commentPlugin) {
22
+ console.log("No e-mail body comment plugin.");
23
+ return;
24
+ }
25
+ const body = commentPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new comment on the Content Review you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendCommentNotification = sendCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lastCommentNotificationPlugin","require","sendCommentNotification","params","context","reviewers","contentReview","length","commentPlugin","getLastCommentNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify","exports"],"sources":["sendCommentNotification.ts"],"sourcesContent":["import { getLastCommentNotificationPlugin } from \"./lastCommentNotificationPlugin\";\nimport { ApwCommentNotificationCbParams } from \"~/ApwCommentNotification\";\n\nexport const sendCommentNotification = async (\n params: ApwCommentNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const commentPlugin = getLastCommentNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!commentPlugin) {\n console.log(\"No e-mail body comment plugin.\");\n return;\n }\n\n const body = commentPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the comment plugin: ${commentPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new comment on the Content Review you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,8BAAA,GAAAC,OAAA;AAGO,MAAMC,uBAAuB,GAAG,MACnCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,aAAa,GAAG,IAAAC,+DAAgC,EAAC;IACnDL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,aAAa,EAAE;IAChBI,OAAO,CAACC,GAAG,CAAC,gCAAgC,CAAC;IAC7C;EACJ;EAEA,MAAMC,IAAI,GAAGN,aAAa,CAACO,MAAM,CAACZ,MAAM,CAAC;EACzC,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,2CAA0CL,aAAa,CAACQ,IAAK,EAAC,CAAC;IAC5E;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,mEAAmE;IAC5EC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAACG,OAAA,CAAA5B,uBAAA,GAAAA,uBAAA"}
@@ -0,0 +1,2 @@
1
+ import { ApwContentReviewNotificationCbParams } from "../../../ApwContentReviewNotification";
2
+ export declare const sendContentReviewNotification: (params: ApwContentReviewNotificationCbParams) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sendContentReviewNotification = void 0;
7
+ var _lastContentReviewNotificationPlugin = require("./lastContentReviewNotificationPlugin");
8
+ const sendContentReviewNotification = async params => {
9
+ const {
10
+ context,
11
+ reviewers,
12
+ contentReview
13
+ } = params;
14
+ if (reviewers.length === 0) {
15
+ return;
16
+ }
17
+ const contentReviewPlugin = (0, _lastContentReviewNotificationPlugin.getLastContentReviewNotificationPlugin)({
18
+ context,
19
+ type: contentReview.content.type
20
+ });
21
+ if (!contentReviewPlugin) {
22
+ console.log("No e-mail body content review plugin.");
23
+ return;
24
+ }
25
+ const body = contentReviewPlugin.create(params);
26
+ if (!body) {
27
+ console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);
28
+ return;
29
+ }
30
+ const result = await context.mailer.sendMail({
31
+ bcc: reviewers.map(r => r.email),
32
+ subject: "There is a new content review which you are assigned on.",
33
+ text: body.text,
34
+ html: body.html || body.text
35
+ });
36
+ if (!result.error) {
37
+ return;
38
+ }
39
+ console.log("Error while sending e-mail", JSON.stringify(result.error));
40
+ };
41
+ exports.sendContentReviewNotification = sendContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lastContentReviewNotificationPlugin","require","sendContentReviewNotification","params","context","reviewers","contentReview","length","contentReviewPlugin","getLastContentReviewNotificationPlugin","type","content","console","log","body","create","name","result","mailer","sendMail","bcc","map","r","email","subject","text","html","error","JSON","stringify","exports"],"sources":["sendContentReviewNotification.ts"],"sourcesContent":["import { getLastContentReviewNotificationPlugin } from \"./lastContentReviewNotificationPlugin\";\nimport { ApwContentReviewNotificationCbParams } from \"~/ApwContentReviewNotification\";\n\nexport const sendContentReviewNotification = async (\n params: ApwContentReviewNotificationCbParams\n): Promise<void> => {\n const { context, reviewers, contentReview } = params;\n if (reviewers.length === 0) {\n return;\n }\n\n const contentReviewPlugin = getLastContentReviewNotificationPlugin({\n context,\n type: contentReview.content.type\n });\n if (!contentReviewPlugin) {\n console.log(\"No e-mail body content review plugin.\");\n return;\n }\n\n const body = contentReviewPlugin.create(params);\n if (!body) {\n console.log(`No e-mail body from the content review plugin: ${contentReviewPlugin.name}`);\n return;\n }\n\n const result = await context.mailer.sendMail({\n bcc: reviewers.map(r => r.email),\n subject: \"There is a new content review which you are assigned on.\",\n text: body.text,\n html: body.html || body.text\n });\n if (!result.error) {\n return;\n }\n console.log(\"Error while sending e-mail\", JSON.stringify(result.error));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,oCAAA,GAAAC,OAAA;AAGO,MAAMC,6BAA6B,GAAG,MACzCC,MAA4C,IAC5B;EAChB,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EACpD,IAAIE,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB;EACJ;EAEA,MAAMC,mBAAmB,GAAG,IAAAC,2EAAsC,EAAC;IAC/DL,OAAO;IACPM,IAAI,EAAEJ,aAAa,CAACK,OAAO,CAACD;EAChC,CAAC,CAAC;EACF,IAAI,CAACF,mBAAmB,EAAE;IACtBI,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;IACpD;EACJ;EAEA,MAAMC,IAAI,GAAGN,mBAAmB,CAACO,MAAM,CAACZ,MAAM,CAAC;EAC/C,IAAI,CAACW,IAAI,EAAE;IACPF,OAAO,CAACC,GAAG,CAAE,kDAAiDL,mBAAmB,CAACQ,IAAK,EAAC,CAAC;IACzF;EACJ;EAEA,MAAMC,MAAM,GAAG,MAAMb,OAAO,CAACc,MAAM,CAACC,QAAQ,CAAC;IACzCC,GAAG,EAAEf,SAAS,CAACgB,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,KAAK,CAAC;IAChCC,OAAO,EAAE,0DAA0D;IACnEC,IAAI,EAAEX,IAAI,CAACW,IAAI;IACfC,IAAI,EAAEZ,IAAI,CAACY,IAAI,IAAIZ,IAAI,CAACW;EAC5B,CAAC,CAAC;EACF,IAAI,CAACR,MAAM,CAACU,KAAK,EAAE;IACf;EACJ;EACAf,OAAO,CAACC,GAAG,CAAC,4BAA4B,EAAEe,IAAI,CAACC,SAAS,CAACZ,MAAM,CAACU,KAAK,CAAC,CAAC;AAC3E,CAAC;AAACG,OAAA,CAAA5B,6BAAA,GAAAA,6BAAA"}
@@ -1,20 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.updatePendingChangeRequestsCount = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _utils = require("../utils");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
10
  const updatePendingChangeRequests = async ({
19
11
  contentReviewMethods,
20
12
  step,
@@ -28,19 +20,18 @@ const updatePendingChangeRequests = async ({
28
20
  contentReviewMethods,
29
21
  id,
30
22
  getNewContentReviewData: data => {
31
- return _objectSpread(_objectSpread({}, data), {}, {
32
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
23
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
24
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
33
25
  pendingChangeRequests: step.pendingChangeRequests + delta
34
26
  }))
35
27
  });
36
28
  }
37
29
  });
38
30
  };
39
-
40
31
  const updatePendingChangeRequestsCount = ({
41
32
  apw
42
33
  }) => {
43
- apw.changeRequest.onAfterChangeRequestDelete.subscribe(async ({
34
+ apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({
44
35
  changeRequest
45
36
  }) => {
46
37
  /**
@@ -54,15 +45,13 @@ const updatePendingChangeRequestsCount = ({
54
45
  * After a "changeRequest" is deleted, decrement the "pendingChangeRequests" count
55
46
  * in the corresponding step of the content review entry.
56
47
  */
57
-
58
-
59
48
  await updatePendingChangeRequests({
60
49
  contentReviewMethods: apw.contentReview,
61
50
  step: changeRequest.step,
62
51
  delta: -1
63
52
  });
64
53
  });
65
- apw.changeRequest.onAfterChangeRequestCreate.subscribe(async ({
54
+ apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
66
55
  changeRequest
67
56
  }) => {
68
57
  /**
@@ -75,7 +64,7 @@ const updatePendingChangeRequestsCount = ({
75
64
  delta: 1
76
65
  });
77
66
  });
78
- apw.changeRequest.onAfterChangeRequestUpdate.subscribe(async ({
67
+ apw.changeRequest.onChangeRequestAfterUpdate.subscribe(async ({
79
68
  changeRequest,
80
69
  original
81
70
  }) => {
@@ -94,5 +83,4 @@ const updatePendingChangeRequestsCount = ({
94
83
  }
95
84
  });
96
85
  };
97
-
98
86
  exports.updatePendingChangeRequestsCount = updatePendingChangeRequestsCount;
@@ -1 +1 @@
1
- {"version":3,"names":["updatePendingChangeRequests","contentReviewMethods","step","delta","id","stepId","extractContentReviewIdAndStep","updateContentReview","getNewContentReviewData","data","steps","updateContentReviewStep","pendingChangeRequests","updatePendingChangeRequestsCount","apw","changeRequest","onAfterChangeRequestDelete","subscribe","resolved","contentReview","onAfterChangeRequestCreate","onAfterChangeRequestUpdate","original"],"sources":["updatePendingChangeRequests.ts"],"sourcesContent":["import { ApwChangeRequest, ApwContentReviewCrud, LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\ninterface UpdatePendingChangeRequestsParams {\n contentReviewMethods: ApwContentReviewCrud;\n delta: number;\n step: ApwChangeRequest[\"step\"];\n}\n\nconst updatePendingChangeRequests = async ({\n contentReviewMethods,\n step,\n delta\n}: UpdatePendingChangeRequestsParams): Promise<void> => {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n pendingChangeRequests: step.pendingChangeRequests + delta\n }))\n };\n }\n });\n};\n\nexport const updatePendingChangeRequestsCount = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onAfterChangeRequestDelete.subscribe(async ({ changeRequest }) => {\n /**\n * If the deleted changeRequest was marked as resolved. We don't need to do anything here,\n * because \"pendingChangeRequests has been already updated in \"onAfterChangeRequestUpdate\" hook.\n */\n if (changeRequest.resolved === true) {\n return;\n }\n /**\n * After a \"changeRequest\" is deleted, decrement the \"pendingChangeRequests\" count\n * in the corresponding step of the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: -1\n });\n });\n\n apw.changeRequest.onAfterChangeRequestCreate.subscribe(async ({ changeRequest }) => {\n /**\n * After a \"changeRequest\" is created, increment the \"pendingChangeRequests\" count\n * of the corresponding step in the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: 1\n });\n });\n\n apw.changeRequest.onAfterChangeRequestUpdate.subscribe(async ({ changeRequest, original }) => {\n /**\n * After a \"changeRequest\" is created, and the value of \"resolved\" field has changed;\n * then we also need to update the \"pendingChangeRequests\" count of the corresponding step in the content review entry.\n */\n if (original.resolved !== changeRequest.resolved) {\n const resolved = changeRequest.resolved;\n const delta = resolved === true ? -1 : 1;\n\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;;;;;AAYA,MAAMA,2BAA2B,GAAG,OAAO;EACvCC,oBADuC;EAEvCC,IAFuC;EAGvCC;AAHuC,CAAP,KAIoB;EACpD,MAAM;IAAEC,EAAF;IAAMC;EAAN,IAAiB,IAAAC,oCAAA,EAA8BJ,IAA9B,CAAvB;EAEA,MAAM,IAAAK,0BAAA,EAAoB;IACtBN,oBADsB;IAEtBG,EAFsB;IAGtBI,u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/B;MACA,MAAMf,KAAK,GAAGe,QAAQ,KAAK,IAAb,GAAoB,CAAC,CAArB,GAAyB,CAAvC;MAEA,MAAMlB,2BAA2B,CAAC;QAC9BC,oBAAoB,EAAEa,GAAG,CAACK,aADI;QAE9BjB,IAAI,EAAEa,aAAa,CAACb,IAFU;QAG9BC;MAH8B,CAAD,CAAjC;IAKH;EACJ,CAfD;AAgBH,CAlDM"}
1
+ {"version":3,"names":["_utils","require","updatePendingChangeRequests","contentReviewMethods","step","delta","id","stepId","extractContentReviewIdAndStep","updateContentReview","getNewContentReviewData","data","_objectSpread2","default","steps","updateContentReviewStep","pendingChangeRequests","updatePendingChangeRequestsCount","apw","changeRequest","onChangeRequestAfterDelete","subscribe","resolved","contentReview","onChangeRequestAfterCreate","onChangeRequestAfterUpdate","original","exports"],"sources":["updatePendingChangeRequests.ts"],"sourcesContent":["import { ApwChangeRequest, ApwContentReviewCrud, LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\ninterface UpdatePendingChangeRequestsParams {\n contentReviewMethods: ApwContentReviewCrud;\n delta: number;\n step: ApwChangeRequest[\"step\"];\n}\n\nconst updatePendingChangeRequests = async ({\n contentReviewMethods,\n step,\n delta\n}: UpdatePendingChangeRequestsParams): Promise<void> => {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n pendingChangeRequests: step.pendingChangeRequests + delta\n }))\n };\n }\n });\n};\n\nexport const updatePendingChangeRequestsCount = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * If the deleted changeRequest was marked as resolved. We don't need to do anything here,\n * because \"pendingChangeRequests has been already updated in \"onAfterChangeRequestUpdate\" hook.\n */\n if (changeRequest.resolved === true) {\n return;\n }\n /**\n * After a \"changeRequest\" is deleted, decrement the \"pendingChangeRequests\" count\n * in the corresponding step of the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: -1\n });\n });\n\n apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({ changeRequest }) => {\n /**\n * After a \"changeRequest\" is created, increment the \"pendingChangeRequests\" count\n * of the corresponding step in the content review entry.\n */\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta: 1\n });\n });\n\n apw.changeRequest.onChangeRequestAfterUpdate.subscribe(async ({ changeRequest, original }) => {\n /**\n * After a \"changeRequest\" is created, and the value of \"resolved\" field has changed;\n * then we also need to update the \"pendingChangeRequests\" count of the corresponding step in the content review entry.\n */\n if (original.resolved !== changeRequest.resolved) {\n const resolved = changeRequest.resolved;\n const delta = resolved === true ? -1 : 1;\n\n await updatePendingChangeRequests({\n contentReviewMethods: apw.contentReview,\n step: changeRequest.step,\n delta\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAYA,MAAMC,2BAA2B,GAAG,MAAAA,CAAO;EACvCC,oBAAoB;EACpBC,IAAI;EACJC;AAC+B,CAAC,KAAoB;EACpD,MAAM;IAAEC,EAAE;IAAEC;EAAO,CAAC,GAAG,IAAAC,oCAA6B,EAACJ,IAAI,CAAC;EAE1D,MAAM,IAAAK,0BAAmB,EAAC;IACtBN,oBAAoB;IACpBG,EAAE;IACFI,uBAAuB,EAAEC,IAAI,IAAI;MAC7B,WAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOF,IAAI;QACPG,KAAK,EAAE,IAAAC,8BAAuB,EAACJ,IAAI,CAACG,KAAK,EAAEP,MAAM,EAAEH,IAAI,QAAAQ,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAChDT,IAAI;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QACxBC;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACsB,OAAA,CAAAV,gCAAA,GAAAA,gCAAA"}
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.updateTotalCommentsCount = exports.updateLatestCommentId = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _utils = require("../utils");
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
10
  const updateTotalCommentsCount = ({
19
11
  apw
20
12
  }) => {
21
- apw.comment.onAfterCommentDelete.subscribe(async ({
13
+ apw.comment.onCommentAfterDelete.subscribe(async ({
22
14
  comment
23
15
  }) => {
24
16
  const {
@@ -28,7 +20,6 @@ const updateTotalCommentsCount = ({
28
20
  * After a "comment" is deleted, decrement the "totalComments" count
29
21
  * in the corresponding step of the content review entry.
30
22
  */
31
-
32
23
  if (step) {
33
24
  const {
34
25
  id,
@@ -38,8 +29,8 @@ const updateTotalCommentsCount = ({
38
29
  contentReviewMethods: apw.contentReview,
39
30
  id,
40
31
  getNewContentReviewData: data => {
41
- return _objectSpread(_objectSpread({}, data), {}, {
42
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
32
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
33
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
43
34
  totalComments: step.totalComments - 1
44
35
  }))
45
36
  });
@@ -47,7 +38,7 @@ const updateTotalCommentsCount = ({
47
38
  });
48
39
  }
49
40
  });
50
- apw.comment.onAfterCommentCreate.subscribe(async ({
41
+ apw.comment.onCommentAfterCreate.subscribe(async ({
51
42
  comment
52
43
  }) => {
53
44
  /**
@@ -62,8 +53,8 @@ const updateTotalCommentsCount = ({
62
53
  contentReviewMethods: apw.contentReview,
63
54
  id,
64
55
  getNewContentReviewData: data => {
65
- return _objectSpread(_objectSpread({}, data), {}, {
66
- steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => _objectSpread(_objectSpread({}, step), {}, {
56
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
57
+ steps: (0, _utils.updateContentReviewStep)(data.steps, stepId, step => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
67
58
  totalComments: step.totalComments + 1
68
59
  }))
69
60
  });
@@ -71,13 +62,11 @@ const updateTotalCommentsCount = ({
71
62
  });
72
63
  });
73
64
  };
74
-
75
65
  exports.updateTotalCommentsCount = updateTotalCommentsCount;
76
-
77
66
  const updateLatestCommentId = ({
78
67
  apw
79
68
  }) => {
80
- apw.comment.onAfterCommentCreate.subscribe(async ({
69
+ apw.comment.onCommentAfterCreate.subscribe(async ({
81
70
  comment
82
71
  }) => {
83
72
  /**
@@ -91,13 +80,13 @@ const updateLatestCommentId = ({
91
80
  contentReviewMethods: apw.contentReview,
92
81
  id,
93
82
  getNewContentReviewData: contentReview => {
94
- return _objectSpread(_objectSpread({}, contentReview), {}, {
83
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
95
84
  latestCommentId: comment.id
96
85
  });
97
86
  }
98
87
  });
99
88
  });
100
- apw.comment.onAfterCommentUpdate.subscribe(async ({
89
+ apw.comment.onCommentAfterUpdate.subscribe(async ({
101
90
  comment
102
91
  }) => {
103
92
  /**
@@ -111,13 +100,13 @@ const updateLatestCommentId = ({
111
100
  contentReviewMethods: apw.contentReview,
112
101
  id,
113
102
  getNewContentReviewData: contentReview => {
114
- return _objectSpread(_objectSpread({}, contentReview), {}, {
103
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
115
104
  latestCommentId: comment.id
116
105
  });
117
106
  }
118
107
  });
119
108
  });
120
- apw.comment.onAfterCommentDelete.subscribe(async ({
109
+ apw.comment.onCommentAfterDelete.subscribe(async ({
121
110
  comment
122
111
  }) => {
123
112
  /**
@@ -131,7 +120,6 @@ const updateLatestCommentId = ({
131
120
  id,
132
121
  contentReviewMethods: apw.contentReview
133
122
  });
134
-
135
123
  if (contentReview && contentReview.latestCommentId === comment.id) {
136
124
  const [[latestComment]] = await apw.comment.list({
137
125
  where: {
@@ -145,7 +133,7 @@ const updateLatestCommentId = ({
145
133
  contentReviewMethods: apw.contentReview,
146
134
  id,
147
135
  getNewContentReviewData: contentReview => {
148
- return _objectSpread(_objectSpread({}, contentReview), {}, {
136
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview), {}, {
149
137
  latestCommentId: latestComment ? latestComment.id : null
150
138
  });
151
139
  }
@@ -153,5 +141,4 @@ const updateLatestCommentId = ({
153
141
  }
154
142
  });
155
143
  };
156
-
157
144
  exports.updateLatestCommentId = updateLatestCommentId;
@@ -1 +1 @@
1
- {"version":3,"names":["updateTotalCommentsCount","apw","comment","onAfterCommentDelete","subscribe","step","id","stepId","extractContentReviewIdAndStep","updateContentReview","contentReviewMethods","contentReview","getNewContentReviewData","data","steps","updateContentReviewStep","totalComments","onAfterCommentCreate","updateLatestCommentId","latestCommentId","onAfterCommentUpdate","safelyGetContentReview","latestComment","list","where","changeRequest","sort"],"sources":["updateTotalComments.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n safelyGetContentReview,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\nexport const updateTotalCommentsCount = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onAfterCommentDelete.subscribe(async ({ comment }) => {\n const { step } = comment;\n /**\n * After a \"comment\" is deleted, decrement the \"totalComments\" count\n * in the corresponding step of the content review entry.\n */\n if (step) {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments - 1\n }))\n };\n }\n });\n }\n });\n\n apw.comment.onAfterCommentCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, increment the \"totalComments\" count\n * of the corresponding step in the content review entry.\n */\n const { id, stepId } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments + 1\n }))\n };\n }\n });\n });\n};\n\nexport const updateLatestCommentId = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onAfterCommentCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onAfterCommentUpdate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onAfterCommentDelete.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n const contentReview = await safelyGetContentReview({\n id,\n contentReviewMethods: apw.contentReview\n });\n\n if (contentReview && contentReview.latestCommentId === comment.id) {\n const [[latestComment]] = await apw.comment.list({\n where: { changeRequest: { id: comment.changeRequest } },\n sort: [\"createdOn_DESC\"]\n });\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: latestComment ? latestComment.id : null\n };\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;;;;;AAOO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAC3FA,GAAG,CAACC,OAAJ,CAAYC,oBAAZ,CAAiCC,SAAjC,CAA2C,OAAO;IAAEF;EAAF,CAAP,KAAuB;IAC9D,MAAM;MAAEG;IAAF,IAAWH,OAAjB;IACA;AACR;AACA;AACA;;IACQ,IAAIG,IAAJ,EAAU;MACN,MAAM;QAAEC,EAAF;QAAMC;MAAN,IAAiB,IAAAC,oCAAA,EAA8BH,IAA9B,CAAvB;MAEA,MAAM,IAAAI,0BAAA,EAAoB;QACtBC,oBAAoB,EAAET,GAAG,CAACU,aADJ;QAEtBL,EAFsB;QAGtBM,uBAAuB,EAAEC,IAAI,IAAI;UAC7B,uCACOA,IADP;YA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,EAAED,aAAa,IAAI;UACtC,uCACOA,aADP;YAEIQ,eAAe,EAAEG,aAAa,GAAGA,aAAa,CAAChB,EAAjB,GAAsB;UAFxD;QAIH;MARqB,CAApB,CAAN;IAUH;EACJ,CA7BD;AA8BH,CArEM"}
1
+ {"version":3,"names":["_utils","require","updateTotalCommentsCount","apw","comment","onCommentAfterDelete","subscribe","step","id","stepId","extractContentReviewIdAndStep","updateContentReview","contentReviewMethods","contentReview","getNewContentReviewData","data","_objectSpread2","default","steps","updateContentReviewStep","totalComments","onCommentAfterCreate","exports","updateLatestCommentId","latestCommentId","onCommentAfterUpdate","safelyGetContentReview","latestComment","list","where","changeRequest","sort"],"sources":["updateTotalComments.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n safelyGetContentReview,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\nexport const updateTotalCommentsCount = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n const { step } = comment;\n /**\n * After a \"comment\" is deleted, decrement the \"totalComments\" count\n * in the corresponding step of the content review entry.\n */\n if (step) {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments - 1\n }))\n };\n }\n });\n }\n });\n\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, increment the \"totalComments\" count\n * of the corresponding step in the content review entry.\n */\n const { id, stepId } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments + 1\n }))\n };\n }\n });\n });\n};\n\nexport const updateLatestCommentId = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterUpdate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n const contentReview = await safelyGetContentReview({\n id,\n contentReviewMethods: apw.contentReview\n });\n\n if (contentReview && contentReview.latestCommentId === comment.id) {\n const [[latestComment]] = await apw.comment.list({\n where: { changeRequest: { id: comment.changeRequest } },\n sort: [\"createdOn_DESC\"]\n });\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: latestComment ? latestComment.id : null\n };\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAGA,CAAC;EAAEC;AAA8C,CAAC,KAAK;EAC3FA,GAAG,CAACC,OAAO,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAQ,CAAC,KAAK;IAC9D,MAAM;MAAEG;IAAK,CAAC,GAAGH,OAAO;IACxB;AACR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