@webiny/api-apw 5.34.8-beta.1 → 5.35.0-beta.0
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 +3 -10
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.js +3 -10
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.js +6 -25
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.js +3 -10
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/workflow.gql.js +3 -10
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.js +3 -18
- 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 -18
- 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 +3 -36
- 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 +3 -38
- 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 +4 -32
- 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 +15 -21
- 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 -40
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +0 -7
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +1 -23
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -28
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.js +0 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.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 -2
- package/scheduler/handlers/utils.js +3 -41
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.js +0 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +2 -20
- package/scheduler/types.js +0 -11
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.js +20 -39
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.js +23 -44
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.js +20 -37
- 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.d.ts +3 -10
- package/storageOperations/models/contentModelPluginFactory.js +3 -11
- 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 -28
- 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 +23 -45
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/workflowStorageOperations.js +20 -39
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +6 -5
- 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
package/plugins/graphql.js
CHANGED
@@ -1,32 +1,20 @@
|
|
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.default = void 0;
|
9
|
-
|
10
|
-
var _plugins = require("@webiny/handler-graphql/plugins");
|
11
|
-
|
12
8
|
var _workflow = _interopRequireDefault(require("./graphql/workflow.gql"));
|
13
|
-
|
14
9
|
var _contentReview = _interopRequireDefault(require("./graphql/contentReview.gql"));
|
15
|
-
|
16
10
|
var _reviewer = _interopRequireDefault(require("./graphql/reviewer.gql"));
|
17
|
-
|
18
11
|
var _comment = _interopRequireDefault(require("./graphql/comment.gql"));
|
19
|
-
|
20
12
|
var _changeRequest = _interopRequireDefault(require("./graphql/changeRequest.gql"));
|
21
|
-
|
13
|
+
var _plugins = require("@webiny/handler-graphql/plugins");
|
22
14
|
var _api = require("@webiny/api");
|
23
|
-
|
24
15
|
const emptyResolver = () => ({});
|
25
|
-
|
26
16
|
const baseSchema = new _plugins.GraphQLSchemaPlugin({
|
27
|
-
typeDefs:
|
28
|
-
/* GraphQL */
|
29
|
-
`
|
17
|
+
typeDefs: /* GraphQL */`
|
30
18
|
input ApwRefFieldInput {
|
31
19
|
id: ID!
|
32
20
|
modelId: String
|
@@ -54,7 +42,7 @@ const baseSchema = new _plugins.GraphQLSchemaPlugin({
|
|
54
42
|
totalCount: Int
|
55
43
|
cursor: String
|
56
44
|
}
|
57
|
-
type
|
45
|
+
type ApwIdentity {
|
58
46
|
id: ID
|
59
47
|
displayName: String
|
60
48
|
type: String
|
@@ -81,15 +69,12 @@ const baseSchema = new _plugins.GraphQLSchemaPlugin({
|
|
81
69
|
}
|
82
70
|
}
|
83
71
|
});
|
84
|
-
|
85
72
|
var _default = () => {
|
86
73
|
return new _api.ContextPlugin(context => {
|
87
74
|
if (!context.wcp.canUseFeature("advancedPublishingWorkflow")) {
|
88
75
|
return;
|
89
76
|
}
|
90
|
-
|
91
77
|
context.plugins.register([baseSchema, _workflow.default, _contentReview.default, _reviewer.default, _comment.default, _changeRequest.default]);
|
92
78
|
});
|
93
79
|
};
|
94
|
-
|
95
80
|
exports.default = _default;
|
package/plugins/graphql.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import workflowSchema from \"./graphql/workflow.gql\";\nimport contentReviewSchema from \"./graphql/contentReview.gql\";\nimport reviewerSchema from \"./graphql/reviewer.gql\";\nimport commentSchema from \"./graphql/comment.gql\";\nimport changeRequestedSchema from \"./graphql/changeRequest.gql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n input ApwRefFieldInput {\n id: ID!\n modelId: String\n }\n\n input ApwRefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n }\n\n type ApwRefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n type ApwMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n type ApwIdentity {\n id: ID\n displayName: String\n type: String\n }\n type ApwError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n extend type Query {\n apw: ApwQuery\n }\n extend type Mutation {\n apw: ApwMutation\n }\n `,\n resolvers: {\n Query: {\n apw: emptyResolver\n },\n Mutation: {\n apw: emptyResolver\n }\n }\n});\n\nexport default () => {\n return new ContextPlugin<ApwContext>(context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n }\n\n context.plugins.register([\n baseSchema,\n workflowSchema,\n contentReviewSchema,\n reviewerSchema,\n commentSchema,\n changeRequestedSchema\n ]);\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,4BAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN;IACT,CAAC;IACDO,QAAQ,EAAE;MACND,GAAG,EAAEN;IACT;EACJ;AACJ,CAAC,CAAC;AAAC,eAEY,MAAM;EACjB,OAAO,IAAIQ,kBAAa,CAAaC,OAAO,IAAI;IAC5C,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,EAAE;MAC1D;IACJ;IAEAF,OAAO,CAACG,OAAO,CAACC,QAAQ,CAAC,CACrBZ,UAAU,EACVa,iBAAc,EACdC,sBAAmB,EACnBC,iBAAc,EACdC,gBAAa,EACbC,sBAAqB,CACxB,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAA"}
|
@@ -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,24 +1,16 @@
|
|
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 _types = require("../../types");
|
15
|
-
|
16
11
|
var _utils = require("../utils");
|
17
|
-
|
18
12
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
19
|
-
|
20
13
|
var _contentApwSettingsPlugin = require("../../utils/contentApwSettingsPlugin");
|
21
|
-
|
22
14
|
const initializeContentReviewSteps = ({
|
23
15
|
apw,
|
24
16
|
plugins
|
@@ -34,35 +26,31 @@ const initializeContentReviewSteps = ({
|
|
34
26
|
/*
|
35
27
|
* Let's set "title" field value.
|
36
28
|
*/
|
37
|
-
|
38
29
|
const getContent = apw.getContentGetter(type);
|
39
30
|
const content = await getContent(id, settings);
|
40
|
-
|
41
31
|
if (!content) {
|
42
32
|
throw new _handlerGraphql.NotFoundError(`Content "${type}" with id ${id} not found.`);
|
43
33
|
}
|
44
|
-
|
45
34
|
const {
|
46
35
|
title
|
47
36
|
} = content;
|
48
37
|
input = (0, _set.default)(input, "title", title);
|
38
|
+
|
49
39
|
/**
|
50
40
|
* We need to find a plugin which can get a workflow ID for the given type of content.
|
51
41
|
*/
|
52
|
-
|
53
42
|
const contentApwSettingsPlugin = (0, _contentApwSettingsPlugin.getContentApwSettingsPlugin)({
|
54
43
|
plugins,
|
55
44
|
type
|
56
45
|
});
|
57
46
|
const workflowId = contentApwSettingsPlugin.getWorkflowId(content);
|
47
|
+
|
58
48
|
/**
|
59
49
|
* Let's initialize the "ContentReview" steps.
|
60
50
|
*/
|
61
|
-
|
62
51
|
if (!workflowId) {
|
63
52
|
throw new _handlerGraphql.NotFoundError(`Unable to initiate a "Content review". No workflow found!`);
|
64
53
|
}
|
65
|
-
|
66
54
|
input.workflowId = workflowId;
|
67
55
|
const workflow = await apw.workflow.get(workflowId);
|
68
56
|
const workflowSteps = workflow.steps;
|
@@ -79,17 +67,13 @@ const initializeContentReviewSteps = ({
|
|
79
67
|
/**
|
80
68
|
* If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED.
|
81
69
|
*/
|
82
|
-
|
83
70
|
const isNonMandatory = updatedSteps.every(step => {
|
84
71
|
return step.type === _types.ApwWorkflowStepTypes.NON_MANDATORY;
|
85
72
|
});
|
86
|
-
|
87
73
|
if (isNonMandatory) {
|
88
74
|
input.reviewStatus = _types.ApwContentReviewStatus.READY_TO_BE_PUBLISHED;
|
89
75
|
}
|
90
|
-
|
91
76
|
input = (0, _set.default)(input, "steps", updatedSteps);
|
92
77
|
});
|
93
78
|
};
|
94
|
-
|
95
79
|
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","isNonMandatory","every","ApwWorkflowStepTypes","NON_MANDATORY","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport {\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwContext,\n ApwWorkflowStepTypes\n} 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 * If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED.\n */\n const isNonMandatory = updatedSteps.every(step => {\n return step.type === ApwWorkflowStepTypes.NON_MANDATORY;\n });\n if (isNonMandatory) {\n input.reviewStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\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","isNonMandatory","every","ApwWorkflowStepTypes","NON_MANDATORY","reviewStatus","ApwContentReviewStatus","READY_TO_BE_PUBLISHED"],"sources":["initializeContentReviewSteps.ts"],"sourcesContent":["import lodashSet from \"lodash/set\";\nimport {\n ApwContentReviewStatus,\n ApwContentReviewStepStatus,\n ApwContext,\n ApwWorkflowStepTypes\n} 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 * If there are only steps which are not mandatory ones, put review status to ApwContentReviewStatus.READY_TO_BE_PUBLISHED.\n */\n const isNonMandatory = updatedSteps.every(step => {\n return step.type === ApwWorkflowStepTypes.NON_MANDATORY;\n });\n if (isNonMandatory) {\n input.reviewStatus = ApwContentReviewStatus.READY_TO_BE_PUBLISHED;\n }\n\n input = lodashSet(input, \"steps\", updatedSteps);\n });\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AAMA;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;IACQ,MAAMC,cAAc,GAAGR,YAAY,CAACS,KAAK,CAACP,IAAI,IAAI;MAC9C,OAAOA,IAAI,CAACrB,IAAI,KAAK6B,2BAAoB,CAACC,aAAa;IAC3D,CAAC,CAAC;IACF,IAAIH,cAAc,EAAE;MAChB5B,KAAK,CAACgC,YAAY,GAAGC,6BAAsB,CAACC,qBAAqB;IACrE;IAEAlC,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"}
|