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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +30 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +30 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +30 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +30 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.js +1 -6
  14. package/ContentApwSettingsPlugin.js.map +1 -1
  15. package/crud/createChangeRequestMethods.js +21 -25
  16. package/crud/createChangeRequestMethods.js.map +1 -1
  17. package/crud/createCommentMethods.js +21 -26
  18. package/crud/createCommentMethods.js.map +1 -1
  19. package/crud/createContentReviewMethods.js +89 -128
  20. package/crud/createContentReviewMethods.js.map +1 -1
  21. package/crud/createReviewerMethods.js +21 -26
  22. package/crud/createReviewerMethods.js.map +1 -1
  23. package/crud/createWorkflowMethods.d.ts +1 -1
  24. package/crud/createWorkflowMethods.js +37 -28
  25. package/crud/createWorkflowMethods.js.map +1 -1
  26. package/crud/index.js +3 -32
  27. package/crud/index.js.map +1 -1
  28. package/crud/utils.js +4 -36
  29. package/crud/utils.js.map +1 -1
  30. package/index.d.ts +2 -3
  31. package/index.js +6 -16
  32. package/index.js.map +1 -1
  33. package/package.json +40 -46
  34. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
  35. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  36. package/plugins/cms/apwEntryPlugins.js +4 -16
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  38. package/plugins/cms/index.js +5 -10
  39. package/plugins/cms/index.js.map +1 -1
  40. package/plugins/cms/linkContentReviewToEntry.js +6 -23
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +14 -43
  43. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  44. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  45. package/plugins/cms/notifications/changeRequestNotification.js +31 -0
  46. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  47. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  48. package/plugins/cms/notifications/commentNotification.js +31 -0
  49. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  50. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  51. package/plugins/cms/notifications/contentReviewNotification.js +31 -0
  52. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  53. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  54. package/plugins/cms/notifications/contentUrl.js +53 -0
  55. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  56. package/plugins/cms/triggerContentReview.js +6 -20
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +14 -36
  59. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  60. package/plugins/cms/utils.js +6 -55
  61. package/plugins/cms/utils.js.map +1 -1
  62. package/plugins/context.d.ts +0 -1
  63. package/plugins/context.js +3 -48
  64. package/plugins/context.js.map +1 -1
  65. package/plugins/graphql/changeRequest.gql.js +4 -11
  66. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  67. package/plugins/graphql/comment.gql.js +4 -11
  68. package/plugins/graphql/comment.gql.js.map +1 -1
  69. package/plugins/graphql/contentReview.gql.js +10 -29
  70. package/plugins/graphql/contentReview.gql.js.map +1 -1
  71. package/plugins/graphql/reviewer.gql.js +6 -11
  72. package/plugins/graphql/reviewer.gql.js.map +1 -1
  73. package/plugins/graphql/workflow.gql.js +4 -11
  74. package/plugins/graphql/workflow.gql.js.map +1 -1
  75. package/plugins/graphql.js +4 -19
  76. package/plugins/graphql.js.map +1 -1
  77. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  78. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  80. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  82. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  83. package/plugins/hooks/index.js +4 -12
  84. package/plugins/hooks/index.js.map +1 -1
  85. package/plugins/hooks/initializeContentReviewSteps.js +15 -25
  86. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  87. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  88. package/plugins/hooks/initializeNotifications.js +15 -0
  89. package/plugins/hooks/initializeNotifications.js.map +1 -0
  90. package/plugins/hooks/listContentReviews.d.ts +10 -0
  91. package/plugins/hooks/listContentReviews.js +56 -0
  92. package/plugins/hooks/listContentReviews.js.map +1 -0
  93. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  94. package/plugins/hooks/notifications/appUrl.js +18 -0
  95. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js +111 -0
  98. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  101. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js +122 -0
  104. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  105. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  106. package/plugins/hooks/notifications/commentUrl.js +27 -0
  107. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js +94 -0
  110. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  113. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  114. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  115. package/plugins/hooks/notifications/contentUrl.js +24 -0
  116. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  119. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  122. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  125. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  126. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  127. package/plugins/hooks/notifications/reviewers.js +45 -0
  128. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  131. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  134. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  137. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  138. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  139. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  140. package/plugins/hooks/updateTotalComments.js +14 -27
  141. package/plugins/hooks/updateTotalComments.js.map +1 -1
  142. package/plugins/hooks/validateChangeRequest.js +27 -18
  143. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  144. package/plugins/hooks/validateComment.js +13 -14
  145. package/plugins/hooks/validateComment.js.map +1 -1
  146. package/plugins/hooks/validateContentReview.js +2 -8
  147. package/plugins/hooks/validateContentReview.js.map +1 -1
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  149. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  150. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  151. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  153. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  154. package/plugins/pageBuilder/index.js +5 -8
  155. package/plugins/pageBuilder/index.js.map +1 -1
  156. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  157. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  158. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  159. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  162. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  165. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  168. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  171. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  172. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  173. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  174. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  175. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  176. package/plugins/pageBuilder/utils.js +2 -36
  177. package/plugins/pageBuilder/utils.js.map +1 -1
  178. package/plugins/utils.d.ts +1 -1
  179. package/plugins/utils.js +4 -57
  180. package/plugins/utils.js.map +1 -1
  181. package/scheduler/createScheduleActionMethods.js +15 -36
  182. package/scheduler/createScheduleActionMethods.js.map +1 -1
  183. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  184. package/scheduler/handlers/executeAction/index.js +45 -39
  185. package/scheduler/handlers/executeAction/index.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  187. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +15 -6
  188. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  189. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  190. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +8 -24
  191. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  192. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  193. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +8 -87
  194. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  195. package/scheduler/handlers/executeAction/security.js +0 -11
  196. package/scheduler/handlers/executeAction/security.js.map +1 -1
  197. package/scheduler/handlers/scheduleAction/index.js +21 -38
  198. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  199. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +9 -32
  200. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  201. package/scheduler/handlers/utils.d.ts +0 -1
  202. package/scheduler/handlers/utils.js +4 -42
  203. package/scheduler/handlers/utils.js.map +1 -1
  204. package/scheduler/index.js +0 -3
  205. package/scheduler/index.js.map +1 -1
  206. package/scheduler/types.d.ts +2 -20
  207. package/scheduler/types.js +12 -23
  208. package/scheduler/types.js.map +1 -1
  209. package/storageOperations/changeRequestStorageOperations.js +22 -45
  210. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  211. package/storageOperations/commentStorageOperations.js +25 -50
  212. package/storageOperations/commentStorageOperations.js.map +1 -1
  213. package/storageOperations/contentReviewStorageOperations.js +22 -43
  214. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  215. package/storageOperations/index.js +5 -23
  216. package/storageOperations/index.js.map +1 -1
  217. package/storageOperations/models/changeRequest.model.js +0 -9
  218. package/storageOperations/models/changeRequest.model.js.map +1 -1
  219. package/storageOperations/models/comment.model.js +0 -8
  220. package/storageOperations/models/comment.model.js.map +1 -1
  221. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
  222. package/storageOperations/models/contentModelPluginFactory.js +5 -17
  223. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  224. package/storageOperations/models/contentReview.model.js +6 -31
  225. package/storageOperations/models/contentReview.model.js.map +1 -1
  226. package/storageOperations/models/index.js +3 -29
  227. package/storageOperations/models/index.js.map +1 -1
  228. package/storageOperations/models/reviewer.model.js +17 -9
  229. package/storageOperations/models/reviewer.model.js.map +1 -1
  230. package/storageOperations/models/utils.js +3 -6
  231. package/storageOperations/models/utils.js.map +1 -1
  232. package/storageOperations/models/workflow.model.js +0 -23
  233. package/storageOperations/models/workflow.model.js.map +1 -1
  234. package/storageOperations/reviewerStorageOperations.js +22 -40
  235. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  236. package/storageOperations/workflowStorageOperations.js +25 -48
  237. package/storageOperations/workflowStorageOperations.js.map +1 -1
  238. package/types.d.ts +104 -88
  239. package/types.js +124 -42
  240. package/types.js.map +1 -1
  241. package/utils/contentApwSettingsPlugin.js +0 -6
  242. package/utils/contentApwSettingsPlugin.js.map +1 -1
  243. package/utils/errors.js +1 -18
  244. package/utils/errors.js.map +1 -1
  245. package/utils/fieldResolver.js +5 -21
  246. package/utils/fieldResolver.js.map +1 -1
  247. package/utils/resolve.js +0 -3
  248. package/utils/resolve.js.map +1 -1
@@ -1,34 +1,27 @@
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.linkContentReviewToEntry = void 0;
9
-
10
8
  var _types = require("../../types");
11
-
12
9
  var _utils = require("./utils");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  const linkContentReviewToEntry = params => {
17
12
  const {
18
13
  apw,
19
14
  cms
20
15
  } = params;
21
- apw.contentReview.onAfterContentReviewCreate.subscribe(async ({
16
+ apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
22
17
  contentReview
23
18
  }) => {
24
19
  const {
25
20
  content
26
21
  } = contentReview;
27
-
28
22
  if (content.type !== _types.ApwContentTypes.CMS_ENTRY) {
29
23
  return;
30
24
  }
31
-
32
25
  const model = await (0, _utils.fetchModel)(cms, content.id, content.settings);
33
26
  await (0, _utils.updateEntryMeta)({
34
27
  cms,
@@ -41,17 +34,15 @@ const linkContentReviewToEntry = params => {
41
34
  entryId: content.id
42
35
  });
43
36
  });
44
- apw.contentReview.onAfterContentReviewDelete.subscribe(async ({
37
+ apw.contentReview.onContentReviewAfterDelete.subscribe(async ({
45
38
  contentReview
46
39
  }) => {
47
40
  const {
48
41
  content
49
42
  } = contentReview;
50
-
51
43
  if (content.type !== _types.ApwContentTypes.CMS_ENTRY) {
52
44
  return;
53
45
  }
54
-
55
46
  const model = await (0, _utils.fetchModel)(cms, content.id, content.settings);
56
47
  await (0, _utils.updateEntryMeta)({
57
48
  cms,
@@ -64,24 +55,19 @@ const linkContentReviewToEntry = params => {
64
55
  entryId: content.id
65
56
  });
66
57
  });
67
- cms.onBeforeEntryDelete.subscribe(async ({
58
+ cms.onEntryBeforeDelete.subscribe(async ({
68
59
  entry,
69
60
  model
70
61
  }) => {
71
- var _entry$meta, _entry$meta$apw;
72
-
62
+ var _entry$meta;
73
63
  if ((0, _utils.isAwpModel)(model)) {
74
64
  return;
75
65
  }
76
-
77
- const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.contentReviewId;
78
-
66
+ const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.contentReviewId;
79
67
  if (!contentReviewId) {
80
68
  return;
81
69
  }
82
-
83
70
  let contentReview;
84
-
85
71
  try {
86
72
  contentReview = await apw.contentReview.get(contentReviewId);
87
73
  } catch (ex) {
@@ -93,16 +79,13 @@ const linkContentReviewToEntry = params => {
93
79
  throw ex;
94
80
  }
95
81
  }
96
-
97
82
  if (!contentReview) {
98
83
  return;
99
84
  }
100
-
101
85
  throw new _error.default(`Cannot delete the entry because a peer review has been requested. Please delete the review first.`, "CANNOT_DELETE_REVIEW_EXIST", {
102
86
  contentReviewId,
103
87
  entry
104
88
  });
105
89
  });
106
90
  };
107
-
108
91
  exports.linkContentReviewToEntry = linkContentReviewToEntry;
@@ -1 +1 @@
1
- {"version":3,"names":["linkContentReviewToEntry","params","apw","cms","contentReview","onAfterContentReviewCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onAfterContentReviewDelete","onBeforeEntryDelete","entry","isAwpModel","get","ex","code","Error"],"sources":["linkContentReviewToEntry.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, isAwpModel, updateEntryMeta } from \"~/plugins/cms/utils\";\nimport Error from \"@webiny/error\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface LinkContentReviewToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkContentReviewToEntry = (params: LinkContentReviewToEntryParams) => {\n const { apw, cms } = params;\n\n apw.contentReview.onAfterContentReviewCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: contentReview.id\n }\n },\n entryId: content.id\n });\n });\n\n apw.contentReview.onAfterContentReviewDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: null\n }\n },\n entryId: content.id\n });\n });\n\n cms.onBeforeEntryDelete.subscribe(async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n\n if (!contentReviewId) {\n return;\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 return;\n }\n throw new Error(\n `Cannot delete the entry because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n entry\n }\n );\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAOO,MAAMA,wBAAwB,GAAIC,MAAD,IAA4C;EAChF,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;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,SAArC,EAAgD;MAC5C;IACH;;IAED,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWT,GAAX,EAAgBI,OAAO,CAACM,EAAxB,EAA4BN,OAAO,CAACO,QAApC,CAApB;IAEA,MAAM,IAAAC,sBAAA,EAAgB;MAClBZ,GADkB;MAElBQ,KAFkB;MAGlBK,IAAI,EAAE;QACFd,GAAG,EAAE;UACDe,eAAe,EAAEb,aAAa,CAACS;QAD9B;MADH,CAHY;MAQlBK,OAAO,EAAEX,OAAO,CAACM;IARC,CAAhB,CAAN;EAUH,CAnBD;EAqBAX,GAAG,CAACE,aAAJ,CAAkBe,0BAAlB,CAA6Cb,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IACA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,SAArC,EAAgD;MAC5C;IACH;;IAED,MAAMC,KAAK,GAAG,MAAM,IAAAC,iBAAA,EAAWT,GAAX,EAAgBI,OAAO,CAACM,EAAxB,EAA4BN,OAAO,CAACO,QAApC,CAApB;IAEA,MAAM,IAAAC,sBAAA,EAAgB;MAClBZ,GADkB;MAElBQ,KAFkB;MAGlBK,IAAI,EAAE;QACFd,GAAG,EAAE;UACDe,eAAe,EAAE;QADhB;MADH,CAHY;MAQlBC,OAAO,EAAEX,OAAO,CAACM;IARC,CAAhB,CAAN;EAUH,CAlBD;EAoBAV,GAAG,CAACiB,mBAAJ,CAAwBd,SAAxB,CAAkC,OAAO;IAAEe,KAAF;IAASV;EAAT,CAAP,KAA4B;IAAA;;IAC1D,IAAI,IAAAW,iBAAA,EAAWX,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAMM,eAAe,kBAAGI,KAAK,CAACL,IAAT,mEAAG,YAAYd,GAAf,oDAAG,gBAAiBe,eAAzC;;IAEA,IAAI,CAACA,eAAL,EAAsB;MAClB;IACH;;IACD,IAAIb,aAAJ;;IACA,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAJ,CAAkBmB,GAAlB,CAAsBN,eAAtB,CAAtB;IACH,CAFD,CAEE,OAAOO,EAAP,EAAW;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAH,KAAY,WAAhB,EAA6B;QACzB,MAAMD,EAAN;MACH;IACJ;;IAED,IAAI,CAACpB,aAAL,EAAoB;MAChB;IACH;;IACD,MAAM,IAAIsB,cAAJ,CACD,mGADC,EAEF,4BAFE,EAGF;MACIT,eADJ;MAEII;IAFJ,CAHE,CAAN;EAQH,CAjCD;AAkCH,CA9EM"}
1
+ {"version":3,"names":["_types","require","_utils","_error","_interopRequireDefault","linkContentReviewToEntry","params","apw","cms","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","CMS_ENTRY","model","fetchModel","id","settings","updateEntryMeta","meta","contentReviewId","entryId","onContentReviewAfterDelete","onEntryBeforeDelete","entry","_entry$meta","isAwpModel","get","ex","code","Error","exports"],"sources":["linkContentReviewToEntry.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { fetchModel, isAwpModel, updateEntryMeta } from \"~/plugins/cms/utils\";\nimport Error from \"@webiny/error\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface LinkContentReviewToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkContentReviewToEntry = (params: LinkContentReviewToEntryParams) => {\n const { apw, cms } = params;\n\n apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: contentReview.id\n }\n },\n entryId: content.id\n });\n });\n\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n if (content.type !== ApwContentTypes.CMS_ENTRY) {\n return;\n }\n\n const model = await fetchModel(cms, content.id, content.settings);\n\n await updateEntryMeta({\n cms,\n model,\n meta: {\n apw: {\n contentReviewId: null\n }\n },\n entryId: content.id\n });\n });\n\n cms.onEntryBeforeDelete.subscribe(async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n\n if (!contentReviewId) {\n return;\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 return;\n }\n throw new Error(\n `Cannot delete the entry because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n entry\n }\n );\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MA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B,CAAC,CAAC;EACN,CAAC,CAAC;EAEFV,GAAG,CAACiB,mBAAmB,CAACd,SAAS,CAAC,OAAO;IAAEe,KAAK;IAAEV;EAAM,CAAC,KAAK;IAAA,IAAAW,WAAA;IAC1D,IAAI,IAAAC,iBAAU,EAACZ,KAAK,CAAC,EAAE;MACnB;IACJ;IACA,MAAMM,eAAe,IAAAK,WAAA,GAAGD,KAAK,CAACL,IAAI,cAAAM,WAAA,gBAAAA,WAAA,GAAVA,WAAA,CAAYpB,GAAG,cAAAoB,WAAA,uBAAfA,WAAA,CAAiBL,eAAe;IAExD,IAAI,CAACA,eAAe,EAAE;MAClB;IACJ;IACA,IAAIb,aAAa;IACjB,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAa,CAACoB,GAAG,CAACP,eAAe,CAAC;IAChE,CAAC,CAAC,OAAOQ,EAAE,EAAE;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;QACzB,MAAMD,EAAE;MACZ;IACJ;IAEA,IAAI,CAACrB,aAAa,EAAE;MAChB;IACJ;IACA,MAAM,IAAIuB,cAAK,CACV,mGAAkG,EACnG,4BAA4B,EAC5B;MACIV,eAAe;MACfI;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAA5B,wBAAA,GAAAA,wBAAA"}
@@ -1,41 +1,35 @@
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.linkWorkflowToEntry = void 0;
9
-
10
8
  var _set = _interopRequireDefault(require("lodash/set"));
11
-
12
9
  var _utils = require("./utils");
13
-
14
10
  const linkWorkflowToEntry = params => {
15
11
  const {
16
12
  apw,
17
13
  cms
18
14
  } = params;
19
- cms.onBeforeEntryCreate.subscribe(async ({
15
+ cms.onEntryBeforeCreate.subscribe(async ({
20
16
  entry,
21
17
  model
22
18
  }) => {
23
19
  if ((0, _utils.isAwpModel)(model)) {
24
20
  return;
25
21
  }
26
-
27
22
  await (0, _utils.assignWorkflowToEntry)({
28
23
  apw,
29
24
  entry
30
25
  });
31
26
  });
32
- cms.onBeforeEntryCreateRevision.subscribe(async ({
27
+ cms.onEntryRevisionBeforeCreate.subscribe(async ({
33
28
  entry,
34
29
  original,
35
30
  model
36
31
  }) => {
37
- var _original$meta, _original$meta$apw, _original$meta2, _original$meta2$apw;
38
-
32
+ var _original$meta, _original$meta2;
39
33
  if ((0, _utils.isAwpModel)(model)) {
40
34
  return;
41
35
  }
@@ -43,53 +37,43 @@ const linkWorkflowToEntry = params => {
43
37
  * If the previous revision(original) already had the "contentReviewId",
44
38
  * we need to unlink it so that new "contentReview" can be request for the new revision.
45
39
  */
46
-
47
-
48
- const previousContentReviewId = (_original$meta = original.meta) === null || _original$meta === void 0 ? void 0 : (_original$meta$apw = _original$meta.apw) === null || _original$meta$apw === void 0 ? void 0 : _original$meta$apw.contentReviewId;
49
-
40
+ const previousContentReviewId = (_original$meta = original.meta) === null || _original$meta === void 0 || (_original$meta = _original$meta.apw) === null || _original$meta === void 0 ? void 0 : _original$meta.contentReviewId;
50
41
  if (previousContentReviewId) {
51
42
  entry.meta = (0, _set.default)(entry.meta || {}, "apw.contentReviewId", null);
52
43
  }
44
+
53
45
  /**
54
46
  * If the previous revision(original) already had the "workflowId",
55
47
  * we don't need to do anything we'll just let it be copied over.
56
48
  */
57
-
58
-
59
- const previousWorkflowId = (_original$meta2 = original.meta) === null || _original$meta2 === void 0 ? void 0 : (_original$meta2$apw = _original$meta2.apw) === null || _original$meta2$apw === void 0 ? void 0 : _original$meta2$apw.workflowId;
60
-
49
+ const previousWorkflowId = (_original$meta2 = original.meta) === null || _original$meta2 === void 0 || (_original$meta2 = _original$meta2.apw) === null || _original$meta2 === void 0 ? void 0 : _original$meta2.workflowId;
61
50
  if (previousWorkflowId) {
62
51
  return;
63
52
  }
64
53
  /**
65
54
  * Lookup and assign "workflowId".
66
55
  */
67
-
68
-
69
56
  await (0, _utils.assignWorkflowToEntry)({
70
57
  apw,
71
58
  entry
72
59
  });
73
60
  });
74
- cms.onBeforeEntryUpdate.subscribe(async ({
61
+ cms.onEntryBeforeUpdate.subscribe(async ({
75
62
  entry,
76
63
  original,
77
64
  model
78
65
  }) => {
79
- var _original$meta3, _original$meta3$apw, _entry$meta, _entry$meta$apw, _entry$meta2, _entry$meta2$apw;
80
-
66
+ var _original$meta3, _entry$meta, _entry$meta2;
81
67
  if ((0, _utils.isAwpModel)(model)) {
82
68
  return;
83
69
  }
84
-
85
- const prevApwWorkflowId = (_original$meta3 = original.meta) === null || _original$meta3 === void 0 ? void 0 : (_original$meta3$apw = _original$meta3.apw) === null || _original$meta3$apw === void 0 ? void 0 : _original$meta3$apw.workflowId;
86
- const currentApwWorkflowId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.workflowId;
70
+ const prevApwWorkflowId = (_original$meta3 = original.meta) === null || _original$meta3 === void 0 || (_original$meta3 = _original$meta3.apw) === null || _original$meta3 === void 0 ? void 0 : _original$meta3.workflowId;
71
+ const currentApwWorkflowId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.workflowId;
87
72
  /**
88
73
  * Make sure the apw property doesn't get lost between updates.
89
74
  * It can happen because we run modal validation in "onBeforePageUpdate" event,
90
75
  * which doesn't have the "apw" property.
91
76
  */
92
-
93
77
  if (prevApwWorkflowId && !currentApwWorkflowId) {
94
78
  entry.meta = (0, _set.default)(entry.meta || {}, "apw", (original.meta || {}).apw || {});
95
79
  }
@@ -97,58 +81,46 @@ const linkWorkflowToEntry = params => {
97
81
  * If there is a linked "contentReview" for this page and the page "title" has changed.
98
82
  * Let's update the "title" field in "contentReview".
99
83
  */
100
-
101
-
102
- const linkedContentReviewId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 ? void 0 : (_entry$meta2$apw = _entry$meta2.apw) === null || _entry$meta2$apw === void 0 ? void 0 : _entry$meta2$apw.contentReviewId;
84
+ const linkedContentReviewId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 || (_entry$meta2 = _entry$meta2.apw) === null || _entry$meta2 === void 0 ? void 0 : _entry$meta2.contentReviewId;
103
85
  const prevTitle = (0, _utils.getEntryTitle)(model, original);
104
86
  const newTitle = (0, _utils.getEntryTitle)(model, entry);
105
-
106
87
  if (!linkedContentReviewId || prevTitle === newTitle) {
107
88
  return;
108
89
  }
109
-
110
90
  await apw.contentReview.update(linkedContentReviewId, {
111
91
  title: newTitle
112
92
  });
113
93
  });
94
+
114
95
  /**
115
96
  * Link created workflow to associated entries.
116
97
  */
117
-
118
- apw.workflow.onAfterWorkflowCreate.subscribe(async ({
98
+ apw.workflow.onWorkflowAfterCreate.subscribe(async ({
119
99
  workflow
120
100
  }) => {
121
101
  var _scope$data;
122
-
123
102
  const {
124
103
  scope
125
104
  } = workflow;
126
105
  /**
127
106
  * If the workflow has entries in it's scope, we'll link that workflow for each of those entries.
128
107
  */
129
-
130
108
  if ((0, _utils.hasEntries)(workflow) === false) {
131
109
  return;
132
110
  }
133
-
134
111
  const models = await cms.listModels();
135
112
  const values = (_scope$data = scope.data) === null || _scope$data === void 0 ? void 0 : _scope$data.entries;
136
-
137
113
  if (!values || Array.isArray(values) === false || values.length === 0) {
138
114
  return;
139
115
  }
140
-
141
116
  for (const value of values) {
142
117
  if (!value || !value.modelId || !value.id) {
143
118
  continue;
144
119
  }
145
-
146
120
  const model = models.find(m => m.modelId === value.modelId);
147
-
148
121
  if (!model) {
149
122
  continue;
150
123
  }
151
-
152
124
  await (0, _utils.updateEntryMeta)({
153
125
  cms,
154
126
  model,
@@ -162,5 +134,4 @@ const linkWorkflowToEntry = params => {
162
134
  }
163
135
  });
164
136
  };
165
-
166
137
  exports.linkWorkflowToEntry = linkWorkflowToEntry;
@@ -1 +1 @@
1
- {"version":3,"names":["linkWorkflowToEntry","params","apw","cms","onBeforeEntryCreate","subscribe","entry","model","isAwpModel","assignWorkflowToEntry","onBeforeEntryCreateRevision","original","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onBeforeEntryUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onAfterWorkflowCreate","scope","hasEntries","models","listModels","values","data","entries","Array","isArray","length","value","modelId","id","find","m","updateEntryMeta","entryId"],"sources":["linkWorkflowToEntry.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport {\n assignWorkflowToEntry,\n getEntryTitle,\n hasEntries,\n isAwpModel,\n updateEntryMeta\n} from \"~/plugins/cms/utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface Value {\n id: string;\n modelId: string;\n}\n\ninterface LinkWorkflowToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkWorkflowToEntry = (params: LinkWorkflowToEntryParams) => {\n const { apw, cms } = params;\n\n cms.onBeforeEntryCreate.subscribe(async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onBeforeEntryCreateRevision.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = original.meta?.apw?.contentReviewId;\n if (previousContentReviewId) {\n entry.meta = set(entry.meta || {}, \"apw.contentReviewId\", null);\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = original.meta?.apw?.workflowId;\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onBeforeEntryUpdate.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const prevApwWorkflowId = original.meta?.apw?.workflowId;\n const currentApwWorkflowId = entry.meta?.apw?.workflowId;\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n entry.meta = set(entry.meta || {}, \"apw\", (original.meta || {}).apw || {});\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = entry.meta?.apw?.contentReviewId;\n const prevTitle = getEntryTitle(model, original);\n const newTitle = getEntryTitle(model, entry);\n\n if (!linkedContentReviewId || prevTitle === newTitle) {\n return;\n }\n await apw.contentReview.update(linkedContentReviewId, {\n title: newTitle\n });\n });\n\n /**\n * Link created workflow to associated entries.\n */\n apw.workflow.onAfterWorkflowCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n /**\n * If the workflow has entries in it's scope, we'll link that workflow for each of those entries.\n */\n if (hasEntries(workflow) === false) {\n return;\n }\n\n const models = await cms.listModels();\n\n const values: Value[] | undefined = scope.data?.entries;\n if (!values || Array.isArray(values) === false || values.length === 0) {\n return;\n }\n\n for (const value of values) {\n if (!value || !value.modelId || !value.id) {\n continue;\n }\n const model = models.find(m => m.modelId === value.modelId);\n if (!model) {\n continue;\n }\n await updateEntryMeta({\n cms,\n model,\n entryId: value.id,\n meta: {\n apw: {\n workflowId: workflow.id\n }\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAkBO,MAAMA,mBAAmB,GAAIC,MAAD,IAAuC;EACtE,MAAM;IAA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T,gDAAG,YAAYC,OAAhD;;IACA,IAAI,CAACF,MAAD,IAAWG,KAAK,CAACC,OAAN,CAAcJ,MAAd,MAA0B,KAArC,IAA8CA,MAAM,CAACK,MAAP,KAAkB,CAApE,EAAuE;MACnE;IACH;;IAED,KAAK,MAAMC,KAAX,IAAoBN,MAApB,EAA4B;MACxB,IAAI,CAACM,KAAD,IAAU,CAACA,KAAK,CAACC,OAAjB,IAA4B,CAACD,KAAK,CAACE,EAAvC,EAA2C;QACvC;MACH;;MACD,MAAMnC,KAAK,GAAGyB,MAAM,CAACW,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACH,OAAF,KAAcD,KAAK,CAACC,OAArC,CAAd;;MACA,IAAI,CAAClC,KAAL,EAAY;QACR;MACH;;MACD,MAAM,IAAAsC,sBAAA,EAAgB;QAClB1C,GADkB;QAElBI,KAFkB;QAGlBuC,OAAO,EAAEN,KAAK,CAACE,EAHG;QAIlB7B,IAAI,EAAE;UACFX,GAAG,EAAE;YACDe,UAAU,EAAEW,QAAQ,CAACc;UADpB;QADH;MAJY,CAAhB,CAAN;IAUH;EACJ,CAnCD;AAoCH,CAhHM"}
1
+ {"version":3,"names":["_set","_interopRequireDefault","require","_utils","linkWorkflowToEntry","params","apw","cms","onEntryBeforeCreate","subscribe","entry","model","isAwpModel","assignWorkflowToEntry","onEntryRevisionBeforeCreate","original","_original$meta","_original$meta2","previousContentReviewId","meta","contentReviewId","set","previousWorkflowId","workflowId","onEntryBeforeUpdate","_original$meta3","_entry$meta","_entry$meta2","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","getEntryTitle","newTitle","contentReview","update","title","workflow","onWorkflowAfterCreate","_scope$data","scope","hasEntries","models","listModels","values","data","entries","Array","isArray","length","value","modelId","id","find","m","updateEntryMeta","entryId","exports"],"sources":["linkWorkflowToEntry.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport {\n assignWorkflowToEntry,\n getEntryTitle,\n hasEntries,\n isAwpModel,\n updateEntryMeta\n} from \"~/plugins/cms/utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\n\ninterface Value {\n id: string;\n modelId: string;\n}\n\ninterface LinkWorkflowToEntryParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const linkWorkflowToEntry = (params: LinkWorkflowToEntryParams) => {\n const { apw, cms } = params;\n\n cms.onEntryBeforeCreate.subscribe(async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onEntryRevisionBeforeCreate.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = original.meta?.apw?.contentReviewId;\n if (previousContentReviewId) {\n entry.meta = set(entry.meta || {}, \"apw.contentReviewId\", null);\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = original.meta?.apw?.workflowId;\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToEntry({\n apw,\n entry\n });\n });\n\n cms.onEntryBeforeUpdate.subscribe(async ({ entry, original, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const prevApwWorkflowId = original.meta?.apw?.workflowId;\n const currentApwWorkflowId = entry.meta?.apw?.workflowId;\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n entry.meta = set(entry.meta || {}, \"apw\", (original.meta || {}).apw || {});\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = entry.meta?.apw?.contentReviewId;\n const prevTitle = getEntryTitle(model, original);\n const newTitle = getEntryTitle(model, entry);\n\n if (!linkedContentReviewId || prevTitle === newTitle) {\n return;\n }\n await apw.contentReview.update(linkedContentReviewId, {\n title: newTitle\n });\n });\n\n /**\n * Link created workflow to associated entries.\n */\n apw.workflow.onWorkflowAfterCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n /**\n * If the workflow has entries in it's scope, we'll link that workflow for each of those entries.\n */\n if (hasEntries(workflow) === false) {\n return;\n }\n\n const models = await cms.listModels();\n\n const values: Value[] | undefined = scope.data?.entries;\n if (!values || Array.isArray(values) === false || values.length === 0) {\n return;\n }\n\n for (const value of values) {\n if (!value || !value.modelId || !value.id) {\n continue;\n }\n const model = models.find(m => m.modelId === value.modelId);\n if (!model) {\n continue;\n }\n await updateEntryMeta({\n cms,\n model,\n entryId: value.id,\n meta: {\n apw: {\n workflowId: workflow.id\n }\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAkBO,MAAME,mBAAmB,GAAIC,MAAiC,IAAK;EACtE,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAE3BE,GAAG,CAACC,mBAAmB,CAACC,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,KAAK;IAC1D,IAAI,IAAAC,iBAAU,EAACD,KAAK,CAAC,EAAE;MACnB;IACJ;IACA,MAAM,IAAAE,4BAAqB,EAAC;MACxBP,GAAG;MACHI;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFH,GAAG,CAACO,2BAA2B,CAACL,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEK,QAAQ;IAAEJ;EAAM,CAAC,KAAK;IAAA,IAAAK,cAAA,EAAAC,eAAA;IAC5E,IAAI,IAAAL,iBAAU,EAACD,KAAK,CAAC,EAAE;MACnB;IACJ;IACA;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CAACJ,MAAM,CAAC,KAAK,KAAK,IAAIA,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MACnE;IACJ;IAEA,KAAK,MAAMC,KAAK,IAAIN,MAAM,EAAE;MACxB,IAAI,CAACM,KAAK,IAAI,CAACA,KAAK,CAACC,OAAO,IAAI,CAACD,KAAK,CAACE,EAAE,EAAE;QACvC;MACJ;MACA,MAAMzC,KAAK,GAAG+B,MAAM,CAACW,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKD,KAAK,CAACC,OAAO,CAAC;MAC3D,IAAI,CAACxC,KAAK,EAAE;QACR;MACJ;MACA,MAAM,IAAA4C,sBAAe,EAAC;QAClBhD,GAAG;QACHI,KAAK;QACL6C,OAAO,EAAEN,KAAK,CAACE,EAAE;QACjBjC,IAAI,EAAE;UACFb,GAAG,EAAE;YACDiB,UAAU,EAAEc,QAAQ,CAACe;UACzB;QACJ;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAArD,mBAAA,GAAAA,mBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createChangeRequestNotification: () => import("../../../ApwChangeRequestNotification").ApwChangeRequestNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
9
+ const createChangeRequestNotification = () => {
10
+ const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ changeRequestUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> content entry.<br /><br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Change Request: ${changeRequestUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createChangeRequestNotification = createChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwChangeRequestNotification","createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","CMS_ENTRY","params","changeRequestUrl","contentUrl","text","name","type","exports"],"sources":["changeRequestNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\nexport const createChangeRequestNotification = () => {\n const plugin = createApwChangeRequestNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { changeRequestUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${changeRequestUrl}\">change request</a>, for <a href=\"${contentUrl}\">this</a> content entry.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Change Request: ${changeRequestUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAE/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1 @@
1
+ export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentNotification = void 0;
7
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
8
+ var _types = require("../../../types");
9
+ const createCommentNotification = () => {
10
+ const plugin = (0, _ApwCommentNotification.createApwCommentNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ commentUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${commentUrl}">comment</a>, on a change request, for <a href="${contentUrl}">this</a> content entry.<br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Comment: ${commentUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createCommentNotification = createCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwCommentNotification","require","_types","createCommentNotification","plugin","createApwCommentNotification","ApwContentTypes","CMS_ENTRY","params","commentUrl","contentUrl","text","name","type","exports"],"sources":["commentNotification.ts"],"sourcesContent":["import { createApwCommentNotification } from \"~/ApwCommentNotification\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport const createCommentNotification = () => {\n const plugin = createApwCommentNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { commentUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${commentUrl}\">comment</a>, on a change request, for <a href=\"${contentUrl}\">this</a> content entry.<br />\n \n Here are the full URLs:<br /><br />\n \n Comment: ${commentUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAAC,oDAA4B,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IAC7E,MAAM;MAAEC,UAAU;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAEzC,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,UAAW,oDAAmDC,UAAW;AACxH;AACA;AACA;AACA,2BAA2BD,UAAW;AACtC,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createContentReviewNotification: () => import("../../../ApwContentReviewNotification").ApwContentReviewNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
9
+ const createContentReviewNotification = () => {
10
+ const plugin = (0, _ApwContentReviewNotification.createApwContentReviewNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
11
+ const {
12
+ contentReviewUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${contentReviewUrl}">content review</a>, for <a href="${contentUrl}">this</a> content entry.<br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Content Review: ${contentReviewUrl}<br />
24
+ Content Entry: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createContentReviewNotification = createContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwContentReviewNotification","createContentReviewNotification","plugin","createApwContentReviewNotification","ApwContentTypes","CMS_ENTRY","params","contentReviewUrl","contentUrl","text","name","type","exports"],"sources":["contentReviewNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\nexport const createContentReviewNotification = () => {\n const plugin = createApwContentReviewNotification(ApwContentTypes.CMS_ENTRY, params => {\n const { contentReviewUrl, contentUrl } = params;\n\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${contentReviewUrl}\">content review</a>, for <a href=\"${contentUrl}\">this</a> content entry.<br />\n \n Here are the full URLs:<br /><br />\n \n Content Review: ${contentReviewUrl}<br />\n Content Entry: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.CMS_ENTRY}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,SAAS,EAAEC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAE/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,SAAU,UAAS;EAEnE,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1,8 @@
1
+ interface CreateContentEntryUrlParams {
2
+ baseUrl?: string;
3
+ modelId?: string;
4
+ id: string;
5
+ }
6
+ export declare const createContentEntryUrl: (params: CreateContentEntryUrlParams) => string | null;
7
+ export declare const createContentUrlPlugin: () => import("../../../ApwContentUrlPlugin").ApwContentUrlPlugin;
8
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrlPlugin = exports.createContentEntryUrl = void 0;
7
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
8
+ var _types = require("../../../types");
9
+ /**
10
+ * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
11
+ * Due to multiple content types for the APW, everything needs to be pluginable.
12
+ */
13
+
14
+ const createContentEntryUrl = params => {
15
+ /**
16
+ * All variables must exist for URL to be created.
17
+ * We go through all vars and throw a log if it does not exist.
18
+ */
19
+ for (const key in params) {
20
+ if (!!key) {
21
+ continue;
22
+ }
23
+ console.log(`Missing variable "${key}", which we use to create a content entry URL.`);
24
+ return null;
25
+ }
26
+ const {
27
+ baseUrl,
28
+ modelId,
29
+ id
30
+ } = params;
31
+ return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;
32
+ };
33
+ exports.createContentEntryUrl = createContentEntryUrl;
34
+ const createContentUrlPlugin = () => {
35
+ return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.CMS_ENTRY, params => {
36
+ const {
37
+ baseUrl,
38
+ contentReview
39
+ } = params;
40
+ const {
41
+ id
42
+ } = contentReview.content;
43
+ const {
44
+ modelId
45
+ } = contentReview.content.settings;
46
+ return createContentEntryUrl({
47
+ baseUrl,
48
+ modelId,
49
+ id
50
+ });
51
+ });
52
+ };
53
+ exports.createContentUrlPlugin = createContentUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwContentUrlPlugin","require","_types","createContentEntryUrl","params","key","console","log","baseUrl","modelId","id","exports","createContentUrlPlugin","createApwContentUrlPlugin","ApwContentTypes","CMS_ENTRY","contentReview","content","settings"],"sources":["contentUrl.ts"],"sourcesContent":["/**\n * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.\n * Due to multiple content types for the APW, everything needs to be pluginable.\n */\nimport { createApwContentUrlPlugin } from \"~/ApwContentUrlPlugin\";\nimport { ApwContentTypes } from \"~/types\";\n\ninterface CreateContentEntryUrlParams {\n baseUrl?: string;\n modelId?: string;\n id: string;\n}\nexport const createContentEntryUrl = (params: CreateContentEntryUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a content entry URL.`);\n return null;\n }\n const { baseUrl, modelId, id } = params;\n return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;\n};\n\nexport const createContentUrlPlugin = () => {\n return createApwContentUrlPlugin(ApwContentTypes.CMS_ENTRY, params => {\n const { baseUrl, contentReview } = params;\n const { id } = contentReview.content;\n const { modelId } = contentReview.content.settings;\n return createContentEntryUrl({\n baseUrl,\n modelId,\n id\n });\n });\n};\n"],"mappings":";;;;;;AAIA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AASO,MAAME,qBAAqB,GAAIC,MAAmC,IAAoB;EACzF;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,gDAA+C,CAAC;IACrF,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC,OAAO;IAAEC;EAAG,CAAC,GAAGN,MAAM;EACvC,OAAQ,GAAEI,OAAQ,wBAAuBC,OAAQ,OAAMC,EAAG,EAAC;AAC/D,CAAC;AAACC,OAAA,CAAAR,qBAAA,GAAAA,qBAAA;AAEK,MAAMS,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAO,IAAAC,8CAAyB,EAACC,sBAAe,CAACC,SAAS,EAAEX,MAAM,IAAI;IAClE,MAAM;MAAEI,OAAO;MAAEQ;IAAc,CAAC,GAAGZ,MAAM;IACzC,MAAM;MAAEM;IAAG,CAAC,GAAGM,aAAa,CAACC,OAAO;IACpC,MAAM;MAAER;IAAQ,CAAC,GAAGO,aAAa,CAACC,OAAO,CAACC,QAAQ;IAClD,OAAOf,qBAAqB,CAAC;MACzBK,OAAO;MACPC,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,sBAAA,GAAAA,sBAAA"}
@@ -1,59 +1,45 @@
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.triggerContentReview = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _types = require("../../types");
13
-
14
10
  var _utils = require("./utils");
15
-
16
11
  const triggerContentReview = params => {
17
12
  const {
18
13
  cms,
19
14
  apw
20
15
  } = params;
21
- cms.onBeforeEntryPublish.subscribe(async ({
16
+ cms.onEntryBeforePublish.subscribe(async ({
22
17
  entry,
23
18
  model
24
19
  }) => {
25
- var _entry$meta, _entry$meta$apw, _entry$meta2, _entry$meta2$apw;
26
-
20
+ var _entry$meta, _entry$meta2;
27
21
  if ((0, _utils.isAwpModel)(model)) {
28
22
  return;
29
23
  }
30
-
31
- const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 ? void 0 : (_entry$meta$apw = _entry$meta.apw) === null || _entry$meta$apw === void 0 ? void 0 : _entry$meta$apw.contentReviewId;
32
-
24
+ const contentReviewId = (_entry$meta = entry.meta) === null || _entry$meta === void 0 || (_entry$meta = _entry$meta.apw) === null || _entry$meta === void 0 ? void 0 : _entry$meta.contentReviewId;
33
25
  if (contentReviewId) {
34
26
  const contentReview = await apw.contentReview.get(contentReviewId);
35
-
36
- if (contentReview.status !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
27
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
37
28
  return;
38
29
  }
39
-
40
30
  throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
41
31
  contentReviewId,
42
32
  entry
43
33
  });
44
34
  }
45
-
46
- const workflowId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 ? void 0 : (_entry$meta2$apw = _entry$meta2.apw) === null || _entry$meta2$apw === void 0 ? void 0 : _entry$meta2$apw.workflowId;
47
-
35
+ const workflowId = (_entry$meta2 = entry.meta) === null || _entry$meta2 === void 0 || (_entry$meta2 = _entry$meta2.apw) === null || _entry$meta2 === void 0 ? void 0 : _entry$meta2.workflowId;
48
36
  if (!workflowId) {
49
37
  return;
50
38
  }
51
-
52
39
  throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
53
40
  workflowId,
54
41
  entry
55
42
  });
56
43
  });
57
44
  };
58
-
59
45
  exports.triggerContentReview = triggerContentReview;