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

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