@webiny/api-apw 0.0.0-ee-vpcs.549378cf03

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 (316) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +40 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +40 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +40 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +40 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.d.ts +10 -0
  14. package/ContentApwSettingsPlugin.js +17 -0
  15. package/ContentApwSettingsPlugin.js.map +1 -0
  16. package/LICENSE +21 -0
  17. package/README.md +34 -0
  18. package/crud/createChangeRequestMethods.d.ts +2 -0
  19. package/crud/createChangeRequestMethods.js +98 -0
  20. package/crud/createChangeRequestMethods.js.map +1 -0
  21. package/crud/createCommentMethods.d.ts +2 -0
  22. package/crud/createCommentMethods.js +99 -0
  23. package/crud/createCommentMethods.js.map +1 -0
  24. package/crud/createContentReviewMethods.d.ts +10 -0
  25. package/crud/createContentReviewMethods.js +562 -0
  26. package/crud/createContentReviewMethods.js.map +1 -0
  27. package/crud/createReviewerMethods.d.ts +2 -0
  28. package/crud/createReviewerMethods.js +99 -0
  29. package/crud/createReviewerMethods.js.map +1 -0
  30. package/crud/createWorkflowMethods.d.ts +2 -0
  31. package/crud/createWorkflowMethods.js +118 -0
  32. package/crud/createWorkflowMethods.js.map +1 -0
  33. package/crud/index.d.ts +2 -0
  34. package/crud/index.js +96 -0
  35. package/crud/index.js.map +1 -0
  36. package/crud/utils.d.ts +21 -0
  37. package/crud/utils.js +138 -0
  38. package/crud/utils.js.map +1 -0
  39. package/index.d.ts +4 -0
  40. package/index.js +38 -0
  41. package/index.js.map +1 -0
  42. package/package.json +76 -0
  43. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
  44. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
  45. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
  46. package/plugins/cms/README.md +49 -0
  47. package/plugins/cms/apwEntryPlugins.d.ts +8 -0
  48. package/plugins/cms/apwEntryPlugins.js +46 -0
  49. package/plugins/cms/apwEntryPlugins.js.map +1 -0
  50. package/plugins/cms/index.d.ts +12 -0
  51. package/plugins/cms/index.js +45 -0
  52. package/plugins/cms/index.js.map +1 -0
  53. package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
  54. package/plugins/cms/linkContentReviewToEntry.js +108 -0
  55. package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
  56. package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
  57. package/plugins/cms/linkWorkflowToEntry.js +166 -0
  58. package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
  59. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  60. package/plugins/cms/notifications/changeRequestNotification.js +35 -0
  61. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  62. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  63. package/plugins/cms/notifications/commentNotification.js +35 -0
  64. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  65. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  66. package/plugins/cms/notifications/contentReviewNotification.js +35 -0
  67. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  68. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  69. package/plugins/cms/notifications/contentUrl.js +60 -0
  70. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  71. package/plugins/cms/triggerContentReview.d.ts +8 -0
  72. package/plugins/cms/triggerContentReview.js +59 -0
  73. package/plugins/cms/triggerContentReview.js.map +1 -0
  74. package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
  75. package/plugins/cms/updateContentReviewStatus.js +97 -0
  76. package/plugins/cms/updateContentReviewStatus.js.map +1 -0
  77. package/plugins/cms/utils.d.ts +27 -0
  78. package/plugins/cms/utils.js +207 -0
  79. package/plugins/cms/utils.js.map +1 -0
  80. package/plugins/context.d.ts +5 -0
  81. package/plugins/context.js +146 -0
  82. package/plugins/context.js.map +1 -0
  83. package/plugins/graphql/changeRequest.gql.d.ts +4 -0
  84. package/plugins/graphql/changeRequest.gql.js +155 -0
  85. package/plugins/graphql/changeRequest.gql.js.map +1 -0
  86. package/plugins/graphql/comment.gql.d.ts +4 -0
  87. package/plugins/graphql/comment.gql.js +160 -0
  88. package/plugins/graphql/comment.gql.js.map +1 -0
  89. package/plugins/graphql/contentReview.gql.d.ts +4 -0
  90. package/plugins/graphql/contentReview.gql.js +382 -0
  91. package/plugins/graphql/contentReview.gql.js.map +1 -0
  92. package/plugins/graphql/reviewer.gql.d.ts +4 -0
  93. package/plugins/graphql/reviewer.gql.js +116 -0
  94. package/plugins/graphql/reviewer.gql.js.map +1 -0
  95. package/plugins/graphql/workflow.gql.d.ts +4 -0
  96. package/plugins/graphql/workflow.gql.js +205 -0
  97. package/plugins/graphql/workflow.gql.js.map +1 -0
  98. package/plugins/graphql.d.ts +4 -0
  99. package/plugins/graphql.js +95 -0
  100. package/plugins/graphql.js.map +1 -0
  101. package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
  102. package/plugins/hooks/createReviewerFromIdentity.js +82 -0
  103. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
  104. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
  105. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
  106. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
  107. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
  108. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
  109. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
  110. package/plugins/hooks/index.d.ts +3 -0
  111. package/plugins/hooks/index.js +74 -0
  112. package/plugins/hooks/index.js.map +1 -0
  113. package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
  114. package/plugins/hooks/initializeContentReviewSteps.js +86 -0
  115. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
  116. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  117. package/plugins/hooks/initializeNotifications.js +20 -0
  118. package/plugins/hooks/initializeNotifications.js.map +1 -0
  119. package/plugins/hooks/listContentReviews.d.ts +10 -0
  120. package/plugins/hooks/listContentReviews.js +68 -0
  121. package/plugins/hooks/listContentReviews.js.map +1 -0
  122. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  123. package/plugins/hooks/notifications/appUrl.js +22 -0
  124. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  125. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  126. package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
  127. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  128. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  129. package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
  130. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  131. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  132. package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
  133. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  134. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  135. package/plugins/hooks/notifications/commentUrl.js +31 -0
  136. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  137. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  138. package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
  139. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  140. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  141. package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
  142. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  143. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  144. package/plugins/hooks/notifications/contentUrl.js +29 -0
  145. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  146. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  147. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
  148. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  149. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  150. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
  151. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  152. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  153. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
  154. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  155. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  156. package/plugins/hooks/notifications/reviewers.js +51 -0
  157. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  158. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  159. package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
  160. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  161. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  162. package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
  163. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  164. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  165. package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
  166. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  167. package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
  168. package/plugins/hooks/updatePendingChangeRequests.js +94 -0
  169. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
  170. package/plugins/hooks/updateTotalComments.d.ts +3 -0
  171. package/plugins/hooks/updateTotalComments.js +153 -0
  172. package/plugins/hooks/updateTotalComments.js.map +1 -0
  173. package/plugins/hooks/validateChangeRequest.d.ts +2 -0
  174. package/plugins/hooks/validateChangeRequest.js +89 -0
  175. package/plugins/hooks/validateChangeRequest.js.map +1 -0
  176. package/plugins/hooks/validateComment.d.ts +2 -0
  177. package/plugins/hooks/validateComment.js +57 -0
  178. package/plugins/hooks/validateComment.js.map +1 -0
  179. package/plugins/hooks/validateContentReview.d.ts +2 -0
  180. package/plugins/hooks/validateContentReview.js +38 -0
  181. package/plugins/hooks/validateContentReview.js.map +1 -0
  182. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
  183. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
  184. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
  185. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
  186. package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
  187. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
  188. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
  189. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
  190. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
  191. package/plugins/pageBuilder/index.d.ts +11 -0
  192. package/plugins/pageBuilder/index.js +53 -0
  193. package/plugins/pageBuilder/index.js.map +1 -0
  194. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
  195. package/plugins/pageBuilder/linkContentReviewToPage.js +105 -0
  196. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
  197. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
  198. package/plugins/pageBuilder/linkWorkflowToPage.js +194 -0
  199. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
  200. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  201. package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
  202. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  203. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  204. package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
  205. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  206. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  207. package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
  208. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  209. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  210. package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
  211. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  212. package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
  213. package/plugins/pageBuilder/triggerContentReview.js +50 -0
  214. package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
  215. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
  216. package/plugins/pageBuilder/updateContentReviewStatus.js +79 -0
  217. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
  218. package/plugins/pageBuilder/utils.d.ts +22 -0
  219. package/plugins/pageBuilder/utils.js +184 -0
  220. package/plugins/pageBuilder/utils.js.map +1 -0
  221. package/plugins/utils.d.ts +35 -0
  222. package/plugins/utils.js +187 -0
  223. package/plugins/utils.js.map +1 -0
  224. package/scheduler/createScheduleActionMethods.d.ts +2 -0
  225. package/scheduler/createScheduleActionMethods.js +149 -0
  226. package/scheduler/createScheduleActionMethods.js.map +1 -0
  227. package/scheduler/handlers/executeAction/index.d.ts +13 -0
  228. package/scheduler/handlers/executeAction/index.js +172 -0
  229. package/scheduler/handlers/executeAction/index.js.map +1 -0
  230. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
  231. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
  232. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
  233. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
  234. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
  235. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
  236. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
  237. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
  238. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
  239. package/scheduler/handlers/executeAction/security.d.ts +4 -0
  240. package/scheduler/handlers/executeAction/security.js +68 -0
  241. package/scheduler/handlers/executeAction/security.js.map +1 -0
  242. package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
  243. package/scheduler/handlers/scheduleAction/index.js +164 -0
  244. package/scheduler/handlers/scheduleAction/index.js.map +1 -0
  245. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
  246. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +172 -0
  247. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
  248. package/scheduler/handlers/utils.d.ts +33 -0
  249. package/scheduler/handlers/utils.js +168 -0
  250. package/scheduler/handlers/utils.js.map +1 -0
  251. package/scheduler/index.d.ts +2 -0
  252. package/scheduler/index.js +27 -0
  253. package/scheduler/index.js.map +1 -0
  254. package/scheduler/types.d.ts +171 -0
  255. package/scheduler/types.js +34 -0
  256. package/scheduler/types.js.map +1 -0
  257. package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
  258. package/storageOperations/changeRequestStorageOperations.js +122 -0
  259. package/storageOperations/changeRequestStorageOperations.js.map +1 -0
  260. package/storageOperations/commentStorageOperations.d.ts +3 -0
  261. package/storageOperations/commentStorageOperations.js +138 -0
  262. package/storageOperations/commentStorageOperations.js.map +1 -0
  263. package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
  264. package/storageOperations/contentReviewStorageOperations.js +93 -0
  265. package/storageOperations/contentReviewStorageOperations.js.map +1 -0
  266. package/storageOperations/index.d.ts +15 -0
  267. package/storageOperations/index.js +48 -0
  268. package/storageOperations/index.js.map +1 -0
  269. package/storageOperations/models/changeRequest.model.d.ts +3 -0
  270. package/storageOperations/models/changeRequest.model.js +59 -0
  271. package/storageOperations/models/changeRequest.model.js.map +1 -0
  272. package/storageOperations/models/comment.model.d.ts +7 -0
  273. package/storageOperations/models/comment.model.js +60 -0
  274. package/storageOperations/models/comment.model.js.map +1 -0
  275. package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
  276. package/storageOperations/models/contentModelPluginFactory.js +28 -0
  277. package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
  278. package/storageOperations/models/contentReview.model.d.ts +7 -0
  279. package/storageOperations/models/contentReview.model.js +258 -0
  280. package/storageOperations/models/contentReview.model.js.map +1 -0
  281. package/storageOperations/models/index.d.ts +2 -0
  282. package/storageOperations/models/index.js +115 -0
  283. package/storageOperations/models/index.js.map +1 -0
  284. package/storageOperations/models/reviewer.model.d.ts +3 -0
  285. package/storageOperations/models/reviewer.model.js +71 -0
  286. package/storageOperations/models/reviewer.model.js.map +1 -0
  287. package/storageOperations/models/utils.d.ts +3 -0
  288. package/storageOperations/models/utils.js +37 -0
  289. package/storageOperations/models/utils.js.map +1 -0
  290. package/storageOperations/models/workflow.model.d.ts +12 -0
  291. package/storageOperations/models/workflow.model.js +208 -0
  292. package/storageOperations/models/workflow.model.js.map +1 -0
  293. package/storageOperations/reviewerStorageOperations.d.ts +3 -0
  294. package/storageOperations/reviewerStorageOperations.js +97 -0
  295. package/storageOperations/reviewerStorageOperations.js.map +1 -0
  296. package/storageOperations/types.d.ts +34 -0
  297. package/storageOperations/types.js +5 -0
  298. package/storageOperations/types.js.map +1 -0
  299. package/storageOperations/workflowStorageOperations.d.ts +3 -0
  300. package/storageOperations/workflowStorageOperations.js +111 -0
  301. package/storageOperations/workflowStorageOperations.js.map +1 -0
  302. package/types.d.ts +752 -0
  303. package/types.js +69 -0
  304. package/types.js.map +1 -0
  305. package/utils/contentApwSettingsPlugin.d.ts +9 -0
  306. package/utils/contentApwSettingsPlugin.js +26 -0
  307. package/utils/contentApwSettingsPlugin.js.map +1 -0
  308. package/utils/errors.d.ts +16 -0
  309. package/utils/errors.js +75 -0
  310. package/utils/errors.js.map +1 -0
  311. package/utils/fieldResolver.d.ts +16 -0
  312. package/utils/fieldResolver.js +54 -0
  313. package/utils/fieldResolver.js.map +1 -0
  314. package/utils/resolve.d.ts +3 -0
  315. package/utils/resolve.js +18 -0
  316. package/utils/resolve.js.map +1 -0
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestNotification = void 0;
7
+
8
+ var _types = require("../../../types");
9
+
10
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
11
+
12
+ const createChangeRequestNotification = () => {
13
+ const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ changeRequestUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> content entry.<br /><br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Change Request: ${changeRequestUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createChangeRequestNotification = createChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","CMS_ENTRY","params","changeRequestUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,+BAA+B,GAAG,MAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAA,EAAmCC,sBAAA,CAAgBC,SAAnD,EAA8DC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAF;MAAoBC;IAApB,IAAmCF,MAAzC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -0,0 +1 @@
1
+ export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentNotification = void 0;
7
+
8
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
9
+
10
+ var _types = require("../../../types");
11
+
12
+ const createCommentNotification = () => {
13
+ const plugin = (0, _ApwCommentNotification.createApwCommentNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ commentUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${commentUrl}">comment</a>, on a change request, for <a href="${contentUrl}">this</a> content entry.<br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Comment: ${commentUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createCommentNotification = createCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createCommentNotification","plugin","createApwCommentNotification","ApwContentTypes","CMS_ENTRY","params","commentUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,MAAMC,MAAM,GAAG,IAAAC,oDAAA,EAA6BC,sBAAA,CAAgBC,SAA7C,EAAwDC,MAAM,IAAI;IAC7E,MAAM;MAAEC,UAAF;MAAcC;IAAd,IAA6BF,MAAnC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,UAAW,oDAAmDC,UAAW;AACxH;AACA;AACA;AACA,2BAA2BD,UAAW;AACtC,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -0,0 +1 @@
1
+ export declare const createContentReviewNotification: () => import("../../../ApwContentReviewNotification").ApwContentReviewNotification;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewNotification = void 0;
7
+
8
+ var _types = require("../../../types");
9
+
10
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
11
+
12
+ const createContentReviewNotification = () => {
13
+ const plugin = (0, _ApwContentReviewNotification.createApwContentReviewNotification)(_types.ApwContentTypes.CMS_ENTRY, params => {
14
+ const {
15
+ contentReviewUrl,
16
+ contentUrl
17
+ } = params;
18
+ return {
19
+ text: `
20
+ Hi,<br /><br />
21
+
22
+ You have received a <a href="${contentReviewUrl}">content review</a>, for <a href="${contentUrl}">this</a> content entry.<br />
23
+
24
+ Here are the full URLs:<br /><br />
25
+
26
+ Content Review: ${contentReviewUrl}<br />
27
+ Content Entry: ${contentUrl}
28
+ `
29
+ };
30
+ });
31
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.CMS_ENTRY}.default`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createContentReviewNotification = createContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentReviewNotification","plugin","createApwContentReviewNotification","ApwContentTypes","CMS_ENTRY","params","contentReviewUrl","contentUrl","text","name","type"],"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;;AACA;;AAEO,MAAMA,+BAA+B,GAAG,MAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAA,EAAmCC,sBAAA,CAAgBC,SAAnD,EAA8DC,MAAM,IAAI;IACnF,MAAM;MAAEC,gBAAF;MAAoBC;IAApB,IAAmCF,MAAzC;IAEA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,iCAAiCC,UAAW;AAC5C;IAVe,CAAP;EAYH,CAfc,CAAf;EAiBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,SAAU,UAA1D;EAEA,OAAOH,MAAP;AACH,CArBM"}
@@ -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,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrlPlugin = exports.createContentEntryUrl = void 0;
7
+
8
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
9
+
10
+ var _types = require("../../../types");
11
+
12
+ /**
13
+ * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
14
+ * Due to multiple content types for the APW, everything needs to be pluginable.
15
+ */
16
+ const createContentEntryUrl = params => {
17
+ /**
18
+ * All variables must exist for URL to be created.
19
+ * We go through all vars and throw a log if it does not exist.
20
+ */
21
+ for (const key in params) {
22
+ if (!!key) {
23
+ continue;
24
+ }
25
+
26
+ console.log(`Missing variable "${key}", which we use to create a content entry URL.`);
27
+ return null;
28
+ }
29
+
30
+ const {
31
+ baseUrl,
32
+ modelId,
33
+ id
34
+ } = params;
35
+ return `${baseUrl}/cms/content-entries/${modelId}?id=${id}`;
36
+ };
37
+
38
+ exports.createContentEntryUrl = createContentEntryUrl;
39
+
40
+ const createContentUrlPlugin = () => {
41
+ return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.CMS_ENTRY, params => {
42
+ const {
43
+ baseUrl,
44
+ contentReview
45
+ } = params;
46
+ const {
47
+ id
48
+ } = contentReview.content;
49
+ const {
50
+ modelId
51
+ } = contentReview.content.settings;
52
+ return createContentEntryUrl({
53
+ baseUrl,
54
+ modelId,
55
+ id
56
+ });
57
+ });
58
+ };
59
+
60
+ exports.createContentUrlPlugin = createContentUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentEntryUrl","params","key","console","log","baseUrl","modelId","id","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;;AACA;;AALA;AACA;AACA;AACA;AASO,MAAMA,qBAAqB,GAAIC,MAAD,IAAwD;EACzF;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,gDAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC,OAAX;IAAoBC;EAApB,IAA2BN,MAAjC;EACA,OAAQ,GAAEI,OAAQ,wBAAuBC,OAAQ,OAAMC,EAAG,EAA1D;AACH,CAdM;;;;AAgBA,MAAMC,sBAAsB,GAAG,MAAM;EACxC,OAAO,IAAAC,8CAAA,EAA0BC,sBAAA,CAAgBC,SAA1C,EAAqDV,MAAM,IAAI;IAClE,MAAM;MAAEI,OAAF;MAAWO;IAAX,IAA6BX,MAAnC;IACA,MAAM;MAAEM;IAAF,IAASK,aAAa,CAACC,OAA7B;IACA,MAAM;MAAEP;IAAF,IAAcM,aAAa,CAACC,OAAd,CAAsBC,QAA1C;IACA,OAAOd,qBAAqB,CAAC;MACzBK,OADyB;MAEzBC,OAFyB;MAGzBC;IAHyB,CAAD,CAA5B;EAKH,CATM,CAAP;AAUH,CAXM"}
@@ -0,0 +1,8 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { HeadlessCms } from "@webiny/api-headless-cms/types";
3
+ interface TriggerContentReviewParams {
4
+ apw: AdvancedPublishingWorkflow;
5
+ cms: HeadlessCms;
6
+ }
7
+ export declare const triggerContentReview: (params: TriggerContentReviewParams) => void;
8
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.triggerContentReview = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _types = require("../../types");
13
+
14
+ var _utils = require("./utils");
15
+
16
+ const triggerContentReview = params => {
17
+ const {
18
+ cms,
19
+ apw
20
+ } = params;
21
+ cms.onEntryBeforePublish.subscribe(async ({
22
+ entry,
23
+ model
24
+ }) => {
25
+ var _entry$meta, _entry$meta$apw, _entry$meta2, _entry$meta2$apw;
26
+
27
+ if ((0, _utils.isAwpModel)(model)) {
28
+ return;
29
+ }
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
+
33
+ if (contentReviewId) {
34
+ const contentReview = await apw.contentReview.get(contentReviewId);
35
+
36
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.UNDER_REVIEW) {
37
+ return;
38
+ }
39
+
40
+ throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
41
+ contentReviewId,
42
+ entry
43
+ });
44
+ }
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
+
48
+ if (!workflowId) {
49
+ return;
50
+ }
51
+
52
+ throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
53
+ workflowId,
54
+ entry
55
+ });
56
+ });
57
+ };
58
+
59
+ exports.triggerContentReview = triggerContentReview;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["triggerContentReview","params","cms","apw","onEntryBeforePublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","reviewStatus","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId"],"sources":["triggerContentReview.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnCmsEntryBeforePublishTopicParams\n} from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { isAwpModel } from \"~/plugins/cms/utils\";\n\ninterface TriggerContentReviewParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n}\nexport const triggerContentReview = (params: TriggerContentReviewParams) => {\n const { cms, apw } = params;\n\n cms.onEntryBeforePublish.subscribe<OnCmsEntryBeforePublishTopicParams>(\n async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n if (contentReviewId) {\n const contentReview = await apw.contentReview.get(contentReviewId);\n\n if (contentReview.reviewStatus !== ApwContentReviewStatus.UNDER_REVIEW) {\n return;\n }\n throw new Error(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n entry\n }\n );\n }\n\n const workflowId = entry.meta?.apw?.workflowId;\n\n if (!workflowId) {\n return;\n }\n throw new Error(\n \"This content requires peer review approval before it can be published.\",\n \"REVIEW_REQUIRED\",\n {\n workflowId,\n entry\n }\n );\n }\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAMA;;AAMO,MAAMA,oBAAoB,GAAIC,MAAD,IAAwC;EACxE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAeF,MAArB;EAEAC,GAAG,CAACE,oBAAJ,CAAyBC,SAAzB,CACI,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAAA;;IACxB,IAAI,IAAAC,iBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAME,eAAe,kBAAGH,KAAK,CAACI,IAAT,mEAAG,YAAYP,GAAf,oDAAG,gBAAiBM,eAAzC;;IACA,IAAIA,eAAJ,EAAqB;MACjB,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBC,GAAlB,CAAsBH,eAAtB,CAA5B;;MAEA,IAAIE,aAAa,CAACE,YAAd,KAA+BC,6BAAA,CAAuBC,YAA1D,EAAwE;QACpE;MACH;;MACD,MAAM,IAAIC,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;QACIP,eADJ;QAEIH;MAFJ,CAHE,CAAN;IAQH;;IAED,MAAMW,UAAU,mBAAGX,KAAK,CAACI,IAAT,qEAAG,aAAYP,GAAf,qDAAG,iBAAiBc,UAApC;;IAEA,IAAI,CAACA,UAAL,EAAiB;MACb;IACH;;IACD,MAAM,IAAID,cAAJ,CACF,wEADE,EAEF,iBAFE,EAGF;MACIC,UADJ;MAEIX;IAFJ,CAHE,CAAN;EAQH,CAnCL;AAqCH,CAxCM"}
@@ -0,0 +1,10 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { HeadlessCms } from "@webiny/api-headless-cms/types";
3
+ import { Security } from "@webiny/api-security/types";
4
+ interface UpdateContentReviewStatusParams {
5
+ apw: AdvancedPublishingWorkflow;
6
+ cms: HeadlessCms;
7
+ security: Security;
8
+ }
9
+ export declare const updateContentReviewStatus: (params: UpdateContentReviewStatusParams) => void;
10
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updateContentReviewStatus = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _types = require("../../types");
13
+
14
+ var _utils = require("../../crud/utils");
15
+
16
+ var _utils2 = require("./utils");
17
+
18
+ const updateContentReviewStatus = params => {
19
+ const {
20
+ apw,
21
+ cms,
22
+ security
23
+ } = params;
24
+ cms.onEntryAfterPublish.subscribe(async ({
25
+ entry,
26
+ model
27
+ }) => {
28
+ var _entry$meta, _entry$meta$apw;
29
+
30
+ if ((0, _utils2.isAwpModel)(model)) {
31
+ return;
32
+ }
33
+
34
+ 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;
35
+ /**
36
+ * Bail out if there is no "content review" linked.
37
+ */
38
+
39
+ if (!contentReviewId) {
40
+ return;
41
+ }
42
+
43
+ const contentReview = await apw.contentReview.get(contentReviewId);
44
+ const identity = security.getIdentity();
45
+ /**
46
+ * If content review is "readyToBePublished set its status as "published" after page publish.
47
+ */
48
+
49
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
50
+ return;
51
+ }
52
+
53
+ await apw.contentReview.update(contentReviewId, {
54
+ reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
55
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
56
+ publishedBy: identity.id
57
+ })
58
+ });
59
+ });
60
+ cms.onEntryAfterUnpublish.subscribe(async ({
61
+ entry,
62
+ model
63
+ }) => {
64
+ var _entry$meta2, _entry$meta2$apw;
65
+
66
+ if ((0, _utils2.isAwpModel)(model)) {
67
+ return;
68
+ }
69
+
70
+ const contentReviewId = (_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;
71
+ /**
72
+ * Bail out if there is no "content review" linked.
73
+ */
74
+
75
+ if (!contentReviewId) {
76
+ return;
77
+ }
78
+
79
+ const contentReview = await apw.contentReview.get(contentReviewId);
80
+ /**
81
+ * If content review is "published set its status as "readyToBePublished" after page unpublish.
82
+ */
83
+
84
+ if (contentReview.reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
85
+ return;
86
+ }
87
+
88
+ await apw.contentReview.update(contentReviewId, {
89
+ reviewStatus: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
90
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
91
+ publishedBy: null
92
+ })
93
+ });
94
+ });
95
+ };
96
+
97
+ exports.updateContentReviewStatus = updateContentReviewStatus;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["updateContentReviewStatus","params","apw","cms","security","onEntryAfterPublish","subscribe","entry","model","isAwpModel","contentReviewId","meta","contentReview","get","identity","getIdentity","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onEntryAfterUnpublish"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n OnCmsEntryAfterPublishTopicParams,\n OnCmsEntryAfterUnpublishTopicParams\n} from \"~/types\";\nimport { INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META } from \"~/crud/utils\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport { isAwpModel } from \"~/plugins/cms/utils\";\n\ninterface UpdateContentReviewStatusParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\n\nexport const updateContentReviewStatus = (params: UpdateContentReviewStatusParams) => {\n const { apw, cms, security } = params;\n\n cms.onEntryAfterPublish.subscribe<OnCmsEntryAfterPublishTopicParams>(\n async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n const identity = security.getIdentity();\n /**\n * If content review is \"readyToBePublished set its status as \"published\" after page publish.\n */\n if (contentReview.reviewStatus !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n );\n cms.onEntryAfterUnpublish.subscribe<OnCmsEntryAfterUnpublishTopicParams>(\n async ({ entry, model }) => {\n if (isAwpModel(model)) {\n return;\n }\n const contentReviewId = entry.meta?.apw?.contentReviewId;\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n /**\n * If content review is \"published set its status as \"readyToBePublished\" after page unpublish.\n */\n\n if (contentReview.reviewStatus !== ApwContentReviewStatus.PUBLISHED) {\n return;\n }\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.READY_TO_BE_PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: null\n }\n });\n }\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAMA;;AAGA;;AAQO,MAAMA,yBAAyB,GAAIC,MAAD,IAA6C;EAClF,MAAM;IAAEC,GAAF;IAAOC,GAAP;IAAYC;EAAZ,IAAyBH,MAA/B;EAEAE,GAAG,CAACE,mBAAJ,CAAwBC,SAAxB,CACI,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAAA;;IACxB,IAAI,IAAAC,kBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAME,eAAe,kBAAGH,KAAK,CAACI,IAAT,mEAAG,YAAYT,GAAf,oDAAG,gBAAiBQ,eAAzC;IACA;AACZ;AACA;;IACY,IAAI,CAACA,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMV,GAAG,CAACU,aAAJ,CAAkBC,GAAlB,CAAsBH,eAAtB,CAA5B;IACA,MAAMI,QAAQ,GAAGV,QAAQ,CAACW,WAAT,EAAjB;IACA;AACZ;AACA;;IACY,IAAIH,aAAa,CAACI,YAAd,KAA+BC,6BAAA,CAAuBC,qBAA1D,EAAiF;MAC7E;IACH;;IACD,MAAMhB,GAAG,CAACU,aAAJ,CAAkBO,MAAlB,CAAyBT,eAAzB,EAA0C;MAC5CM,YAAY,EAAEC,6BAAA,CAAuBG,SADO;MAE5CC,OAAO,0FACAT,aAAa,CAACS,OADd,GAEAC,mDAFA;QAGHC,WAAW,EAAET,QAAQ,CAACU;MAHnB;IAFqC,CAA1C,CAAN;EAQH,CA7BL;EA+BArB,GAAG,CAACsB,qBAAJ,CAA0BnB,SAA1B,CACI,OAAO;IAAEC,KAAF;IAASC;EAAT,CAAP,KAA4B;IAAA;;IACxB,IAAI,IAAAC,kBAAA,EAAWD,KAAX,CAAJ,EAAuB;MACnB;IACH;;IACD,MAAME,eAAe,mBAAGH,KAAK,CAACI,IAAT,qEAAG,aAAYT,GAAf,qDAAG,iBAAiBQ,eAAzC;IACA;AACZ;AACA;;IACY,IAAI,CAACA,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMV,GAAG,CAACU,aAAJ,CAAkBC,GAAlB,CAAsBH,eAAtB,CAA5B;IACA;AACZ;AACA;;IAEY,IAAIE,aAAa,CAACI,YAAd,KAA+BC,6BAAA,CAAuBG,SAA1D,EAAqE;MACjE;IACH;;IACD,MAAMlB,GAAG,CAACU,aAAJ,CAAkBO,MAAlB,CAAyBT,eAAzB,EAA0C;MAC5CM,YAAY,EAAEC,6BAAA,CAAuBC,qBADO;MAE5CG,OAAO,0FACAT,aAAa,CAACS,OADd,GAEAC,mDAFA;QAGHC,WAAW,EAAE;MAHV;IAFqC,CAA1C,CAAN;EAQH,CA7BL;AA+BH,CAjEM"}
@@ -0,0 +1,27 @@
1
+ import { CmsEntry, CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
2
+ import { AdvancedPublishingWorkflow, ApwWorkflow } from "../../types";
3
+ export declare const fetchModel: (cms: HeadlessCms, id: string, settings?: {
4
+ modelId?: string;
5
+ } | null) => Promise<CmsModel>;
6
+ export declare const getEntryTitle: (model: CmsModel, entry: CmsEntry) => string;
7
+ interface GetLatestEntryRevisionParams {
8
+ cms: HeadlessCms;
9
+ model: CmsModel;
10
+ entryId: string;
11
+ }
12
+ export declare const getLatestEntryRevision: (params: GetLatestEntryRevisionParams) => Promise<CmsEntry>;
13
+ interface UpdateEntryMetaParams {
14
+ meta: Record<string, any>;
15
+ entryId: string;
16
+ cms: HeadlessCms;
17
+ model: CmsModel;
18
+ }
19
+ export declare const updateEntryMeta: (params: UpdateEntryMetaParams) => Promise<void>;
20
+ interface AssignWorkflowToEntryParams {
21
+ apw: AdvancedPublishingWorkflow;
22
+ entry: CmsEntry;
23
+ }
24
+ export declare const assignWorkflowToEntry: (params: AssignWorkflowToEntryParams) => Promise<void>;
25
+ export declare const hasEntries: (workflow: ApwWorkflow) => Boolean;
26
+ export declare const isAwpModel: (model: CmsModel) => boolean;
27
+ export {};
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updateEntryMeta = exports.isAwpModel = exports.hasEntries = exports.getLatestEntryRevision = exports.getEntryTitle = exports.fetchModel = exports.assignWorkflowToEntry = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _types = require("../../types");
15
+
16
+ var _utils = require("../utils");
17
+
18
+ var _changeRequest = require("../../storageOperations/models/changeRequest.model");
19
+
20
+ var _comment = require("../../storageOperations/models/comment.model");
21
+
22
+ var _contentReview = require("../../storageOperations/models/contentReview.model");
23
+
24
+ var _reviewer = require("../../storageOperations/models/reviewer.model");
25
+
26
+ var _workflow = require("../../storageOperations/models/workflow.model");
27
+
28
+ const fetchModel = async (cms, id, settings) => {
29
+ if (!settings) {
30
+ throw new _error.default("Missing settings.", "SETTINGS_ERROR", {
31
+ id
32
+ });
33
+ }
34
+
35
+ const modelId = settings.modelId;
36
+
37
+ if (!modelId) {
38
+ throw new _error.default("Missing modelId in settings.", "MODEL_ID_ERROR", {
39
+ id,
40
+ settings
41
+ });
42
+ }
43
+
44
+ const model = await cms.getModel(modelId);
45
+
46
+ if (model) {
47
+ return model;
48
+ }
49
+
50
+ throw new _error.default("There is no requested model in the system.", "MODEL_NOT_EXISTS", {
51
+ id,
52
+ settings
53
+ });
54
+ };
55
+
56
+ exports.fetchModel = fetchModel;
57
+
58
+ const getEntryTitle = (model, entry) => {
59
+ const titleFieldId = model.titleFieldId;
60
+
61
+ if (!titleFieldId || !entry.values[titleFieldId]) {
62
+ return entry.id;
63
+ }
64
+
65
+ return entry.values[titleFieldId];
66
+ };
67
+
68
+ exports.getEntryTitle = getEntryTitle;
69
+
70
+ const getLatestEntryRevision = async params => {
71
+ const {
72
+ cms,
73
+ model,
74
+ entryId
75
+ } = params;
76
+ const items = await cms.getLatestEntriesByIds(model, [entryId]);
77
+ const item = items.shift();
78
+
79
+ if (!item) {
80
+ throw new _error.default("There is no entry with given ID.", "ENTRY_NOT_FOUND", {
81
+ entryId
82
+ });
83
+ }
84
+
85
+ return item;
86
+ };
87
+
88
+ exports.getLatestEntryRevision = getLatestEntryRevision;
89
+
90
+ const updateEntryMeta = async params => {
91
+ const {
92
+ entryId,
93
+ cms,
94
+ model,
95
+ meta
96
+ } = params;
97
+ const entry = await getLatestEntryRevision({
98
+ cms,
99
+ model,
100
+ entryId
101
+ });
102
+ await cms.updateEntry(model, entry.id, {}, meta);
103
+ };
104
+
105
+ exports.updateEntryMeta = updateEntryMeta;
106
+
107
+ const isWorkflowApplicable = (entry, workflow) => {
108
+ const application = workflow.app;
109
+
110
+ if (application !== _types.ApwWorkflowApplications.CMS) {
111
+ return false;
112
+ }
113
+
114
+ const scopeType = workflow.scope.type;
115
+
116
+ if (scopeType === _types.WorkflowScopeTypes.DEFAULT) {
117
+ return true;
118
+ } else if (scopeType === _types.WorkflowScopeTypes.CUSTOM) {
119
+ var _workflow$scope$data, _workflow$scope$data2;
120
+
121
+ const models = (_workflow$scope$data = workflow.scope.data) === null || _workflow$scope$data === void 0 ? void 0 : _workflow$scope$data.models;
122
+
123
+ if (Array.isArray(models) && models.includes(entry.modelId)) {
124
+ return true;
125
+ }
126
+
127
+ const entries = ((_workflow$scope$data2 = workflow.scope.data) === null || _workflow$scope$data2 === void 0 ? void 0 : _workflow$scope$data2.entries) || [];
128
+
129
+ if (Array.isArray(entries) && entries.some(value => value.id === entry.entryId)) {
130
+ return true;
131
+ }
132
+
133
+ return false;
134
+ }
135
+
136
+ throw new _error.default(`Unknown scope type "${scopeType}".`, "UNKNOWN_SCOPE_TYPE", {
137
+ workflow
138
+ });
139
+ };
140
+
141
+ const assignWorkflowToEntry = async params => {
142
+ const {
143
+ apw,
144
+ entry
145
+ } = params;
146
+ /**
147
+ * Lookup and assign "workflowId".
148
+ */
149
+
150
+ try {
151
+ /*
152
+ * List all workflows for app cms
153
+ */
154
+ const [entries] = await apw.workflow.list({
155
+ where: {
156
+ app: _types.ApwWorkflowApplications.CMS
157
+ }
158
+ });
159
+ console.log(`Found ${entries.length} workflows.`);
160
+ /*
161
+ * Re-order them based on workflow scope and pre-defined rule i.e.
162
+ * "specific" entry -> entry for a "category" -> "default".
163
+ * There can be more than one workflow with same "scope" and "app".
164
+ * Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.
165
+ */
166
+
167
+ const sortedWorkflows = entries.sort(_utils.workflowByPrecedenceDesc).sort(_utils.workflowByCreatedOnDesc);
168
+ /**
169
+ * Assign the first applicable workflow to the page and exit.
170
+ */
171
+
172
+ for (const workflow of sortedWorkflows) {
173
+ if (isWorkflowApplicable(entry, workflow) === false) {
174
+ console.log(`Not applying workflow ${workflow.id} to entry ${entry.id}.`);
175
+ continue;
176
+ }
177
+
178
+ entry.meta = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry.meta || {}), {}, {
179
+ apw: {
180
+ workflowId: workflow.id,
181
+ contentReviewId: null
182
+ }
183
+ });
184
+ return;
185
+ }
186
+ } catch (ex) {
187
+ throw new _error.default(`Failed to assign workflow to CMS entry "${entry.id}".`, ex.code, ex.data);
188
+ }
189
+ };
190
+
191
+ exports.assignWorkflowToEntry = assignWorkflowToEntry;
192
+
193
+ const hasEntries = workflow => {
194
+ const {
195
+ app,
196
+ scope
197
+ } = workflow;
198
+ return app === _types.ApwWorkflowApplications.CMS && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.entries);
199
+ };
200
+
201
+ exports.hasEntries = hasEntries;
202
+
203
+ const isAwpModel = model => {
204
+ return [_changeRequest.CHANGE_REQUEST_MODEL_ID, _comment.COMMENT_MODEL_ID, _contentReview.CONTENT_REVIEW_MODEL_ID, _reviewer.REVIEWER_MODEL_ID, _workflow.WORKFLOW_MODEL_ID].includes(model.modelId);
205
+ };
206
+
207
+ exports.isAwpModel = isAwpModel;