@webiny/api-apw 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApwChangeRequestNotification.d.ts +1 -1
- package/ApwChangeRequestNotification.js +3 -15
- package/ApwChangeRequestNotification.js.map +1 -1
- package/ApwCommentNotification.d.ts +1 -1
- package/ApwCommentNotification.js +3 -15
- package/ApwCommentNotification.js.map +1 -1
- package/ApwContentReviewNotification.d.ts +1 -1
- package/ApwContentReviewNotification.js +3 -15
- package/ApwContentReviewNotification.js.map +1 -1
- package/ApwContentUrlPlugin.d.ts +1 -1
- package/ApwContentUrlPlugin.js +3 -15
- package/ApwContentUrlPlugin.js.map +1 -1
- package/ContentApwSettingsPlugin.d.ts +1 -1
- package/ContentApwSettingsPlugin.js +5 -9
- package/ContentApwSettingsPlugin.js.map +1 -1
- package/README.md +3 -3
- package/crud/createChangeRequestMethods.d.ts +1 -1
- package/crud/createChangeRequestMethods.js +7 -12
- package/crud/createChangeRequestMethods.js.map +1 -1
- package/crud/createCommentMethods.d.ts +1 -1
- package/crud/createCommentMethods.js +7 -13
- package/crud/createCommentMethods.js.map +1 -1
- package/crud/createContentReviewMethods.d.ts +2 -2
- package/crud/createContentReviewMethods.js +76 -115
- package/crud/createContentReviewMethods.js.map +1 -1
- package/crud/createReviewerMethods.d.ts +1 -1
- package/crud/createReviewerMethods.js +7 -13
- package/crud/createReviewerMethods.js.map +1 -1
- package/crud/createWorkflowMethods.d.ts +1 -1
- package/crud/createWorkflowMethods.js +7 -18
- package/crud/createWorkflowMethods.js.map +1 -1
- package/crud/index.d.ts +1 -1
- package/crud/index.js +5 -29
- package/crud/index.js.map +1 -1
- package/crud/utils.d.ts +2 -2
- package/crud/utils.js +7 -35
- package/crud/utils.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +6 -19
- package/index.js.map +1 -1
- package/package.json +32 -50
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +4 -19
- package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
- package/plugins/cms/apwEntryPlugins.d.ts +2 -2
- package/plugins/cms/apwEntryPlugins.js +18 -14
- package/plugins/cms/apwEntryPlugins.js.map +1 -1
- package/plugins/cms/index.d.ts +4 -4
- package/plugins/cms/index.js +2 -13
- package/plugins/cms/index.js.map +1 -1
- package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
- package/plugins/cms/linkContentReviewToEntry.js +4 -20
- package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
- package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
- package/plugins/cms/linkWorkflowToEntry.js +18 -46
- package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
- package/plugins/cms/notifications/changeRequestNotification.js +2 -4
- package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
- package/plugins/cms/notifications/commentNotification.js +2 -4
- package/plugins/cms/notifications/commentNotification.js.map +1 -1
- package/plugins/cms/notifications/contentReviewNotification.js +2 -4
- package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
- package/plugins/cms/notifications/contentUrl.js +3 -8
- package/plugins/cms/notifications/contentUrl.js.map +1 -1
- package/plugins/cms/triggerContentReview.d.ts +2 -2
- package/plugins/cms/triggerContentReview.js +5 -18
- package/plugins/cms/triggerContentReview.js.map +1 -1
- package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
- package/plugins/cms/updateContentReviewStatus.js +14 -30
- package/plugins/cms/updateContentReviewStatus.js.map +1 -1
- package/plugins/cms/utils.d.ts +5 -4
- package/plugins/cms/utils.js +20 -59
- package/plugins/cms/utils.js.map +1 -1
- package/plugins/context.d.ts +3 -4
- package/plugins/context.js +4 -58
- package/plugins/context.js.map +1 -1
- package/plugins/graphql/changeRequest.gql.d.ts +1 -1
- package/plugins/graphql/changeRequest.gql.js +16 -20
- package/plugins/graphql/changeRequest.gql.js.map +1 -1
- package/plugins/graphql/comment.gql.d.ts +1 -1
- package/plugins/graphql/comment.gql.js +41 -43
- package/plugins/graphql/comment.gql.js.map +1 -1
- package/plugins/graphql/contentReview.gql.d.ts +1 -1
- package/plugins/graphql/contentReview.gql.js +25 -35
- package/plugins/graphql/contentReview.gql.js.map +1 -1
- package/plugins/graphql/reviewer.gql.d.ts +1 -1
- package/plugins/graphql/reviewer.gql.js +15 -20
- package/plugins/graphql/reviewer.gql.js.map +1 -1
- package/plugins/graphql/utils.d.ts +2 -0
- package/plugins/graphql/utils.js +10 -0
- package/plugins/graphql/utils.js.map +1 -0
- package/plugins/graphql/workflow.gql.d.ts +1 -1
- package/plugins/graphql/workflow.gql.js +15 -20
- package/plugins/graphql/workflow.gql.js.map +1 -1
- package/plugins/graphql.d.ts +1 -1
- package/plugins/graphql.js +5 -18
- package/plugins/graphql.js.map +1 -1
- package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
- package/plugins/hooks/createReviewerFromIdentity.js +5 -12
- package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -9
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -8
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
- package/plugins/hooks/index.d.ts +1 -1
- package/plugins/hooks/index.js +2 -14
- package/plugins/hooks/index.js.map +1 -1
- package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
- package/plugins/hooks/initializeContentReviewSteps.js +15 -20
- package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
- package/plugins/hooks/initializeNotifications.d.ts +1 -1
- package/plugins/hooks/initializeNotifications.js +2 -5
- package/plugins/hooks/initializeNotifications.js.map +1 -1
- package/plugins/hooks/listContentReviews.d.ts +3 -3
- package/plugins/hooks/listContentReviews.js +3 -13
- package/plugins/hooks/listContentReviews.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/changeRequestAfterCreate.js +7 -38
- package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/changeRequestUrl.js +2 -4
- package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/commentAfterCreate.js +7 -40
- package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/commentUrl.js +2 -4
- package/plugins/hooks/notifications/commentUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +1 -1
- package/plugins/hooks/notifications/contentReviewAfterCreate.js +9 -35
- package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
- package/plugins/hooks/notifications/contentReviewUrl.js +2 -4
- package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
- package/plugins/hooks/notifications/contentUrl.d.ts +2 -2
- package/plugins/hooks/notifications/contentUrl.js +2 -5
- package/plugins/hooks/notifications/contentUrl.js.map +1 -1
- package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
- package/plugins/hooks/notifications/getAppUrl.js +19 -0
- package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +2 -4
- package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
- package/plugins/hooks/notifications/reviewers.d.ts +1 -1
- package/plugins/hooks/notifications/reviewers.js +17 -21
- package/plugins/hooks/notifications/reviewers.js.map +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendChangeRequestNotification.js +2 -11
- package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendCommentNotification.js +2 -11
- package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
- package/plugins/hooks/notifications/sendContentReviewNotification.js +2 -11
- package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
- package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
- package/plugins/hooks/updatePendingChangeRequests.js +7 -13
- package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
- package/plugins/hooks/updateTotalComments.d.ts +1 -1
- package/plugins/hooks/updateTotalComments.js +21 -23
- package/plugins/hooks/updateTotalComments.js.map +1 -1
- package/plugins/hooks/validateChangeRequest.d.ts +1 -1
- package/plugins/hooks/validateChangeRequest.js +2 -16
- package/plugins/hooks/validateChangeRequest.js.map +1 -1
- package/plugins/hooks/validateComment.d.ts +1 -1
- package/plugins/hooks/validateComment.js +3 -12
- package/plugins/hooks/validateComment.js.map +1 -1
- package/plugins/hooks/validateContentReview.d.ts +1 -1
- package/plugins/hooks/validateContentReview.js +2 -6
- package/plugins/hooks/validateContentReview.js.map +1 -1
- package/plugins/utils.d.ts +7 -6
- package/plugins/utils.js +11 -50
- package/plugins/utils.js.map +1 -1
- package/scheduler/createScheduleActionMethods.d.ts +1 -1
- package/scheduler/createScheduleActionMethods.js +105 -85
- package/scheduler/createScheduleActionMethods.js.map +1 -1
- package/scheduler/handlers/executeAction/index.d.ts +2 -2
- package/scheduler/handlers/executeAction/index.js +47 -41
- package/scheduler/handlers/executeAction/index.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +19 -9
- package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +3 -3
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +11 -28
- package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +4 -3
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +10 -92
- package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
- package/scheduler/handlers/executeAction/security.d.ts +2 -2
- package/scheduler/handlers/executeAction/security.js +2 -11
- package/scheduler/handlers/executeAction/security.js.map +1 -1
- package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
- package/scheduler/handlers/scheduleAction/index.js +23 -38
- package/scheduler/handlers/scheduleAction/index.js.map +1 -1
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +20 -36
- package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
- package/scheduler/handlers/utils.d.ts +2 -4
- package/scheduler/handlers/utils.js +22 -53
- package/scheduler/handlers/utils.js.map +1 -1
- package/scheduler/index.d.ts +1 -1
- package/scheduler/index.js +2 -3
- package/scheduler/index.js.map +1 -1
- package/scheduler/types.d.ts +20 -36
- package/scheduler/types.js +11 -23
- package/scheduler/types.js.map +1 -1
- package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
- package/storageOperations/changeRequestStorageOperations.js +43 -41
- package/storageOperations/changeRequestStorageOperations.js.map +1 -1
- package/storageOperations/commentStorageOperations.d.ts +3 -3
- package/storageOperations/commentStorageOperations.js +16 -44
- package/storageOperations/commentStorageOperations.js.map +1 -1
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
- package/storageOperations/contentReviewStorageOperations.js +19 -41
- package/storageOperations/contentReviewStorageOperations.js.map +1 -1
- package/storageOperations/index.d.ts +3 -9
- package/storageOperations/index.js +10 -29
- package/storageOperations/index.js.map +1 -1
- package/storageOperations/models/changeRequest.model.d.ts +1 -2
- package/storageOperations/models/changeRequest.model.js +9 -19
- package/storageOperations/models/changeRequest.model.js.map +1 -1
- package/storageOperations/models/comment.model.d.ts +1 -2
- package/storageOperations/models/comment.model.js +9 -18
- package/storageOperations/models/comment.model.js.map +1 -1
- package/storageOperations/models/contentReview.model.d.ts +1 -2
- package/storageOperations/models/contentReview.model.js +16 -41
- package/storageOperations/models/contentReview.model.js.map +1 -1
- package/storageOperations/models/index.d.ts +1 -1
- package/storageOperations/models/index.js +11 -55
- package/storageOperations/models/index.js.map +1 -1
- package/storageOperations/models/reviewer.model.d.ts +1 -2
- package/storageOperations/models/reviewer.model.js +10 -19
- package/storageOperations/models/reviewer.model.js.map +1 -1
- package/storageOperations/models/utils.d.ts +2 -2
- package/storageOperations/models/utils.js +2 -4
- package/storageOperations/models/utils.js.map +1 -1
- package/storageOperations/models/workflow.model.d.ts +2 -3
- package/storageOperations/models/workflow.model.js +22 -46
- package/storageOperations/models/workflow.model.js.map +1 -1
- package/storageOperations/reviewerStorageOperations.d.ts +3 -3
- package/storageOperations/reviewerStorageOperations.js +23 -50
- package/storageOperations/reviewerStorageOperations.js.map +1 -1
- package/storageOperations/types.d.ts +2 -2
- package/storageOperations/types.js +3 -1
- package/storageOperations/types.js.map +1 -1
- package/storageOperations/workflowStorageOperations.d.ts +2 -2
- package/storageOperations/workflowStorageOperations.js +24 -44
- package/storageOperations/workflowStorageOperations.js.map +1 -1
- package/types.d.ts +49 -64
- package/types.js +121 -43
- package/types.js.map +1 -1
- package/utils/contentApwSettingsPlugin.d.ts +2 -2
- package/utils/contentApwSettingsPlugin.js +2 -6
- package/utils/contentApwSettingsPlugin.js.map +1 -1
- package/utils/errors.js +2 -17
- package/utils/errors.js.map +1 -1
- package/utils/fieldResolver.d.ts +2 -2
- package/utils/fieldResolver.js +8 -18
- package/utils/fieldResolver.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +30 -0
- package/utils/pickEntryFieldValues.js.map +1 -0
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +2 -3
- package/utils/resolve.js.map +1 -1
- package/plugins/hooks/notifications/appUrl.d.ts +0 -2
- package/plugins/hooks/notifications/appUrl.js +0 -22
- package/plugins/hooks/notifications/appUrl.js.map +0 -1
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +0 -9
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -51
- package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +0 -1
- package/plugins/pageBuilder/apwContentPagePlugins.d.ts +0 -3
- package/plugins/pageBuilder/apwContentPagePlugins.js +0 -30
- package/plugins/pageBuilder/apwContentPagePlugins.js.map +0 -1
- package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +0 -3
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js +0 -25
- package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +0 -1
- package/plugins/pageBuilder/index.d.ts +0 -11
- package/plugins/pageBuilder/index.js +0 -53
- package/plugins/pageBuilder/index.js.map +0 -1
- package/plugins/pageBuilder/linkContentReviewToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkContentReviewToPage.js +0 -105
- package/plugins/pageBuilder/linkContentReviewToPage.js.map +0 -1
- package/plugins/pageBuilder/linkWorkflowToPage.d.ts +0 -8
- package/plugins/pageBuilder/linkWorkflowToPage.js +0 -194
- package/plugins/pageBuilder/linkWorkflowToPage.js.map +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -35
- package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/commentNotification.js +0 -35
- package/plugins/pageBuilder/notifications/commentNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -35
- package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.d.ts +0 -1
- package/plugins/pageBuilder/notifications/contentUrl.js +0 -53
- package/plugins/pageBuilder/notifications/contentUrl.js.map +0 -1
- package/plugins/pageBuilder/triggerContentReview.d.ts +0 -8
- package/plugins/pageBuilder/triggerContentReview.js +0 -50
- package/plugins/pageBuilder/triggerContentReview.js.map +0 -1
- package/plugins/pageBuilder/updateContentReviewStatus.d.ts +0 -10
- package/plugins/pageBuilder/updateContentReviewStatus.js +0 -79
- package/plugins/pageBuilder/updateContentReviewStatus.js.map +0 -1
- package/plugins/pageBuilder/utils.d.ts +0 -22
- package/plugins/pageBuilder/utils.js +0 -184
- package/plugins/pageBuilder/utils.js.map +0 -1
- package/storageOperations/models/contentModelPluginFactory.d.ts +0 -15
- package/storageOperations/models/contentModelPluginFactory.js +0 -28
- package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -1,96 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
8
6
|
exports.PageBuilderGraphQL = void 0;
|
9
|
-
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
|
12
7
|
var _ApplicationGraphQL = require("./ApplicationGraphQL");
|
13
|
-
|
14
8
|
var _types = require("../../../types");
|
15
|
-
|
16
|
-
const PB_PAGE_DATA_FIELD =
|
17
|
-
/* GraphQL */
|
18
|
-
`
|
9
|
+
const PB_PAGE_DATA_FIELD = /* GraphQL */`
|
19
10
|
{
|
20
11
|
id
|
21
|
-
pid
|
22
|
-
editor
|
23
|
-
category {
|
24
|
-
slug
|
25
|
-
}
|
26
|
-
version
|
27
|
-
title
|
28
|
-
path
|
29
|
-
url
|
30
|
-
content
|
31
|
-
savedOn
|
32
|
-
status
|
33
|
-
locked
|
34
|
-
publishedOn
|
35
|
-
locked
|
36
|
-
revisions {
|
37
|
-
id
|
38
|
-
status
|
39
|
-
locked
|
40
|
-
version
|
41
|
-
}
|
42
|
-
settings {
|
43
|
-
general {
|
44
|
-
snippet
|
45
|
-
tags
|
46
|
-
layout
|
47
|
-
image {
|
48
|
-
id
|
49
|
-
src
|
50
|
-
}
|
51
|
-
}
|
52
|
-
social {
|
53
|
-
meta {
|
54
|
-
property
|
55
|
-
content
|
56
|
-
}
|
57
|
-
title
|
58
|
-
description
|
59
|
-
image {
|
60
|
-
id
|
61
|
-
src
|
62
|
-
}
|
63
|
-
}
|
64
|
-
seo {
|
65
|
-
title
|
66
|
-
description
|
67
|
-
meta {
|
68
|
-
name
|
69
|
-
content
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
createdFrom
|
74
|
-
createdOn
|
75
|
-
createdBy {
|
76
|
-
id
|
77
|
-
displayName
|
78
|
-
type
|
79
|
-
}
|
80
12
|
}
|
81
13
|
`;
|
82
|
-
const ERROR_FIELD =
|
83
|
-
/* GraphQL */
|
84
|
-
`
|
14
|
+
const ERROR_FIELD = /* GraphQL */`
|
85
15
|
{
|
86
16
|
code
|
87
17
|
data
|
88
18
|
message
|
89
19
|
}
|
90
20
|
`;
|
91
|
-
const PUBLISH_MUTATION =
|
92
|
-
/* GraphQL */
|
93
|
-
`
|
21
|
+
const PUBLISH_MUTATION = /* GraphQL */`
|
94
22
|
mutation PublishPage($id: ID!) {
|
95
23
|
pageBuilder {
|
96
24
|
publishPage(id: $id) {
|
@@ -100,9 +28,7 @@ const PUBLISH_MUTATION =
|
|
100
28
|
}
|
101
29
|
}
|
102
30
|
`;
|
103
|
-
const UNPUBLISH_MUTATION =
|
104
|
-
/* GraphQL */
|
105
|
-
`
|
31
|
+
const UNPUBLISH_MUTATION = /* GraphQL */`
|
106
32
|
mutation UnpublishPage($id: ID!) {
|
107
33
|
pageBuilder {
|
108
34
|
unpublishPage(id: $id) {
|
@@ -112,34 +38,27 @@ const UNPUBLISH_MUTATION =
|
|
112
38
|
}
|
113
39
|
}
|
114
40
|
`;
|
115
|
-
|
116
41
|
class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
117
|
-
|
118
|
-
super(...args);
|
119
|
-
(0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.pageBuilder");
|
120
|
-
}
|
121
|
-
|
42
|
+
name = "apw.scheduler.applicationGraphQL.pageBuilder";
|
122
43
|
canUse(data) {
|
123
44
|
return data.type === _types.ApwContentTypes.PAGE;
|
124
45
|
}
|
125
|
-
|
46
|
+
getUrl() {
|
47
|
+
return `/graphql`;
|
48
|
+
}
|
126
49
|
getArn(settings) {
|
127
50
|
return settings.mainGraphqlFunctionArn;
|
128
51
|
}
|
129
|
-
|
130
52
|
getGraphQLBody(data) {
|
131
53
|
switch (data.action) {
|
132
54
|
case _types.ApwScheduleActionTypes.PUBLISH:
|
133
55
|
return this.getPublishBody(data);
|
134
|
-
|
135
56
|
case _types.ApwScheduleActionTypes.UNPUBLISH:
|
136
57
|
return this.getUnpublishBody(data);
|
137
|
-
|
138
58
|
default:
|
139
59
|
return null;
|
140
60
|
}
|
141
61
|
}
|
142
|
-
|
143
62
|
getPublishBody(data) {
|
144
63
|
return {
|
145
64
|
query: PUBLISH_MUTATION,
|
@@ -148,7 +67,6 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
148
67
|
}
|
149
68
|
};
|
150
69
|
}
|
151
|
-
|
152
70
|
getUnpublishBody(data) {
|
153
71
|
return {
|
154
72
|
query: UNPUBLISH_MUTATION,
|
@@ -157,7 +75,7 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
157
75
|
}
|
158
76
|
};
|
159
77
|
}
|
160
|
-
|
161
78
|
}
|
79
|
+
exports.PageBuilderGraphQL = PageBuilderGraphQL;
|
162
80
|
|
163
|
-
|
81
|
+
//# sourceMappingURL=PageBuilderGraphQL.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"names":["_ApplicationGraphQL","require","_types","PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","name","canUse","data","type","ApwContentTypes","PAGE","getUrl","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId","exports"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import type { ApplicationGraphQLBody, ApwScheduleActionData } from \"./ApplicationGraphQL\";\nimport { ApplicationGraphQL } from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport type { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nconst PB_PAGE_DATA_FIELD = /* GraphQL */ `\n {\n id\n }\n`;\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n code\n data\n message\n }\n`;\n\nconst PUBLISH_MUTATION = /* GraphQL */ `\n mutation PublishPage($id: ID!) {\n pageBuilder {\n publishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\nconst UNPUBLISH_MUTATION = /* GraphQL */ `\n mutation UnpublishPage($id: ID!) {\n pageBuilder {\n unpublishPage(id: $id) {\n data ${PB_PAGE_DATA_FIELD}\n error ${ERROR_FIELD}\n }\n }\n }\n`;\n\ninterface ApplicationGraphQLBodyVariables {\n id: string;\n}\n\nexport class PageBuilderGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.pageBuilder\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.PAGE;\n }\n\n public override getUrl(): string {\n return `/graphql`;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.mainGraphqlFunctionArn;\n }\n\n public override getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null {\n switch (data.action) {\n case ApwScheduleActionTypes.PUBLISH:\n return this.getPublishBody(data);\n case ApwScheduleActionTypes.UNPUBLISH:\n return this.getUnpublishBody(data);\n default:\n return null;\n }\n }\n\n private getPublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: PUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n return {\n query: UNPUBLISH_MUTATION,\n variables: {\n id: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAG,aAAc;AACzC;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAG,aAAc;AAClC;AACA;A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import { ContextPlugin } from "@webiny/api";
|
2
|
-
import { CreateApwContextParams } from "../../types";
|
3
|
-
import { ApwContext } from "../../../types";
|
2
|
+
import type { CreateApwContextParams } from "../../types";
|
3
|
+
import type { ApwContext } from "../../../types";
|
4
4
|
export declare const createCustomAuth: ({ storageOperations }: CreateApwContextParams) => ContextPlugin<ApwContext>;
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createCustomAuth = void 0;
|
7
|
-
|
8
7
|
var _api = require("@webiny/api");
|
9
|
-
|
10
8
|
var _utils = require("../utils");
|
11
|
-
|
12
9
|
const createCustomAuth = ({
|
13
10
|
storageOperations
|
14
11
|
}) => {
|
@@ -20,7 +17,6 @@ const createCustomAuth = ({
|
|
20
17
|
if (!token.startsWith(_utils.TOKEN_PREFIX)) {
|
21
18
|
return null;
|
22
19
|
}
|
23
|
-
|
24
20
|
const {
|
25
21
|
id,
|
26
22
|
tenant,
|
@@ -29,15 +25,12 @@ const createCustomAuth = ({
|
|
29
25
|
/**
|
30
26
|
* No point in going further if any piece of information is missing.
|
31
27
|
*/
|
32
|
-
|
33
28
|
if (!id || !tenant || !locale) {
|
34
29
|
return null;
|
35
30
|
}
|
36
31
|
/**
|
37
32
|
* We must verify that action we are trying to execute actually exists.
|
38
33
|
*/
|
39
|
-
|
40
|
-
|
41
34
|
const item = await storageOperations.get({
|
42
35
|
where: {
|
43
36
|
id,
|
@@ -45,11 +38,9 @@ const createCustomAuth = ({
|
|
45
38
|
locale
|
46
39
|
}
|
47
40
|
});
|
48
|
-
|
49
41
|
if (!item) {
|
50
42
|
return null;
|
51
43
|
}
|
52
|
-
|
53
44
|
hasApwToken = true;
|
54
45
|
return item.createdBy;
|
55
46
|
});
|
@@ -57,12 +48,12 @@ const createCustomAuth = ({
|
|
57
48
|
if (!hasApwToken) {
|
58
49
|
return null;
|
59
50
|
}
|
60
|
-
|
61
51
|
return [{
|
62
52
|
name: "*"
|
63
53
|
}];
|
64
54
|
});
|
65
55
|
});
|
66
56
|
};
|
57
|
+
exports.createCustomAuth = createCustomAuth;
|
67
58
|
|
68
|
-
|
59
|
+
//# sourceMappingURL=security.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createCustomAuth","storageOperations","ContextPlugin","security","hasApwToken","addAuthenticator","token","startsWith","TOKEN_PREFIX","id","tenant","locale","decodeToken","item","get","where","createdBy","addAuthorizer","name"],"sources":["security.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CreateApwContextParams } from \"~/scheduler/types\";\nimport { decodeToken, TOKEN_PREFIX } from \"~/scheduler/handlers/utils\";\nimport { ApwContext } from \"~/types\";\n\nexport const createCustomAuth = ({ storageOperations }: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(({ security }) => {\n let hasApwToken = false;\n\n security.addAuthenticator(async token => {\n if (!token.startsWith(TOKEN_PREFIX)) {\n return null;\n }\n\n const { id, tenant, locale } = decodeToken(token);\n /**\n * No point in going further if any piece of information is missing.\n */\n if (!id || !tenant || !locale) {\n return null;\n }\n /**\n * We must verify that action we are trying to execute actually exists.\n */\n const item = await storageOperations.get({\n where: {\n id,\n tenant,\n locale\n }\n });\n\n if (!item) {\n return null;\n }\n\n hasApwToken = true;\n\n return item.createdBy;\n });\n\n security.addAuthorizer(async () => {\n if (!hasApwToken) {\n return null;\n }\n return [{ name: \"*\" }];\n });\n });\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["_api","require","_utils","createCustomAuth","storageOperations","ContextPlugin","security","hasApwToken","addAuthenticator","token","startsWith","TOKEN_PREFIX","id","tenant","locale","decodeToken","item","get","where","createdBy","addAuthorizer","name","exports"],"sources":["security.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { CreateApwContextParams } from \"~/scheduler/types\";\nimport { decodeToken, TOKEN_PREFIX } from \"~/scheduler/handlers/utils\";\nimport type { ApwContext } from \"~/types\";\n\nexport const createCustomAuth = ({ storageOperations }: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(({ security }) => {\n let hasApwToken = false;\n\n security.addAuthenticator(async token => {\n if (!token.startsWith(TOKEN_PREFIX)) {\n return null;\n }\n\n const { id, tenant, locale } = decodeToken(token);\n /**\n * No point in going further if any piece of information is missing.\n */\n if (!id || !tenant || !locale) {\n return null;\n }\n /**\n * We must verify that action we are trying to execute actually exists.\n */\n const item = await storageOperations.get({\n where: {\n id,\n tenant,\n locale\n }\n });\n\n if (!item) {\n return null;\n }\n\n hasApwToken = true;\n\n return item.createdBy;\n });\n\n security.addAuthorizer(async () => {\n if (!hasApwToken) {\n return null;\n }\n return [{ name: \"*\" }];\n });\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,gBAAgB,GAAGA,CAAC;EAAEC;AAA0C,CAAC,KAAK;EAC/E,OAAO,IAAIC,kBAAa,CAAa,CAAC;IAAEC;EAAS,CAAC,KAAK;IACnD,IAAIC,WAAW,GAAG,KAAK;IAEvBD,QAAQ,CAACE,gBAAgB,CAAC,MAAMC,KAAK,IAAI;MACrC,IAAI,CAACA,KAAK,CAACC,UAAU,CAACC,mBAAY,CAAC,EAAE;QACjC,OAAO,IAAI;MACf;MAEA,MAAM;QAAEC,EAAE;QAAEC,MAAM;QAAEC;MAAO,CAAC,GAAG,IAAAC,kBAAW,EAACN,KAAK,CAAC;MACjD;AACZ;AACA;MACY,IAAI,CAACG,EAAE,IAAI,CAACC,MAAM,IAAI,CAACC,MAAM,EAAE;QAC3B,OAAO,IAAI;MACf;MACA;AACZ;AACA;MACY,MAAME,IAAI,GAAG,MAAMZ,iBAAiB,CAACa,GAAG,CAAC;QACrCC,KAAK,EAAE;UACHN,EAAE;UACFC,MAAM;UACNC;QACJ;MACJ,CAAC,CAAC;MAEF,IAAI,CAACE,IAAI,EAAE;QACP,OAAO,IAAI;MACf;MAEAT,WAAW,GAAG,IAAI;MAElB,OAAOS,IAAI,CAACG,SAAS;IACzB,CAAC,CAAC;IAEFb,QAAQ,CAACc,aAAa,CAAC,YAAY;MAC/B,IAAI,CAACb,WAAW,EAAE;QACd,OAAO,IAAI;MACf;MACA,OAAO,CAAC;QAAEc,IAAI,EAAE;MAAI,CAAC,CAAC;IAC1B,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* This logic/file should be moved somewhere else as it is relying on AWS specific stuff.
|
3
3
|
*/
|
4
|
-
import { ApwScheduleActionStorageOperations } from "../../types";
|
4
|
+
import type { ApwScheduleActionStorageOperations } from "../../types";
|
5
5
|
export declare enum InvocationTypes {
|
6
6
|
SCHEDULED = "scheduled"
|
7
7
|
}
|
@@ -19,4 +19,4 @@ export interface Configuration {
|
|
19
19
|
executeAction: string;
|
20
20
|
};
|
21
21
|
}
|
22
|
-
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/
|
22
|
+
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin<any, any>[][] | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
|
@@ -1,35 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
8
6
|
exports.scheduleActionHandlerPlugins = exports.InvocationTypes = void 0;
|
9
|
-
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
11
|
-
|
12
7
|
var _utils = require("../utils");
|
13
|
-
|
14
8
|
var _scheduleAction = require("./scheduleAction.utils");
|
15
|
-
|
16
9
|
var _handlerAws = require("@webiny/handler-aws");
|
17
|
-
|
18
10
|
/**
|
19
11
|
* This logic/file should be moved somewhere else as it is relying on AWS specific stuff.
|
20
12
|
*/
|
21
|
-
let InvocationTypes
|
22
|
-
exports.InvocationTypes = InvocationTypes;
|
23
|
-
|
24
|
-
(function (InvocationTypes) {
|
13
|
+
let InvocationTypes = exports.InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
|
25
14
|
InvocationTypes["SCHEDULED"] = "scheduled";
|
26
|
-
|
27
|
-
|
15
|
+
return InvocationTypes;
|
16
|
+
}({});
|
28
17
|
const log = console.log;
|
18
|
+
|
29
19
|
/**
|
30
20
|
* Handler that creates a cloudwatch event rule for the schedule action workflow.
|
31
21
|
*/
|
32
|
-
|
33
22
|
const createScheduleActionLambda = params => {
|
34
23
|
const {
|
35
24
|
cwClient: cloudWatchEventClient,
|
@@ -50,7 +39,6 @@ const createScheduleActionLambda = params => {
|
|
50
39
|
/**
|
51
40
|
* If invocationType is "scheduled", execute the action.
|
52
41
|
*/
|
53
|
-
|
54
42
|
if (invocationType === InvocationTypes.SCHEDULED) {
|
55
43
|
await (0, _scheduleAction.executeTask)({
|
56
44
|
args: payload,
|
@@ -59,21 +47,20 @@ const createScheduleActionLambda = params => {
|
|
59
47
|
storageOperations
|
60
48
|
});
|
61
49
|
}
|
50
|
+
|
62
51
|
/**
|
63
52
|
* Get current scheduled task from the DB.
|
64
53
|
*/
|
65
|
-
|
66
|
-
|
67
54
|
const currentTask = await storageOperations.getCurrentTask({
|
68
55
|
where: {
|
69
56
|
tenant,
|
70
57
|
locale
|
71
58
|
}
|
72
59
|
});
|
60
|
+
|
73
61
|
/**
|
74
62
|
* Get next task from the DB.
|
75
63
|
*/
|
76
|
-
|
77
64
|
const [[nextItem]] = await storageOperations.list({
|
78
65
|
where: {
|
79
66
|
tenant,
|
@@ -82,45 +69,41 @@ const createScheduleActionLambda = params => {
|
|
82
69
|
sort: ["datetime_ASC"],
|
83
70
|
limit: 1
|
84
71
|
});
|
85
|
-
|
86
72
|
if (!nextItem) {
|
87
73
|
log(`No item found.`);
|
88
74
|
return;
|
89
75
|
}
|
90
|
-
|
91
76
|
const nextTaskDatetime = nextItem.data.datetime;
|
92
77
|
const currentTaskDatetime = currentTask && currentTask.data.datetime;
|
93
|
-
|
94
78
|
if ((0, _utils.isDateTimeInNextCentury)(nextTaskDatetime)) {
|
95
79
|
log(`Already processed the task.`);
|
96
80
|
return;
|
97
81
|
}
|
98
|
-
|
99
82
|
if (!(0, _scheduleAction.shouldScheduleTask)(nextTaskDatetime, currentTaskDatetime)) {
|
100
83
|
log(`Already scheduled the task.`);
|
101
84
|
return;
|
102
85
|
}
|
103
|
-
|
104
86
|
const futureDatetime = (0, _utils.moveDateTimeToNextCentury)(nextItem.data.datetime);
|
105
87
|
/**
|
106
88
|
* Update "datetime" to a future date to mark it as scheduled.
|
107
89
|
*/
|
108
|
-
|
109
90
|
log(`Update task's datetime to `, futureDatetime);
|
110
91
|
await storageOperations.update({
|
111
|
-
item:
|
112
|
-
|
92
|
+
item: {
|
93
|
+
...nextItem,
|
94
|
+
data: {
|
95
|
+
...nextItem.data,
|
113
96
|
datetime: futureDatetime
|
114
|
-
}
|
115
|
-
}
|
116
|
-
input:
|
97
|
+
}
|
98
|
+
},
|
99
|
+
input: {
|
100
|
+
...nextItem.data,
|
117
101
|
datetime: futureDatetime
|
118
|
-
}
|
102
|
+
}
|
119
103
|
});
|
120
104
|
/**
|
121
105
|
* Restore "datetime" of current task so that it can be schedule in next cycle.
|
122
106
|
*/
|
123
|
-
|
124
107
|
if (currentTaskDatetime && (0, _utils.shouldRestoreDatetime)({
|
125
108
|
invocationType,
|
126
109
|
datetime: currentTaskDatetime
|
@@ -135,8 +118,6 @@ const createScheduleActionLambda = params => {
|
|
135
118
|
/**
|
136
119
|
* Schedule Lambda
|
137
120
|
*/
|
138
|
-
|
139
|
-
|
140
121
|
log(`Schedule Lambda Execution...`);
|
141
122
|
await (0, _scheduleAction.scheduleLambdaExecution)({
|
142
123
|
cloudWatchEventClient,
|
@@ -149,16 +130,20 @@ const createScheduleActionLambda = params => {
|
|
149
130
|
/**
|
150
131
|
* Update current task.
|
151
132
|
*/
|
152
|
-
|
153
133
|
await storageOperations.updateCurrentTask({
|
154
134
|
item: nextItem
|
155
135
|
});
|
156
136
|
} catch (ex) {
|
157
|
-
|
137
|
+
console.error("[HANDLER_CREATE_RULE] => ", JSON.stringify({
|
138
|
+
message: ex.message,
|
139
|
+
code: ex.code,
|
140
|
+
data: ex.data
|
141
|
+
}));
|
142
|
+
// TODO: Handler error. Maybe save it into DB.
|
158
143
|
}
|
159
144
|
});
|
160
145
|
};
|
161
|
-
|
162
146
|
const scheduleActionHandlerPlugins = config => [(0, _utils.basePlugins)(), createScheduleActionLambda(config)];
|
147
|
+
exports.scheduleActionHandlerPlugins = scheduleActionHandlerPlugins;
|
163
148
|
|
164
|
-
|
149
|
+
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["InvocationTypes","log","console","createScheduleActionLambda","params","cwClient","cloudWatchEventClient","storageOperations","handlers","createRawEventHandler","payload","context","lambdaContext","eventContext","locale","tenant","invocationType","SCHEDULED","executeTask","args","lambdaName","executeAction","handlerClient","currentTask","getCurrentTask","where","nextItem","list","sort","limit","nextTaskDatetime","data","datetime","currentTaskDatetime","isDateTimeInNextCentury","shouldScheduleTask","futureDatetime","moveDateTimeToNextCentury","update","item","input","shouldRestoreDatetime","restoreDateTime","task","scheduleLambdaExecution","invokedFunctionArn","updateCurrentTask","ex","scheduleActionHandlerPlugins","config","basePlugins"],"sources":["index.ts"],"sourcesContent":["/**\n * This logic/file should be moved somewhere else as it is relying on AWS specific stuff.\n */\nimport { ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport {\n isDateTimeInNextCentury,\n moveDateTimeToNextCentury,\n shouldRestoreDatetime,\n basePlugins\n} from \"~/scheduler/handlers/utils\";\nimport {\n executeTask,\n shouldScheduleTask,\n restoreDateTime,\n scheduleLambdaExecution\n} from \"./scheduleAction.utils\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n invocationType?: InvocationTypes;\n futureDatetime?: string;\n}\n\nexport interface Configuration {\n cwClient: any;\n storageOperations: ApwScheduleActionStorageOperations;\n handlers: {\n executeAction: string;\n };\n}\n\nconst log = console.log;\n\n/**\n * Handler that creates a cloudwatch event rule for the schedule action workflow.\n */\nconst createScheduleActionLambda = (params: Configuration) => {\n const { cwClient: cloudWatchEventClient, storageOperations, handlers } = params;\n\n return createRawEventHandler<HandlerArgs>(\n async ({ payload, context, lambdaContext: eventContext }) => {\n try {\n const { locale, tenant, invocationType } = payload;\n /**\n * If invocationType is \"scheduled\", execute the action.\n */\n if (invocationType === InvocationTypes.SCHEDULED) {\n await executeTask({\n args: payload,\n lambdaName: handlers.executeAction,\n handlerClient: context.handlerClient,\n storageOperations\n });\n }\n\n /**\n * Get current scheduled task from the DB.\n */\n const currentTask = await storageOperations.getCurrentTask({\n where: {\n tenant,\n locale\n }\n });\n\n /**\n * Get next task from the DB.\n */\n const [[nextItem]] = await storageOperations.list({\n where: {\n tenant,\n locale\n },\n sort: [\"datetime_ASC\"],\n limit: 1\n });\n\n if (!nextItem) {\n log(`No item found.`);\n return;\n }\n\n const nextTaskDatetime = nextItem.data.datetime;\n const currentTaskDatetime = currentTask && currentTask.data.datetime;\n\n if (isDateTimeInNextCentury(nextTaskDatetime)) {\n log(`Already processed the task.`);\n return;\n }\n\n if (!shouldScheduleTask(nextTaskDatetime, currentTaskDatetime)) {\n log(`Already scheduled the task.`);\n return;\n }\n\n const futureDatetime = moveDateTimeToNextCentury(nextItem.data.datetime);\n /**\n * Update \"datetime\" to a future date to mark it as scheduled.\n */\n log(`Update task's datetime to `, futureDatetime);\n await storageOperations.update({\n item: {\n ...nextItem,\n data: { ...nextItem.data, datetime: futureDatetime }\n },\n input: { ...nextItem.data, datetime: futureDatetime }\n });\n /**\n * Restore \"datetime\" of current task so that it can be schedule in next cycle.\n */\n if (\n currentTaskDatetime &&\n shouldRestoreDatetime({\n invocationType,\n datetime: currentTaskDatetime\n })\n ) {\n await restoreDateTime({\n tenant,\n locale,\n task: currentTask,\n storageOperations\n });\n }\n /**\n * Schedule Lambda\n */\n log(`Schedule Lambda Execution...`);\n await scheduleLambdaExecution({\n cloudWatchEventClient,\n invokedFunctionArn: eventContext.invokedFunctionArn,\n datetime: nextItem.data.datetime,\n futureDatetime: futureDatetime,\n tenant,\n locale\n });\n /**\n * Update current task.\n */\n await storageOperations.updateCurrentTask({ item: nextItem });\n } catch (ex) {\n
|
1
|
+
{"version":3,"names":["_utils","require","_scheduleAction","_handlerAws","InvocationTypes","exports","log","console","createScheduleActionLambda","params","cwClient","cloudWatchEventClient","storageOperations","handlers","createRawEventHandler","payload","context","lambdaContext","eventContext","locale","tenant","invocationType","SCHEDULED","executeTask","args","lambdaName","executeAction","handlerClient","currentTask","getCurrentTask","where","nextItem","list","sort","limit","nextTaskDatetime","data","datetime","currentTaskDatetime","isDateTimeInNextCentury","shouldScheduleTask","futureDatetime","moveDateTimeToNextCentury","update","item","input","shouldRestoreDatetime","restoreDateTime","task","scheduleLambdaExecution","invokedFunctionArn","updateCurrentTask","ex","error","JSON","stringify","message","code","scheduleActionHandlerPlugins","config","basePlugins"],"sources":["index.ts"],"sourcesContent":["/**\n * This logic/file should be moved somewhere else as it is relying on AWS specific stuff.\n */\nimport type { ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport {\n isDateTimeInNextCentury,\n moveDateTimeToNextCentury,\n shouldRestoreDatetime,\n basePlugins\n} from \"~/scheduler/handlers/utils\";\nimport {\n executeTask,\n shouldScheduleTask,\n restoreDateTime,\n scheduleLambdaExecution\n} from \"./scheduleAction.utils\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n invocationType?: InvocationTypes;\n futureDatetime?: string;\n}\n\nexport interface Configuration {\n cwClient: any;\n storageOperations: ApwScheduleActionStorageOperations;\n handlers: {\n executeAction: string;\n };\n}\n\nconst log = console.log;\n\n/**\n * Handler that creates a cloudwatch event rule for the schedule action workflow.\n */\nconst createScheduleActionLambda = (params: Configuration) => {\n const { cwClient: cloudWatchEventClient, storageOperations, handlers } = params;\n\n return createRawEventHandler<HandlerArgs>(\n async ({ payload, context, lambdaContext: eventContext }) => {\n try {\n const { locale, tenant, invocationType } = payload;\n /**\n * If invocationType is \"scheduled\", execute the action.\n */\n if (invocationType === InvocationTypes.SCHEDULED) {\n await executeTask({\n args: payload,\n lambdaName: handlers.executeAction,\n handlerClient: context.handlerClient,\n storageOperations\n });\n }\n\n /**\n * Get current scheduled task from the DB.\n */\n const currentTask = await storageOperations.getCurrentTask({\n where: {\n tenant,\n locale\n }\n });\n\n /**\n * Get next task from the DB.\n */\n const [[nextItem]] = await storageOperations.list({\n where: {\n tenant,\n locale\n },\n sort: [\"datetime_ASC\"],\n limit: 1\n });\n\n if (!nextItem) {\n log(`No item found.`);\n return;\n }\n\n const nextTaskDatetime = nextItem.data.datetime;\n const currentTaskDatetime = currentTask && currentTask.data.datetime;\n\n if (isDateTimeInNextCentury(nextTaskDatetime)) {\n log(`Already processed the task.`);\n return;\n }\n\n if (!shouldScheduleTask(nextTaskDatetime, currentTaskDatetime)) {\n log(`Already scheduled the task.`);\n return;\n }\n\n const futureDatetime = moveDateTimeToNextCentury(nextItem.data.datetime);\n /**\n * Update \"datetime\" to a future date to mark it as scheduled.\n */\n log(`Update task's datetime to `, futureDatetime);\n await storageOperations.update({\n item: {\n ...nextItem,\n data: { ...nextItem.data, datetime: futureDatetime }\n },\n input: { ...nextItem.data, datetime: futureDatetime }\n });\n /**\n * Restore \"datetime\" of current task so that it can be schedule in next cycle.\n */\n if (\n currentTaskDatetime &&\n shouldRestoreDatetime({\n invocationType,\n datetime: currentTaskDatetime\n })\n ) {\n await restoreDateTime({\n tenant,\n locale,\n task: currentTask,\n storageOperations\n });\n }\n /**\n * Schedule Lambda\n */\n log(`Schedule Lambda Execution...`);\n await scheduleLambdaExecution({\n cloudWatchEventClient,\n invokedFunctionArn: eventContext.invokedFunctionArn,\n datetime: nextItem.data.datetime,\n futureDatetime: futureDatetime,\n tenant,\n locale\n });\n /**\n * Update current task.\n */\n await storageOperations.updateCurrentTask({ item: nextItem });\n } catch (ex) {\n console.error(\n \"[HANDLER_CREATE_RULE] => \",\n JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })\n );\n // TODO: Handler error. Maybe save it into DB.\n }\n }\n );\n};\n\nexport const scheduleActionHandlerPlugins = (config: Configuration) => [\n basePlugins(),\n createScheduleActionLambda(config)\n];\n"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAD,OAAA;AAMA,IAAAE,WAAA,GAAAF,OAAA;AAhBA;AACA;AACA;AAFA,IAkBYG,eAAe,GAAAC,OAAA,CAAAD,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAoB3B,MAAME,GAAG,GAAGC,OAAO,CAACD,GAAG;;AAEvB;AACA;AACA;AACA,MAAME,0BAA0B,GAAIC,MAAqB,IAAK;EAC1D,MAAM;IAAEC,QAAQ,EAAEC,qBAAqB;IAAEC,iBAAiB;IAAEC;EAAS,CAAC,GAAGJ,MAAM;EAE/E,OAAO,IAAAK,iCAAqB,EACxB,OAAO;IAAEC,OAAO;IAAEC,OAAO;IAAEC,aAAa,EAAEC;EAAa,CAAC,KAAK;IACzD,IAAI;MACA,MAAM;QAA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,IAAAC,kBAAW,EAAC,CAAC,EACbpD,0BAA0B,CAACmD,MAAM,CAAC,CACrC;AAACtD,OAAA,CAAAqD,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ApwScheduleAction } from "../../types";
|
2
|
-
import { HandlerArgs, Configuration } from "./index";
|
3
|
-
import { ClientContext } from "@webiny/handler-client/types";
|
1
|
+
import type { ApwScheduleAction } from "../../types";
|
2
|
+
import type { HandlerArgs, Configuration } from "./index";
|
3
|
+
import type { ClientContext } from "@webiny/handler-client/types";
|
4
4
|
interface ScheduleLambdaExecutionParams extends Omit<HandlerArgs, "invocationType"> {
|
5
5
|
cloudWatchEventClient: any;
|
6
6
|
invokedFunctionArn: string;
|