@webiny/api-apw 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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