@webiny/api-apw 0.0.0-unstable.5e7233243f

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 (229) hide show
  1. package/ContentApwSettingsPlugin.d.ts +10 -0
  2. package/ContentApwSettingsPlugin.js +17 -0
  3. package/ContentApwSettingsPlugin.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +34 -0
  6. package/crud/createChangeRequestMethods.d.ts +2 -0
  7. package/crud/createChangeRequestMethods.js +95 -0
  8. package/crud/createChangeRequestMethods.js.map +1 -0
  9. package/crud/createCommentMethods.d.ts +2 -0
  10. package/crud/createCommentMethods.js +96 -0
  11. package/crud/createCommentMethods.js.map +1 -0
  12. package/crud/createContentReviewMethods.d.ts +10 -0
  13. package/crud/createContentReviewMethods.js +552 -0
  14. package/crud/createContentReviewMethods.js.map +1 -0
  15. package/crud/createReviewerMethods.d.ts +2 -0
  16. package/crud/createReviewerMethods.js +96 -0
  17. package/crud/createReviewerMethods.js.map +1 -0
  18. package/crud/createWorkflowMethods.d.ts +2 -0
  19. package/crud/createWorkflowMethods.js +96 -0
  20. package/crud/createWorkflowMethods.js.map +1 -0
  21. package/crud/index.d.ts +2 -0
  22. package/crud/index.js +100 -0
  23. package/crud/index.js.map +1 -0
  24. package/crud/utils.d.ts +21 -0
  25. package/crud/utils.js +142 -0
  26. package/crud/utils.js.map +1 -0
  27. package/index.d.ts +4 -0
  28. package/index.js +34 -0
  29. package/index.js.map +1 -0
  30. package/package.json +75 -0
  31. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
  32. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
  33. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
  34. package/plugins/cms/README.md +49 -0
  35. package/plugins/cms/apwEntryPlugins.d.ts +8 -0
  36. package/plugins/cms/apwEntryPlugins.js +50 -0
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -0
  38. package/plugins/cms/index.d.ts +12 -0
  39. package/plugins/cms/index.js +37 -0
  40. package/plugins/cms/index.js.map +1 -0
  41. package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
  42. package/plugins/cms/linkContentReviewToEntry.js +108 -0
  43. package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
  44. package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
  45. package/plugins/cms/linkWorkflowToEntry.js +166 -0
  46. package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
  47. package/plugins/cms/triggerContentReview.d.ts +8 -0
  48. package/plugins/cms/triggerContentReview.js +59 -0
  49. package/plugins/cms/triggerContentReview.js.map +1 -0
  50. package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
  51. package/plugins/cms/updateContentReviewStatus.js +101 -0
  52. package/plugins/cms/updateContentReviewStatus.js.map +1 -0
  53. package/plugins/cms/utils.d.ts +27 -0
  54. package/plugins/cms/utils.js +211 -0
  55. package/plugins/cms/utils.js.map +1 -0
  56. package/plugins/context.d.ts +5 -0
  57. package/plugins/context.js +146 -0
  58. package/plugins/context.js.map +1 -0
  59. package/plugins/graphql/changeRequest.gql.d.ts +4 -0
  60. package/plugins/graphql/changeRequest.gql.js +155 -0
  61. package/plugins/graphql/changeRequest.gql.js.map +1 -0
  62. package/plugins/graphql/comment.gql.d.ts +4 -0
  63. package/plugins/graphql/comment.gql.js +160 -0
  64. package/plugins/graphql/comment.gql.js.map +1 -0
  65. package/plugins/graphql/contentReview.gql.d.ts +4 -0
  66. package/plugins/graphql/contentReview.gql.js +382 -0
  67. package/plugins/graphql/contentReview.gql.js.map +1 -0
  68. package/plugins/graphql/reviewer.gql.d.ts +4 -0
  69. package/plugins/graphql/reviewer.gql.js +114 -0
  70. package/plugins/graphql/reviewer.gql.js.map +1 -0
  71. package/plugins/graphql/workflow.gql.d.ts +4 -0
  72. package/plugins/graphql/workflow.gql.js +205 -0
  73. package/plugins/graphql/workflow.gql.js.map +1 -0
  74. package/plugins/graphql.d.ts +4 -0
  75. package/plugins/graphql.js +95 -0
  76. package/plugins/graphql.js.map +1 -0
  77. package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
  78. package/plugins/hooks/createReviewerFromIdentity.js +62 -0
  79. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
  80. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
  81. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
  82. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
  83. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
  84. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
  85. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
  86. package/plugins/hooks/index.d.ts +3 -0
  87. package/plugins/hooks/index.js +68 -0
  88. package/plugins/hooks/index.js.map +1 -0
  89. package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
  90. package/plugins/hooks/initializeContentReviewSteps.js +89 -0
  91. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
  92. package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
  93. package/plugins/hooks/updatePendingChangeRequests.js +98 -0
  94. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
  95. package/plugins/hooks/updateTotalComments.d.ts +3 -0
  96. package/plugins/hooks/updateTotalComments.js +157 -0
  97. package/plugins/hooks/updateTotalComments.js.map +1 -0
  98. package/plugins/hooks/validateChangeRequest.d.ts +2 -0
  99. package/plugins/hooks/validateChangeRequest.js +64 -0
  100. package/plugins/hooks/validateChangeRequest.js.map +1 -0
  101. package/plugins/hooks/validateComment.d.ts +2 -0
  102. package/plugins/hooks/validateComment.js +47 -0
  103. package/plugins/hooks/validateComment.js.map +1 -0
  104. package/plugins/hooks/validateContentReview.d.ts +2 -0
  105. package/plugins/hooks/validateContentReview.js +38 -0
  106. package/plugins/hooks/validateContentReview.js.map +1 -0
  107. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
  108. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
  109. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
  110. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
  111. package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
  112. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
  113. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
  114. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
  115. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
  116. package/plugins/pageBuilder/index.d.ts +11 -0
  117. package/plugins/pageBuilder/index.js +45 -0
  118. package/plugins/pageBuilder/index.js.map +1 -0
  119. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
  120. package/plugins/pageBuilder/linkContentReviewToPage.js +93 -0
  121. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
  122. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
  123. package/plugins/pageBuilder/linkWorkflowToPage.js +182 -0
  124. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
  125. package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
  126. package/plugins/pageBuilder/triggerContentReview.js +50 -0
  127. package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
  128. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
  129. package/plugins/pageBuilder/updateContentReviewStatus.js +83 -0
  130. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
  131. package/plugins/pageBuilder/utils.d.ts +22 -0
  132. package/plugins/pageBuilder/utils.js +184 -0
  133. package/plugins/pageBuilder/utils.js.map +1 -0
  134. package/plugins/utils.d.ts +35 -0
  135. package/plugins/utils.js +197 -0
  136. package/plugins/utils.js.map +1 -0
  137. package/scheduler/createScheduleActionMethods.d.ts +2 -0
  138. package/scheduler/createScheduleActionMethods.js +146 -0
  139. package/scheduler/createScheduleActionMethods.js.map +1 -0
  140. package/scheduler/handlers/executeAction/index.d.ts +13 -0
  141. package/scheduler/handlers/executeAction/index.js +172 -0
  142. package/scheduler/handlers/executeAction/index.js.map +1 -0
  143. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
  144. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
  145. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
  146. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
  147. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
  148. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
  149. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
  150. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
  151. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
  152. package/scheduler/handlers/executeAction/security.d.ts +4 -0
  153. package/scheduler/handlers/executeAction/security.js +68 -0
  154. package/scheduler/handlers/executeAction/security.js.map +1 -0
  155. package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
  156. package/scheduler/handlers/scheduleAction/index.js +165 -0
  157. package/scheduler/handlers/scheduleAction/index.js.map +1 -0
  158. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
  159. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +176 -0
  160. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
  161. package/scheduler/handlers/utils.d.ts +33 -0
  162. package/scheduler/handlers/utils.js +168 -0
  163. package/scheduler/handlers/utils.js.map +1 -0
  164. package/scheduler/index.d.ts +2 -0
  165. package/scheduler/index.js +27 -0
  166. package/scheduler/index.js.map +1 -0
  167. package/scheduler/types.d.ts +171 -0
  168. package/scheduler/types.js +34 -0
  169. package/scheduler/types.js.map +1 -0
  170. package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
  171. package/storageOperations/changeRequestStorageOperations.js +126 -0
  172. package/storageOperations/changeRequestStorageOperations.js.map +1 -0
  173. package/storageOperations/commentStorageOperations.d.ts +3 -0
  174. package/storageOperations/commentStorageOperations.js +142 -0
  175. package/storageOperations/commentStorageOperations.js.map +1 -0
  176. package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
  177. package/storageOperations/contentReviewStorageOperations.js +97 -0
  178. package/storageOperations/contentReviewStorageOperations.js.map +1 -0
  179. package/storageOperations/index.d.ts +15 -0
  180. package/storageOperations/index.js +52 -0
  181. package/storageOperations/index.js.map +1 -0
  182. package/storageOperations/models/changeRequest.model.d.ts +3 -0
  183. package/storageOperations/models/changeRequest.model.js +59 -0
  184. package/storageOperations/models/changeRequest.model.js.map +1 -0
  185. package/storageOperations/models/comment.model.d.ts +7 -0
  186. package/storageOperations/models/comment.model.js +60 -0
  187. package/storageOperations/models/comment.model.js.map +1 -0
  188. package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
  189. package/storageOperations/models/contentModelPluginFactory.js +32 -0
  190. package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
  191. package/storageOperations/models/contentReview.model.d.ts +7 -0
  192. package/storageOperations/models/contentReview.model.js +257 -0
  193. package/storageOperations/models/contentReview.model.js.map +1 -0
  194. package/storageOperations/models/index.d.ts +2 -0
  195. package/storageOperations/models/index.js +115 -0
  196. package/storageOperations/models/index.js.map +1 -0
  197. package/storageOperations/models/reviewer.model.d.ts +3 -0
  198. package/storageOperations/models/reviewer.model.js +55 -0
  199. package/storageOperations/models/reviewer.model.js.map +1 -0
  200. package/storageOperations/models/utils.d.ts +3 -0
  201. package/storageOperations/models/utils.js +36 -0
  202. package/storageOperations/models/utils.js.map +1 -0
  203. package/storageOperations/models/workflow.model.d.ts +12 -0
  204. package/storageOperations/models/workflow.model.js +208 -0
  205. package/storageOperations/models/workflow.model.js.map +1 -0
  206. package/storageOperations/reviewerStorageOperations.d.ts +3 -0
  207. package/storageOperations/reviewerStorageOperations.js +93 -0
  208. package/storageOperations/reviewerStorageOperations.js.map +1 -0
  209. package/storageOperations/types.d.ts +34 -0
  210. package/storageOperations/types.js +5 -0
  211. package/storageOperations/types.js.map +1 -0
  212. package/storageOperations/workflowStorageOperations.d.ts +3 -0
  213. package/storageOperations/workflowStorageOperations.js +115 -0
  214. package/storageOperations/workflowStorageOperations.js.map +1 -0
  215. package/types.d.ts +737 -0
  216. package/types.js +69 -0
  217. package/types.js.map +1 -0
  218. package/utils/contentApwSettingsPlugin.d.ts +9 -0
  219. package/utils/contentApwSettingsPlugin.js +26 -0
  220. package/utils/contentApwSettingsPlugin.js.map +1 -0
  221. package/utils/errors.d.ts +16 -0
  222. package/utils/errors.js +75 -0
  223. package/utils/errors.js.map +1 -0
  224. package/utils/fieldResolver.d.ts +16 -0
  225. package/utils/fieldResolver.js +60 -0
  226. package/utils/fieldResolver.js.map +1 -0
  227. package/utils/resolve.d.ts +3 -0
  228. package/utils/resolve.js +18 -0
  229. package/utils/resolve.js.map +1 -0
@@ -0,0 +1,552 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createContentReviewMethods = createContentReviewMethods;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _get = _interopRequireDefault(require("lodash/get"));
13
+
14
+ var _pubsub = require("@webiny/pubsub");
15
+
16
+ var _error = _interopRequireDefault(require("@webiny/error"));
17
+
18
+ var _types = require("../types");
19
+
20
+ var _utils = require("../plugins/utils");
21
+
22
+ var _errors = require("../utils/errors");
23
+
24
+ var _types2 = require("../scheduler/types");
25
+
26
+ var _utils2 = require("./utils");
27
+
28
+ 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
+ function createContentReviewMethods(params) {
35
+ const {
36
+ getIdentity,
37
+ storageOperations,
38
+ getReviewer,
39
+ getContentGetter,
40
+ getContentPublisher,
41
+ getContentUnPublisher,
42
+ scheduler,
43
+ handlerClient,
44
+ getTenant,
45
+ getLocale,
46
+ plugins
47
+ } = 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)();
54
+ return {
55
+ /**
56
+ * Lifecycle events
57
+ */
58
+ onBeforeContentReviewCreate,
59
+ onAfterContentReviewCreate,
60
+ onBeforeContentReviewUpdate,
61
+ onAfterContentReviewUpdate,
62
+ onBeforeContentReviewDelete,
63
+ onAfterContentReviewDelete,
64
+
65
+ async get(id) {
66
+ return storageOperations.getContentReview({
67
+ id
68
+ });
69
+ },
70
+
71
+ async list(params) {
72
+ if (params.where && params.where.status === "requiresMyAttention") {
73
+ return (0, _utils2.filterContentReviewsByRequiresMyAttention)({
74
+ listParams: params,
75
+ listContentReviews: storageOperations.listContentReviews,
76
+ getReviewer,
77
+ getIdentity
78
+ });
79
+ }
80
+
81
+ return storageOperations.listContentReviews(params);
82
+ },
83
+
84
+ async create(data) {
85
+ const input = _objectSpread(_objectSpread({}, data), {}, {
86
+ status: _types.ApwContentReviewStatus.UNDER_REVIEW
87
+ });
88
+
89
+ await onBeforeContentReviewCreate.publish({
90
+ input
91
+ });
92
+ const contentReview = await storageOperations.createContentReview({
93
+ data: input
94
+ });
95
+ await onAfterContentReviewCreate.publish({
96
+ contentReview
97
+ });
98
+ return contentReview;
99
+ },
100
+
101
+ async update(id, data) {
102
+ const original = await storageOperations.getContentReview({
103
+ id
104
+ });
105
+ await onBeforeContentReviewUpdate.publish({
106
+ original,
107
+ input: {
108
+ id,
109
+ data
110
+ }
111
+ });
112
+ const contentReview = await storageOperations.updateContentReview({
113
+ id,
114
+ data
115
+ });
116
+ await onAfterContentReviewUpdate.publish({
117
+ original,
118
+ input: {
119
+ id,
120
+ data
121
+ },
122
+ contentReview
123
+ });
124
+ return contentReview;
125
+ },
126
+
127
+ async delete(id) {
128
+ const contentReview = await storageOperations.getContentReview({
129
+ id
130
+ });
131
+ await onBeforeContentReviewDelete.publish({
132
+ contentReview
133
+ });
134
+ await storageOperations.deleteContentReview({
135
+ id
136
+ });
137
+ await onAfterContentReviewDelete.publish({
138
+ contentReview
139
+ });
140
+ return true;
141
+ },
142
+
143
+ async provideSignOff(id, stepId) {
144
+ const entry = await this.get(id);
145
+ const {
146
+ steps,
147
+ status
148
+ } = entry;
149
+ const stepIndex = steps.findIndex(step => step.id === stepId);
150
+ const currentStep = steps[stepIndex];
151
+ const previousStep = steps[stepIndex - 1];
152
+ const identity = getIdentity();
153
+ const hasPermission = await (0, _utils.hasReviewer)({
154
+ getReviewer,
155
+ identity,
156
+ step: currentStep
157
+ });
158
+ /**
159
+ * Check whether the sign-off is requested by a reviewer.
160
+ */
161
+
162
+ if (!hasPermission) {
163
+ throw new _errors.NotAuthorizedError({
164
+ entry,
165
+ input: {
166
+ id,
167
+ step: stepId
168
+ }
169
+ });
170
+ }
171
+ /**
172
+ * Don't allow sign off, if previous step is of "mandatory_blocking" type and undone.
173
+ */
174
+
175
+
176
+ if (previousStep && previousStep.status !== _types.ApwContentReviewStepStatus.DONE && previousStep.type === _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
177
+ throw new _errors.StepMissingError({
178
+ entry,
179
+ input: {
180
+ id,
181
+ step: stepId
182
+ }
183
+ });
184
+ }
185
+ /**
186
+ * Don't allow sign off, if there are pending change requests.
187
+ */
188
+
189
+
190
+ if (currentStep.pendingChangeRequests > 0) {
191
+ throw new _errors.PendingChangeRequestsError({
192
+ entry,
193
+ input: {
194
+ id,
195
+ step: stepId
196
+ }
197
+ });
198
+ }
199
+ /**
200
+ * Don't allow sign off, if current step is not in "active" state.
201
+ */
202
+
203
+
204
+ if (currentStep.status !== _types.ApwContentReviewStepStatus.ACTIVE) {
205
+ throw new _errors.StepInActiveError({
206
+ entry,
207
+ input: {
208
+ id,
209
+ step: stepId
210
+ }
211
+ });
212
+ }
213
+
214
+ let previousStepStatus;
215
+ /*
216
+ * Provide sign-off for give step.
217
+ */
218
+
219
+ const updatedSteps = steps.map((step, index) => {
220
+ if (index === stepIndex) {
221
+ previousStepStatus = _types.ApwContentReviewStepStatus.DONE;
222
+ return _objectSpread(_objectSpread({}, step), {}, {
223
+ status: _types.ApwContentReviewStepStatus.DONE,
224
+ signOffProvidedOn: new Date().toISOString(),
225
+ signOffProvidedBy: identity
226
+ });
227
+ }
228
+ /**
229
+ * Update next steps status based on type.
230
+ */
231
+
232
+
233
+ if (index > stepIndex) {
234
+ const previousStep = steps[index - 1];
235
+ previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
236
+ return _objectSpread(_objectSpread({}, step), {}, {
237
+ status: previousStepStatus
238
+ });
239
+ }
240
+
241
+ return step;
242
+ });
243
+ /**
244
+ * Check for pending steps
245
+ */
246
+
247
+ let newStatus = status;
248
+ const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => typeof step.signOffProvidedOn !== "string");
249
+ /**
250
+ * If there are no required steps that are pending, set the status to "READY_TO_BE_PUBLISHED".
251
+ */
252
+
253
+ if (pendingRequiredSteps.length === 0) {
254
+ newStatus = _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED;
255
+ }
256
+ /**
257
+ * Save updated steps.
258
+ */
259
+
260
+
261
+ await this.update(id, {
262
+ steps: updatedSteps,
263
+ status: newStatus
264
+ });
265
+ return true;
266
+ },
267
+
268
+ async retractSignOff(id, stepId) {
269
+ const entry = await this.get(id);
270
+ const {
271
+ steps,
272
+ status
273
+ } = entry;
274
+ const stepIndex = steps.findIndex(step => step.id === stepId);
275
+ const currentStep = steps[stepIndex];
276
+ const identity = getIdentity();
277
+ const hasPermission = await (0, _utils.hasReviewer)({
278
+ getReviewer,
279
+ identity,
280
+ step: currentStep
281
+ });
282
+ /**
283
+ * Check whether the retract sign-off is requested by a reviewer.
284
+ */
285
+
286
+ if (!hasPermission) {
287
+ throw new _errors.NotAuthorizedError({
288
+ entry,
289
+ input: {
290
+ id,
291
+ step: stepId
292
+ }
293
+ });
294
+ }
295
+ /**
296
+ * Don't allow, if step in not "done" i.e. no sign-off was provided for it.
297
+ */
298
+
299
+
300
+ if (currentStep.status !== _types.ApwContentReviewStepStatus.DONE) {
301
+ throw new _errors.NoSignOffProvidedError({
302
+ entry,
303
+ input: {
304
+ id,
305
+ step: stepId
306
+ }
307
+ });
308
+ }
309
+
310
+ let previousStepStatus;
311
+ /*
312
+ * Retract sign-off for give step.
313
+ */
314
+
315
+ const updatedSteps = steps.map((step, index) => {
316
+ if (index === stepIndex) {
317
+ previousStepStatus = _types.ApwContentReviewStepStatus.ACTIVE;
318
+ return _objectSpread(_objectSpread({}, step), {}, {
319
+ status: previousStepStatus,
320
+ signOffProvidedOn: null,
321
+ signOffProvidedBy: null
322
+ });
323
+ }
324
+ /**
325
+ * Set next step status as "inactive".
326
+ */
327
+
328
+
329
+ if (index > stepIndex) {
330
+ const previousStep = steps[index - 1];
331
+ previousStepStatus = (0, _utils.getNextStepStatus)(previousStep.type, previousStepStatus);
332
+ return _objectSpread(_objectSpread({}, step), {}, {
333
+ status: previousStepStatus
334
+ });
335
+ }
336
+
337
+ return step;
338
+ });
339
+ /**
340
+ * Check for pending steps
341
+ */
342
+
343
+ let newStatus = status;
344
+ const pendingRequiredSteps = (0, _utils2.getPendingRequiredSteps)(updatedSteps, step => step.signOffProvidedOn === null);
345
+ /**
346
+ * If there are required steps that are pending, set the status to "UNDER_REVIEW".
347
+ */
348
+
349
+ if (pendingRequiredSteps.length !== 0) {
350
+ newStatus = _types.ApwContentReviewStatus.UNDER_REVIEW;
351
+ }
352
+
353
+ await this.update(id, {
354
+ steps: updatedSteps,
355
+ status: newStatus
356
+ });
357
+ return true;
358
+ },
359
+
360
+ async isReviewRequired(data) {
361
+ const contentGetter = getContentGetter(data.type);
362
+ const content = await contentGetter(data.id, data.settings);
363
+ let isReviewRequired = false;
364
+ let contentReviewId = null;
365
+ const contentApwSettingsPlugin = (0, _contentApwSettingsPlugin.getContentApwSettingsPlugin)({
366
+ plugins,
367
+ type: data.type
368
+ });
369
+
370
+ if (contentApwSettingsPlugin) {
371
+ contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);
372
+ const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
373
+
374
+ if (workflowId) {
375
+ isReviewRequired = true;
376
+ }
377
+ }
378
+
379
+ return {
380
+ isReviewRequired,
381
+ contentReviewId
382
+ };
383
+ },
384
+
385
+ async publishContent(id, datetime) {
386
+ var _content$settings;
387
+
388
+ const {
389
+ content,
390
+ status
391
+ } = await this.get(id);
392
+ const identity = getIdentity();
393
+
394
+ if (status !== _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
395
+ throw new _error.default({
396
+ message: `Cannot publish content because it is not yet ready to be published.`,
397
+ code: "NOT_READY_TO_BE_PUBLISHED",
398
+ data: {
399
+ id,
400
+ status,
401
+ content
402
+ }
403
+ });
404
+ }
405
+
406
+ (0, _utils2.checkValidDateTime)(datetime);
407
+ /**
408
+ * If datetime is present it means we're scheduling this action.
409
+ * And if not, we are publishing immediately.
410
+ */
411
+
412
+ if (!datetime) {
413
+ const contentPublisher = getContentPublisher(content.type);
414
+ await contentPublisher(content.id, content.settings);
415
+ return true;
416
+ }
417
+
418
+ const data = {
419
+ action: _types2.ApwScheduleActionTypes.PUBLISH,
420
+ type: content.type,
421
+ entryId: content.id,
422
+ modelId: (_content$settings = content.settings) === null || _content$settings === void 0 ? void 0 : _content$settings.modelId,
423
+ datetime
424
+ };
425
+ const scheduledActionId = await this.scheduleAction(data);
426
+ /**
427
+ * Update scheduled related meta data.
428
+ */
429
+
430
+ await this.update(id, {
431
+ content: _objectSpread(_objectSpread({}, content), {}, {
432
+ scheduledOn: datetime,
433
+ scheduledBy: identity.id,
434
+ scheduledActionId
435
+ })
436
+ });
437
+ return true;
438
+ },
439
+
440
+ async unpublishContent(id, datetime) {
441
+ var _content$settings2;
442
+
443
+ const {
444
+ content,
445
+ status
446
+ } = await this.get(id);
447
+ const identity = getIdentity();
448
+
449
+ if (status !== _types.ApwContentReviewStatus.PUBLISHED) {
450
+ throw new _error.default({
451
+ message: `Cannot unpublish content because it is not yet published.`,
452
+ code: "NOT_YET_PUBLISHED",
453
+ data: {
454
+ id,
455
+ status,
456
+ content
457
+ }
458
+ });
459
+ }
460
+
461
+ (0, _utils2.checkValidDateTime)(datetime);
462
+ /**
463
+ * If datetime is present it means we're scheduling this action.
464
+ * If not, we are unpublishing immediately.
465
+ */
466
+
467
+ if (!datetime) {
468
+ const contentUnPublisher = getContentUnPublisher(content.type);
469
+ await contentUnPublisher(content.id, content.settings);
470
+ return true;
471
+ }
472
+
473
+ const scheduledActionId = await this.scheduleAction({
474
+ action: _types2.ApwScheduleActionTypes.UNPUBLISH,
475
+ type: content.type,
476
+ entryId: content.id,
477
+ modelId: (_content$settings2 = content.settings) === null || _content$settings2 === void 0 ? void 0 : _content$settings2.modelId,
478
+ datetime
479
+ });
480
+ /**
481
+ * Update scheduled related meta data.
482
+ */
483
+
484
+ await this.update(id, {
485
+ content: _objectSpread(_objectSpread({}, content), {}, {
486
+ scheduledOn: datetime,
487
+ scheduledBy: identity.id,
488
+ scheduledActionId
489
+ })
490
+ });
491
+ return true;
492
+ },
493
+
494
+ async scheduleAction(data) {
495
+ // Save input in DB
496
+ const scheduledAction = await scheduler.create(data);
497
+ /**
498
+ * This function contains logic of lambda invocation.
499
+ * Current we're not mocking it, therefore, we're just returning true.
500
+ */
501
+
502
+ if (process.env.NODE_ENV === "test") {
503
+ return scheduledAction.id;
504
+ } // Invoke handler
505
+
506
+
507
+ await handlerClient.invoke({
508
+ name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),
509
+ payload: {
510
+ tenant: getTenant().id,
511
+ locale: getLocale().code
512
+ },
513
+ await: false,
514
+ description: "APW scheduler handler"
515
+ });
516
+ return scheduledAction.id;
517
+ },
518
+
519
+ async deleteScheduledAction(id) {
520
+ const contentReview = await this.get(id);
521
+ const scheduledActionId = (0, _get.default)(contentReview, "content.scheduledActionId");
522
+ /**
523
+ * Check if there is any action scheduled for this "content review".
524
+ */
525
+
526
+ if (!scheduledActionId) {
527
+ throw new _error.default({
528
+ message: `There is no action scheduled for content review.`,
529
+ code: "NO_ACTION_SCHEDULED",
530
+ data: {
531
+ id
532
+ }
533
+ });
534
+ }
535
+ /**
536
+ * Delete scheduled action.
537
+ */
538
+
539
+
540
+ await scheduler.delete(scheduledActionId);
541
+ /**
542
+ * Reset scheduled related meta data.
543
+ */
544
+
545
+ await this.update(id, {
546
+ content: _objectSpread(_objectSpread({}, contentReview.content), _utils2.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META)
547
+ });
548
+ return true;
549
+ }
550
+
551
+ };
552
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentReviewMethods","params","getIdentity","storageOperations","getReviewer","getContentGetter","getContentPublisher","getContentUnPublisher","scheduler","handlerClient","getTenant","getLocale","plugins","onBeforeContentReviewCreate","createTopic","onAfterContentReviewCreate","onBeforeContentReviewUpdate","onAfterContentReviewUpdate","onBeforeContentReviewDelete","onAfterContentReviewDelete","get","id","getContentReview","list","where","status","filterContentReviewsByRequiresMyAttention","listParams","listContentReviews","create","data","input","ApwContentReviewStatus","UNDER_REVIEW","publish","contentReview","createContentReview","update","original","updateContentReview","delete","deleteContentReview","provideSignOff","stepId","entry","steps","stepIndex","findIndex","step","currentStep","previousStep","identity","hasPermission","hasReviewer","NotAuthorizedError","ApwContentReviewStepStatus","DONE","type","ApwWorkflowStepTypes","MANDATORY_BLOCKING","StepMissingError","pendingChangeRequests","PendingChangeRequestsError","ACTIVE","StepInActiveError","previousStepStatus","updatedSteps","map","index","signOffProvidedOn","Date","toISOString","signOffProvidedBy","getNextStepStatus","newStatus","pendingRequiredSteps","getPendingRequiredSteps","length","READY_TO_BE_PUBLISHED","retractSignOff","NoSignOffProvidedError","isReviewRequired","contentGetter","content","settings","contentReviewId","contentApwSettingsPlugin","getContentApwSettingsPlugin","getContentReviewId","workflowId","getWorkflowId","publishContent","datetime","Error","message","code","checkValidDateTime","contentPublisher","action","ApwScheduleActionTypes","PUBLISH","entryId","modelId","scheduledActionId","scheduleAction","scheduledOn","scheduledBy","unpublishContent","PUBLISHED","contentUnPublisher","UNPUBLISH","scheduledAction","process","env","NODE_ENV","invoke","name","String","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","payload","tenant","locale","await","description","deleteScheduledAction","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META"],"sources":["createContentReviewMethods.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReview,\n ApwContentReviewCrud,\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwReviewerCrud,\n ApwScheduleActionData,\n ApwWorkflowStepTypes,\n CreateApwParams,\n OnAfterContentReviewCreateTopicParams,\n OnAfterContentReviewDeleteTopicParams,\n OnAfterContentReviewUpdateTopicParams,\n OnBeforeContentReviewCreateTopicParams,\n OnBeforeContentReviewDeleteTopicParams,\n OnBeforeContentReviewUpdateTopicParams\n} from \"~/types\";\nimport { getNextStepStatus, hasReviewer } from \"~/plugins/utils\";\nimport {\n NoSignOffProvidedError,\n NotAuthorizedError,\n PendingChangeRequestsError,\n StepInActiveError,\n StepMissingError\n} from \"~/utils/errors\";\nimport { ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport {\n checkValidDateTime,\n filterContentReviewsByRequiresMyAttention,\n getPendingRequiredSteps,\n INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n} from \"./utils\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\nexport interface CreateContentReviewMethodsParams extends CreateApwParams {\n getReviewer: ApwReviewerCrud[\"get\"];\n getContentGetter: AdvancedPublishingWorkflow[\"getContentGetter\"];\n getContentPublisher: AdvancedPublishingWorkflow[\"getContentPublisher\"];\n getContentUnPublisher: AdvancedPublishingWorkflow[\"getContentUnPublisher\"];\n plugins: PluginsContainer;\n}\n\nexport function createContentReviewMethods(\n params: CreateContentReviewMethodsParams\n): ApwContentReviewCrud {\n const {\n getIdentity,\n storageOperations,\n getReviewer,\n getContentGetter,\n getContentPublisher,\n getContentUnPublisher,\n scheduler,\n handlerClient,\n getTenant,\n getLocale,\n plugins\n } = params;\n\n const onBeforeContentReviewCreate = createTopic<OnBeforeContentReviewCreateTopicParams>();\n const onAfterContentReviewCreate = createTopic<OnAfterContentReviewCreateTopicParams>();\n const onBeforeContentReviewUpdate = createTopic<OnBeforeContentReviewUpdateTopicParams>();\n const onAfterContentReviewUpdate = createTopic<OnAfterContentReviewUpdateTopicParams>();\n const onBeforeContentReviewDelete = createTopic<OnBeforeContentReviewDeleteTopicParams>();\n const onAfterContentReviewDelete = createTopic<OnAfterContentReviewDeleteTopicParams>();\n return {\n /**\n * Lifecycle events\n */\n onBeforeContentReviewCreate,\n onAfterContentReviewCreate,\n onBeforeContentReviewUpdate,\n onAfterContentReviewUpdate,\n onBeforeContentReviewDelete,\n onAfterContentReviewDelete,\n async get(id) {\n return storageOperations.getContentReview({ id });\n },\n async list(params) {\n if (params.where && params.where.status === \"requiresMyAttention\") {\n return filterContentReviewsByRequiresMyAttention({\n listParams: params,\n listContentReviews: storageOperations.listContentReviews,\n getReviewer,\n getIdentity\n });\n }\n\n return storageOperations.listContentReviews(params);\n },\n async create(data) {\n const input = {\n ...data,\n status: ApwContentReviewStatus.UNDER_REVIEW\n };\n await onBeforeContentReviewCreate.publish({ input });\n\n const contentReview = await storageOperations.createContentReview({\n data: input\n });\n\n await onAfterContentReviewCreate.publish({ contentReview });\n\n return contentReview;\n },\n async update(id, data) {\n const original = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewUpdate.publish({ original, input: { id, data } });\n\n const contentReview = await storageOperations.updateContentReview({\n id,\n data\n });\n\n await onAfterContentReviewUpdate.publish({\n original,\n input: { id, data },\n contentReview\n });\n\n return contentReview;\n },\n async delete(id) {\n const contentReview = await storageOperations.getContentReview({ id });\n\n await onBeforeContentReviewDelete.publish({ contentReview });\n\n await storageOperations.deleteContentReview({ id });\n\n await onAfterContentReviewDelete.publish({ contentReview });\n\n return true;\n },\n async provideSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n const previousStep = steps[stepIndex - 1];\n\n const identity = getIdentity();\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if previous step is of \"mandatory_blocking\" type and undone.\n */\n if (\n previousStep &&\n previousStep.status !== ApwContentReviewStepStatus.DONE &&\n previousStep.type === ApwWorkflowStepTypes.MANDATORY_BLOCKING\n ) {\n throw new StepMissingError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if there are pending change requests.\n */\n if (currentStep.pendingChangeRequests > 0) {\n throw new PendingChangeRequestsError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow sign off, if current step is not in \"active\" state.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.ACTIVE) {\n throw new StepInActiveError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n /*\n * Provide sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.DONE;\n return {\n ...step,\n status: ApwContentReviewStepStatus.DONE,\n signOffProvidedOn: new Date().toISOString(),\n signOffProvidedBy: identity\n };\n }\n /**\n * Update next steps status based on type.\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => typeof step.signOffProvidedOn !== \"string\"\n );\n\n /**\n * If there are no required steps that are pending, set the status to \"READY_TO_BE_PUBLISHED\".\n */\n if (pendingRequiredSteps.length === 0) {\n newStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n /**\n * Save updated steps.\n */\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async retractSignOff(this: ApwContentReviewCrud, id, stepId) {\n const entry: ApwContentReview = await this.get(id);\n const { steps, status } = entry;\n const stepIndex = steps.findIndex(step => step.id === stepId);\n const currentStep = steps[stepIndex];\n\n const identity = getIdentity();\n\n const hasPermission = await hasReviewer({\n getReviewer,\n identity,\n step: currentStep\n });\n\n /**\n * Check whether the retract sign-off is requested by a reviewer.\n */\n if (!hasPermission) {\n throw new NotAuthorizedError({ entry, input: { id, step: stepId } });\n }\n /**\n * Don't allow, if step in not \"done\" i.e. no sign-off was provided for it.\n */\n if (currentStep.status !== ApwContentReviewStepStatus.DONE) {\n throw new NoSignOffProvidedError({ entry, input: { id, step: stepId } });\n }\n let previousStepStatus: ApwContentReviewStepStatus;\n\n /*\n * Retract sign-off for give step.\n */\n const updatedSteps = steps.map((step, index) => {\n if (index === stepIndex) {\n previousStepStatus = ApwContentReviewStepStatus.ACTIVE;\n return {\n ...step,\n status: previousStepStatus,\n signOffProvidedOn: null,\n signOffProvidedBy: null\n };\n }\n /**\n * Set next step status as \"inactive\".\n */\n if (index > stepIndex) {\n const previousStep = steps[index - 1];\n\n previousStepStatus = getNextStepStatus(previousStep.type, previousStepStatus);\n\n return {\n ...step,\n status: previousStepStatus\n };\n }\n\n return step;\n });\n\n /**\n * Check for pending steps\n */\n let newStatus = status;\n const pendingRequiredSteps = getPendingRequiredSteps(\n updatedSteps,\n step => step.signOffProvidedOn === null\n );\n /**\n * If there are required steps that are pending, set the status to \"UNDER_REVIEW\".\n */\n if (pendingRequiredSteps.length !== 0) {\n newStatus = ApwContentReviewStatus.UNDER_REVIEW;\n }\n\n await this.update(id, {\n steps: updatedSteps,\n status: newStatus\n });\n return true;\n },\n async isReviewRequired(data) {\n const contentGetter = getContentGetter(data.type);\n const content = await contentGetter(data.id, data.settings);\n\n let isReviewRequired = false;\n let contentReviewId: string | null = null;\n\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type: data.type\n });\n\n if (contentApwSettingsPlugin) {\n contentReviewId = contentApwSettingsPlugin.getContentReviewId(content);\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n if (workflowId) {\n isReviewRequired = true;\n }\n }\n\n return {\n isReviewRequired,\n contentReviewId\n };\n },\n async publishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n throw new Error({\n message: `Cannot publish content because it is not yet ready to be published.`,\n code: \"NOT_READY_TO_BE_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * And if not, we are publishing immediately.\n */\n if (!datetime) {\n const contentPublisher = getContentPublisher(content.type);\n\n await contentPublisher(content.id, content.settings);\n\n return true;\n }\n\n const data: ApwScheduleActionData = {\n action: ApwScheduleActionTypes.PUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n };\n const scheduledActionId = await this.scheduleAction(data);\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async unpublishContent(this: ApwContentReviewCrud, id: string, datetime) {\n const { content, status } = await this.get(id);\n const identity = getIdentity();\n\n if (status !== ApwContentReviewStatus.PUBLISHED) {\n throw new Error({\n message: `Cannot unpublish content because it is not yet published.`,\n code: \"NOT_YET_PUBLISHED\",\n data: {\n id,\n status,\n content\n }\n });\n }\n checkValidDateTime(datetime);\n\n /**\n * If datetime is present it means we're scheduling this action.\n * If not, we are unpublishing immediately.\n */\n if (!datetime) {\n const contentUnPublisher = getContentUnPublisher(content.type);\n\n await contentUnPublisher(content.id, content.settings);\n\n return true;\n }\n\n const scheduledActionId = await this.scheduleAction({\n action: ApwScheduleActionTypes.UNPUBLISH,\n type: content.type,\n entryId: content.id,\n modelId: content.settings?.modelId,\n datetime\n });\n /**\n * Update scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...content,\n scheduledOn: datetime,\n scheduledBy: identity.id,\n scheduledActionId\n }\n });\n\n return true;\n },\n async scheduleAction(data) {\n // Save input in DB\n const scheduledAction = await scheduler.create(data);\n /**\n * This function contains logic of lambda invocation.\n * Current we're not mocking it, therefore, we're just returning true.\n */\n if (process.env.NODE_ENV === \"test\") {\n return scheduledAction.id;\n }\n // Invoke handler\n await handlerClient.invoke({\n name: String(process.env.APW_SCHEDULER_SCHEDULE_ACTION_HANDLER),\n payload: {\n tenant: getTenant().id,\n locale: getLocale().code\n },\n await: false,\n description: \"APW scheduler handler\"\n });\n return scheduledAction.id;\n },\n async deleteScheduledAction(id) {\n const contentReview = await this.get(id);\n const scheduledActionId = get(contentReview, \"content.scheduledActionId\");\n\n /**\n * Check if there is any action scheduled for this \"content review\".\n */\n if (!scheduledActionId) {\n throw new Error({\n message: `There is no action scheduled for content review.`,\n code: \"NO_ACTION_SCHEDULED\",\n data: {\n id\n }\n });\n }\n /**\n * Delete scheduled action.\n */\n await scheduler.delete(scheduledActionId);\n\n /**\n * Reset scheduled related meta data.\n */\n await this.update(id, {\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META\n }\n });\n\n return true;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAiBA;;AACA;;AAOA;;AACA;;AAMA;;;;;;AAWO,SAASA,0BAAT,CACHC,MADG,EAEiB;EACpB,MAAM;IACFC,WADE;IAEFC,iBAFE;IAGFC,WAHE;IAIFC,gBAJE;IAKFC,mBALE;IAMFC,qBANE;IAOFC,SAPE;IAQFC,aARE;IASFC,SATE;IAUFC,SAVE;IAWFC;EAXE,IAYFX,MAZJ;EAcA,MAAMY,2BAA2B,GAAG,IAAAC,mBAAA,GAApC;EACA,MAAMC,0BAA0B,GAAG,IAAAD,mBAAA,GAAnC;EACA,MAAME,2BAA2B,GAAG,IAAAF,mBAAA,GAApC;EACA,MAAMG,0BAA0B,GAAG,IAAAH,mBAAA,GAAnC;EACA,MAAMI,2BAA2B,GAAG,IAAAJ,mBAAA,GAApC;EACA,MAAMK,0BAA0B,GAAG,IAAAL,mBAAA,GAA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,GAAR,CAAYC,QAAZ,KAAyB,MAA7B,EAAqC;QACjC,OAAOH,eAAe,CAAC1F,EAAvB;MACH,CATsB,CAUvB;;;MACA,MAAMZ,aAAa,CAAC0G,MAAd,CAAqB;QACvBC,IAAI,EAAEC,MAAM,CAACL,OAAO,CAACC,GAAR,CAAYK,qCAAb,CADW;QAEvBC,OAAO,EAAE;UACLC,MAAM,EAAE9G,SAAS,GAAGW,EADf;UAELoG,MAAM,EAAE9G,SAAS,GAAGoF;QAFf,CAFc;QAMvB2B,KAAK,EAAE,KANgB;QAOvBC,WAAW,EAAE;MAPU,CAArB,CAAN;MASA,OAAOZ,eAAe,CAAC1F,EAAvB;IACH,CAxYE;;IAyYH,MAAMuG,qBAAN,CAA4BvG,EAA5B,EAAgC;MAC5B,MAAMc,aAAa,GAAG,MAAM,KAAKf,GAAL,CAASC,EAAT,CAA5B;MACA,MAAMkF,iBAAiB,GAAG,IAAAnF,YAAA,EAAIe,aAAJ,EAAmB,2BAAnB,CAA1B;MAEA;AACZ;AACA;;MACY,IAAI,CAACoE,iBAAL,EAAwB;QACpB,MAAM,IAAIV,cAAJ,CAAU;UACZC,OAAO,EAAG,kDADE;UAEZC,IAAI,EAAE,qBAFM;UAGZjE,IAAI,EAAE;YACFT;UADE;QAHM,CAAV,CAAN;MAOH;MACD;AACZ;AACA;;;MACY,MAAMb,SAAS,CAACgC,MAAV,CAAiB+D,iBAAjB,CAAN;MAEA;AACZ;AACA;;MACY,MAAM,KAAKlE,MAAL,CAAYhB,EAAZ,EAAgB;QAClB8D,OAAO,kCACAhD,aAAa,CAACgD,OADd,GAEA0C,oDAFA;MADW,CAAhB,CAAN;MAOA,OAAO,IAAP;IACH;;EAzaE,CAAP;AA2aH"}
@@ -0,0 +1,2 @@
1
+ import { ApwReviewerCrud, CreateApwParams } from "../types";
2
+ export declare function createReviewerMethods({ storageOperations }: CreateApwParams): ApwReviewerCrud;