@webiny/api-apw 5.25.0 → 5.30.0

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 (216) hide show
  1. package/ContentApwSettingsPlugin.d.ts +10 -0
  2. package/ContentApwSettingsPlugin.js +17 -0
  3. package/ContentApwSettingsPlugin.js.map +1 -0
  4. package/README.md +7 -6
  5. package/{createApw → crud}/createChangeRequestMethods.d.ts +0 -0
  6. package/{createApw → crud}/createChangeRequestMethods.js +0 -0
  7. package/crud/createChangeRequestMethods.js.map +1 -0
  8. package/{createApw → crud}/createCommentMethods.d.ts +0 -0
  9. package/{createApw → crud}/createCommentMethods.js +0 -0
  10. package/crud/createCommentMethods.js.map +1 -0
  11. package/crud/createContentReviewMethods.d.ts +10 -0
  12. package/{createApw → crud}/createContentReviewMethods.js +269 -19
  13. package/crud/createContentReviewMethods.js.map +1 -0
  14. package/{createApw → crud}/createReviewerMethods.d.ts +0 -0
  15. package/{createApw → crud}/createReviewerMethods.js +0 -0
  16. package/crud/createReviewerMethods.js.map +1 -0
  17. package/{createApw → crud}/createWorkflowMethods.d.ts +0 -0
  18. package/{createApw → crud}/createWorkflowMethods.js +0 -0
  19. package/crud/createWorkflowMethods.js.map +1 -0
  20. package/{createApw → crud}/index.d.ts +0 -0
  21. package/{createApw → crud}/index.js +55 -11
  22. package/crud/index.js.map +1 -0
  23. package/crud/utils.d.ts +21 -0
  24. package/crud/utils.js +142 -0
  25. package/crud/utils.js.map +1 -0
  26. package/index.d.ts +4 -2
  27. package/index.js +11 -5
  28. package/index.js.map +1 -1
  29. package/package.json +37 -30
  30. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
  31. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
  32. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
  33. package/plugins/cms/README.md +49 -0
  34. package/plugins/cms/apwEntryPlugins.d.ts +8 -0
  35. package/plugins/cms/apwEntryPlugins.js +50 -0
  36. package/plugins/cms/apwEntryPlugins.js.map +1 -0
  37. package/plugins/cms/index.d.ts +12 -0
  38. package/plugins/cms/index.js +37 -0
  39. package/plugins/cms/index.js.map +1 -0
  40. package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
  41. package/plugins/cms/linkContentReviewToEntry.js +108 -0
  42. package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
  43. package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
  44. package/plugins/cms/linkWorkflowToEntry.js +166 -0
  45. package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
  46. package/plugins/cms/triggerContentReview.d.ts +8 -0
  47. package/plugins/cms/triggerContentReview.js +59 -0
  48. package/plugins/cms/triggerContentReview.js.map +1 -0
  49. package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
  50. package/plugins/cms/updateContentReviewStatus.js +101 -0
  51. package/plugins/cms/updateContentReviewStatus.js.map +1 -0
  52. package/plugins/cms/utils.d.ts +27 -0
  53. package/plugins/cms/utils.js +211 -0
  54. package/plugins/cms/utils.js.map +1 -0
  55. package/plugins/context.d.ts +3 -2
  56. package/plugins/context.js +82 -49
  57. package/plugins/context.js.map +1 -1
  58. package/plugins/graphql/changeRequest.gql.js +1 -1
  59. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  60. package/plugins/graphql/comment.gql.js +8 -17
  61. package/plugins/graphql/comment.gql.js.map +1 -1
  62. package/plugins/graphql/contentReview.gql.js +168 -13
  63. package/plugins/graphql/contentReview.gql.js.map +1 -1
  64. package/plugins/graphql/reviewer.gql.js +1 -1
  65. package/plugins/graphql/reviewer.gql.js.map +1 -1
  66. package/plugins/graphql/workflow.gql.js +18 -15
  67. package/plugins/graphql/workflow.gql.js.map +1 -1
  68. package/plugins/graphql.d.ts +3 -2
  69. package/plugins/graphql.js +11 -1
  70. package/plugins/graphql.js.map +1 -1
  71. package/plugins/hooks/createReviewerFromIdentity.js +18 -0
  72. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  73. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +8 -8
  74. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  75. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +6 -6
  76. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  77. package/plugins/hooks/index.d.ts +1 -2
  78. package/plugins/hooks/index.js +25 -25
  79. package/plugins/hooks/index.js.map +1 -1
  80. package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -7
  81. package/plugins/hooks/initializeContentReviewSteps.js +42 -24
  82. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  83. package/plugins/hooks/updatePendingChangeRequests.js +27 -39
  84. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  85. package/plugins/hooks/updateTotalComments.d.ts +3 -0
  86. package/plugins/hooks/updateTotalComments.js +157 -0
  87. package/plugins/hooks/updateTotalComments.js.map +1 -0
  88. package/plugins/hooks/validateChangeRequest.d.ts +2 -0
  89. package/plugins/hooks/validateChangeRequest.js +64 -0
  90. package/plugins/hooks/validateChangeRequest.js.map +1 -0
  91. package/plugins/hooks/validateComment.d.ts +2 -0
  92. package/plugins/hooks/validateComment.js +45 -0
  93. package/plugins/hooks/validateComment.js.map +1 -0
  94. package/plugins/hooks/validateContentReview.d.ts +2 -0
  95. package/plugins/hooks/validateContentReview.js +38 -0
  96. package/plugins/hooks/validateContentReview.js.map +1 -0
  97. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
  98. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
  99. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
  100. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
  101. package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
  102. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
  103. package/plugins/{hooks/extendPbPageSchema.d.ts → pageBuilder/extendPbPageSettingsSchema.d.ts} +1 -2
  104. package/plugins/{hooks/extendPbPageSchema.js → pageBuilder/extendPbPageSettingsSchema.js} +4 -3
  105. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
  106. package/plugins/pageBuilder/index.d.ts +11 -0
  107. package/plugins/pageBuilder/index.js +45 -0
  108. package/plugins/pageBuilder/index.js.map +1 -0
  109. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
  110. package/plugins/pageBuilder/linkContentReviewToPage.js +93 -0
  111. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
  112. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
  113. package/plugins/pageBuilder/linkWorkflowToPage.js +182 -0
  114. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
  115. package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
  116. package/plugins/pageBuilder/triggerContentReview.js +50 -0
  117. package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
  118. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
  119. package/plugins/pageBuilder/updateContentReviewStatus.js +83 -0
  120. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
  121. package/plugins/pageBuilder/utils.d.ts +22 -0
  122. package/plugins/pageBuilder/utils.js +184 -0
  123. package/plugins/pageBuilder/utils.js.map +1 -0
  124. package/plugins/utils.d.ts +22 -2
  125. package/plugins/utils.js +128 -2
  126. package/plugins/utils.js.map +1 -1
  127. package/scheduler/createScheduleActionMethods.d.ts +2 -0
  128. package/scheduler/createScheduleActionMethods.js +146 -0
  129. package/scheduler/createScheduleActionMethods.js.map +1 -0
  130. package/scheduler/handlers/executeAction/index.d.ts +16 -0
  131. package/scheduler/handlers/executeAction/index.js +148 -0
  132. package/scheduler/handlers/executeAction/index.js.map +1 -0
  133. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
  134. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
  135. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
  136. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
  137. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
  138. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
  139. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
  140. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
  141. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
  142. package/scheduler/handlers/executeAction/security.d.ts +4 -0
  143. package/scheduler/handlers/executeAction/security.js +68 -0
  144. package/scheduler/handlers/executeAction/security.js.map +1 -0
  145. package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
  146. package/scheduler/handlers/scheduleAction/index.js +162 -0
  147. package/scheduler/handlers/scheduleAction/index.js.map +1 -0
  148. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
  149. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +176 -0
  150. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
  151. package/scheduler/handlers/utils.d.ts +33 -0
  152. package/scheduler/handlers/utils.js +168 -0
  153. package/scheduler/handlers/utils.js.map +1 -0
  154. package/scheduler/index.d.ts +2 -0
  155. package/scheduler/index.js +27 -0
  156. package/scheduler/index.js.map +1 -0
  157. package/scheduler/types.d.ts +171 -0
  158. package/scheduler/types.js +34 -0
  159. package/scheduler/types.js.map +1 -0
  160. package/storageOperations/changeRequestStorageOperations.js +1 -3
  161. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  162. package/storageOperations/commentStorageOperations.js +25 -11
  163. package/storageOperations/commentStorageOperations.js.map +1 -1
  164. package/storageOperations/contentReviewStorageOperations.js +1 -3
  165. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  166. package/storageOperations/index.js.map +1 -1
  167. package/storageOperations/models/changeRequest.model.d.ts +1 -0
  168. package/storageOperations/models/changeRequest.model.js +10 -5
  169. package/storageOperations/models/changeRequest.model.js.map +1 -1
  170. package/storageOperations/models/comment.model.d.ts +1 -0
  171. package/storageOperations/models/comment.model.js +24 -3
  172. package/storageOperations/models/comment.model.js.map +1 -1
  173. package/storageOperations/models/contentModelPluginFactory.d.ts +2 -2
  174. package/storageOperations/models/contentModelPluginFactory.js +2 -2
  175. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  176. package/storageOperations/models/contentReview.model.d.ts +1 -0
  177. package/storageOperations/models/contentReview.model.js +98 -26
  178. package/storageOperations/models/contentReview.model.js.map +1 -1
  179. package/storageOperations/models/index.js +25 -5
  180. package/storageOperations/models/index.js.map +1 -1
  181. package/storageOperations/models/reviewer.model.d.ts +1 -0
  182. package/storageOperations/models/reviewer.model.js +11 -6
  183. package/storageOperations/models/reviewer.model.js.map +1 -1
  184. package/storageOperations/models/utils.js.map +1 -1
  185. package/storageOperations/models/workflow.model.d.ts +2 -1
  186. package/storageOperations/models/workflow.model.js +32 -30
  187. package/storageOperations/models/workflow.model.js.map +1 -1
  188. package/storageOperations/reviewerStorageOperations.js +1 -3
  189. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  190. package/storageOperations/types.js.map +1 -1
  191. package/storageOperations/workflowStorageOperations.js +21 -7
  192. package/storageOperations/workflowStorageOperations.js.map +1 -1
  193. package/types.d.ts +138 -49
  194. package/types.js +9 -3
  195. package/types.js.map +1 -1
  196. package/utils/contentApwSettingsPlugin.d.ts +9 -0
  197. package/utils/contentApwSettingsPlugin.js +26 -0
  198. package/utils/contentApwSettingsPlugin.js.map +1 -0
  199. package/utils/errors.js.map +1 -1
  200. package/utils/fieldResolver.js +2 -2
  201. package/utils/fieldResolver.js.map +1 -1
  202. package/utils/resolve.js.map +1 -1
  203. package/createApw/createChangeRequestMethods.js.map +0 -1
  204. package/createApw/createCommentMethods.js.map +0 -1
  205. package/createApw/createContentReviewMethods.d.ts +0 -6
  206. package/createApw/createContentReviewMethods.js.map +0 -1
  207. package/createApw/createReviewerMethods.js.map +0 -1
  208. package/createApw/createWorkflowMethods.js.map +0 -1
  209. package/createApw/index.js.map +0 -1
  210. package/plugins/createManageCMSPlugin.d.ts +0 -2
  211. package/plugins/createManageCMSPlugin.js +0 -31
  212. package/plugins/createManageCMSPlugin.js.map +0 -1
  213. package/plugins/hooks/extendPbPageSchema.js.map +0 -1
  214. package/plugins/hooks/linkWorkflowToPage.d.ts +0 -9
  215. package/plugins/hooks/linkWorkflowToPage.js +0 -155
  216. package/plugins/hooks/linkWorkflowToPage.js.map +0 -1
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.linkWorkflowToPage = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ var _set = _interopRequireDefault(require("lodash/set"));
13
+
14
+ var _utils = require("./utils");
15
+
16
+ const linkWorkflowToPage = params => {
17
+ const {
18
+ apw,
19
+ pageBuilder
20
+ } = params;
21
+ pageBuilder.onBeforePageCreate.subscribe(async ({
22
+ page
23
+ }) => {
24
+ await (0, _utils.assignWorkflowToPage)({
25
+ listWorkflow: apw.workflow.list,
26
+ page
27
+ });
28
+ });
29
+ pageBuilder.onBeforePageCreateFrom.subscribe(async params => {
30
+ const {
31
+ page,
32
+ original
33
+ } = params;
34
+ /**
35
+ * If the previous revision(original) already had the "contentReviewId",
36
+ * we need to unlink it so that new "contentReview" can be request for the new revision.
37
+ */
38
+
39
+ const previousContentReviewId = (0, _get.default)(original, "settings.apw.contentReviewId");
40
+
41
+ if (previousContentReviewId) {
42
+ page.settings.apw.contentReviewId = null;
43
+ }
44
+ /**
45
+ * If the previous revision(original) already had the "workflowId",
46
+ * we don't need to do anything we'll just let it be copied over.
47
+ */
48
+
49
+
50
+ const previousWorkflowId = (0, _get.default)(original, "settings.apw.workflowId");
51
+
52
+ if (previousWorkflowId) {
53
+ return;
54
+ }
55
+ /**
56
+ * Lookup and assign "workflowId".
57
+ */
58
+
59
+
60
+ await (0, _utils.assignWorkflowToPage)({
61
+ listWorkflow: apw.workflow.list,
62
+ page
63
+ });
64
+ });
65
+ pageBuilder.onBeforePageUpdate.subscribe(async params => {
66
+ const {
67
+ page,
68
+ original
69
+ } = params;
70
+ const prevApwWorkflowId = (0, _get.default)(original, "settings.apw");
71
+ const currentApwWorkflowId = (0, _get.default)(page, "settings.apw");
72
+ /**
73
+ * Make sure the apw property doesn't get lost between updates.
74
+ * It can happen because we run modal validation in "onBeforePageUpdate" event,
75
+ * which doesn't have the "apw" property.
76
+ */
77
+
78
+ if (prevApwWorkflowId && !currentApwWorkflowId) {
79
+ page.settings.apw = original.settings.apw;
80
+ }
81
+ /*
82
+ * If there is a linked "contentReview" for this page and the page "title" has changed.
83
+ * Let's update the "title" field in "contentReview".
84
+ */
85
+
86
+
87
+ const linkedContentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
88
+ const prevTitle = (0, _get.default)(original, "title");
89
+ const newTitle = (0, _get.default)(page, "title");
90
+
91
+ if (linkedContentReviewId && prevTitle !== newTitle) {
92
+ await apw.contentReview.update(linkedContentReviewId, {
93
+ title: newTitle
94
+ });
95
+ }
96
+ });
97
+ /**
98
+ * Link created workflow to associated pages.
99
+ */
100
+
101
+ apw.workflow.onAfterWorkflowCreate.subscribe(async ({
102
+ workflow
103
+ }) => {
104
+ const {
105
+ scope
106
+ } = workflow;
107
+ /**
108
+ * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.
109
+ */
110
+
111
+ if ((0, _utils.hasPages)(workflow) === false) {
112
+ return;
113
+ }
114
+
115
+ const pages = (0, _get.default)(scope, "data.pages");
116
+
117
+ for (const pid of pages) {
118
+ await (0, _utils.updatePageSettings)({
119
+ getPage: pageBuilder.getPage,
120
+ updatePage: pageBuilder.updatePage,
121
+ uniquePageId: pid,
122
+ getNewSettings: settings => {
123
+ return (0, _set.default)(settings, "apw.workflowId", workflow.id);
124
+ }
125
+ });
126
+ }
127
+ });
128
+ /**
129
+ * Link updated workflow to associated pages.
130
+ */
131
+
132
+ apw.workflow.onAfterWorkflowUpdate.subscribe(async ({
133
+ workflow,
134
+ original
135
+ }) => {
136
+ const {
137
+ scope
138
+ } = workflow;
139
+ const {
140
+ scope: prevScope
141
+ } = original;
142
+ /**
143
+ * If the workflow has pages in it's scope and there is a change in that page list,
144
+ * we'll update the workflow link for corresponding pages.
145
+ */
146
+
147
+ if ((0, _utils.hasPages)(workflow) === false || (0, _utils.shouldUpdatePages)(scope, prevScope) === false) {
148
+ return;
149
+ }
150
+
151
+ const previousPages = (0, _get.default)(prevScope, "data.pages", []);
152
+ const currentPages = (0, _get.default)(scope, "data.pages", []);
153
+ const {
154
+ removedPages,
155
+ addedPages
156
+ } = (0, _utils.getPagesDiff)(currentPages, previousPages);
157
+
158
+ for (const pid of addedPages) {
159
+ await (0, _utils.updatePageSettings)({
160
+ getPage: pageBuilder.getPage,
161
+ updatePage: pageBuilder.updatePage,
162
+ uniquePageId: pid,
163
+ getNewSettings: settings => {
164
+ return (0, _set.default)(settings, "apw.workflowId", workflow.id);
165
+ }
166
+ });
167
+ }
168
+
169
+ for (const pid of removedPages) {
170
+ await (0, _utils.updatePageSettings)({
171
+ getPage: pageBuilder.getPage,
172
+ updatePage: pageBuilder.updatePage,
173
+ uniquePageId: pid,
174
+ getNewSettings: settings => {
175
+ return (0, _set.default)(settings, "apw.workflowId", null);
176
+ }
177
+ });
178
+ }
179
+ });
180
+ };
181
+
182
+ exports.linkWorkflowToPage = linkWorkflowToPage;
@@ -0,0 +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,8BAAd,CAAhC;;IACA,IAAIC,uBAAJ,EAA6B;MACzBP,IAAI,CAACS,QAAL,CAAcb,GAAd,CAAkBc,eAAlB,GAAoC,IAApC;IACH;IAED;AACZ;AACA;AACA;;;IACY,MAAMC,kBAAkB,GAAG,IAAAH,YAAA,EAAIF,QAAJ,EAAc,yBAAd,CAA3B;;IACA,IAAIK,kBAAJ,EAAwB;MACpB;IACH;IACD;AACZ;AACA;;;IACY,MAAM,IAAAV,2BAAA,EAAqB;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAJ,CAAaC,IAA7B;MAAmCJ;IAAnC,CAArB,CAAN;EACH,CAxBL;EA0BAH,WAAW,CAACe,kBAAZ,CAA+Bb,SAA/B,CAA2E,MAAMJ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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"}
@@ -0,0 +1,8 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ interface TriggerContentReviewParams {
4
+ apw: AdvancedPublishingWorkflow;
5
+ pageBuilder: PageBuilderContextObject;
6
+ }
7
+ export declare const triggerContentReview: (params: TriggerContentReviewParams) => void;
8
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.triggerContentReview = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _types = require("../../types");
15
+
16
+ const triggerContentReview = params => {
17
+ const {
18
+ pageBuilder,
19
+ apw
20
+ } = params;
21
+ pageBuilder.onBeforePagePublish.subscribe(async ({
22
+ page
23
+ }) => {
24
+ const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
25
+
26
+ if (contentReviewId) {
27
+ const contentReview = await apw.contentReview.get(contentReviewId);
28
+
29
+ if (contentReview.status === _types.ApwContentReviewStatus.UNDER_REVIEW) {
30
+ throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
31
+ contentReviewId,
32
+ page
33
+ });
34
+ }
35
+
36
+ return;
37
+ }
38
+
39
+ const workflowId = (0, _get.default)(page, "settings.apw.workflowId");
40
+
41
+ if (workflowId) {
42
+ throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
43
+ workflowId,
44
+ page
45
+ });
46
+ }
47
+ });
48
+ };
49
+
50
+ exports.triggerContentReview = triggerContentReview;
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ import { Security } from "@webiny/api-security/types";
4
+ interface UpdateContentReviewStatusParams {
5
+ apw: AdvancedPublishingWorkflow;
6
+ pageBuilder: PageBuilderContextObject;
7
+ security: Security;
8
+ }
9
+ export declare const updateContentReviewStatus: (params: UpdateContentReviewStatusParams) => void;
10
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updateContentReviewStatus = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _get = _interopRequireDefault(require("lodash/get"));
13
+
14
+ var _types = require("../../types");
15
+
16
+ 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
+ const updateContentReviewStatus = params => {
23
+ const {
24
+ apw,
25
+ pageBuilder,
26
+ security
27
+ } = params;
28
+ pageBuilder.onAfterPagePublish.subscribe(async ({
29
+ page
30
+ }) => {
31
+ const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
32
+ /**
33
+ * Bail out if there is no "content review" linked.
34
+ */
35
+
36
+ if (!contentReviewId) {
37
+ return;
38
+ }
39
+
40
+ const contentReview = await apw.contentReview.get(contentReviewId);
41
+ const identity = security.getIdentity();
42
+ /**
43
+ * If content review is "readyToBePublished set its status as "published" after page publish.
44
+ */
45
+
46
+ if (contentReview.status === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
47
+ await apw.contentReview.update(contentReviewId, {
48
+ status: _types.ApwContentReviewStatus.PUBLISHED,
49
+ content: _objectSpread(_objectSpread(_objectSpread({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
50
+ publishedBy: identity.id
51
+ })
52
+ });
53
+ }
54
+ });
55
+ pageBuilder.onAfterPageUnpublish.subscribe(async ({
56
+ page
57
+ }) => {
58
+ const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
59
+ /**
60
+ * Bail out if there is no "content review" linked.
61
+ */
62
+
63
+ if (!contentReviewId) {
64
+ return;
65
+ }
66
+
67
+ const contentReview = await apw.contentReview.get(contentReviewId);
68
+ /**
69
+ * If content review is "published set its status as "readyToBePublished" after page unpublish.
70
+ */
71
+
72
+ if (contentReview.status === _types.ApwContentReviewStatus.PUBLISHED) {
73
+ 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), {}, {
76
+ publishedBy: null
77
+ })
78
+ });
79
+ }
80
+ });
81
+ };
82
+
83
+ exports.updateContentReviewStatus = updateContentReviewStatus;
@@ -0,0 +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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Scope, PageWithWorkflow } from "../../types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ interface AssignWorkflowToPageParams {
4
+ listWorkflow: ApwWorkflowCrud["list"];
5
+ page: PageWithWorkflow;
6
+ }
7
+ export declare const assignWorkflowToPage: ({ listWorkflow, page }: AssignWorkflowToPageParams) => Promise<void>;
8
+ export declare const hasPages: (workflow: ApwWorkflow) => Boolean;
9
+ export declare const shouldUpdatePages: (scope: ApwWorkflowScope, prevScope: ApwWorkflowScope) => Boolean;
10
+ interface GetUpdatePageOpsResult {
11
+ addedPages: string[];
12
+ removedPages: string[];
13
+ }
14
+ export declare const getPagesDiff: (currentPages: string[], prevPages: string[]) => GetUpdatePageOpsResult;
15
+ interface UpdatePageSettingsParams {
16
+ getPage: PageBuilderContextObject["getPage"];
17
+ updatePage: PageBuilderContextObject["updatePage"];
18
+ uniquePageId: string;
19
+ getNewSettings: (settings: PageWithWorkflow["settings"]) => PageWithWorkflow["settings"];
20
+ }
21
+ export declare const updatePageSettings: ({ getPage, updatePage, uniquePageId, getNewSettings }: UpdatePageSettingsParams) => Promise<void>;
22
+ export {};
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updatePageSettings = exports.shouldUpdatePages = exports.hasPages = exports.getPagesDiff = exports.assignWorkflowToPage = void 0;
9
+
10
+ var _get = _interopRequireDefault(require("lodash/get"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _types = require("../../types");
15
+
16
+ var _utils = require("../utils");
17
+
18
+ const isWorkflowApplicable = (page, workflow) => {
19
+ const application = workflow.app;
20
+
21
+ if (application !== _types.ApwWorkflowApplications.PB) {
22
+ return false;
23
+ }
24
+
25
+ const scopeType = workflow.scope.type;
26
+
27
+ if (scopeType === _types.WorkflowScopeTypes.DEFAULT) {
28
+ return true;
29
+ } else if (scopeType === _types.WorkflowScopeTypes.CUSTOM) {
30
+ const categories = (0, _get.default)(workflow, "scope.data.categories");
31
+
32
+ if (Array.isArray(categories) && categories.includes(page.category)) {
33
+ return true;
34
+ }
35
+
36
+ const pages = (0, _get.default)(workflow, "scope.data.pages");
37
+
38
+ if (Array.isArray(pages) && pages.includes(page.pid)) {
39
+ return true;
40
+ }
41
+
42
+ return false;
43
+ }
44
+
45
+ throw new _error.default(`Unknown scope type "${scopeType}".`, "UNKNOWN_SCOPE_TYPE", {
46
+ workflow
47
+ });
48
+ };
49
+
50
+ const assignWorkflowToPage = async ({
51
+ listWorkflow,
52
+ page
53
+ }) => {
54
+ /**
55
+ * Lookup and assign "workflowId".
56
+ */
57
+ try {
58
+ /*
59
+ * List all workflows for app pageBuilder
60
+ */
61
+ const [entries] = await listWorkflow({
62
+ where: {
63
+ app: _types.ApwWorkflowApplications.PB
64
+ }
65
+ });
66
+ /*
67
+ * Re-order them based on workflow scope and pre-defined rule i.e.
68
+ * "specific" entry -> entry for a "category" -> "default".
69
+ * There can be more than one workflow with same "scope" and "app".
70
+ * Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.
71
+ */
72
+
73
+ const sortedWorkflows = entries.sort(_utils.workflowByPrecedenceDesc).sort(_utils.workflowByCreatedOnDesc);
74
+
75
+ for (const workflow of sortedWorkflows) {
76
+ /**
77
+ * Assign the first applicable workflow to the page and exit.
78
+ */
79
+ if (isWorkflowApplicable(page, workflow)) {
80
+ page.settings.apw = {
81
+ workflowId: workflow.id,
82
+ contentReviewId: null
83
+ };
84
+ break;
85
+ }
86
+ }
87
+ } catch (e) {
88
+ throw new _error.default(`Failed to assign workflow to page "${page.pid}".`, e.code, e.data);
89
+ }
90
+ };
91
+
92
+ exports.assignWorkflowToPage = assignWorkflowToPage;
93
+
94
+ const hasPages = workflow => {
95
+ const {
96
+ app,
97
+ scope
98
+ } = workflow;
99
+ return app === _types.ApwWorkflowApplications.PB && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.pages);
100
+ };
101
+
102
+ exports.hasPages = hasPages;
103
+
104
+ const shouldUpdatePages = (scope, prevScope) => {
105
+ /**
106
+ * Bail out early if the scope is not "CUSTOM" - at that point all pages should be updated.
107
+ */
108
+ if (prevScope.type !== _types.WorkflowScopeTypes.CUSTOM) {
109
+ return true;
110
+ }
111
+
112
+ const prevScopePages = (0, _get.default)(prevScope, "data.pages");
113
+ const currentScopePages = (0, _get.default)(scope, "data.pages");
114
+ /**
115
+ * Bail out early if there were no pages assigned previously.
116
+ */
117
+
118
+ if (prevScopePages.length === 0) {
119
+ return true;
120
+ }
121
+ /**
122
+ * Bail out early if number of pages has been changed.
123
+ */
124
+
125
+
126
+ if (currentScopePages.length !== prevScopePages.length) {
127
+ return true;
128
+ }
129
+ /*
130
+ * Check whether previous scope has the exactly same pages as in the new scope.
131
+ */
132
+
133
+
134
+ return !prevScopePages.every(pid => currentScopePages.includes(pid));
135
+ };
136
+
137
+ exports.shouldUpdatePages = shouldUpdatePages;
138
+
139
+ const getPagesDiff = (currentPages, prevPages) => {
140
+ const addedPages = currentPages.filter(id => !prevPages.includes(id));
141
+ const removedPages = prevPages.filter(id => !currentPages.includes(id));
142
+ return {
143
+ addedPages,
144
+ removedPages
145
+ };
146
+ };
147
+
148
+ exports.getPagesDiff = getPagesDiff;
149
+
150
+ const updatePageSettings = async ({
151
+ getPage,
152
+ updatePage,
153
+ uniquePageId,
154
+ getNewSettings
155
+ }) => {
156
+ try {
157
+ /**
158
+ * Currently, we only assign "workflow" to latest page.
159
+ */
160
+ const page = await getPage(uniquePageId);
161
+ /**
162
+ * We can't update a page that is "locked".
163
+ */
164
+
165
+ if (page.locked) {
166
+ return;
167
+ }
168
+ /**
169
+ * There can be more than one workflow with same `scope` for same `app`. That is why;
170
+ * We'll update the workflow reference even though it already had one assign.
171
+ */
172
+
173
+
174
+ await updatePage(page.id, {
175
+ settings: getNewSettings(page.settings)
176
+ });
177
+ } catch (e) {
178
+ if (e.code !== "NOT_FOUND") {
179
+ throw e;
180
+ }
181
+ }
182
+ };
183
+
184
+ exports.updatePageSettings = updatePageSettings;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isWorkflowApplicable","page","workflow","application","app","ApwWorkflowApplications","PB","scopeType","scope","type","WorkflowScopeTypes","DEFAULT","CUSTOM","categories","get","Array","isArray","includes","category","pages","pid","WebinyError","assignWorkflowToPage","listWorkflow","entries","where","sortedWorkflows","sort","workflowByPrecedenceDesc","workflowByCreatedOnDesc","settings","apw","workflowId","id","contentReviewId","e","code","data","hasPages","shouldUpdatePages","prevScope","prevScopePages","currentScopePages","length","every","getPagesDiff","currentPages","prevPages","addedPages","filter","removedPages","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","locked"],"sources":["utils.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport WebinyError from \"@webiny/error\";\nimport {\n ApwWorkflow,\n ApwWorkflowApplications,\n ApwWorkflowCrud,\n ApwWorkflowScope,\n PageWithWorkflow,\n WorkflowScopeTypes\n} from \"~/types\";\nimport { workflowByCreatedOnDesc, workflowByPrecedenceDesc } from \"~/plugins/utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\nconst isWorkflowApplicable = (page: PageWithWorkflow, workflow: ApwWorkflow) => {\n const application = workflow.app;\n if (application !== ApwWorkflowApplications.PB) {\n return false;\n }\n\n const scopeType = workflow.scope.type;\n\n if (scopeType === WorkflowScopeTypes.DEFAULT) {\n return true;\n } else if (scopeType === WorkflowScopeTypes.CUSTOM) {\n const categories = get(workflow, \"scope.data.categories\");\n\n if (Array.isArray(categories) && categories.includes(page.category)) {\n return true;\n }\n\n const pages = get(workflow, \"scope.data.pages\");\n if (Array.isArray(pages) && pages.includes(page.pid)) {\n return true;\n }\n return false;\n }\n throw new WebinyError(`Unknown scope type \"${scopeType}\".`, \"UNKNOWN_SCOPE_TYPE\", {\n workflow\n });\n};\n\ninterface AssignWorkflowToPageParams {\n listWorkflow: ApwWorkflowCrud[\"list\"];\n page: PageWithWorkflow;\n}\n\nexport const assignWorkflowToPage = async ({ listWorkflow, page }: AssignWorkflowToPageParams) => {\n /**\n * Lookup and assign \"workflowId\".\n */\n try {\n /*\n * List all workflows for app pageBuilder\n */\n const [entries] = await listWorkflow({\n where: {\n app: ApwWorkflowApplications.PB\n }\n });\n\n /*\n * Re-order them based on workflow scope and pre-defined rule i.e.\n * \"specific\" entry -> entry for a \"category\" -> \"default\".\n * There can be more than one workflow with same \"scope\" and \"app\".\n * Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.\n */\n const sortedWorkflows = entries\n .sort(workflowByPrecedenceDesc)\n .sort(workflowByCreatedOnDesc);\n\n for (const workflow of sortedWorkflows) {\n /**\n * Assign the first applicable workflow to the page and exit.\n */\n if (isWorkflowApplicable(page, workflow)) {\n page.settings.apw = {\n workflowId: workflow.id,\n contentReviewId: null\n };\n break;\n }\n }\n } catch (e) {\n throw new WebinyError(`Failed to assign workflow to page \"${page.pid}\".`, e.code, e.data);\n }\n};\n\nexport const hasPages = (workflow: ApwWorkflow): Boolean => {\n const { app, scope } = workflow;\n return (\n app === ApwWorkflowApplications.PB &&\n scope.type === WorkflowScopeTypes.CUSTOM &&\n scope.data &&\n Array.isArray(scope.data.pages)\n );\n};\n\nexport const shouldUpdatePages = (\n scope: ApwWorkflowScope,\n prevScope: ApwWorkflowScope\n): Boolean => {\n /**\n * Bail out early if the scope is not \"CUSTOM\" - at that point all pages should be updated.\n */\n if (prevScope.type !== WorkflowScopeTypes.CUSTOM) {\n return true;\n }\n const prevScopePages: string[] = get(prevScope, \"data.pages\");\n const currentScopePages: string[] = get(scope, \"data.pages\");\n /**\n * Bail out early if there were no pages assigned previously.\n */\n if (prevScopePages.length === 0) {\n return true;\n }\n /**\n * Bail out early if number of pages has been changed.\n */\n if (currentScopePages.length !== prevScopePages.length) {\n return true;\n }\n /*\n * Check whether previous scope has the exactly same pages as in the new scope.\n */\n return !prevScopePages.every(pid => currentScopePages.includes(pid));\n};\n\ninterface GetUpdatePageOpsResult {\n addedPages: string[];\n removedPages: string[];\n}\n\nexport const getPagesDiff = (\n currentPages: string[],\n prevPages: string[]\n): GetUpdatePageOpsResult => {\n const addedPages = currentPages.filter(id => !prevPages.includes(id));\n const removedPages = prevPages.filter(id => !currentPages.includes(id));\n\n return {\n addedPages,\n removedPages\n };\n};\n\ninterface UpdatePageSettingsParams {\n getPage: PageBuilderContextObject[\"getPage\"];\n updatePage: PageBuilderContextObject[\"updatePage\"];\n uniquePageId: string;\n getNewSettings: (settings: PageWithWorkflow[\"settings\"]) => PageWithWorkflow[\"settings\"];\n}\n\nexport const updatePageSettings = async ({\n getPage,\n updatePage,\n uniquePageId,\n getNewSettings\n}: UpdatePageSettingsParams) => {\n try {\n /**\n * Currently, we only assign \"workflow\" to latest page.\n */\n const page = await getPage<PageWithWorkflow>(uniquePageId);\n /**\n * We can't update a page that is \"locked\".\n */\n if (page.locked) {\n return;\n }\n /**\n * There can be more than one workflow with same `scope` for same `app`. That is why;\n * We'll update the workflow reference even though it already had one assign.\n */\n await updatePage(page.id, {\n settings: getNewSettings(page.settings)\n });\n } catch (e) {\n if (e.code !== \"NOT_FOUND\") {\n throw e;\n }\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAQA;;AAGA,MAAMA,oBAAoB,GAAG,CAACC,IAAD,EAAyBC,QAAzB,KAAmD;EAC5E,MAAMC,WAAW,GAAGD,QAAQ,CAACE,GAA7B;;EACA,IAAID,WAAW,KAAKE,8BAAA,CAAwBC,EAA5C,EAAgD;IAC5C,OAAO,KAAP;EACH;;EAED,MAAMC,SAAS,GAAGL,QAAQ,CAACM,KAAT,CAAeC,IAAjC;;EAEA,IAAIF,SAAS,KAAKG,yBAAA,CAAmBC,OAArC,EAA8C;IAC1C,OAAO,IAAP;EACH,CAFD,MAEO,IAAIJ,SAAS,KAAKG,yBAAA,CAAmBE,MAArC,EAA6C;IAChD,MAA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MAAMC,UAAU,GAAGF,YAAY,CAACG,MAAb,CAAoBhB,EAAE,IAAI,CAACc,SAAS,CAAC9B,QAAV,CAAmBgB,EAAnB,CAA3B,CAAnB;EACA,MAAMiB,YAAY,GAAGH,SAAS,CAACE,MAAV,CAAiBhB,EAAE,IAAI,CAACa,YAAY,CAAC7B,QAAb,CAAsBgB,EAAtB,CAAxB,CAArB;EAEA,OAAO;IACHe,UADG;IAEHE;EAFG,CAAP;AAIH,CAXM;;;;AAoBA,MAAMC,kBAAkB,GAAG,OAAO;EACrCC,OADqC;EAErCC,UAFqC;EAGrCC,YAHqC;EAIrCC;AAJqC,CAAP,KAKF;EAC5B,IAAI;IACA;AACR;AACA;IACQ,MAAMtD,IAAI,GAAG,MAAMmD,OAAO,CAAmBE,YAAnB,CAA1B;IACA;AACR;AACA;;IACQ,IAAIrD,IAAI,CAACuD,MAAT,EAAiB;MACb;IACH;IACD;AACR;AACA;AACA;;;IACQ,MAAMH,UAAU,CAACpD,IAAI,CAACgC,EAAN,EAAU;MACtBH,QAAQ,EAAEyB,cAAc,CAACtD,IAAI,CAAC6B,QAAN;IADF,CAAV,CAAhB;EAGH,CAlBD,CAkBE,OAAOK,CAAP,EAAU;IACR,IAAIA,CAAC,CAACC,IAAF,KAAW,WAAf,EAA4B;MACxB,MAAMD,CAAN;IACH;EACJ;AACJ,CA7BM"}
@@ -1,6 +1,7 @@
1
1
  import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { ApwContentReviewStep, ApwContentReviewStepStatus, ApwReviewerCrud, ApwWorkflowStep, ApwWorkflowStepTypes } from "../types";
3
2
  import { SecurityIdentity } from "@webiny/api-security/types";
3
+ import { ApwChangeRequest, ApwContentReview, ApwContentReviewCrud, ApwContentReviewStep, ApwContentReviewStepStatus, ApwContext, ApwReviewerCrud, ApwWorkflow, ApwWorkflowStep, ApwWorkflowStepTypes } from "../types";
4
+ export declare const getNanoid: (size?: number | undefined) => string;
4
5
  export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "fieldId"> {
5
6
  parent: string;
6
7
  }
@@ -11,5 +12,24 @@ export interface HasReviewersParams {
11
12
  }
12
13
  export declare const hasReviewer: (params: HasReviewersParams) => Promise<Boolean>;
13
14
  export declare const getValue: (object: Record<string, any>, key: string) => any;
14
- export declare const getContentReviewStepInitialStatus: (workflowSteps: ApwWorkflowStep[], index: number, previousStepStatus: ApwContentReviewStepStatus) => ApwContentReviewStepStatus;
15
+ export declare const getContentReviewStepInitialStatus: (workflowSteps: ApwWorkflowStep[], index: number, previousStepStatus?: ApwContentReviewStepStatus) => ApwContentReviewStepStatus;
15
16
  export declare const getNextStepStatus: (previousStepType: ApwWorkflowStepTypes, previousStepStatus: ApwContentReviewStepStatus) => ApwContentReviewStepStatus;
17
+ export interface ExtractContentReviewIdAndStepResult {
18
+ id: string;
19
+ stepId: string;
20
+ }
21
+ export declare const extractContentReviewIdAndStep: (step: ApwChangeRequest["step"]) => ExtractContentReviewIdAndStepResult;
22
+ declare type SafelyGetContentReviewParams = Pick<UpdateContentReviewParams, "id" | "contentReviewMethods">;
23
+ export declare const safelyGetContentReview: ({ id, contentReviewMethods }: SafelyGetContentReviewParams) => Promise<ApwContentReview | null>;
24
+ export interface UpdateContentReviewParams {
25
+ id: string;
26
+ contentReviewMethods: ApwContentReviewCrud;
27
+ getNewContentReviewData: (entry: ApwContentReview) => ApwContentReview;
28
+ }
29
+ export declare const updateContentReview: ({ contentReviewMethods, id, getNewContentReviewData }: UpdateContentReviewParams) => Promise<void>;
30
+ export declare const updateContentReviewStep: (steps: ApwContentReviewStep[], stepId: string, updater: (step: ApwContentReviewStep) => ApwContentReviewStep) => ApwContentReviewStep[];
31
+ declare type CheckInstallationParams = Pick<ApwContext, "tenancy" | "i18n">;
32
+ export declare const isInstallationPending: ({ tenancy, i18n }: CheckInstallationParams) => boolean;
33
+ export declare const workflowByPrecedenceDesc: (a: ApwWorkflow, b: ApwWorkflow) => number;
34
+ export declare const workflowByCreatedOnDesc: (a: ApwWorkflow, b: ApwWorkflow) => number;
35
+ export {};