@webiny/api-apw 0.0.0-ee-vpcs.549378cf03
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.
- package/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +40 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +40 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +40 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +40 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.d.ts +10 -0
- package/ContentApwSettingsPlugin.js +17 -0
- package/ContentApwSettingsPlugin.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/crud/createChangeRequestMethods.d.ts +2 -0
- package/crud/createChangeRequestMethods.js +98 -0
- package/crud/createChangeRequestMethods.js.map +1 -0
- package/crud/createCommentMethods.d.ts +2 -0
- package/crud/createCommentMethods.js +99 -0
- package/crud/createCommentMethods.js.map +1 -0
- package/crud/createContentReviewMethods.d.ts +10 -0
- package/crud/createContentReviewMethods.js +562 -0
- package/crud/createContentReviewMethods.js.map +1 -0
- package/crud/createReviewerMethods.d.ts +2 -0
- package/crud/createReviewerMethods.js +99 -0
- package/crud/createReviewerMethods.js.map +1 -0
- package/crud/createWorkflowMethods.d.ts +2 -0
- package/crud/createWorkflowMethods.js +118 -0
- package/crud/createWorkflowMethods.js.map +1 -0
- package/crud/index.d.ts +2 -0
- package/crud/index.js +96 -0
- package/crud/index.js.map +1 -0
- package/crud/utils.d.ts +21 -0
- package/crud/utils.js +138 -0
- package/crud/utils.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +38 -0
- package/index.js.map +1 -0
- package/package.json +76 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +10 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +51 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -0
- package/plugins/cms/README.md +49 -0
- package/plugins/cms/apwEntryPlugins.d.ts +8 -0
- package/plugins/cms/apwEntryPlugins.js +46 -0
- package/plugins/cms/apwEntryPlugins.js.map +1 -0
- package/plugins/cms/index.d.ts +12 -0
- package/plugins/cms/index.js +45 -0
- package/plugins/cms/index.js.map +1 -0
- package/plugins/cms/linkContentReviewToEntry.d.ts +8 -0
- package/plugins/cms/linkContentReviewToEntry.js +108 -0
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -0
- package/plugins/cms/linkWorkflowToEntry.d.ts +8 -0
- package/plugins/cms/linkWorkflowToEntry.js +166 -0
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -0
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +35 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +35 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +35 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +60 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.d.ts +8 -0
- package/plugins/cms/triggerContentReview.js +59 -0
- package/plugins/cms/triggerContentReview.js.map +1 -0
- package/plugins/cms/updateContentReviewStatus.d.ts +10 -0
- package/plugins/cms/updateContentReviewStatus.js +97 -0
- package/plugins/cms/updateContentReviewStatus.js.map +1 -0
- package/plugins/cms/utils.d.ts +27 -0
- package/plugins/cms/utils.js +207 -0
- package/plugins/cms/utils.js.map +1 -0
- package/plugins/context.d.ts +5 -0
- package/plugins/context.js +146 -0
- package/plugins/context.js.map +1 -0
- package/plugins/graphql/changeRequest.gql.d.ts +4 -0
- package/plugins/graphql/changeRequest.gql.js +155 -0
- package/plugins/graphql/changeRequest.gql.js.map +1 -0
- package/plugins/graphql/comment.gql.d.ts +4 -0
- package/plugins/graphql/comment.gql.js +160 -0
- package/plugins/graphql/comment.gql.js.map +1 -0
- package/plugins/graphql/contentReview.gql.d.ts +4 -0
- package/plugins/graphql/contentReview.gql.js +382 -0
- package/plugins/graphql/contentReview.gql.js.map +1 -0
- package/plugins/graphql/reviewer.gql.d.ts +4 -0
- package/plugins/graphql/reviewer.gql.js +116 -0
- package/plugins/graphql/reviewer.gql.js.map +1 -0
- package/plugins/graphql/workflow.gql.d.ts +4 -0
- package/plugins/graphql/workflow.gql.js +205 -0
- package/plugins/graphql/workflow.gql.js.map +1 -0
- package/plugins/graphql.d.ts +4 -0
- package/plugins/graphql.js +95 -0
- package/plugins/graphql.js.map +1 -0
- package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
- package/plugins/hooks/createReviewerFromIdentity.js +82 -0
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +67 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +59 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -0
- package/plugins/hooks/index.d.ts +3 -0
- package/plugins/hooks/index.js +74 -0
- package/plugins/hooks/index.js.map +1 -0
- package/plugins/hooks/initializeContentReviewSteps.d.ts +2 -0
- package/plugins/hooks/initializeContentReviewSteps.js +86 -0
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -0
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +20 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +10 -0
- package/plugins/hooks/listContentReviews.js +68 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +22 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +31 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +29 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +51 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
- package/plugins/hooks/updatePendingChangeRequests.js +94 -0
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -0
- package/plugins/hooks/updateTotalComments.d.ts +3 -0
- package/plugins/hooks/updateTotalComments.js +153 -0
- package/plugins/hooks/updateTotalComments.js.map +1 -0
- package/plugins/hooks/validateChangeRequest.d.ts +2 -0
- package/plugins/hooks/validateChangeRequest.js +89 -0
- package/plugins/hooks/validateChangeRequest.js.map +1 -0
- package/plugins/hooks/validateComment.d.ts +2 -0
- package/plugins/hooks/validateComment.js +57 -0
- package/plugins/hooks/validateComment.js.map +1 -0
- package/plugins/hooks/validateContentReview.d.ts +2 -0
- package/plugins/hooks/validateContentReview.js +38 -0
- package/plugins/hooks/validateContentReview.js.map +1 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +9 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +51 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -0
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +3 -0
- package/plugins/pageBuilder/apwContentPagePlugins.js +30 -0
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +3 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +25 -0
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -0
- package/plugins/pageBuilder/index.d.ts +11 -0
- package/plugins/pageBuilder/index.js +53 -0
- package/plugins/pageBuilder/index.js.map +1 -0
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +8 -0
- package/plugins/pageBuilder/linkContentReviewToPage.js +105 -0
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -0
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +8 -0
- package/plugins/pageBuilder/linkWorkflowToPage.js +194 -0
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.d.ts +8 -0
- package/plugins/pageBuilder/triggerContentReview.js +50 -0
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -0
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +10 -0
- package/plugins/pageBuilder/updateContentReviewStatus.js +79 -0
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -0
- package/plugins/pageBuilder/utils.d.ts +22 -0
- package/plugins/pageBuilder/utils.js +184 -0
- package/plugins/pageBuilder/utils.js.map +1 -0
- package/plugins/utils.d.ts +35 -0
- package/plugins/utils.js +187 -0
- package/plugins/utils.js.map +1 -0
- package/scheduler/createScheduleActionMethods.d.ts +2 -0
- package/scheduler/createScheduleActionMethods.js +149 -0
- package/scheduler/createScheduleActionMethods.js.map +1 -0
- package/scheduler/handlers/executeAction/index.d.ts +13 -0
- package/scheduler/handlers/executeAction/index.js +172 -0
- package/scheduler/handlers/executeAction/index.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +13 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +17 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +11 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +126 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +11 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +163 -0
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -0
- package/scheduler/handlers/executeAction/security.d.ts +4 -0
- package/scheduler/handlers/executeAction/security.js +68 -0
- package/scheduler/handlers/executeAction/security.js.map +1 -0
- package/scheduler/handlers/scheduleAction/index.d.ts +22 -0
- package/scheduler/handlers/scheduleAction/index.js +164 -0
- package/scheduler/handlers/scheduleAction/index.js.map +1 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +24 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +172 -0
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -0
- package/scheduler/handlers/utils.d.ts +33 -0
- package/scheduler/handlers/utils.js +168 -0
- package/scheduler/handlers/utils.js.map +1 -0
- package/scheduler/index.d.ts +2 -0
- package/scheduler/index.js +27 -0
- package/scheduler/index.js.map +1 -0
- package/scheduler/types.d.ts +171 -0
- package/scheduler/types.js +34 -0
- package/scheduler/types.js.map +1 -0
- package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
- package/storageOperations/changeRequestStorageOperations.js +122 -0
- package/storageOperations/changeRequestStorageOperations.js.map +1 -0
- package/storageOperations/commentStorageOperations.d.ts +3 -0
- package/storageOperations/commentStorageOperations.js +138 -0
- package/storageOperations/commentStorageOperations.js.map +1 -0
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
- package/storageOperations/contentReviewStorageOperations.js +93 -0
- package/storageOperations/contentReviewStorageOperations.js.map +1 -0
- package/storageOperations/index.d.ts +15 -0
- package/storageOperations/index.js +48 -0
- package/storageOperations/index.js.map +1 -0
- package/storageOperations/models/changeRequest.model.d.ts +3 -0
- package/storageOperations/models/changeRequest.model.js +59 -0
- package/storageOperations/models/changeRequest.model.js.map +1 -0
- package/storageOperations/models/comment.model.d.ts +7 -0
- package/storageOperations/models/comment.model.js +60 -0
- package/storageOperations/models/comment.model.js.map +1 -0
- package/storageOperations/models/contentModelPluginFactory.d.ts +15 -0
- package/storageOperations/models/contentModelPluginFactory.js +28 -0
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -0
- package/storageOperations/models/contentReview.model.d.ts +7 -0
- package/storageOperations/models/contentReview.model.js +258 -0
- package/storageOperations/models/contentReview.model.js.map +1 -0
- package/storageOperations/models/index.d.ts +2 -0
- package/storageOperations/models/index.js +115 -0
- package/storageOperations/models/index.js.map +1 -0
- package/storageOperations/models/reviewer.model.d.ts +3 -0
- package/storageOperations/models/reviewer.model.js +71 -0
- package/storageOperations/models/reviewer.model.js.map +1 -0
- package/storageOperations/models/utils.d.ts +3 -0
- package/storageOperations/models/utils.js +37 -0
- package/storageOperations/models/utils.js.map +1 -0
- package/storageOperations/models/workflow.model.d.ts +12 -0
- package/storageOperations/models/workflow.model.js +208 -0
- package/storageOperations/models/workflow.model.js.map +1 -0
- package/storageOperations/reviewerStorageOperations.d.ts +3 -0
- package/storageOperations/reviewerStorageOperations.js +97 -0
- package/storageOperations/reviewerStorageOperations.js.map +1 -0
- package/storageOperations/types.d.ts +34 -0
- package/storageOperations/types.js +5 -0
- package/storageOperations/types.js.map +1 -0
- package/storageOperations/workflowStorageOperations.d.ts +3 -0
- package/storageOperations/workflowStorageOperations.js +111 -0
- package/storageOperations/workflowStorageOperations.js.map +1 -0
- package/types.d.ts +752 -0
- package/types.js +69 -0
- package/types.js.map +1 -0
- package/utils/contentApwSettingsPlugin.d.ts +9 -0
- package/utils/contentApwSettingsPlugin.js +26 -0
- package/utils/contentApwSettingsPlugin.js.map +1 -0
- package/utils/errors.d.ts +16 -0
- package/utils/errors.js +75 -0
- package/utils/errors.js.map +1 -0
- package/utils/fieldResolver.d.ts +16 -0
- package/utils/fieldResolver.js +54 -0
- package/utils/fieldResolver.js.map +1 -0
- package/utils/resolve.d.ts +3 -0
- package/utils/resolve.js +18 -0
- package/utils/resolve.js.map +1 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createContentUrlPlugin = void 0;
|
7
|
+
|
8
|
+
var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
|
9
|
+
|
10
|
+
var _types = require("../../../types");
|
11
|
+
|
12
|
+
/**
|
13
|
+
* In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
|
14
|
+
* Due to multiple content types for the APW, everything needs to be pluginable.
|
15
|
+
*/
|
16
|
+
const createPageUrl = params => {
|
17
|
+
/**
|
18
|
+
* All variables must exist for URL to be created.
|
19
|
+
* We go through all vars and throw a log if it does not exist.
|
20
|
+
*/
|
21
|
+
for (const key in params) {
|
22
|
+
if (!!key) {
|
23
|
+
continue;
|
24
|
+
}
|
25
|
+
|
26
|
+
console.log(`Missing variable "${key}", which we use to create a page URL.`);
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
|
30
|
+
const {
|
31
|
+
baseUrl,
|
32
|
+
id
|
33
|
+
} = params;
|
34
|
+
return `${baseUrl}/page-builder/pages?id=${id}`;
|
35
|
+
};
|
36
|
+
|
37
|
+
const createContentUrlPlugin = () => {
|
38
|
+
return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.PAGE, params => {
|
39
|
+
const {
|
40
|
+
baseUrl,
|
41
|
+
contentReview
|
42
|
+
} = params;
|
43
|
+
const {
|
44
|
+
id
|
45
|
+
} = contentReview.content;
|
46
|
+
return createPageUrl({
|
47
|
+
baseUrl,
|
48
|
+
id
|
49
|
+
});
|
50
|
+
});
|
51
|
+
};
|
52
|
+
|
53
|
+
exports.createContentUrlPlugin = createContentUrlPlugin;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createPageUrl","params","key","console","log","baseUrl","id","createContentUrlPlugin","createApwContentUrlPlugin","ApwContentTypes","PAGE","contentReview","content"],"sources":["contentUrl.ts"],"sourcesContent":["/**\n * In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.\n * Due to multiple content types for the APW, everything needs to be pluginable.\n */\nimport { createApwContentUrlPlugin } from \"~/ApwContentUrlPlugin\";\nimport { ApwContentTypes } from \"~/types\";\n\ninterface CreatePageUrlParams {\n baseUrl?: string;\n id: string;\n}\nconst createPageUrl = (params: CreatePageUrlParams): string | null => {\n /**\n * All variables must exist for URL to be created.\n * We go through all vars and throw a log if it does not exist.\n */\n for (const key in params) {\n if (!!key) {\n continue;\n }\n console.log(`Missing variable \"${key}\", which we use to create a page URL.`);\n return null;\n }\n const { baseUrl, id } = params;\n return `${baseUrl}/page-builder/pages?id=${id}`;\n};\n\nexport const createContentUrlPlugin = () => {\n return createApwContentUrlPlugin(ApwContentTypes.PAGE, params => {\n const { baseUrl, contentReview } = params;\n const { id } = contentReview.content;\n return createPageUrl({\n baseUrl,\n id\n });\n });\n};\n"],"mappings":";;;;;;;AAIA;;AACA;;AALA;AACA;AACA;AACA;AAQA,MAAMA,aAAa,GAAIC,MAAD,IAAgD;EAClE;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACtB,IAAI,CAAC,CAACC,GAAN,EAAW;MACP;IACH;;IACDC,OAAO,CAACC,GAAR,CAAa,qBAAoBF,GAAI,uCAArC;IACA,OAAO,IAAP;EACH;;EACD,MAAM;IAAEG,OAAF;IAAWC;EAAX,IAAkBL,MAAxB;EACA,OAAQ,GAAEI,OAAQ,0BAAyBC,EAAG,EAA9C;AACH,CAdD;;AAgBO,MAAMC,sBAAsB,GAAG,MAAM;EACxC,OAAO,IAAAC,8CAAA,EAA0BC,sBAAA,CAAgBC,IAA1C,EAAgDT,MAAM,IAAI;IAC7D,MAAM;MAAEI,OAAF;MAAWM;IAAX,IAA6BV,MAAnC;IACA,MAAM;MAAEK;IAAF,IAASK,aAAa,CAACC,OAA7B;IACA,OAAOZ,aAAa,CAAC;MACjBK,OADiB;MAEjBC;IAFiB,CAAD,CAApB;EAIH,CAPM,CAAP;AAQH,CATM"}
|
@@ -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").default;
|
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.onPageBeforePublish.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.reviewStatus === _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","onPageBeforePublish","subscribe","page","contentReviewId","get","contentReview","reviewStatus","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 ApwOnPageBeforePublishTopicParams\n} from \"~/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface TriggerContentReviewParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const triggerContentReview = (params: TriggerContentReviewParams) => {\n const { pageBuilder, apw } = params;\n\n pageBuilder.onPageBeforePublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n if (contentReviewId) {\n const contentReview = await apw.contentReview.get(contentReviewId);\n\n if (contentReview.reviewStatus === ApwContentReviewStatus.UNDER_REVIEW) {\n throw new Error(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n return;\n }\n\n const workflowId = get(page, \"settings.apw.workflowId\");\n\n if (workflowId) {\n throw new Error(\n \"This content requires peer review approval before it can be published.\",\n \"REVIEW_REQUIRED\",\n {\n workflowId,\n page\n }\n );\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;AAAA;;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,YAAd,KAA+BC,6BAAA,CAAuBC,YAA1D,EAAwE;QACpE,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,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.updateContentReviewStatus = void 0;
|
9
|
+
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
+
|
12
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
+
|
14
|
+
var _types = require("../../types");
|
15
|
+
|
16
|
+
var _utils = require("../../crud/utils");
|
17
|
+
|
18
|
+
const updateContentReviewStatus = params => {
|
19
|
+
const {
|
20
|
+
apw,
|
21
|
+
pageBuilder,
|
22
|
+
security
|
23
|
+
} = params;
|
24
|
+
pageBuilder.onPageAfterPublish.subscribe(async ({
|
25
|
+
page
|
26
|
+
}) => {
|
27
|
+
const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
|
28
|
+
/**
|
29
|
+
* Bail out if there is no "content review" linked.
|
30
|
+
*/
|
31
|
+
|
32
|
+
if (!contentReviewId) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
|
36
|
+
const contentReview = await apw.contentReview.get(contentReviewId);
|
37
|
+
const identity = security.getIdentity();
|
38
|
+
/**
|
39
|
+
* If content review is "readyToBePublished set its status as "published" after page publish.
|
40
|
+
*/
|
41
|
+
|
42
|
+
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
43
|
+
await apw.contentReview.update(contentReviewId, {
|
44
|
+
reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
|
45
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
|
46
|
+
publishedBy: identity.id
|
47
|
+
})
|
48
|
+
});
|
49
|
+
}
|
50
|
+
});
|
51
|
+
pageBuilder.onPageAfterUnpublish.subscribe(async ({
|
52
|
+
page
|
53
|
+
}) => {
|
54
|
+
const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
|
55
|
+
/**
|
56
|
+
* Bail out if there is no "content review" linked.
|
57
|
+
*/
|
58
|
+
|
59
|
+
if (!contentReviewId) {
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
|
63
|
+
const contentReview = await apw.contentReview.get(contentReviewId);
|
64
|
+
/**
|
65
|
+
* If content review is "published set its status as "readyToBePublished" after page unpublish.
|
66
|
+
*/
|
67
|
+
|
68
|
+
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.PUBLISHED) {
|
69
|
+
await apw.contentReview.update(contentReviewId, {
|
70
|
+
reviewStatus: _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED,
|
71
|
+
content: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, contentReview.content), _utils.INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META), {}, {
|
72
|
+
publishedBy: null
|
73
|
+
})
|
74
|
+
});
|
75
|
+
}
|
76
|
+
});
|
77
|
+
};
|
78
|
+
|
79
|
+
exports.updateContentReviewStatus = updateContentReviewStatus;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["updateContentReviewStatus","params","apw","pageBuilder","security","onPageAfterPublish","subscribe","page","contentReviewId","get","contentReview","identity","getIdentity","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED","update","PUBLISHED","content","INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META","publishedBy","id","onPageAfterUnpublish"],"sources":["updateContentReviewStatus.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport {\n AdvancedPublishingWorkflow,\n ApwContentReviewStatus,\n ApwOnPageBeforePublishTopicParams\n} from \"~/types\";\nimport { INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META } from \"~/crud/utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface UpdateContentReviewStatusParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n security: Security;\n}\n\nexport const updateContentReviewStatus = (params: UpdateContentReviewStatusParams) => {\n const { apw, pageBuilder, security } = params;\n\n pageBuilder.onPageAfterPublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n const identity = security.getIdentity();\n /**\n * If content review is \"readyToBePublished set its status as \"published\" after page publish.\n */\n if (contentReview.reviewStatus === ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: identity.id\n }\n });\n }\n }\n );\n pageBuilder.onPageAfterUnpublish.subscribe<ApwOnPageBeforePublishTopicParams>(\n async ({ page }) => {\n const contentReviewId = get(page, \"settings.apw.contentReviewId\");\n /**\n * Bail out if there is no \"content review\" linked.\n */\n if (!contentReviewId) {\n return;\n }\n\n const contentReview = await apw.contentReview.get(contentReviewId);\n /**\n * If content review is \"published set its status as \"readyToBePublished\" after page unpublish.\n */\n\n if (contentReview.reviewStatus === ApwContentReviewStatus.PUBLISHED) {\n await apw.contentReview.update(contentReviewId, {\n reviewStatus: ApwContentReviewStatus.READY_TO_BE_PUBLISHED,\n content: {\n ...contentReview.content,\n ...INITIAL_CONTENT_REVIEW_CONTENT_SCHEDULE_META,\n publishedBy: null\n }\n });\n }\n }\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAKA;;AAUO,MAAMA,yBAAyB,GAAIC,MAAD,IAA6C;EAClF,MAAM;IAAEC,GAAF;IAAOC,WAAP;IAAoBC;EAApB,IAAiCH,MAAvC;EAEAE,WAAW,CAACE,kBAAZ,CAA+BC,SAA/B,CACI,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;IACA;AACZ;AACA;;IACY,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBD,GAAlB,CAAsBD,eAAtB,CAA5B;IACA,MAAMG,QAAQ,GAAGP,QAAQ,CAACQ,WAAT,EAAjB;IACA;AACZ;AACA;;IACY,IAAIF,aAAa,CAACG,YAAd,KAA+BC,6BAAA,CAAuBC,qBAA1D,EAAiF;MAC7E,MAAMb,GAAG,CAACQ,aAAJ,CAAkBM,MAAlB,CAAyBR,eAAzB,EAA0C;QAC5CK,YAAY,EAAEC,6BAAA,CAAuBG,SADO;QAE5CC,OAAO,0FACAR,aAAa,CAACQ,OADd,GAEAC,mDAFA;UAGHC,WAAW,EAAET,QAAQ,CAACU;QAHnB;MAFqC,CAA1C,CAAN;IAQH;EACJ,CAzBL;EA2BAlB,WAAW,CAACmB,oBAAZ,CAAiChB,SAAjC,CACI,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAA,EAAIF,IAAJ,EAAU,8BAAV,CAAxB;IACA;AACZ;AACA;;IACY,IAAI,CAACC,eAAL,EAAsB;MAClB;IACH;;IAED,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAJ,CAAkBD,GAAlB,CAAsBD,eAAtB,CAA5B;IACA;AACZ;AACA;;IAEY,IAAIE,aAAa,CAACG,YAAd,KAA+BC,6BAAA,CAAuBG,SAA1D,EAAqE;MACjE,MAAMf,GAAG,CAACQ,aAAJ,CAAkBM,MAAlB,CAAyBR,eAAzB,EAA0C;QAC5CK,YAAY,EAAEC,6BAAA,CAAuBC,qBADO;QAE5CG,OAAO,0FACAR,aAAa,CAACQ,OADd,GAEAC,mDAFA;UAGHC,WAAW,EAAE;QAHV;MAFqC,CAA1C,CAAN;IAQH;EACJ,CAzBL;AA2BH,CAzDM"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { ApwWorkflow, ApwWorkflowCrud, ApwWorkflowScope, 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").default;
|
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 (ex) {
|
88
|
+
throw new _error.default(`Failed to assign workflow to page "${page.pid}".`, ex.code, ex.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","ex","code","data","hasPages","shouldUpdatePages","prevScope","prevScopePages","currentScopePages","length","every","getPagesDiff","currentPages","prevPages","addedPages","filter","removedPages","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","locked","e"],"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 (ex) {\n throw new WebinyError(`Failed to assign workflow to page \"${page.pid}\".`, ex.code, ex.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\") as unknown as string[];\n const currentScopePages: string[] = get(scope, \"data.pages\") as unknown as string[];\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":"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"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
2
|
+
import { SecurityIdentity } from "@webiny/api-security/types";
|
3
|
+
import { ApwChangeRequest, ApwContentReview, ApwContentReviewCrud, ApwContentReviewStep, ApwContentReviewStepStatus, ApwContext, ApwReviewerCrud, ApwWorkflow, ApwWorkflowStep, ApwWorkflowStepTypes } from "../types";
|
4
|
+
export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
|
5
|
+
fieldId?: string;
|
6
|
+
parent: string;
|
7
|
+
}
|
8
|
+
export interface HasReviewersParams {
|
9
|
+
identity: SecurityIdentity;
|
10
|
+
step: ApwContentReviewStep;
|
11
|
+
getReviewer: ApwReviewerCrud["get"];
|
12
|
+
}
|
13
|
+
export declare const hasReviewer: (params: HasReviewersParams) => Promise<Boolean>;
|
14
|
+
export declare const getValue: (object: Record<string, any>, key: string) => any;
|
15
|
+
export declare const getContentReviewStepInitialStatus: (workflowSteps: ApwWorkflowStep[], index: number, previousStepStatus?: ApwContentReviewStepStatus) => ApwContentReviewStepStatus;
|
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 {};
|