@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.8feaff8c32

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 (248) 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 +89 -128
  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 +2 -3
  31. package/index.js +6 -16
  32. package/index.js.map +1 -1
  33. package/package.json +40 -46
  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 +6 -23
  41. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  42. package/plugins/cms/linkWorkflowToEntry.js +14 -43
  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 +6 -20
  57. package/plugins/cms/triggerContentReview.js.map +1 -1
  58. package/plugins/cms/updateContentReviewStatus.js +14 -36
  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.d.ts +0 -1
  63. package/plugins/context.js +3 -48
  64. package/plugins/context.js.map +1 -1
  65. package/plugins/graphql/changeRequest.gql.js +4 -11
  66. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  67. package/plugins/graphql/comment.gql.js +4 -11
  68. package/plugins/graphql/comment.gql.js.map +1 -1
  69. package/plugins/graphql/contentReview.gql.js +10 -29
  70. package/plugins/graphql/contentReview.gql.js.map +1 -1
  71. package/plugins/graphql/reviewer.gql.js +6 -11
  72. package/plugins/graphql/reviewer.gql.js.map +1 -1
  73. package/plugins/graphql/workflow.gql.js +4 -11
  74. package/plugins/graphql/workflow.gql.js.map +1 -1
  75. package/plugins/graphql.js +4 -19
  76. package/plugins/graphql.js.map +1 -1
  77. package/plugins/hooks/createReviewerFromIdentity.js +26 -15
  78. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  79. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
  80. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  81. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
  82. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  83. package/plugins/hooks/index.js +4 -12
  84. package/plugins/hooks/index.js.map +1 -1
  85. package/plugins/hooks/initializeContentReviewSteps.js +15 -25
  86. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  87. package/plugins/hooks/initializeNotifications.d.ts +2 -0
  88. package/plugins/hooks/initializeNotifications.js +15 -0
  89. package/plugins/hooks/initializeNotifications.js.map +1 -0
  90. package/plugins/hooks/listContentReviews.d.ts +10 -0
  91. package/plugins/hooks/listContentReviews.js +56 -0
  92. package/plugins/hooks/listContentReviews.js.map +1 -0
  93. package/plugins/hooks/notifications/appUrl.d.ts +2 -0
  94. package/plugins/hooks/notifications/appUrl.js +18 -0
  95. package/plugins/hooks/notifications/appUrl.js.map +1 -0
  96. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
  97. package/plugins/hooks/notifications/changeRequestAfterCreate.js +111 -0
  98. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
  99. package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
  100. package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
  101. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
  102. package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
  103. package/plugins/hooks/notifications/commentAfterCreate.js +122 -0
  104. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
  105. package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
  106. package/plugins/hooks/notifications/commentUrl.js +27 -0
  107. package/plugins/hooks/notifications/commentUrl.js.map +1 -0
  108. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
  109. package/plugins/hooks/notifications/contentReviewAfterCreate.js +94 -0
  110. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
  111. package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
  112. package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
  113. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
  114. package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
  115. package/plugins/hooks/notifications/contentUrl.js +24 -0
  116. package/plugins/hooks/notifications/contentUrl.js.map +1 -0
  117. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
  118. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
  119. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
  120. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
  121. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
  122. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
  123. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
  124. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
  125. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
  126. package/plugins/hooks/notifications/reviewers.d.ts +15 -0
  127. package/plugins/hooks/notifications/reviewers.js +45 -0
  128. package/plugins/hooks/notifications/reviewers.js.map +1 -0
  129. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
  130. package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
  131. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
  132. package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
  133. package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
  134. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
  135. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
  136. package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
  137. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
  138. package/plugins/hooks/updatePendingChangeRequests.js +7 -19
  139. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  140. package/plugins/hooks/updateTotalComments.js +14 -27
  141. package/plugins/hooks/updateTotalComments.js.map +1 -1
  142. package/plugins/hooks/validateChangeRequest.js +27 -18
  143. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  144. package/plugins/hooks/validateComment.js +13 -14
  145. package/plugins/hooks/validateComment.js.map +1 -1
  146. package/plugins/hooks/validateContentReview.js +2 -8
  147. package/plugins/hooks/validateContentReview.js.map +1 -1
  148. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
  149. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  150. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  151. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  152. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  153. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  154. package/plugins/pageBuilder/index.js +5 -8
  155. package/plugins/pageBuilder/index.js.map +1 -1
  156. package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
  157. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  158. package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
  159. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  160. package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
  161. package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
  162. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
  163. package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
  164. package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
  165. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
  166. package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
  167. package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
  168. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
  169. package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
  170. package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
  171. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
  172. package/plugins/pageBuilder/triggerContentReview.js +3 -14
  173. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  174. package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
  175. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  176. package/plugins/pageBuilder/utils.js +2 -36
  177. package/plugins/pageBuilder/utils.js.map +1 -1
  178. package/plugins/utils.d.ts +1 -1
  179. package/plugins/utils.js +4 -57
  180. package/plugins/utils.js.map +1 -1
  181. package/scheduler/createScheduleActionMethods.js +15 -36
  182. package/scheduler/createScheduleActionMethods.js.map +1 -1
  183. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  184. package/scheduler/handlers/executeAction/index.js +45 -39
  185. package/scheduler/handlers/executeAction/index.js.map +1 -1
  186. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  187. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +15 -6
  188. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  189. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  190. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +8 -24
  191. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  192. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  193. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +8 -87
  194. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  195. package/scheduler/handlers/executeAction/security.js +0 -11
  196. package/scheduler/handlers/executeAction/security.js.map +1 -1
  197. package/scheduler/handlers/scheduleAction/index.js +21 -38
  198. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  199. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +9 -32
  200. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  201. package/scheduler/handlers/utils.d.ts +0 -1
  202. package/scheduler/handlers/utils.js +4 -42
  203. package/scheduler/handlers/utils.js.map +1 -1
  204. package/scheduler/index.js +0 -3
  205. package/scheduler/index.js.map +1 -1
  206. package/scheduler/types.d.ts +2 -20
  207. package/scheduler/types.js +12 -23
  208. package/scheduler/types.js.map +1 -1
  209. package/storageOperations/changeRequestStorageOperations.js +22 -45
  210. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  211. package/storageOperations/commentStorageOperations.js +25 -50
  212. package/storageOperations/commentStorageOperations.js.map +1 -1
  213. package/storageOperations/contentReviewStorageOperations.js +22 -43
  214. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  215. package/storageOperations/index.js +5 -23
  216. package/storageOperations/index.js.map +1 -1
  217. package/storageOperations/models/changeRequest.model.js +0 -9
  218. package/storageOperations/models/changeRequest.model.js.map +1 -1
  219. package/storageOperations/models/comment.model.js +0 -8
  220. package/storageOperations/models/comment.model.js.map +1 -1
  221. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
  222. package/storageOperations/models/contentModelPluginFactory.js +5 -17
  223. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  224. package/storageOperations/models/contentReview.model.js +6 -31
  225. package/storageOperations/models/contentReview.model.js.map +1 -1
  226. package/storageOperations/models/index.js +3 -29
  227. package/storageOperations/models/index.js.map +1 -1
  228. package/storageOperations/models/reviewer.model.js +17 -9
  229. package/storageOperations/models/reviewer.model.js.map +1 -1
  230. package/storageOperations/models/utils.js +3 -6
  231. package/storageOperations/models/utils.js.map +1 -1
  232. package/storageOperations/models/workflow.model.js +0 -23
  233. package/storageOperations/models/workflow.model.js.map +1 -1
  234. package/storageOperations/reviewerStorageOperations.js +22 -40
  235. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  236. package/storageOperations/workflowStorageOperations.js +25 -48
  237. package/storageOperations/workflowStorageOperations.js.map +1 -1
  238. package/types.d.ts +104 -88
  239. package/types.js +124 -42
  240. package/types.js.map +1 -1
  241. package/utils/contentApwSettingsPlugin.js +0 -6
  242. package/utils/contentApwSettingsPlugin.js.map +1 -1
  243. package/utils/errors.js +1 -18
  244. package/utils/errors.js.map +1 -1
  245. package/utils/fieldResolver.js +5 -21
  246. package/utils/fieldResolver.js.map +1 -1
  247. package/utils/resolve.js +0 -3
  248. package/utils/resolve.js.map +1 -1
@@ -1,24 +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.linkWorkflowToPage = void 0;
9
-
10
8
  var _get = _interopRequireDefault(require("lodash/get"));
11
-
12
9
  var _set = _interopRequireDefault(require("lodash/set"));
13
-
10
+ var _types = require("../../types");
14
11
  var _utils = require("./utils");
15
-
16
12
  const linkWorkflowToPage = params => {
17
13
  const {
18
14
  apw,
19
15
  pageBuilder
20
16
  } = params;
21
- pageBuilder.onBeforePageCreate.subscribe(async ({
17
+ pageBuilder.onPageBeforeCreate.subscribe(async ({
22
18
  page
23
19
  }) => {
24
20
  await (0, _utils.assignWorkflowToPage)({
@@ -26,7 +22,7 @@ const linkWorkflowToPage = params => {
26
22
  page
27
23
  });
28
24
  });
29
- pageBuilder.onBeforePageCreateFrom.subscribe(async params => {
25
+ pageBuilder.onPageBeforeCreateFrom.subscribe(async params => {
30
26
  const {
31
27
  page,
32
28
  original
@@ -35,34 +31,28 @@ const linkWorkflowToPage = params => {
35
31
  * If the previous revision(original) already had the "contentReviewId",
36
32
  * we need to unlink it so that new "contentReview" can be request for the new revision.
37
33
  */
38
-
39
34
  const previousContentReviewId = (0, _get.default)(original, "settings.apw.contentReviewId");
40
-
41
35
  if (previousContentReviewId) {
42
36
  page.settings.apw.contentReviewId = null;
43
37
  }
38
+
44
39
  /**
45
40
  * If the previous revision(original) already had the "workflowId",
46
41
  * we don't need to do anything we'll just let it be copied over.
47
42
  */
48
-
49
-
50
43
  const previousWorkflowId = (0, _get.default)(original, "settings.apw.workflowId");
51
-
52
44
  if (previousWorkflowId) {
53
45
  return;
54
46
  }
55
47
  /**
56
48
  * Lookup and assign "workflowId".
57
49
  */
58
-
59
-
60
50
  await (0, _utils.assignWorkflowToPage)({
61
51
  listWorkflow: apw.workflow.list,
62
52
  page
63
53
  });
64
54
  });
65
- pageBuilder.onBeforePageUpdate.subscribe(async params => {
55
+ pageBuilder.onPageBeforeUpdate.subscribe(async params => {
66
56
  const {
67
57
  page,
68
58
  original
@@ -74,7 +64,6 @@ const linkWorkflowToPage = params => {
74
64
  * It can happen because we run modal validation in "onBeforePageUpdate" event,
75
65
  * which doesn't have the "apw" property.
76
66
  */
77
-
78
67
  if (prevApwWorkflowId && !currentApwWorkflowId) {
79
68
  page.settings.apw = original.settings.apw;
80
69
  }
@@ -82,12 +71,9 @@ const linkWorkflowToPage = params => {
82
71
  * If there is a linked "contentReview" for this page and the page "title" has changed.
83
72
  * Let's update the "title" field in "contentReview".
84
73
  */
85
-
86
-
87
74
  const linkedContentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
88
75
  const prevTitle = (0, _get.default)(original, "title");
89
76
  const newTitle = (0, _get.default)(page, "title");
90
-
91
77
  if (linkedContentReviewId && prevTitle !== newTitle) {
92
78
  await apw.contentReview.update(linkedContentReviewId, {
93
79
  title: newTitle
@@ -97,23 +83,22 @@ const linkWorkflowToPage = params => {
97
83
  /**
98
84
  * Link created workflow to associated pages.
99
85
  */
100
-
101
- apw.workflow.onAfterWorkflowCreate.subscribe(async ({
86
+ apw.workflow.onWorkflowAfterCreate.subscribe(async ({
102
87
  workflow
103
88
  }) => {
104
89
  const {
105
90
  scope
106
91
  } = workflow;
92
+ if (workflow.app !== _types.ApwWorkflowApplications.PB) {
93
+ return;
94
+ }
107
95
  /**
108
96
  * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.
109
97
  */
110
-
111
98
  if ((0, _utils.hasPages)(workflow) === false) {
112
99
  return;
113
100
  }
114
-
115
101
  const pages = (0, _get.default)(scope, "data.pages");
116
-
117
102
  for (const pid of pages) {
118
103
  await (0, _utils.updatePageSettings)({
119
104
  getPage: pageBuilder.getPage,
@@ -128,14 +113,16 @@ const linkWorkflowToPage = params => {
128
113
  /**
129
114
  * Link updated workflow to associated pages.
130
115
  */
131
-
132
- apw.workflow.onAfterWorkflowUpdate.subscribe(async ({
116
+ apw.workflow.onWorkflowAfterUpdate.subscribe(async ({
133
117
  workflow,
134
118
  original
135
119
  }) => {
136
120
  const {
137
121
  scope
138
122
  } = workflow;
123
+ if (workflow.app !== _types.ApwWorkflowApplications.PB) {
124
+ return;
125
+ }
139
126
  const {
140
127
  scope: prevScope
141
128
  } = original;
@@ -143,18 +130,15 @@ const linkWorkflowToPage = params => {
143
130
  * If the workflow has pages in it's scope and there is a change in that page list,
144
131
  * we'll update the workflow link for corresponding pages.
145
132
  */
146
-
147
133
  if ((0, _utils.hasPages)(workflow) === false || (0, _utils.shouldUpdatePages)(scope, prevScope) === false) {
148
134
  return;
149
135
  }
150
-
151
136
  const previousPages = (0, _get.default)(prevScope, "data.pages", []);
152
137
  const currentPages = (0, _get.default)(scope, "data.pages", []);
153
138
  const {
154
139
  removedPages,
155
140
  addedPages
156
141
  } = (0, _utils.getPagesDiff)(currentPages, previousPages);
157
-
158
142
  for (const pid of addedPages) {
159
143
  await (0, _utils.updatePageSettings)({
160
144
  getPage: pageBuilder.getPage,
@@ -165,7 +149,6 @@ const linkWorkflowToPage = params => {
165
149
  }
166
150
  });
167
151
  }
168
-
169
152
  for (const pid of removedPages) {
170
153
  await (0, _utils.updatePageSettings)({
171
154
  getPage: pageBuilder.getPage,
@@ -178,5 +161,4 @@ const linkWorkflowToPage = params => {
178
161
  }
179
162
  });
180
163
  };
181
-
182
164
  exports.linkWorkflowToPage = linkWorkflowToPage;
@@ -1 +1 @@
1
- {"version":3,"names":["linkWorkflowToPage","params","apw","pageBuilder","onBeforePageCreate","subscribe","page","assignWorkflowToPage","listWorkflow","workflow","list","onBeforePageCreateFrom","original","previousContentReviewId","get","settings","contentReviewId","previousWorkflowId","onBeforePageUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","newTitle","contentReview","update","title","onAfterWorkflowCreate","scope","hasPages","pages","pid","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","set","id","onAfterWorkflowUpdate","prevScope","shouldUpdatePages","previousPages","currentPages","removedPages","addedPages","getPagesDiff"],"sources":["linkWorkflowToPage.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport set from \"lodash/set\";\nimport {\n ApwOnBeforePageCreateTopicParams,\n ApwOnBeforePageCreateFromTopicParams,\n ApwOnBeforePageUpdateTopicParams,\n AdvancedPublishingWorkflow\n} from \"~/types\";\nimport {\n getPagesDiff,\n hasPages,\n updatePageSettings,\n shouldUpdatePages,\n assignWorkflowToPage\n} from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkWorkflowToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkWorkflowToPage = (params: LinkWorkflowToPageParams) => {\n const { apw, pageBuilder } = params;\n\n pageBuilder.onBeforePageCreate.subscribe<ApwOnBeforePageCreateTopicParams>(async ({ page }) => {\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n });\n pageBuilder.onBeforePageCreateFrom.subscribe<ApwOnBeforePageCreateFromTopicParams>(\n async params => {\n const { page, original } = params;\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = get(original, \"settings.apw.contentReviewId\");\n if (previousContentReviewId) {\n page.settings.apw.contentReviewId = null;\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = get(original, \"settings.apw.workflowId\");\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n }\n );\n pageBuilder.onBeforePageUpdate.subscribe<ApwOnBeforePageUpdateTopicParams>(async params => {\n const { page, original } = params;\n const prevApwWorkflowId = get(original, \"settings.apw\");\n const currentApwWorkflowId = get(page, \"settings.apw\");\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n page.settings.apw = original.settings.apw;\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = get(page, \"settings.apw.contentReviewId\");\n const prevTitle = get(original, \"title\");\n const newTitle = get(page, \"title\");\n\n if (linkedContentReviewId && prevTitle !== newTitle) {\n await apw.contentReview.update(linkedContentReviewId, { title: newTitle });\n }\n });\n /**\n * Link created workflow to associated pages.\n */\n apw.workflow.onAfterWorkflowCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n /**\n * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.\n */\n if (hasPages(workflow) === false) {\n return;\n }\n const pages = get(scope, \"data.pages\");\n\n for (const pid of pages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n });\n /**\n * Link updated workflow to associated pages.\n */\n apw.workflow.onAfterWorkflowUpdate.subscribe(async ({ workflow, original }) => {\n const { scope } = workflow;\n const { scope: prevScope } = original;\n /**\n * If the workflow has pages in it's scope and there is a change in that page list,\n * we'll update the workflow link for corresponding pages.\n */\n if (hasPages(workflow) === false || shouldUpdatePages(scope, prevScope) === false) {\n return;\n }\n\n const previousPages = get(prevScope, \"data.pages\", []);\n const currentPages = get(scope, \"data.pages\", []);\n\n const { removedPages, addedPages } = getPagesDiff(currentPages, previousPages);\n for (const pid of addedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n for (const pid of removedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", null);\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAOA;;AAcO,MAAMA,kBAAkB,GAAIC,MAAD,IAAsC;EACpE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAE,WAAW,CAACC,kBAAZ,CAA+BC,SAA/B,CAA2E,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAC3F,MAAM,IAAAC,2BAAA,EAAqB;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAJ,CAAaC,IAA7B;MAAmCJ;IAAnC,CAArB,CAAN;EACH,CAFD;EAGAH,WAAW,CAACQ,sBAAZ,CAAmCN,SAAnC,CACI,MAAMJ,MAAN,IAAgB;IACZ,MAAM;MAAEK,IAAF;MAAQM;IAAR,IAAqBX,MAA3B;IACA;AACZ;AACA;AACA;;IACY,MAAMY,uBAAuB,GAAG,IAAAC,YAAA,EAAIF,QAAJ,EAAc,8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AA7B,YAAA,EAAIc,KAAJ,EAAW,YAAX,EAAyB,EAAzB,CAArB;IAEA,MAAM;MAAEgB,YAAF;MAAgBC;IAAhB,IAA+B,IAAAC,mBAAA,EAAaH,YAAb,EAA2BD,aAA3B,CAArC;;IACA,KAAK,MAAMX,GAAX,IAAkBc,UAAlB,EAA8B;MAC1B,MAAM,IAAAb,yBAAA,EAAmB;QACrBC,OAAO,EAAE9B,WAAW,CAAC8B,OADA;QAErBC,UAAU,EAAE/B,WAAW,CAAC+B,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAErB,QAAQ,IAAI;UACxB,OAAO,IAAAsB,YAAA,EAAItB,QAAJ,EAAc,gBAAd,EAAgCN,QAAQ,CAAC6B,EAAzC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;;IACD,KAAK,MAAMP,GAAX,IAAkBa,YAAlB,EAAgC;MAC5B,MAAM,IAAAZ,yBAAA,EAAmB;QACrBC,OAAO,EAAE9B,WAAW,CAAC8B,OADA;QAErBC,UAAU,EAAE/B,WAAW,CAAC+B,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAErB,QAAQ,IAAI;UACxB,OAAO,IAAAsB,YAAA,EAAItB,QAAJ,EAAc,gBAAd,EAAgC,IAAhC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;EACJ,CAnCD;AAoCH,CAvHM"}
1
+ {"version":3,"names":["_get","_interopRequireDefault","require","_set","_types","_utils","linkWorkflowToPage","params","apw","pageBuilder","onPageBeforeCreate","subscribe","page","assignWorkflowToPage","listWorkflow","workflow","list","onPageBeforeCreateFrom","original","previousContentReviewId","get","settings","contentReviewId","previousWorkflowId","onPageBeforeUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","newTitle","contentReview","update","title","onWorkflowAfterCreate","scope","app","ApwWorkflowApplications","PB","hasPages","pages","pid","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","set","id","onWorkflowAfterUpdate","prevScope","shouldUpdatePages","previousPages","currentPages","removedPages","addedPages","getPagesDiff","exports"],"sources":["linkWorkflowToPage.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport set from \"lodash/set\";\nimport {\n ApwWorkflowApplications,\n ApwOnPageBeforeCreateTopicParams,\n ApwOnPageBeforeCreateFromTopicParams,\n ApwOnPageBeforeUpdateTopicParams,\n AdvancedPublishingWorkflow\n} from \"~/types\";\nimport {\n getPagesDiff,\n hasPages,\n updatePageSettings,\n shouldUpdatePages,\n assignWorkflowToPage\n} from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkWorkflowToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkWorkflowToPage = (params: LinkWorkflowToPageParams) => {\n const { apw, pageBuilder } = params;\n\n pageBuilder.onPageBeforeCreate.subscribe<ApwOnPageBeforeCreateTopicParams>(async ({ page }) => {\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n });\n pageBuilder.onPageBeforeCreateFrom.subscribe<ApwOnPageBeforeCreateFromTopicParams>(\n async params => {\n const { page, original } = params;\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = get(original, \"settings.apw.contentReviewId\");\n if (previousContentReviewId) {\n page.settings.apw.contentReviewId = null;\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = get(original, \"settings.apw.workflowId\");\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n }\n );\n pageBuilder.onPageBeforeUpdate.subscribe<ApwOnPageBeforeUpdateTopicParams>(async params => {\n const { page, original } = params;\n const prevApwWorkflowId = get(original, \"settings.apw\");\n const currentApwWorkflowId = get(page, \"settings.apw\");\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n page.settings.apw = original.settings.apw;\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = get(page, \"settings.apw.contentReviewId\");\n const prevTitle = get(original, \"title\");\n const newTitle = get(page, \"title\");\n\n if (linkedContentReviewId && prevTitle !== newTitle) {\n await apw.contentReview.update(linkedContentReviewId, { title: newTitle });\n }\n });\n /**\n * Link created workflow to associated pages.\n */\n apw.workflow.onWorkflowAfterCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n if (workflow.app !== ApwWorkflowApplications.PB) {\n return;\n }\n /**\n * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.\n */\n if (hasPages(workflow) === false) {\n return;\n }\n const pages = get(scope, \"data.pages\") as unknown as string[];\n\n for (const pid of pages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n });\n /**\n * Link updated workflow to associated pages.\n */\n apw.workflow.onWorkflowAfterUpdate.subscribe(async ({ workflow, original }) => {\n const { scope } = workflow;\n if (workflow.app !== ApwWorkflowApplications.PB) {\n return;\n }\n const { scope: prevScope } = original;\n /**\n * If the workflow has pages in it's scope and there is a change in that page list,\n * we'll update the workflow link for corresponding pages.\n */\n if (hasPages(workflow) === false || shouldUpdatePages(scope, prevScope) === false) {\n return;\n }\n\n const previousPages = get(prevScope, \"data.pages\", []);\n const currentPages = get(scope, \"data.pages\", []);\n\n const { removedPages, addedPages } = getPagesDiff(currentPages, previousPages);\n for (const pid of addedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n for (const pid of removedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", null);\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AAcO,MAAMI,kBAAkB,GAAIC,MAAgC,IAAK;EACpE,MAAM;IAAEC,GAAG;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAEnCE,WAAW,CAACC,kBAAkB,CAACC,SAAS,CAAmC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC3F,MAAM,IAAAC,2BAAoB,EAAC;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAQ,CAACC,IAAI;MAAEJ;IAAK,CAAC,CAAC;EACzE,CAAC,CAAC;EACFH,WAAW,CAACQ,sBAAsB,CAACN,SAAS,CACxC,MAAMJ,MAAM,IAAI;IACZ,MAAM;MAAEK,IAAI;MAAEM;IAAS,CAAC,GAAGX,MAAM;IACjC;AACZ;AACA;AACA;IACY,MAAMY,uBAAuB,GAAG,IAAAC,YAAG,EAACF,QAAQ,EAAE,8BAA8B,CAAC;IAC7E,IAAIC,uBAAuB,EAAE;MACzBP,IAAI,CAACS,QAAQ,CAACb,GAAG,CAACc,eAAe,GAAG,IAAI;IAC5C;;IAEA;AACZ;AACA;AACA;IACY,MAAMC,kBAAkB,GAAG,IAAAH,YAAG,EAACF,QAAQ,EAAE,yBAAyB,CAAC;IACnE,IAAIK,kBAAkB,EAAE;MACpB;IACJ;IACA;AACZ;AACA;IACY,MAAM,IAAAV,2BAAoB,EAAC;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAQ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B,MAAM,IAAAb,yBAAkB,EAAC;QACrBC,OAAO,EAAEjC,WAAW,CAACiC,OAAO;QAC5BC,UAAU,EAAElC,WAAW,CAACkC,UAAU;QAClCC,YAAY,EAAEJ,GAAG;QACjBK,cAAc,EAAExB,QAAQ,IAAI;UACxB,OAAO,IAAAyB,YAAG,EAACzB,QAAQ,EAAE,gBAAgB,EAAEN,QAAQ,CAACgC,EAAE,CAAC;QACvD;MACJ,CAAC,CAAC;IACN;IACA,KAAK,MAAMP,GAAG,IAAIa,YAAY,EAAE;MAC5B,MAAM,IAAAZ,yBAAkB,EAAC;QACrBC,OAAO,EAAEjC,WAAW,CAACiC,OAAO;QAC5BC,UAAU,EAAElC,WAAW,CAACkC,UAAU;QAClCC,YAAY,EAAEJ,GAAG;QACjBK,cAAc,EAAExB,QAAQ,IAAI;UACxB,OAAO,IAAAyB,YAAG,EAACzB,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC;QAChD;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACmC,OAAA,CAAAlD,kBAAA,GAAAA,kBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createChangeRequestNotification: () => import("../../../ApwChangeRequestNotification").ApwChangeRequestNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createChangeRequestNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
9
+ const createChangeRequestNotification = () => {
10
+ const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.PAGE, params => {
11
+ const {
12
+ changeRequestUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> page.<br /><br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Change Request: ${changeRequestUrl}<br />
24
+ Page: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.PAGE}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createChangeRequestNotification = createChangeRequestNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwChangeRequestNotification","createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","PAGE","params","changeRequestUrl","contentUrl","text","name","type","exports"],"sources":["changeRequestNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\nexport const createChangeRequestNotification = () => {\n const plugin = createApwChangeRequestNotification(ApwContentTypes.PAGE, params => {\n const { changeRequestUrl, contentUrl } = params;\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${changeRequestUrl}\">change request</a>, for <a href=\"${contentUrl}\">this</a> page.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Change Request: ${changeRequestUrl}<br />\n Page: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.PAGE}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,IAAI,EAAEC,MAAM,IAAI;IAC9E,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAC/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,wBAAwBC,UAAW;AACnC;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,IAAK,UAAS;EAE9D,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1 @@
1
+ export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCommentNotification = void 0;
7
+ var _ApwCommentNotification = require("../../../ApwCommentNotification");
8
+ var _types = require("../../../types");
9
+ const createCommentNotification = () => {
10
+ const plugin = (0, _ApwCommentNotification.createApwCommentNotification)(_types.ApwContentTypes.PAGE, params => {
11
+ const {
12
+ commentUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${commentUrl}">comment</a>, on a change request, for <a href="${contentUrl}">this</a> page.<br /><br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Comment: ${commentUrl}<br />
24
+ Page: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.PAGE}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createCommentNotification = createCommentNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwCommentNotification","require","_types","createCommentNotification","plugin","createApwCommentNotification","ApwContentTypes","PAGE","params","commentUrl","contentUrl","text","name","type","exports"],"sources":["commentNotification.ts"],"sourcesContent":["import { createApwCommentNotification } from \"~/ApwCommentNotification\";\nimport { ApwContentTypes } from \"~/types\";\n\nexport const createCommentNotification = () => {\n const plugin = createApwCommentNotification(ApwContentTypes.PAGE, params => {\n const { commentUrl, contentUrl } = params;\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${commentUrl}\">comment</a>, on a change request, for <a href=\"${contentUrl}\">this</a> page.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Comment: ${commentUrl}<br />\n Page: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.PAGE}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAAC,oDAA4B,EAACC,sBAAe,CAACC,IAAI,EAAEC,MAAM,IAAI;IACxE,MAAM;MAAEC,UAAU;MAAEC;IAAW,CAAC,GAAGF,MAAM;IACzC,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,UAAW,oDAAmDC,UAAW;AACxH;AACA;AACA;AACA,2BAA2BD,UAAW;AACtC,wBAAwBC,UAAW;AACnC;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,IAAK,UAAS;EAE9D,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,yBAAA,GAAAA,yBAAA"}
@@ -0,0 +1 @@
1
+ export declare const createContentReviewNotification: () => import("../../../ApwContentReviewNotification").ApwContentReviewNotification;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentReviewNotification = void 0;
7
+ var _types = require("../../../types");
8
+ var _ApwContentReviewNotification = require("../../../ApwContentReviewNotification");
9
+ const createContentReviewNotification = () => {
10
+ const plugin = (0, _ApwContentReviewNotification.createApwContentReviewNotification)(_types.ApwContentTypes.PAGE, params => {
11
+ const {
12
+ contentReviewUrl,
13
+ contentUrl
14
+ } = params;
15
+ return {
16
+ text: `
17
+ Hi,<br /><br />
18
+
19
+ You have received a <a href="${contentReviewUrl}">content review</a>, for <a href="${contentUrl}">this</a> page.<br /><br />
20
+
21
+ Here are the full URLs:<br /><br />
22
+
23
+ Content Review: ${contentReviewUrl}<br />
24
+ Page: ${contentUrl}
25
+ `
26
+ };
27
+ });
28
+ plugin.name = `${plugin.type}.${_types.ApwContentTypes.PAGE}.default`;
29
+ return plugin;
30
+ };
31
+ exports.createContentReviewNotification = createContentReviewNotification;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_ApwContentReviewNotification","createContentReviewNotification","plugin","createApwContentReviewNotification","ApwContentTypes","PAGE","params","contentReviewUrl","contentUrl","text","name","type","exports"],"sources":["contentReviewNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwContentReviewNotification } from \"~/ApwContentReviewNotification\";\n\nexport const createContentReviewNotification = () => {\n const plugin = createApwContentReviewNotification(ApwContentTypes.PAGE, params => {\n const { contentReviewUrl, contentUrl } = params;\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${contentReviewUrl}\">content review</a>, for <a href=\"${contentUrl}\">this</a> page.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Content Review: ${contentReviewUrl}<br />\n Page: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.PAGE}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,6BAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAGA,CAAA,KAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAkC,EAACC,sBAAe,CAACC,IAAI,EAAEC,MAAM,IAAI;IAC9E,MAAM;MAAEC,gBAAgB;MAAEC;IAAW,CAAC,GAAGF,MAAM;IAC/C,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,wBAAwBC,UAAW;AACnC;IACQ,CAAC;EACL,CAAC,CAAC;EAEFN,MAAM,CAACQ,IAAI,GAAI,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAe,CAACC,IAAK,UAAS;EAE9D,OAAOH,MAAM;AACjB,CAAC;AAACU,OAAA,CAAAX,+BAAA,GAAAA,+BAAA"}
@@ -0,0 +1 @@
1
+ export declare const createContentUrlPlugin: () => import("../../../ApwContentUrlPlugin").ApwContentUrlPlugin;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentUrlPlugin = void 0;
7
+ var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
8
+ var _types = require("../../../types");
9
+ /**
10
+ * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
11
+ * Due to multiple content types for the APW, everything needs to be pluginable.
12
+ */
13
+
14
+ const createPageUrl = params => {
15
+ /**
16
+ * All variables must exist for URL to be created.
17
+ * We go through all vars and throw a log if it does not exist.
18
+ */
19
+ for (const key in params) {
20
+ if (!!key) {
21
+ continue;
22
+ }
23
+ console.log(`Missing variable "${key}", which we use to create a page URL.`);
24
+ return null;
25
+ }
26
+ const {
27
+ baseUrl,
28
+ id
29
+ } = params;
30
+ return `${baseUrl}/page-builder/pages?id=${id}`;
31
+ };
32
+ const createContentUrlPlugin = () => {
33
+ return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.PAGE, params => {
34
+ const {
35
+ baseUrl,
36
+ contentReview
37
+ } = params;
38
+ const {
39
+ id
40
+ } = contentReview.content;
41
+ return createPageUrl({
42
+ baseUrl,
43
+ id
44
+ });
45
+ });
46
+ };
47
+ exports.createContentUrlPlugin = createContentUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ApwContentUrlPlugin","require","_types","createPageUrl","params","key","console","log","baseUrl","id","createContentUrlPlugin","createApwContentUrlPlugin","ApwContentTypes","PAGE","contentReview","content","exports"],"sources":["contentUrl.ts"],"sourcesContent":["/**\n * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.\n * Due to multiple content types for the APW, everything needs to be pluginable.\n */\nimport { createApwContentUrlPlugin } from \"~/ApwContentUrlPlugin\";\nimport { ApwContentTypes } from \"~/types\";\n\ninterface CreatePageUrlParams {\n baseUrl?: string;\n id: string;\n}\nconst createPageUrl = (params: CreatePageUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a page URL.`);\n return null;\n }\n const { baseUrl, id } = params;\n return `${baseUrl}/page-builder/pages?id=${id}`;\n};\n\nexport const createContentUrlPlugin = () => {\n return createApwContentUrlPlugin(ApwContentTypes.PAGE, params => {\n const { baseUrl, contentReview } = params;\n const { id } = contentReview.content;\n return createPageUrl({\n baseUrl,\n id\n });\n });\n};\n"],"mappings":";;;;;;AAIA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AAQA,MAAME,aAAa,GAAIC,MAA2B,IAAoB;EAClE;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,uCAAsC,CAAC;IAC5E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC;EAAG,CAAC,GAAGL,MAAM;EAC9B,OAAQ,GAAEI,OAAQ,0BAAyBC,EAAG,EAAC;AACnD,CAAC;AAEM,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAO,IAAAC,8CAAyB,EAACC,sBAAe,CAACC,IAAI,EAAET,MAAM,IAAI;IAC7D,MAAM;MAAEI,OAAO;MAAEM;IAAc,CAAC,GAAGV,MAAM;IACzC,MAAM;MAAEK;IAAG,CAAC,GAAGK,aAAa,CAACC,OAAO;IACpC,OAAOZ,aAAa,CAAC;MACjBK,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAAN,sBAAA,GAAAA,sBAAA"}
@@ -1,43 +1,33 @@
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.triggerContentReview = void 0;
9
-
10
8
  var _get = _interopRequireDefault(require("lodash/get"));
11
-
12
9
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
10
  var _types = require("../../types");
15
-
16
11
  const triggerContentReview = params => {
17
12
  const {
18
13
  pageBuilder,
19
14
  apw
20
15
  } = params;
21
- pageBuilder.onBeforePagePublish.subscribe(async ({
16
+ pageBuilder.onPageBeforePublish.subscribe(async ({
22
17
  page
23
18
  }) => {
24
19
  const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
25
-
26
20
  if (contentReviewId) {
27
21
  const contentReview = await apw.contentReview.get(contentReviewId);
28
-
29
- if (contentReview.status === _types.ApwContentReviewStatus.UNDER_REVIEW) {
22
+ if (contentReview.reviewStatus === _types.ApwContentReviewStatus.UNDER_REVIEW) {
30
23
  throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
31
24
  contentReviewId,
32
25
  page
33
26
  });
34
27
  }
35
-
36
28
  return;
37
29
  }
38
-
39
30
  const workflowId = (0, _get.default)(page, "settings.apw.workflowId");
40
-
41
31
  if (workflowId) {
42
32
  throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
43
33
  workflowId,
@@ -46,5 +36,4 @@ const triggerContentReview = params => {
46
36
  }
47
37
  });
48
38
  };
49
-
50
39
  exports.triggerContentReview = triggerContentReview;
@@ -1 +1 @@
1
- {"version":3,"names":["triggerContentReview","params","pageBuilder","apw","onBeforePagePublish","subscribe","page","contentReviewId","get","contentReview","status","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId"],"sources":["triggerContentReview.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n ApwOnBeforePagePublishTopicParams\n} from \"~/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface TriggerContentReviewParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const triggerContentReview = (params: TriggerContentReviewParams) => {\n const { pageBuilder, apw } = params;\n\n pageBuilder.onBeforePagePublish.subscribe<ApwOnBeforePagePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n if (contentReviewId) {\n const contentReview = await apw.contentReview.get(contentReviewId);\n\n if (contentReview.status === ApwContentReviewStatus.UNDER_REVIEW) {\n throw new Error(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n return;\n }\n\n const workflowId = get(page, \"settings.apw.workflowId\");\n\n if (workflowId) {\n throw new Error(\n \"This content requires peer review approval before it can be published.\",\n \"REVIEW_REQUIRED\",\n {\n workflowId,\n page\n }\n );\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAYO,MAAMA,oBAAoB,GAAIC,MAAD,IAAwC;EACxE,MAAM;IAAEC,WAAF;IAAeC;EAAf,IAAuBF,MAA7B;EAEAC,WAAW,CAACE,mBAAZ,CAAgCC,SAAhC,CACI,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;;IACA,IAAIC,eAAJ,EAAqB;MACjB,MAAME,aAAa,GAAG,MAAMN,GAAG,CAACM,aAAJ,CAAkBD,GAAlB,CAAsBD,eAAtB,CAA5B;;MAEA,IAAIE,aAAa,CAACC,MAAd,KAAyBC,6BAAA,CAAuBC,YAApD,EAAkE;QAC9D,MAAM,IAAIC,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;UACIN,eADJ;UAEID;QAFJ,CAHE,CAAN;MAQH;;MACD;IACH;;IAED,MAAMQ,UAAU,GAAG,IAAAN,YAAA,EAAIF,IAAJ,EAAU,yBAAV,CAAnB;;IAEA,IAAIQ,UAAJ,EAAgB;MACZ,MAAM,IAAID,cAAJ,CACF,wEADE,EAEF,iBAFE,EAGF;QACIC,UADJ;QAEIR;MAFJ,CAHE,CAAN;IAQH;EACJ,CA/BL;AAiCH,CApCM"}
1
+ {"version":3,"names":["_get","_interopRequireDefault","require","_error","_types","triggerContentReview","params","pageBuilder","apw","onPageBeforePublish","subscribe","page","contentReviewId","get","contentReview","reviewStatus","ApwContentReviewStatus","UNDER_REVIEW","Error","workflowId","exports"],"sources":["triggerContentReview.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport Error from \"@webiny/error\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n ApwOnPageBeforePublishTopicParams\n} from \"~/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface TriggerContentReviewParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const triggerContentReview = (params: TriggerContentReviewParams) => {\n const { pageBuilder, apw } = params;\n\n pageBuilder.onPageBeforePublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n if (contentReviewId) {\n const contentReview = await apw.contentReview.get(contentReviewId);\n\n if (contentReview.reviewStatus === ApwContentReviewStatus.UNDER_REVIEW) {\n throw new Error(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n return;\n }\n\n const workflowId = get(page, \"settings.apw.workflowId\");\n\n if (workflowId) {\n throw new Error(\n \"This content requires peer review approval before it can be published.\",\n \"REVIEW_REQUIRED\",\n {\n workflowId,\n page\n }\n );\n }\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAYO,MAAMG,oBAAoB,GAAIC,MAAkC,IAAK;EACxE,MAAM;IAAEC,WAAW;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAEnCC,WAAW,CAACE,mBAAmB,CAACC,SAAS,CACrC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAG,EAACF,IAAI,EAAE,8BAA8B,CAAC;IACjE,IAAIC,eAAe,EAAE;MACjB,MAAME,aAAa,GAAG,MAAMN,GAAG,CAACM,aAAa,CAACD,GAAG,CAACD,eAAe,CAAC;MAElE,IAAIE,aAAa,CAACC,YAAY,KAAKC,6BAAsB,CAACC,YAAY,EAAE;QACpE,MAAM,IAAIC,cAAK,CACV,4DAA2D,EAC5D,sBAAsB,EACtB;UACIN,eAAe;UACfD;QACJ,CACJ,CAAC;MACL;MACA;IACJ;IAEA,MAAMQ,UAAU,GAAG,IAAAN,YAAG,EAACF,IAAI,EAAE,yBAAyB,CAAC;IAEvD,IAAIQ,UAAU,EAAE;MACZ,MAAM,IAAID,cAAK,CACX,wEAAwE,EACxE,iBAAiB,EACjB;QACIC,UAAU;QACVR;MACJ,CACJ,CAAC;IACL;EACJ,CACJ,CAAC;AACL,CAAC;AAACS,OAAA,CAAAf,oBAAA,GAAAA,oBAAA"}
@@ -1,83 +1,67 @@
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.updateContentReviewStatus = void 0;
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 _types = require("../../types");
15
-
16
11
  var _utils = require("../../crud/utils");
17
-
18
- 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; }
19
-
20
- 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; }
21
-
22
12
  const updateContentReviewStatus = params => {
23
13
  const {
24
14
  apw,
25
15
  pageBuilder,
26
16
  security
27
17
  } = params;
28
- pageBuilder.onAfterPagePublish.subscribe(async ({
18
+ pageBuilder.onPageAfterPublish.subscribe(async ({
29
19
  page
30
20
  }) => {
31
21
  const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
32
22
  /**
33
23
  * Bail out if there is no "content review" linked.
34
24
  */
35
-
36
25
  if (!contentReviewId) {
37
26
  return;
38
27
  }
39
-
40
28
  const contentReview = await apw.contentReview.get(contentReviewId);
41
29
  const identity = security.getIdentity();
42
30
  /**
43
31
  * If content review is "readyToBePublished set its status as "published" after page publish.
44
32
  */
45
-
46
- if (contentReview.status === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
33
+ if (contentReview.reviewStatus === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
47
34
  await apw.contentReview.update(contentReviewId, {
48
- status: _types.ApwContentReviewStatus.PUBLISHED,
49
- content: _objectSpread(_objectSpread(_objectSpread({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
35
+ reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
36
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
50
37
  publishedBy: identity.id
51
38
  })
52
39
  });
53
40
  }
54
41
  });
55
- pageBuilder.onAfterPageUnpublish.subscribe(async ({
42
+ pageBuilder.onPageAfterUnpublish.subscribe(async ({
56
43
  page
57
44
  }) => {
58
45
  const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
59
46
  /**
60
47
  * Bail out if there is no "content review" linked.
61
48
  */
62
-
63
49
  if (!contentReviewId) {
64
50
  return;
65
51
  }
66
-
67
52
  const contentReview = await apw.contentReview.get(contentReviewId);
68
53
  /**
69
54
  * If content review is "published set its status as "readyToBePublished" after page unpublish.
70
55
  */
71
56
 
72
- if (contentReview.status === _types.ApwContentReviewStatus.PUBLISHED) {
57
+ if (contentReview.reviewStatus === _types.ApwContentReviewStatus.PUBLISHED) {
73
58
  await apw.contentReview.update(contentReviewId, {
74
- status: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
75
- content: _objectSpread(_objectSpread(_objectSpread({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
59
+ reviewStatus: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
60
+ content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
76
61
  publishedBy: null
77
62
  })
78
63
  });
79
64
  }
80
65
  });
81
66
  };
82
-
83
67
  exports.updateContentReviewStatus = updateContentReviewStatus;
@@ -1 +1 @@
1
- {"version":3,"names":["updateContentReviewStatus","params","apw","pageBuilder","security","onAfterPagePublish","subscribe","page","contentReviewId","get","contentReview","identity","getIdentity","status","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onAfterPageUnpublish"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n ApwOnBeforePagePublishTopicParams\n} from \"~/types\";\nimport { INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META } from \"~/crud/utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface UpdateContentReviewStatusParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n security: Security;\n}\n\nexport const updateContentReviewStatus = (params: UpdateContentReviewStatusParams) => {\n const { apw, pageBuilder, security } = params;\n\n pageBuilder.onAfterPagePublish.subscribe<ApwOnBeforePagePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n const identity = security.getIdentity();\n /**\n * If content review is \"readyToBePublished set its status as \"published\" after page publish.\n */\n if (contentReview.status === ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n status: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n }\n );\n pageBuilder.onAfterPageUnpublish.subscribe<ApwOnBeforePagePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n /**\n * If content review is \"published set its status as \"readyToBePublished\" after page unpublish.\n */\n\n if (contentReview.status === ApwContentReviewStatus.PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n status: ApwContentReviewStatus.READY_TO_BE_PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: null\n }\n });\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAKA;;;;;;AAUO,MAAMA,yBAAyB,GAAIC,MAAD,IAA6C;EAClF,MAAM;IAAEC,GAAF;IAAOC,WAAP;IAAoBC;EAApB,IAAiCH,MAAvC;EAEAE,WAAW,CAACE,kBAAZ,CAA+BC,SAA/B,CACI,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;IACA;AACZ;AACA;;IACY,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBD,GAAlB,CAAsBD,eAAtB,CAA5B;IACA,MAAMG,QAAQ,GAAGP,QAAQ,CAACQ,WAAT,EAAjB;IACA;AACZ;AACA;;IACY,IAAIF,aAAa,CAACG,MAAd,KAAyBC,6BAAA,CAAuBC,qBAApD,EAA2E;MACvE,MAAMb,GAAG,CAACQ,aAAJ,CAAkBM,MAAlB,CAAyBR,eAAzB,EAA0C;QAC5CK,MAAM,EAAEC,6BAAA,CAAuBG,SADa;QAE5CC,OAAO,gDACAR,aAAa,CAACQ,OADd,GAEAC,mDAFA;UAGHC,WAAW,EAAET,QAAQ,CAACU;QAHnB;MAFqC,CAA1C,CAAN;IAQH;EACJ,CAzBL;EA2BAlB,WAAW,CAACmB,oBAAZ,CAAiChB,SAAjC,CACI,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;IACA;AACZ;AACA;;IACY,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBD,GAAlB,CAAsBD,eAAtB,CAA5B;IACA;AACZ;AACA;;IAEY,IAAIE,aAAa,CAACG,MAAd,KAAyBC,6BAAA,CAAuBG,SAApD,EAA+D;MAC3D,MAAMf,GAAG,CAACQ,aAAJ,CAAkBM,MAAlB,CAAyBR,eAAzB,EAA0C;QAC5CK,MAAM,EAAEC,6BAAA,CAAuBC,qBADa;QAE5CG,OAAO,gDACAR,aAAa,CAACQ,OADd,GAEAC,mDAFA;UAGHC,WAAW,EAAE;QAHV;MAFqC,CAA1C,CAAN;IAQH;EACJ,CAzBL;AA2BH,CAzDM"}
1
+ {"version":3,"names":["_get","_interopRequireDefault","require","_types","_utils","updateContentReviewStatus","params","apw","pageBuilder","security","onPageAfterPublish","subscribe","page","contentReviewId","get","contentReview","identity","getIdentity","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","_objectSpread2","default","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onPageAfterUnpublish","exports"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n ApwOnPageBeforePublishTopicParams\n} from \"~/types\";\nimport { INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META } from \"~/crud/utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface UpdateContentReviewStatusParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n security: Security;\n}\n\nexport const updateContentReviewStatus = (params: UpdateContentReviewStatusParams) => {\n const { apw, pageBuilder, security } = params;\n\n pageBuilder.onPageAfterPublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n const identity = security.getIdentity();\n /**\n * If content review is \"readyToBePublished set its status as \"published\" after page publish.\n */\n if (contentReview.reviewStatus === ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n }\n );\n pageBuilder.onPageAfterUnpublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n /**\n * If content review is \"published set its status as \"readyToBePublished\" after page unpublish.\n */\n\n if (contentReview.reviewStatus === ApwContentReviewStatus.PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.READY_TO_BE_PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: null\n }\n });\n }\n }\n );\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAUO,MAAMG,yBAAyB,GAAIC,MAAuC,IAAK;EAClF,MAAM;IAAEC,GAAG;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE7CE,WAAW,CAACE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