@webiny/api-apw 0.0.0-unstable.1e66d121db → 0.0.0-unstable.2aaa1916d9

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 (307) hide show
  1. package/ApwChangeRequestNotification.d.ts +27 -0
  2. package/ApwChangeRequestNotification.js +28 -0
  3. package/ApwChangeRequestNotification.js.map +1 -0
  4. package/ApwCommentNotification.d.ts +27 -0
  5. package/ApwCommentNotification.js +28 -0
  6. package/ApwCommentNotification.js.map +1 -0
  7. package/ApwContentReviewNotification.d.ts +26 -0
  8. package/ApwContentReviewNotification.js +28 -0
  9. package/ApwContentReviewNotification.js.map +1 -0
  10. package/ApwContentUrlPlugin.d.ts +19 -0
  11. package/ApwContentUrlPlugin.js +28 -0
  12. package/ApwContentUrlPlugin.js.map +1 -0
  13. package/ContentApwSettingsPlugin.d.ts +1 -1
  14. package/ContentApwSettingsPlugin.js +5 -9
  15. package/ContentApwSettingsPlugin.js.map +1 -1
  16. package/README.md +3 -3
  17. package/crud/createChangeRequestMethods.d.ts +1 -1
  18. package/crud/createChangeRequestMethods.js +7 -12
  19. package/crud/createChangeRequestMethods.js.map +1 -1
  20. package/crud/createCommentMethods.d.ts +1 -1
  21. package/crud/createCommentMethods.js +7 -13
  22. package/crud/createCommentMethods.js.map +1 -1
  23. package/crud/createContentReviewMethods.d.ts +2 -2
  24. package/crud/createContentReviewMethods.js +84 -113
  25. package/crud/createContentReviewMethods.js.map +1 -1
  26. package/crud/createReviewerMethods.d.ts +1 -1
  27. package/crud/createReviewerMethods.js +7 -13
  28. package/crud/createReviewerMethods.js.map +1 -1
  29. package/crud/createWorkflowMethods.d.ts +1 -1
  30. package/crud/createWorkflowMethods.js +7 -18
  31. package/crud/createWorkflowMethods.js.map +1 -1
  32. package/crud/index.d.ts +1 -1
  33. package/crud/index.js +5 -29
  34. package/crud/index.js.map +1 -1
  35. package/crud/utils.d.ts +2 -2
  36. package/crud/utils.js +7 -35
  37. package/crud/utils.js.map +1 -1
  38. package/index.d.ts +3 -4
  39. package/index.js +7 -18
  40. package/index.js.map +1 -1
  41. package/package.json +32 -50
  42. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
  43. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
  44. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  45. package/plugins/cms/apwEntryPlugins.d.ts +2 -2
  46. package/plugins/cms/apwEntryPlugins.js +18 -14
  47. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  48. package/plugins/cms/index.d.ts +4 -4
  49. package/plugins/cms/index.js +7 -10
  50. package/plugins/cms/index.js.map +1 -1
  51. package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
  52. package/plugins/cms/linkContentReviewToEntry.js +4 -20
  53. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  54. package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
  55. package/plugins/cms/linkWorkflowToEntry.js +18 -46
  56. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  57. package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
  58. package/plugins/cms/notifications/changeRequestNotification.js +33 -0
  59. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
  60. package/plugins/cms/notifications/commentNotification.d.ts +1 -0
  61. package/plugins/cms/notifications/commentNotification.js +33 -0
  62. package/plugins/cms/notifications/commentNotification.js.map +1 -0
  63. package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
  64. package/plugins/cms/notifications/contentReviewNotification.js +33 -0
  65. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
  66. package/plugins/cms/notifications/contentUrl.d.ts +8 -0
  67. package/plugins/cms/notifications/contentUrl.js +55 -0
  68. package/plugins/cms/notifications/contentUrl.js.map +1 -0
  69. package/plugins/cms/triggerContentReview.d.ts +2 -2
  70. package/plugins/cms/triggerContentReview.js +5 -18
  71. package/plugins/cms/triggerContentReview.js.map +1 -1
  72. package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
  73. package/plugins/cms/updateContentReviewStatus.js +14 -30
  74. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  75. package/plugins/cms/utils.d.ts +5 -4
  76. package/plugins/cms/utils.js +20 -59
  77. package/plugins/cms/utils.js.map +1 -1
  78. package/plugins/context.d.ts +3 -4
  79. package/plugins/context.js +4 -58
  80. package/plugins/context.js.map +1 -1
  81. package/plugins/graphql/changeRequest.gql.d.ts +1 -1
  82. package/plugins/graphql/changeRequest.gql.js +16 -20
  83. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  84. package/plugins/graphql/comment.gql.d.ts +1 -1
  85. package/plugins/graphql/comment.gql.js +41 -43
  86. package/plugins/graphql/comment.gql.js.map +1 -1
  87. package/plugins/graphql/contentReview.gql.d.ts +1 -1
  88. package/plugins/graphql/contentReview.gql.js +25 -35
  89. package/plugins/graphql/contentReview.gql.js.map +1 -1
  90. package/plugins/graphql/reviewer.gql.d.ts +1 -1
  91. package/plugins/graphql/reviewer.gql.js +17 -20
  92. package/plugins/graphql/reviewer.gql.js.map +1 -1
  93. package/plugins/graphql/utils.d.ts +2 -0
  94. package/plugins/graphql/utils.js +10 -0
  95. package/plugins/graphql/utils.js.map +1 -0
  96. package/plugins/graphql/workflow.gql.d.ts +1 -1
  97. package/plugins/graphql/workflow.gql.js +15 -20
  98. package/plugins/graphql/workflow.gql.js.map +1 -1
  99. package/plugins/graphql.d.ts +1 -1
  100. package/plugins/graphql.js +5 -18
  101. package/plugins/graphql.js.map +1 -1
  102. package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
  103. package/plugins/hooks/createReviewerFromIdentity.js +28 -15
  104. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  105. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
  106. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
  107. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  108. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
  109. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
  110. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  111. package/plugins/hooks/index.d.ts +1 -1
  112. package/plugins/hooks/index.js +4 -13
  113. package/plugins/hooks/index.js.map +1 -1
  114. package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
  115. package/plugins/hooks/initializeContentReviewSteps.js +15 -20
  116. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  117. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  118. package/plugins/hooks/initializeNotifications.js +17 -0
  119. package/plugins/hooks/initializeNotifications.js.map +1 -0
  120. package/plugins/hooks/listContentReviews.d.ts +4 -4
  121. package/plugins/hooks/listContentReviews.js +11 -33
  122. package/plugins/hooks/listContentReviews.js.map +1 -1
  123. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  124. package/plugins/hooks/notifications/changeRequestAfterCreate.js +113 -0
  125. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  126. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  127. package/plugins/hooks/notifications/changeRequestUrl.js +29 -0
  128. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  129. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  130. package/plugins/hooks/notifications/commentAfterCreate.js +124 -0
  131. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  132. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  133. package/plugins/hooks/notifications/commentUrl.js +29 -0
  134. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  135. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  136. package/plugins/hooks/notifications/contentReviewAfterCreate.js +96 -0
  137. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  138. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  139. package/plugins/hooks/notifications/contentReviewUrl.js +28 -0
  140. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  141. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  142. package/plugins/hooks/notifications/contentUrl.js +26 -0
  143. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  144. package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
  145. package/plugins/hooks/notifications/getAppUrl.js +19 -0
  146. package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
  147. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  148. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +23 -0
  149. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  150. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  151. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +23 -0
  152. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  153. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  154. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +23 -0
  155. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  156. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  157. package/plugins/hooks/notifications/reviewers.js +47 -0
  158. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  159. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  160. package/plugins/hooks/notifications/sendChangeRequestNotification.js +43 -0
  161. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  162. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  163. package/plugins/hooks/notifications/sendCommentNotification.js +43 -0
  164. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  165. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  166. package/plugins/hooks/notifications/sendContentReviewNotification.js +43 -0
  167. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  168. package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
  169. package/plugins/hooks/updatePendingChangeRequests.js +7 -13
  170. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  171. package/plugins/hooks/updateTotalComments.d.ts +1 -1
  172. package/plugins/hooks/updateTotalComments.js +21 -23
  173. package/plugins/hooks/updateTotalComments.js.map +1 -1
  174. package/plugins/hooks/validateChangeRequest.d.ts +1 -1
  175. package/plugins/hooks/validateChangeRequest.js +27 -16
  176. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  177. package/plugins/hooks/validateComment.d.ts +1 -1
  178. package/plugins/hooks/validateComment.js +13 -12
  179. package/plugins/hooks/validateComment.js.map +1 -1
  180. package/plugins/hooks/validateContentReview.d.ts +1 -1
  181. package/plugins/hooks/validateContentReview.js +2 -6
  182. package/plugins/hooks/validateContentReview.js.map +1 -1
  183. package/plugins/utils.d.ts +7 -7
  184. package/plugins/utils.js +12 -57
  185. package/plugins/utils.js.map +1 -1
  186. package/scheduler/createScheduleActionMethods.d.ts +1 -1
  187. package/scheduler/createScheduleActionMethods.js +105 -85
  188. package/scheduler/createScheduleActionMethods.js.map +1 -1
  189. package/scheduler/handlers/executeAction/index.d.ts +2 -2
  190. package/scheduler/handlers/executeAction/index.js +47 -41
  191. package/scheduler/handlers/executeAction/index.js.map +1 -1
  192. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  193. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +19 -9
  194. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  195. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +3 -3
  196. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +11 -28
  197. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  198. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +4 -3
  199. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
  200. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  201. package/scheduler/handlers/executeAction/security.d.ts +2 -2
  202. package/scheduler/handlers/executeAction/security.js +2 -11
  203. package/scheduler/handlers/executeAction/security.js.map +1 -1
  204. package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
  205. package/scheduler/handlers/scheduleAction/index.js +23 -38
  206. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  207. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
  208. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
  209. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  210. package/scheduler/handlers/utils.d.ts +2 -4
  211. package/scheduler/handlers/utils.js +22 -53
  212. package/scheduler/handlers/utils.js.map +1 -1
  213. package/scheduler/index.d.ts +1 -1
  214. package/scheduler/index.js +2 -3
  215. package/scheduler/index.js.map +1 -1
  216. package/scheduler/types.d.ts +20 -36
  217. package/scheduler/types.js +11 -23
  218. package/scheduler/types.js.map +1 -1
  219. package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
  220. package/storageOperations/changeRequestStorageOperations.js +43 -41
  221. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  222. package/storageOperations/commentStorageOperations.d.ts +3 -3
  223. package/storageOperations/commentStorageOperations.js +16 -44
  224. package/storageOperations/commentStorageOperations.js.map +1 -1
  225. package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
  226. package/storageOperations/contentReviewStorageOperations.js +19 -41
  227. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  228. package/storageOperations/index.d.ts +3 -9
  229. package/storageOperations/index.js +10 -29
  230. package/storageOperations/index.js.map +1 -1
  231. package/storageOperations/models/changeRequest.model.d.ts +1 -2
  232. package/storageOperations/models/changeRequest.model.js +9 -19
  233. package/storageOperations/models/changeRequest.model.js.map +1 -1
  234. package/storageOperations/models/comment.model.d.ts +1 -2
  235. package/storageOperations/models/comment.model.js +9 -18
  236. package/storageOperations/models/comment.model.js.map +1 -1
  237. package/storageOperations/models/contentReview.model.d.ts +1 -2
  238. package/storageOperations/models/contentReview.model.js +16 -41
  239. package/storageOperations/models/contentReview.model.js.map +1 -1
  240. package/storageOperations/models/index.d.ts +1 -1
  241. package/storageOperations/models/index.js +11 -55
  242. package/storageOperations/models/index.js.map +1 -1
  243. package/storageOperations/models/reviewer.model.d.ts +1 -2
  244. package/storageOperations/models/reviewer.model.js +25 -18
  245. package/storageOperations/models/reviewer.model.js.map +1 -1
  246. package/storageOperations/models/utils.d.ts +2 -2
  247. package/storageOperations/models/utils.js +2 -4
  248. package/storageOperations/models/utils.js.map +1 -1
  249. package/storageOperations/models/workflow.model.d.ts +2 -3
  250. package/storageOperations/models/workflow.model.js +22 -46
  251. package/storageOperations/models/workflow.model.js.map +1 -1
  252. package/storageOperations/reviewerStorageOperations.d.ts +3 -3
  253. package/storageOperations/reviewerStorageOperations.js +19 -38
  254. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  255. package/storageOperations/types.d.ts +2 -2
  256. package/storageOperations/types.js +3 -1
  257. package/storageOperations/types.js.map +1 -1
  258. package/storageOperations/workflowStorageOperations.d.ts +2 -2
  259. package/storageOperations/workflowStorageOperations.js +24 -44
  260. package/storageOperations/workflowStorageOperations.js.map +1 -1
  261. package/types.d.ts +66 -69
  262. package/types.js +121 -43
  263. package/types.js.map +1 -1
  264. package/utils/contentApwSettingsPlugin.d.ts +2 -2
  265. package/utils/contentApwSettingsPlugin.js +2 -6
  266. package/utils/contentApwSettingsPlugin.js.map +1 -1
  267. package/utils/errors.js +2 -17
  268. package/utils/errors.js.map +1 -1
  269. package/utils/fieldResolver.d.ts +2 -2
  270. package/utils/fieldResolver.js +8 -18
  271. package/utils/fieldResolver.js.map +1 -1
  272. package/utils/pickEntryFieldValues.d.ts +3 -0
  273. package/utils/pickEntryFieldValues.js +30 -0
  274. package/utils/pickEntryFieldValues.js.map +1 -0
  275. package/utils/resolve.d.ts +1 -1
  276. package/utils/resolve.js +2 -3
  277. package/utils/resolve.js.map +1 -1
  278. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
  279. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -51
  280. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
  281. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
  282. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -30
  283. package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
  284. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
  285. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -25
  286. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
  287. package/plugins/pageBuilder/index.d.ts +0 -11
  288. package/plugins/pageBuilder/index.js +0 -45
  289. package/plugins/pageBuilder/index.js.map +0 -1
  290. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
  291. package/plugins/pageBuilder/linkContentReviewToPage.js +0 -105
  292. package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
  293. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
  294. package/plugins/pageBuilder/linkWorkflowToPage.js +0 -194
  295. package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
  296. package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
  297. package/plugins/pageBuilder/triggerContentReview.js +0 -50
  298. package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
  299. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
  300. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -79
  301. package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
  302. package/plugins/pageBuilder/utils.d.ts +0 -22
  303. package/plugins/pageBuilder/utils.js +0 -184
  304. package/plugins/pageBuilder/utils.js.map +0 -1
  305. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
  306. package/storageOperations/models/contentModelPluginFactory.js +0 -28
  307. package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -1,32 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createContentReviewMethods = createContentReviewMethods;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _get = _interopRequireDefault(require("lodash/get"));
13
-
14
8
  var _pubsub = require("@webiny/pubsub");
15
-
16
9
  var _error = _interopRequireDefault(require("@webiny/error"));
17
-
18
10
  var _types = require("../types");
19
-
20
11
  var _utils = require("../plugins/utils");
21
-
22
12
  var _errors = require("../utils/errors");
23
-
24
13
  var _types2 = require("../scheduler/types");
25
-
26
14
  var _utils2 = require("./utils");
27
-
28
15
  var _contentApwSettingsPlugin = require("../utils/contentApwSettingsPlugin");
29
-
30
16
  function createContentReviewMethods(params) {
31
17
  const {
32
18
  getIdentity,
@@ -40,16 +26,19 @@ function createContentReviewMethods(params) {
40
26
  getTenant,
41
27
  getLocale,
42
28
  plugins
43
- } = params; // create
29
+ } = params;
44
30
 
31
+ // create
45
32
  const onContentReviewBeforeCreate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeCreate");
46
- const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate"); // update
47
-
33
+ const onContentReviewAfterCreate = (0, _pubsub.createTopic)("apw.onContentReviewAfterCreate");
34
+ // update
48
35
  const onContentReviewBeforeUpdate = (0, _pubsub.createTopic)("apw.onContentReviewBeforeUpdate");
49
- const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate"); // delete
50
-
36
+ const onContentReviewAfterUpdate = (0, _pubsub.createTopic)("apw.onContentReviewAfterUpdate");
37
+ // delete
51
38
  const onContentReviewBeforeDelete = (0, _pubsub.createTopic)("apw.onContentReviewBeforeDelete");
52
39
  const onContentReviewAfterDelete = (0, _pubsub.createTopic)("apw.onContentReviewAfterDelete");
40
+ // list
41
+ const onContentReviewBeforeList = (0, _pubsub.createTopic)("apw.onContentReviewBeforeList");
53
42
  return {
54
43
  /**
55
44
  * Lifecycle events
@@ -60,32 +49,38 @@ function createContentReviewMethods(params) {
60
49
  onContentReviewAfterUpdate,
61
50
  onContentReviewBeforeDelete,
62
51
  onContentReviewAfterDelete,
63
-
52
+ onContentReviewBeforeList,
64
53
  async get(id) {
65
54
  return storageOperations.getContentReview({
66
55
  id
67
56
  });
68
57
  },
69
-
70
58
  async list(params) {
71
- var _params$where;
72
-
73
- if (((_params$where = params.where) === null || _params$where === void 0 ? void 0 : _params$where.reviewStatus) === "requiresMyAttention") {
59
+ const where = params.where || {};
60
+ await onContentReviewBeforeList.publish({
61
+ where
62
+ });
63
+ if (where.reviewStatus === "requiresMyAttention") {
74
64
  return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
75
- listParams: params,
65
+ listParams: {
66
+ ...params,
67
+ where
68
+ },
76
69
  listContentReviews: storageOperations.listContentReviews,
77
70
  getReviewer,
78
71
  getIdentity
79
72
  });
80
73
  }
81
-
82
- return storageOperations.listContentReviews(params);
74
+ return storageOperations.listContentReviews({
75
+ ...params,
76
+ where
77
+ });
83
78
  },
84
-
85
79
  async create(data) {
86
- const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
80
+ const input = {
81
+ ...data,
87
82
  reviewStatus: _types.ApwContentReviewStatus.UNDER_REVIEW
88
- });
83
+ };
89
84
  await onContentReviewBeforeCreate.publish({
90
85
  input
91
86
  });
@@ -97,7 +92,6 @@ function createContentReviewMethods(params) {
97
92
  });
98
93
  return contentReview;
99
94
  },
100
-
101
95
  async update(id, data) {
102
96
  const original = await storageOperations.getContentReview({
103
97
  id
@@ -123,7 +117,6 @@ function createContentReviewMethods(params) {
123
117
  });
124
118
  return contentReview;
125
119
  },
126
-
127
120
  async delete(id) {
128
121
  const contentReview = await storageOperations.getContentReview({
129
122
  id
@@ -139,7 +132,6 @@ function createContentReviewMethods(params) {
139
132
  });
140
133
  return true;
141
134
  },
142
-
143
135
  async provideSignOff(id, stepId) {
144
136
  const entry = await this.get(id);
145
137
  const {
@@ -155,10 +147,10 @@ function createContentReviewMethods(params) {
155
147
  identity,
156
148
  step: currentStep
157
149
  });
150
+
158
151
  /**
159
152
  * Check whether the sign-off is requested by a reviewer.
160
153
  */
161
-
162
154
  if (!hasPermission) {
163
155
  throw new _errors.NotAuthorizedError({
164
156
  entry,
@@ -171,8 +163,6 @@ function createContentReviewMethods(params) {
171
163
  /**
172
164
  * Don't allow sign off, if previous step is of "mandatory_blocking" type and undone.
173
165
  */
174
-
175
-
176
166
  if (previousStep && previousStep.status !== _types.ApwContentReviewStepStatus.DONE && previousStep.type === _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
177
167
  throw new _errors.StepMissingError({
178
168
  entry,
@@ -185,8 +175,6 @@ function createContentReviewMethods(params) {
185
175
  /**
186
176
  * Don't allow sign off, if there are pending change requests.
187
177
  */
188
-
189
-
190
178
  if (currentStep.pendingChangeRequests > 0) {
191
179
  throw new _errors.PendingChangeRequestsError({
192
180
  entry,
@@ -199,8 +187,6 @@ function createContentReviewMethods(params) {
199
187
  /**
200
188
  * Don't allow sign off, if current step is not in "active" state.
201
189
  */
202
-
203
-
204
190
  if (currentStep.status !== _types.ApwContentReviewStepStatus.ACTIVE) {
205
191
  throw new _errors.StepInActiveError({
206
192
  entry,
@@ -210,67 +196,62 @@ function createContentReviewMethods(params) {
210
196
  }
211
197
  });
212
198
  }
213
-
214
199
  let previousStepStatus;
215
200
  /*
216
201
  * Provide sign-off for give step.
217
202
  */
218
-
219
203
  const updatedSteps = steps.map((step, index) => {
220
204
  if (index === stepIndex) {
221
205
  previousStepStatus = _types.ApwContentReviewStepStatus.DONE;
222
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
206
+ return {
207
+ ...step,
223
208
  status: _types.ApwContentReviewStepStatus.DONE,
224
209
  signOffProvidedOn: new Date().toISOString(),
225
210
  signOffProvidedBy: identity
226
- });
211
+ };
227
212
  }
228
213
  /**
229
214
  * Update next steps status based on type.
230
215
  */
231
-
232
-
233
216
  if (index > stepIndex) {
234
217
  const previousStep = steps[index - 1];
235
218
  previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
236
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
219
+ return {
220
+ ...step,
237
221
  status: previousStepStatus
238
- });
222
+ };
239
223
  }
240
-
241
224
  return step;
242
225
  });
243
226
  /**
244
227
  * Check for pending steps
245
228
  */
246
-
247
229
  let newStatus = reviewStatus;
248
230
  const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => typeof step.signOffProvidedOn !== "string");
231
+
249
232
  /**
250
233
  * If there are no required steps that are pending, set the status to "READY_TO_BE_PUBLISHED".
251
234
  */
252
-
253
235
  if (pendingRequiredSteps.length === 0) {
254
236
  newStatus = _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED;
255
237
  }
238
+
256
239
  /**
257
240
  * Save updated steps.
258
241
  */
259
-
260
-
261
242
  await this.update(id, {
262
243
  steps: updatedSteps,
263
244
  reviewStatus: newStatus
264
245
  });
265
246
  return true;
266
247
  },
267
-
268
248
  async retractSignOff(id, stepId) {
269
- const entry = await this.get(id);
249
+ const contentReview = await this.get(id);
270
250
  const {
271
251
  steps,
272
- reviewStatus
273
- } = entry;
252
+ reviewStatus,
253
+ content
254
+ } = contentReview;
274
255
  const stepIndex = steps.findIndex(step => step.id === stepId);
275
256
  const currentStep = steps[stepIndex];
276
257
  const identity = getIdentity();
@@ -279,13 +260,13 @@ function createContentReviewMethods(params) {
279
260
  identity,
280
261
  step: currentStep
281
262
  });
263
+
282
264
  /**
283
265
  * Check whether the retract sign-off is requested by a reviewer.
284
266
  */
285
-
286
267
  if (!hasPermission) {
287
268
  throw new _errors.NotAuthorizedError({
288
- entry,
269
+ entry: contentReview,
289
270
  input: {
290
271
  id,
291
272
  step: stepId
@@ -295,68 +276,75 @@ function createContentReviewMethods(params) {
295
276
  /**
296
277
  * Don't allow, if step in not "done" i.e. no sign-off was provided for it.
297
278
  */
298
-
299
-
300
279
  if (currentStep.status !== _types.ApwContentReviewStepStatus.DONE) {
301
280
  throw new _errors.NoSignOffProvidedError({
302
- entry,
281
+ entry: contentReview,
303
282
  input: {
304
283
  id,
305
284
  step: stepId
306
285
  }
307
286
  });
308
287
  }
309
-
310
288
  let previousStepStatus;
289
+
311
290
  /*
312
291
  * Retract sign-off for give step.
313
292
  */
314
-
315
293
  const updatedSteps = steps.map((step, index) => {
316
294
  if (index === stepIndex) {
317
295
  previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
318
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
296
+ return {
297
+ ...step,
319
298
  status: previousStepStatus,
320
299
  signOffProvidedOn: null,
321
300
  signOffProvidedBy: null
322
- });
301
+ };
323
302
  }
324
303
  /**
325
304
  * Set next step status as "inactive".
326
305
  */
327
-
328
-
329
306
  if (index > stepIndex) {
330
307
  const previousStep = steps[index - 1];
331
308
  previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
332
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, step), {}, {
309
+ return {
310
+ ...step,
333
311
  status: previousStepStatus
334
- });
312
+ };
335
313
  }
336
-
337
314
  return step;
338
315
  });
316
+
339
317
  /**
340
318
  * Check for pending steps
341
319
  */
342
-
343
320
  let newStatus = reviewStatus;
344
321
  const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => step.signOffProvidedOn === null);
345
322
  /**
346
323
  * If there are required steps that are pending, set the status to "UNDER_REVIEW".
347
324
  */
348
-
349
325
  if (pendingRequiredSteps.length !== 0) {
350
326
  newStatus = _types.ApwContentReviewStatus.UNDER_REVIEW;
351
327
  }
352
328
 
329
+ /**
330
+ * We need to delete the scheduled action if one was created.
331
+ */
332
+ const scheduledActionId = contentReview.content?.scheduledActionId;
333
+ if (!!scheduledActionId) {
334
+ await scheduler.delete(scheduledActionId);
335
+ }
353
336
  await this.update(id, {
337
+ content: {
338
+ ...content,
339
+ scheduledOn: null,
340
+ scheduledBy: null,
341
+ scheduledActionId: null
342
+ },
354
343
  steps: updatedSteps,
355
344
  reviewStatus: newStatus
356
345
  });
357
346
  return true;
358
347
  },
359
-
360
348
  async isReviewRequired(data) {
361
349
  const contentGetter = getContentGetter(data.type);
362
350
  const content = await contentGetter(data.id, data.settings);
@@ -366,31 +354,24 @@ function createContentReviewMethods(params) {
366
354
  plugins,
367
355
  type: data.type
368
356
  });
369
-
370
357
  if (contentApwSettingsPlugin) {
371
358
  contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);
372
359
  const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
373
-
374
360
  if (workflowId) {
375
361
  isReviewRequired = true;
376
362
  }
377
363
  }
378
-
379
364
  return {
380
365
  isReviewRequired,
381
366
  contentReviewId
382
367
  };
383
368
  },
384
-
385
369
  async publishContent(id, datetime) {
386
- var _content$settings;
387
-
388
370
  const {
389
371
  content,
390
372
  reviewStatus
391
373
  } = await this.get(id);
392
374
  const identity = getIdentity();
393
-
394
375
  if (reviewStatus !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
395
376
  throw new _error.default({
396
377
  message: `Cannot publish content because it is not yet ready to be published.`,
@@ -402,50 +383,44 @@ function createContentReviewMethods(params) {
402
383
  }
403
384
  });
404
385
  }
405
-
406
386
  (0, _utils2.checkValidDateTime)(datetime);
387
+
407
388
  /**
408
389
  * If datetime is present it means we're scheduling this action.
409
390
  * And if not, we are publishing immediately.
410
391
  */
411
-
412
392
  if (!datetime) {
413
393
  const contentPublisher = getContentPublisher(content.type);
414
394
  await contentPublisher(content.id, content.settings);
415
395
  return true;
416
396
  }
417
-
418
397
  const data = {
419
398
  action: _types2.ApwScheduleActionTypes.PUBLISH,
420
399
  type: content.type,
421
400
  entryId: content.id,
422
- modelId: (_content$settings = content.settings) === null || _content$settings === void 0 ? void 0 : _content$settings.modelId,
401
+ modelId: content.settings?.modelId,
423
402
  datetime
424
403
  };
425
404
  const scheduledActionId = await this.scheduleAction(data);
426
405
  /**
427
406
  * Update scheduled related meta data.
428
407
  */
429
-
430
408
  await this.update(id, {
431
- content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
409
+ content: {
410
+ ...content,
432
411
  scheduledOn: datetime,
433
412
  scheduledBy: identity.id,
434
413
  scheduledActionId
435
- })
414
+ }
436
415
  });
437
416
  return true;
438
417
  },
439
-
440
418
  async unpublishContent(id, datetime) {
441
- var _content$settings2;
442
-
443
419
  const {
444
420
  content,
445
421
  reviewStatus
446
422
  } = await this.get(id);
447
423
  const identity = getIdentity();
448
-
449
424
  if (reviewStatus !== _types.ApwContentReviewStatus.PUBLISHED) {
450
425
  throw new _error.default({
451
426
  message: `Cannot unpublish content because it is not yet published.`,
@@ -457,40 +432,37 @@ function createContentReviewMethods(params) {
457
432
  }
458
433
  });
459
434
  }
460
-
461
435
  (0, _utils2.checkValidDateTime)(datetime);
436
+
462
437
  /**
463
438
  * If datetime is present it means we're scheduling this action.
464
439
  * If not, we are unpublishing immediately.
465
440
  */
466
-
467
441
  if (!datetime) {
468
442
  const contentUnPublisher = getContentUnPublisher(content.type);
469
443
  await contentUnPublisher(content.id, content.settings);
470
444
  return true;
471
445
  }
472
-
473
446
  const scheduledActionId = await this.scheduleAction({
474
447
  action: _types2.ApwScheduleActionTypes.UNPUBLISH,
475
448
  type: content.type,
476
449
  entryId: content.id,
477
- modelId: (_content$settings2 = content.settings) === null || _content$settings2 === void 0 ? void 0 : _content$settings2.modelId,
450
+ modelId: content.settings?.modelId,
478
451
  datetime
479
452
  });
480
453
  /**
481
454
  * Update scheduled related meta data.
482
455
  */
483
-
484
456
  await this.update(id, {
485
- content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, content), {}, {
457
+ content: {
458
+ ...content,
486
459
  scheduledOn: datetime,
487
460
  scheduledBy: identity.id,
488
461
  scheduledActionId
489
- })
462
+ }
490
463
  });
491
464
  return true;
492
465
  },
493
-
494
466
  async scheduleAction(data) {
495
467
  // Save input in DB
496
468
  const scheduledAction = await scheduler.create(data);
@@ -498,12 +470,10 @@ function createContentReviewMethods(params) {
498
470
  * This function contains logic of lambda invocation.
499
471
  * Current we're not mocking it, therefore, we're just returning true.
500
472
  */
501
-
502
473
  if (process.env.NODE_ENV === "test") {
503
474
  return scheduledAction.id;
504
- } // Invoke handler
505
-
506
-
475
+ }
476
+ // Invoke handler
507
477
  await handlerClient.invoke({
508
478
  name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),
509
479
  payload: {
@@ -515,14 +485,13 @@ function createContentReviewMethods(params) {
515
485
  });
516
486
  return scheduledAction.id;
517
487
  },
518
-
519
488
  async deleteScheduledAction(id) {
520
489
  const contentReview = await this.get(id);
521
- const scheduledActionId = (0, _get.default)(contentReview, "content.scheduledActionId");
490
+ const scheduledActionId = contentReview.content?.scheduledActionId;
491
+
522
492
  /**
523
493
  * Check if there is any action scheduled for this "content review".
524
494
  */
525
-
526
495
  if (!scheduledActionId) {
527
496
  throw new _error.default({
528
497
  message: `There is no action scheduled for content review.`,
@@ -535,18 +504,20 @@ function createContentReviewMethods(params) {
535
504
  /**
536
505
  * Delete scheduled action.
537
506
  */
538
-
539
-
540
507
  await scheduler.delete(scheduledActionId);
508
+
541
509
  /**
542
510
  * Reset scheduled related meta data.
543
511
  */
544
-
545
512
  await this.update(id, {
546
- content: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META)
513
+ content: {
514
+ ...contentReview.content,
515
+ ..._utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META
516
+ }
547
517
  });
548
518
  return true;
549
519
  }
550
-
551
520
  };
552
- }
521
+ }
522
+
523
+ //# sourceMappingURL=createContentReviewMethods.js.map