@webiny/api-apw 0.0.0-unstable.6e5425ee89 → 0.0.0-unstable.78f581c1d2
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.js +10 -0
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +10 -0
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +10 -0
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +10 -0
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +5 -0
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +11 -4
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +12 -4
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +84 -20
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +12 -4
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +17 -4
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +25 -0
- package/crud/index.js.map +1 -1
- package/crud/utils.js +28 -0
- package/crud/utils.js.map +1 -1
- package/index.js +11 -1
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +15 -0
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +8 -0
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +13 -0
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +17 -0
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +31 -2
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +4 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +4 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +4 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +8 -1
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +14 -0
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +18 -0
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +47 -2
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +31 -0
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +8 -1
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +8 -1
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +20 -1
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +8 -1
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +8 -1
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +16 -1
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +11 -2
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +9 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +8 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +14 -0
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +15 -2
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +5 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +12 -0
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +4 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +28 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +4 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +30 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +4 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +24 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +4 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +5 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +4 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +4 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +4 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +7 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +11 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +11 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +11 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +8 -0
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +9 -0
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +16 -0
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +12 -1
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +6 -0
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +15 -0
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +4 -0
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +6 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +11 -0
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +16 -0
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +31 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +4 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +4 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +4 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +7 -1
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +11 -0
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +12 -0
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +35 -1
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.js +43 -0
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +20 -1
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.js +33 -9
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +5 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +21 -0
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +27 -4
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +11 -0
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.js +25 -5
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +23 -2
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.js +40 -3
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +3 -0
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.js +6 -0
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +19 -0
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +21 -0
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +17 -0
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +14 -0
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +9 -0
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +8 -0
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +5 -0
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +26 -0
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +24 -2
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +8 -0
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +4 -0
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +23 -0
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +17 -0
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +19 -0
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.js +14 -0
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +6 -0
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +17 -0
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +12 -2
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.js +3 -0
- package/utils/resolve.js.map +1 -1
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createContentUrlPlugin = void 0;
|
7
|
+
|
7
8
|
var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
|
9
|
+
|
8
10
|
var _types = require("../../../types");
|
11
|
+
|
9
12
|
/**
|
10
13
|
* In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
|
11
14
|
* Due to multiple content types for the APW, everything needs to be pluginable.
|
12
15
|
*/
|
13
|
-
|
14
16
|
const createPageUrl = params => {
|
15
17
|
/**
|
16
18
|
* All variables must exist for URL to be created.
|
@@ -20,15 +22,18 @@ const createPageUrl = params => {
|
|
20
22
|
if (!!key) {
|
21
23
|
continue;
|
22
24
|
}
|
25
|
+
|
23
26
|
console.log(`Missing variable "${key}", which we use to create a page URL.`);
|
24
27
|
return null;
|
25
28
|
}
|
29
|
+
|
26
30
|
const {
|
27
31
|
baseUrl,
|
28
32
|
id
|
29
33
|
} = params;
|
30
34
|
return `${baseUrl}/page-builder/pages?id=${id}`;
|
31
35
|
};
|
36
|
+
|
32
37
|
const createContentUrlPlugin = () => {
|
33
38
|
return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.PAGE, params => {
|
34
39
|
const {
|
@@ -44,4 +49,5 @@ const createContentUrlPlugin = () => {
|
|
44
49
|
});
|
45
50
|
});
|
46
51
|
};
|
52
|
+
|
47
53
|
exports.createContentUrlPlugin = createContentUrlPlugin;
|
@@ -1 +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":"
|
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"}
|
@@ -1,13 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.triggerContentReview = void 0;
|
9
|
+
|
8
10
|
var _get = _interopRequireDefault(require("lodash/get"));
|
11
|
+
|
9
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
13
|
+
|
10
14
|
var _types = require("../../types");
|
15
|
+
|
11
16
|
const triggerContentReview = params => {
|
12
17
|
const {
|
13
18
|
pageBuilder,
|
@@ -17,17 +22,22 @@ const triggerContentReview = params => {
|
|
17
22
|
page
|
18
23
|
}) => {
|
19
24
|
const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
|
25
|
+
|
20
26
|
if (contentReviewId) {
|
21
27
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
28
|
+
|
22
29
|
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.UNDER_REVIEW) {
|
23
30
|
throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
|
24
31
|
contentReviewId,
|
25
32
|
page
|
26
33
|
});
|
27
34
|
}
|
35
|
+
|
28
36
|
return;
|
29
37
|
}
|
38
|
+
|
30
39
|
const workflowId = (0, _get.default)(page, "settings.apw.workflowId");
|
40
|
+
|
31
41
|
if (workflowId) {
|
32
42
|
throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
|
33
43
|
workflowId,
|
@@ -36,4 +46,5 @@ const triggerContentReview = params => {
|
|
36
46
|
}
|
37
47
|
});
|
38
48
|
};
|
49
|
+
|
39
50
|
exports.triggerContentReview = triggerContentReview;
|
@@ -1 +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":"
|
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"}
|
@@ -1,14 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.updateContentReviewStatus = void 0;
|
9
|
+
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
+
|
9
12
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
+
|
10
14
|
var _types = require("../../types");
|
15
|
+
|
11
16
|
var _utils = require("../../crud/utils");
|
17
|
+
|
12
18
|
const updateContentReviewStatus = params => {
|
13
19
|
const {
|
14
20
|
apw,
|
@@ -22,14 +28,17 @@ const updateContentReviewStatus = params => {
|
|
22
28
|
/**
|
23
29
|
* Bail out if there is no "content review" linked.
|
24
30
|
*/
|
31
|
+
|
25
32
|
if (!contentReviewId) {
|
26
33
|
return;
|
27
34
|
}
|
35
|
+
|
28
36
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
29
37
|
const identity = security.getIdentity();
|
30
38
|
/**
|
31
39
|
* If content review is "readyToBePublished set its status as "published" after page publish.
|
32
40
|
*/
|
41
|
+
|
33
42
|
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
34
43
|
await apw.contentReview.update(contentReviewId, {
|
35
44
|
reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
|
@@ -46,9 +55,11 @@ const updateContentReviewStatus = params => {
|
|
46
55
|
/**
|
47
56
|
* Bail out if there is no "content review" linked.
|
48
57
|
*/
|
58
|
+
|
49
59
|
if (!contentReviewId) {
|
50
60
|
return;
|
51
61
|
}
|
62
|
+
|
52
63
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
53
64
|
/**
|
54
65
|
* If content review is "published set its status as "readyToBePublished" after page unpublish.
|
@@ -64,4 +75,5 @@ const updateContentReviewStatus = params => {
|
|
64
75
|
}
|
65
76
|
});
|
66
77
|
};
|
78
|
+
|
67
79
|
exports.updateContentReviewStatus = updateContentReviewStatus;
|
@@ -1 +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":"
|
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"}
|
@@ -1,37 +1,52 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.updatePageSettings = exports.shouldUpdatePages = exports.hasPages = exports.getPagesDiff = exports.assignWorkflowToPage = void 0;
|
9
|
+
|
8
10
|
var _get = _interopRequireDefault(require("lodash/get"));
|
11
|
+
|
9
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
13
|
+
|
10
14
|
var _types = require("../../types");
|
15
|
+
|
11
16
|
var _utils = require("../utils");
|
17
|
+
|
12
18
|
const isWorkflowApplicable = (page, workflow) => {
|
13
19
|
const application = workflow.app;
|
20
|
+
|
14
21
|
if (application !== _types.ApwWorkflowApplications.PB) {
|
15
22
|
return false;
|
16
23
|
}
|
24
|
+
|
17
25
|
const scopeType = workflow.scope.type;
|
26
|
+
|
18
27
|
if (scopeType === _types.WorkflowScopeTypes.DEFAULT) {
|
19
28
|
return true;
|
20
29
|
} else if (scopeType === _types.WorkflowScopeTypes.CUSTOM) {
|
21
30
|
const categories = (0, _get.default)(workflow, "scope.data.categories");
|
31
|
+
|
22
32
|
if (Array.isArray(categories) && categories.includes(page.category)) {
|
23
33
|
return true;
|
24
34
|
}
|
35
|
+
|
25
36
|
const pages = (0, _get.default)(workflow, "scope.data.pages");
|
37
|
+
|
26
38
|
if (Array.isArray(pages) && pages.includes(page.pid)) {
|
27
39
|
return true;
|
28
40
|
}
|
41
|
+
|
29
42
|
return false;
|
30
43
|
}
|
44
|
+
|
31
45
|
throw new _error.default(`Unknown scope type "${scopeType}".`, "UNKNOWN_SCOPE_TYPE", {
|
32
46
|
workflow
|
33
47
|
});
|
34
48
|
};
|
49
|
+
|
35
50
|
const assignWorkflowToPage = async ({
|
36
51
|
listWorkflow,
|
37
52
|
page
|
@@ -48,14 +63,15 @@ const assignWorkflowToPage = async ({
|
|
48
63
|
app: _types.ApwWorkflowApplications.PB
|
49
64
|
}
|
50
65
|
});
|
51
|
-
|
52
66
|
/*
|
53
67
|
* Re-order them based on workflow scope and pre-defined rule i.e.
|
54
68
|
* "specific" entry -> entry for a "category" -> "default".
|
55
69
|
* There can be more than one workflow with same "scope" and "app".
|
56
70
|
* Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.
|
57
71
|
*/
|
72
|
+
|
58
73
|
const sortedWorkflows = entries.sort(_utils.workflowByPrecedenceDesc).sort(_utils.workflowByCreatedOnDesc);
|
74
|
+
|
59
75
|
for (const workflow of sortedWorkflows) {
|
60
76
|
/**
|
61
77
|
* Assign the first applicable workflow to the page and exit.
|
@@ -72,7 +88,9 @@ const assignWorkflowToPage = async ({
|
|
72
88
|
throw new _error.default(`Failed to assign workflow to page "${page.pid}".`, ex.code, ex.data);
|
73
89
|
}
|
74
90
|
};
|
91
|
+
|
75
92
|
exports.assignWorkflowToPage = assignWorkflowToPage;
|
93
|
+
|
76
94
|
const hasPages = workflow => {
|
77
95
|
const {
|
78
96
|
app,
|
@@ -80,7 +98,9 @@ const hasPages = workflow => {
|
|
80
98
|
} = workflow;
|
81
99
|
return app === _types.ApwWorkflowApplications.PB && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.pages);
|
82
100
|
};
|
101
|
+
|
83
102
|
exports.hasPages = hasPages;
|
103
|
+
|
84
104
|
const shouldUpdatePages = (scope, prevScope) => {
|
85
105
|
/**
|
86
106
|
* Bail out early if the scope is not "CUSTOM" - at that point all pages should be updated.
|
@@ -88,26 +108,34 @@ const shouldUpdatePages = (scope, prevScope) => {
|
|
88
108
|
if (prevScope.type !== _types.WorkflowScopeTypes.CUSTOM) {
|
89
109
|
return true;
|
90
110
|
}
|
111
|
+
|
91
112
|
const prevScopePages = (0, _get.default)(prevScope, "data.pages");
|
92
113
|
const currentScopePages = (0, _get.default)(scope, "data.pages");
|
93
114
|
/**
|
94
115
|
* Bail out early if there were no pages assigned previously.
|
95
116
|
*/
|
117
|
+
|
96
118
|
if (prevScopePages.length === 0) {
|
97
119
|
return true;
|
98
120
|
}
|
99
121
|
/**
|
100
122
|
* Bail out early if number of pages has been changed.
|
101
123
|
*/
|
124
|
+
|
125
|
+
|
102
126
|
if (currentScopePages.length !== prevScopePages.length) {
|
103
127
|
return true;
|
104
128
|
}
|
105
129
|
/*
|
106
130
|
* Check whether previous scope has the exactly same pages as in the new scope.
|
107
131
|
*/
|
132
|
+
|
133
|
+
|
108
134
|
return !prevScopePages.every(pid => currentScopePages.includes(pid));
|
109
135
|
};
|
136
|
+
|
110
137
|
exports.shouldUpdatePages = shouldUpdatePages;
|
138
|
+
|
111
139
|
const getPagesDiff = (currentPages, prevPages) => {
|
112
140
|
const addedPages = currentPages.filter(id => !prevPages.includes(id));
|
113
141
|
const removedPages = prevPages.filter(id => !currentPages.includes(id));
|
@@ -116,7 +144,9 @@ const getPagesDiff = (currentPages, prevPages) => {
|
|
116
144
|
removedPages
|
117
145
|
};
|
118
146
|
};
|
147
|
+
|
119
148
|
exports.getPagesDiff = getPagesDiff;
|
149
|
+
|
120
150
|
const updatePageSettings = async ({
|
121
151
|
getPage,
|
122
152
|
updatePage,
|
@@ -131,6 +161,7 @@ const updatePageSettings = async ({
|
|
131
161
|
/**
|
132
162
|
* We can't update a page that is "locked".
|
133
163
|
*/
|
164
|
+
|
134
165
|
if (page.locked) {
|
135
166
|
return;
|
136
167
|
}
|
@@ -138,6 +169,8 @@ const updatePageSettings = async ({
|
|
138
169
|
* There can be more than one workflow with same `scope` for same `app`. That is why;
|
139
170
|
* We'll update the workflow reference even though it already had one assign.
|
140
171
|
*/
|
172
|
+
|
173
|
+
|
141
174
|
await updatePage(page.id, {
|
142
175
|
settings: getNewSettings(page.settings)
|
143
176
|
});
|
@@ -147,4 +180,5 @@ const updatePageSettings = async ({
|
|
147
180
|
}
|
148
181
|
}
|
149
182
|
};
|
183
|
+
|
150
184
|
exports.updatePageSettings = updatePageSettings;
|
@@ -1 +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":"
|
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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"}
|
package/plugins/utils.js
CHANGED
@@ -1,32 +1,44 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
+
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
7
8
|
exports.workflowByPrecedenceDesc = exports.workflowByCreatedOnDesc = exports.updateContentReviewStep = exports.updateContentReview = exports.safelyGetContentReview = exports.isInstallationPending = exports.hasReviewer = exports.getValue = exports.getNextStepStatus = exports.getContentReviewStepInitialStatus = exports.extractContentReviewIdAndStep = void 0;
|
9
|
+
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
+
|
9
12
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
+
|
10
14
|
var _types = require("../types");
|
15
|
+
|
11
16
|
const hasReviewer = async params => {
|
12
17
|
const {
|
13
18
|
getReviewer,
|
14
19
|
identity,
|
15
20
|
step
|
16
21
|
} = params;
|
22
|
+
|
17
23
|
for (const stepReviewer of step.reviewers) {
|
18
24
|
const entry = await getReviewer(stepReviewer.id);
|
25
|
+
|
19
26
|
if (entry.identityId === identity.id) {
|
20
27
|
return true;
|
21
28
|
}
|
22
29
|
}
|
30
|
+
|
23
31
|
return false;
|
24
32
|
};
|
33
|
+
|
25
34
|
exports.hasReviewer = hasReviewer;
|
35
|
+
|
26
36
|
const getValue = (object, key) => {
|
27
37
|
return (0, _get.default)(object, `values.${key}`);
|
28
38
|
};
|
39
|
+
|
29
40
|
exports.getValue = getValue;
|
41
|
+
|
30
42
|
const getContentReviewStepInitialStatus = (workflowSteps, index, previousStepStatus) => {
|
31
43
|
/**
|
32
44
|
* Always set first step 'active' by default.
|
@@ -34,23 +46,32 @@ const getContentReviewStepInitialStatus = (workflowSteps, index, previousStepSta
|
|
34
46
|
if (index === 0) {
|
35
47
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
36
48
|
}
|
49
|
+
|
37
50
|
const previousStep = workflowSteps[index - 1];
|
51
|
+
|
38
52
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.ACTIVE && previousStep.type !== _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
|
39
53
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
40
54
|
}
|
55
|
+
|
41
56
|
return _types.ApwContentReviewStepStatus.INACTIVE;
|
42
57
|
};
|
58
|
+
|
43
59
|
exports.getContentReviewStepInitialStatus = getContentReviewStepInitialStatus;
|
60
|
+
|
44
61
|
const getNextStepStatus = (previousStepType, previousStepStatus) => {
|
45
62
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.DONE) {
|
46
63
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
47
64
|
}
|
65
|
+
|
48
66
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.ACTIVE && previousStepType !== _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
|
49
67
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
50
68
|
}
|
69
|
+
|
51
70
|
return _types.ApwContentReviewStepStatus.INACTIVE;
|
52
71
|
};
|
72
|
+
|
53
73
|
exports.getNextStepStatus = getNextStepStatus;
|
74
|
+
|
54
75
|
const extractContentReviewIdAndStep = step => {
|
55
76
|
/*
|
56
77
|
* Get associated content review entry.
|
@@ -62,12 +83,15 @@ const extractContentReviewIdAndStep = step => {
|
|
62
83
|
stepId
|
63
84
|
};
|
64
85
|
};
|
86
|
+
|
65
87
|
exports.extractContentReviewIdAndStep = extractContentReviewIdAndStep;
|
88
|
+
|
66
89
|
const safelyGetContentReview = async ({
|
67
90
|
id,
|
68
91
|
contentReviewMethods
|
69
92
|
}) => {
|
70
93
|
let contentReviewEntry = null;
|
94
|
+
|
71
95
|
try {
|
72
96
|
contentReviewEntry = await contentReviewMethods.get(id);
|
73
97
|
} catch (e) {
|
@@ -75,9 +99,12 @@ const safelyGetContentReview = async ({
|
|
75
99
|
throw e;
|
76
100
|
}
|
77
101
|
}
|
102
|
+
|
78
103
|
return contentReviewEntry;
|
79
104
|
};
|
105
|
+
|
80
106
|
exports.safelyGetContentReview = safelyGetContentReview;
|
107
|
+
|
81
108
|
const updateContentReview = async ({
|
82
109
|
contentReviewMethods,
|
83
110
|
id,
|
@@ -87,24 +114,31 @@ const updateContentReview = async ({
|
|
87
114
|
id,
|
88
115
|
contentReviewMethods
|
89
116
|
});
|
117
|
+
|
90
118
|
if (contentReviewEntry) {
|
91
119
|
const newContentReviewData = getNewContentReviewData(contentReviewEntry);
|
92
120
|
/**
|
93
121
|
* Update content review entry.
|
94
122
|
*/
|
123
|
+
|
95
124
|
await contentReviewMethods.update(contentReviewEntry.id, newContentReviewData);
|
96
125
|
}
|
97
126
|
};
|
127
|
+
|
98
128
|
exports.updateContentReview = updateContentReview;
|
129
|
+
|
99
130
|
const updateContentReviewStep = (steps, stepId, updater) => {
|
100
131
|
return steps.map(step => {
|
101
132
|
if (step.id === stepId) {
|
102
133
|
return (0, _objectSpread2.default)({}, updater(step));
|
103
134
|
}
|
135
|
+
|
104
136
|
return step;
|
105
137
|
});
|
106
138
|
};
|
139
|
+
|
107
140
|
exports.updateContentReviewStep = updateContentReviewStep;
|
141
|
+
|
108
142
|
const isInstallationPending = ({
|
109
143
|
tenancy,
|
110
144
|
i18n
|
@@ -114,31 +148,40 @@ const isInstallationPending = ({
|
|
114
148
|
* installation is completed. So, we need to skip "APW" creation till then.
|
115
149
|
*/
|
116
150
|
const tenant = tenancy.getCurrentTenant();
|
151
|
+
|
117
152
|
if (!tenant) {
|
118
153
|
return true;
|
119
154
|
}
|
155
|
+
|
120
156
|
return !i18n.getContentLocale();
|
121
157
|
};
|
158
|
+
|
122
159
|
exports.isInstallationPending = isInstallationPending;
|
123
160
|
const WORKFLOW_PRECEDENCE = {
|
124
161
|
[_types.WorkflowScopeTypes.DEFAULT]: 0,
|
125
162
|
[_types.WorkflowScopeTypes.CUSTOM]: 1
|
126
163
|
};
|
164
|
+
|
127
165
|
const workflowByPrecedenceDesc = (a, b) => {
|
128
166
|
const scoreA = WORKFLOW_PRECEDENCE[a.scope.type];
|
129
167
|
const scoreB = WORKFLOW_PRECEDENCE[b.scope.type];
|
130
168
|
/**
|
131
169
|
* In descending order of workflow precedence.
|
132
170
|
*/
|
171
|
+
|
133
172
|
return scoreB - scoreA;
|
134
173
|
};
|
174
|
+
|
135
175
|
exports.workflowByPrecedenceDesc = workflowByPrecedenceDesc;
|
176
|
+
|
136
177
|
const workflowByCreatedOnDesc = (a, b) => {
|
137
178
|
const createdOnA = (0, _get.default)(a, "createdOn");
|
138
179
|
const createdOnB = (0, _get.default)(b, "createdOn");
|
139
180
|
/**
|
140
181
|
* In descending order of workflow createdOn i.e. the most recent one first.
|
141
182
|
*/
|
183
|
+
|
142
184
|
return new Date(createdOnB).getTime() - new Date(createdOnA).getTime();
|
143
185
|
};
|
186
|
+
|
144
187
|
exports.workflowByCreatedOnDesc = workflowByCreatedOnDesc;
|