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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/ContentApwSettingsPlugin.d.ts +10 -0
  2. package/ContentApwSettingsPlugin.js +17 -0
  3. package/ContentApwSettingsPlugin.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +34 -0
  6. package/crud/createChangeRequestMethods.d.ts +2 -0
  7. package/crud/createChangeRequestMethods.js +95 -0
  8. package/crud/createChangeRequestMethods.js.map +1 -0
  9. package/crud/createCommentMethods.d.ts +2 -0
  10. package/crud/createCommentMethods.js +96 -0
  11. package/crud/createCommentMethods.js.map +1 -0
  12. package/crud/createContentReviewMethods.d.ts +10 -0
  13. package/crud/createContentReviewMethods.js +552 -0
  14. package/crud/createContentReviewMethods.js.map +1 -0
  15. package/crud/createReviewerMethods.d.ts +2 -0
  16. package/crud/createReviewerMethods.js +96 -0
  17. package/crud/createReviewerMethods.js.map +1 -0
  18. package/crud/createWorkflowMethods.d.ts +2 -0
  19. package/crud/createWorkflowMethods.js +96 -0
  20. package/crud/createWorkflowMethods.js.map +1 -0
  21. package/crud/index.d.ts +2 -0
  22. package/crud/index.js +100 -0
  23. package/crud/index.js.map +1 -0
  24. package/crud/utils.d.ts +21 -0
  25. package/crud/utils.js +142 -0
  26. package/crud/utils.js.map +1 -0
  27. package/index.d.ts +4 -0
  28. package/index.js +34 -0
  29. package/index.js.map +1 -0
  30. package/package.json +75 -0
  31. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
  32. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
  33. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
  34. package/plugins/cms/README.md +49 -0
  35. package/plugins/cms/apwEntryPlugins.d.ts +8 -0
  36. package/plugins/cms/apwEntryPlugins.js +50 -0
  37. package/plugins/cms/apwEntryPlugins.js.map +1 -0
  38. package/plugins/cms/index.d.ts +12 -0
  39. package/plugins/cms/index.js +37 -0
  40. package/plugins/cms/index.js.map +1 -0
  41. package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
  42. package/plugins/cms/linkContentReviewToEntry.js +108 -0
  43. package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
  44. package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
  45. package/plugins/cms/linkWorkflowToEntry.js +166 -0
  46. package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
  47. package/plugins/cms/triggerContentReview.d.ts +8 -0
  48. package/plugins/cms/triggerContentReview.js +59 -0
  49. package/plugins/cms/triggerContentReview.js.map +1 -0
  50. package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
  51. package/plugins/cms/updateContentReviewStatus.js +101 -0
  52. package/plugins/cms/updateContentReviewStatus.js.map +1 -0
  53. package/plugins/cms/utils.d.ts +27 -0
  54. package/plugins/cms/utils.js +211 -0
  55. package/plugins/cms/utils.js.map +1 -0
  56. package/plugins/context.d.ts +5 -0
  57. package/plugins/context.js +146 -0
  58. package/plugins/context.js.map +1 -0
  59. package/plugins/graphql/changeRequest.gql.d.ts +4 -0
  60. package/plugins/graphql/changeRequest.gql.js +155 -0
  61. package/plugins/graphql/changeRequest.gql.js.map +1 -0
  62. package/plugins/graphql/comment.gql.d.ts +4 -0
  63. package/plugins/graphql/comment.gql.js +160 -0
  64. package/plugins/graphql/comment.gql.js.map +1 -0
  65. package/plugins/graphql/contentReview.gql.d.ts +4 -0
  66. package/plugins/graphql/contentReview.gql.js +382 -0
  67. package/plugins/graphql/contentReview.gql.js.map +1 -0
  68. package/plugins/graphql/reviewer.gql.d.ts +4 -0
  69. package/plugins/graphql/reviewer.gql.js +114 -0
  70. package/plugins/graphql/reviewer.gql.js.map +1 -0
  71. package/plugins/graphql/workflow.gql.d.ts +4 -0
  72. package/plugins/graphql/workflow.gql.js +205 -0
  73. package/plugins/graphql/workflow.gql.js.map +1 -0
  74. package/plugins/graphql.d.ts +4 -0
  75. package/plugins/graphql.js +95 -0
  76. package/plugins/graphql.js.map +1 -0
  77. package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
  78. package/plugins/hooks/createReviewerFromIdentity.js +62 -0
  79. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
  80. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
  81. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
  82. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
  83. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
  84. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
  85. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
  86. package/plugins/hooks/index.d.ts +3 -0
  87. package/plugins/hooks/index.js +68 -0
  88. package/plugins/hooks/index.js.map +1 -0
  89. package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
  90. package/plugins/hooks/initializeContentReviewSteps.js +89 -0
  91. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
  92. package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
  93. package/plugins/hooks/updatePendingChangeRequests.js +98 -0
  94. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
  95. package/plugins/hooks/updateTotalComments.d.ts +3 -0
  96. package/plugins/hooks/updateTotalComments.js +157 -0
  97. package/plugins/hooks/updateTotalComments.js.map +1 -0
  98. package/plugins/hooks/validateChangeRequest.d.ts +2 -0
  99. package/plugins/hooks/validateChangeRequest.js +64 -0
  100. package/plugins/hooks/validateChangeRequest.js.map +1 -0
  101. package/plugins/hooks/validateComment.d.ts +2 -0
  102. package/plugins/hooks/validateComment.js +47 -0
  103. package/plugins/hooks/validateComment.js.map +1 -0
  104. package/plugins/hooks/validateContentReview.d.ts +2 -0
  105. package/plugins/hooks/validateContentReview.js +38 -0
  106. package/plugins/hooks/validateContentReview.js.map +1 -0
  107. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
  108. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
  109. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
  110. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
  111. package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
  112. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
  113. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
  114. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
  115. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
  116. package/plugins/pageBuilder/index.d.ts +11 -0
  117. package/plugins/pageBuilder/index.js +45 -0
  118. package/plugins/pageBuilder/index.js.map +1 -0
  119. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
  120. package/plugins/pageBuilder/linkContentReviewToPage.js +93 -0
  121. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
  122. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
  123. package/plugins/pageBuilder/linkWorkflowToPage.js +182 -0
  124. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
  125. package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
  126. package/plugins/pageBuilder/triggerContentReview.js +50 -0
  127. package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
  128. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
  129. package/plugins/pageBuilder/updateContentReviewStatus.js +83 -0
  130. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
  131. package/plugins/pageBuilder/utils.d.ts +22 -0
  132. package/plugins/pageBuilder/utils.js +184 -0
  133. package/plugins/pageBuilder/utils.js.map +1 -0
  134. package/plugins/utils.d.ts +35 -0
  135. package/plugins/utils.js +197 -0
  136. package/plugins/utils.js.map +1 -0
  137. package/scheduler/createScheduleActionMethods.d.ts +2 -0
  138. package/scheduler/createScheduleActionMethods.js +146 -0
  139. package/scheduler/createScheduleActionMethods.js.map +1 -0
  140. package/scheduler/handlers/executeAction/index.d.ts +13 -0
  141. package/scheduler/handlers/executeAction/index.js +172 -0
  142. package/scheduler/handlers/executeAction/index.js.map +1 -0
  143. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
  144. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
  145. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
  146. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
  147. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
  148. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
  149. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
  150. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
  151. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
  152. package/scheduler/handlers/executeAction/security.d.ts +4 -0
  153. package/scheduler/handlers/executeAction/security.js +68 -0
  154. package/scheduler/handlers/executeAction/security.js.map +1 -0
  155. package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
  156. package/scheduler/handlers/scheduleAction/index.js +165 -0
  157. package/scheduler/handlers/scheduleAction/index.js.map +1 -0
  158. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
  159. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +176 -0
  160. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
  161. package/scheduler/handlers/utils.d.ts +33 -0
  162. package/scheduler/handlers/utils.js +168 -0
  163. package/scheduler/handlers/utils.js.map +1 -0
  164. package/scheduler/index.d.ts +2 -0
  165. package/scheduler/index.js +27 -0
  166. package/scheduler/index.js.map +1 -0
  167. package/scheduler/types.d.ts +171 -0
  168. package/scheduler/types.js +34 -0
  169. package/scheduler/types.js.map +1 -0
  170. package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
  171. package/storageOperations/changeRequestStorageOperations.js +126 -0
  172. package/storageOperations/changeRequestStorageOperations.js.map +1 -0
  173. package/storageOperations/commentStorageOperations.d.ts +3 -0
  174. package/storageOperations/commentStorageOperations.js +142 -0
  175. package/storageOperations/commentStorageOperations.js.map +1 -0
  176. package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
  177. package/storageOperations/contentReviewStorageOperations.js +97 -0
  178. package/storageOperations/contentReviewStorageOperations.js.map +1 -0
  179. package/storageOperations/index.d.ts +15 -0
  180. package/storageOperations/index.js +52 -0
  181. package/storageOperations/index.js.map +1 -0
  182. package/storageOperations/models/changeRequest.model.d.ts +3 -0
  183. package/storageOperations/models/changeRequest.model.js +59 -0
  184. package/storageOperations/models/changeRequest.model.js.map +1 -0
  185. package/storageOperations/models/comment.model.d.ts +7 -0
  186. package/storageOperations/models/comment.model.js +60 -0
  187. package/storageOperations/models/comment.model.js.map +1 -0
  188. package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
  189. package/storageOperations/models/contentModelPluginFactory.js +32 -0
  190. package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
  191. package/storageOperations/models/contentReview.model.d.ts +7 -0
  192. package/storageOperations/models/contentReview.model.js +257 -0
  193. package/storageOperations/models/contentReview.model.js.map +1 -0
  194. package/storageOperations/models/index.d.ts +2 -0
  195. package/storageOperations/models/index.js +115 -0
  196. package/storageOperations/models/index.js.map +1 -0
  197. package/storageOperations/models/reviewer.model.d.ts +3 -0
  198. package/storageOperations/models/reviewer.model.js +55 -0
  199. package/storageOperations/models/reviewer.model.js.map +1 -0
  200. package/storageOperations/models/utils.d.ts +3 -0
  201. package/storageOperations/models/utils.js +36 -0
  202. package/storageOperations/models/utils.js.map +1 -0
  203. package/storageOperations/models/workflow.model.d.ts +12 -0
  204. package/storageOperations/models/workflow.model.js +208 -0
  205. package/storageOperations/models/workflow.model.js.map +1 -0
  206. package/storageOperations/reviewerStorageOperations.d.ts +3 -0
  207. package/storageOperations/reviewerStorageOperations.js +93 -0
  208. package/storageOperations/reviewerStorageOperations.js.map +1 -0
  209. package/storageOperations/types.d.ts +34 -0
  210. package/storageOperations/types.js +5 -0
  211. package/storageOperations/types.js.map +1 -0
  212. package/storageOperations/workflowStorageOperations.d.ts +3 -0
  213. package/storageOperations/workflowStorageOperations.js +115 -0
  214. package/storageOperations/workflowStorageOperations.js.map +1 -0
  215. package/types.d.ts +737 -0
  216. package/types.js +69 -0
  217. package/types.js.map +1 -0
  218. package/utils/contentApwSettingsPlugin.d.ts +9 -0
  219. package/utils/contentApwSettingsPlugin.js +26 -0
  220. package/utils/contentApwSettingsPlugin.js.map +1 -0
  221. package/utils/errors.d.ts +16 -0
  222. package/utils/errors.js +75 -0
  223. package/utils/errors.js.map +1 -0
  224. package/utils/fieldResolver.d.ts +16 -0
  225. package/utils/fieldResolver.js +60 -0
  226. package/utils/fieldResolver.js.map +1 -0
  227. package/utils/resolve.d.ts +3 -0
  228. package/utils/resolve.js +18 -0
  229. package/utils/resolve.js.map +1 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.apwContentPagePlugins = void 0;
7
+
8
+ var _api = require("@webiny/api");
9
+
10
+ var _types = require("../../types");
11
+
12
+ const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
13
+ const {
14
+ apw,
15
+ pageBuilder
16
+ } = context;
17
+ apw.addContentGetter(_types.ApwContentTypes.PAGE, async id => {
18
+ return pageBuilder.getPage(id);
19
+ });
20
+ apw.addContentPublisher(_types.ApwContentTypes.PAGE, async id => {
21
+ await pageBuilder.publishPage(id);
22
+ return true;
23
+ });
24
+ apw.addContentUnPublisher(_types.ApwContentTypes.PAGE, async id => {
25
+ await pageBuilder.unpublishPage(id);
26
+ return true;
27
+ });
28
+ });
29
+
30
+ exports.apwContentPagePlugins = apwContentPagePlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MACjC,IAAIC,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;EAC3C,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,OAA7B;EAEAC,GAAG,CAACE,gBAAJ,CAAqBC,sBAAA,CAAgBC,IAArC,EAA2C,MAAMC,EAAN,IAAY;IACnD,OAAOJ,WAAW,CAACK,OAAZ,CAAsCD,EAAtC,CAAP;EACH,CAFD;EAIAL,GAAG,CAACO,mBAAJ,CAAwBJ,sBAAA,CAAgBC,IAAxC,EAA8C,MAAMC,EAAN,IAAY;IACtD,MAAMJ,WAAW,CAACO,WAAZ,CAA0CH,EAA1C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;EAKAL,GAAG,CAACS,qBAAJ,CAA0BN,sBAAA,CAAgBC,IAA1C,EAAgD,MAAMC,EAAN,IAAY;IACxD,MAAMJ,WAAW,CAACS,aAAZ,CAA4CL,EAA5C,CAAN;IACA,OAAO,IAAP;EACH,CAHD;AAIH,CAhBD,CADG"}
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins";
2
+ import { ApwContext } from "../../types";
3
+ export declare const extendPbPageSettingsSchema: () => GraphQLSchemaPlugin<ApwContext>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extendPbPageSettingsSchema = void 0;
7
+
8
+ var _plugins = require("@webiny/handler-graphql/plugins");
9
+
10
+ const extendPbPageSettingsSchema = () => new _plugins.GraphQLSchemaPlugin({
11
+ typeDefs:
12
+ /* GraphQL */
13
+ `
14
+ type PbApwPageSettings {
15
+ workflowId: ID
16
+ contentReviewId: ID
17
+ }
18
+
19
+ extend type PbPageSettings {
20
+ apw: PbApwPageSettings
21
+ }
22
+ `
23
+ });
24
+
25
+ exports.extendPbPageSettingsSchema = extendPbPageSettingsSchema;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["extendPbPageSettingsSchema","GraphQLSchemaPlugin","typeDefs"],"sources":["extendPbPageSettingsSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ApwContext } from \"~/types\";\n\nexport const extendPbPageSettingsSchema = () =>\n new GraphQLSchemaPlugin<ApwContext>({\n typeDefs: /* GraphQL */ `\n type PbApwPageSettings {\n workflowId: ID\n contentReviewId: ID\n }\n\n extend type PbPageSettings {\n apw: PbApwPageSettings\n }\n `\n });\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,0BAA0B,GAAG,MACtC,IAAIC,4BAAJ,CAAoC;EAChCC,QAAQ;EAAE;EAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVwC,CAApC,CADG"}
@@ -0,0 +1,11 @@
1
+ import { Security } from "@webiny/api-security/types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ import { AdvancedPublishingWorkflow } from "../../types";
4
+ import { PluginsContainer } from "@webiny/plugins";
5
+ export interface ApwPageBuilderPluginsParams {
6
+ pageBuilder: PageBuilderContextObject;
7
+ apw: AdvancedPublishingWorkflow;
8
+ security: Security;
9
+ plugins: PluginsContainer;
10
+ }
11
+ export declare const apwPageBuilderHooks: (params: ApwPageBuilderPluginsParams) => void;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.apwPageBuilderHooks = void 0;
7
+
8
+ var _triggerContentReview = require("./triggerContentReview");
9
+
10
+ var _linkContentReviewToPage = require("./linkContentReviewToPage");
11
+
12
+ var _updateContentReviewStatus = require("./updateContentReviewStatus");
13
+
14
+ var _linkWorkflowToPage = require("./linkWorkflowToPage");
15
+
16
+ var _PageApwSettingsGetterPlugin = require("./PageApwSettingsGetterPlugin");
17
+
18
+ const apwPageBuilderHooks = params => {
19
+ const {
20
+ pageBuilder,
21
+ apw,
22
+ security,
23
+ plugins
24
+ } = params;
25
+ plugins.register(new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin());
26
+ (0, _triggerContentReview.triggerContentReview)({
27
+ apw,
28
+ pageBuilder
29
+ });
30
+ (0, _linkContentReviewToPage.linkContentReviewToPage)({
31
+ apw,
32
+ pageBuilder
33
+ });
34
+ (0, _updateContentReviewStatus.updateContentReviewStatus)({
35
+ apw,
36
+ pageBuilder,
37
+ security
38
+ });
39
+ (0, _linkWorkflowToPage.linkWorkflowToPage)({
40
+ apw,
41
+ pageBuilder
42
+ });
43
+ };
44
+
45
+ exports.apwPageBuilderHooks = apwPageBuilderHooks;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["apwPageBuilderHooks","params","pageBuilder","apw","security","plugins","register","PageApwSettingsGetterPlugin","triggerContentReview","linkContentReviewToPage","updateContentReviewStatus","linkWorkflowToPage"],"sources":["index.ts"],"sourcesContent":["import { Security } from \"@webiny/api-security/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { linkContentReviewToPage } from \"./linkContentReviewToPage\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { linkWorkflowToPage } from \"./linkWorkflowToPage\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageApwSettingsGetterPlugin } from \"~/plugins/pageBuilder/PageApwSettingsGetterPlugin\";\n\nexport interface ApwPageBuilderPluginsParams {\n pageBuilder: PageBuilderContextObject;\n apw: AdvancedPublishingWorkflow;\n security: Security;\n plugins: PluginsContainer;\n}\n\nexport const apwPageBuilderHooks = (params: ApwPageBuilderPluginsParams) => {\n const { pageBuilder, apw, security, plugins } = params;\n\n plugins.register(new PageApwSettingsGetterPlugin());\n\n triggerContentReview({\n apw,\n pageBuilder\n });\n linkContentReviewToPage({\n apw,\n pageBuilder\n });\n updateContentReviewStatus({\n apw,\n pageBuilder,\n security\n });\n linkWorkflowToPage({\n apw,\n pageBuilder\n });\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAEA;;AASO,MAAMA,mBAAmB,GAAIC,MAAD,IAAyC;EACxE,MAAM;IAAEC,WAAF;IAAeC,GAAf;IAAoBC,QAApB;IAA8BC;EAA9B,IAA0CJ,MAAhD;EAEAI,OAAO,CAACC,QAAR,CAAiB,IAAIC,wDAAJ,EAAjB;EAEA,IAAAC,0CAAA,EAAqB;IACjBL,GADiB;IAEjBD;EAFiB,CAArB;EAIA,IAAAO,gDAAA,EAAwB;IACpBN,GADoB;IAEpBD;EAFoB,CAAxB;EAIA,IAAAQ,oDAAA,EAA0B;IACtBP,GADsB;IAEtBD,WAFsB;IAGtBE;EAHsB,CAA1B;EAKA,IAAAO,sCAAA,EAAmB;IACfR,GADe;IAEfD;EAFe,CAAnB;AAIH,CAtBM"}
@@ -0,0 +1,8 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ interface LinkContentReviewToPageParams {
4
+ apw: AdvancedPublishingWorkflow;
5
+ pageBuilder: PageBuilderContextObject;
6
+ }
7
+ export declare const linkContentReviewToPage: (params: LinkContentReviewToPageParams) => void;
8
+ export {};
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.linkContentReviewToPage = void 0;
9
+
10
+ var _set = _interopRequireDefault(require("lodash/set"));
11
+
12
+ var _get = _interopRequireDefault(require("lodash/get"));
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _types = require("../../types");
17
+
18
+ var _utils = require("./utils");
19
+
20
+ const linkContentReviewToPage = params => {
21
+ const {
22
+ apw,
23
+ pageBuilder
24
+ } = params;
25
+ apw.contentReview.onAfterContentReviewCreate.subscribe(async ({
26
+ contentReview
27
+ }) => {
28
+ const {
29
+ content
30
+ } = contentReview;
31
+
32
+ if (content.type === _types.ApwContentTypes.PAGE) {
33
+ await (0, _utils.updatePageSettings)({
34
+ getPage: pageBuilder.getPage,
35
+ updatePage: pageBuilder.updatePage,
36
+ uniquePageId: content.id,
37
+ getNewSettings: settings => {
38
+ return (0, _set.default)(settings, "apw.contentReviewId", contentReview.id);
39
+ }
40
+ });
41
+ }
42
+ });
43
+ apw.contentReview.onAfterContentReviewDelete.subscribe(async ({
44
+ contentReview
45
+ }) => {
46
+ const {
47
+ content
48
+ } = contentReview;
49
+
50
+ if (content.type === _types.ApwContentTypes.PAGE) {
51
+ await (0, _utils.updatePageSettings)({
52
+ getPage: pageBuilder.getPage,
53
+ updatePage: pageBuilder.updatePage,
54
+ uniquePageId: content.id,
55
+ getNewSettings: settings => {
56
+ return (0, _set.default)(settings, "apw.contentReviewId", null);
57
+ }
58
+ });
59
+ }
60
+ });
61
+ pageBuilder.onBeforePageDelete.subscribe(async ({
62
+ page
63
+ }) => {
64
+ const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
65
+
66
+ if (!contentReviewId) {
67
+ return;
68
+ }
69
+
70
+ let contentReview;
71
+
72
+ try {
73
+ contentReview = await apw.contentReview.get(contentReviewId);
74
+ } catch (e) {
75
+ /**
76
+ * We're handling the case whereby "contentReviewId" is still linked to page;
77
+ * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.
78
+ */
79
+ if (e.code !== "NOT_FOUND") {
80
+ throw e;
81
+ }
82
+ }
83
+
84
+ if (contentReview) {
85
+ throw new _error.default(`Cannot delete the page because a peer review has been requested. Please delete the review first.`, "CANNOT_DELETE_REVIEW_EXIST", {
86
+ contentReviewId,
87
+ page
88
+ });
89
+ }
90
+ });
91
+ };
92
+
93
+ exports.linkContentReviewToPage = linkContentReviewToPage;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["linkContentReviewToPage","params","apw","pageBuilder","contentReview","onAfterContentReviewCreate","subscribe","content","type","ApwContentTypes","PAGE","updatePageSettings","getPage","updatePage","uniquePageId","id","getNewSettings","settings","set","onAfterContentReviewDelete","onBeforePageDelete","page","contentReviewId","get","e","code","Error"],"sources":["linkContentReviewToPage.ts"],"sourcesContent":["import set from \"lodash/set\";\nimport get from \"lodash/get\";\nimport Error from \"@webiny/error\";\nimport { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { updatePageSettings } from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkContentReviewToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkContentReviewToPage = (params: LinkContentReviewToPageParams) => {\n const { apw, pageBuilder } = params;\n\n apw.contentReview.onAfterContentReviewCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type === ApwContentTypes.PAGE) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return set(settings, \"apw.contentReviewId\", contentReview.id);\n }\n });\n }\n });\n\n apw.contentReview.onAfterContentReviewDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type === ApwContentTypes.PAGE) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return set(settings, \"apw.contentReviewId\", null);\n }\n });\n }\n });\n\n pageBuilder.onBeforePageDelete.subscribe(async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n if (!contentReviewId) {\n return;\n }\n\n let contentReview;\n try {\n contentReview = await apw.contentReview.get(contentReviewId);\n } catch (e) {\n /**\n * We're handling the case whereby \"contentReviewId\" is still linked to page;\n * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.\n */\n if (e.code !== \"NOT_FOUND\") {\n throw e;\n }\n }\n\n if (contentReview) {\n throw new Error(\n `Cannot delete the page because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAQO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAC,GAAG,CAACE,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,IAArC,EAA2C;MACvC,MAAM,IAAAC,yBAAA,EAAmB;QACrBC,OAAO,EAAET,WAAW,CAACS,OADA;QAErBC,UAAU,EAAEV,WAAW,CAACU,UAFH;QAGrBC,YAAY,EAAEP,OAAO,CAACQ,EAHD;QAIrBC,cAAc,EAAEC,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ACJ,CA7BD;AA8BH,CA/DM"}
@@ -0,0 +1,8 @@
1
+ import { AdvancedPublishingWorkflow } from "../../types";
2
+ import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
3
+ interface LinkWorkflowToPageParams {
4
+ apw: AdvancedPublishingWorkflow;
5
+ pageBuilder: PageBuilderContextObject;
6
+ }
7
+ export declare const linkWorkflowToPage: (params: LinkWorkflowToPageParams) => void;
8
+ export {};
@@ -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,MAAN,IAAgB;IACvF,MAAM;MAAEK,IAAF;MAAQM;IAAR,IAAqBX,MAA3B;IACA,MAAMkB,iBAAiB,GAAG,IAAAL,YAAA,EAAIF,QA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,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;AACA;;IACY,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBD,GAAlB,CA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