@webiny/api-apw 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.97a151f74d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.d.ts +27 -0
- package/ApwChangeRequestNotification.js +40 -0
- package/ApwChangeRequestNotification.js.map +1 -0
- package/ApwCommentNotification.d.ts +27 -0
- package/ApwCommentNotification.js +40 -0
- package/ApwCommentNotification.js.map +1 -0
- package/ApwContentReviewNotification.d.ts +26 -0
- package/ApwContentReviewNotification.js +40 -0
- package/ApwContentReviewNotification.js.map +1 -0
- package/ApwContentUrlPlugin.d.ts +19 -0
- package/ApwContentUrlPlugin.js +40 -0
- package/ApwContentUrlPlugin.js.map +1 -0
- package/ContentApwSettingsPlugin.js +1 -1
- package/crud/createChangeRequestMethods.js +21 -18
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +21 -18
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +60 -50
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +21 -18
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +42 -20
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +3 -7
- package/crud/index.js.map +1 -1
- package/crud/utils.js +4 -8
- package/crud/utils.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +8 -4
- package/index.js.map +1 -1
- package/package.json +38 -37
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +1 -1
- package/plugins/cms/apwEntryPlugins.js +4 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +9 -1
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +4 -4
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +5 -5
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/cms/notifications/changeRequestNotification.js +35 -0
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/cms/notifications/commentNotification.d.ts +1 -0
- package/plugins/cms/notifications/commentNotification.js +35 -0
- package/plugins/cms/notifications/commentNotification.js.map +1 -0
- package/plugins/cms/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/cms/notifications/contentReviewNotification.js +35 -0
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/cms/notifications/contentUrl.d.ts +8 -0
- package/plugins/cms/notifications/contentUrl.js +60 -0
- package/plugins/cms/notifications/contentUrl.js.map +1 -0
- package/plugins/cms/triggerContentReview.js +3 -3
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +10 -14
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +4 -8
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.js +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -1
- package/plugins/graphql/comment.gql.js +1 -1
- package/plugins/graphql/contentReview.gql.js +4 -4
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -1
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -1
- package/plugins/graphql.js +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +28 -8
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +6 -0
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +5 -8
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +2 -0
- package/plugins/hooks/initializeNotifications.js +20 -0
- package/plugins/hooks/initializeNotifications.js.map +1 -0
- package/plugins/hooks/listContentReviews.d.ts +10 -0
- package/plugins/hooks/listContentReviews.js +68 -0
- package/plugins/hooks/listContentReviews.js.map +1 -0
- package/plugins/hooks/notifications/appUrl.d.ts +2 -0
- package/plugins/hooks/notifications/appUrl.js +22 -0
- package/plugins/hooks/notifications/appUrl.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +144 -0
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/changeRequestUrl.d.ts +8 -0
- package/plugins/hooks/notifications/changeRequestUrl.js +31 -0
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -0
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/commentAfterCreate.js +157 -0
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/commentUrl.d.ts +8 -0
- package/plugins/hooks/notifications/commentUrl.js +31 -0
- package/plugins/hooks/notifications/commentUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +2 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +122 -0
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -0
- package/plugins/hooks/notifications/contentReviewUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentReviewUrl.js +30 -0
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -0
- package/plugins/hooks/notifications/contentUrl.d.ts +7 -0
- package/plugins/hooks/notifications/contentUrl.js +29 -0
- package/plugins/hooks/notifications/contentUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +11 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +25 -0
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -0
- package/plugins/hooks/notifications/reviewers.d.ts +15 -0
- package/plugins/hooks/notifications/reviewers.js +51 -0
- package/plugins/hooks/notifications/reviewers.js.map +1 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +52 -0
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendCommentNotification.js +52 -0
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +2 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js +52 -0
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -0
- package/plugins/hooks/updatePendingChangeRequests.js +7 -11
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +14 -18
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +30 -5
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +14 -4
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +2 -2
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +1 -1
- package/plugins/pageBuilder/index.js +9 -1
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +41 -29
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +18 -6
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +35 -0
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/commentNotification.js +35 -0
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +35 -0
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +1 -0
- package/plugins/pageBuilder/notifications/contentUrl.js +53 -0
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -0
- package/plugins/pageBuilder/triggerContentReview.js +3 -3
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +10 -14
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -1
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.d.ts +1 -1
- package/plugins/utils.js +4 -14
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +17 -14
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +8 -9
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +5 -9
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +1 -1
- package/storageOperations/changeRequestStorageOperations.js +5 -9
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +4 -8
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +5 -9
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +5 -9
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +3 -7
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +6 -5
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +1 -1
- package/storageOperations/models/reviewer.model.js +18 -2
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +3 -2
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +18 -14
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +8 -12
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +99 -84
- package/types.js.map +1 -1
- package/utils/errors.js +1 -1
- package/utils/fieldResolver.js +3 -9
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["updateTotalCommentsCount","apw","comment","
|
1
|
+
{"version":3,"names":["updateTotalCommentsCount","apw","comment","onCommentAfterDelete","subscribe","step","id","stepId","extractContentReviewIdAndStep","updateContentReview","contentReviewMethods","contentReview","getNewContentReviewData","data","steps","updateContentReviewStep","totalComments","onCommentAfterCreate","updateLatestCommentId","latestCommentId","onCommentAfterUpdate","safelyGetContentReview","latestComment","list","where","changeRequest","sort"],"sources":["updateTotalComments.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\nimport {\n extractContentReviewIdAndStep,\n safelyGetContentReview,\n updateContentReview,\n updateContentReviewStep\n} from \"../utils\";\n\nexport const updateTotalCommentsCount = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n const { step } = comment;\n /**\n * After a \"comment\" is deleted, decrement the \"totalComments\" count\n * in the corresponding step of the content review entry.\n */\n if (step) {\n const { id, stepId } = extractContentReviewIdAndStep(step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments - 1\n }))\n };\n }\n });\n }\n });\n\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, increment the \"totalComments\" count\n * of the corresponding step in the content review entry.\n */\n const { id, stepId } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: data => {\n return {\n ...data,\n steps: updateContentReviewStep(data.steps, stepId, step => ({\n ...step,\n totalComments: step.totalComments + 1\n }))\n };\n }\n });\n });\n};\n\nexport const updateLatestCommentId = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.comment.onCommentAfterCreate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is created, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterUpdate.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: comment.id\n };\n }\n });\n });\n\n apw.comment.onCommentAfterDelete.subscribe(async ({ comment }) => {\n /**\n * After a \"comment\" is updated, update the \"latestCommentId\" in\n * the corresponding content review entry.\n */\n const { id } = extractContentReviewIdAndStep(comment.step);\n\n const contentReview = await safelyGetContentReview({\n id,\n contentReviewMethods: apw.contentReview\n });\n\n if (contentReview && contentReview.latestCommentId === comment.id) {\n const [[latestComment]] = await apw.comment.list({\n where: { changeRequest: { id: comment.changeRequest } },\n sort: [\"createdOn_DESC\"]\n });\n\n await updateContentReview({\n contentReviewMethods: apw.contentReview,\n id,\n getNewContentReviewData: contentReview => {\n return {\n ...contentReview,\n latestCommentId: latestComment ? latestComment.id : null\n };\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAOO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EAC3FA,GAAG,CAACC,OAAJ,CAAYC,oBAAZ,CAAiCC,SAAjC,CAA2C,OAAO;IAAEF;EAAF,CAAP,KAAuB;IAC9D,MAAM;MAAEG;IAAF,IAAWH,OAAjB;IACA;AACR;AACA;AACA;;IACQ,IAAIG,IAAJ,EAAU;MACN,MAAM;QAAEC,EAAF;QAAMC;MAAN,IAAiB,IAAAC,oCAAA,EAA8BH,IAA9B,CAAvB;MAEA,MAAM,IAAAI,0BAAA,EAAoB;QACtBC,oBAAoB,EAAET,GAAG,CAACU,aADJ;QAEtBL,EAFsB;QAGtBM,uBAAuB,EAAEC,IAAI,IAAI;UAC7B,mEACOA,IADP;YAEIC,KAAK,EAAE,IAAAC,8BAAA,EAAwBF,IAAI,CAACC,KAA7B,EAAoCP,MAApC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aAAa,CAAChB,EAAjB,GAAsB;UAFxD;QAIH;MARqB,CAApB,CAAN;IAUH;EACJ,CA7BD;AA8BH,CArEM"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -11,10 +11,14 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
|
12
12
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
13
13
|
|
14
|
+
var _utils = require("../utils");
|
15
|
+
|
16
|
+
var _utils2 = require("@webiny/utils");
|
17
|
+
|
14
18
|
const validateChangeRequest = ({
|
15
19
|
apw
|
16
20
|
}) => {
|
17
|
-
apw.changeRequest.
|
21
|
+
apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({
|
18
22
|
input
|
19
23
|
}) => {
|
20
24
|
const {
|
@@ -24,7 +28,14 @@ const validateChangeRequest = ({
|
|
24
28
|
* We need step to be in a particular format i.e. "contentReviewId#version#stepId"
|
25
29
|
*/
|
26
30
|
|
27
|
-
const
|
31
|
+
const {
|
32
|
+
id: revisionId,
|
33
|
+
stepId
|
34
|
+
} = (0, _utils.extractContentReviewIdAndStep)(step);
|
35
|
+
const {
|
36
|
+
id: entryId,
|
37
|
+
version
|
38
|
+
} = (0, _utils2.parseIdentifier)(revisionId);
|
28
39
|
|
29
40
|
if (!entryId || !version || !stepId) {
|
30
41
|
throw new _error.default(`The step property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_STEP", {
|
@@ -36,8 +47,22 @@ const validateChangeRequest = ({
|
|
36
47
|
*/
|
37
48
|
|
38
49
|
|
39
|
-
|
40
|
-
|
50
|
+
let contentReview = undefined;
|
51
|
+
|
52
|
+
try {
|
53
|
+
contentReview = await apw.contentReview.get(revisionId);
|
54
|
+
} catch (ex) {
|
55
|
+
/**
|
56
|
+
* There is no need to output the log if this is the test environment.
|
57
|
+
*/
|
58
|
+
if (process.env.NODE_ENV !== "test") {
|
59
|
+
console.log({
|
60
|
+
message: ex.message,
|
61
|
+
code: ex.data,
|
62
|
+
data: ex.data
|
63
|
+
});
|
64
|
+
}
|
65
|
+
}
|
41
66
|
|
42
67
|
if (!contentReview) {
|
43
68
|
throw new _handlerGraphql.NotFoundError(`Unable to found "ContentReview" with given id "${revisionId}"`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["validateChangeRequest","apw","changeRequest","
|
1
|
+
{"version":3,"names":["validateChangeRequest","apw","changeRequest","onChangeRequestBeforeCreate","subscribe","input","step","id","revisionId","stepId","extractContentReviewIdAndStep","entryId","version","parseIdentifier","WebinyError","contentReview","undefined","get","ex","process","env","NODE_ENV","console","log","message","code","data","NotFoundError","steps","currentStep","find","signOffProvidedOn"],"sources":["validateChangeRequest.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { ApwContentReview, LifeCycleHookCallbackParams } from \"~/types\";\nimport { extractContentReviewIdAndStep } from \"~/plugins/utils\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const validateChangeRequest = ({ apw }: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestBeforeCreate.subscribe(async ({ input }) => {\n const { step } = input;\n /**\n * We need step to be in a particular format i.e. \"contentReviewId#version#stepId\"\n */\n const { id: revisionId, stepId } = extractContentReviewIdAndStep(step);\n\n const { id: entryId, version } = parseIdentifier(revisionId);\n if (!entryId || !version || !stepId) {\n throw new WebinyError(\n `The step property in input is not properly formatted.`,\n \"MALFORMED_CHANGE_REQUEST_STEP\",\n {\n step\n }\n );\n }\n /**\n * Check whether a contentReview entry exists with provided id.\n */\n let contentReview: ApwContentReview | undefined = undefined;\n try {\n contentReview = await apw.contentReview.get(revisionId);\n } catch (ex) {\n /**\n * There is no need to output the log if this is the test environment.\n */\n if (process.env.NODE_ENV !== \"test\") {\n console.log({\n message: ex.message,\n code: ex.data,\n data: ex.data\n });\n }\n }\n if (!contentReview) {\n throw new NotFoundError(\n `Unable to found \"ContentReview\" with given id \"${revisionId}\"`\n );\n }\n /**\n * Don't allow \"change request\" creation once the sign-off has been provided.\n */\n const { steps } = contentReview;\n const currentStep = steps.find(step => step.id === stepId);\n\n if (currentStep && currentStep.signOffProvidedOn) {\n throw new WebinyError(\n `Please retract the sign-off before opening a new change request.`,\n \"SIGN_OFF_PROVIDED\",\n {\n step: currentStep,\n stepId: stepId\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAWD,KAAjB;IACA;AACR;AACA;;IACQ,MAAM;MAAEE,EAAE,EAAEC,UAAN;MAAkBC;IAAlB,IAA6B,IAAAC,oCAAA,EAA8BJ,IAA9B,CAAnC;IAEA,MAAM;MAAEC,EAAE,EAAEI,OAAN;MAAeC;IAAf,IAA2B,IAAAC,uBAAA,EAAgBL,UAAhB,CAAjC;;IACA,IAAI,CAACG,OAAD,IAAY,CAACC,OAAb,IAAwB,CAACH,MAA7B,EAAqC;MACjC,MAAM,IAAIK,cAAJ,CACD,uDADC,EAEF,+BAFE,EAGF;QACIR;MADJ,CAHE,CAAN;IAOH;IACD;AACR;AACA;;;IACQ,IAAIS,aAA2C,GAAGC,SAAlD;;IACA,IAAI;MACAD,aAAa,GAAG,MAAMd,GAAG,CAACc,aAAJ,CAAkBE,GAAlB,CAAsBT,UAAtB,CAAtB;IACH,CAFD,CAEE,OAAOU,EAAP,EAAW;MACT;AACZ;AACA;MACY,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAA7B,EAAqC;QACjCC,OAAO,CAACC,GAAR,CAAY;UACRC,OAAO,EAAEN,EAAE,CAACM,OADJ;UAERC,IAAI,EAAEP,EAAE,CAACQ,IAFD;UAGRA,IAAI,EAAER,EAAE,CAACQ;QAHD,CAAZ;MAKH;IACJ;;IACD,IAAI,CAACX,aAAL,EAAoB;MAChB,MAAM,IAAIY,6BAAJ,CACD,kDAAiDnB,UAAW,GAD3D,CAAN;IAGH;IACD;AACR;AACA;;;IACQ,MAAM;MAAEoB;IAAF,IAAYb,aAAlB;IACA,MAAMc,WAAW,GAAGD,KAAK,CAACE,IAAN,CAAWxB,IAAI,IAAIA,IAAI,CAACC,EAAL,KAAYE,MAA/B,CAApB;;IAEA,IAAIoB,WAAW,IAAIA,WAAW,CAACE,iBAA/B,EAAkD;MAC9C,MAAM,IAAIjB,cAAJ,CACD,kEADC,EAEF,mBAFE,EAGF;QACIR,IAAI,EAAEuB,WADV;QAEIpB,MAAM,EAAEA;MAFZ,CAHE,CAAN;IAQH;EACJ,CAxDD;AAyDH,CA1DM"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -9,10 +9,12 @@ exports.validateComment = void 0;
|
|
9
9
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
11
|
|
12
|
+
var _utils = require("@webiny/utils");
|
13
|
+
|
12
14
|
const validateComment = ({
|
13
15
|
apw
|
14
16
|
}) => {
|
15
|
-
apw.comment.
|
17
|
+
apw.comment.onCommentBeforeCreate.subscribe(async ({
|
16
18
|
input
|
17
19
|
}) => {
|
18
20
|
const {
|
@@ -22,9 +24,17 @@ const validateComment = ({
|
|
22
24
|
* We need changeRequest to be in a particular format i.e. "contentReviewUniqueId#version"
|
23
25
|
*/
|
24
26
|
|
25
|
-
|
27
|
+
let result;
|
28
|
+
|
29
|
+
try {
|
30
|
+
result = (0, _utils.parseIdentifier)(changeRequestId);
|
26
31
|
|
27
|
-
|
32
|
+
if (!result) {
|
33
|
+
throw new _error.default("Could not parse changeRequestId.", "MALFORMED_CHANGE_REQUEST_ID", {
|
34
|
+
changeRequestId
|
35
|
+
});
|
36
|
+
}
|
37
|
+
} catch (ex) {
|
28
38
|
throw new _error.default(`The"changeRequest" property in input is not properly formatted.`, "MALFORMED_CHANGE_REQUEST_ID", {
|
29
39
|
input
|
30
40
|
});
|
@@ -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;AAAF,CAAD,KAAuD;EAClFA,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,CAAkCC,SAAlC,CAA4C,OAAO;IAAEC;EAAF,CAAP,KAAqB;IAC7D,MAAM;MAAEC,aAAa,EAAEC;IAAjB,IAAqCF,KAA3C;IACA;AACR;AACA;;IACQ,IAAIG,MAAJ;;IACA,IAAI;MACAA,MAAM,GAAG,IAAAC,sBAAA,EAAgBF,eAAhB,CAAT;;MACA,IAAI,CAACC,MAAL,EAAa;QACT,MAAM,IAAIE,cAAJ,CACF,kCADE,EAEF,6BAFE,EAGF;UACIH;QADJ,CAHE,CAAN;MAOH;IACJ,CAXD,CAWE,OAAOI,EAAP,EAAW;MACT,MAAM,IAAID,cAAJ,CACD,iEADC,EAEF,6BAFE,EAGF;QACIL;MADJ,CAHE,CAAN;IAOH;IAED;AACR;AACA;;;IACQ,MAAMC,aAAa,GAAG,MAAML,GAAG,CAACK,aAAJ,CAAkBM,GAAlB,CAAsBL,eAAtB,CAA5B;;IACA,IAAI,CAACD,aAAL,EAAoB;MAChB;IACH;;IACDD,KAAK,CAACQ,IAAN,GAAaP,aAAa,CAACO,IAA3B;EACH,CAnCD;AAoCH,CArCM"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -12,7 +12,7 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
12
12
|
const validateContentReview = ({
|
13
13
|
apw
|
14
14
|
}) => {
|
15
|
-
apw.contentReview.
|
15
|
+
apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({
|
16
16
|
input
|
17
17
|
}) => {
|
18
18
|
const {
|
@@ -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;AAAF,CAAD,KAAuD;EACxFA,GAAG,CAACC,aAAJ,CAAkBC,2BAAlB,CAA8CC,SAA9C,CAAwD,OAAO;IAAEC;EAAF,CAAP,KAAqB;IACzE,MAAM;MAAEC;IAAF,IAAcD,KAApB;IACA;AACR;AACA;;IACQ,MAAM;MAAEE;IAAF,IAAsB,MAAMN,GAAG,CAACC,aAAJ,CAAkBM,gBAAlB,CAAmCF,OAAnC,CAAlC;;IACA,IAAIC,eAAJ,EAAqB;MACjB,MAAM,IAAIE,cAAJ,CACD,4DADC,EAEF,sBAFE,EAGF;QACIF,eADJ;QAEID;MAFJ,CAHE,CAAN;IAQH;EACJ,CAhBD;AAiBH,CAlBM"}
|
@@ -15,6 +15,14 @@ var _linkWorkflowToPage = require("./linkWorkflowToPage");
|
|
15
15
|
|
16
16
|
var _PageApwSettingsGetterPlugin = require("./PageApwSettingsGetterPlugin");
|
17
17
|
|
18
|
+
var _commentNotification = require("./notifications/commentNotification");
|
19
|
+
|
20
|
+
var _contentUrl = require("./notifications/contentUrl");
|
21
|
+
|
22
|
+
var _changeRequestNotification = require("./notifications/changeRequestNotification");
|
23
|
+
|
24
|
+
var _contentReviewNotification = require("./notifications/contentReviewNotification");
|
25
|
+
|
18
26
|
const apwPageBuilderHooks = params => {
|
19
27
|
const {
|
20
28
|
pageBuilder,
|
@@ -22,7 +30,7 @@ const apwPageBuilderHooks = params => {
|
|
22
30
|
security,
|
23
31
|
plugins
|
24
32
|
} = params;
|
25
|
-
plugins.register(new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin());
|
33
|
+
plugins.register([new _PageApwSettingsGetterPlugin.PageApwSettingsGetterPlugin(), (0, _commentNotification.createCommentNotification)(), (0, _changeRequestNotification.createChangeRequestNotification)(), (0, _contentUrl.createContentUrlPlugin)(), (0, _contentReviewNotification.createContentReviewNotification)()]);
|
26
34
|
(0, _triggerContentReview.triggerContentReview)({
|
27
35
|
apw,
|
28
36
|
pageBuilder
|
@@ -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":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAEA;;AASO,MAAMA,mBAAmB,GAAIC,MAAD,IAAyC;EACxE,MAAM;IAAEC,WAAF;IAAeC,GAAf;IAAoBC,QAApB;IAA8BC;EAA9B,IAA0CJ,MAAhD;EAEAI,OAAO,CAACC,QAAR,CAAiB,IAAIC,wDAAJ,
|
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,MAAD,IAAyC;EACxE,MAAM;IAAEC,WAAF;IAAeC,GAAf;IAAoBC,QAApB;IAA8BC;EAA9B,IAA0CJ,MAAhD;EAEAI,OAAO,CAACC,QAAR,CAAiB,CACb,IAAIC,wDAAJ,EADa,EAEb,IAAAC,8CAAA,GAFa,EAGb,IAAAC,0DAAA,GAHa,EAIb,IAAAC,kCAAA,GAJa,EAKb,IAAAC,0DAAA,GALa,CAAjB;EAQA,IAAAC,0CAAA,EAAqB;IACjBT,GADiB;IAEjBD;EAFiB,CAArB;EAIA,IAAAW,gDAAA,EAAwB;IACpBV,GADoB;IAEpBD;EAFoB,CAAxB;EAIA,IAAAY,oDAAA,EAA0B;IACtBX,GADsB;IAEtBD,WAFsB;IAGtBE;EAHsB,CAA1B;EAKA,IAAAW,sCAAA,EAAmB;IACfZ,GADe;IAEfD;EAFe,CAAnB;AAIH,CA5BM"}
|
@@ -1,15 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
8
|
exports.linkContentReviewToPage = void 0;
|
9
9
|
|
10
|
-
var
|
11
|
-
|
12
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
13
11
|
|
14
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
15
13
|
|
@@ -22,46 +20,60 @@ const linkContentReviewToPage = params => {
|
|
22
20
|
apw,
|
23
21
|
pageBuilder
|
24
22
|
} = params;
|
25
|
-
apw.contentReview.
|
23
|
+
apw.contentReview.onContentReviewAfterCreate.subscribe(async ({
|
26
24
|
contentReview
|
27
25
|
}) => {
|
28
26
|
const {
|
29
27
|
content
|
30
28
|
} = contentReview;
|
31
29
|
|
32
|
-
if (content.type
|
33
|
-
|
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
|
-
});
|
30
|
+
if (content.type !== _types.ApwContentTypes.PAGE) {
|
31
|
+
return;
|
41
32
|
}
|
33
|
+
|
34
|
+
await (0, _utils.updatePageSettings)({
|
35
|
+
getPage: pageBuilder.getPage,
|
36
|
+
updatePage: pageBuilder.updatePage,
|
37
|
+
uniquePageId: content.id,
|
38
|
+
getNewSettings: settings => {
|
39
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
40
|
+
apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
|
41
|
+
contentReviewId: contentReview.id
|
42
|
+
})
|
43
|
+
});
|
44
|
+
}
|
45
|
+
});
|
42
46
|
});
|
43
|
-
apw.contentReview.
|
47
|
+
apw.contentReview.onContentReviewAfterDelete.subscribe(async ({
|
44
48
|
contentReview
|
45
49
|
}) => {
|
46
50
|
const {
|
47
51
|
content
|
48
52
|
} = contentReview;
|
49
53
|
|
50
|
-
if (content.type
|
51
|
-
|
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
|
-
});
|
54
|
+
if (content.type !== _types.ApwContentTypes.PAGE) {
|
55
|
+
return;
|
59
56
|
}
|
57
|
+
|
58
|
+
await (0, _utils.updatePageSettings)({
|
59
|
+
getPage: pageBuilder.getPage,
|
60
|
+
updatePage: pageBuilder.updatePage,
|
61
|
+
uniquePageId: content.id,
|
62
|
+
getNewSettings: settings => {
|
63
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
64
|
+
apw: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings.apw || {}), {}, {
|
65
|
+
contentReviewId: null
|
66
|
+
})
|
67
|
+
});
|
68
|
+
}
|
69
|
+
});
|
60
70
|
});
|
61
|
-
pageBuilder.
|
71
|
+
pageBuilder.onPageBeforeDelete.subscribe(async ({
|
62
72
|
page
|
63
73
|
}) => {
|
64
|
-
|
74
|
+
var _page$settings, _page$settings$apw;
|
75
|
+
|
76
|
+
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;
|
65
77
|
|
66
78
|
if (!contentReviewId) {
|
67
79
|
return;
|
@@ -71,13 +83,13 @@ const linkContentReviewToPage = params => {
|
|
71
83
|
|
72
84
|
try {
|
73
85
|
contentReview = await apw.contentReview.get(contentReviewId);
|
74
|
-
} catch (
|
86
|
+
} catch (ex) {
|
75
87
|
/**
|
76
88
|
* We're handling the case whereby "contentReviewId" is still linked to page;
|
77
89
|
* even when the contentReview entry has been deleted. In that case, we'll allow page deletion.
|
78
90
|
*/
|
79
|
-
if (
|
80
|
-
throw
|
91
|
+
if (ex.code !== "NOT_FOUND") {
|
92
|
+
throw ex;
|
81
93
|
}
|
82
94
|
}
|
83
95
|
|
@@ -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,MAAD,IAA2C;EAC9E,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAC,GAAG,CAACE,aAAJ,CAAkBC,0BAAlB,CAA6CC,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,IAArC,EAA2C;MACvC;IACH;;IACD,MAAM,IAAAC,yBAAA,EAAmB;MACrBC,OAAO,EAAET,WAAW,CAACS,OADA;MAErBC,UAAU,EAAEV,WAAW,CAACU,UAFH;MAGrBC,YAAY,EAAEP,OAAO,CAACQ,EAHD;MAIrBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QADP;UAEIf,GAAG,8DACKe,QAAQ,CAACf,GAAT,IAAgB,EADrB;YAECgB,eAAe,EAAEd,aAAa,CAACW;UAFhC;QAFP;MAOH;IAZoB,CAAnB,CAAN;EAcH,CApBD;EAsBAb,GAAG,CAACE,aAAJ,CAAkBe,0BAAlB,CAA6Cb,SAA7C,CAAuD,OAAO;IAAEF;EAAF,CAAP,KAA6B;IAChF,MAAM;MAAEG;IAAF,IAAcH,aAApB;;IAEA,IAAIG,OAAO,CAACC,IAAR,KAAiBC,sBAAA,CAAgBC,IAArC,EAA2C;MACvC;IACH;;IACD,MAAM,IAAAC,yBAAA,EAAmB;MACrBC,OAAO,EAAET,WAAW,CAACS,OADA;MAErBC,UAAU,EAAEV,WAAW,CAACU,UAFH;MAGrBC,YAAY,EAAEP,OAAO,CAACQ,EAHD;MAIrBC,cAAc,EAAEC,QAAQ,IAAI;QACxB,mEACOA,QADP;UAEIf,GAAG,8DACKe,QAAQ,CAACf,GAAT,IAAgB,EADrB;YAECgB,eAAe,EAAE;UAFlB;QAFP;MAOH;IAZoB,CAAnB,CAAN;EAcH,CApBD;EAsBAf,WAAW,CAACiB,kBAAZ,CAA+Bd,SAA/B,CAAyC,OAAO;IAAEe;EAAF,CAAP,KAAoB;IAAA;;IACzD,MAAMH,eAAe,qBAAGG,IAAI,CAACJ,QAAR,yEAAG,eAAef,GAAlB,uDAAG,mBAAoBgB,eAA5C;;IACA,IAAI,CAACA,eAAL,EAAsB;MAClB;IACH;;IAED,IAAId,aAAJ;;IACA,IAAI;MACAA,aAAa,GAAG,MAAMF,GAAG,CAACE,aAAJ,CAAkBkB,GAAlB,CAAsBJ,eAAtB,CAAtB;IACH,CAFD,CAEE,OAAOK,EAAP,EAAW;MACT;AACZ;AACA;AACA;MACY,IAAIA,EAAE,CAACC,IAAH,KAAY,WAAhB,EAA6B;QACzB,MAAMD,EAAN;MACH;IACJ;;IAED,IAAInB,aAAJ,EAAmB;MACf,MAAM,IAAIqB,cAAJ,CACD,kGADC,EAEF,4BAFE,EAGF;QACIP,eADJ;QAEIG;MAFJ,CAHE,CAAN;IAQH;EACJ,CA7BD;AA8BH,CA7EM"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
4
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
@@ -11,6 +11,8 @@ var _get = _interopRequireDefault(require("lodash/get"));
|
|
11
11
|
|
12
12
|
var _set = _interopRequireDefault(require("lodash/set"));
|
13
13
|
|
14
|
+
var _types = require("../../types");
|
15
|
+
|
14
16
|
var _utils = require("./utils");
|
15
17
|
|
16
18
|
const linkWorkflowToPage = params => {
|
@@ -18,7 +20,7 @@ const linkWorkflowToPage = params => {
|
|
18
20
|
apw,
|
19
21
|
pageBuilder
|
20
22
|
} = params;
|
21
|
-
pageBuilder.
|
23
|
+
pageBuilder.onPageBeforeCreate.subscribe(async ({
|
22
24
|
page
|
23
25
|
}) => {
|
24
26
|
await (0, _utils.assignWorkflowToPage)({
|
@@ -26,7 +28,7 @@ const linkWorkflowToPage = params => {
|
|
26
28
|
page
|
27
29
|
});
|
28
30
|
});
|
29
|
-
pageBuilder.
|
31
|
+
pageBuilder.onPageBeforeCreateFrom.subscribe(async params => {
|
30
32
|
const {
|
31
33
|
page,
|
32
34
|
original
|
@@ -62,7 +64,7 @@ const linkWorkflowToPage = params => {
|
|
62
64
|
page
|
63
65
|
});
|
64
66
|
});
|
65
|
-
pageBuilder.
|
67
|
+
pageBuilder.onPageBeforeUpdate.subscribe(async params => {
|
66
68
|
const {
|
67
69
|
page,
|
68
70
|
original
|
@@ -98,16 +100,21 @@ const linkWorkflowToPage = params => {
|
|
98
100
|
* Link created workflow to associated pages.
|
99
101
|
*/
|
100
102
|
|
101
|
-
apw.workflow.
|
103
|
+
apw.workflow.onWorkflowAfterCreate.subscribe(async ({
|
102
104
|
workflow
|
103
105
|
}) => {
|
104
106
|
const {
|
105
107
|
scope
|
106
108
|
} = workflow;
|
109
|
+
|
110
|
+
if (workflow.app !== _types.ApwWorkflowApplications.PB) {
|
111
|
+
return;
|
112
|
+
}
|
107
113
|
/**
|
108
114
|
* If the workflow has pages in it's scope, we'll link that workflow for each of those pages.
|
109
115
|
*/
|
110
116
|
|
117
|
+
|
111
118
|
if ((0, _utils.hasPages)(workflow) === false) {
|
112
119
|
return;
|
113
120
|
}
|
@@ -129,13 +136,18 @@ const linkWorkflowToPage = params => {
|
|
129
136
|
* Link updated workflow to associated pages.
|
130
137
|
*/
|
131
138
|
|
132
|
-
apw.workflow.
|
139
|
+
apw.workflow.onWorkflowAfterUpdate.subscribe(async ({
|
133
140
|
workflow,
|
134
141
|
original
|
135
142
|
}) => {
|
136
143
|
const {
|
137
144
|
scope
|
138
145
|
} = workflow;
|
146
|
+
|
147
|
+
if (workflow.app !== _types.ApwWorkflowApplications.PB) {
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
|
139
151
|
const {
|
140
152
|
scope: prevScope
|
141
153
|
} = original;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["linkWorkflowToPage","params","apw","pageBuilder","onBeforePageCreate","subscribe","page","assignWorkflowToPage","listWorkflow","workflow","list","onBeforePageCreateFrom","original","previousContentReviewId","get","settings","contentReviewId","previousWorkflowId","onBeforePageUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","newTitle","contentReview","update","title","onAfterWorkflowCreate","scope","hasPages","pages","pid","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","set","id","onAfterWorkflowUpdate","prevScope","shouldUpdatePages","previousPages","currentPages","removedPages","addedPages","getPagesDiff"],"sources":["linkWorkflowToPage.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport set from \"lodash/set\";\nimport {\n ApwOnBeforePageCreateTopicParams,\n ApwOnBeforePageCreateFromTopicParams,\n ApwOnBeforePageUpdateTopicParams,\n AdvancedPublishingWorkflow\n} from \"~/types\";\nimport {\n getPagesDiff,\n hasPages,\n updatePageSettings,\n shouldUpdatePages,\n assignWorkflowToPage\n} from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkWorkflowToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkWorkflowToPage = (params: LinkWorkflowToPageParams) => {\n const { apw, pageBuilder } = params;\n\n pageBuilder.onBeforePageCreate.subscribe<ApwOnBeforePageCreateTopicParams>(async ({ page }) => {\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n });\n pageBuilder.onBeforePageCreateFrom.subscribe<ApwOnBeforePageCreateFromTopicParams>(\n async params => {\n const { page, original } = params;\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = get(original, \"settings.apw.contentReviewId\");\n if (previousContentReviewId) {\n page.settings.apw.contentReviewId = null;\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = get(original, \"settings.apw.workflowId\");\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n }\n );\n pageBuilder.onBeforePageUpdate.subscribe<ApwOnBeforePageUpdateTopicParams>(async params => {\n const { page, original } = params;\n const prevApwWorkflowId = get(original, \"settings.apw\");\n const currentApwWorkflowId = get(page, \"settings.apw\");\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n page.settings.apw = original.settings.apw;\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = get(page, \"settings.apw.contentReviewId\");\n const prevTitle = get(original, \"title\");\n const newTitle = get(page, \"title\");\n\n if (linkedContentReviewId && prevTitle !== newTitle) {\n await apw.contentReview.update(linkedContentReviewId, { title: newTitle });\n }\n });\n /**\n * Link created workflow to associated pages.\n */\n apw.workflow.onAfterWorkflowCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n /**\n * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.\n */\n if (hasPages(workflow) === false) {\n return;\n }\n const pages = get(scope, \"data.pages\");\n\n for (const pid of pages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n });\n /**\n * Link updated workflow to associated pages.\n */\n apw.workflow.onAfterWorkflowUpdate.subscribe(async ({ workflow, original }) => {\n const { scope } = workflow;\n const { scope: prevScope } = original;\n /**\n * If the workflow has pages in it's scope and there is a change in that page list,\n * we'll update the workflow link for corresponding pages.\n */\n if (hasPages(workflow) === false || shouldUpdatePages(scope, prevScope) === false) {\n return;\n }\n\n const previousPages = get(prevScope, \"data.pages\", []);\n const currentPages = get(scope, \"data.pages\", []);\n\n const { removedPages, addedPages } = getPagesDiff(currentPages, previousPages);\n for (const pid of addedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n for (const pid of removedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", null);\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAOA;;AAcO,MAAMA,kBAAkB,GAAIC,MAAD,IAAsC;EACpE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAE,WAAW,CAACC,kBAAZ,CAA+BC,SAA/B,CAA2E,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAC3F,MAAM,IAAAC,2BAAA,EAAqB;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAJ,CAAaC,IAA7B;MAAmCJ;IAAnC,CAArB,CAAN;EACH,CAFD;EAGA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,IAAgC,IAAAgC,wBAAA,EAAkBb,KAAlB,EAAyBY,SAAzB,MAAwC,KAA5E,EAAmF;MAC/E;IACH;;IAED,MAAME,aAAa,GAAG,IAAA5B,YAAA,EAAI0B,SAAJ,EAAe,YAAf,EAA6B,EAA7B,CAAtB;IACA,MAAMG,YAAY,GAAG,IAAA7B,YAAA,EAAIc,KAAJ,EAAW,YAAX,EAAyB,EAAzB,CAArB;IAEA,MAAM;MAAEgB,YAAF;MAAgBC;IAAhB,IAA+B,IAAAC,mBAAA,EAAaH,YAAb,EAA2BD,aAA3B,CAArC;;IACA,KAAK,MAAMX,GAAX,IAAkBc,UAAlB,EAA8B;MAC1B,MAAM,IAAAb,yBAAA,EAAmB;QACrBC,OAAO,EAAE9B,WAAW,CAAC8B,OADA;QAErBC,UAAU,EAAE/B,WAAW,CAAC+B,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAErB,QAAQ,IAAI;UACxB,OAAO,IAAAsB,YAAA,EAAItB,QAAJ,EAAc,gBAAd,EAAgCN,QAAQ,CAAC6B,EAAzC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;;IACD,KAAK,MAAMP,GAAX,IAAkBa,YAAlB,EAAgC;MAC5B,MAAM,IAAAZ,yBAAA,EAAmB;QACrBC,OAAO,EAAE9B,WAAW,CAAC8B,OADA;QAErBC,UAAU,EAAE/B,WAAW,CAAC+B,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAErB,QAAQ,IAAI;UACxB,OAAO,IAAAsB,YAAA,EAAItB,QAAJ,EAAc,gBAAd,EAAgC,IAAhC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;EACJ,CAnCD;AAoCH,CAvHM"}
|
1
|
+
{"version":3,"names":["linkWorkflowToPage","params","apw","pageBuilder","onPageBeforeCreate","subscribe","page","assignWorkflowToPage","listWorkflow","workflow","list","onPageBeforeCreateFrom","original","previousContentReviewId","get","settings","contentReviewId","previousWorkflowId","onPageBeforeUpdate","prevApwWorkflowId","currentApwWorkflowId","linkedContentReviewId","prevTitle","newTitle","contentReview","update","title","onWorkflowAfterCreate","scope","app","ApwWorkflowApplications","PB","hasPages","pages","pid","updatePageSettings","getPage","updatePage","uniquePageId","getNewSettings","set","id","onWorkflowAfterUpdate","prevScope","shouldUpdatePages","previousPages","currentPages","removedPages","addedPages","getPagesDiff"],"sources":["linkWorkflowToPage.ts"],"sourcesContent":["import get from \"lodash/get\";\nimport set from \"lodash/set\";\nimport {\n ApwWorkflowApplications,\n ApwOnPageBeforeCreateTopicParams,\n ApwOnPageBeforeCreateFromTopicParams,\n ApwOnPageBeforeUpdateTopicParams,\n AdvancedPublishingWorkflow\n} from \"~/types\";\nimport {\n getPagesDiff,\n hasPages,\n updatePageSettings,\n shouldUpdatePages,\n assignWorkflowToPage\n} from \"./utils\";\nimport { PageBuilderContextObject } from \"@webiny/api-page-builder/graphql/types\";\n\ninterface LinkWorkflowToPageParams {\n apw: AdvancedPublishingWorkflow;\n pageBuilder: PageBuilderContextObject;\n}\n\nexport const linkWorkflowToPage = (params: LinkWorkflowToPageParams) => {\n const { apw, pageBuilder } = params;\n\n pageBuilder.onPageBeforeCreate.subscribe<ApwOnPageBeforeCreateTopicParams>(async ({ page }) => {\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n });\n pageBuilder.onPageBeforeCreateFrom.subscribe<ApwOnPageBeforeCreateFromTopicParams>(\n async params => {\n const { page, original } = params;\n /**\n * If the previous revision(original) already had the \"contentReviewId\",\n * we need to unlink it so that new \"contentReview\" can be request for the new revision.\n */\n const previousContentReviewId = get(original, \"settings.apw.contentReviewId\");\n if (previousContentReviewId) {\n page.settings.apw.contentReviewId = null;\n }\n\n /**\n * If the previous revision(original) already had the \"workflowId\",\n * we don't need to do anything we'll just let it be copied over.\n */\n const previousWorkflowId = get(original, \"settings.apw.workflowId\");\n if (previousWorkflowId) {\n return;\n }\n /**\n * Lookup and assign \"workflowId\".\n */\n await assignWorkflowToPage({ listWorkflow: apw.workflow.list, page });\n }\n );\n pageBuilder.onPageBeforeUpdate.subscribe<ApwOnPageBeforeUpdateTopicParams>(async params => {\n const { page, original } = params;\n const prevApwWorkflowId = get(original, \"settings.apw\");\n const currentApwWorkflowId = get(page, \"settings.apw\");\n /**\n * Make sure the apw property doesn't get lost between updates.\n * It can happen because we run modal validation in \"onBeforePageUpdate\" event,\n * which doesn't have the \"apw\" property.\n */\n if (prevApwWorkflowId && !currentApwWorkflowId) {\n page.settings.apw = original.settings.apw;\n }\n /*\n * If there is a linked \"contentReview\" for this page and the page \"title\" has changed.\n * Let's update the \"title\" field in \"contentReview\".\n */\n const linkedContentReviewId = get(page, \"settings.apw.contentReviewId\");\n const prevTitle = get(original, \"title\");\n const newTitle = get(page, \"title\");\n\n if (linkedContentReviewId && prevTitle !== newTitle) {\n await apw.contentReview.update(linkedContentReviewId, { title: newTitle });\n }\n });\n /**\n * Link created workflow to associated pages.\n */\n apw.workflow.onWorkflowAfterCreate.subscribe(async ({ workflow }) => {\n const { scope } = workflow;\n if (workflow.app !== ApwWorkflowApplications.PB) {\n return;\n }\n /**\n * If the workflow has pages in it's scope, we'll link that workflow for each of those pages.\n */\n if (hasPages(workflow) === false) {\n return;\n }\n const pages = get(scope, \"data.pages\") as unknown as string[];\n\n for (const pid of pages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n });\n /**\n * Link updated workflow to associated pages.\n */\n apw.workflow.onWorkflowAfterUpdate.subscribe(async ({ workflow, original }) => {\n const { scope } = workflow;\n if (workflow.app !== ApwWorkflowApplications.PB) {\n return;\n }\n const { scope: prevScope } = original;\n /**\n * If the workflow has pages in it's scope and there is a change in that page list,\n * we'll update the workflow link for corresponding pages.\n */\n if (hasPages(workflow) === false || shouldUpdatePages(scope, prevScope) === false) {\n return;\n }\n\n const previousPages = get(prevScope, \"data.pages\", []);\n const currentPages = get(scope, \"data.pages\", []);\n\n const { removedPages, addedPages } = getPagesDiff(currentPages, previousPages);\n for (const pid of addedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", workflow.id);\n }\n });\n }\n for (const pid of removedPages) {\n await updatePageSettings({\n getPage: pageBuilder.getPage,\n updatePage: pageBuilder.updatePage,\n uniquePageId: pid,\n getNewSettings: settings => {\n return set(settings, \"apw.workflowId\", null);\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAOA;;AAcO,MAAMA,kBAAkB,GAAIC,MAAD,IAAsC;EACpE,MAAM;IAAEC,GAAF;IAAOC;EAAP,IAAuBF,MAA7B;EAEAE,WAAW,CAACC,kBAAZ,CAA+BC,SAA/B,CAA2E,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAC3F,MAAM,IAAAC,2BAAA,EAAqB;MAAEC,YAAY,EAAEN,GAAG,CAACO,QAAJ,CAAaC,IAA7B;MAAmCJ;IAAnC,CAArB,CAAN;EACH,CAFD;EAGAH,WAAW,CAACQ,sBAAZ,CAAmCN,SAAnC,CACI,MAAMJ,MAAN,IAAgB;IACZ,MAAM;MAAEK,IAAF;MAAQM;IAAR,IAAqBX,MAA3B;IACA;AACZ;AACA;AACA;;IACY,MAAMY,uBAAuB,GAAG,IAAAC,YAAA,EAAIF,QAAJ,EAAc,8BAAd,CAAhC;;IACA,IAAIC,uBAAJ,EAA6B;MACzBP,IAAI,CAACS,QAAL,CAAcb,GAAd,CAAkBc,eAAlB,GAAoC,IAApC;IACH;IAED;AACZ;AACA;AACA;;;IACY,MAAMC,kBAAkB,GAAG,IAAAH,YAAA,EAAIF,QAAJ,EAAc,yBAAd,CAA3B;;IACA,IAAIK,kBAAJ,EAAwB;MACpB;IACH;IACD;AACZ;AACA;;;IACY,MAAM,IAAAV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AAA,EAAaH,YAAb,EAA2BD,aAA3B,CAArC;;IACA,KAAK,MAAMX,GAAX,IAAkBc,UAAlB,EAA8B;MAC1B,MAAM,IAAAb,yBAAA,EAAmB;QACrBC,OAAO,EAAEjC,WAAW,CAACiC,OADA;QAErBC,UAAU,EAAElC,WAAW,CAACkC,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAExB,QAAQ,IAAI;UACxB,OAAO,IAAAyB,YAAA,EAAIzB,QAAJ,EAAc,gBAAd,EAAgCN,QAAQ,CAACgC,EAAzC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;;IACD,KAAK,MAAMP,GAAX,IAAkBa,YAAlB,EAAgC;MAC5B,MAAM,IAAAZ,yBAAA,EAAmB;QACrBC,OAAO,EAAEjC,WAAW,CAACiC,OADA;QAErBC,UAAU,EAAElC,WAAW,CAACkC,UAFH;QAGrBC,YAAY,EAAEJ,GAHO;QAIrBK,cAAc,EAAExB,QAAQ,IAAI;UACxB,OAAO,IAAAyB,YAAA,EAAIzB,QAAJ,EAAc,gBAAd,EAAgC,IAAhC,CAAP;QACH;MANoB,CAAnB,CAAN;IAQH;EACJ,CAtCD;AAuCH,CA7HM"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const createChangeRequestNotification: () => import("../../../ApwChangeRequestNotification").ApwChangeRequestNotification;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createChangeRequestNotification = void 0;
|
7
|
+
|
8
|
+
var _types = require("../../../types");
|
9
|
+
|
10
|
+
var _ApwChangeRequestNotification = require("../../../ApwChangeRequestNotification");
|
11
|
+
|
12
|
+
const createChangeRequestNotification = () => {
|
13
|
+
const plugin = (0, _ApwChangeRequestNotification.createApwChangeRequestNotification)(_types.ApwContentTypes.PAGE, params => {
|
14
|
+
const {
|
15
|
+
changeRequestUrl,
|
16
|
+
contentUrl
|
17
|
+
} = params;
|
18
|
+
return {
|
19
|
+
text: `
|
20
|
+
Hi,<br /><br />
|
21
|
+
|
22
|
+
You have received a <a href="${changeRequestUrl}">change request</a>, for <a href="${contentUrl}">this</a> page.<br /><br />
|
23
|
+
|
24
|
+
Here are the full URLs:<br /><br />
|
25
|
+
|
26
|
+
Change Request: ${changeRequestUrl}<br />
|
27
|
+
Page: ${contentUrl}
|
28
|
+
`
|
29
|
+
};
|
30
|
+
});
|
31
|
+
plugin.name = `${plugin.type}.${_types.ApwContentTypes.PAGE}.default`;
|
32
|
+
return plugin;
|
33
|
+
};
|
34
|
+
|
35
|
+
exports.createChangeRequestNotification = createChangeRequestNotification;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createChangeRequestNotification","plugin","createApwChangeRequestNotification","ApwContentTypes","PAGE","params","changeRequestUrl","contentUrl","text","name","type"],"sources":["changeRequestNotification.ts"],"sourcesContent":["import { ApwContentTypes } from \"~/types\";\nimport { createApwChangeRequestNotification } from \"~/ApwChangeRequestNotification\";\n\nexport const createChangeRequestNotification = () => {\n const plugin = createApwChangeRequestNotification(ApwContentTypes.PAGE, params => {\n const { changeRequestUrl, contentUrl } = params;\n return {\n text: `\n Hi,<br /><br />\n \n You have received a <a href=\"${changeRequestUrl}\">change request</a>, for <a href=\"${contentUrl}\">this</a> page.<br /><br />\n \n Here are the full URLs:<br /><br />\n \n Change Request: ${changeRequestUrl}<br />\n Page: ${contentUrl}\n `\n };\n });\n\n plugin.name = `${plugin.type}.${ApwContentTypes.PAGE}.default`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,+BAA+B,GAAG,MAAM;EACjD,MAAMC,MAAM,GAAG,IAAAC,gEAAA,EAAmCC,sBAAA,CAAgBC,IAAnD,EAAyDC,MAAM,IAAI;IAC9E,MAAM;MAAEC,gBAAF;MAAoBC;IAApB,IAAmCF,MAAzC;IACA,OAAO;MACHG,IAAI,EAAG;AACnB;AACA;AACA,+CAA+CF,gBAAiB,sCAAqCC,UAAW;AAChH;AACA;AACA;AACA,kCAAkCD,gBAAiB;AACnD,wBAAwBC,UAAW;AACnC;IAVe,CAAP;EAYH,CAdc,CAAf;EAgBAN,MAAM,CAACQ,IAAP,GAAe,GAAER,MAAM,CAACS,IAAK,IAAGP,sBAAA,CAAgBC,IAAK,UAArD;EAEA,OAAOH,MAAP;AACH,CApBM"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const createCommentNotification: () => import("../../../ApwCommentNotification").ApwCommentNotification;
|