@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.611c5af35e

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 (239) 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 +0 -5
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +4 -11
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +4 -12
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +32 -86
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +4 -12
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.js +4 -17
  24. package/crud/createWorkflowMethods.js.map +1 -1
  25. package/crud/index.js +0 -25
  26. package/crud/index.js.map +1 -1
  27. package/crud/utils.js +0 -28
  28. package/crud/utils.js.map +1 -1
  29. package/index.d.ts +3 -3
  30. package/index.js +5 -13
  31. package/index.js.map +1 -1
  32. package/package.json +35 -35
  33. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  35. package/plugins/cms/apwEntryPlugins.js +0 -8
  36. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  37. package/plugins/cms/index.js +5 -10
  38. package/plugins/cms/index.js.map +1 -1
  39. package/plugins/cms/linkContentReviewToEntry.js +0 -17
  40. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  41. package/plugins/cms/linkWorkflowToEntry.js +2 -31
  42. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  43. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  44. package/plugins/cms/notifications/changeRequestNotification.js +31 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  46. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  47. package/plugins/cms/notifications/commentNotification.js +31 -0
  48. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  49. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.js +31 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  52. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  53. package/plugins/cms/notifications/contentUrl.js +53 -0
  54. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  55. package/plugins/cms/triggerContentReview.js +0 -14
  56. package/plugins/cms/triggerContentReview.js.map +1 -1
  57. package/plugins/cms/updateContentReviewStatus.js +0 -18
  58. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  59. package/plugins/cms/utils.js +2 -47
  60. package/plugins/cms/utils.js.map +1 -1
  61. package/plugins/context.js +0 -31
  62. package/plugins/context.js.map +1 -1
  63. package/plugins/graphql/changeRequest.gql.js +1 -8
  64. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  65. package/plugins/graphql/comment.gql.js +1 -8
  66. package/plugins/graphql/comment.gql.js.map +1 -1
  67. package/plugins/graphql/contentReview.gql.js +1 -20
  68. package/plugins/graphql/contentReview.gql.js.map +1 -1
  69. package/plugins/graphql/reviewer.gql.js +3 -8
  70. package/plugins/graphql/reviewer.gql.js.map +1 -1
  71. package/plugins/graphql/workflow.gql.js +1 -8
  72. package/plugins/graphql/workflow.gql.js.map +1 -1
  73. package/plugins/graphql.js +1 -16
  74. package/plugins/graphql.js.map +1 -1
  75. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  76. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  77. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
  78. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  79. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
  80. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  81. package/plugins/hooks/index.js +2 -13
  82. package/plugins/hooks/index.js.map +1 -1
  83. package/plugins/hooks/initializeContentReviewSteps.js +2 -15
  84. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  85. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  86. package/plugins/hooks/initializeNotifications.js +15 -0
  87. package/plugins/hooks/initializeNotifications.js.map +1 -0
  88. package/plugins/hooks/listContentReviews.d.ts +1 -1
  89. package/plugins/hooks/listContentReviews.js +9 -33
  90. package/plugins/hooks/listContentReviews.js.map +1 -1
  91. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  92. package/plugins/hooks/notifications/appUrl.js +18 -0
  93. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  94. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  95. package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  97. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  98. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  100. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  101. package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  103. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  104. package/plugins/hooks/notifications/commentUrl.js +27 -0
  105. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  106. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  107. package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  109. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  110. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  112. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  113. package/plugins/hooks/notifications/contentUrl.js +24 -0
  114. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  115. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  116. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  118. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  119. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  121. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  122. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  124. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  125. package/plugins/hooks/notifications/reviewers.js +44 -0
  126. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  127. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  128. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  130. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  131. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  133. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  134. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  136. package/plugins/hooks/updatePendingChangeRequests.js +0 -8
  137. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  138. package/plugins/hooks/updateTotalComments.js +0 -9
  139. package/plugins/hooks/updateTotalComments.js.map +1 -1
  140. package/plugins/hooks/validateChangeRequest.js +25 -16
  141. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  142. package/plugins/hooks/validateComment.js +11 -12
  143. package/plugins/hooks/validateComment.js.map +1 -1
  144. package/plugins/hooks/validateContentReview.js +0 -6
  145. package/plugins/hooks/validateContentReview.js.map +1 -1
  146. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
  147. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  148. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  149. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  150. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  151. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  152. package/plugins/pageBuilder/index.js +5 -8
  153. package/plugins/pageBuilder/index.js.map +1 -1
  154. package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
  155. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  156. package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
  157. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  158. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  159. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  161. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  162. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  164. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  165. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  167. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  168. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  170. package/plugins/pageBuilder/triggerContentReview.js +0 -11
  171. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  172. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
  173. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  174. package/plugins/pageBuilder/utils.js +1 -35
  175. package/plugins/pageBuilder/utils.js.map +1 -1
  176. package/plugins/utils.d.ts +0 -1
  177. package/plugins/utils.js +1 -50
  178. package/plugins/utils.js.map +1 -1
  179. package/scheduler/createScheduleActionMethods.js +1 -20
  180. package/scheduler/createScheduleActionMethods.js.map +1 -1
  181. package/scheduler/handlers/executeAction/index.js +9 -33
  182. package/scheduler/handlers/executeAction/index.js.map +1 -1
  183. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -5
  184. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  185. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +0 -21
  186. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  187. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -27
  188. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  189. package/scheduler/handlers/executeAction/security.js +0 -11
  190. package/scheduler/handlers/executeAction/security.js.map +1 -1
  191. package/scheduler/handlers/scheduleAction/index.js +5 -25
  192. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  193. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
  194. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  195. package/scheduler/handlers/utils.js +3 -40
  196. package/scheduler/handlers/utils.js.map +1 -1
  197. package/scheduler/index.js +0 -3
  198. package/scheduler/index.js.map +1 -1
  199. package/scheduler/types.js +0 -6
  200. package/scheduler/types.js.map +1 -1
  201. package/storageOperations/changeRequestStorageOperations.js +0 -19
  202. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  203. package/storageOperations/commentStorageOperations.js +0 -21
  204. package/storageOperations/commentStorageOperations.js.map +1 -1
  205. package/storageOperations/contentReviewStorageOperations.js +0 -17
  206. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  207. package/storageOperations/index.js +0 -14
  208. package/storageOperations/index.js.map +1 -1
  209. package/storageOperations/models/changeRequest.model.js +0 -9
  210. package/storageOperations/models/changeRequest.model.js.map +1 -1
  211. package/storageOperations/models/comment.model.js +0 -8
  212. package/storageOperations/models/comment.model.js.map +1 -1
  213. package/storageOperations/models/contentModelPluginFactory.js +0 -5
  214. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  215. package/storageOperations/models/contentReview.model.js +0 -26
  216. package/storageOperations/models/contentReview.model.js.map +1 -1
  217. package/storageOperations/models/index.js +2 -24
  218. package/storageOperations/models/index.js.map +1 -1
  219. package/storageOperations/models/reviewer.model.js +17 -9
  220. package/storageOperations/models/reviewer.model.js.map +1 -1
  221. package/storageOperations/models/utils.js +0 -4
  222. package/storageOperations/models/utils.js.map +1 -1
  223. package/storageOperations/models/workflow.model.js +0 -23
  224. package/storageOperations/models/workflow.model.js.map +1 -1
  225. package/storageOperations/reviewerStorageOperations.js +11 -20
  226. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  227. package/storageOperations/workflowStorageOperations.js +0 -19
  228. package/storageOperations/workflowStorageOperations.js.map +1 -1
  229. package/types.d.ts +21 -9
  230. package/types.js +0 -14
  231. package/types.js.map +1 -1
  232. package/utils/contentApwSettingsPlugin.js +0 -6
  233. package/utils/contentApwSettingsPlugin.js.map +1 -1
  234. package/utils/errors.js +0 -17
  235. package/utils/errors.js.map +1 -1
  236. package/utils/fieldResolver.js +2 -12
  237. package/utils/fieldResolver.js.map +1 -1
  238. package/utils/resolve.js +0 -3
  239. package/utils/resolve.js.map +1 -1
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createReviewerFromIdentity = void 0;
7
-
8
7
  const createReviewerFromIdentity = ({
9
8
  security,
10
9
  apw
@@ -16,7 +15,6 @@ const createReviewerFromIdentity = ({
16
15
  identity
17
16
  }) => {
18
17
  let reviewer;
19
-
20
18
  try {
21
19
  [[reviewer]] = await apw.reviewer.list({
22
20
  where: {
@@ -25,38 +23,51 @@ const createReviewerFromIdentity = ({
25
23
  limit: 1
26
24
  });
27
25
  } catch (e) {
28
- if (e.message === "index_not_found_exception") {// Do nothing
26
+ if (e.message === "index_not_found_exception") {
27
+ // Do nothing
29
28
  } else {
30
29
  throw e;
31
30
  }
32
31
  }
32
+ const email = identity.email || null;
33
33
  /**
34
34
  * Create a reviewer if it doesn't exist already.
35
35
  */
36
-
37
-
38
36
  if (!reviewer) {
39
- await apw.reviewer.create({
40
- identityId: identity.id,
41
- displayName: identity.displayName,
42
- type: identity.type
43
- });
37
+ try {
38
+ await apw.reviewer.create({
39
+ identityId: identity.id,
40
+ displayName: identity.displayName,
41
+ type: identity.type,
42
+ email
43
+ });
44
+ } catch (ex) {
45
+ console.log(`There was an error while creating reviewer with identity: ${identity.id}`);
46
+ console.log(JSON.stringify(ex));
47
+ throw ex;
48
+ }
44
49
  return;
45
50
  }
46
51
  /**
47
52
  * If "displayName" doesn't match it means it has been updated in the identity,
48
53
  * therefore, we need to update it on reviewer as well keep them in sync.
49
54
  */
50
-
51
-
52
- if (reviewer.displayName !== identity.displayName) {
55
+ const update = reviewer.displayName !== identity.displayName || reviewer.email !== email;
56
+ if (!update) {
57
+ return;
58
+ }
59
+ try {
53
60
  await apw.reviewer.update(reviewer.id, {
54
61
  identityId: reviewer.identityId,
55
62
  type: reviewer.type,
56
- displayName: identity.displayName
63
+ displayName: identity.displayName,
64
+ email
57
65
  });
66
+ } catch (ex) {
67
+ console.log(`There was an error while updating reviewer: ${reviewer.id}`);
68
+ console.log(JSON.stringify(ex));
69
+ throw ex;
58
70
  }
59
71
  });
60
72
  };
61
-
62
73
  exports.createReviewerFromIdentity = createReviewerFromIdentity;
@@ -1 +1 @@
1
- {"version":3,"names":["createReviewerFromIdentity","security","apw","onAfterLogin","subscribe","identity","reviewer","list","where","identityId","id","limit","e","message","create","displayName","type","update"],"sources":["createReviewerFromIdentity.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const createReviewerFromIdentity = ({ security, apw }: LifeCycleHookCallbackParams) => {\n /**\n * Replicate identity in \"AdvancedPublishingWorkflow\" system after login.\n */\n security.onAfterLogin.subscribe(async ({ identity }) => {\n let reviewer;\n try {\n [[reviewer]] = await apw.reviewer.list({\n where: { identityId: identity.id },\n limit: 1\n });\n } catch (e) {\n if (e.message === \"index_not_found_exception\") {\n // Do nothing\n } else {\n throw e;\n }\n }\n /**\n * Create a reviewer if it doesn't exist already.\n */\n if (!reviewer) {\n await apw.reviewer.create({\n identityId: identity.id,\n displayName: identity.displayName,\n type: identity.type\n });\n return;\n }\n /**\n * If \"displayName\" doesn't match it means it has been updated in the identity,\n * therefore, we need to update it on reviewer as well keep them in sync.\n */\n if (reviewer.displayName !== identity.displayName) {\n await apw.reviewer.update(reviewer.id, {\n identityId: reviewer.identityId,\n type: reviewer.type,\n displayName: identity.displayName\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,0BAA0B,GAAG,CAAC;EAAEC,QAAF;EAAYC;AAAZ,CAAD,KAAoD;EAC1F;AACJ;AACA;EACID,QAAQ,CAACE,YAAT,CAAsBC,SAAtB,CAAgC,OAAO;IAAEC;EAAF,CAAP,KAAwB;IACpD,IAAIC,QAAJ;;IACA,IAAI;MACA,CAAC,CAACA,QAAD,CAAD,IAAe,MAAMJ,GAAG,CAACI,QAAJ,CAAaC,IAAb,CAAkB;QACnCC,KAAK,EAAE;UAAEC,UAAU,EAAEJ,QAAQ,CAACK;QAAvB,CAD4B;QAEnCC,KAAK,EAAE;MAF4B,CAAlB,CAArB;IAIH,CALD,CAKE,OAAOC,CAAP,EAAU;MACR,IAAIA,CAAC,CAACC,OAAF,KAAc,2BAAlB,EAA+C,CAC3C;MACH,CAFD,MAEO;QACH,MAAMD,CAAN;MACH;IACJ;IACD;AACR;AACA;;;IACQ,IAAI,CAACN,QAAL,EAAe;MACX,MAAMJ,GAAG,CAACI,QAAJ,CAAaQ,MAAb,CAAoB;QACtBL,UAAU,EAAEJ,QAAQ,CAACK,EADC;QAEtBK,WAAW,EAAEV,QAAQ,CAACU,WAFA;QAGtBC,IAAI,EAAEX,QAAQ,CAACW;MAHO,CAApB,CAAN;MAKA;IACH;IACD;AACR;AACA;AACA;;;IACQ,IAAIV,QAAQ,CAACS,WAAT,KAAyBV,QAAQ,CAACU,WAAtC,EAAmD;MAC/C,MAAMb,GAAG,CAACI,QAAJ,CAAaW,MAAb,CAAoBX,QAAQ,CAACI,EAA7B,EAAiC;QACnCD,UAAU,EAAEH,QAAQ,CAACG,UADc;QAEnCO,IAAI,EAAEV,QAAQ,CAACU,IAFoB;QAGnCD,WAAW,EAAEV,QAAQ,CAACU;MAHa,CAAjC,CAAN;IAKH;EACJ,CApCD;AAqCH,CAzCM"}
1
+ {"version":3,"names":["createReviewerFromIdentity","security","apw","onAfterLogin","subscribe","identity","reviewer","list","where","identityId","id","limit","e","message","email","create","displayName","type","ex","console","log","JSON","stringify","update"],"sources":["createReviewerFromIdentity.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const createReviewerFromIdentity = ({ security, apw }: LifeCycleHookCallbackParams) => {\n /**\n * Replicate identity in \"AdvancedPublishingWorkflow\" system after login.\n */\n security.onAfterLogin.subscribe(async ({ identity }) => {\n let reviewer;\n try {\n [[reviewer]] = await apw.reviewer.list({\n where: { identityId: identity.id },\n limit: 1\n });\n } catch (e) {\n if (e.message === \"index_not_found_exception\") {\n // Do nothing\n } else {\n throw e;\n }\n }\n const email = (identity as any).email || null;\n /**\n * Create a reviewer if it doesn't exist already.\n */\n if (!reviewer) {\n try {\n await apw.reviewer.create({\n identityId: identity.id,\n displayName: identity.displayName,\n type: identity.type,\n email\n });\n } catch (ex) {\n console.log(\n `There was an error while creating reviewer with identity: ${identity.id}`\n );\n console.log(JSON.stringify(ex));\n throw ex;\n }\n return;\n }\n /**\n * If \"displayName\" doesn't match it means it has been updated in the identity,\n * therefore, we need to update it on reviewer as well keep them in sync.\n */\n const update = reviewer.displayName !== identity.displayName || reviewer.email !== email;\n if (!update) {\n return;\n }\n try {\n await apw.reviewer.update(reviewer.id, {\n identityId: reviewer.identityId,\n type: reviewer.type,\n displayName: identity.displayName,\n email\n });\n } catch (ex) {\n console.log(`There was an error while updating reviewer: ${reviewer.id}`);\n console.log(JSON.stringify(ex));\n throw ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,0BAA0B,GAAG,CAAC;EAAEC,QAAQ;EAAEC;AAAiC,CAAC,KAAK;EAC1F;AACJ;AACA;EACID,QAAQ,CAACE,YAAY,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAS,CAAC,KAAK;IACpD,IAAIC,QAAQ;IACZ,IAAI;MACA,CAAC,CAACA,QAAQ,CAAC,CAAC,GAAG,MAAMJ,GAAG,CAACI,QAAQ,CAACC,IAAI,CAAC;QACnCC,KAAK,EAAE;UAAEC,UAAU,EAAEJ,QAAQ,CAACK;QAAG,CAAC;QAClCC,KAAK,EAAE;MACX,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,CAAC,EAAE;MACR,IAAIA,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;QAC3C;MAAA,CACH,MAAM;QACH,MAAMD,CAAC;MACX;IACJ;IACA,MAAME,KAAK,GAAIT,QAAQ,CAASS,KAAK,IAAI,IAAI;IAC7C;AACR;AACA;IACQ,IAAI,CAACR,QAAQ,EAAE;MACX,IAAI;QACA,MAAMJ,GAAG,CAACI,QAAQ,CAACS,MAAM,CAAC;UACtBN,UAAU,EAAEJ,QAAQ,CAACK,EAAE;UACvBM,WAAW,EAAEX,QAAQ,CAACW,WAAW;UACjCC,IAAI,EAAEZ,QAAQ,CAACY,IAAI;UACnBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,GAAG,CACN,6DAA4Df,QAAQ,CAACK,EAAG,EAAC,CAC7E;QACDS,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,EAAE,CAAC,CAAC;QAC/B,MAAMA,EAAE;MACZ;MACA;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMK,MAAM,GAAGjB,QAAQ,CAACU,WAAW,KAAKX,QAAQ,CAACW,WAAW,IAAIV,QAAQ,CAACQ,KAAK,KAAKA,KAAK;IACxF,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IACA,IAAI;MACA,MAAMrB,GAAG,CAACI,QAAQ,CAACiB,MAAM,CAACjB,QAAQ,CAACI,EAAE,EAAE;QACnCD,UAAU,EAAEH,QAAQ,CAACG,UAAU;QAC/BQ,IAAI,EAAEX,QAAQ,CAACW,IAAI;QACnBD,WAAW,EAAEX,QAAQ,CAACW,WAAW;QACjCF;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAE,+CAA8Cd,QAAQ,CAACI,EAAG,EAAC,CAAC;MACzES,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,EAAE,CAAC,CAAC;MAC/B,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteChangeRequestsWithContentReview = void 0;
7
-
8
7
  const deleteChangeRequestsWithContentReview = ({
9
8
  apw
10
9
  }) => {
@@ -18,7 +17,6 @@ const deleteChangeRequestsWithContentReview = ({
18
17
  /**
19
18
  * For each step get associated change requests and delete them.
20
19
  */
21
-
22
20
  for (let i = 0; i < steps.length; i++) {
23
21
  const {
24
22
  id: stepId
@@ -29,13 +27,11 @@ const deleteChangeRequestsWithContentReview = ({
29
27
  /**
30
28
  * Paginate through change requests.
31
29
  */
32
-
33
30
  while (meta.totalCount > 0) {
34
31
  let changeRequests = [];
35
32
  /**
36
33
  * Get all change requests.
37
34
  */
38
-
39
35
  try {
40
36
  [changeRequests, meta] = await apw.changeRequest.list({
41
37
  where: {
@@ -44,18 +40,15 @@ const deleteChangeRequestsWithContentReview = ({
44
40
  });
45
41
  } catch (e) {
46
42
  meta.totalCount = 0;
47
-
48
43
  if (e.message !== "index_not_found_exception") {
49
44
  throw e;
50
45
  }
51
-
52
46
  console.log(e);
53
47
  }
48
+
54
49
  /**
55
50
  * Delete change requests one by one.
56
51
  */
57
-
58
-
59
52
  for (const changeRequest of changeRequests) {
60
53
  await apw.changeRequest.delete(changeRequest.id);
61
54
  }
@@ -63,5 +56,4 @@ const deleteChangeRequestsWithContentReview = ({
63
56
  }
64
57
  });
65
58
  };
66
-
67
59
  exports.deleteChangeRequestsWithContentReview = deleteChangeRequestsWithContentReview;
@@ -1 +1 @@
1
- {"version":3,"names":["deleteChangeRequestsWithContentReview","apw","contentReview","onContentReviewAfterDelete","subscribe","steps","i","length","id","stepId","meta","totalCount","changeRequests","changeRequest","list","where","step","e","message","console","log","delete"],"sources":["deleteChangeRequestsAfterContentReview.ts"],"sourcesContent":["import { ApwChangeRequest, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteChangeRequestsWithContentReview = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n /**\n * Also delete all associated \"changeRequest\" when a \"contentReview\" is deleted.\n */\n const steps = contentReview.steps;\n /**\n * For each step get associated change requests and delete them.\n */\n for (let i = 0; i < steps.length; i++) {\n const { id: stepId } = steps[i];\n\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through change requests.\n */\n while (meta.totalCount > 0) {\n let changeRequests: ApwChangeRequest[] = [];\n /**\n * Get all change requests.\n */\n try {\n [changeRequests, meta] = await apw.changeRequest.list({\n where: {\n step: `${contentReview.id}#${stepId}`\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete change requests one by one.\n */\n for (const changeRequest of changeRequests) {\n await apw.changeRequest.delete(changeRequest.id);\n }\n }\n }\n });\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,qCAAqC,GAAG,CAAC;EAClDC;AADkD,CAAD,KAEL;EAC5CA,GAAG,CAACC,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF;AACR;AACA;IACQ,MAAMG,KAAK,GAAGH,aAAa,CAACG,KAA5B;IACA;AACR;AACA;;IACQ,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,KAAK,CAACE,MAA1B,EAAkCD,CAAC,EAAnC,EAAuC;MACnC,MAAM;QAAEE,EAAE,EAAEC;MAAN,IAAiBJ,KAAK,CAACC,CAAD,CAA5B;MAEA,IAAII,IAAkC,GAAG;QACrCC,UAAU,EAAE;MADyB,CAAzC;MAGA;AACZ;AACA;;MACY,OAAOD,IAAI,CAACC,UAAL,GAAkB,CAAzB,EAA4B;QACxB,IAAIC,cAAkC,GAAG,EAAzC;QACA;AAChB;AACA;;QACgB,IAAI;UACA,CAACA,cAAD,EAAiBF,IAAjB,IAAyB,MAAMT,GAAG,CAACY,aAAJ,CAAkBC,IAAlB,CAAuB;YAClDC,KAAK,EAAE;cACHC,IAAI,EAAG,GAAEd,aAAa,CAACM,EAAG,IAAGC,MAAO;YADjC;UAD2C,CAAvB,CAA/B;QAKH,CAND,CAME,OAAOQ,CAAP,EAAU;UACRP,IAAI,CAACC,UAAL,GAAkB,CAAlB;;UACA,IAAIM,CAAC,CAACC,OAAF,KAAc,2BAAlB,EAA+C;YAC3C,MAAMD,CAAN;UACH;;UACDE,OAAO,CAACC,GAAR,CAAYH,CAAZ;QACH;QAED;AAChB;AACA;;;QACgB,KAAK,MAAMJ,aAAX,IAA4BD,cAA5B,EAA4C;UACxC,MAAMX,GAAG,CAACY,aAAJ,CAAkBQ,MAAlB,CAAyBR,aAAa,CAACL,EAAvC,CAAN;QACH;MACJ;IACJ;EACJ,CA5CD;AA6CH,CAhDM"}
1
+ {"version":3,"names":["deleteChangeRequestsWithContentReview","apw","contentReview","onContentReviewAfterDelete","subscribe","steps","i","length","id","stepId","meta","totalCount","changeRequests","changeRequest","list","where","step","e","message","console","log","delete"],"sources":["deleteChangeRequestsAfterContentReview.ts"],"sourcesContent":["import { ApwChangeRequest, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteChangeRequestsWithContentReview = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n /**\n * Also delete all associated \"changeRequest\" when a \"contentReview\" is deleted.\n */\n const steps = contentReview.steps;\n /**\n * For each step get associated change requests and delete them.\n */\n for (let i = 0; i < steps.length; i++) {\n const { id: stepId } = steps[i];\n\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through change requests.\n */\n while (meta.totalCount > 0) {\n let changeRequests: ApwChangeRequest[] = [];\n /**\n * Get all change requests.\n */\n try {\n [changeRequests, meta] = await apw.changeRequest.list({\n where: {\n step: `${contentReview.id}#${stepId}`\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete change requests one by one.\n */\n for (const changeRequest of changeRequests) {\n await apw.changeRequest.delete(changeRequest.id);\n }\n }\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,qCAAqC,GAAG,CAAC;EAClDC;AACsC,CAAC,KAAK;EAC5CA,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF;AACR;AACA;IACQ,MAAMG,KAAK,GAAGH,aAAa,CAACG,KAAK;IACjC;AACR;AACA;IACQ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;MACnC,MAAM;QAAEE,EAAE,EAAEC;MAAO,CAAC,GAAGJ,KAAK,CAACC,CAAC,CAAC;MAE/B,IAAII,IAAkC,GAAG;QACrCC,UAAU,EAAE;MAChB,CAAC;MACD;AACZ;AACA;MACY,OAAOD,IAAI,CAACC,UAAU,GAAG,CAAC,EAAE;QACxB,IAAIC,cAAkC,GAAG,EAAE;QAC3C;AAChB;AACA;QACgB,IAAI;UACA,CAACA,cAAc,EAAEF,IAAI,CAAC,GAAG,MAAMT,GAAG,CAACY,aAAa,CAACC,IAAI,CAAC;YAClDC,KAAK,EAAE;cACHC,IAAI,EAAG,GAAEd,aAAa,CAACM,EAAG,IAAGC,MAAO;YACxC;UACJ,CAAC,CAAC;QACN,CAAC,CAAC,OAAOQ,CAAC,EAAE;UACRP,IAAI,CAACC,UAAU,GAAG,CAAC;UACnB,IAAIM,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;YAC3C,MAAMD,CAAC;UACX;UACAE,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC;QAClB;;QAEA;AAChB;AACA;QACgB,KAAK,MAAMJ,aAAa,IAAID,cAAc,EAAE;UACxC,MAAMX,GAAG,CAACY,aAAa,CAACQ,MAAM,CAACR,aAAa,CAACL,EAAE,CAAC;QACpD;MACJ;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteCommentsAfterChangeRequest = void 0;
7
-
8
7
  const deleteCommentsAfterChangeRequest = ({
9
8
  apw
10
9
  }) => {
@@ -20,13 +19,11 @@ const deleteCommentsAfterChangeRequest = ({
20
19
  /**
21
20
  * Paginate through comments.
22
21
  */
23
-
24
22
  while (meta.totalCount > 0) {
25
23
  let comments = [];
26
24
  /**
27
25
  * Get all comments.
28
26
  */
29
-
30
27
  try {
31
28
  [comments, meta] = await apw.comment.list({
32
29
  where: {
@@ -37,23 +34,19 @@ const deleteCommentsAfterChangeRequest = ({
37
34
  });
38
35
  } catch (e) {
39
36
  meta.totalCount = 0;
40
-
41
37
  if (e.message !== "index_not_found_exception") {
42
38
  throw e;
43
39
  }
44
-
45
40
  console.log(e);
46
41
  }
42
+
47
43
  /**
48
44
  * Delete comments one by one.
49
45
  */
50
-
51
-
52
46
  for (const comment of comments) {
53
47
  await apw.comment.delete(comment.id);
54
48
  }
55
49
  }
56
50
  });
57
51
  };
58
-
59
52
  exports.deleteCommentsAfterChangeRequest = deleteCommentsAfterChangeRequest;
@@ -1 +1 @@
1
- {"version":3,"names":["deleteCommentsAfterChangeRequest","apw","changeRequest","onChangeRequestAfterDelete","subscribe","meta","totalCount","comments","comment","list","where","id","e","message","console","log","delete"],"sources":["deleteCommentsAfterChangeRequest.ts"],"sourcesContent":["import { ApwComment, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteCommentsAfterChangeRequest = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * Also delete all associated comments with \"changeRequest\".\n */\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through comments.\n */\n while (meta.totalCount > 0) {\n let comments: ApwComment[] = [];\n /**\n * Get all comments.\n */\n try {\n [comments, meta] = await apw.comment.list({\n where: {\n changeRequest: {\n id: changeRequest.id\n }\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete comments one by one.\n */\n for (const comment of comments) {\n await apw.comment.delete(comment.id);\n }\n }\n });\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,gCAAgC,GAAG,CAAC;EAC7CC;AAD6C,CAAD,KAEA;EAC5CA,GAAG,CAACC,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF;AACR;AACA;IACQ,IAAIG,IAAkC,GAAG;MACrCC,UAAU,EAAE;IADyB,CAAzC;IAGA;AACR;AACA;;IACQ,OAAOD,IAAI,CAACC,UAAL,GAAkB,CAAzB,EAA4B;MACxB,IAAIC,QAAsB,GAAG,EAA7B;MACA;AACZ;AACA;;MACY,IAAI;QACA,CAACA,QAAD,EAAWF,IAAX,IAAmB,MAAMJ,GAAG,CAACO,OAAJ,CAAYC,IAAZ,CAAiB;UACtCC,KAAK,EAAE;YACHR,aAAa,EAAE;cACXS,EAAE,EAAET,aAAa,CAACS;YADP;UADZ;QAD+B,CAAjB,CAAzB;MAOH,CARD,CAQE,OAAOC,CAAP,EAAU;QACRP,IAAI,CAACC,UAAL,GAAkB,CAAlB;;QACA,IAAIM,CAAC,CAACC,OAAF,KAAc,2BAAlB,EAA+C;UAC3C,MAAMD,CAAN;QACH;;QACDE,OAAO,CAACC,GAAR,CAAYH,CAAZ;MACH;MAED;AACZ;AACA;;;MACY,KAAK,MAAMJ,OAAX,IAAsBD,QAAtB,EAAgC;QAC5B,MAAMN,GAAG,CAACO,OAAJ,CAAYQ,MAAZ,CAAmBR,OAAO,CAACG,EAA3B,CAAN;MACH;IACJ;EACJ,CAtCD;AAuCH,CA1CM"}
1
+ {"version":3,"names":["deleteCommentsAfterChangeRequest","apw","changeRequest","onChangeRequestAfterDelete","subscribe","meta","totalCount","comments","comment","list","where","id","e","message","console","log","delete"],"sources":["deleteCommentsAfterChangeRequest.ts"],"sourcesContent":["import { ApwComment, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteCommentsAfterChangeRequest = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * Also delete all associated comments with \"changeRequest\".\n */\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through comments.\n */\n while (meta.totalCount > 0) {\n let comments: ApwComment[] = [];\n /**\n * Get all comments.\n */\n try {\n [comments, meta] = await apw.comment.list({\n where: {\n changeRequest: {\n id: changeRequest.id\n }\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete comments one by one.\n */\n for (const comment of comments) {\n await apw.comment.delete(comment.id);\n }\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gCAAgC,GAAG,CAAC;EAC7CC;AACsC,CAAC,KAAK;EAC5CA,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF;AACR;AACA;IACQ,IAAIG,IAAkC,GAAG;MACrCC,UAAU,EAAE;IAChB,CAAC;IACD;AACR;AACA;IACQ,OAAOD,IAAI,CAACC,UAAU,GAAG,CAAC,EAAE;MACxB,IAAIC,QAAsB,GAAG,EAAE;MAC/B;AACZ;AACA;MACY,IAAI;QACA,CAACA,QAAQ,EAAEF,IAAI,CAAC,GAAG,MAAMJ,GAAG,CAACO,OAAO,CAACC,IAAI,CAAC;UACtCC,KAAK,EAAE;YACHR,aAAa,EAAE;cACXS,EAAE,EAAET,aAAa,CAACS;YACtB;UACJ;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOC,CAAC,EAAE;QACRP,IAAI,CAACC,UAAU,GAAG,CAAC;QACnB,IAAIM,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;UAC3C,MAAMD,CAAC;QACX;QACAE,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC;MAClB;;MAEA;AACZ;AACA;MACY,KAAK,MAAMJ,OAAO,IAAID,QAAQ,EAAE;QAC5B,MAAMN,GAAG,CAACO,OAAO,CAACQ,MAAM,CAACR,OAAO,CAACG,EAAE,CAAC;MACxC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -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,6 @@ new _api.ContextPlugin(async context => {
66
55
  apw
67
56
  });
68
57
  (0, _listContentReviews.listContentReviews)(context);
58
+ (0, _initializeNotifications.initializeNotifications)(context);
69
59
  });
70
-
71
60
  exports.attachApwHooks = attachApwHooks;
@@ -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":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview","listContentReviews","initializeNotifications"],"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 \"./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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,cAAc,GAAG;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;AAAC"}
@@ -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
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
9
  var _set = _interopRequireDefault(require("lodash/set"));
13
-
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;
@@ -78,9 +67,7 @@ const initializeContentReviewSteps = ({
78
67
  * TODO Figure our what does this actually do?
79
68
  * There is no steps property on CreateApwContentReviewParams
80
69
  */
81
-
82
70
  input = (0, _set.default)(input, "steps", updatedSteps);
83
71
  });
84
72
  };
85
-
86
73
  exports.initializeContentReviewSteps = initializeContentReviewSteps;
@@ -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 */\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AAEO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,GAAF;EAAOC;AAAP,CAAD,KAAkC;EAC1ED,GAAG,CAACE,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC,IAAF;MAAQC,EAAR;MAAYC;IAAZ,IAAyBH,KAAK,CAACI,OAArC;IACA;AACR;AACA;;IACQ,MAAMC,UAAU,GAAGV,GAAG,CAACW,gBAAJ,CAAqBL,IAArB,CAAnB;IACA,MAAMG,OAAO,GAAG,MAAMC,UAAU,CAACH,EAAD,EAAKC,QAAL,CAAhC;;IACA,IAAI,CAACC,OAAL,EAAc;MACV,MAAM,IAAIG,6BAAJ,CAAmB,YAAWN,IAAK,aAAYC,EAAG,aAAlD,CAAN;IACH;;IAED,MAAM;MAAEM;IAAF,IAAYJ,OAAlB;IACAJ,KAAK,GAAG,IAAAS,YAAA,EAAUT,KAAV,EAAiB,OAAjB,EAA0BQ,KAA1B,CAAR;IAEA;AACR;AACA;;IACQ,MAAME,wBAAwB,GAAG,IAAAC,qDAAA,EAA4B;MACzDf,OADyD;MAEzDK;IAFyD,CAA5B,CAAjC;IAKA,MAAMW,UAAU,GAAGF,wBAAwB,CAACG,aAAzB,CAAuCT,OAAvC,CAAnB;IAEA;AACR;AACA;;IACQ,IAAI,CAACQ,UAAL,EAAiB;MACb,MAAM,IAAIL,6BAAJ,CAAmB,2DAAnB,CAAN;IACH;;IAEDP,KAAK,CAACY,UAAN,GAAmBA,UAAnB;IAEA,MAAME,QAAQ,GAAG,MAAMnB,GAAG,CAACmB,QAAJ,CAAaC,GAAb,CAAiBH,UAAjB,CAAvB;IACA,MAAMI,aAAa,GAAGF,QAAQ,CAACG,KAA/B;IAEA,IAAIC,kBAA0D,GAAGC,SAAjE;IACA,MAAMC,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":["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 */\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,GAAG;EAAEC;AAAoB,CAAC,KAAK;EAC1ED,GAAG,CAACE,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACzE,MAAM;MAAEC,IAAI;MAAEC,EAAE;MAAEC;IAAS,CAAC,GAAGH,KAAK,CAACI,OAAO;IAC5C;AACR;AACA;IACQ,MAAMC,UAAU,GAAGV,GAAG,CAACW,gBAAgB,CAACL,IAAI,CAAC;IAC7C,MAAMG,OAAO,GAAG,MAAMC,UAAU,CAACH,EAAE,EAAEC,QAAQ,CAAC;IAC9C,IAAI,CAACC,OAAO,EAAE;MACV,MAAM,IAAIG,6BAAa,CAAE,YAAWN,IAAK,aAAYC,EAAG,aAAY,CAAC;IACzE;IAEA,MAAM;MAAEM;IAAM,CAAC,GAAGJ,OAAO;IACzBJ,KAAK,GAAG,IAAAS,YAAS,EAACT,KAAK,EAAE,OAAO,EAAEQ,KAAK,CAAC;;IAExC;AACR;AACA;IACQ,MAAME,wBAAwB,GAAG,IAAAC,qDAA2B,EAAC;MACzDf,OAAO;MACPK;IACJ,CAAC,CAAC;IAEF,MAAMW,UAAU,GAAGF,wBAAwB,CAACG,aAAa,CAACT,OAAO,CAAC;;IAElE;AACR;AACA;IACQ,IAAI,CAACQ,UAAU,EAAE;MACb,MAAM,IAAIL,6BAAa,CAAE,2DAA0D,CAAC;IACxF;IAEAP,KAAK,CAACY,UAAU,GAAGA,UAAU;IAE7B,MAAME,QAAQ,GAAG,MAAMnB,GAAG,CAACmB,QAAQ,CAACC,GAAG,CAACH,UAAU,CAAC;IACnD,MAAMI,aAAa,GAAGF,QAAQ,CAACG,KAAK;IAEpC,IAAIC,kBAA0D,GAAGC,SAAS;IAC1E,MAAMC,YAAY,GAAGN,QAAQ,CAACG,KAAK,CAACI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MACrD,MAAMC,MAAM,GAAG,IAAAC,wCAAiC,EAC5CT,aAAa,EACbO,KAAK,EACLL,kBAAkB,CACrB;MACDA,kBAAkB,GAAGM,MAAM;MAC3B,mEACOF,IAAI;QACPE,MAAM;QACNE,qBAAqB,EAAE,CAAC;QACxBC,aAAa,EAAE;MAAC;IAExB,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQ3B,KAAK,GAAG,IAAAS,YAAS,EAACT,KAAK,EAAE,OAAO,EAAEoB,YAAY,CAAC;EACnD,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApwContext } from "../../types";
2
+ export declare const initializeNotifications: (context: ApwContext) => void;
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["initializeNotifications","context","attachContentReviewAfterCreate","attachCommentAfterCreate","attachChangeRequestAfterCreate"],"sources":["initializeNotifications.ts"],"sourcesContent":["import { 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;AACA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,OAAmB,IAAK;EAC5D,IAAAC,wDAA8B,EAACD,OAAO,CAAC;EACvC,IAAAE,4CAAwB,EAACF,OAAO,CAAC;EACjC,IAAAG,wDAA8B,EAACH,OAAO,CAAC;AAC3C,CAAC;AAAC"}
@@ -6,5 +6,5 @@ interface ListWorkflowsParams {
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 !== null && identity !== void 0 && 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,7 @@ 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
  };
79
-
80
56
  exports.listContentReviews = listContentReviews;
@@ -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,GAAP;EAAYC;AAAZ,CAAD,KAAiD;EAC/E;AACJ;AACA;AACA;EACID,GAAG,CAACE,iBAAJ,CAAsBC,SAAtB,CAAgC,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IACxD,MAAMC,QAAQ,GAAGL,QAAQ,CAACM,WAAT,EAAjB;;IACA,IAAI,EAACD,QAAD,aAACA,QAAD,eAACA,QAAQ,CAAEE,EAAX,KAAiBJ,KAAK,CAACK,OAAN,KAAkBC,sCAAvC,EAAgE;MAC5D;IACH;IACD;AACR;AACA;;;IACQ,MAAM,CAACC,SAAD,IAAc,MAAMZ,GAAG,CAACa,QAAJ,CAAaC,IAAb,EAA1B;;IACA,IAAIF,SAAS,CAACG,MAAV,KAAqB,CAAzB,EAA4B;MACxB;IACH;IACD;AACR;AACA;;;IACQ,MAAM,CAACC,SAAD,IAAc,MAAMhB,GAAG,CAACiB,QAAJ,CAAaH,IAAb,CAAkB;MACxCR,KAAK,EAAE;QACHY,UAAU,EAAEX,QAAQ,CAACE;MADlB;IADiC,CAAlB,CAA1B;;IAKA,IAAIO,SAAS,CAACD,MAAV,KAAqB,CAAzB,EAA4B;MACxB;IACH;;IACD,MAAMI,YAAY,GAAGH,SAAS,CAACI,GAAV,CAAcH,QAAQ,IAAIA,QAAQ,CAACI,OAAnC,CAArB;IACA;AACR;AACA;AACA;;IACQ,MAAMC,aAAa,GAAGV,SAAS,CAACW,MAAV,CAAiBV,QAAQ,IAAI;MAC/C,OAAOA,QAAQ,CAACW,KAAT,CAAeC,IAAf,CAAoBC,IAAI,IAAI;QAC/B,OAAOA,IAAI,CAACV,SAAL,CAAeS,IAAf,CAAoBR,QAAQ,IAAI;UACnC,OAAOE,YAAY,CAACQ,QAAb,CAAsBV,QAAQ,CAACI,OAA/B,CAAP;QACH,CAFM,CAAP;MAGH,CAJM,CAAP;IAKH,CANqB,CAAtB;;IAOA,IAAIC,aAAa,CAACP,MAAd,KAAyB,CAA7B,EAAgC;MAC5B;IACH;IACD;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"],"sources":["listContentReviews.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { 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,GAAG,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,EAAE;IACvC,IAAI,EAACD,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEE,EAAE,GAAE;MACf;IACJ;IACA;AACR;AACA;IACQ,MAAM,CAACC,SAAS,CAAC,GAAG,MAAMV,GAAG,CAACW,QAAQ,CAACC,IAAI,EAAE;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;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApwContext } from "../../../types";
2
+ export declare const getAppUrl: (context: ApwContext) => Promise<import("@webiny/api-admin-settings/types").AdminSettings | null>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAppUrl = void 0;
7
+ const getAppUrl = async context => {
8
+ const tenant = context.tenancy.getCurrentTenant().id;
9
+ try {
10
+ return await context.settings.getSettings(tenant);
11
+ } catch (ex) {
12
+ if (ex.code !== "NOT_FOUND") {
13
+ throw ex;
14
+ }
15
+ }
16
+ return null;
17
+ };
18
+ exports.getAppUrl = getAppUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getAppUrl","context","tenant","tenancy","getCurrentTenant","id","settings","getSettings","ex","code"],"sources":["appUrl.ts"],"sourcesContent":["import { ApwContext } from \"~/types\";\n\nexport const getAppUrl = async (context: ApwContext) => {\n const tenant = context.tenancy.getCurrentTenant().id;\n try {\n return await context.settings.getSettings(tenant);\n } catch (ex) {\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n return null;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,SAAS,GAAG,MAAOC,OAAmB,IAAK;EACpD,MAAMC,MAAM,GAAGD,OAAO,CAACE,OAAO,CAACC,gBAAgB,EAAE,CAACC,EAAE;EACpD,IAAI;IACA,OAAO,MAAMJ,OAAO,CAACK,QAAQ,CAACC,WAAW,CAACL,MAAM,CAAC;EACrD,CAAC,CAAC,OAAOM,EAAE,EAAE;IACT,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;MACzB,MAAMD,EAAE;IACZ;EACJ;EACA,OAAO,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,2 @@
1
+ import { ApwContext } from "../../../types";
2
+ export declare const attachChangeRequestAfterCreate: (context: ApwContext) => void;