@webiny/api-apw 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7f63ea0744
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 +0 -10
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +0 -10
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +0 -10
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +0 -10
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +0 -5
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +4 -11
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +4 -12
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +20 -84
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +4 -12
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +4 -17
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +0 -25
- package/crud/index.js.map +1 -1
- package/crud/utils.js +0 -28
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +1 -15
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +0 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +0 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +0 -17
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +2 -31
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +0 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +0 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +0 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +1 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +0 -14
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +0 -18
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +2 -47
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -47
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -8
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +1 -8
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +1 -20
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +1 -8
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -8
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +2 -17
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +2 -11
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +0 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +2 -15
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +0 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +0 -12
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +0 -4
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +0 -28
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +0 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +0 -30
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +0 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +1 -24
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +0 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +0 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +0 -7
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +0 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +0 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +0 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +0 -8
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +0 -9
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +0 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +1 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +0 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +0 -11
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -4
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -4
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -4
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +1 -7
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +0 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.js +0 -43
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +1 -20
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +9 -33
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -5
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +0 -21
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -27
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +0 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -25
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +3 -40
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.js +0 -6
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +0 -19
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +0 -21
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +0 -17
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +0 -14
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +0 -9
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +0 -8
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +0 -5
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +0 -26
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +2 -24
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +0 -8
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +0 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +0 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +0 -17
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +3 -20
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +0 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +2 -12
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createContentUrlPlugin = void 0;
|
7
|
-
|
8
7
|
var _ApwContentUrlPlugin = require("../../../ApwContentUrlPlugin");
|
9
|
-
|
10
8
|
var _types = require("../../../types");
|
11
|
-
|
12
9
|
/**
|
13
10
|
* In this file we create a plugin which in turn creates a content entry url when requested by the code which sends notifications.
|
14
11
|
* Due to multiple content types for the APW, everything needs to be pluginable.
|
15
12
|
*/
|
13
|
+
|
16
14
|
const createPageUrl = params => {
|
17
15
|
/**
|
18
16
|
* All variables must exist for URL to be created.
|
@@ -22,18 +20,15 @@ const createPageUrl = params => {
|
|
22
20
|
if (!!key) {
|
23
21
|
continue;
|
24
22
|
}
|
25
|
-
|
26
23
|
console.log(`Missing variable "${key}", which we use to create a page URL.`);
|
27
24
|
return null;
|
28
25
|
}
|
29
|
-
|
30
26
|
const {
|
31
27
|
baseUrl,
|
32
28
|
id
|
33
29
|
} = params;
|
34
30
|
return `${baseUrl}/page-builder/pages?id=${id}`;
|
35
31
|
};
|
36
|
-
|
37
32
|
const createContentUrlPlugin = () => {
|
38
33
|
return (0, _ApwContentUrlPlugin.createApwContentUrlPlugin)(_types.ApwContentTypes.PAGE, params => {
|
39
34
|
const {
|
@@ -49,5 +44,4 @@ const createContentUrlPlugin = () => {
|
|
49
44
|
});
|
50
45
|
});
|
51
46
|
};
|
52
|
-
|
53
47
|
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,MAA2B,IAAoB;EAClE;AACJ;AACA;AACA;EACI,KAAK,MAAMC,GAAG,IAAID,MAAM,EAAE;IACtB,IAAI,CAAC,CAACC,GAAG,EAAE;MACP;IACJ;IACAC,OAAO,CAACC,GAAG,CAAE,qBAAoBF,GAAI,uCAAsC,CAAC;IAC5E,OAAO,IAAI;EACf;EACA,MAAM;IAAEG,OAAO;IAAEC;EAAG,CAAC,GAAGL,MAAM;EAC9B,OAAQ,GAAEI,OAAQ,0BAAyBC,EAAG,EAAC;AACnD,CAAC;AAEM,MAAMC,sBAAsB,GAAG,MAAM;EACxC,OAAO,IAAAC,8CAAyB,EAACC,sBAAe,CAACC,IAAI,EAAET,MAAM,IAAI;IAC7D,MAAM;MAAEI,OAAO;MAAEM;IAAc,CAAC,GAAGV,MAAM;IACzC,MAAM;MAAEK;IAAG,CAAC,GAAGK,aAAa,CAACC,OAAO;IACpC,OAAOZ,aAAa,CAAC;MACjBK,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -1,18 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.triggerContentReview = void 0;
|
9
|
-
|
10
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
11
|
-
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
13
|
-
|
14
10
|
var _types = require("../../types");
|
15
|
-
|
16
11
|
const triggerContentReview = params => {
|
17
12
|
const {
|
18
13
|
pageBuilder,
|
@@ -22,22 +17,17 @@ const triggerContentReview = params => {
|
|
22
17
|
page
|
23
18
|
}) => {
|
24
19
|
const contentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
|
25
|
-
|
26
20
|
if (contentReviewId) {
|
27
21
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
28
|
-
|
29
22
|
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.UNDER_REVIEW) {
|
30
23
|
throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
|
31
24
|
contentReviewId,
|
32
25
|
page
|
33
26
|
});
|
34
27
|
}
|
35
|
-
|
36
28
|
return;
|
37
29
|
}
|
38
|
-
|
39
30
|
const workflowId = (0, _get.default)(page, "settings.apw.workflowId");
|
40
|
-
|
41
31
|
if (workflowId) {
|
42
32
|
throw new _error.default("This content requires peer review approval before it can be published.", "REVIEW_REQUIRED", {
|
43
33
|
workflowId,
|
@@ -46,5 +36,4 @@ const triggerContentReview = params => {
|
|
46
36
|
}
|
47
37
|
});
|
48
38
|
};
|
49
|
-
|
50
39
|
exports.triggerContentReview = triggerContentReview;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["triggerContentReview","params","pageBuilder","apw","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,MAAkC,IAAK;EACxE,MAAM;IAAEC,WAAW;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAEnCC,WAAW,CAACE,mBAAmB,CAACC,SAAS,CACrC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAG,EAACF,IAAI,EAAE,8BAA8B,CAAC;IACjE,IAAIC,eAAe,EAAE;MACjB,MAAME,aAAa,GAAG,MAAMN,GAAG,CAACM,aAAa,CAACD,GAAG,CAACD,eAAe,CAAC;MAElE,IAAIE,aAAa,CAACC,YAAY,KAAKC,6BAAsB,CAACC,YAAY,EAAE;QACpE,MAAM,IAAIC,cAAK,CACV,4DAA2D,EAC5D,sBAAsB,EACtB;UACIN,eAAe;UACfD;QACJ,CAAC,CACJ;MACL;MACA;IACJ;IAEA,MAAMQ,UAAU,GAAG,IAAAN,YAAG,EAACF,IAAI,EAAE,yBAAyB,CAAC;IAEvD,IAAIQ,UAAU,EAAE;MACZ,MAAM,IAAID,cAAK,CACX,wEAAwE,EACxE,iBAAiB,EACjB;QACIC,UAAU;QACVR;MACJ,CAAC,CACJ;IACL;EACJ,CAAC,CACJ;AACL,CAAC;AAAC"}
|
@@ -1,20 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.updateContentReviewStatus = void 0;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
-
|
14
10
|
var _types = require("../../types");
|
15
|
-
|
16
11
|
var _utils = require("../../crud/utils");
|
17
|
-
|
18
12
|
const updateContentReviewStatus = params => {
|
19
13
|
const {
|
20
14
|
apw,
|
@@ -28,17 +22,14 @@ const updateContentReviewStatus = params => {
|
|
28
22
|
/**
|
29
23
|
* Bail out if there is no "content review" linked.
|
30
24
|
*/
|
31
|
-
|
32
25
|
if (!contentReviewId) {
|
33
26
|
return;
|
34
27
|
}
|
35
|
-
|
36
28
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
37
29
|
const identity = security.getIdentity();
|
38
30
|
/**
|
39
31
|
* If content review is "readyToBePublished set its status as "published" after page publish.
|
40
32
|
*/
|
41
|
-
|
42
33
|
if (contentReview.reviewStatus === _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED) {
|
43
34
|
await apw.contentReview.update(contentReviewId, {
|
44
35
|
reviewStatus: _types.ApwContentReviewStatus.PUBLISHED,
|
@@ -55,11 +46,9 @@ const updateContentReviewStatus = params => {
|
|
55
46
|
/**
|
56
47
|
* Bail out if there is no "content review" linked.
|
57
48
|
*/
|
58
|
-
|
59
49
|
if (!contentReviewId) {
|
60
50
|
return;
|
61
51
|
}
|
62
|
-
|
63
52
|
const contentReview = await apw.contentReview.get(contentReviewId);
|
64
53
|
/**
|
65
54
|
* If content review is "published set its status as "readyToBePublished" after page unpublish.
|
@@ -75,5 +64,4 @@ const updateContentReviewStatus = params => {
|
|
75
64
|
}
|
76
65
|
});
|
77
66
|
};
|
78
|
-
|
79
67
|
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,MAAuC,IAAK;EAClF,MAAM;IAAEC,GAAG;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE7CE,WAAW,CAACE,kBAAkB,CAACC,SAAS,CACpC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAG,EAACF,IAAI,EAAE,8BAA8B,CAAC;IACjE;AACZ;AACA;IACY,IAAI,CAACC,eAAe,EAAE;MAClB;IACJ;IAEA,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAa,CAACD,GAAG,CAACD,eAAe,CAAC;IAClE,MAAMG,QAAQ,GAAGP,QAAQ,CAACQ,WAAW,EAAE;IACvC;AACZ;AACA;IACY,IAAIF,aAAa,CAACG,YAAY,KAAKC,6BAAsB,CAACC,qBAAqB,EAAE;MAC7E,MAAMb,GAAG,CAACQ,aAAa,CAACM,MAAM,CAACR,eAAe,EAAE;QAC5CK,YAAY,EAAEC,6BAAsB,CAACG,SAAS;QAC9CC,OAAO,0FACAR,aAAa,CAACQ,OAAO,GACrBC,mDAA4C;UAC/CC,WAAW,EAAET,QAAQ,CAACU;QAAE;MAEhC,CAAC,CAAC;IACN;EACJ,CAAC,CACJ;EACDlB,WAAW,CAACmB,oBAAoB,CAAChB,SAAS,CACtC,OAAO;IAAEC;EAAK,CAAC,KAAK;IAChB,MAAMC,eAAe,GAAG,IAAAC,YAAG,EAACF,IAAI,EAAE,8BAA8B,CAAC;IACjE;AACZ;AACA;IACY,IAAI,CAACC,eAAe,EAAE;MAClB;IACJ;IAEA,MAAME,aAAa,GAAG,MAAMR,GAAG,CAACQ,aAAa,CAACD,GAAG,CAACD,eAAe,CAAC;IAClE;AACZ;AACA;;IAEY,IAAIE,aAAa,CAACG,YAAY,KAAKC,6BAAsB,CAACG,SAAS,EAAE;MACjE,MAAMf,GAAG,CAACQ,aAAa,CAACM,MAAM,CAACR,eAAe,EAAE;QAC5CK,YAAY,EAAEC,6BAAsB,CAACC,qBAAqB;QAC1DG,OAAO,0FACAR,aAAa,CAACQ,OAAO,GACrBC,mDAA4C;UAC/CC,WAAW,EAAE;QAAI;MAEzB,CAAC,CAAC;IACN;EACJ,CAAC,CACJ;AACL,CAAC;AAAC"}
|
@@ -1,52 +1,37 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.updatePageSettings = exports.shouldUpdatePages = exports.hasPages = exports.getPagesDiff = exports.assignWorkflowToPage = void 0;
|
9
|
-
|
10
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
11
|
-
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
13
|
-
|
14
10
|
var _types = require("../../types");
|
15
|
-
|
16
11
|
var _utils = require("../utils");
|
17
|
-
|
18
12
|
const isWorkflowApplicable = (page, workflow) => {
|
19
13
|
const application = workflow.app;
|
20
|
-
|
21
14
|
if (application !== _types.ApwWorkflowApplications.PB) {
|
22
15
|
return false;
|
23
16
|
}
|
24
|
-
|
25
17
|
const scopeType = workflow.scope.type;
|
26
|
-
|
27
18
|
if (scopeType === _types.WorkflowScopeTypes.DEFAULT) {
|
28
19
|
return true;
|
29
20
|
} else if (scopeType === _types.WorkflowScopeTypes.CUSTOM) {
|
30
21
|
const categories = (0, _get.default)(workflow, "scope.data.categories");
|
31
|
-
|
32
22
|
if (Array.isArray(categories) && categories.includes(page.category)) {
|
33
23
|
return true;
|
34
24
|
}
|
35
|
-
|
36
25
|
const pages = (0, _get.default)(workflow, "scope.data.pages");
|
37
|
-
|
38
26
|
if (Array.isArray(pages) && pages.includes(page.pid)) {
|
39
27
|
return true;
|
40
28
|
}
|
41
|
-
|
42
29
|
return false;
|
43
30
|
}
|
44
|
-
|
45
31
|
throw new _error.default(`Unknown scope type "${scopeType}".`, "UNKNOWN_SCOPE_TYPE", {
|
46
32
|
workflow
|
47
33
|
});
|
48
34
|
};
|
49
|
-
|
50
35
|
const assignWorkflowToPage = async ({
|
51
36
|
listWorkflow,
|
52
37
|
page
|
@@ -63,15 +48,14 @@ const assignWorkflowToPage = async ({
|
|
63
48
|
app: _types.ApwWorkflowApplications.PB
|
64
49
|
}
|
65
50
|
});
|
51
|
+
|
66
52
|
/*
|
67
53
|
* Re-order them based on workflow scope and pre-defined rule i.e.
|
68
54
|
* "specific" entry -> entry for a "category" -> "default".
|
69
55
|
* There can be more than one workflow with same "scope" and "app".
|
70
56
|
* Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.
|
71
57
|
*/
|
72
|
-
|
73
58
|
const sortedWorkflows = entries.sort(_utils.workflowByPrecedenceDesc).sort(_utils.workflowByCreatedOnDesc);
|
74
|
-
|
75
59
|
for (const workflow of sortedWorkflows) {
|
76
60
|
/**
|
77
61
|
* Assign the first applicable workflow to the page and exit.
|
@@ -88,9 +72,7 @@ const assignWorkflowToPage = async ({
|
|
88
72
|
throw new _error.default(`Failed to assign workflow to page "${page.pid}".`, ex.code, ex.data);
|
89
73
|
}
|
90
74
|
};
|
91
|
-
|
92
75
|
exports.assignWorkflowToPage = assignWorkflowToPage;
|
93
|
-
|
94
76
|
const hasPages = workflow => {
|
95
77
|
const {
|
96
78
|
app,
|
@@ -98,9 +80,7 @@ const hasPages = workflow => {
|
|
98
80
|
} = workflow;
|
99
81
|
return app === _types.ApwWorkflowApplications.PB && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.pages);
|
100
82
|
};
|
101
|
-
|
102
83
|
exports.hasPages = hasPages;
|
103
|
-
|
104
84
|
const shouldUpdatePages = (scope, prevScope) => {
|
105
85
|
/**
|
106
86
|
* Bail out early if the scope is not "CUSTOM" - at that point all pages should be updated.
|
@@ -108,34 +88,26 @@ const shouldUpdatePages = (scope, prevScope) => {
|
|
108
88
|
if (prevScope.type !== _types.WorkflowScopeTypes.CUSTOM) {
|
109
89
|
return true;
|
110
90
|
}
|
111
|
-
|
112
91
|
const prevScopePages = (0, _get.default)(prevScope, "data.pages");
|
113
92
|
const currentScopePages = (0, _get.default)(scope, "data.pages");
|
114
93
|
/**
|
115
94
|
* Bail out early if there were no pages assigned previously.
|
116
95
|
*/
|
117
|
-
|
118
96
|
if (prevScopePages.length === 0) {
|
119
97
|
return true;
|
120
98
|
}
|
121
99
|
/**
|
122
100
|
* Bail out early if number of pages has been changed.
|
123
101
|
*/
|
124
|
-
|
125
|
-
|
126
102
|
if (currentScopePages.length !== prevScopePages.length) {
|
127
103
|
return true;
|
128
104
|
}
|
129
105
|
/*
|
130
106
|
* Check whether previous scope has the exactly same pages as in the new scope.
|
131
107
|
*/
|
132
|
-
|
133
|
-
|
134
108
|
return !prevScopePages.every(pid => currentScopePages.includes(pid));
|
135
109
|
};
|
136
|
-
|
137
110
|
exports.shouldUpdatePages = shouldUpdatePages;
|
138
|
-
|
139
111
|
const getPagesDiff = (currentPages, prevPages) => {
|
140
112
|
const addedPages = currentPages.filter(id => !prevPages.includes(id));
|
141
113
|
const removedPages = prevPages.filter(id => !currentPages.includes(id));
|
@@ -144,9 +116,7 @@ const getPagesDiff = (currentPages, prevPages) => {
|
|
144
116
|
removedPages
|
145
117
|
};
|
146
118
|
};
|
147
|
-
|
148
119
|
exports.getPagesDiff = getPagesDiff;
|
149
|
-
|
150
120
|
const updatePageSettings = async ({
|
151
121
|
getPage,
|
152
122
|
updatePage,
|
@@ -161,7 +131,6 @@ const updatePageSettings = async ({
|
|
161
131
|
/**
|
162
132
|
* We can't update a page that is "locked".
|
163
133
|
*/
|
164
|
-
|
165
134
|
if (page.locked) {
|
166
135
|
return;
|
167
136
|
}
|
@@ -169,8 +138,6 @@ const updatePageSettings = async ({
|
|
169
138
|
* There can be more than one workflow with same `scope` for same `app`. That is why;
|
170
139
|
* We'll update the workflow reference even though it already had one assign.
|
171
140
|
*/
|
172
|
-
|
173
|
-
|
174
141
|
await updatePage(page.id, {
|
175
142
|
settings: getNewSettings(page.settings)
|
176
143
|
});
|
@@ -180,5 +147,4 @@ const updatePageSettings = async ({
|
|
180
147
|
}
|
181
148
|
}
|
182
149
|
};
|
183
|
-
|
184
150
|
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,44 +1,32 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
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
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
-
|
14
10
|
var _types = require("../types");
|
15
|
-
|
16
11
|
const hasReviewer = async params => {
|
17
12
|
const {
|
18
13
|
getReviewer,
|
19
14
|
identity,
|
20
15
|
step
|
21
16
|
} = params;
|
22
|
-
|
23
17
|
for (const stepReviewer of step.reviewers) {
|
24
18
|
const entry = await getReviewer(stepReviewer.id);
|
25
|
-
|
26
19
|
if (entry.identityId === identity.id) {
|
27
20
|
return true;
|
28
21
|
}
|
29
22
|
}
|
30
|
-
|
31
23
|
return false;
|
32
24
|
};
|
33
|
-
|
34
25
|
exports.hasReviewer = hasReviewer;
|
35
|
-
|
36
26
|
const getValue = (object, key) => {
|
37
27
|
return (0, _get.default)(object, `values.${key}`);
|
38
28
|
};
|
39
|
-
|
40
29
|
exports.getValue = getValue;
|
41
|
-
|
42
30
|
const getContentReviewStepInitialStatus = (workflowSteps, index, previousStepStatus) => {
|
43
31
|
/**
|
44
32
|
* Always set first step 'active' by default.
|
@@ -46,32 +34,23 @@ const getContentReviewStepInitialStatus = (workflowSteps, index, previousStepSta
|
|
46
34
|
if (index === 0) {
|
47
35
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
48
36
|
}
|
49
|
-
|
50
37
|
const previousStep = workflowSteps[index - 1];
|
51
|
-
|
52
38
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.ACTIVE && previousStep.type !== _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
|
53
39
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
54
40
|
}
|
55
|
-
|
56
41
|
return _types.ApwContentReviewStepStatus.INACTIVE;
|
57
42
|
};
|
58
|
-
|
59
43
|
exports.getContentReviewStepInitialStatus = getContentReviewStepInitialStatus;
|
60
|
-
|
61
44
|
const getNextStepStatus = (previousStepType, previousStepStatus) => {
|
62
45
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.DONE) {
|
63
46
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
64
47
|
}
|
65
|
-
|
66
48
|
if (previousStepStatus === _types.ApwContentReviewStepStatus.ACTIVE && previousStepType !== _types.ApwWorkflowStepTypes.MANDATORY_BLOCKING) {
|
67
49
|
return _types.ApwContentReviewStepStatus.ACTIVE;
|
68
50
|
}
|
69
|
-
|
70
51
|
return _types.ApwContentReviewStepStatus.INACTIVE;
|
71
52
|
};
|
72
|
-
|
73
53
|
exports.getNextStepStatus = getNextStepStatus;
|
74
|
-
|
75
54
|
const extractContentReviewIdAndStep = step => {
|
76
55
|
/*
|
77
56
|
* Get associated content review entry.
|
@@ -83,15 +62,12 @@ const extractContentReviewIdAndStep = step => {
|
|
83
62
|
stepId
|
84
63
|
};
|
85
64
|
};
|
86
|
-
|
87
65
|
exports.extractContentReviewIdAndStep = extractContentReviewIdAndStep;
|
88
|
-
|
89
66
|
const safelyGetContentReview = async ({
|
90
67
|
id,
|
91
68
|
contentReviewMethods
|
92
69
|
}) => {
|
93
70
|
let contentReviewEntry = null;
|
94
|
-
|
95
71
|
try {
|
96
72
|
contentReviewEntry = await contentReviewMethods.get(id);
|
97
73
|
} catch (e) {
|
@@ -99,12 +75,9 @@ const safelyGetContentReview = async ({
|
|
99
75
|
throw e;
|
100
76
|
}
|
101
77
|
}
|
102
|
-
|
103
78
|
return contentReviewEntry;
|
104
79
|
};
|
105
|
-
|
106
80
|
exports.safelyGetContentReview = safelyGetContentReview;
|
107
|
-
|
108
81
|
const updateContentReview = async ({
|
109
82
|
contentReviewMethods,
|
110
83
|
id,
|
@@ -114,31 +87,24 @@ const updateContentReview = async ({
|
|
114
87
|
id,
|
115
88
|
contentReviewMethods
|
116
89
|
});
|
117
|
-
|
118
90
|
if (contentReviewEntry) {
|
119
91
|
const newContentReviewData = getNewContentReviewData(contentReviewEntry);
|
120
92
|
/**
|
121
93
|
* Update content review entry.
|
122
94
|
*/
|
123
|
-
|
124
95
|
await contentReviewMethods.update(contentReviewEntry.id, newContentReviewData);
|
125
96
|
}
|
126
97
|
};
|
127
|
-
|
128
98
|
exports.updateContentReview = updateContentReview;
|
129
|
-
|
130
99
|
const updateContentReviewStep = (steps, stepId, updater) => {
|
131
100
|
return steps.map(step => {
|
132
101
|
if (step.id === stepId) {
|
133
102
|
return (0, _objectSpread2.default)({}, updater(step));
|
134
103
|
}
|
135
|
-
|
136
104
|
return step;
|
137
105
|
});
|
138
106
|
};
|
139
|
-
|
140
107
|
exports.updateContentReviewStep = updateContentReviewStep;
|
141
|
-
|
142
108
|
const isInstallationPending = ({
|
143
109
|
tenancy,
|
144
110
|
i18n
|
@@ -148,40 +114,31 @@ const isInstallationPending = ({
|
|
148
114
|
* installation is completed. So, we need to skip "APW" creation till then.
|
149
115
|
*/
|
150
116
|
const tenant = tenancy.getCurrentTenant();
|
151
|
-
|
152
117
|
if (!tenant) {
|
153
118
|
return true;
|
154
119
|
}
|
155
|
-
|
156
120
|
return !i18n.getContentLocale();
|
157
121
|
};
|
158
|
-
|
159
122
|
exports.isInstallationPending = isInstallationPending;
|
160
123
|
const WORKFLOW_PRECEDENCE = {
|
161
124
|
[_types.WorkflowScopeTypes.DEFAULT]: 0,
|
162
125
|
[_types.WorkflowScopeTypes.CUSTOM]: 1
|
163
126
|
};
|
164
|
-
|
165
127
|
const workflowByPrecedenceDesc = (a, b) => {
|
166
128
|
const scoreA = WORKFLOW_PRECEDENCE[a.scope.type];
|
167
129
|
const scoreB = WORKFLOW_PRECEDENCE[b.scope.type];
|
168
130
|
/**
|
169
131
|
* In descending order of workflow precedence.
|
170
132
|
*/
|
171
|
-
|
172
133
|
return scoreB - scoreA;
|
173
134
|
};
|
174
|
-
|
175
135
|
exports.workflowByPrecedenceDesc = workflowByPrecedenceDesc;
|
176
|
-
|
177
136
|
const workflowByCreatedOnDesc = (a, b) => {
|
178
137
|
const createdOnA = (0, _get.default)(a, "createdOn");
|
179
138
|
const createdOnB = (0, _get.default)(b, "createdOn");
|
180
139
|
/**
|
181
140
|
* In descending order of workflow createdOn i.e. the most recent one first.
|
182
141
|
*/
|
183
|
-
|
184
142
|
return new Date(createdOnB).getTime() - new Date(createdOnA).getTime();
|
185
143
|
};
|
186
|
-
|
187
144
|
exports.workflowByCreatedOnDesc = workflowByCreatedOnDesc;
|