@webiny/api-apw 0.0.0-unstable.5e7233243f → 0.0.0-unstable.6e5425ee89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +30 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +30 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +30 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +30 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +1 -6
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +21 -25
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +21 -26
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +71 -125
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +21 -26
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +37 -28
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +3 -32
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -36
- package/crud/utils.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +7 -13
- package/index.js.map +1 -1
- package/package.json +38 -37
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -16
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +4 -16
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +5 -10
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -21
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +7 -36
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +31 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +31 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +31 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +53 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +3 -17
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +10 -32
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +6 -55
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +1 -32
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +2 -9
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +2 -9
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +5 -24
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +4 -9
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +2 -9
- 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 +26 -15
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +2 -10
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +2 -9
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +4 -12
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +7 -23
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +15 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +10 -0
- package/plugins/hooks/listContentReviews.js +56 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +18 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +116 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +27 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +127 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +27 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +99 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +26 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +24 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +21 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +21 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +21 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +44 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +41 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +41 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +41 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +7 -19
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +14 -27
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +27 -18
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +13 -14
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -8
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -16
- 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 +5 -8
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +38 -42
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +14 -32
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +31 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +31 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +31 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +47 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +3 -14
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -26
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +2 -36
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +4 -57
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +17 -33
- package/scheduler/createScheduleActionMethods.js.map +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 +1 -6
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -22
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +5 -28
- 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.js +13 -34
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +7 -32
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.js +4 -41
- 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 +5 -28
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +4 -29
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +5 -26
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +5 -23
- 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 +3 -12
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +6 -31
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +3 -25
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +17 -9
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +3 -6
- 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 +16 -29
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +6 -31
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +99 -84
- 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 +1 -18
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +5 -21
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["validateComment","apw","comment","
|
1
|
+
{"version":3,"names":["validateComment","apw","comment","onCommentBeforeCreate","subscribe","input","changeRequest","changeRequestId","result","parseIdentifier","WebinyError","ex","get","step"],"sources":["validateComment.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\nimport { parseIdentifier, ParseIdentifierResult } from \"@webiny/utils\";\n\nexport const validateComment = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentBeforeCreate.subscribe(async ({ input }) => {\n const { changeRequest: changeRequestId } = input;\n /**\n * We need changeRequest to be in a particular format i.e. \"contentReviewUniqueId#version\"\n */\n let result: ParseIdentifierResult;\n try {\n result = parseIdentifier(changeRequestId);\n if (!result) {\n throw new WebinyError(\n \"Could not parse changeRequestId.\",\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n changeRequestId\n }\n );\n }\n } catch (ex) {\n throw new WebinyError(\n `The\"changeRequest\" property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_ID\",\n {\n input\n }\n );\n }\n\n /**\n * Assign value for \"step\" field from \"changeRequest\".\n */\n const changeRequest = await apw.changeRequest.get(changeRequestId);\n if (!changeRequest) {\n return;\n }\n input.step = changeRequest.step;\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEO,MAAMA,eAAe,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EAClFA,GAAG,CAACC,OAAO,CAACC,qBAAqB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAgB,CAAC,GAAGF,KAAK;IAChD;AACR;AACA;IACQ,IAAIG,MAA6B;IACjC,IAAI;MACAA,MAAM,GAAG,IAAAC,sBAAe,EAACF,eAAe,CAAC;MACzC,IAAI,CAACC,MAAM,EAAE;QACT,MAAM,IAAIE,cAAW,CACjB,kCAAkC,EAClC,6BAA6B,EAC7B;UACIH;QACJ,CAAC,CACJ;MACL;IACJ,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAID,cAAW,CAChB,iEAAgE,EACjE,6BAA6B,EAC7B;QACIL;MACJ,CAAC,CACJ;IACL;;IAEA;AACR;AACA;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAa,CAACM,GAAG,CAACL,eAAe,CAAC;IAClE,IAAI,CAACD,aAAa,EAAE;MAChB;IACJ;IACAD,KAAK,CAACQ,IAAI,GAAGP,aAAa,CAACO,IAAI;EACnC,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -1,18 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.validateContentReview = void 0;
|
9
|
-
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
-
|
12
9
|
const validateContentReview = ({
|
13
10
|
apw
|
14
11
|
}) => {
|
15
|
-
apw.contentReview.
|
12
|
+
apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({
|
16
13
|
input
|
17
14
|
}) => {
|
18
15
|
const {
|
@@ -21,11 +18,9 @@ const validateContentReview = ({
|
|
21
18
|
/**
|
22
19
|
* Check whether a contentReview already exists for provided content.
|
23
20
|
*/
|
24
|
-
|
25
21
|
const {
|
26
22
|
contentReviewId
|
27
23
|
} = await apw.contentReview.isReviewRequired(content);
|
28
|
-
|
29
24
|
if (contentReviewId) {
|
30
25
|
throw new _error.default(`A peer review for this content has been already requested.`, "REVIEW_ALREADY_EXIST", {
|
31
26
|
contentReviewId,
|
@@ -34,5 +29,4 @@ const validateContentReview = ({
|
|
34
29
|
}
|
35
30
|
});
|
36
31
|
};
|
37
|
-
|
38
32
|
exports.validateContentReview = validateContentReview;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["validateContentReview","apw","contentReview","
|
1
|
+
{"version":3,"names":["validateContentReview","apw","contentReview","onContentReviewBeforeCreate","subscribe","input","content","contentReviewId","isReviewRequired","WebinyError"],"sources":["validateContentReview.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const validateContentReview = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { content } = input;\n /**\n * Check whether a contentReview already exists for provided content.\n */\n const { contentReviewId } = await apw.contentReview.isReviewRequired(content);\n if (contentReviewId) {\n throw new WebinyError(\n `A peer review for this content has been already requested.`,\n \"REVIEW_ALREADY_EXIST\",\n {\n contentReviewId,\n content\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAA8C,CAAC,KAAK;EACxFA,GAAG,CAACC,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACzE,MAAM;MAAEC;IAAQ,CAAC,GAAGD,KAAK;IACzB;AACR;AACA;IACQ,MAAM;MAAEE;IAAgB,CAAC,GAAG,MAAMN,GAAG,CAACC,aAAa,CAACM,gBAAgB,CAACF,OAAO,CAAC;IAC7E,IAAIC,eAAe,EAAE;MACjB,MAAM,IAAIE,cAAW,CAChB,4DAA2D,EAC5D,sBAAsB,EACtB;QACIF,eAAe;QACfD;MACJ,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -1,51 +1,36 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.PageApwSettingsGetterPlugin = void 0;
|
9
|
-
|
10
8
|
var _ContentApwSettingsPlugin = require("../../ContentApwSettingsPlugin");
|
11
|
-
|
12
9
|
var _types = require("../../types");
|
13
|
-
|
14
10
|
var _set = _interopRequireDefault(require("lodash/set"));
|
15
|
-
|
16
11
|
class PageApwSettingsGetterPlugin extends _ContentApwSettingsPlugin.ContentApwSettingsPlugin {
|
17
12
|
canUse(type) {
|
18
13
|
return type === _types.ApwContentTypes.PAGE;
|
19
14
|
}
|
20
|
-
|
21
15
|
setWorkflowId(page, id) {
|
22
16
|
page.settings = (0, _set.default)(page.settings || {}, "apw.workflowId", id);
|
23
17
|
}
|
24
|
-
|
25
18
|
getWorkflowId(page) {
|
26
19
|
var _page$settings$apw;
|
27
|
-
|
28
20
|
if (!page.settings) {
|
29
21
|
return null;
|
30
22
|
}
|
31
|
-
|
32
23
|
return ((_page$settings$apw = page.settings.apw) === null || _page$settings$apw === void 0 ? void 0 : _page$settings$apw.workflowId) || null;
|
33
24
|
}
|
34
|
-
|
35
25
|
setContentReviewId(page, id) {
|
36
26
|
page.settings = (0, _set.default)(page.settings || {}, "apw.contentReviewId", id);
|
37
27
|
}
|
38
|
-
|
39
28
|
getContentReviewId(page) {
|
40
29
|
var _page$settings$apw2;
|
41
|
-
|
42
30
|
if (!page.settings) {
|
43
31
|
return null;
|
44
32
|
}
|
45
|
-
|
46
33
|
return (_page$settings$apw2 = page.settings.apw) === null || _page$settings$apw2 === void 0 ? void 0 : _page$settings$apw2.contentReviewId;
|
47
34
|
}
|
48
|
-
|
49
35
|
}
|
50
|
-
|
51
36
|
exports.PageApwSettingsGetterPlugin = PageApwSettingsGetterPlugin;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PageApwSettingsGetterPlugin","ContentApwSettingsPlugin","canUse","type","ApwContentTypes","PAGE","setWorkflowId","page","id","settings","set","getWorkflowId","apw","workflowId","setContentReviewId","getContentReviewId","contentReviewId"],"sources":["PageApwSettingsGetterPlugin.ts"],"sourcesContent":["import { ContentApwSettingsPlugin } from \"~/ContentApwSettingsPlugin\";\nimport { ApwContentTypes, PageWithWorkflow } from \"~/types\";\nimport set from \"lodash/set\";\n\nexport class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {\n public override canUse(type: ApwContentTypes): boolean {\n return type === ApwContentTypes.PAGE;\n }\n\n public override setWorkflowId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.workflowId\", id);\n }\n\n public override getWorkflowId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.workflowId || null;\n }\n\n public override setContentReviewId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.contentReviewId\", id);\n }\n\n public override getContentReviewId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.contentReviewId;\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["PageApwSettingsGetterPlugin","ContentApwSettingsPlugin","canUse","type","ApwContentTypes","PAGE","setWorkflowId","page","id","settings","set","getWorkflowId","apw","workflowId","setContentReviewId","getContentReviewId","contentReviewId"],"sources":["PageApwSettingsGetterPlugin.ts"],"sourcesContent":["import { ContentApwSettingsPlugin } from \"~/ContentApwSettingsPlugin\";\nimport { ApwContentTypes, PageWithWorkflow } from \"~/types\";\nimport set from \"lodash/set\";\n\nexport class PageApwSettingsGetterPlugin extends ContentApwSettingsPlugin {\n public override canUse(type: ApwContentTypes): boolean {\n return type === ApwContentTypes.PAGE;\n }\n\n public override setWorkflowId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.workflowId\", id);\n }\n\n public override getWorkflowId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.workflowId || null;\n }\n\n public override setContentReviewId(page: PageWithWorkflow, id: string | null) {\n page.settings = set(page.settings || {}, \"apw.contentReviewId\", id);\n }\n\n public override getContentReviewId(page: PageWithWorkflow): string | null {\n if (!page.settings) {\n return null;\n }\n return page.settings.apw?.contentReviewId;\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEO,MAAMA,2BAA2B,SAASC,kDAAwB,CAAC;EACtDC,MAAM,CAACC,IAAqB,EAAW;IACnD,OAAOA,IAAI,KAAKC,sBAAe,CAACC,IAAI;EACxC;EAEgBC,aAAa,CAACC,IAAsB,EAAEC,EAAiB,EAAE;IACrED,IAAI,CAACE,QAAQ,GAAG,IAAAC,YAAG,EAACH,IAAI,CAACE,QAAQ,IAAI,CAAC,CAAC,EAAE,gBAAgB,EAAED,EAAE,CAAC;EAClE;EAEgBG,aAAa,CAACJ,IAAsB,EAAiB;IAAA;IACjE,IAAI,CAACA,IAAI,CAACE,QAAQ,EAAE;MAChB,OAAO,IAAI;IACf;IACA,OAAO,uBAAAF,IAAI,CAACE,QAAQ,CAACG,GAAG,uDAAjB,mBAAmBC,UAAU,KAAI,IAAI;EAChD;EAEgBC,kBAAkB,CAACP,IAAsB,EAAEC,EAAiB,EAAE;IAC1ED,IAAI,CAACE,QAAQ,GAAG,IAAAC,YAAG,EAACH,IAAI,CAACE,QAAQ,IAAI,CAAC,CAAC,EAAE,qBAAqB,EAAED,EAAE,CAAC;EACvE;EAEgBO,kBAAkB,CAACR,IAAsB,EAAiB;IAAA;IACtE,IAAI,CAACA,IAAI,CAACE,QAAQ,EAAE;MAChB,OAAO,IAAI;IACf;IACA,8BAAOF,IAAI,CAACE,QAAQ,CAACG,GAAG,wDAAjB,oBAAmBI,eAAe;EAC7C;AACJ;AAAC"}
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.apwContentPagePlugins = void 0;
|
7
|
-
|
8
7
|
var _api = require("@webiny/api");
|
9
|
-
|
10
8
|
var _types = require("../../types");
|
11
|
-
|
12
9
|
const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
|
13
10
|
const {
|
14
11
|
apw,
|
@@ -26,5 +23,4 @@ const apwContentPagePlugins = () => new _api.ContextPlugin(async context => {
|
|
26
23
|
return true;
|
27
24
|
});
|
28
25
|
});
|
29
|
-
|
30
26
|
exports.apwContentPagePlugins = apwContentPagePlugins;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":"
|
1
|
+
{"version":3,"names":["apwContentPagePlugins","ContextPlugin","context","apw","pageBuilder","addContentGetter","ApwContentTypes","PAGE","id","getPage","addContentPublisher","publishPage","addContentUnPublisher","unpublishPage"],"sources":["apwContentPagePlugins.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContentTypes, ApwContext, PageWithWorkflow } from \"~/types\";\n\nexport const apwContentPagePlugins = () =>\n new ContextPlugin<ApwContext>(async context => {\n const { apw, pageBuilder } = context;\n\n apw.addContentGetter(ApwContentTypes.PAGE, async id => {\n return pageBuilder.getPage<PageWithWorkflow>(id);\n });\n\n apw.addContentPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.publishPage<PageWithWorkflow>(id);\n return true;\n });\n\n apw.addContentUnPublisher(ApwContentTypes.PAGE, async id => {\n await pageBuilder.unpublishPage<PageWithWorkflow>(id);\n return true;\n });\n });\n"],"mappings":";;;;;;AAAA;AACA;AAEO,MAAMA,qBAAqB,GAAG,MACjC,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,GAAG;IAAEC;EAAY,CAAC,GAAGF,OAAO;EAEpCC,GAAG,CAACE,gBAAgB,CAACC,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACnD,OAAOJ,WAAW,CAACK,OAAO,CAAmBD,EAAE,CAAC;EACpD,CAAC,CAAC;EAEFL,GAAG,CAACO,mBAAmB,CAACJ,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACtD,MAAMJ,WAAW,CAACO,WAAW,CAAmBH,EAAE,CAAC;IACnD,OAAO,IAAI;EACf,CAAC,CAAC;EAEFL,GAAG,CAACS,qBAAqB,CAACN,sBAAe,CAACC,IAAI,EAAE,MAAMC,EAAE,IAAI;IACxD,MAAMJ,WAAW,CAACS,aAAa,CAAmBL,EAAE,CAAC;IACrD,OAAO,IAAI;EACf,CAAC,CAAC;AACN,CAAC,CAAC;AAAC"}
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.extendPbPageSettingsSchema = void 0;
|
7
|
-
|
8
7
|
var _plugins = require("@webiny/handler-graphql/plugins");
|
9
|
-
|
10
8
|
const extendPbPageSettingsSchema = () => new _plugins.GraphQLSchemaPlugin({
|
11
|
-
typeDefs:
|
12
|
-
/* GraphQL */
|
13
|
-
`
|
9
|
+
typeDefs: /* GraphQL */`
|
14
10
|
type PbApwPageSettings {
|
15
11
|
workflowId: ID
|
16
12
|
contentReviewId: ID
|
@@ -21,5 +17,4 @@ const extendPbPageSettingsSchema = () => new _plugins.GraphQLSchemaPlugin({
|
|
21
17
|
}
|
22
18
|
`
|
23
19
|
});
|
24
|
-
|
25
20
|
exports.extendPbPageSettingsSchema = extendPbPageSettingsSchema;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["extendPbPageSettingsSchema","GraphQLSchemaPlugin","typeDefs"],"sources":["extendPbPageSettingsSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ApwContext } from \"~/types\";\n\nexport const extendPbPageSettingsSchema = () =>\n new GraphQLSchemaPlugin<ApwContext>({\n typeDefs: /* GraphQL */ `\n type PbApwPageSettings {\n workflowId: ID\n contentReviewId: ID\n }\n\n extend type PbPageSettings {\n apw: PbApwPageSettings\n }\n `\n });\n"],"mappings":"
|
1
|
+
{"version":3,"names":["extendPbPageSettingsSchema","GraphQLSchemaPlugin","typeDefs"],"sources":["extendPbPageSettingsSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ApwContext } from \"~/types\";\n\nexport const extendPbPageSettingsSchema = () =>\n new GraphQLSchemaPlugin<ApwContext>({\n typeDefs: /* GraphQL */ `\n type PbApwPageSettings {\n workflowId: ID\n contentReviewId: ID\n }\n\n extend type PbPageSettings {\n apw: PbApwPageSettings\n }\n `\n });\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,0BAA0B,GAAG,MACtC,IAAIC,4BAAmB,CAAa;EAChCC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,CAAC,CAAC;AAAC"}
|
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.apwPageBuilderHooks = void 0;
|
7
|
-
|
8
7
|
var _triggerContentReview = require("./triggerContentReview");
|
9
|
-
|
10
8
|
var _linkContentReviewToPage = require("./linkContentReviewToPage");
|
11
|
-
|
12
9
|
var _updateContentReviewStatus = require("./updateContentReviewStatus");
|
13
|
-
|
14
10
|
var _linkWorkflowToPage = require("./linkWorkflowToPage");
|
15
|
-
|
16
11
|
var _PageApwSettingsGetterPlugin = require("./PageApwSettingsGetterPlugin");
|
17
|
-
|
12
|
+
var _commentNotification = require("./notifications/commentNotification");
|
13
|
+
var _contentUrl = require("./notifications/contentUrl");
|
14
|
+
var _changeRequestNotification = require("./notifications/changeRequestNotification");
|
15
|
+
var _contentReviewNotification = require("./notifications/contentReviewNotification");
|
18
16
|
const apwPageBuilderHooks = params => {
|
19
17
|
const {
|
20
18
|
pageBuilder,
|
@@ -22,7 +20,7 @@ const apwPageBuilderHooks = params => {
|
|
22
20
|
security,
|
23
21
|
plugins
|
24
22
|
} = params;
|
25
|
-
plugins.register(new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin());
|
23
|
+
plugins.register([new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin(), (0, _commentNotification.createCommentNotification)(), (0, _changeRequestNotification.createChangeRequestNotification)(), (0, _contentUrl.createContentUrlPlugin)(), (0, _contentReviewNotification.createContentReviewNotification)()]);
|
26
24
|
(0, _triggerContentReview.triggerContentReview)({
|
27
25
|
apw,
|
28
26
|
pageBuilder
|
@@ -41,5 +39,4 @@ const apwPageBuilderHooks = params => {
|
|
41
39
|
pageBuilder
|
42
40
|
});
|
43
41
|
};
|
44
|
-
|
45
42
|
exports.apwPageBuilderHooks = apwPageBuilderHooks;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["apwPageBuilderHooks","params","pageBuilder","apw","security","plugins","register","PageApwSettingsGetterPlugin","triggerContentReview","linkContentReviewToPage","updateContentReviewStatus","linkWorkflowToPage"],"sources":["index.ts"],"sourcesContent":["import { Security } from \"@webiny/api-security/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { linkContentReviewToPage } from \"./linkContentReviewToPage\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { linkWorkflowToPage } from \"./linkWorkflowToPage\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageApwSettingsGetterPlugin } from \"~/plugins/pageBuilder/PageApwSettingsGetterPlugin\";\n\nexport interface ApwPageBuilderPluginsParams {\n pageBuilder: PageBuilderContextObject;\n apw: AdvancedPublishingWorkflow;\n security: Security;\n plugins: PluginsContainer;\n}\n\nexport const apwPageBuilderHooks = (params: ApwPageBuilderPluginsParams) => {\n const { pageBuilder, apw, security, plugins } = params;\n\n plugins.register(new PageApwSettingsGetterPlugin());\n\n triggerContentReview({\n apw,\n pageBuilder\n });\n linkContentReviewToPage({\n apw,\n pageBuilder\n });\n updateContentReviewStatus({\n apw,\n pageBuilder,\n security\n });\n linkWorkflowToPage({\n apw,\n pageBuilder\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["apwPageBuilderHooks","params","pageBuilder","apw","security","plugins","register","PageApwSettingsGetterPlugin","createCommentNotification","createChangeRequestNotification","createContentUrlPlugin","createContentReviewNotification","triggerContentReview","linkContentReviewToPage","updateContentReviewStatus","linkWorkflowToPage"],"sources":["index.ts"],"sourcesContent":["import { Security } from \"@webiny/api-security/types\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\nimport { AdvancedPublishingWorkflow } from \"~/types\";\nimport { triggerContentReview } from \"./triggerContentReview\";\nimport { linkContentReviewToPage } from \"./linkContentReviewToPage\";\nimport { updateContentReviewStatus } from \"./updateContentReviewStatus\";\nimport { linkWorkflowToPage } from \"./linkWorkflowToPage\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageApwSettingsGetterPlugin } from \"~/plugins/pageBuilder/PageApwSettingsGetterPlugin\";\nimport { createCommentNotification } from \"./notifications/commentNotification\";\nimport { createContentUrlPlugin } from \"./notifications/contentUrl\";\nimport { createChangeRequestNotification } from \"./notifications/changeRequestNotification\";\nimport { createContentReviewNotification } from \"./notifications/contentReviewNotification\";\n\nexport interface ApwPageBuilderPluginsParams {\n pageBuilder: PageBuilderContextObject;\n apw: AdvancedPublishingWorkflow;\n security: Security;\n plugins: PluginsContainer;\n}\n\nexport const apwPageBuilderHooks = (params: ApwPageBuilderPluginsParams) => {\n const { pageBuilder, apw, security, plugins } = params;\n\n plugins.register([\n new PageApwSettingsGetterPlugin(),\n createCommentNotification(),\n createChangeRequestNotification(),\n createContentUrlPlugin(),\n createContentReviewNotification()\n ]);\n\n triggerContentReview({\n apw,\n pageBuilder\n });\n linkContentReviewToPage({\n apw,\n pageBuilder\n });\n updateContentReviewStatus({\n apw,\n pageBuilder,\n security\n });\n linkWorkflowToPage({\n apw,\n pageBuilder\n });\n};\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AASO,MAAMA,mBAAmB,GAAIC,MAAmC,IAAK;EACxE,MAAM;IAAEC,WAAW;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAEtDI,OAAO,CAACC,QAAQ,CAAC,CACb,IAAIC,wDAA2B,EAAE,EACjC,IAAAC,8CAAyB,GAAE,EAC3B,IAAAC,0DAA+B,GAAE,EACjC,IAAAC,kCAAsB,GAAE,EACxB,IAAAC,0DAA+B,GAAE,CACpC,CAAC;EAEF,IAAAC,0CAAoB,EAAC;IACjBT,GAAG;IACHD;EACJ,CAAC,CAAC;EACF,IAAAW,gDAAuB,EAAC;IACpBV,GAAG;IACHD;EACJ,CAAC,CAAC;EACF,IAAAY,oDAAyB,EAAC;IACtBX,GAAG;IACHD,WAAW;IACXE;EACJ,CAAC,CAAC;EACF,IAAAW,sCAAkB,EAAC;IACfZ,GAAG;IACHD;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -1,86 +1,83 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.linkContentReviewToPage = void 0;
|
9
|
-
|
10
|
-
var _set = _interopRequireDefault(require("lodash/set"));
|
11
|
-
|
12
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
13
|
-
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
14
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
15
|
-
|
16
10
|
var _types = require("../../types");
|
17
|
-
|
18
11
|
var _utils = require("./utils");
|
19
|
-
|
20
12
|
const linkContentReviewToPage = params => {
|
21
13
|
const {
|
22
14
|
apw,
|
23
15
|
pageBuilder
|
24
16
|
} = params;
|
25
|
-
apw.contentReview.
|
17
|
+
apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
|
26
18
|
contentReview
|
27
19
|
}) => {
|
28
20
|
const {
|
29
21
|
content
|
30
22
|
} = contentReview;
|
31
|
-
|
32
|
-
|
33
|
-
await (0, _utils.updatePageSettings)({
|
34
|
-
getPage: pageBuilder.getPage,
|
35
|
-
updatePage: pageBuilder.updatePage,
|
36
|
-
uniquePageId: content.id,
|
37
|
-
getNewSettings: settings => {
|
38
|
-
return (0, _set.default)(settings, "apw.contentReviewId", contentReview.id);
|
39
|
-
}
|
40
|
-
});
|
23
|
+
if (content.type !== _types.ApwContentTypes.PAGE) {
|
24
|
+
return;
|
41
25
|
}
|
26
|
+
await (0, _utils.updatePageSettings)({
|
27
|
+
getPage: pageBuilder.getPage,
|
28
|
+
updatePage: pageBuilder.updatePage,
|
29
|
+
uniquePageId: content.id,
|
30
|
+
getNewSettings: settings => {
|
31
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
32
|
+
apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
|
33
|
+
contentReviewId: contentReview.id
|
34
|
+
})
|
35
|
+
});
|
36
|
+
}
|
37
|
+
});
|
42
38
|
});
|
43
|
-
apw.contentReview.
|
39
|
+
apw.contentReview.onContentReviewAfterDelete.subscribe(async ({
|
44
40
|
contentReview
|
45
41
|
}) => {
|
46
42
|
const {
|
47
43
|
content
|
48
44
|
} = contentReview;
|
49
|
-
|
50
|
-
|
51
|
-
await (0, _utils.updatePageSettings)({
|
52
|
-
getPage: pageBuilder.getPage,
|
53
|
-
updatePage: pageBuilder.updatePage,
|
54
|
-
uniquePageId: content.id,
|
55
|
-
getNewSettings: settings => {
|
56
|
-
return (0, _set.default)(settings, "apw.contentReviewId", null);
|
57
|
-
}
|
58
|
-
});
|
45
|
+
if (content.type !== _types.ApwContentTypes.PAGE) {
|
46
|
+
return;
|
59
47
|
}
|
48
|
+
await (0, _utils.updatePageSettings)({
|
49
|
+
getPage: pageBuilder.getPage,
|
50
|
+
updatePage: pageBuilder.updatePage,
|
51
|
+
uniquePageId: content.id,
|
52
|
+
getNewSettings: settings => {
|
53
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
54
|
+
apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
|
55
|
+
contentReviewId: null
|
56
|
+
})
|
57
|
+
});
|
58
|
+
}
|
59
|
+
});
|
60
60
|
});
|
61
|
-
pageBuilder.
|
61
|
+
pageBuilder.onPageBeforeDelete.subscribe(async ({
|
62
62
|
page
|
63
63
|
}) => {
|
64
|
-
|
65
|
-
|
64
|
+
var _page$settings, _page$settings$apw;
|
65
|
+
const contentReviewId = (_page$settings = page.settings) === null || _page$settings === void 0 ? void 0 : (_page$settings$apw = _page$settings.apw) === null || _page$settings$apw === void 0 ? void 0 : _page$settings$apw.contentReviewId;
|
66
66
|
if (!contentReviewId) {
|
67
67
|
return;
|
68
68
|
}
|
69
|
-
|
70
69
|
let contentReview;
|
71
|
-
|
72
70
|
try {
|
73
71
|
contentReview = await apw.contentReview.get(contentReviewId);
|
74
|
-
} catch (
|
72
|
+
} catch (ex) {
|
75
73
|
/**
|
76
74
|
* We're handling the case whereby "contentReviewId" is still linked to page;
|
77
75
|
* even when the contentReview entry has been deleted. In that case, we'll allow page deletion.
|
78
76
|
*/
|
79
|
-
if (
|
80
|
-
throw
|
77
|
+
if (ex.code !== "NOT_FOUND") {
|
78
|
+
throw ex;
|
81
79
|
}
|
82
80
|
}
|
83
|
-
|
84
81
|
if (contentReview) {
|
85
82
|
throw new _error.default(`Cannot delete the page because a peer review has been requested. Please delete the review first.`, "CANNOT_DELETE_REVIEW_EXIST", {
|
86
83
|
contentReviewId,
|
@@ -89,5 +86,4 @@ const linkContentReviewToPage = params => {
|
|
89
86
|
}
|
90
87
|
});
|
91
88
|
};
|
92
|
-
|
93
89
|
exports.linkContentReviewToPage = linkContentReviewToPage;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["linkContentReviewToPage","params","apw","pageBuilder","contentReview","
|
1
|
+
{"version":3,"names":["linkContentReviewToPage","params","apw","pageBuilder","contentReview","onContentReviewAfterCreate","subscribe","content","type","ApwContentTypes","PAGE","updatePageSettings","getPage","updatePage","uniquePageId","id","getNewSettings","settings","contentReviewId","onContentReviewAfterDelete","onPageBeforeDelete","page","get","ex","code","Error"],"sources":["linkContentReviewToPage.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport { AdvancedPublishingWorkflow, ApwContentTypes } from \"~/types\";\nimport { updatePageSettings } from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkContentReviewToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkContentReviewToPage = (params: LinkContentReviewToPageParams) => {\n const { apw, pageBuilder } = params;\n\n apw.contentReview.onContentReviewAfterCreate.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.PAGE) {\n return;\n }\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return {\n ...settings,\n apw: {\n ...(settings.apw || {}),\n contentReviewId: contentReview.id\n }\n };\n }\n });\n });\n\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n const { content } = contentReview;\n\n if (content.type !== ApwContentTypes.PAGE) {\n return;\n }\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: content.id,\n getNewSettings: settings => {\n return {\n ...settings,\n apw: {\n ...(settings.apw || {}),\n contentReviewId: null\n }\n };\n }\n });\n });\n\n pageBuilder.onPageBeforeDelete.subscribe(async ({ page }) => {\n const contentReviewId = page.settings?.apw?.contentReviewId;\n if (!contentReviewId) {\n return;\n }\n\n let contentReview;\n try {\n contentReview = await apw.contentReview.get(contentReviewId);\n } catch (ex) {\n /**\n * We're handling the case whereby \"contentReviewId\" is still linked to page;\n * even when the contentReview entry has been deleted. In that case, we'll allow page deletion.\n */\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n\n if (contentReview) {\n throw new Error(\n `Cannot delete the page because a peer review has been requested. Please delete the review first.`,\n \"CANNOT_DELETE_REVIEW_EXIST\",\n {\n contentReviewId,\n page\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAQO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC;EAAY,CAAC,GAAGF,MAAM;EAEnCC,GAAG,CAACE,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IAEjC,IAAIG,OAAO,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI,EAAE;MACvC;IACJ;IACA,MAAM,IAAAC,yBAAkB,EAAC;MACrBC,OAAO,EAAET,WAAW,CAACS,OAAO;MAC5BC,UAAU,EAAEV,WAAW,CAACU,UAAU;MAClCC,YAAY,EAAEP,OAAO,CAACQ,EAAE;MACxBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QAAQ;UACXf,GAAG,8DACKe,QAAQ,CAACf,GAAG,IAAI,CAAC,CAAC;YACtBgB,eAAe,EAAEd,aAAa,CAACW;UAAE;QACpC;MAET;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFb,GAAG,CAACE,aAAa,CAACe,0BAA0B,CAACb,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF,MAAM;MAAEG;IAAQ,CAAC,GAAGH,aAAa;IAEjC,IAAIG,OAAO,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI,EAAE;MACvC;IACJ;IACA,MAAM,IAAAC,yBAAkB,EAAC;MACrBC,OAAO,EAAET,WAAW,CAACS,OAAO;MAC5BC,UAAU,EAAEV,WAAW,CAACU,UAAU;MAClCC,YAAY,EAAEP,OAAO,CAACQ,EAAE;MACxBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QAAQ;UACXf,GAAG,8DACKe,QAAQ,CAACf,GAAG,IAAI,CAAC,CAAC;YACtBgB,eAAe,EAAE;UAAI;QACxB;MAET;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFf,WAAW,CAACiB,kBAAkB,CAACd,SAAS,CAAC,OAAO;IAAEe;EAAK,CAAC,KAAK;IAAA;IACzD,MAAMH,eAAe,qBAAGG,IAAI,CAACJ,QAAQ,yEAAb,eAAef,GAAG,uDAAlB,mBAAoBgB,eAAe;IAC3D,IAAI,CAACA,eAAe,EAAE;MAClB;IACJ;IAEA,IAAId,aAAa;IACjB,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAa,CAACkB,GAAG,CAACJ,eAAe,CAAC;IAChE,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;QACzB,MAAMD,EAAE;MACZ;IACJ;IAEA,IAAInB,aAAa,EAAE;MACf,MAAM,IAAIqB,cAAK,CACV,kGAAiG,EAClG,4BAA4B,EAC5B;QACIP,eAAe;QACfG;MACJ,CAAC,CACJ;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -1,24 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.linkWorkflowToPage = void 0;
|
9
|
-
|
10
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
11
|
-
|
12
9
|
var _set = _interopRequireDefault(require("lodash/set"));
|
13
|
-
|
10
|
+
var _types = require("../../types");
|
14
11
|
var _utils = require("./utils");
|
15
|
-
|
16
12
|
const linkWorkflowToPage = params => {
|
17
13
|
const {
|
18
14
|
apw,
|
19
15
|
pageBuilder
|
20
16
|
} = params;
|
21
|
-
pageBuilder.
|
17
|
+
pageBuilder.onPageBeforeCreate.subscribe(async ({
|
22
18
|
page
|
23
19
|
}) => {
|
24
20
|
await (0, _utils.assignWorkflowToPage)({
|
@@ -26,7 +22,7 @@ const linkWorkflowToPage = params => {
|
|
26
22
|
page
|
27
23
|
});
|
28
24
|
});
|
29
|
-
pageBuilder.
|
25
|
+
pageBuilder.onPageBeforeCreateFrom.subscribe(async params => {
|
30
26
|
const {
|
31
27
|
page,
|
32
28
|
original
|
@@ -35,34 +31,28 @@ const linkWorkflowToPage = params => {
|
|
35
31
|
* If the previous revision(original) already had the "contentReviewId",
|
36
32
|
* we need to unlink it so that new "contentReview" can be request for the new revision.
|
37
33
|
*/
|
38
|
-
|
39
34
|
const previousContentReviewId = (0, _get.default)(original, "settings.apw.contentReviewId");
|
40
|
-
|
41
35
|
if (previousContentReviewId) {
|
42
36
|
page.settings.apw.contentReviewId = null;
|
43
37
|
}
|
38
|
+
|
44
39
|
/**
|
45
40
|
* If the previous revision(original) already had the "workflowId",
|
46
41
|
* we don't need to do anything we'll just let it be copied over.
|
47
42
|
*/
|
48
|
-
|
49
|
-
|
50
43
|
const previousWorkflowId = (0, _get.default)(original, "settings.apw.workflowId");
|
51
|
-
|
52
44
|
if (previousWorkflowId) {
|
53
45
|
return;
|
54
46
|
}
|
55
47
|
/**
|
56
48
|
* Lookup and assign "workflowId".
|
57
49
|
*/
|
58
|
-
|
59
|
-
|
60
50
|
await (0, _utils.assignWorkflowToPage)({
|
61
51
|
listWorkflow: apw.workflow.list,
|
62
52
|
page
|
63
53
|
});
|
64
54
|
});
|
65
|
-
pageBuilder.
|
55
|
+
pageBuilder.onPageBeforeUpdate.subscribe(async params => {
|
66
56
|
const {
|
67
57
|
page,
|
68
58
|
original
|
@@ -74,7 +64,6 @@ const linkWorkflowToPage = params => {
|
|
74
64
|
* It can happen because we run modal validation in "onBeforePageUpdate" event,
|
75
65
|
* which doesn't have the "apw" property.
|
76
66
|
*/
|
77
|
-
|
78
67
|
if (prevApwWorkflowId && !currentApwWorkflowId) {
|
79
68
|
page.settings.apw = original.settings.apw;
|
80
69
|
}
|
@@ -82,12 +71,9 @@ const linkWorkflowToPage = params => {
|
|
82
71
|
* If there is a linked "contentReview" for this page and the page "title" has changed.
|
83
72
|
* Let's update the "title" field in "contentReview".
|
84
73
|
*/
|
85
|
-
|
86
|
-
|
87
74
|
const linkedContentReviewId = (0, _get.default)(page, "settings.apw.contentReviewId");
|
88
75
|
const prevTitle = (0, _get.default)(original, "title");
|
89
76
|
const newTitle = (0, _get.default)(page, "title");
|
90
|
-
|
91
77
|
if (linkedContentReviewId && prevTitle !== newTitle) {
|
92
78
|
await apw.contentReview.update(linkedContentReviewId, {
|
93
79
|
title: newTitle
|
@@ -97,23 +83,22 @@ const linkWorkflowToPage = params => {
|
|
97
83
|
/**
|
98
84
|
* Link created workflow to associated pages.
|
99
85
|
*/
|
100
|
-
|
101
|
-
apw.workflow.onAfterWorkflowCreate.subscribe(async ({
|
86
|
+
apw.workflow.onWorkflowAfterCreate.subscribe(async ({
|
102
87
|
workflow
|
103
88
|
}) => {
|
104
89
|
const {
|
105
90
|
scope
|
106
91
|
} = workflow;
|
92
|
+
if (workflow.app !== _types.ApwWorkflowApplications.PB) {
|
93
|
+
return;
|
94
|
+
}
|
107
95
|
/**
|
108
96
|
* If the workflow has pages in it's scope, we'll link that workflow for each of those pages.
|
109
97
|
*/
|
110
|
-
|
111
98
|
if ((0, _utils.hasPages)(workflow) === false) {
|
112
99
|
return;
|
113
100
|
}
|
114
|
-
|
115
101
|
const pages = (0, _get.default)(scope, "data.pages");
|
116
|
-
|
117
102
|
for (const pid of pages) {
|
118
103
|
await (0, _utils.updatePageSettings)({
|
119
104
|
getPage: pageBuilder.getPage,
|
@@ -128,14 +113,16 @@ const linkWorkflowToPage = params => {
|
|
128
113
|
/**
|
129
114
|
* Link updated workflow to associated pages.
|
130
115
|
*/
|
131
|
-
|
132
|
-
apw.workflow.onAfterWorkflowUpdate.subscribe(async ({
|
116
|
+
apw.workflow.onWorkflowAfterUpdate.subscribe(async ({
|
133
117
|
workflow,
|
134
118
|
original
|
135
119
|
}) => {
|
136
120
|
const {
|
137
121
|
scope
|
138
122
|
} = workflow;
|
123
|
+
if (workflow.app !== _types.ApwWorkflowApplications.PB) {
|
124
|
+
return;
|
125
|
+
}
|
139
126
|
const {
|
140
127
|
scope: prevScope
|
141
128
|
} = original;
|
@@ -143,18 +130,15 @@ const linkWorkflowToPage = params => {
|
|
143
130
|
* If the workflow has pages in it's scope and there is a change in that page list,
|
144
131
|
* we'll update the workflow link for corresponding pages.
|
145
132
|
*/
|
146
|
-
|
147
133
|
if ((0, _utils.hasPages)(workflow) === false || (0, _utils.shouldUpdatePages)(scope, prevScope) === false) {
|
148
134
|
return;
|
149
135
|
}
|
150
|
-
|
151
136
|
const previousPages = (0, _get.default)(prevScope, "data.pages", []);
|
152
137
|
const currentPages = (0, _get.default)(scope, "data.pages", []);
|
153
138
|
const {
|
154
139
|
removedPages,
|
155
140
|
addedPages
|
156
141
|
} = (0, _utils.getPagesDiff)(currentPages, previousPages);
|
157
|
-
|
158
142
|
for (const pid of addedPages) {
|
159
143
|
await (0, _utils.updatePageSettings)({
|
160
144
|
getPage: pageBuilder.getPage,
|
@@ -165,7 +149,6 @@ const linkWorkflowToPage = params => {
|
|
165
149
|
}
|
166
150
|
});
|
167
151
|
}
|
168
|
-
|
169
152
|
for (const pid of removedPages) {
|
170
153
|
await (0, _utils.updatePageSettings)({
|
171
154
|
getPage: pageBuilder.getPage,
|
@@ -178,5 +161,4 @@ const linkWorkflowToPage = params => {
|
|
178
161
|
}
|
179
162
|
});
|
180
163
|
};
|
181
|
-
|
182
164
|
exports.linkWorkflowToPage = linkWorkflowToPage;
|