@webiny/api-apw 0.0.0-unstable.5e7233243f → 0.0.0-unstable.6e5425ee89

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 (240) 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 +71 -125
  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 +3 -3
  31. package/index.js +7 -13
  32. package/index.js.map +1 -1
  33. package/package.json +38 -37
  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 +4 -21
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +7 -36
  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 +3 -17
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +10 -32
  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.js +1 -32
  63. package/plugins/context.js.map +1 -1
  64. package/plugins/graphql/changeRequest.gql.js +2 -9
  65. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  66. package/plugins/graphql/comment.gql.js +2 -9
  67. package/plugins/graphql/comment.gql.js.map +1 -1
  68. package/plugins/graphql/contentReview.gql.js +5 -24
  69. package/plugins/graphql/contentReview.gql.js.map +1 -1
  70. package/plugins/graphql/reviewer.gql.js +4 -9
  71. package/plugins/graphql/reviewer.gql.js.map +1 -1
  72. package/plugins/graphql/workflow.gql.js +2 -9
  73. package/plugins/graphql/workflow.gql.js.map +1 -1
  74. package/plugins/graphql.js +2 -17
  75. package/plugins/graphql.js.map +1 -1
  76. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  77. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  78. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  80. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  82. package/plugins/hooks/index.js +4 -12
  83. package/plugins/hooks/index.js.map +1 -1
  84. package/plugins/hooks/initializeContentReviewSteps.js +7 -23
  85. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  86. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  87. package/plugins/hooks/initializeNotifications.js +15 -0
  88. package/plugins/hooks/initializeNotifications.js.map +1 -0
  89. package/plugins/hooks/listContentReviews.d.ts +10 -0
  90. package/plugins/hooks/listContentReviews.js +56 -0
  91. package/plugins/hooks/listContentReviews.js.map +1 -0
  92. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  93. package/plugins/hooks/notifications/appUrl.js +18 -0
  94. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  95. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  98. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  101. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  104. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  105. package/plugins/hooks/notifications/commentUrl.js +27 -0
  106. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  107. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  110. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  113. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  114. package/plugins/hooks/notifications/contentUrl.js +24 -0
  115. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  116. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  119. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  122. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  125. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  126. package/plugins/hooks/notifications/reviewers.js +44 -0
  127. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  128. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  131. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  134. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  137. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  138. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  139. package/plugins/hooks/updateTotalComments.js +14 -27
  140. package/plugins/hooks/updateTotalComments.js.map +1 -1
  141. package/plugins/hooks/validateChangeRequest.js +27 -18
  142. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  143. package/plugins/hooks/validateComment.js +13 -14
  144. package/plugins/hooks/validateComment.js.map +1 -1
  145. package/plugins/hooks/validateContentReview.js +2 -8
  146. package/plugins/hooks/validateContentReview.js.map +1 -1
  147. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  149. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  150. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  151. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  153. package/plugins/pageBuilder/index.js +5 -8
  154. package/plugins/pageBuilder/index.js.map +1 -1
  155. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  156. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  157. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  158. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  159. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  162. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  165. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  168. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  171. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  172. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  173. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  174. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  175. package/plugins/pageBuilder/utils.js +2 -36
  176. package/plugins/pageBuilder/utils.js.map +1 -1
  177. package/plugins/utils.d.ts +1 -1
  178. package/plugins/utils.js +4 -57
  179. package/plugins/utils.js.map +1 -1
  180. package/scheduler/createScheduleActionMethods.js +17 -33
  181. package/scheduler/createScheduleActionMethods.js.map +1 -1
  182. package/scheduler/handlers/executeAction/index.js +9 -33
  183. package/scheduler/handlers/executeAction/index.js.map +1 -1
  184. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -6
  185. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -22
  187. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  188. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +5 -28
  189. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  190. package/scheduler/handlers/executeAction/security.js +0 -11
  191. package/scheduler/handlers/executeAction/security.js.map +1 -1
  192. package/scheduler/handlers/scheduleAction/index.js +13 -34
  193. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  194. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +7 -32
  195. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  196. package/scheduler/handlers/utils.js +4 -41
  197. package/scheduler/handlers/utils.js.map +1 -1
  198. package/scheduler/index.js +0 -3
  199. package/scheduler/index.js.map +1 -1
  200. package/scheduler/types.js +0 -6
  201. package/scheduler/types.js.map +1 -1
  202. package/storageOperations/changeRequestStorageOperations.js +5 -28
  203. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  204. package/storageOperations/commentStorageOperations.js +4 -29
  205. package/storageOperations/commentStorageOperations.js.map +1 -1
  206. package/storageOperations/contentReviewStorageOperations.js +5 -26
  207. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  208. package/storageOperations/index.js +5 -23
  209. package/storageOperations/index.js.map +1 -1
  210. package/storageOperations/models/changeRequest.model.js +0 -9
  211. package/storageOperations/models/changeRequest.model.js.map +1 -1
  212. package/storageOperations/models/comment.model.js +0 -8
  213. package/storageOperations/models/comment.model.js.map +1 -1
  214. package/storageOperations/models/contentModelPluginFactory.js +3 -12
  215. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  216. package/storageOperations/models/contentReview.model.js +6 -31
  217. package/storageOperations/models/contentReview.model.js.map +1 -1
  218. package/storageOperations/models/index.js +3 -25
  219. package/storageOperations/models/index.js.map +1 -1
  220. package/storageOperations/models/reviewer.model.js +17 -9
  221. package/storageOperations/models/reviewer.model.js.map +1 -1
  222. package/storageOperations/models/utils.js +3 -6
  223. package/storageOperations/models/utils.js.map +1 -1
  224. package/storageOperations/models/workflow.model.js +0 -23
  225. package/storageOperations/models/workflow.model.js.map +1 -1
  226. package/storageOperations/reviewerStorageOperations.js +16 -29
  227. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  228. package/storageOperations/workflowStorageOperations.js +6 -31
  229. package/storageOperations/workflowStorageOperations.js.map +1 -1
  230. package/types.d.ts +99 -84
  231. package/types.js +0 -14
  232. package/types.js.map +1 -1
  233. package/utils/contentApwSettingsPlugin.js +0 -6
  234. package/utils/contentApwSettingsPlugin.js.map +1 -1
  235. package/utils/errors.js +1 -18
  236. package/utils/errors.js.map +1 -1
  237. package/utils/fieldResolver.js +5 -21
  238. package/utils/fieldResolver.js.map +1 -1
  239. package/utils/resolve.js +0 -3
  240. package/utils/resolve.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["validateComment","apw","comment","onBeforeCommentCreate","subscribe","input","changeRequest","changeRequestId","entryId","version","split","WebinyError","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onBeforeCommentCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n const [entryId, version] = changeRequestId.split(\"#\");\n if (!entryId || !version) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAClFA,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,CAAkCC,SAAlC,CAA4C,OAAO;IAAEC;EAAF,CAAP,KAAqB;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAjB,IAAqCF,KAA3C;IACA;AACR;AACA;;IACQ,MAAM,CAACG,OAAD,EAAUC,OAAV,IAAqBF,eAAe,CAACG,KAAhB,CAAsB,GAAtB,CAA3B;;IACA,IAAI,CAACF,OAAD,IAAY,CAACC,OAAjB,EAA0B;MACtB,MAAM,IAAIE,cAAJ,CACD,iEADC,EAEF,6BAFE,EAGF;QACIN;MADJ,CAHE,CAAN;IAOH;IAED;AACR;AACA;;;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAJ,CAAkBM,GAAlB,CAAsBL,eAAtB,CAA5B;;IACA,IAAI,CAACD,aAAL,EAAoB;MAChB;IACH;;IACDD,KAAK,CAACQ,IAAN,GAAaP,aAAa,CAACO,IAA3B;EACH,CAxBD;AAyBH,CA1BM"}
1
+ {"version":3,"names":["validateComment","apw","comment","onCommentBeforeCreate","subscribe","input","changeRequest","changeRequestId","result","parseIdentifier","WebinyError","ex","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\nimport { parseIdentifier, ParseIdentifierResult } from \"@webiny/utils\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentBeforeCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n let result: ParseIdentifierResult;\n try {\n result = parseIdentifier(changeRequestId);\n if (!result) {\n throw new WebinyError(\n \"Could not parse changeRequestId.\",\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n changeRequestId\n }\n );\n }\n } catch (ex) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EAClFA,GAAG,CAACC,OAAO,CAACC,qBAAqB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAgB,CAAC,GAAGF,KAAK;IAChD;AACR;AACA;IACQ,IAAIG,MAA6B;IACjC,IAAI;MACAA,MAAM,GAAG,IAAAC,sBAAe,EAACF,eAAe,CAAC;MACzC,IAAI,CAACC,MAAM,EAAE;QACT,MAAM,IAAIE,cAAW,CACjB,kCAAkC,EAClC,6BAA6B,EAC7B;UACIH;QACJ,CAAC,CACJ;MACL;IACJ,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAID,cAAW,CAChB,iEAAgE,EACjE,6BAA6B,EAC7B;QACIL;MACJ,CAAC,CACJ;IACL;;IAEA;AACR;AACA;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAa,CAACM,GAAG,CAACL,eAAe,CAAC;IAClE,IAAI,CAACD,aAAa,EAAE;MAChB;IACJ;IACAD,KAAK,CAACQ,IAAI,GAAGP,aAAa,CAACO,IAAI;EACnC,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,18 +1,15 @@
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.validateContentReview = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  const validateContentReview = ({
13
10
  apw
14
11
  }) => {
15
- apw.contentReview.onBeforeContentReviewCreate.subscribe(async ({
12
+ apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({
16
13
  input
17
14
  }) => {
18
15
  const {
@@ -21,11 +18,9 @@ const validateContentReview = ({
21
18
  /**
22
19
  * Check whether a contentReview already exists for provided content.
23
20
  */
24
-
25
21
  const {
26
22
  contentReviewId
27
23
  } = await apw.contentReview.isReviewRequired(content);
28
-
29
24
  if (contentReviewId) {
30
25
  throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
31
26
  contentReviewId,
@@ -34,5 +29,4 @@ const validateContentReview = ({
34
29
  }
35
30
  });
36
31
  };
37
-
38
32
  exports.validateContentReview = validateContentReview;
@@ -1 +1 @@
1
- {"version":3,"names":["validateContentReview","apw","contentReview","onBeforeContentReviewCreate","subscribe","input","content","contentReviewId","isReviewRequired","WebinyError"],"sources":["validateContentReview.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateContentReview = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onBeforeContentReviewCreate.subscribe(async ({ input }) => {\n const { content } = input;\n /**\n * Check whether a contentReview already exists for provided content.\n */\n const { contentReviewId } = await apw.contentReview.isReviewRequired(content);\n if (contentReviewId) {\n throw new WebinyError(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n content\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAcD,KAApB;IACA;AACR;AACA;;IACQ,MAAM;MAAEE;IAAF,IAAsB,MAAMN,GAAG,CAACC,aAAJ,CAAkBM,gBAAlB,CAAmCF,OAAnC,CAAlC;;IACA,IAAIC,eAAJ,EAAqB;MACjB,MAAM,IAAIE,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;QACIF,eADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CAhBD;AAiBH,CAlBM"}
1
+ {"version":3,"names":["validateContentReview","apw","contentReview","onContentReviewBeforeCreate","subscribe","input","content","contentReviewId","isReviewRequired","WebinyError"],"sources":["validateContentReview.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateContentReview = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { content } = input;\n /**\n * Check whether a contentReview already exists for provided content.\n */\n const { contentReviewId } = await apw.contentReview.isReviewRequired(content);\n if (contentReviewId) {\n throw new WebinyError(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n content\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EACxFA,GAAG,CAACC,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACzE,MAAM;MAAEC;IAAQ,CAAC,GAAGD,KAAK;IACzB;AACR;AACA;IACQ,MAAM;MAAEE;IAAgB,CAAC,GAAG,MAAMN,GAAG,CAACC,aAAa,CAACM,gBAAgB,CAACF,OAAO,CAAC;IAC7E,IAAIC,eAAe,EAAE;MACjB,MAAM,IAAIE,cAAW,CAChB,4DAA2D,EAC5D,sBAAsB,EACtB;QACIF,eAAe;QACfD;MACJ,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,51 +1,36 @@
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.PageApwSettingsGetterPlugin = void 0;
9
-
10
8
  var _ContentApwSettingsPlugin = require("../../ContentApwSettingsPlugin");
11
-
12
9
  var _types = require("../../types");
13
-
14
10
  var _set = _interopRequireDefault(require("lodash/set"));
15
-
16
11
  class PageApwSettingsGetterPlugin extends _ContentApwSettingsPlugin.ContentApwSettingsPlugin {
17
12
  canUse(type) {
18
13
  return type === _types.ApwContentTypes.PAGE;
19
14
  }
20
-
21
15
  setWorkflowId(page, id) {
22
16
  page.settings = (0, _set.default)(page.settings || {}, "apw.workflowId", id);
23
17
  }
24
-
25
18
  getWorkflowId(page) {
26
19
  var _page$settings$apw;
27
-
28
20
  if (!page.settings) {
29
21
  return null;
30
22
  }
31
-
32
23
  return ((_page$settings$apw = page.settings.apw) === null || _page$settings$apw === void 0 ? void 0 : _page$settings$apw.workflowId) || null;
33
24
  }
34
-
35
25
  setContentReviewId(page, id) {
36
26
  page.settings = (0, _set.default)(page.settings || {}, "apw.contentReviewId", id);
37
27
  }
38
-
39
28
  getContentReviewId(page) {
40
29
  var _page$settings$apw2;
41
-
42
30
  if (!page.settings) {
43
31
  return null;
44
32
  }
45
-
46
33
  return (_page$settings$apw2 = page.settings.apw) === null || _page$settings$apw2 === void 0 ? void 0 : _page$settings$apw2.contentReviewId;
47
34
  }
48
-
49
35
  }
50
-
51
36
  exports.PageApwSettingsGetterPlugin = PageApwSettingsGetterPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["PageApwSettingsGetterPlugin","ContentApwSettingsPlugin","canUse","type","ApwContentTypes","PAGE","setWorkflowId","page","id","settings","set","getWorkflowId","apw","workflowId","setContentReviewId","getContentReviewId","contentReviewId"],"sources":["PageApwSettingsGetterPlugin.ts"],"sourcesContent":["import { ContentApwSettingsPlugin } from \"~/ContentApwSettingsPlugin\";\nimport { ApwContentTypes, PageWithWorkflow } from \"~/types\";\nimport set from \"lodash/set\";\n\nexport class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {\n public override canUse(type: ApwContentTypes): boolean {\n return type === ApwContentTypes.PAGE;\n }\n\n public override setWorkflowId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.workflowId\", id);\n }\n\n public override getWorkflowId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.workflowId || null;\n }\n\n public override setContentReviewId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.contentReviewId\", id);\n }\n\n public override getContentReviewId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.contentReviewId;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,2BAAN,SAA0CC,kDAA1C,CAAmE;EACtDC,MAAM,CAACC,IAAD,EAAiC;IACnD,OAAOA,IAAI,KAAKC,sBAAA,CAAgBC,IAAhC;EACH;;EAEeC,aAAa,CAACC,IAAD,EAAyBC,EAAzB,EAA4C;IACrED,IAAI,CAACE,QAAL,GAAgB,IAAAC,YAAA,EAAIH,IAAI,CAACE,QAAL,IAAiB,EAArB,EAAyB,gBAAzB,EAA2CD,EAA3C,CAAhB;EACH;;EAEeG,aAAa,CAACJ,IAAD,EAAwC;IAAA;;IACjE,IAAI,CAACA,IAAI,CAACE,QAAV,EAAoB;MAChB,OAAO,IAAP;IACH;;IACD,OAAO,uBAAAF,IAAI,CAACE,QAAL,CAAcG,GAAd,0EAAmBC,UAAnB,KAAiC,IAAxC;EACH;;EAEeC,kBAAkB,CAACP,IAAD,EAAyBC,EAAzB,EAA4C;IAC1ED,IAAI,CAACE,QAAL,GAAgB,IAAAC,YAAA,EAAIH,IAAI,CAACE,QAAL,IAAiB,EAArB,EAAyB,qBAAzB,EAAgDD,EAAhD,CAAhB;EACH;;EAEeO,kBAAkB,CAACR,IAAD,EAAwC;IAAA;;IACtE,IAAI,CAACA,IAAI,CAACE,QAAV,EAAoB;MAChB,OAAO,IAAP;IACH;;IACD,8BAAOF,IAAI,CAACE,QAAL,CAAcG,GAArB,wDAAO,oBAAmBI,eAA1B;EACH;;AAzBqE"}
1
+ {"version":3,"names":["PageApwSettingsGetterPlugin","ContentApwSettingsPlugin","canUse","type","ApwContentTypes","PAGE","setWorkflowId","page","id","settings","set","getWorkflowId","apw","workflowId","setContentReviewId","getContentReviewId","contentReviewId"],"sources":["PageApwSettingsGetterPlugin.ts"],"sourcesContent":["import { ContentApwSettingsPlugin } from \"~/ContentApwSettingsPlugin\";\nimport { ApwContentTypes, PageWithWorkflow } from \"~/types\";\nimport set from \"lodash/set\";\n\nexport class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {\n public override canUse(type: ApwContentTypes): boolean {\n return type === ApwContentTypes.PAGE;\n }\n\n public override setWorkflowId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.workflowId\", id);\n }\n\n public override getWorkflowId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.workflowId || null;\n }\n\n public override setContentReviewId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.contentReviewId\", id);\n }\n\n public override getContentReviewId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.contentReviewId;\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEO,MAAMA,2BAA2B,SAASC,kDAAwB,CAAC;EACtDC,MAAM,CAACC,IAAqB,EAAW;IACnD,OAAOA,IAAI,KAAKC,sBAAe,CAACC,IAAI;EACxC;EAEgBC,aAAa,CAACC,IAAsB,EAAEC,EAAiB,EAAE;IACrED,IAAI,CAACE,QAAQ,GAAG,IAAAC,YAAG,EAACH,IAAI,CAACE,QAAQ,IAAI,CAAC,CAAC,EAAE,gBAAgB,EAAED,EAAE,CAAC;EAClE;EAEgBG,aAAa,CAACJ,IAAsB,EAAiB;IAAA;IACjE,IAAI,CAACA,IAAI,CAACE,QAAQ,EAAE;MAChB,OAAO,IAAI;IACf;IACA,OAAO,uBAAAF,IAAI,CAACE,QAAQ,CAACG,GAAG,uDAAjB,mBAAmBC,UAAU,KAAI,IAAI;EAChD;EAEgBC,kBAAkB,CAACP,IAAsB,EAAEC,EAAiB,EAAE;IAC1ED,IAAI,CAACE,QAAQ,GAAG,IAAAC,YAAG,EAACH,IAAI,CAACE,QAAQ,IAAI,CAAC,CAAC,EAAE,qBAAqB,EAAED,EAAE,CAAC;EACvE;EAEgBO,kBAAkB,CAACR,IAAsB,EAAiB;IAAA;IACtE,IAAI,CAACA,IAAI,CAACE,QAAQ,EAAE;MAChB,OAAO,IAAI;IACf;IACA,8BAAOF,IAAI,CAACE,QAAQ,CAACG,GAAG,wDAAjB,oBAAmBI,eAAe;EAC7C;AACJ;AAAC"}
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.apwContentPagePlugins = void 0;
7
-
8
7
  var _api = require("@webiny/api");
9
-
10
8
  var _types = require("../../types");
11
-
12
9
  const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
13
10
  const {
14
11
  apw,
@@ -26,5 +23,4 @@ const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
26
23
  return true;
27
24
  });
28
25
  });
29
-
30
26
  exports.apwContentPagePlugins = apwContentPagePlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MACjC,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,OAA7B;EAEAC,GAAG,CAACE,gBAAJ,CAAqBC,sBAAA,CAAgBC,IAArC,EAA2C,MAAMC,EAAN,IAAY;IACnD,OAAOJ,WAAW,CAACK,OAAZ,CAAsCD,EAAtC,CAAP;EACH,CAFD;EAIAL,GAAG,CAACO,mBAAJ,CAAwBJ,sBAAA,CAAgBC,IAAxC,EAA8C,MAAMC,EAAN,IAAY;IACtD,MAAMJ,WAAW,CAACO,WAAZ,CAA0CH,EAA1C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;EAKAL,GAAG,CAACS,qBAAJ,CAA0BN,sBAAA,CAAgBC,IAA1C,EAAgD,MAAMC,EAAN,IAAY;IACxD,MAAMJ,WAAW,CAACS,aAAZ,CAA4CL,EAA5C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;AAIH,CAhBD,CADG"}
1
+ {"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":";;;;;;AAAA;AACA;AAEO,MAAMA,qBAAqB,GAAG,MACjC,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,GAAG;IAAEC;EAAY,CAAC,GAAGF,OAAO;EAEpCC,GAAG,CAACE,gBAAgB,CAACC,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACnD,OAAOJ,WAAW,CAACK,OAAO,CAAmBD,EAAE,CAAC;EACpD,CAAC,CAAC;EAEFL,GAAG,CAACO,mBAAmB,CAACJ,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACtD,MAAMJ,WAAW,CAACO,WAAW,CAAmBH,EAAE,CAAC;IACnD,OAAO,IAAI;EACf,CAAC,CAAC;EAEFL,GAAG,CAACS,qBAAqB,CAACN,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACxD,MAAMJ,WAAW,CAACS,aAAa,CAAmBL,EAAE,CAAC;IACrD,OAAO,IAAI;EACf,CAAC,CAAC;AACN,CAAC,CAAC;AAAC"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.extendPbPageSettingsSchema = void 0;
7
-
8
7
  var _plugins = require("@webiny/handler-graphql/plugins");
9
-
10
8
  const extendPbPageSettingsSchema = () => new _plugins.GraphQLSchemaPlugin({
11
- typeDefs:
12
- /* GraphQL */
13
- `
9
+ typeDefs: /* GraphQL */`
14
10
  type PbApwPageSettings {
15
11
  workflowId: ID
16
12
  contentReviewId: ID
@@ -21,5 +17,4 @@ const extendPbPageSettingsSchema = () => new _plugins.GraphQLSchemaPlugin({
21
17
  }
22
18
  `
23
19
  });
24
-
25
20
  exports.extendPbPageSettingsSchema = extendPbPageSettingsSchema;
@@ -1 +1 @@
1
- {"version":3,"names":["extendPbPageSettingsSchema","GraphQLSchemaPlugin","typeDefs"],"sources":["extendPbPageSettingsSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ApwContext } from \"~/types\";\n\nexport const extendPbPageSettingsSchema = () =>\n new GraphQLSchemaPlugin<ApwContext>({\n typeDefs: /* GraphQL */ `\n type PbApwPageSettings {\n workflowId: ID\n contentReviewId: ID\n }\n\n extend type PbPageSettings {\n apw: PbApwPageSettings\n }\n `\n });\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,0BAA0B,GAAG,MACtC,IAAIC,4BAAJ,CAAoC;EAChCC,QAAQ;EAAE;EAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVwC,CAApC,CADG"}
1
+ {"version":3,"names":["extendPbPageSettingsSchema","GraphQLSchemaPlugin","typeDefs"],"sources":["extendPbPageSettingsSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ApwContext } from \"~/types\";\n\nexport const extendPbPageSettingsSchema = () =>\n new GraphQLSchemaPlugin<ApwContext>({\n typeDefs: /* GraphQL */ `\n type PbApwPageSettings {\n workflowId: ID\n contentReviewId: ID\n }\n\n extend type PbPageSettings {\n apw: PbApwPageSettings\n }\n `\n });\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,0BAA0B,GAAG,MACtC,IAAIC,4BAAmB,CAAa;EAChCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,CAAC,CAAC;AAAC"}
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.apwPageBuilderHooks = void 0;
7
-
8
7
  var _triggerContentReview = require("./triggerContentReview");
9
-
10
8
  var _linkContentReviewToPage = require("./linkContentReviewToPage");
11
-
12
9
  var _updateContentReviewStatus = require("./updateContentReviewStatus");
13
-
14
10
  var _linkWorkflowToPage = require("./linkWorkflowToPage");
15
-
16
11
  var _PageApwSettingsGetterPlugin = require("./PageApwSettingsGetterPlugin");
17
-
12
+ var _commentNotification = require("./notifications/commentNotification");
13
+ var _contentUrl = require("./notifications/contentUrl");
14
+ var _changeRequestNotification = require("./notifications/changeRequestNotification");
15
+ var _contentReviewNotification = require("./notifications/contentReviewNotification");
18
16
  const apwPageBuilderHooks = params => {
19
17
  const {
20
18
  pageBuilder,
@@ -22,7 +20,7 @@ const apwPageBuilderHooks = params => {
22
20
  security,
23
21
  plugins
24
22
  } = params;
25
- plugins.register(new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin());
23
+ plugins.register([new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin(), (0, _commentNotification.createCommentNotification)(), (0, _changeRequestNotification.createChangeRequestNotification)(), (0, _contentUrl.createContentUrlPlugin)(), (0, _contentReviewNotification.createContentReviewNotification)()]);
26
24
  (0, _triggerContentReview.triggerContentReview)({
27
25
  apw,
28
26
  pageBuilder
@@ -41,5 +39,4 @@ const apwPageBuilderHooks = params => {
41
39
  pageBuilder
42
40
  });
43
41
  };
44
-
45
42
  exports.apwPageBuilderHooks = apwPageBuilderHooks;
@@ -1 +1 @@
1
- {"version":3,"names":["apwPageBuilderHooks","params","pageBuilder","apw","security","plugins","register","PageApwSettingsGetterPlugin","triggerContentReview","linkContentReviewToPage","updateContentReviewStatus","linkWorkflowToPage"],"sources":["index.ts"],"sourcesContent":["import { Security } from \"@webiny/api-security/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { linkContentReviewToPage } from \"./linkContentReviewToPage\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { linkWorkflowToPage } from \"./linkWorkflowToPage\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageApwSettingsGetterPlugin } from \"~/plugins/pageBuilder/PageApwSettingsGetterPlugin\";\n\nexport interface ApwPageBuilderPluginsParams {\n pageBuilder: PageBuilderContextObject;\n apw: AdvancedPublishingWorkflow;\n security: Security;\n plugins: PluginsContainer;\n}\n\nexport const apwPageBuilderHooks = (params: ApwPageBuilderPluginsParams) => {\n const { pageBuilder, apw, security, plugins } = params;\n\n plugins.register(new PageApwSettingsGetterPlugin());\n\n triggerContentReview({\n apw,\n pageBuilder\n });\n linkContentReviewToPage({\n apw,\n pageBuilder\n });\n updateContentReviewStatus({\n apw,\n pageBuilder,\n security\n });\n linkWorkflowToPage({\n apw,\n pageBuilder\n });\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAEA;;AASO,MAAMA,mBAAmB,GAAIC,MAAD,IAAyC;EACxE,MAAM;IAAEC,WAAF;IAAeC,GAAf;IAAoBC,QAApB;IAA8BC;EAA9B,IAA0CJ,MAAhD;EAEAI,OAAO,CAACC,QAAR,CAAiB,IAAIC,wDAAJ,EAAjB;EAEA,IAAAC,0CAAA,EAAqB;IACjBL,GADiB;IAEjBD;EAFiB,CAArB;EAIA,IAAAO,gDAAA,EAAwB;IACpBN,GADoB;IAEpBD;EAFoB,CAAxB;EAIA,IAAAQ,oDAAA,EAA0B;IACtBP,GADsB;IAEtBD,WAFsB;IAGtBE;EAHsB,CAA1B;EAKA,IAAAO,sCAAA,EAAmB;IACfR,GADe;IAEfD;EAFe,CAAnB;AAIH,CAtBM"}
1
+ {"version":3,"names":["apwPageBuilderHooks","params","pageBuilder","apw","security","plugins","register","PageApwSettingsGetterPlugin","createCommentNotification","createChangeRequestNotification","createContentUrlPlugin","createContentReviewNotification","triggerContentReview","linkContentReviewToPage","updateContentReviewStatus","linkWorkflowToPage"],"sources":["index.ts"],"sourcesContent":["import { Security } from \"@webiny/api-security/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { linkContentReviewToPage } from \"./linkContentReviewToPage\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { linkWorkflowToPage } from \"./linkWorkflowToPage\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageApwSettingsGetterPlugin } from \"~/plugins/pageBuilder/PageApwSettingsGetterPlugin\";\nimport { createCommentNotification } from \"./notifications/commentNotification\";\nimport { createContentUrlPlugin } from \"./notifications/contentUrl\";\nimport { createChangeRequestNotification } from \"./notifications/changeRequestNotification\";\nimport { createContentReviewNotification } from \"./notifications/contentReviewNotification\";\n\nexport interface ApwPageBuilderPluginsParams {\n pageBuilder: PageBuilderContextObject;\n apw: AdvancedPublishingWorkflow;\n security: Security;\n plugins: PluginsContainer;\n}\n\nexport const apwPageBuilderHooks = (params: ApwPageBuilderPluginsParams) => {\n const { pageBuilder, apw, security, plugins } = params;\n\n plugins.register([\n new PageApwSettingsGetterPlugin(),\n createCommentNotification(),\n createChangeRequestNotification(),\n createContentUrlPlugin(),\n createContentReviewNotification()\n ]);\n\n triggerContentReview({\n apw,\n pageBuilder\n });\n linkContentReviewToPage({\n apw,\n pageBuilder\n });\n updateContentReviewStatus({\n apw,\n pageBuilder,\n security\n });\n linkWorkflowToPage({\n apw,\n pageBuilder\n });\n};\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AASO,MAAMA,mBAAmB,GAAIC,MAAmC,IAAK;EACxE,MAAM;IAAEC,WAAW;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAEtDI,OAAO,CAACC,QAAQ,CAAC,CACb,IAAIC,wDAA2B,EAAE,EACjC,IAAAC,8CAAyB,GAAE,EAC3B,IAAAC,0DAA+B,GAAE,EACjC,IAAAC,kCAAsB,GAAE,EACxB,IAAAC,0DAA+B,GAAE,CACpC,CAAC;EAEF,IAAAC,0CAAoB,EAAC;IACjBT,GAAG;IACHD;EACJ,CAAC,CAAC;EACF,IAAAW,gDAAuB,EAAC;IACpBV,GAAG;IACHD;EACJ,CAAC,CAAC;EACF,IAAAY,oDAAyB,EAAC;IACtBX,GAAG;IACHD,WAAW;IACXE;EACJ,CAAC,CAAC;EACF,IAAAW,sCAAkB,EAAC;IACfZ,GAAG;IACHD;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,86 +1,83 @@
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.linkContentReviewToPage = void 0;
9
-
10
- var _set = _interopRequireDefault(require("lodash/set"));
11
-
12
- var _get = _interopRequireDefault(require("lodash/get"));
13
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
14
9
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
10
  var _types = require("../../types");
17
-
18
11
  var _utils = require("./utils");
19
-
20
12
  const linkContentReviewToPage = params => {
21
13
  const {
22
14
  apw,
23
15
  pageBuilder
24
16
  } = params;
25
- apw.contentReview.onAfterContentReviewCreate.subscribe(async ({
17
+ apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
26
18
  contentReview
27
19
  }) => {
28
20
  const {
29
21
  content
30
22
  } = contentReview;
31
-
32
- if (content.type === _types.ApwContentTypes.PAGE) {
33
- await (0, _utils.updatePageSettings)({
34
- getPage: pageBuilder.getPage,
35
- updatePage: pageBuilder.updatePage,
36
- uniquePageId: content.id,
37
- getNewSettings: settings => {
38
- return (0, _set.default)(settings, "apw.contentReviewId", contentReview.id);
39
- }
40
- });
23
+ if (content.type !== _types.ApwContentTypes.PAGE) {
24
+ return;
41
25
  }
26
+ await (0, _utils.updatePageSettings)({
27
+ getPage: pageBuilder.getPage,
28
+ updatePage: pageBuilder.updatePage,
29
+ uniquePageId: content.id,
30
+ getNewSettings: settings => {
31
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
32
+ apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
33
+ contentReviewId: contentReview.id
34
+ })
35
+ });
36
+ }
37
+ });
42
38
  });
43
- apw.contentReview.onAfterContentReviewDelete.subscribe(async ({
39
+ apw.contentReview.onContentReviewAfterDelete.subscribe(async ({
44
40
  contentReview
45
41
  }) => {
46
42
  const {
47
43
  content
48
44
  } = contentReview;
49
-
50
- if (content.type === _types.ApwContentTypes.PAGE) {
51
- await (0, _utils.updatePageSettings)({
52
- getPage: pageBuilder.getPage,
53
- updatePage: pageBuilder.updatePage,
54
- uniquePageId: content.id,
55
- getNewSettings: settings => {
56
- return (0, _set.default)(settings, "apw.contentReviewId", null);
57
- }
58
- });
45
+ if (content.type !== _types.ApwContentTypes.PAGE) {
46
+ return;
59
47
  }
48
+ await (0, _utils.updatePageSettings)({
49
+ getPage: pageBuilder.getPage,
50
+ updatePage: pageBuilder.updatePage,
51
+ uniquePageId: content.id,
52
+ getNewSettings: settings => {
53
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
54
+ apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
55
+ contentReviewId: null
56
+ })
57
+ });
58
+ }
59
+ });
60
60
  });
61
- pageBuilder.onBeforePageDelete.subscribe(async ({
61
+ pageBuilder.onPageBeforeDelete.subscribe(async ({
62
62
  page
63
63
  }) => {
64
- const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
65
-
64
+ var _page$settings, _page$settings$apw;
65
+ const contentReviewId = (_page$settings = page.settings) === null || _page$settings === void 0 ? void 0 : (_page$settings$apw = _page$settings.apw) === null || _page$settings$apw === void 0 ? void 0 : _page$settings$apw.contentReviewId;
66
66
  if (!contentReviewId) {
67
67
  return;
68
68
  }
69
-
70
69
  let contentReview;
71
-
72
70
  try {
73
71
  contentReview = await apw.contentReview.get(contentReviewId);
74
- } catch (e) {
72
+ } catch (ex) {
75
73
  /**
76
74
  * We're handling the case whereby "contentReviewId" is still linked to page;
77
75
  * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.
78
76
  */
79
- if (e.code !== "NOT_FOUND") {
80
- throw e;
77
+ if (ex.code !== "NOT_FOUND") {
78
+ throw ex;
81
79
  }
82
80
  }
83
-
84
81
  if (contentReview) {
85
82
  throw new _error.default(`Cannot delete the page because a peer review has been requested. Please delete the review first.`, "CANNOT_DELETE_REVIEW_EXIST", {
86
83
  contentReviewId,
@@ -89,5 +86,4 @@ const linkContentReviewToPage = params => {
89
86
  }
90
87
  });
91
88
  };
92
-
93
89
  exports.linkContentReviewToPage = linkContentReviewToPage;
@@ -1 +1 @@
1
- {"version":3,"names":["linkContentReviewToPage","params","apw","pageBuilder","contentReview","onAfterContentReviewCreate","subscribe","content","type","ApwContentTypes","PAGE","updatePageSettings","getPage","updatePage","uniquePageId","id","getNewSettings","settings","set","onAfterContentReviewDelete","onBeforePageDelete","page","contentReviewId","get","e","code","Error"],"sources":["linkContentReviewToPage.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport get from \"lodash/get\";\nimport Error from \"@webiny/error\";\nimport { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { updatePageSettings } from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkContentReviewToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkContentReviewToPage = (params: LinkContentReviewToPageParams) => {\n const { apw, pageBuilder } = params;\n\n apw.contentReview.onAfterContentReviewCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type === ApwContentTypes.PAGE) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return set(settings, \"apw.contentReviewId\", contentReview.id);\n }\n });\n }\n });\n\n apw.contentReview.onAfterContentReviewDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type === ApwContentTypes.PAGE) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return set(settings, \"apw.contentReviewId\", null);\n }\n });\n }\n });\n\n pageBuilder.onBeforePageDelete.subscribe(async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n if (!contentReviewId) {\n return;\n }\n\n let contentReview;\n try {\n contentReview = await apw.contentReview.get(contentReviewId);\n } catch (e) {\n /**\n * We're handling the case whereby \"contentReviewId\" is still linked to page;\n * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.\n */\n if (e.code !== \"NOT_FOUND\") {\n throw e;\n }\n }\n\n if (contentReview) {\n throw new Error(\n `Cannot delete the page because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAQO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAC,GAAG,CAACE,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,IAArC,EAA2C;MACvC,MAAM,IAAAC,yBAAA,EAAmB;QACrBC,OAAO,EAAET,WAAW,CAACS,OADA;QAErBC,UAAU,EAAEV,WAAW,CAACU,UAFH;QAGrBC,YAAY,EAAEP,OAAO,CAACQ,EAHD;QAIrBC,cAAc,EAAEC,QAAQ,IAAI;UACxB,OAAO,IAAAC,YAAA,EAAID,QAAJ,EAAc,qBAAd,EAAqCb,aAAa,CAACW,EAAnD,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;EACJ,CAbD;EAeAb,GAAG,CAACE,aAAJ,CAAkBe,0BAAlB,CAA6Cb,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,IAArC,EAA2C;MACvC,MAAM,IAAAC,yBAAA,EAAmB;QACrBC,OAAO,EAAET,WAAW,CAACS,OADA;QAErBC,UAAU,EAAEV,WAAW,CAACU,UAFH;QAGrBC,YAAY,EAAEP,OAAO,CAACQ,EAHD;QAIrBC,cAAc,EAAEC,QAAQ,IAAI;UACxB,OAAO,IAAAC,YAAA,EAAID,QAAJ,EAAc,qBAAd,EAAqC,IAArC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;EACJ,CAbD;EAeAd,WAAW,CAACiB,kBAAZ,CAA+Bd,SAA/B,CAAyC,OAAO;IAAEe;EAAF,CAAP,KAAoB;IACzD,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;;IACA,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,IAAIlB,aAAJ;;IACA,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAJ,CAAkBmB,GAAlB,CAAsBD,eAAtB,CAAtB;IACH,CAFD,CAEE,OAAOE,CAAP,EAAU;MACR;AACZ;AACA;AACA;MACY,IAAIA,CAAC,CAACC,IAAF,KAAW,WAAf,EAA4B;QACxB,MAAMD,CAAN;MACH;IACJ;;IAED,IAAIpB,aAAJ,EAAmB;MACf,MAAM,IAAIsB,cAAJ,CACD,kGADC,EAEF,4BAFE,EAGF;QACIJ,eADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CA7BD;AA8BH,CA/DM"}
1
+ {"version":3,"names":["linkContentReviewToPage","params","apw","pageBuilder","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","PAGE","updatePageSettings","getPage","updatePage","uniquePageId","id","getNewSettings","settings","contentReviewId","onContentReviewAfterDelete","onPageBeforeDelete","page","get","ex","code","Error"],"sources":["linkContentReviewToPage.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { updatePageSettings } from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkContentReviewToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkContentReviewToPage = (params: LinkContentReviewToPageParams) => {\n const { apw, pageBuilder } = params;\n\n apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.PAGE) {\n return;\n }\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return {\n ...settings,\n apw: {\n ...(settings.apw || {}),\n contentReviewId: contentReview.id\n }\n };\n }\n });\n });\n\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.PAGE) {\n return;\n }\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return {\n ...settings,\n apw: {\n ...(settings.apw || {}),\n contentReviewId: null\n }\n };\n }\n });\n });\n\n pageBuilder.onPageBeforeDelete.subscribe(async ({ page }) => {\n const contentReviewId = page.settings?.apw?.contentReviewId;\n if (!contentReviewId) {\n return;\n }\n\n let contentReview;\n try {\n contentReview = await apw.contentReview.get(contentReviewId);\n } catch (ex) {\n /**\n * We're handling the case whereby \"contentReviewId\" is still linked to page;\n * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.\n */\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n\n if (contentReview) {\n throw new Error(\n `Cannot delete the page because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAQO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAEnCC,GAAG,CAACE,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IAEjC,IAAIG,OAAO,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI,EAAE;MACvC;IACJ;IACA,MAAM,IAAAC,yBAAkB,EAAC;MACrBC,OAAO,EAAET,WAAW,CAACS,OAAO;MAC5BC,UAAU,EAAEV,WAAW,CAACU,UAAU;MAClCC,YAAY,EAAEP,OAAO,CAACQ,EAAE;MACxBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QAAQ;UACXf,GAAG,8DACKe,QAAQ,CAACf,GAAG,IAAI,CAAC,CAAC;YACtBgB,eAAe,EAAEd,aAAa,CAACW;UAAE;QACpC;MAET;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFb,GAAG,CAACE,aAAa,CAACe,0BAA0B,CAACb,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IAEjC,IAAIG,OAAO,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI,EAAE;MACvC;IACJ;IACA,MAAM,IAAAC,yBAAkB,EAAC;MACrBC,OAAO,EAAET,WAAW,CAACS,OAAO;MAC5BC,UAAU,EAAEV,WAAW,CAACU,UAAU;MAClCC,YAAY,EAAEP,OAAO,CAACQ,EAAE;MACxBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QAAQ;UACXf,GAAG,8DACKe,QAAQ,CAACf,GAAG,IAAI,CAAC,CAAC;YACtBgB,eAAe,EAAE;UAAI;QACxB;MAET;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFf,WAAW,CAACiB,kBAAkB,CAACd,SAAS,CAAC,OAAO;IAAEe;EAAK,CAAC,KAAK;IAAA;IACzD,MAAMH,eAAe,qBAAGG,IAAI,CAACJ,QAAQ,yEAAb,eAAef,GAAG,uDAAlB,mBAAoBgB,eAAe;IAC3D,IAAI,CAACA,eAAe,EAAE;MAClB;IACJ;IAEA,IAAId,aAAa;IACjB,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAa,CAACkB,GAAG,CAACJ,eAAe,CAAC;IAChE,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;QACzB,MAAMD,EAAE;MACZ;IACJ;IAEA,IAAInB,aAAa,EAAE;MACf,MAAM,IAAIqB,cAAK,CACV,kGAAiG,EAClG,4BAA4B,EAC5B;QACIP,eAAe;QACfG;MACJ,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,24 +1,20 @@
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.linkWorkflowToPage = void 0;
9
-
10
8
  var _get = _interopRequireDefault(require("lodash/get"));
11
-
12
9
  var _set = _interopRequireDefault(require("lodash/set"));
13
-
10
+ var _types = require("../../types");
14
11
  var _utils = require("./utils");
15
-
16
12
  const linkWorkflowToPage = params => {
17
13
  const {
18
14
  apw,
19
15
  pageBuilder
20
16
  } = params;
21
- pageBuilder.onBeforePageCreate.subscribe(async ({
17
+ pageBuilder.onPageBeforeCreate.subscribe(async ({
22
18
  page
23
19
  }) => {
24
20
  await (0, _utils.assignWorkflowToPage)({
@@ -26,7 +22,7 @@ const linkWorkflowToPage = params => {
26
22
  page
27
23
  });
28
24
  });
29
- pageBuilder.onBeforePageCreateFrom.subscribe(async params => {
25
+ pageBuilder.onPageBeforeCreateFrom.subscribe(async params => {
30
26
  const {
31
27
  page,
32
28
  original
@@ -35,34 +31,28 @@ const linkWorkflowToPage = params => {
35
31
  * If the previous revision(original) already had the "contentReviewId",
36
32
  * we need to unlink it so that new "contentReview" can be request for the new revision.
37
33
  */
38
-
39
34
  const previousContentReviewId = (0, _get.default)(original, "settings.apw.contentReviewId");
40
-
41
35
  if (previousContentReviewId) {
42
36
  page.settings.apw.contentReviewId = null;
43
37
  }
38
+
44
39
  /**
45
40
  * If the previous revision(original) already had the "workflowId",
46
41
  * we don't need to do anything we'll just let it be copied over.
47
42
  */
48
-
49
-
50
43
  const previousWorkflowId = (0, _get.default)(original, "settings.apw.workflowId");
51
-
52
44
  if (previousWorkflowId) {
53
45
  return;
54
46
  }
55
47
  /**
56
48
  * Lookup and assign "workflowId".
57
49
  */
58
-
59
-
60
50
  await (0, _utils.assignWorkflowToPage)({
61
51
  listWorkflow: apw.workflow.list,
62
52
  page
63
53
  });
64
54
  });
65
- pageBuilder.onBeforePageUpdate.subscribe(async params => {
55
+ pageBuilder.onPageBeforeUpdate.subscribe(async params => {
66
56
  const {
67
57
  page,
68
58
  original
@@ -74,7 +64,6 @@ const linkWorkflowToPage = params => {
74
64
  * It can happen because we run modal validation in "onBeforePageUpdate" event,
75
65
  * which doesn't have the "apw" property.
76
66
  */
77
-
78
67
  if (prevApwWorkflowId && !currentApwWorkflowId) {
79
68
  page.settings.apw = original.settings.apw;
80
69
  }
@@ -82,12 +71,9 @@ const linkWorkflowToPage = params => {
82
71
  * If there is a linked "contentReview" for this page and the page "title" has changed.
83
72
  * Let's update the "title" field in "contentReview".
84
73
  */
85
-
86
-
87
74
  const linkedContentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
88
75
  const prevTitle = (0, _get.default)(original, "title");
89
76
  const newTitle = (0, _get.default)(page, "title");
90
-
91
77
  if (linkedContentReviewId && prevTitle !== newTitle) {
92
78
  await apw.contentReview.update(linkedContentReviewId, {
93
79
  title: newTitle
@@ -97,23 +83,22 @@ const linkWorkflowToPage = params => {
97
83
  /**
98
84
  * Link created workflow to associated pages.
99
85
  */
100
-
101
- apw.workflow.onAfterWorkflowCreate.subscribe(async ({
86
+ apw.workflow.onWorkflowAfterCreate.subscribe(async ({
102
87
  workflow
103
88
  }) => {
104
89
  const {
105
90
  scope
106
91
  } = workflow;
92
+ if (workflow.app !== _types.ApwWorkflowApplications.PB) {
93
+ return;
94
+ }
107
95
  /**
108
96
  * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.
109
97
  */
110
-
111
98
  if ((0, _utils.hasPages)(workflow) === false) {
112
99
  return;
113
100
  }
114
-
115
101
  const pages = (0, _get.default)(scope, "data.pages");
116
-
117
102
  for (const pid of pages) {
118
103
  await (0, _utils.updatePageSettings)({
119
104
  getPage: pageBuilder.getPage,
@@ -128,14 +113,16 @@ const linkWorkflowToPage = params => {
128
113
  /**
129
114
  * Link updated workflow to associated pages.
130
115
  */
131
-
132
- apw.workflow.onAfterWorkflowUpdate.subscribe(async ({
116
+ apw.workflow.onWorkflowAfterUpdate.subscribe(async ({
133
117
  workflow,
134
118
  original
135
119
  }) => {
136
120
  const {
137
121
  scope
138
122
  } = workflow;
123
+ if (workflow.app !== _types.ApwWorkflowApplications.PB) {
124
+ return;
125
+ }
139
126
  const {
140
127
  scope: prevScope
141
128
  } = original;
@@ -143,18 +130,15 @@ const linkWorkflowToPage = params => {
143
130
  * If the workflow has pages in it's scope and there is a change in that page list,
144
131
  * we'll update the workflow link for corresponding pages.
145
132
  */
146
-
147
133
  if ((0, _utils.hasPages)(workflow) === false || (0, _utils.shouldUpdatePages)(scope, prevScope) === false) {
148
134
  return;
149
135
  }
150
-
151
136
  const previousPages = (0, _get.default)(prevScope, "data.pages", []);
152
137
  const currentPages = (0, _get.default)(scope, "data.pages", []);
153
138
  const {
154
139
  removedPages,
155
140
  addedPages
156
141
  } = (0, _utils.getPagesDiff)(currentPages, previousPages);
157
-
158
142
  for (const pid of addedPages) {
159
143
  await (0, _utils.updatePageSettings)({
160
144
  getPage: pageBuilder.getPage,
@@ -165,7 +149,6 @@ const linkWorkflowToPage = params => {
165
149
  }
166
150
  });
167
151
  }
168
-
169
152
  for (const pid of removedPages) {
170
153
  await (0, _utils.updatePageSettings)({
171
154
  getPage: pageBuilder.getPage,
@@ -178,5 +161,4 @@ const linkWorkflowToPage = params => {
178
161
  }
179
162
  });
180
163
  };
181
-
182
164
  exports.linkWorkflowToPage = linkWorkflowToPage;