@webiny/api-apw 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7f63ea0744
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.js +0 -10
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.js +0 -10
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.js +0 -10
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.js +0 -10
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.js +0 -5
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/crud/createChangeRequestMethods.js +4 -11
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.js +4 -12
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.js +20 -84
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.js +4 -12
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.js +4 -17
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.js +0 -25
- package/crud/index.js.map +1 -1
- package/crud/utils.js +0 -28
- package/crud/utils.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +1 -15
- package/index.js.map +1 -1
- package/package.json +34 -34
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.js +0 -8
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.js +0 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.js +0 -17
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.js +2 -31
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +0 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +0 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +0 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +1 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.js +0 -14
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.js +0 -18
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.js +2 -47
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +0 -1
- package/plugins/context.js +2 -47
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.js +1 -8
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +1 -8
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +1 -20
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +1 -8
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +1 -8
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +2 -17
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +2 -11
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.js +0 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +2 -15
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.js +0 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.js +0 -12
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.js +0 -4
- package/plugins/hooks/notifications/appUrl.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +0 -28
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +0 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +0 -30
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +0 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +1 -24
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +0 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.js +0 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +0 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.js +0 -7
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +0 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +0 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +0 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +0 -8
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.js +0 -9
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.js +0 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.js +1 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.js +0 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
- package/plugins/pageBuilder/index.js +0 -11
- package/plugins/pageBuilder/index.js.map +1 -1
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -16
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
- package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -4
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -4
- package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -4
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +1 -7
- package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
- package/plugins/pageBuilder/triggerContentReview.js +0 -11
- package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
- package/plugins/pageBuilder/utils.js +1 -35
- package/plugins/pageBuilder/utils.js.map +1 -1
- package/plugins/utils.js +0 -43
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.js +1 -20
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +1 -1
- package/scheduler/handlers/executeAction/index.js +9 -33
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -5
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +0 -21
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -27
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +0 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
- package/scheduler/handlers/scheduleAction/index.js +5 -25
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -23
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +1 -1
- package/scheduler/handlers/utils.js +3 -40
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.js +0 -6
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +0 -19
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +0 -21
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +0 -17
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.js +0 -14
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.js +0 -9
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.js +0 -8
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentModelPluginFactory.js +0 -5
- package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
- package/storageOperations/models/contentReview.model.js +0 -26
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.js +2 -24
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.js +0 -8
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.js +0 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.js +0 -23
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.js +0 -17
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +3 -20
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.js +0 -14
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.js +0 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +0 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.js +2 -12
- package/utils/fieldResolver.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +0 -3
- package/utils/resolve.js.map +1 -1
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createReviewerFromIdentity = void 0;
|
7
|
-
|
8
7
|
const createReviewerFromIdentity = ({
|
9
8
|
security,
|
10
9
|
apw
|
@@ -16,7 +15,6 @@ const createReviewerFromIdentity = ({
|
|
16
15
|
identity
|
17
16
|
}) => {
|
18
17
|
let reviewer;
|
19
|
-
|
20
18
|
try {
|
21
19
|
[[reviewer]] = await apw.reviewer.list({
|
22
20
|
where: {
|
@@ -25,17 +23,16 @@ const createReviewerFromIdentity = ({
|
|
25
23
|
limit: 1
|
26
24
|
});
|
27
25
|
} catch (e) {
|
28
|
-
if (e.message === "index_not_found_exception") {
|
26
|
+
if (e.message === "index_not_found_exception") {
|
27
|
+
// Do nothing
|
29
28
|
} else {
|
30
29
|
throw e;
|
31
30
|
}
|
32
31
|
}
|
33
|
-
|
34
32
|
const email = identity.email || null;
|
35
33
|
/**
|
36
34
|
* Create a reviewer if it doesn't exist already.
|
37
35
|
*/
|
38
|
-
|
39
36
|
if (!reviewer) {
|
40
37
|
try {
|
41
38
|
await apw.reviewer.create({
|
@@ -49,21 +46,16 @@ const createReviewerFromIdentity = ({
|
|
49
46
|
console.log(JSON.stringify(ex));
|
50
47
|
throw ex;
|
51
48
|
}
|
52
|
-
|
53
49
|
return;
|
54
50
|
}
|
55
51
|
/**
|
56
52
|
* If "displayName" doesn't match it means it has been updated in the identity,
|
57
53
|
* therefore, we need to update it on reviewer as well keep them in sync.
|
58
54
|
*/
|
59
|
-
|
60
|
-
|
61
55
|
const update = reviewer.displayName !== identity.displayName || reviewer.email !== email;
|
62
|
-
|
63
56
|
if (!update) {
|
64
57
|
return;
|
65
58
|
}
|
66
|
-
|
67
59
|
try {
|
68
60
|
await apw.reviewer.update(reviewer.id, {
|
69
61
|
identityId: reviewer.identityId,
|
@@ -78,5 +70,4 @@ const createReviewerFromIdentity = ({
|
|
78
70
|
}
|
79
71
|
});
|
80
72
|
};
|
81
|
-
|
82
73
|
exports.createReviewerFromIdentity = createReviewerFromIdentity;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createReviewerFromIdentity","security","apw","onAfterLogin","subscribe","identity","reviewer","list","where","identityId","id","limit","e","message","email","create","displayName","type","ex","console","log","JSON","stringify","update"],"sources":["createReviewerFromIdentity.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const createReviewerFromIdentity = ({ security, apw }: LifeCycleHookCallbackParams) => {\n /**\n * Replicate identity in \"AdvancedPublishingWorkflow\" system after login.\n */\n security.onAfterLogin.subscribe(async ({ identity }) => {\n let reviewer;\n try {\n [[reviewer]] = await apw.reviewer.list({\n where: { identityId: identity.id },\n limit: 1\n });\n } catch (e) {\n if (e.message === \"index_not_found_exception\") {\n // Do nothing\n } else {\n throw e;\n }\n }\n const email = (identity as any).email || null;\n /**\n * Create a reviewer if it doesn't exist already.\n */\n if (!reviewer) {\n try {\n await apw.reviewer.create({\n identityId: identity.id,\n displayName: identity.displayName,\n type: identity.type,\n email\n });\n } catch (ex) {\n console.log(\n `There was an error while creating reviewer with identity: ${identity.id}`\n );\n console.log(JSON.stringify(ex));\n throw ex;\n }\n return;\n }\n /**\n * If \"displayName\" doesn't match it means it has been updated in the identity,\n * therefore, we need to update it on reviewer as well keep them in sync.\n */\n const update = reviewer.displayName !== identity.displayName || reviewer.email !== email;\n if (!update) {\n return;\n }\n try {\n await apw.reviewer.update(reviewer.id, {\n identityId: reviewer.identityId,\n type: reviewer.type,\n displayName: identity.displayName,\n email\n });\n } catch (ex) {\n console.log(`There was an error while updating reviewer: ${reviewer.id}`);\n console.log(JSON.stringify(ex));\n throw ex;\n }\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["createReviewerFromIdentity","security","apw","onAfterLogin","subscribe","identity","reviewer","list","where","identityId","id","limit","e","message","email","create","displayName","type","ex","console","log","JSON","stringify","update"],"sources":["createReviewerFromIdentity.ts"],"sourcesContent":["import { LifeCycleHookCallbackParams } from \"~/types\";\n\nexport const createReviewerFromIdentity = ({ security, apw }: LifeCycleHookCallbackParams) => {\n /**\n * Replicate identity in \"AdvancedPublishingWorkflow\" system after login.\n */\n security.onAfterLogin.subscribe(async ({ identity }) => {\n let reviewer;\n try {\n [[reviewer]] = await apw.reviewer.list({\n where: { identityId: identity.id },\n limit: 1\n });\n } catch (e) {\n if (e.message === \"index_not_found_exception\") {\n // Do nothing\n } else {\n throw e;\n }\n }\n const email = (identity as any).email || null;\n /**\n * Create a reviewer if it doesn't exist already.\n */\n if (!reviewer) {\n try {\n await apw.reviewer.create({\n identityId: identity.id,\n displayName: identity.displayName,\n type: identity.type,\n email\n });\n } catch (ex) {\n console.log(\n `There was an error while creating reviewer with identity: ${identity.id}`\n );\n console.log(JSON.stringify(ex));\n throw ex;\n }\n return;\n }\n /**\n * If \"displayName\" doesn't match it means it has been updated in the identity,\n * therefore, we need to update it on reviewer as well keep them in sync.\n */\n const update = reviewer.displayName !== identity.displayName || reviewer.email !== email;\n if (!update) {\n return;\n }\n try {\n await apw.reviewer.update(reviewer.id, {\n identityId: reviewer.identityId,\n type: reviewer.type,\n displayName: identity.displayName,\n email\n });\n } catch (ex) {\n console.log(`There was an error while updating reviewer: ${reviewer.id}`);\n console.log(JSON.stringify(ex));\n throw ex;\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,0BAA0B,GAAG,CAAC;EAAEC,QAAQ;EAAEC;AAAiC,CAAC,KAAK;EAC1F;AACJ;AACA;EACID,QAAQ,CAACE,YAAY,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAS,CAAC,KAAK;IACpD,IAAIC,QAAQ;IACZ,IAAI;MACA,CAAC,CAACA,QAAQ,CAAC,CAAC,GAAG,MAAMJ,GAAG,CAACI,QAAQ,CAACC,IAAI,CAAC;QACnCC,KAAK,EAAE;UAAEC,UAAU,EAAEJ,QAAQ,CAACK;QAAG,CAAC;QAClCC,KAAK,EAAE;MACX,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,CAAC,EAAE;MACR,IAAIA,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;QAC3C;MAAA,CACH,MAAM;QACH,MAAMD,CAAC;MACX;IACJ;IACA,MAAME,KAAK,GAAIT,QAAQ,CAASS,KAAK,IAAI,IAAI;IAC7C;AACR;AACA;IACQ,IAAI,CAACR,QAAQ,EAAE;MACX,IAAI;QACA,MAAMJ,GAAG,CAACI,QAAQ,CAACS,MAAM,CAAC;UACtBN,UAAU,EAAEJ,QAAQ,CAACK,EAAE;UACvBM,WAAW,EAAEX,QAAQ,CAACW,WAAW;UACjCC,IAAI,EAAEZ,QAAQ,CAACY,IAAI;UACnBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,GAAG,CACN,6DAA4Df,QAAQ,CAACK,EAAG,EAAC,CAC7E;QACDS,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,EAAE,CAAC,CAAC;QAC/B,MAAMA,EAAE;MACZ;MACA;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMK,MAAM,GAAGjB,QAAQ,CAACU,WAAW,KAAKX,QAAQ,CAACW,WAAW,IAAIV,QAAQ,CAACQ,KAAK,KAAKA,KAAK;IACxF,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IACA,IAAI;MACA,MAAMrB,GAAG,CAACI,QAAQ,CAACiB,MAAM,CAACjB,QAAQ,CAACI,EAAE,EAAE;QACnCD,UAAU,EAAEH,QAAQ,CAACG,UAAU;QAC/BQ,IAAI,EAAEX,QAAQ,CAACW,IAAI;QACnBD,WAAW,EAAEX,QAAQ,CAACW,WAAW;QACjCF;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAE,+CAA8Cd,QAAQ,CAACI,EAAG,EAAC,CAAC;MACzES,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACJ,EAAE,CAAC,CAAC;MAC/B,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.deleteChangeRequestsWithContentReview = void 0;
|
7
|
-
|
8
7
|
const deleteChangeRequestsWithContentReview = ({
|
9
8
|
apw
|
10
9
|
}) => {
|
@@ -18,7 +17,6 @@ const deleteChangeRequestsWithContentReview = ({
|
|
18
17
|
/**
|
19
18
|
* For each step get associated change requests and delete them.
|
20
19
|
*/
|
21
|
-
|
22
20
|
for (let i = 0; i < steps.length; i++) {
|
23
21
|
const {
|
24
22
|
id: stepId
|
@@ -29,13 +27,11 @@ const deleteChangeRequestsWithContentReview = ({
|
|
29
27
|
/**
|
30
28
|
* Paginate through change requests.
|
31
29
|
*/
|
32
|
-
|
33
30
|
while (meta.totalCount > 0) {
|
34
31
|
let changeRequests = [];
|
35
32
|
/**
|
36
33
|
* Get all change requests.
|
37
34
|
*/
|
38
|
-
|
39
35
|
try {
|
40
36
|
[changeRequests, meta] = await apw.changeRequest.list({
|
41
37
|
where: {
|
@@ -44,18 +40,15 @@ const deleteChangeRequestsWithContentReview = ({
|
|
44
40
|
});
|
45
41
|
} catch (e) {
|
46
42
|
meta.totalCount = 0;
|
47
|
-
|
48
43
|
if (e.message !== "index_not_found_exception") {
|
49
44
|
throw e;
|
50
45
|
}
|
51
|
-
|
52
46
|
console.log(e);
|
53
47
|
}
|
48
|
+
|
54
49
|
/**
|
55
50
|
* Delete change requests one by one.
|
56
51
|
*/
|
57
|
-
|
58
|
-
|
59
52
|
for (const changeRequest of changeRequests) {
|
60
53
|
await apw.changeRequest.delete(changeRequest.id);
|
61
54
|
}
|
@@ -63,5 +56,4 @@ const deleteChangeRequestsWithContentReview = ({
|
|
63
56
|
}
|
64
57
|
});
|
65
58
|
};
|
66
|
-
|
67
59
|
exports.deleteChangeRequestsWithContentReview = deleteChangeRequestsWithContentReview;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["deleteChangeRequestsWithContentReview","apw","contentReview","onContentReviewAfterDelete","subscribe","steps","i","length","id","stepId","meta","totalCount","changeRequests","changeRequest","list","where","step","e","message","console","log","delete"],"sources":["deleteChangeRequestsAfterContentReview.ts"],"sourcesContent":["import { ApwChangeRequest, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteChangeRequestsWithContentReview = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n /**\n * Also delete all associated \"changeRequest\" when a \"contentReview\" is deleted.\n */\n const steps = contentReview.steps;\n /**\n * For each step get associated change requests and delete them.\n */\n for (let i = 0; i < steps.length; i++) {\n const { id: stepId } = steps[i];\n\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through change requests.\n */\n while (meta.totalCount > 0) {\n let changeRequests: ApwChangeRequest[] = [];\n /**\n * Get all change requests.\n */\n try {\n [changeRequests, meta] = await apw.changeRequest.list({\n where: {\n step: `${contentReview.id}#${stepId}`\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete change requests one by one.\n */\n for (const changeRequest of changeRequests) {\n await apw.changeRequest.delete(changeRequest.id);\n }\n }\n }\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["deleteChangeRequestsWithContentReview","apw","contentReview","onContentReviewAfterDelete","subscribe","steps","i","length","id","stepId","meta","totalCount","changeRequests","changeRequest","list","where","step","e","message","console","log","delete"],"sources":["deleteChangeRequestsAfterContentReview.ts"],"sourcesContent":["import { ApwChangeRequest, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteChangeRequestsWithContentReview = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.contentReview.onContentReviewAfterDelete.subscribe(async ({ contentReview }) => {\n /**\n * Also delete all associated \"changeRequest\" when a \"contentReview\" is deleted.\n */\n const steps = contentReview.steps;\n /**\n * For each step get associated change requests and delete them.\n */\n for (let i = 0; i < steps.length; i++) {\n const { id: stepId } = steps[i];\n\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through change requests.\n */\n while (meta.totalCount > 0) {\n let changeRequests: ApwChangeRequest[] = [];\n /**\n * Get all change requests.\n */\n try {\n [changeRequests, meta] = await apw.changeRequest.list({\n where: {\n step: `${contentReview.id}#${stepId}`\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete change requests one by one.\n */\n for (const changeRequest of changeRequests) {\n await apw.changeRequest.delete(changeRequest.id);\n }\n }\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,qCAAqC,GAAG,CAAC;EAClDC;AACsC,CAAC,KAAK;EAC5CA,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF;AACR;AACA;IACQ,MAAMG,KAAK,GAAGH,aAAa,CAACG,KAAK;IACjC;AACR;AACA;IACQ,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;MACnC,MAAM;QAAEE,EAAE,EAAEC;MAAO,CAAC,GAAGJ,KAAK,CAACC,CAAC,CAAC;MAE/B,IAAII,IAAkC,GAAG;QACrCC,UAAU,EAAE;MAChB,CAAC;MACD;AACZ;AACA;MACY,OAAOD,IAAI,CAACC,UAAU,GAAG,CAAC,EAAE;QACxB,IAAIC,cAAkC,GAAG,EAAE;QAC3C;AAChB;AACA;QACgB,IAAI;UACA,CAACA,cAAc,EAAEF,IAAI,CAAC,GAAG,MAAMT,GAAG,CAACY,aAAa,CAACC,IAAI,CAAC;YAClDC,KAAK,EAAE;cACHC,IAAI,EAAG,GAAEd,aAAa,CAACM,EAAG,IAAGC,MAAO;YACxC;UACJ,CAAC,CAAC;QACN,CAAC,CAAC,OAAOQ,CAAC,EAAE;UACRP,IAAI,CAACC,UAAU,GAAG,CAAC;UACnB,IAAIM,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;YAC3C,MAAMD,CAAC;UACX;UACAE,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC;QAClB;;QAEA;AAChB;AACA;QACgB,KAAK,MAAMJ,aAAa,IAAID,cAAc,EAAE;UACxC,MAAMX,GAAG,CAACY,aAAa,CAACQ,MAAM,CAACR,aAAa,CAACL,EAAE,CAAC;QACpD;MACJ;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.deleteCommentsAfterChangeRequest = void 0;
|
7
|
-
|
8
7
|
const deleteCommentsAfterChangeRequest = ({
|
9
8
|
apw
|
10
9
|
}) => {
|
@@ -20,13 +19,11 @@ const deleteCommentsAfterChangeRequest = ({
|
|
20
19
|
/**
|
21
20
|
* Paginate through comments.
|
22
21
|
*/
|
23
|
-
|
24
22
|
while (meta.totalCount > 0) {
|
25
23
|
let comments = [];
|
26
24
|
/**
|
27
25
|
* Get all comments.
|
28
26
|
*/
|
29
|
-
|
30
27
|
try {
|
31
28
|
[comments, meta] = await apw.comment.list({
|
32
29
|
where: {
|
@@ -37,23 +34,19 @@ const deleteCommentsAfterChangeRequest = ({
|
|
37
34
|
});
|
38
35
|
} catch (e) {
|
39
36
|
meta.totalCount = 0;
|
40
|
-
|
41
37
|
if (e.message !== "index_not_found_exception") {
|
42
38
|
throw e;
|
43
39
|
}
|
44
|
-
|
45
40
|
console.log(e);
|
46
41
|
}
|
42
|
+
|
47
43
|
/**
|
48
44
|
* Delete comments one by one.
|
49
45
|
*/
|
50
|
-
|
51
|
-
|
52
46
|
for (const comment of comments) {
|
53
47
|
await apw.comment.delete(comment.id);
|
54
48
|
}
|
55
49
|
}
|
56
50
|
});
|
57
51
|
};
|
58
|
-
|
59
52
|
exports.deleteCommentsAfterChangeRequest = deleteCommentsAfterChangeRequest;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["deleteCommentsAfterChangeRequest","apw","changeRequest","onChangeRequestAfterDelete","subscribe","meta","totalCount","comments","comment","list","where","id","e","message","console","log","delete"],"sources":["deleteCommentsAfterChangeRequest.ts"],"sourcesContent":["import { ApwComment, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteCommentsAfterChangeRequest = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * Also delete all associated comments with \"changeRequest\".\n */\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through comments.\n */\n while (meta.totalCount > 0) {\n let comments: ApwComment[] = [];\n /**\n * Get all comments.\n */\n try {\n [comments, meta] = await apw.comment.list({\n where: {\n changeRequest: {\n id: changeRequest.id\n }\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete comments one by one.\n */\n for (const comment of comments) {\n await apw.comment.delete(comment.id);\n }\n }\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["deleteCommentsAfterChangeRequest","apw","changeRequest","onChangeRequestAfterDelete","subscribe","meta","totalCount","comments","comment","list","where","id","e","message","console","log","delete"],"sources":["deleteCommentsAfterChangeRequest.ts"],"sourcesContent":["import { ApwComment, LifeCycleHookCallbackParams, ListMeta } from \"~/types\";\n\nexport const deleteCommentsAfterChangeRequest = ({\n apw\n}: Pick<LifeCycleHookCallbackParams, \"apw\">) => {\n apw.changeRequest.onChangeRequestAfterDelete.subscribe(async ({ changeRequest }) => {\n /**\n * Also delete all associated comments with \"changeRequest\".\n */\n let meta: Pick<ListMeta, \"totalCount\"> = {\n totalCount: 1\n };\n /**\n * Paginate through comments.\n */\n while (meta.totalCount > 0) {\n let comments: ApwComment[] = [];\n /**\n * Get all comments.\n */\n try {\n [comments, meta] = await apw.comment.list({\n where: {\n changeRequest: {\n id: changeRequest.id\n }\n }\n });\n } catch (e) {\n meta.totalCount = 0;\n if (e.message !== \"index_not_found_exception\") {\n throw e;\n }\n console.log(e);\n }\n\n /**\n * Delete comments one by one.\n */\n for (const comment of comments) {\n await apw.comment.delete(comment.id);\n }\n }\n });\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gCAAgC,GAAG,CAAC;EAC7CC;AACsC,CAAC,KAAK;EAC5CA,GAAG,CAACC,aAAa,CAACC,0BAA0B,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAc,CAAC,KAAK;IAChF;AACR;AACA;IACQ,IAAIG,IAAkC,GAAG;MACrCC,UAAU,EAAE;IAChB,CAAC;IACD;AACR;AACA;IACQ,OAAOD,IAAI,CAACC,UAAU,GAAG,CAAC,EAAE;MACxB,IAAIC,QAAsB,GAAG,EAAE;MAC/B;AACZ;AACA;MACY,IAAI;QACA,CAACA,QAAQ,EAAEF,IAAI,CAAC,GAAG,MAAMJ,GAAG,CAACO,OAAO,CAACC,IAAI,CAAC;UACtCC,KAAK,EAAE;YACHR,aAAa,EAAE;cACXS,EAAE,EAAET,aAAa,CAACS;YACtB;UACJ;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOC,CAAC,EAAE;QACRP,IAAI,CAACC,UAAU,GAAG,CAAC;QACnB,IAAIM,CAAC,CAACC,OAAO,KAAK,2BAA2B,EAAE;UAC3C,MAAMD,CAAC;QACX;QACAE,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC;MAClB;;MAEA;AACZ;AACA;MACY,KAAK,MAAMJ,OAAO,IAAID,QAAQ,EAAE;QAC5B,MAAMN,GAAG,CAACO,OAAO,CAACQ,MAAM,CAACR,OAAO,CAACG,EAAE,CAAC;MACxC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/plugins/hooks/index.js
CHANGED
@@ -4,31 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.attachApwHooks = void 0;
|
7
|
-
|
8
7
|
var _api = require("@webiny/api");
|
9
|
-
|
10
8
|
var _deleteCommentsAfterChangeRequest = require("./deleteCommentsAfterChangeRequest");
|
11
|
-
|
12
9
|
var _deleteChangeRequestsAfterContentReview = require("./deleteChangeRequestsAfterContentReview");
|
13
|
-
|
14
10
|
var _createReviewerFromIdentity = require("./createReviewerFromIdentity");
|
15
|
-
|
16
11
|
var _initializeContentReviewSteps = require("./initializeContentReviewSteps");
|
17
|
-
|
18
12
|
var _updatePendingChangeRequests = require("./updatePendingChangeRequests");
|
19
|
-
|
20
13
|
var _updateTotalComments = require("./updateTotalComments");
|
21
|
-
|
22
14
|
var _validateChangeRequest = require("./validateChangeRequest");
|
23
|
-
|
24
15
|
var _validateContentReview = require("./validateContentReview");
|
25
|
-
|
26
16
|
var _validateComment = require("./validateComment");
|
27
|
-
|
28
17
|
var _listContentReviews = require("./listContentReviews");
|
29
|
-
|
30
18
|
var _initializeNotifications = require("./initializeNotifications");
|
31
|
-
|
32
19
|
const attachApwHooks = () =>
|
33
20
|
/**
|
34
21
|
* Hook into CMS events and execute business logic.
|
@@ -70,5 +57,4 @@ new _api.ContextPlugin(async context => {
|
|
70
57
|
(0, _listContentReviews.listContentReviews)(context);
|
71
58
|
(0, _initializeNotifications.initializeNotifications)(context);
|
72
59
|
});
|
73
|
-
|
74
60
|
exports.attachApwHooks = attachApwHooks;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview","listContentReviews","initializeNotifications"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { deleteCommentsAfterChangeRequest } from \"./deleteCommentsAfterChangeRequest\";\nimport { deleteChangeRequestsWithContentReview } from \"./deleteChangeRequestsAfterContentReview\";\nimport { createReviewerFromIdentity } from \"./createReviewerFromIdentity\";\nimport { initializeContentReviewSteps } from \"./initializeContentReviewSteps\";\nimport { updatePendingChangeRequestsCount } from \"./updatePendingChangeRequests\";\nimport { updateTotalCommentsCount, updateLatestCommentId } from \"./updateTotalComments\";\nimport { validateChangeRequest } from \"./validateChangeRequest\";\nimport { validateContentReview } from \"./validateContentReview\";\nimport { validateComment } from \"./validateComment\";\nimport { listContentReviews } from \"./listContentReviews\";\nimport { initializeNotifications } from \"./initializeNotifications\";\n\nexport const attachApwHooks = () =>\n /**\n * Hook into CMS events and execute business logic.\n */\n new ContextPlugin<ApwContext>(async context => {\n const { security, apw } = context;\n\n validateContentReview({ apw });\n\n validateChangeRequest({ apw });\n\n validateComment({ apw });\n\n createReviewerFromIdentity({ security, apw });\n\n initializeContentReviewSteps(context);\n\n updatePendingChangeRequestsCount({ apw });\n\n updateTotalCommentsCount({ apw });\n\n updateLatestCommentId({ apw });\n\n deleteCommentsAfterChangeRequest({ apw });\n\n deleteChangeRequestsWithContentReview({ apw });\n\n listContentReviews(context);\n\n initializeNotifications(context);\n });\n"],"mappings":"
|
1
|
+
{"version":3,"names":["attachApwHooks","ContextPlugin","context","security","apw","validateContentReview","validateChangeRequest","validateComment","createReviewerFromIdentity","initializeContentReviewSteps","updatePendingChangeRequestsCount","updateTotalCommentsCount","updateLatestCommentId","deleteCommentsAfterChangeRequest","deleteChangeRequestsWithContentReview","listContentReviews","initializeNotifications"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { deleteCommentsAfterChangeRequest } from \"./deleteCommentsAfterChangeRequest\";\nimport { deleteChangeRequestsWithContentReview } from \"./deleteChangeRequestsAfterContentReview\";\nimport { createReviewerFromIdentity } from \"./createReviewerFromIdentity\";\nimport { initializeContentReviewSteps } from \"./initializeContentReviewSteps\";\nimport { updatePendingChangeRequestsCount } from \"./updatePendingChangeRequests\";\nimport { updateTotalCommentsCount, updateLatestCommentId } from \"./updateTotalComments\";\nimport { validateChangeRequest } from \"./validateChangeRequest\";\nimport { validateContentReview } from \"./validateContentReview\";\nimport { validateComment } from \"./validateComment\";\nimport { listContentReviews } from \"./listContentReviews\";\nimport { initializeNotifications } from \"./initializeNotifications\";\n\nexport const attachApwHooks = () =>\n /**\n * Hook into CMS events and execute business logic.\n */\n new ContextPlugin<ApwContext>(async context => {\n const { security, apw } = context;\n\n validateContentReview({ apw });\n\n validateChangeRequest({ apw });\n\n validateComment({ apw });\n\n createReviewerFromIdentity({ security, apw });\n\n initializeContentReviewSteps(context);\n\n updatePendingChangeRequestsCount({ apw });\n\n updateTotalCommentsCount({ apw });\n\n updateLatestCommentId({ apw });\n\n deleteCommentsAfterChangeRequest({ apw });\n\n deleteChangeRequestsWithContentReview({ apw });\n\n listContentReviews(context);\n\n initializeNotifications(context);\n });\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,cAAc,GAAG;AAC1B;AACJ;AACA;AACI,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,QAAQ;IAAEC;EAAI,CAAC,GAAGF,OAAO;EAEjC,IAAAG,4CAAqB,EAAC;IAAED;EAAI,CAAC,CAAC;EAE9B,IAAAE,4CAAqB,EAAC;IAAEF;EAAI,CAAC,CAAC;EAE9B,IAAAG,gCAAe,EAAC;IAAEH;EAAI,CAAC,CAAC;EAExB,IAAAI,sDAA0B,EAAC;IAAEL,QAAQ;IAAEC;EAAI,CAAC,CAAC;EAE7C,IAAAK,0DAA4B,EAACP,OAAO,CAAC;EAErC,IAAAQ,6DAAgC,EAAC;IAAEN;EAAI,CAAC,CAAC;EAEzC,IAAAO,6CAAwB,EAAC;IAAEP;EAAI,CAAC,CAAC;EAEjC,IAAAQ,0CAAqB,EAAC;IAAER;EAAI,CAAC,CAAC;EAE9B,IAAAS,kEAAgC,EAAC;IAAET;EAAI,CAAC,CAAC;EAEzC,IAAAU,6EAAqC,EAAC;IAAEV;EAAI,CAAC,CAAC;EAE9C,IAAAW,sCAAkB,EAACb,OAAO,CAAC;EAE3B,IAAAc,gDAAuB,EAACd,OAAO,CAAC;AACpC,CAAC,CAAC;AAAC"}
|
@@ -1,22 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.initializeContentReviewSteps = void 0;
|
9
|
-
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
9
|
var _set = _interopRequireDefault(require("lodash/set"));
|
13
|
-
|
14
10
|
var _utils = require("../utils");
|
15
|
-
|
16
11
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
17
|
-
|
18
12
|
var _contentApwSettingsPlugin = require("../../utils/contentApwSettingsPlugin");
|
19
|
-
|
20
13
|
const initializeContentReviewSteps = ({
|
21
14
|
apw,
|
22
15
|
plugins
|
@@ -32,35 +25,31 @@ const initializeContentReviewSteps = ({
|
|
32
25
|
/*
|
33
26
|
* Let's set "title" field value.
|
34
27
|
*/
|
35
|
-
|
36
28
|
const getContent = apw.getContentGetter(type);
|
37
29
|
const content = await getContent(id, settings);
|
38
|
-
|
39
30
|
if (!content) {
|
40
31
|
throw new _handlerGraphql.NotFoundError(`Content "${type}" with id ${id} not found.`);
|
41
32
|
}
|
42
|
-
|
43
33
|
const {
|
44
34
|
title
|
45
35
|
} = content;
|
46
36
|
input = (0, _set.default)(input, "title", title);
|
37
|
+
|
47
38
|
/**
|
48
39
|
* We need to find a plugin which can get a workflow ID for the given type of content.
|
49
40
|
*/
|
50
|
-
|
51
41
|
const contentApwSettingsPlugin = (0, _contentApwSettingsPlugin.getContentApwSettingsPlugin)({
|
52
42
|
plugins,
|
53
43
|
type
|
54
44
|
});
|
55
45
|
const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
|
46
|
+
|
56
47
|
/**
|
57
48
|
* Let's initialize the "ContentReview" steps.
|
58
49
|
*/
|
59
|
-
|
60
50
|
if (!workflowId) {
|
61
51
|
throw new _handlerGraphql.NotFoundError(`Unable to initiate a "Content review". No workflow found!`);
|
62
52
|
}
|
63
|
-
|
64
53
|
input.workflowId = workflowId;
|
65
54
|
const workflow = await apw.workflow.get(workflowId);
|
66
55
|
const workflowSteps = workflow.steps;
|
@@ -78,9 +67,7 @@ const initializeContentReviewSteps = ({
|
|
78
67
|
* TODO Figure our what does this actually do?
|
79
68
|
* There is no steps property on CreateApwContentReviewParams
|
80
69
|
*/
|
81
|
-
|
82
70
|
input = (0, _set.default)(input, "steps", updatedSteps);
|
83
71
|
});
|
84
72
|
};
|
85
|
-
|
86
73
|
exports.initializeContentReviewSteps = initializeContentReviewSteps;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["initializeContentReviewSteps","apw","plugins","contentReview","onContentReviewBeforeCreate","subscribe","input","type","id","settings","content","getContent","getContentGetter","NotFoundError","title","lodashSet","contentApwSettingsPlugin","getContentApwSettingsPlugin","workflowId","getWorkflowId","workflow","get","workflowSteps","steps","previousStepStatus","undefined","updatedSteps","map","step","index","status","getContentReviewStepInitialStatus","pendingChangeRequests","totalComments"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport { ApwContentReviewStepStatus, ApwContext } from \"~/types\";\nimport { getContentReviewStepInitialStatus } from \"~/plugins/utils\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\n\nexport const initializeContentReviewSteps = ({ apw, plugins }: ApwContext) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { type, id, settings } = input.content;\n /*\n * Let's set \"title\" field value.\n */\n const getContent = apw.getContentGetter(type);\n const content = await getContent(id, settings);\n if (!content) {\n throw new NotFoundError(`Content \"${type}\" with id ${id} not found.`);\n }\n\n const { title } = content;\n input = lodashSet(input, \"title\", title);\n\n /**\n * We need to find a plugin which can get a workflow ID for the given type of content.\n */\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type\n });\n\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n\n /**\n * Let's initialize the \"ContentReview\" steps.\n */\n if (!workflowId) {\n throw new NotFoundError(`Unable to initiate a \"Content review\". No workflow found!`);\n }\n\n input.workflowId = workflowId;\n\n const workflow = await apw.workflow.get(workflowId);\n const workflowSteps = workflow.steps;\n\n let previousStepStatus: ApwContentReviewStepStatus | undefined = undefined;\n const updatedSteps = workflow.steps.map((step, index) => {\n const status = getContentReviewStepInitialStatus(\n workflowSteps,\n index,\n previousStepStatus\n );\n previousStepStatus = status;\n return {\n ...step,\n status,\n pendingChangeRequests: 0,\n totalComments: 0\n };\n });\n /**\n * TODO Figure our what does this actually do?\n * There is no steps property on CreateApwContentReviewParams\n */\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["initializeContentReviewSteps","apw","plugins","contentReview","onContentReviewBeforeCreate","subscribe","input","type","id","settings","content","getContent","getContentGetter","NotFoundError","title","lodashSet","contentApwSettingsPlugin","getContentApwSettingsPlugin","workflowId","getWorkflowId","workflow","get","workflowSteps","steps","previousStepStatus","undefined","updatedSteps","map","step","index","status","getContentReviewStepInitialStatus","pendingChangeRequests","totalComments"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport { ApwContentReviewStepStatus, ApwContext } from \"~/types\";\nimport { getContentReviewStepInitialStatus } from \"~/plugins/utils\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { getContentApwSettingsPlugin } from \"~/utils/contentApwSettingsPlugin\";\n\nexport const initializeContentReviewSteps = ({ apw, plugins }: ApwContext) => {\n apw.contentReview.onContentReviewBeforeCreate.subscribe(async ({ input }) => {\n const { type, id, settings } = input.content;\n /*\n * Let's set \"title\" field value.\n */\n const getContent = apw.getContentGetter(type);\n const content = await getContent(id, settings);\n if (!content) {\n throw new NotFoundError(`Content \"${type}\" with id ${id} not found.`);\n }\n\n const { title } = content;\n input = lodashSet(input, \"title\", title);\n\n /**\n * We need to find a plugin which can get a workflow ID for the given type of content.\n */\n const contentApwSettingsPlugin = getContentApwSettingsPlugin({\n plugins,\n type\n });\n\n const workflowId = contentApwSettingsPlugin.getWorkflowId(content);\n\n /**\n * Let's initialize the \"ContentReview\" steps.\n */\n if (!workflowId) {\n throw new NotFoundError(`Unable to initiate a \"Content review\". No workflow found!`);\n }\n\n input.workflowId = workflowId;\n\n const workflow = await apw.workflow.get(workflowId);\n const workflowSteps = workflow.steps;\n\n let previousStepStatus: ApwContentReviewStepStatus | undefined = undefined;\n const updatedSteps = workflow.steps.map((step, index) => {\n const status = getContentReviewStepInitialStatus(\n workflowSteps,\n index,\n previousStepStatus\n );\n previousStepStatus = status;\n return {\n ...step,\n status,\n pendingChangeRequests: 0,\n totalComments: 0\n };\n });\n /**\n * TODO Figure our what does this actually do?\n * There is no steps property on CreateApwContentReviewParams\n */\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,GAAG;EAAEC;AAAoB,CAAC,KAAK;EAC1ED,GAAG,CAACE,aAAa,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACzE,MAAM;MAAEC,IAAI;MAAEC,EAAE;MAAEC;IAAS,CAAC,GAAGH,KAAK,CAACI,OAAO;IAC5C;AACR;AACA;IACQ,MAAMC,UAAU,GAAGV,GAAG,CAACW,gBAAgB,CAACL,IAAI,CAAC;IAC7C,MAAMG,OAAO,GAAG,MAAMC,UAAU,CAACH,EAAE,EAAEC,QAAQ,CAAC;IAC9C,IAAI,CAACC,OAAO,EAAE;MACV,MAAM,IAAIG,6BAAa,CAAE,YAAWN,IAAK,aAAYC,EAAG,aAAY,CAAC;IACzE;IAEA,MAAM;MAAEM;IAAM,CAAC,GAAGJ,OAAO;IACzBJ,KAAK,GAAG,IAAAS,YAAS,EAACT,KAAK,EAAE,OAAO,EAAEQ,KAAK,CAAC;;IAExC;AACR;AACA;IACQ,MAAME,wBAAwB,GAAG,IAAAC,qDAA2B,EAAC;MACzDf,OAAO;MACPK;IACJ,CAAC,CAAC;IAEF,MAAMW,UAAU,GAAGF,wBAAwB,CAACG,aAAa,CAACT,OAAO,CAAC;;IAElE;AACR;AACA;IACQ,IAAI,CAACQ,UAAU,EAAE;MACb,MAAM,IAAIL,6BAAa,CAAE,2DAA0D,CAAC;IACxF;IAEAP,KAAK,CAACY,UAAU,GAAGA,UAAU;IAE7B,MAAME,QAAQ,GAAG,MAAMnB,GAAG,CAACmB,QAAQ,CAACC,GAAG,CAACH,UAAU,CAAC;IACnD,MAAMI,aAAa,GAAGF,QAAQ,CAACG,KAAK;IAEpC,IAAIC,kBAA0D,GAAGC,SAAS;IAC1E,MAAMC,YAAY,GAAGN,QAAQ,CAACG,KAAK,CAACI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MACrD,MAAMC,MAAM,GAAG,IAAAC,wCAAiC,EAC5CT,aAAa,EACbO,KAAK,EACLL,kBAAkB,CACrB;MACDA,kBAAkB,GAAGM,MAAM;MAC3B,mEACOF,IAAI;QACPE,MAAM;QACNE,qBAAqB,EAAE,CAAC;QACxBC,aAAa,EAAE;MAAC;IAExB,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQ3B,KAAK,GAAG,IAAAS,YAAS,EAACT,KAAK,EAAE,OAAO,EAAEoB,YAAY,CAAC;EACnD,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,17 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.initializeNotifications = void 0;
|
7
|
-
|
8
7
|
var _contentReviewAfterCreate = require("./notifications/contentReviewAfterCreate");
|
9
|
-
|
10
8
|
var _commentAfterCreate = require("./notifications/commentAfterCreate");
|
11
|
-
|
12
9
|
var _changeRequestAfterCreate = require("./notifications/changeRequestAfterCreate");
|
13
|
-
|
14
10
|
const initializeNotifications = context => {
|
15
11
|
(0, _contentReviewAfterCreate.attachContentReviewAfterCreate)(context);
|
16
12
|
(0, _commentAfterCreate.attachCommentAfterCreate)(context);
|
17
13
|
(0, _changeRequestAfterCreate.attachChangeRequestAfterCreate)(context);
|
18
14
|
};
|
19
|
-
|
20
15
|
exports.initializeNotifications = initializeNotifications;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["initializeNotifications","context","attachContentReviewAfterCreate","attachCommentAfterCreate","attachChangeRequestAfterCreate"],"sources":["initializeNotifications.ts"],"sourcesContent":["import { ApwContext } from \"~/types\";\nimport { attachContentReviewAfterCreate } from \"./notifications/contentReviewAfterCreate\";\nimport { attachCommentAfterCreate } from \"./notifications/commentAfterCreate\";\nimport { attachChangeRequestAfterCreate } from \"./notifications/changeRequestAfterCreate\";\n\nexport const initializeNotifications = (context: ApwContext) => {\n attachContentReviewAfterCreate(context);\n attachCommentAfterCreate(context);\n attachChangeRequestAfterCreate(context);\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["initializeNotifications","context","attachContentReviewAfterCreate","attachCommentAfterCreate","attachChangeRequestAfterCreate"],"sources":["initializeNotifications.ts"],"sourcesContent":["import { ApwContext } from \"~/types\";\nimport { attachContentReviewAfterCreate } from \"./notifications/contentReviewAfterCreate\";\nimport { attachCommentAfterCreate } from \"./notifications/commentAfterCreate\";\nimport { attachChangeRequestAfterCreate } from \"./notifications/changeRequestAfterCreate\";\n\nexport const initializeNotifications = (context: ApwContext) => {\n attachContentReviewAfterCreate(context);\n attachCommentAfterCreate(context);\n attachChangeRequestAfterCreate(context);\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AAEO,MAAMA,uBAAuB,GAAIC,OAAmB,IAAK;EAC5D,IAAAC,wDAA8B,EAACD,OAAO,CAAC;EACvC,IAAAE,4CAAwB,EAACF,OAAO,CAAC;EACjC,IAAAG,wDAA8B,EAACH,OAAO,CAAC;AAC3C,CAAC;AAAC"}
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.listContentReviews = void 0;
|
7
|
-
|
8
7
|
const listContentReviews = ({
|
9
8
|
apw,
|
10
9
|
security
|
@@ -22,19 +21,14 @@ const listContentReviews = ({
|
|
22
21
|
if (where.workflowId_in) {
|
23
22
|
return;
|
24
23
|
}
|
25
|
-
|
26
24
|
const identity = security.getIdentity();
|
27
|
-
|
28
25
|
if (!(identity !== null && identity !== void 0 && identity.id)) {
|
29
26
|
return;
|
30
27
|
}
|
31
28
|
/**
|
32
29
|
* Find all available workflows.
|
33
30
|
*/
|
34
|
-
|
35
|
-
|
36
31
|
const [workflows] = await apw.workflow.list();
|
37
|
-
|
38
32
|
if (workflows.length === 0) {
|
39
33
|
return;
|
40
34
|
}
|
@@ -42,8 +36,6 @@ const listContentReviews = ({
|
|
42
36
|
* Find all workflows which user has access to.
|
43
37
|
* User access is buried quite deep in the workflow data, so we need to do some traversing.
|
44
38
|
*/
|
45
|
-
|
46
|
-
|
47
39
|
const userWorkflows = workflows.filter(workflow => {
|
48
40
|
return workflow.steps.some(step => {
|
49
41
|
return step.reviewers.some(reviewer => {
|
@@ -51,7 +43,6 @@ const listContentReviews = ({
|
|
51
43
|
});
|
52
44
|
});
|
53
45
|
});
|
54
|
-
|
55
46
|
if (userWorkflows.length === 0) {
|
56
47
|
return;
|
57
48
|
}
|
@@ -59,10 +50,7 @@ const listContentReviews = ({
|
|
59
50
|
* In the end, we need to attach the workflow filter by the entryId.
|
60
51
|
* Just in case we add versioning at some point...
|
61
52
|
*/
|
62
|
-
|
63
|
-
|
64
53
|
where.workflowId_in = userWorkflows.map(workflow => workflow.id);
|
65
54
|
});
|
66
55
|
};
|
67
|
-
|
68
56
|
exports.listContentReviews = listContentReviews;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["listContentReviews","apw","security","contentReview","onContentReviewBeforeList","subscribe","where","workflowId_in","identity","getIdentity","id","workflows","workflow","list","length","userWorkflows","filter","steps","some","step","reviewers","reviewer","identityId","map"],"sources":["listContentReviews.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface ListWorkflowsParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\nexport const listContentReviews = ({ apw, security }: ListWorkflowsParams) => {\n /**\n * We need to hook into listing the content review entries.\n * When listing content review entries, we need to check which ones current user can actually see.\n */\n apw.contentReview.onContentReviewBeforeList.subscribe(async ({ where }) => {\n /**\n * If there is workflowId_in attached on where, we will not change it.\n */\n if (where.workflowId_in) {\n return;\n }\n const identity = security.getIdentity();\n if (!identity?.id) {\n return;\n }\n /**\n * Find all available workflows.\n */\n const [workflows] = await apw.workflow.list();\n if (workflows.length === 0) {\n return;\n }\n /**\n * Find all workflows which user has access to.\n * User access is buried quite deep in the workflow data, so we need to do some traversing.\n */\n const userWorkflows = workflows.filter(workflow => {\n return workflow.steps.some(step => {\n return step.reviewers.some(reviewer => {\n return identity.id === reviewer.identityId;\n });\n });\n });\n if (userWorkflows.length === 0) {\n return;\n }\n /**\n * In the end, we need to attach the workflow filter by the entryId.\n * Just in case we add versioning at some point...\n */\n where.workflowId_in = userWorkflows.map(workflow => workflow.id);\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["listContentReviews","apw","security","contentReview","onContentReviewBeforeList","subscribe","where","workflowId_in","identity","getIdentity","id","workflows","workflow","list","length","userWorkflows","filter","steps","some","step","reviewers","reviewer","identityId","map"],"sources":["listContentReviews.ts"],"sourcesContent":["import { AdvancedPublishingWorkflow } from \"~/types\";\nimport { HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\ninterface ListWorkflowsParams {\n apw: AdvancedPublishingWorkflow;\n cms: HeadlessCms;\n security: Security;\n}\nexport const listContentReviews = ({ apw, security }: ListWorkflowsParams) => {\n /**\n * We need to hook into listing the content review entries.\n * When listing content review entries, we need to check which ones current user can actually see.\n */\n apw.contentReview.onContentReviewBeforeList.subscribe(async ({ where }) => {\n /**\n * If there is workflowId_in attached on where, we will not change it.\n */\n if (where.workflowId_in) {\n return;\n }\n const identity = security.getIdentity();\n if (!identity?.id) {\n return;\n }\n /**\n * Find all available workflows.\n */\n const [workflows] = await apw.workflow.list();\n if (workflows.length === 0) {\n return;\n }\n /**\n * Find all workflows which user has access to.\n * User access is buried quite deep in the workflow data, so we need to do some traversing.\n */\n const userWorkflows = workflows.filter(workflow => {\n return workflow.steps.some(step => {\n return step.reviewers.some(reviewer => {\n return identity.id === reviewer.identityId;\n });\n });\n });\n if (userWorkflows.length === 0) {\n return;\n }\n /**\n * In the end, we need to attach the workflow filter by the entryId.\n * Just in case we add versioning at some point...\n */\n where.workflowId_in = userWorkflows.map(workflow => workflow.id);\n });\n};\n"],"mappings":";;;;;;AASO,MAAMA,kBAAkB,GAAG,CAAC;EAAEC,GAAG;EAAEC;AAA8B,CAAC,KAAK;EAC1E;AACJ;AACA;AACA;EACID,GAAG,CAACE,aAAa,CAACC,yBAAyB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IACvE;AACR;AACA;IACQ,IAAIA,KAAK,CAACC,aAAa,EAAE;MACrB;IACJ;IACA,MAAMC,QAAQ,GAAGN,QAAQ,CAACO,WAAW,EAAE;IACvC,IAAI,EAACD,QAAQ,aAARA,QAAQ,eAARA,QAAQ,CAAEE,EAAE,GAAE;MACf;IACJ;IACA;AACR;AACA;IACQ,MAAM,CAACC,SAAS,CAAC,GAAG,MAAMV,GAAG,CAACW,QAAQ,CAACC,IAAI,EAAE;IAC7C,IAAIF,SAAS,CAACG,MAAM,KAAK,CAAC,EAAE;MACxB;IACJ;IACA;AACR;AACA;AACA;IACQ,MAAMC,aAAa,GAAGJ,SAAS,CAACK,MAAM,CAACJ,QAAQ,IAAI;MAC/C,OAAOA,QAAQ,CAACK,KAAK,CAACC,IAAI,CAACC,IAAI,IAAI;QAC/B,OAAOA,IAAI,CAACC,SAAS,CAACF,IAAI,CAACG,QAAQ,IAAI;UACnC,OAAOb,QAAQ,CAACE,EAAE,KAAKW,QAAQ,CAACC,UAAU;QAC9C,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,CAAC;IACF,IAAIP,aAAa,CAACD,MAAM,KAAK,CAAC,EAAE;MAC5B;IACJ;IACA;AACR;AACA;AACA;IACQR,KAAK,CAACC,aAAa,GAAGQ,aAAa,CAACQ,GAAG,CAACX,QAAQ,IAAIA,QAAQ,CAACF,EAAE,CAAC;EACpE,CAAC,CAAC;AACN,CAAC;AAAC"}
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getAppUrl = void 0;
|
7
|
-
|
8
7
|
const getAppUrl = async context => {
|
9
8
|
const tenant = context.tenancy.getCurrentTenant().id;
|
10
|
-
|
11
9
|
try {
|
12
10
|
return await context.settings.getSettings(tenant);
|
13
11
|
} catch (ex) {
|
@@ -15,8 +13,6 @@ const getAppUrl = async context => {
|
|
15
13
|
throw ex;
|
16
14
|
}
|
17
15
|
}
|
18
|
-
|
19
16
|
return null;
|
20
17
|
};
|
21
|
-
|
22
18
|
exports.getAppUrl = getAppUrl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getAppUrl","context","tenant","tenancy","getCurrentTenant","id","settings","getSettings","ex","code"],"sources":["appUrl.ts"],"sourcesContent":["import { ApwContext } from \"~/types\";\n\nexport const getAppUrl = async (context: ApwContext) => {\n const tenant = context.tenancy.getCurrentTenant().id;\n try {\n return await context.settings.getSettings(tenant);\n } catch (ex) {\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n return null;\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["getAppUrl","context","tenant","tenancy","getCurrentTenant","id","settings","getSettings","ex","code"],"sources":["appUrl.ts"],"sourcesContent":["import { ApwContext } from \"~/types\";\n\nexport const getAppUrl = async (context: ApwContext) => {\n const tenant = context.tenancy.getCurrentTenant().id;\n try {\n return await context.settings.getSettings(tenant);\n } catch (ex) {\n if (ex.code !== \"NOT_FOUND\") {\n throw ex;\n }\n }\n return null;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,SAAS,GAAG,MAAOC,OAAmB,IAAK;EACpD,MAAMC,MAAM,GAAGD,OAAO,CAACE,OAAO,CAACC,gBAAgB,EAAE,CAACC,EAAE;EACpD,IAAI;IACA,OAAO,MAAMJ,OAAO,CAACK,QAAQ,CAACC,WAAW,CAACL,MAAM,CAAC;EACrD,CAAC,CAAC,OAAOM,EAAE,EAAE;IACT,IAAIA,EAAE,CAACC,IAAI,KAAK,WAAW,EAAE;MACzB,MAAMD,EAAE;IACZ;EACJ;EACA,OAAO,IAAI;AACf,CAAC;AAAC"}
|
@@ -1,26 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.attachChangeRequestAfterCreate = void 0;
|
9
|
-
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
-
|
12
9
|
var _utils = require("../../utils");
|
13
|
-
|
14
10
|
var _contentUrl = require("./contentUrl");
|
15
|
-
|
16
11
|
var _sendChangeRequestNotification = require("./sendChangeRequestNotification");
|
17
|
-
|
18
12
|
var _reviewers = require("./reviewers");
|
19
|
-
|
20
13
|
var _changeRequestUrl = require("./changeRequestUrl");
|
21
|
-
|
22
14
|
var _appUrl = require("./appUrl");
|
23
|
-
|
24
15
|
const attachChangeRequestAfterCreate = context => {
|
25
16
|
context.apw.changeRequest.onChangeRequestAfterCreate.subscribe(async ({
|
26
17
|
changeRequest
|
@@ -30,40 +21,31 @@ const attachChangeRequestAfterCreate = context => {
|
|
30
21
|
id: contentReviewId,
|
31
22
|
stepId
|
32
23
|
} = (0, _utils.extractContentReviewIdAndStep)(changeRequest.step);
|
33
|
-
|
34
24
|
if (!stepId) {
|
35
25
|
throw new _error.default("Malformed changeRequest.step value.", "MALFORMED_VALUE", {
|
36
26
|
step: changeRequest.step
|
37
27
|
});
|
38
28
|
}
|
39
|
-
|
40
29
|
const settings = await (0, _appUrl.getAppUrl)(context);
|
41
|
-
|
42
30
|
if (!settings) {
|
43
31
|
return;
|
44
32
|
}
|
45
33
|
/**
|
46
34
|
* We will check if we can create a comment url before we go digging further into the database.
|
47
35
|
*/
|
48
|
-
|
49
|
-
|
50
36
|
const changeRequestUrl = (0, _changeRequestUrl.createChangeRequestUrl)({
|
51
37
|
baseUrl: settings.appUrl,
|
52
38
|
changeRequestId: changeRequest.id,
|
53
39
|
contentReviewId,
|
54
40
|
stepId
|
55
41
|
});
|
56
|
-
|
57
42
|
if (!changeRequestUrl) {
|
58
43
|
return;
|
59
44
|
}
|
60
45
|
/**
|
61
46
|
* Let's see if content review exists.
|
62
47
|
*/
|
63
|
-
|
64
|
-
|
65
48
|
const contentReview = await context.apw.contentReview.get(contentReviewId);
|
66
|
-
|
67
49
|
if (!contentReview) {
|
68
50
|
throw new _error.default(`There is no contentReview with id "${contentReviewId}".`, "CONTENT_REVIEW_NOT_FOUND", {
|
69
51
|
contentReviewId
|
@@ -72,37 +54,29 @@ const attachChangeRequestAfterCreate = context => {
|
|
72
54
|
/**
|
73
55
|
* We go and check the workflow.
|
74
56
|
*/
|
75
|
-
|
76
|
-
|
77
57
|
const workflow = await context.apw.workflow.get(contentReview.workflowId);
|
78
|
-
|
79
58
|
if (!workflow) {
|
80
59
|
throw new _error.default(`There is no workflow with workflowId "${contentReview.workflowId}".`, "WORKFLOW_NOT_FOUND", {
|
81
60
|
workflowId: contentReview.workflowId
|
82
61
|
});
|
83
62
|
}
|
84
|
-
|
85
63
|
const contentUrl = (0, _contentUrl.createContentUrl)({
|
86
64
|
plugins: context.plugins,
|
87
65
|
baseUrl: settings.appUrl,
|
88
66
|
contentReview,
|
89
67
|
workflow
|
90
68
|
});
|
91
|
-
|
92
69
|
if (!contentUrl) {
|
93
70
|
return;
|
94
71
|
}
|
95
|
-
|
96
72
|
const reviewers = await (0, _reviewers.fetchReviewers)({
|
97
73
|
context,
|
98
74
|
workflow,
|
99
75
|
exclude: [changeRequest.createdBy.id]
|
100
76
|
});
|
101
|
-
|
102
77
|
if (reviewers.length === 0) {
|
103
78
|
return;
|
104
79
|
}
|
105
|
-
|
106
80
|
try {
|
107
81
|
await (0, _sendChangeRequestNotification.sendChangeRequestNotification)({
|
108
82
|
context,
|
@@ -129,7 +103,6 @@ const attachChangeRequestAfterCreate = context => {
|
|
129
103
|
});
|
130
104
|
}
|
131
105
|
};
|
132
|
-
|
133
106
|
try {
|
134
107
|
context.security.disableAuthorization();
|
135
108
|
await execute();
|
@@ -140,5 +113,4 @@ const attachChangeRequestAfterCreate = context => {
|
|
140
113
|
}
|
141
114
|
});
|
142
115
|
};
|
143
|
-
|
144
116
|
exports.attachChangeRequestAfterCreate = attachChangeRequestAfterCreate;
|