@webiny/api-apw 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.d.ts +1 -1
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.d.ts +1 -1
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.d.ts +1 -1
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.d.ts +1 -1
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.d.ts +1 -1
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.d.ts +1 -1
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.d.ts +1 -1
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.d.ts +2 -2
- package/crud/createContentReviewMethods.js +1 -2
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.d.ts +1 -1
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.d.ts +1 -1
- package/crud/index.js.map +1 -1
- package/crud/utils.d.ts +2 -2
- package/crud/utils.js +1 -2
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +4 -5
- package/index.js.map +1 -1
- package/package.json +32 -43
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.d.ts +2 -2
- package/plugins/cms/apwEntryPlugins.js +10 -1
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.d.ts +4 -4
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
- package/plugins/cms/linkWorkflowToEntry.js +1 -1
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.d.ts +2 -2
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +2 -2
- package/plugins/cms/utils.js +1 -3
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +3 -3
- package/plugins/context.js +3 -14
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.d.ts +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -2
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.d.ts +1 -1
- package/plugins/graphql/comment.gql.js +1 -2
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.d.ts +1 -1
- package/plugins/graphql/contentReview.gql.js +1 -2
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.d.ts +1 -1
- package/plugins/graphql/reviewer.gql.js +1 -2
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/utils.js +2 -4
- package/plugins/graphql/utils.js.map +1 -1
- package/plugins/graphql/workflow.gql.d.ts +1 -1
- package/plugins/graphql/workflow.gql.js +1 -2
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.d.ts +1 -1
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.d.ts +1 -1
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +1 -1
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.d.ts +3 -3
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +2 -2
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +2 -2
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +2 -2
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.d.ts +2 -2
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
- package/plugins/hooks/notifications/getAppUrl.js +19 -0
- package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.d.ts +1 -1
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.d.ts +1 -1
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.d.ts +1 -1
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.d.ts +1 -1
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.d.ts +1 -1
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/utils.d.ts +6 -5
- package/plugins/utils.js +6 -5
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.d.ts +1 -1
- package/scheduler/createScheduleActionMethods.js +63 -38
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +2 -2
- package/scheduler/handlers/executeAction/index.js +0 -1
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +3 -2
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.d.ts +2 -2
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
- package/scheduler/handlers/scheduleAction/index.js +1 -3
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +15 -7
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.d.ts +1 -1
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +11 -11
- package/scheduler/types.js +3 -6
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
- package/storageOperations/changeRequestStorageOperations.js +13 -25
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.d.ts +3 -3
- package/storageOperations/commentStorageOperations.js +15 -28
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
- package/storageOperations/contentReviewStorageOperations.js +14 -27
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +3 -3
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -1
- package/storageOperations/models/changeRequest.model.js +5 -6
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -1
- package/storageOperations/models/comment.model.js +5 -6
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -1
- package/storageOperations/models/contentReview.model.js +5 -6
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.d.ts +1 -1
- package/storageOperations/models/index.js +5 -5
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -1
- package/storageOperations/models/reviewer.model.js +5 -6
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.d.ts +2 -2
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +2 -2
- package/storageOperations/models/workflow.model.js +5 -6
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +3 -3
- package/storageOperations/reviewerStorageOperations.js +14 -27
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/types.d.ts +2 -2
- package/storageOperations/types.js.map +1 -1
- package/storageOperations/workflowStorageOperations.d.ts +2 -2
- package/storageOperations/workflowStorageOperations.js +11 -24
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +31 -48
- package/types.js +6 -12
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.d.ts +2 -2
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.d.ts +2 -2
- package/utils/fieldResolver.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +1 -1
- package/utils/pickEntryFieldValues.js +1 -2
- package/utils/pickEntryFieldValues.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +0 -2
- package/plugins/hooks/notifications/appUrl.js +0 -20
- package/plugins/hooks/notifications/appUrl.js.map +0 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -36
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -28
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -22
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
- package/plugins/pageBuilder/index.d.ts +0 -11
- package/plugins/pageBuilder/index.js +0 -44
- package/plugins/pageBuilder/index.js.map +0 -1
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -93
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkWorkflowToPage.js +0 -166
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -33
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -33
- package/plugins/pageBuilder/notifications/commentNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -33
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +0 -49
- package/plugins/pageBuilder/notifications/contentUrl.js.map +0 -1
- package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
- package/plugins/pageBuilder/triggerContentReview.js +0 -41
- package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -72
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
- package/plugins/pageBuilder/utils.d.ts +0 -22
- package/plugins/pageBuilder/utils.js +0 -152
- package/plugins/pageBuilder/utils.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_get","_interopRequireDefault","require","_types","_utils","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","exports"],"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,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAUO,MAAMG,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,CAAC,CAAC;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,EAAE;UACL,GAAGR,aAAa,CAACQ,OAAO;UACxB,GAAGC,mDAA4C;UAC/CC,WAAW,EAAET,QAAQ,CAACU;QAC1B;MACJ,CAAC,CAAC;IACN;EACJ,CACJ,CAAC;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,EAAE;UACL,GAAGR,aAAa,CAACQ,OAAO;UACxB,GAAGC,mDAA4C;UAC/CC,WAAW,EAAE;QACjB;MACJ,CAAC,CAAC;IACN;EACJ,CACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAvB,yBAAA,GAAAA,yBAAA"}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { ApwWorkflow, ApwWorkflowCrud, ApwWorkflowScope, PageWithWorkflow } from "../../types";
|
2
|
-
import { PageBuilderContextObject } from "@webiny/api-page-builder/graphql/types";
|
3
|
-
interface AssignWorkflowToPageParams {
|
4
|
-
listWorkflow: ApwWorkflowCrud["list"];
|
5
|
-
page: PageWithWorkflow;
|
6
|
-
}
|
7
|
-
export declare const assignWorkflowToPage: ({ listWorkflow, page }: AssignWorkflowToPageParams) => Promise<void>;
|
8
|
-
export declare const hasPages: (workflow: ApwWorkflow) => boolean;
|
9
|
-
export declare const shouldUpdatePages: (scope: ApwWorkflowScope, prevScope: ApwWorkflowScope) => boolean;
|
10
|
-
interface GetUpdatePageOpsResult {
|
11
|
-
addedPages: string[];
|
12
|
-
removedPages: string[];
|
13
|
-
}
|
14
|
-
export declare const getPagesDiff: (currentPages: string[], prevPages: string[]) => GetUpdatePageOpsResult;
|
15
|
-
interface UpdatePageSettingsParams {
|
16
|
-
getPage: PageBuilderContextObject["getPage"];
|
17
|
-
updatePage: PageBuilderContextObject["updatePage"];
|
18
|
-
uniquePageId: string;
|
19
|
-
getNewSettings: (settings: PageWithWorkflow["settings"]) => PageWithWorkflow["settings"];
|
20
|
-
}
|
21
|
-
export declare const updatePageSettings: ({ getPage, updatePage, uniquePageId, getNewSettings }: UpdatePageSettingsParams) => Promise<void>;
|
22
|
-
export {};
|
@@ -1,152 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
5
|
-
value: true
|
6
|
-
});
|
7
|
-
exports.updatePageSettings = exports.shouldUpdatePages = exports.hasPages = exports.getPagesDiff = exports.assignWorkflowToPage = void 0;
|
8
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
10
|
-
var _types = require("../../types");
|
11
|
-
var _utils = require("../utils");
|
12
|
-
const isWorkflowApplicable = (page, workflow) => {
|
13
|
-
const application = workflow.app;
|
14
|
-
if (application !== _types.ApwWorkflowApplications.PB) {
|
15
|
-
return false;
|
16
|
-
}
|
17
|
-
const scopeType = workflow.scope.type;
|
18
|
-
if (scopeType === _types.WorkflowScopeTypes.DEFAULT) {
|
19
|
-
return true;
|
20
|
-
} else if (scopeType === _types.WorkflowScopeTypes.CUSTOM) {
|
21
|
-
const categories = (0, _get.default)(workflow, "scope.data.categories");
|
22
|
-
if (Array.isArray(categories) && categories.includes(page.category)) {
|
23
|
-
return true;
|
24
|
-
}
|
25
|
-
const pages = (0, _get.default)(workflow, "scope.data.pages");
|
26
|
-
if (Array.isArray(pages) && pages.includes(page.pid)) {
|
27
|
-
return true;
|
28
|
-
}
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
throw new _error.default(`Unknown scope type "${scopeType}".`, "UNKNOWN_SCOPE_TYPE", {
|
32
|
-
workflow
|
33
|
-
});
|
34
|
-
};
|
35
|
-
const assignWorkflowToPage = async ({
|
36
|
-
listWorkflow,
|
37
|
-
page
|
38
|
-
}) => {
|
39
|
-
/**
|
40
|
-
* Lookup and assign "workflowId".
|
41
|
-
*/
|
42
|
-
try {
|
43
|
-
/*
|
44
|
-
* List all workflows for app pageBuilder
|
45
|
-
*/
|
46
|
-
const [entries] = await listWorkflow({
|
47
|
-
where: {
|
48
|
-
app: _types.ApwWorkflowApplications.PB
|
49
|
-
}
|
50
|
-
});
|
51
|
-
|
52
|
-
/*
|
53
|
-
* Re-order them based on workflow scope and pre-defined rule i.e.
|
54
|
-
* "specific" entry -> entry for a "category" -> "default".
|
55
|
-
* There can be more than one workflow with same "scope" and "app".
|
56
|
-
* Therefore, we are also sorting the workflows by `createdOn` to get the latest workflow.
|
57
|
-
*/
|
58
|
-
const sortedWorkflows = entries.sort(_utils.workflowByPrecedenceDesc).sort(_utils.workflowByCreatedOnDesc);
|
59
|
-
for (const workflow of sortedWorkflows) {
|
60
|
-
/**
|
61
|
-
* Assign the first applicable workflow to the page and exit.
|
62
|
-
*/
|
63
|
-
if (isWorkflowApplicable(page, workflow)) {
|
64
|
-
page.settings.apw = {
|
65
|
-
workflowId: workflow.id,
|
66
|
-
contentReviewId: null
|
67
|
-
};
|
68
|
-
break;
|
69
|
-
}
|
70
|
-
}
|
71
|
-
} catch (ex) {
|
72
|
-
throw new _error.default(`Failed to assign workflow to page "${page.pid}".`, ex.code, ex.data);
|
73
|
-
}
|
74
|
-
};
|
75
|
-
exports.assignWorkflowToPage = assignWorkflowToPage;
|
76
|
-
const hasPages = workflow => {
|
77
|
-
const {
|
78
|
-
app,
|
79
|
-
scope
|
80
|
-
} = workflow;
|
81
|
-
return app === _types.ApwWorkflowApplications.PB && scope.type === _types.WorkflowScopeTypes.CUSTOM && scope.data && Array.isArray(scope.data.pages);
|
82
|
-
};
|
83
|
-
exports.hasPages = hasPages;
|
84
|
-
const shouldUpdatePages = (scope, prevScope) => {
|
85
|
-
/**
|
86
|
-
* Bail out early if the scope is not "CUSTOM" - at that point all pages should be updated.
|
87
|
-
*/
|
88
|
-
if (prevScope.type !== _types.WorkflowScopeTypes.CUSTOM) {
|
89
|
-
return true;
|
90
|
-
}
|
91
|
-
const prevScopePages = (0, _get.default)(prevScope, "data.pages");
|
92
|
-
const currentScopePages = (0, _get.default)(scope, "data.pages");
|
93
|
-
/**
|
94
|
-
* Bail out early if there were no pages assigned previously.
|
95
|
-
*/
|
96
|
-
if (prevScopePages.length === 0) {
|
97
|
-
return true;
|
98
|
-
}
|
99
|
-
/**
|
100
|
-
* Bail out early if number of pages has been changed.
|
101
|
-
*/
|
102
|
-
if (currentScopePages.length !== prevScopePages.length) {
|
103
|
-
return true;
|
104
|
-
}
|
105
|
-
/*
|
106
|
-
* Check whether previous scope has the exactly same pages as in the new scope.
|
107
|
-
*/
|
108
|
-
return !prevScopePages.every(pid => currentScopePages.includes(pid));
|
109
|
-
};
|
110
|
-
exports.shouldUpdatePages = shouldUpdatePages;
|
111
|
-
const getPagesDiff = (currentPages, prevPages) => {
|
112
|
-
const addedPages = currentPages.filter(id => !prevPages.includes(id));
|
113
|
-
const removedPages = prevPages.filter(id => !currentPages.includes(id));
|
114
|
-
return {
|
115
|
-
addedPages,
|
116
|
-
removedPages
|
117
|
-
};
|
118
|
-
};
|
119
|
-
exports.getPagesDiff = getPagesDiff;
|
120
|
-
const updatePageSettings = async ({
|
121
|
-
getPage,
|
122
|
-
updatePage,
|
123
|
-
uniquePageId,
|
124
|
-
getNewSettings
|
125
|
-
}) => {
|
126
|
-
try {
|
127
|
-
/**
|
128
|
-
* Currently, we only assign "workflow" to latest page.
|
129
|
-
*/
|
130
|
-
const page = await getPage(uniquePageId);
|
131
|
-
/**
|
132
|
-
* We can't update a page that is "locked".
|
133
|
-
*/
|
134
|
-
if (page.locked) {
|
135
|
-
return;
|
136
|
-
}
|
137
|
-
/**
|
138
|
-
* There can be more than one workflow with same `scope` for same `app`. That is why;
|
139
|
-
* We'll update the workflow reference even though it already had one assign.
|
140
|
-
*/
|
141
|
-
await updatePage(page.id, {
|
142
|
-
settings: getNewSettings(page.settings)
|
143
|
-
});
|
144
|
-
} catch (e) {
|
145
|
-
if (e.code !== "NOT_FOUND") {
|
146
|
-
throw e;
|
147
|
-
}
|
148
|
-
}
|
149
|
-
};
|
150
|
-
exports.updatePageSettings = updatePageSettings;
|
151
|
-
|
152
|
-
//# sourceMappingURL=utils.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_get","_interopRequireDefault","require","_error","_types","_utils","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","exports","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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