@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
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.executeActionHandlerPlugins = void 0;
|
7
|
-
|
8
7
|
var _utils = require("../utils");
|
9
|
-
|
10
8
|
var _api = require("@webiny/api");
|
11
|
-
|
12
9
|
var _PageBuilderGraphQL = require("./plugins/PageBuilderGraphQL");
|
13
|
-
|
14
10
|
var _HeadlessCMSGraphQL = require("./plugins/HeadlessCMSGraphQL");
|
15
|
-
|
16
11
|
var _ApplicationGraphQL = require("./plugins/ApplicationGraphQL");
|
17
|
-
|
18
12
|
var _handlerAws = require("@webiny/handler-aws");
|
19
|
-
|
20
13
|
/**
|
21
14
|
* Handler that execute the provided action(s) for the schedule action workflow.
|
22
15
|
*/
|
@@ -30,35 +23,27 @@ const createExecuteActionLambda = params => {
|
|
30
23
|
}) => {
|
31
24
|
const log = console.log;
|
32
25
|
const applicationGraphQLPlugins = context.plugins.byType(_ApplicationGraphQL.ApplicationGraphQL.type);
|
33
|
-
|
34
26
|
if (applicationGraphQLPlugins.length === 0) {
|
35
27
|
console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);
|
36
28
|
return;
|
37
29
|
}
|
38
|
-
|
39
30
|
const applicationGraphQLPluginCache = {};
|
40
|
-
|
41
31
|
const getApplicationGraphQLPlugin = data => {
|
42
32
|
const {
|
43
33
|
type
|
44
34
|
} = data;
|
45
|
-
|
46
35
|
if (applicationGraphQLPluginCache[type]) {
|
47
36
|
return applicationGraphQLPluginCache[type];
|
48
37
|
}
|
49
|
-
|
50
38
|
for (const plugin of applicationGraphQLPlugins) {
|
51
39
|
if (!plugin.canUse(data)) {
|
52
40
|
continue;
|
53
41
|
}
|
54
|
-
|
55
42
|
applicationGraphQLPluginCache[type] = plugin;
|
56
43
|
return plugin;
|
57
44
|
}
|
58
|
-
|
59
45
|
return null;
|
60
46
|
};
|
61
|
-
|
62
47
|
try {
|
63
48
|
const apwSettings = await (0, _utils.getApwSettings)();
|
64
49
|
const {
|
@@ -69,16 +54,14 @@ const createExecuteActionLambda = params => {
|
|
69
54
|
/**
|
70
55
|
* If there is no datetime we bail out early.
|
71
56
|
*/
|
72
|
-
|
73
57
|
if (!datetime || typeof datetime !== "string") {
|
74
58
|
log(`Bailing out!!`);
|
75
59
|
return;
|
76
60
|
}
|
61
|
+
|
77
62
|
/**
|
78
63
|
* Get tasks from the DB by datetime.
|
79
64
|
*/
|
80
|
-
|
81
|
-
|
82
65
|
const [items] = await storageOperations.list({
|
83
66
|
where: {
|
84
67
|
tenant,
|
@@ -88,28 +71,23 @@ const createExecuteActionLambda = params => {
|
|
88
71
|
sort: ["datetime_ASC"],
|
89
72
|
limit: 1000
|
90
73
|
});
|
74
|
+
|
91
75
|
/**
|
92
76
|
* Execute all actions.
|
93
77
|
*/
|
94
|
-
|
95
78
|
if (!items || items.length === 0) {
|
96
79
|
return;
|
97
80
|
}
|
98
|
-
|
99
81
|
log(`Found ${items.length} actions.`);
|
100
|
-
|
101
82
|
for (const item of items) {
|
102
83
|
log(`Performing mutation "${item.data.action}" on "${item.data.type}" at "${item.data.datetime}"`);
|
103
84
|
const plugin = getApplicationGraphQLPlugin(item.data);
|
104
|
-
|
105
85
|
if (!plugin) {
|
106
86
|
console.error(`There is no plugin to determine GraphQL endpoint and mutations for type "${item.data.type}".`);
|
107
87
|
console.log(JSON.stringify(item));
|
108
88
|
continue;
|
109
89
|
}
|
110
|
-
|
111
90
|
const name = plugin.getArn(apwSettings);
|
112
|
-
|
113
91
|
if (!name) {
|
114
92
|
console.error(`There is no FunctionName found for type "${item.data.type}".`);
|
115
93
|
console.log(JSON.stringify({
|
@@ -118,28 +96,23 @@ const createExecuteActionLambda = params => {
|
|
118
96
|
}));
|
119
97
|
continue;
|
120
98
|
}
|
121
|
-
|
122
99
|
const url = plugin.getUrl({
|
123
100
|
locale,
|
124
101
|
tenant
|
125
102
|
});
|
126
|
-
|
127
103
|
if (!url) {
|
128
104
|
console.error(`There is no url defined, in the Plugin, for type "${item.data.type}".`);
|
129
105
|
console.log(JSON.stringify(item));
|
130
106
|
continue;
|
131
107
|
}
|
132
|
-
|
133
108
|
const body = plugin.getGraphQLBody(item.data);
|
134
|
-
|
135
109
|
if (!body) {
|
136
110
|
console.error(`There is no GraphQL body defined, in the Plugin, for type "${item.data.type}".`);
|
137
111
|
console.log(JSON.stringify(item));
|
138
112
|
continue;
|
139
113
|
}
|
140
|
-
|
141
|
-
|
142
|
-
|
114
|
+
console.log(`Invoking Lambda "${name}" with url "${url}".`);
|
115
|
+
// Perform the actual action call.
|
143
116
|
const response = await context.handlerClient.invoke({
|
144
117
|
name,
|
145
118
|
payload: {
|
@@ -162,7 +135,6 @@ const createExecuteActionLambda = params => {
|
|
162
135
|
/**
|
163
136
|
*
|
164
137
|
*/
|
165
|
-
|
166
138
|
await storageOperations.delete({
|
167
139
|
locale,
|
168
140
|
tenant,
|
@@ -171,33 +143,31 @@ const createExecuteActionLambda = params => {
|
|
171
143
|
/**
|
172
144
|
* Check for the response and log the error if any.
|
173
145
|
*/
|
174
|
-
|
175
146
|
if (response !== null && response !== void 0 && response.body) {
|
176
147
|
var _response$body$data, _response$body$data$c;
|
177
|
-
|
178
148
|
const error = (_response$body$data = response.body.data) === null || _response$body$data === void 0 ? void 0 : (_response$body$data$c = _response$body$data.content) === null || _response$body$data$c === void 0 ? void 0 : _response$body$data$c.error;
|
179
|
-
|
180
149
|
if (!error) {
|
181
150
|
console.log("Invoke successful.");
|
182
151
|
continue;
|
183
152
|
}
|
184
|
-
|
185
153
|
console.log(JSON.stringify({
|
186
154
|
error
|
187
155
|
}, null, 2));
|
188
156
|
continue;
|
189
157
|
}
|
190
|
-
|
191
158
|
console.log(JSON.stringify({
|
192
159
|
response
|
193
|
-
}, null, 2));
|
160
|
+
}, null, 2));
|
161
|
+
|
162
|
+
// TODO: Maybe update the status like error in original item in DB.
|
194
163
|
}
|
195
164
|
} catch (ex) {
|
196
165
|
console.error("[HANDLER_EXECUTE_ACTION] => ", JSON.stringify({
|
197
166
|
message: ex.message,
|
198
167
|
code: ex.code,
|
199
168
|
data: ex.data
|
200
|
-
}));
|
169
|
+
}));
|
170
|
+
// TODO: Maybe update the status like error in original item in DB.
|
201
171
|
}
|
202
172
|
});
|
203
173
|
};
|
@@ -205,5 +175,4 @@ const createExecuteActionLambda = params => {
|
|
205
175
|
const executeActionHandlerPlugins = config => [new _api.ContextPlugin(async context => {
|
206
176
|
context.plugins.register([new _PageBuilderGraphQL.PageBuilderGraphQL(), new _HeadlessCMSGraphQL.HeadlessCMSGraphQL()]);
|
207
177
|
}), (0, _utils.basePlugins)(), createExecuteActionLambda(config)];
|
208
|
-
|
209
178
|
exports.executeActionHandlerPlugins = executeActionHandlerPlugins;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createExecuteActionLambda","params","storageOperations","createRawEventHandler","payload","context","log","console","applicationGraphQLPlugins","plugins","byType","ApplicationGraphQL","type","length","error","applicationGraphQLPluginCache","getApplicationGraphQLPlugin","data","plugin","canUse","apwSettings","getApwSettings","futureDatetime","datetime","locale","tenant","items","list","where","datetime_startsWith","getIsoStringTillMinutes","sort","limit","item","action","JSON","stringify","name","getArn","settings","url","getUrl","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","path","headers","Authorization","encodeToken","id","await","delete","content","ex","message","code","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins"],"sources":["index.ts"],"sourcesContent":["import { ApwScheduleActionData, ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport { getIsoStringTillMinutes, encodeToken, basePlugins } from \"~/scheduler/handlers/utils\";\nimport { getApwSettings } from \"~/scheduler/handlers/utils\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { PageBuilderGraphQL } from \"./plugins/PageBuilderGraphQL\";\nimport { HeadlessCMSGraphQL } from \"./plugins/HeadlessCMSGraphQL\";\nimport { ApplicationGraphQL } from \"./plugins/ApplicationGraphQL\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n futureDatetime?: string;\n}\n\ninterface Configuration {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\n/**\n * Handler that execute the provided action(s) for the schedule action workflow.\n */\nconst createExecuteActionLambda = (params: Configuration) => {\n const { storageOperations } = params;\n\n return createRawEventHandler<HandlerArgs>(async ({ payload, context }) => {\n const log = console.log;\n\n const applicationGraphQLPlugins = context.plugins.byType<ApplicationGraphQL>(\n ApplicationGraphQL.type\n );\n\n if (applicationGraphQLPlugins.length === 0) {\n console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);\n return;\n }\n\n const applicationGraphQLPluginCache: Record<string, ApplicationGraphQL> = {};\n\n const getApplicationGraphQLPlugin = (\n data: ApwScheduleActionData\n ): ApplicationGraphQL | null => {\n const { type } = data;\n if (applicationGraphQLPluginCache[type]) {\n return applicationGraphQLPluginCache[type];\n }\n for (const plugin of applicationGraphQLPlugins) {\n if (!plugin.canUse(data)) {\n continue;\n }\n applicationGraphQLPluginCache[type] = plugin;\n return plugin;\n }\n return null;\n };\n\n try {\n const apwSettings = await getApwSettings();\n\n const { futureDatetime: datetime, locale, tenant } = payload;\n /**\n * If there is no datetime we bail out early.\n */\n if (!datetime || typeof datetime !== \"string\") {\n log(`Bailing out!!`);\n return;\n }\n\n /**\n * Get tasks from the DB by datetime.\n */\n const [items] = await storageOperations.list({\n where: {\n tenant,\n locale,\n datetime_startsWith: getIsoStringTillMinutes(datetime)\n },\n sort: [\"datetime_ASC\"],\n limit: 1000\n });\n\n /**\n * Execute all actions.\n */\n if (!items || items.length === 0) {\n return;\n }\n log(`Found ${items.length} actions.`);\n for (const item of items) {\n log(\n `Performing mutation \"${item.data.action}\" on \"${item.data.type}\" at \"${item.data.datetime}\"`\n );\n\n const plugin = getApplicationGraphQLPlugin(item.data);\n if (!plugin) {\n console.error(\n `There is no plugin to determine GraphQL endpoint and mutations for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const name = plugin.getArn(apwSettings);\n if (!name) {\n console.error(`There is no FunctionName found for type \"${item.data.type}\".`);\n console.log(\n JSON.stringify({\n item,\n settings: apwSettings\n })\n );\n continue;\n }\n\n const url = plugin.getUrl({\n locale,\n tenant\n });\n if (!url) {\n console.error(\n `There is no url defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const body = plugin.getGraphQLBody(item.data);\n\n if (!body) {\n console.error(\n `There is no GraphQL body defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n console.log(`Invoking Lambda \"${name}\" with url \"${url}\".`);\n // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n path: url,\n headers: {\n [\"content-type\"]: \"application/json\",\n Authorization: encodeToken({\n id: item.id,\n locale: item.locale,\n tenant: item.tenant\n }),\n [\"x-tenant\"]: tenant,\n [\"x-i18n-locale\"]: `default:${locale};content:${locale};`\n },\n body: JSON.stringify(body)\n },\n await: true\n });\n /**\n *\n */\n await storageOperations.delete({\n locale,\n tenant,\n id: item.id\n });\n /**\n * Check for the response and log the error if any.\n */\n if (response?.body) {\n const error = response.body.data?.content?.error;\n if (!error) {\n console.log(\"Invoke successful.\");\n continue;\n }\n console.log(JSON.stringify({ error }, null, 2));\n continue;\n }\n console.log(JSON.stringify({ response }, null, 2));\n\n // TODO: Maybe update the status like error in original item in DB.\n }\n } catch (ex) {\n console.error(\n \"[HANDLER_EXECUTE_ACTION] => \",\n JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })\n );\n // TODO: Maybe update the status like error in original item in DB.\n }\n });\n};\n\nexport const executeActionHandlerPlugins = (config: Configuration) => [\n new ContextPlugin(async context => {\n context.plugins.register([new PageBuilderGraphQL(), new HeadlessCMSGraphQL()]);\n }),\n basePlugins(),\n createExecuteActionLambda(config)\n];\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAaA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAIC,MAAD,IAA2B;EACzD,MAAM;IAAEC;EAAF,IA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AAJ,eAAIA,QAAQ,CAAEF,IAAd,EAAoB;UAAA;;UAChB,MAAM5B,KAAK,0BAAG8B,QAAQ,CAACF,IAAT,CAAczB,IAAjB,iFAAG,oBAAoBsC,OAAvB,0DAAG,sBAA6BzC,KAA3C;;UACA,IAAI,CAACA,KAAL,EAAY;YACRP,OAAO,CAACD,GAAR,CAAY,oBAAZ;YACA;UACH;;UACDC,OAAO,CAACD,GAAR,CAAY6B,IAAI,CAACC,SAAL,CAAe;YAAEtB;UAAF,CAAf,EAA0B,IAA1B,EAAgC,CAAhC,CAAZ;UACA;QACH;;QACDP,OAAO,CAACD,GAAR,CAAY6B,IAAI,CAACC,SAAL,CAAe;UAAEQ;QAAF,CAAf,EAA6B,IAA7B,EAAmC,CAAnC,CAAZ,EAzFsB,CA2FtB;MACH;IACJ,CA7HD,CA6HE,OAAOY,EAAP,EAAW;MACTjD,OAAO,CAACO,KAAR,CACI,8BADJ,EAEIqB,IAAI,CAACC,SAAL,CAAe;QACXqB,OAAO,EAAED,EAAE,CAACC,OADD;QAEXC,IAAI,EAAEF,EAAE,CAACE,IAFE;QAGXzC,IAAI,EAAEuC,EAAE,CAACvC;MAHE,CAAf,CAFJ,EADS,CAST;IACH;EACJ,CAvKM,CAAP;AAwKH,CA3KD;;AA6KO,MAAM0C,2BAA2B,GAAIC,MAAD,IAA2B,CAClE,IAAIC,kBAAJ,CAAkB,MAAMxD,OAAN,IAAiB;EAC/BA,OAAO,CAACI,OAAR,CAAgBqD,QAAhB,CAAyB,CAAC,IAAIC,sCAAJ,EAAD,EAA2B,IAAIC,sCAAJ,EAA3B,CAAzB;AACH,CAFD,CADkE,EAIlE,IAAAC,kBAAA,GAJkE,EAKlEjE,yBAAyB,CAAC4D,MAAD,CALyC,CAA/D"}
|
1
|
+
{"version":3,"names":["createExecuteActionLambda","params","storageOperations","createRawEventHandler","payload","context","log","console","applicationGraphQLPlugins","plugins","byType","ApplicationGraphQL","type","length","error","applicationGraphQLPluginCache","getApplicationGraphQLPlugin","data","plugin","canUse","apwSettings","getApwSettings","futureDatetime","datetime","locale","tenant","items","list","where","datetime_startsWith","getIsoStringTillMinutes","sort","limit","item","action","JSON","stringify","name","getArn","settings","url","getUrl","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","path","headers","Authorization","encodeToken","id","await","delete","content","ex","message","code","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins"],"sources":["index.ts"],"sourcesContent":["import { ApwScheduleActionData, ApwScheduleActionStorageOperations } from \"~/scheduler/types\";\nimport { getIsoStringTillMinutes, encodeToken, basePlugins } from \"~/scheduler/handlers/utils\";\nimport { getApwSettings } from \"~/scheduler/handlers/utils\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { PageBuilderGraphQL } from \"./plugins/PageBuilderGraphQL\";\nimport { HeadlessCMSGraphQL } from \"./plugins/HeadlessCMSGraphQL\";\nimport { ApplicationGraphQL } from \"./plugins/ApplicationGraphQL\";\nimport { createRawEventHandler } from \"@webiny/handler-aws\";\n\nexport interface HandlerArgs {\n datetime: string;\n tenant: string;\n locale: string;\n futureDatetime?: string;\n}\n\ninterface Configuration {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\n/**\n * Handler that execute the provided action(s) for the schedule action workflow.\n */\nconst createExecuteActionLambda = (params: Configuration) => {\n const { storageOperations } = params;\n\n return createRawEventHandler<HandlerArgs>(async ({ payload, context }) => {\n const log = console.log;\n\n const applicationGraphQLPlugins = context.plugins.byType<ApplicationGraphQL>(\n ApplicationGraphQL.type\n );\n\n if (applicationGraphQLPlugins.length === 0) {\n console.error(`There are no plugins to determine GraphQL endpoints or mutations.`);\n return;\n }\n\n const applicationGraphQLPluginCache: Record<string, ApplicationGraphQL> = {};\n\n const getApplicationGraphQLPlugin = (\n data: ApwScheduleActionData\n ): ApplicationGraphQL | null => {\n const { type } = data;\n if (applicationGraphQLPluginCache[type]) {\n return applicationGraphQLPluginCache[type];\n }\n for (const plugin of applicationGraphQLPlugins) {\n if (!plugin.canUse(data)) {\n continue;\n }\n applicationGraphQLPluginCache[type] = plugin;\n return plugin;\n }\n return null;\n };\n\n try {\n const apwSettings = await getApwSettings();\n\n const { futureDatetime: datetime, locale, tenant } = payload;\n /**\n * If there is no datetime we bail out early.\n */\n if (!datetime || typeof datetime !== \"string\") {\n log(`Bailing out!!`);\n return;\n }\n\n /**\n * Get tasks from the DB by datetime.\n */\n const [items] = await storageOperations.list({\n where: {\n tenant,\n locale,\n datetime_startsWith: getIsoStringTillMinutes(datetime)\n },\n sort: [\"datetime_ASC\"],\n limit: 1000\n });\n\n /**\n * Execute all actions.\n */\n if (!items || items.length === 0) {\n return;\n }\n log(`Found ${items.length} actions.`);\n for (const item of items) {\n log(\n `Performing mutation \"${item.data.action}\" on \"${item.data.type}\" at \"${item.data.datetime}\"`\n );\n\n const plugin = getApplicationGraphQLPlugin(item.data);\n if (!plugin) {\n console.error(\n `There is no plugin to determine GraphQL endpoint and mutations for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const name = plugin.getArn(apwSettings);\n if (!name) {\n console.error(`There is no FunctionName found for type \"${item.data.type}\".`);\n console.log(\n JSON.stringify({\n item,\n settings: apwSettings\n })\n );\n continue;\n }\n\n const url = plugin.getUrl({\n locale,\n tenant\n });\n if (!url) {\n console.error(\n `There is no url defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n const body = plugin.getGraphQLBody(item.data);\n\n if (!body) {\n console.error(\n `There is no GraphQL body defined, in the Plugin, for type \"${item.data.type}\".`\n );\n console.log(JSON.stringify(item));\n continue;\n }\n\n console.log(`Invoking Lambda \"${name}\" with url \"${url}\".`);\n // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n path: url,\n headers: {\n [\"content-type\"]: \"application/json\",\n Authorization: encodeToken({\n id: item.id,\n locale: item.locale,\n tenant: item.tenant\n }),\n [\"x-tenant\"]: tenant,\n [\"x-i18n-locale\"]: `default:${locale};content:${locale};`\n },\n body: JSON.stringify(body)\n },\n await: true\n });\n /**\n *\n */\n await storageOperations.delete({\n locale,\n tenant,\n id: item.id\n });\n /**\n * Check for the response and log the error if any.\n */\n if (response?.body) {\n const error = response.body.data?.content?.error;\n if (!error) {\n console.log(\"Invoke successful.\");\n continue;\n }\n console.log(JSON.stringify({ error }, null, 2));\n continue;\n }\n console.log(JSON.stringify({ response }, null, 2));\n\n // TODO: Maybe update the status like error in original item in DB.\n }\n } catch (ex) {\n console.error(\n \"[HANDLER_EXECUTE_ACTION] => \",\n JSON.stringify({\n message: ex.message,\n code: ex.code,\n data: ex.data\n })\n );\n // TODO: Maybe update the status like error in original item in DB.\n }\n });\n};\n\nexport const executeActionHandlerPlugins = (config: Configuration) => [\n new ContextPlugin(async context => {\n context.plugins.register([new PageBuilderGraphQL(), new HeadlessCMSGraphQL()]);\n }),\n basePlugins(),\n createExecuteActionLambda(config)\n];\n"],"mappings":";;;;;;AACA;AAEA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAIC,MAAqB,IAAK;EACzD,MAAM;IAAEC;EAAkB,CAAC,GAAGD,MAAM;EAEpC,OAAO,IAAAE,iCAAqB,EAAc,OAAO;IAAEC,OAAO;IAAEC;EAAQ,CAAC,KAAK;IACtE,MAAMC,GAAG,GAAGC,OAAO,CAACD,GAAG;IAEvB,MAAME,yBAAyB,GAAGH,OAAO,CAACI,OAAO,CAACC,MAAM,CACpDC,sCAAkB,CAACC,IAAI,CAC1B;IAED,IAAIJ,yBAAyB,CAACK,MAAM,KAAK,CAAC,EAAE;MACxCN,OAAO,CAACO,KAAK,CAAE,mEAAkE,CAAC;MAClF;IACJ;IAEA,MAAMC,6BAAiE,GAAG,CAAC,CAAC;IAE5E,MAAMC,2BAA2B,GAC7BC,IAA2B,IACC;MAC5B,MAAM;QAAEL;MAAK,CAAC,GAAGK,IAAI;MACrB,IA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OY,EAAE,EAAE;MACTjD,OAAO,CAACO,KAAK,CACT,8BAA8B,EAC9BqB,IAAI,CAACC,SAAS,CAAC;QACXqB,OAAO,EAAED,EAAE,CAACC,OAAO;QACnBC,IAAI,EAAEF,EAAE,CAACE,IAAI;QACbzC,IAAI,EAAEuC,EAAE,CAACvC;MACb,CAAC,CAAC,CACL;MACD;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;;AAEM,MAAM0C,2BAA2B,GAAIC,MAAqB,IAAK,CAClE,IAAIC,kBAAa,CAAC,MAAMxD,OAAO,IAAI;EAC/BA,OAAO,CAACI,OAAO,CAACqD,QAAQ,CAAC,CAAC,IAAIC,sCAAkB,EAAE,EAAE,IAAIC,sCAAkB,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC,EACF,IAAAC,kBAAW,GAAE,EACbjE,yBAAyB,CAAC4D,MAAM,CAAC,CACpC;AAAC"}
|
@@ -1,7 +1,6 @@
|
|
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
|
});
|
@@ -18,16 +17,10 @@ Object.defineProperty(exports, "ApwSettings", {
|
|
18
17
|
return _utils.ApwSettings;
|
19
18
|
}
|
20
19
|
});
|
21
|
-
|
22
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
23
|
-
|
24
21
|
var _Plugin = require("@webiny/plugins/Plugin");
|
25
|
-
|
26
22
|
var _types = require("../../../types");
|
27
|
-
|
28
23
|
var _utils = require("../../utils");
|
29
|
-
|
30
24
|
class ApplicationGraphQL extends _Plugin.Plugin {}
|
31
|
-
|
32
25
|
exports.ApplicationGraphQL = ApplicationGraphQL;
|
33
26
|
(0, _defineProperty2.default)(ApplicationGraphQL, "type", "apw.scheduler.applicationGraphQL");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ApplicationGraphQL","Plugin"],"sources":["ApplicationGraphQL.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwScheduleActionData } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nexport { ApwScheduleActionData, ApwSettings };\n\nexport interface ApplicationGraphQLGetUrlParams {\n tenant: string;\n locale: string;\n}\nexport interface ApplicationGraphQLBody<T = Record<string, any>> {\n query: string;\n variables: T;\n}\n\nexport abstract class ApplicationGraphQL extends Plugin {\n public static override readonly type: string = \"apw.scheduler.applicationGraphQL\";\n\n public abstract getUrl(params: ApplicationGraphQLGetUrlParams): string;\n\n public abstract canUse(data: ApwScheduleActionData): boolean;\n\n public abstract getArn(settings: ApwSettings): string;\n\n public abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;\n}\n"],"mappings":"
|
1
|
+
{"version":3,"names":["ApplicationGraphQL","Plugin"],"sources":["ApplicationGraphQL.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { ApwScheduleActionData } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nexport { ApwScheduleActionData, ApwSettings };\n\nexport interface ApplicationGraphQLGetUrlParams {\n tenant: string;\n locale: string;\n}\nexport interface ApplicationGraphQLBody<T = Record<string, any>> {\n query: string;\n variables: T;\n}\n\nexport abstract class ApplicationGraphQL extends Plugin {\n public static override readonly type: string = \"apw.scheduler.applicationGraphQL\";\n\n public abstract getUrl(params: ApplicationGraphQLGetUrlParams): string;\n\n public abstract canUse(data: ApwScheduleActionData): boolean;\n\n public abstract getArn(settings: ApwSettings): string;\n\n public abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAaO,MAAeA,kBAAkB,SAASC,cAAM,CAAC;AAUvD;AAAA,8BAVqBD,kBAAkB,UACW,kCAAkC"}
|
@@ -1,22 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.HeadlessCMSGraphQL = void 0;
|
9
|
-
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
|
12
9
|
var _ApplicationGraphQL = require("./ApplicationGraphQL");
|
13
|
-
|
14
10
|
var _types = require("../../../types");
|
15
|
-
|
16
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
17
|
-
|
18
12
|
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
19
|
-
|
20
13
|
const META_FIELDS = `
|
21
14
|
title
|
22
15
|
publishedOn
|
@@ -31,7 +24,6 @@ const ERROR_FIELD = `
|
|
31
24
|
message
|
32
25
|
}
|
33
26
|
`;
|
34
|
-
|
35
27
|
const createPublishMutation = modelId => {
|
36
28
|
const ucFirstModelId = (0, _upperFirst.default)(modelId);
|
37
29
|
return `
|
@@ -47,7 +39,6 @@ const createPublishMutation = modelId => {
|
|
47
39
|
}
|
48
40
|
}`;
|
49
41
|
};
|
50
|
-
|
51
42
|
const createUnpublishMutation = modelId => {
|
52
43
|
const ucFirstModelId = (0, _upperFirst.default)(modelId);
|
53
44
|
return `
|
@@ -63,47 +54,38 @@ const createUnpublishMutation = modelId => {
|
|
63
54
|
}
|
64
55
|
}`;
|
65
56
|
};
|
66
|
-
|
67
57
|
class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
68
58
|
constructor(...args) {
|
69
59
|
super(...args);
|
70
60
|
(0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.headlessCms");
|
71
61
|
}
|
72
|
-
|
73
62
|
canUse(data) {
|
74
63
|
return data.type === _types.ApwContentTypes.CMS_ENTRY;
|
75
64
|
}
|
76
|
-
|
77
65
|
getUrl({
|
78
66
|
locale
|
79
67
|
}) {
|
80
68
|
return `/cms/manage/${locale}`;
|
81
69
|
}
|
82
|
-
|
83
70
|
getArn(settings) {
|
84
|
-
return settings.
|
71
|
+
return settings.mainGraphqlFunctionArn;
|
85
72
|
}
|
86
|
-
|
87
73
|
getGraphQLBody(data) {
|
88
74
|
switch (data.action) {
|
89
75
|
case _types.ApwScheduleActionTypes.PUBLISH:
|
90
76
|
return this.getPublishBody(data);
|
91
|
-
|
92
77
|
case _types.ApwScheduleActionTypes.UNPUBLISH:
|
93
78
|
return this.getUnpublishBody(data);
|
94
|
-
|
95
79
|
default:
|
96
80
|
return null;
|
97
81
|
}
|
98
82
|
}
|
99
|
-
|
100
83
|
getPublishBody(data) {
|
101
84
|
if (!data.modelId) {
|
102
85
|
throw new _error.default("Missing model ID in the schedule action data.", "SCHEDULE_ACTION_ERROR", {
|
103
86
|
data
|
104
87
|
});
|
105
88
|
}
|
106
|
-
|
107
89
|
return {
|
108
90
|
query: createPublishMutation(data.modelId),
|
109
91
|
variables: {
|
@@ -111,14 +93,12 @@ class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
111
93
|
}
|
112
94
|
};
|
113
95
|
}
|
114
|
-
|
115
96
|
getUnpublishBody(data) {
|
116
97
|
if (!data.modelId) {
|
117
98
|
throw new _error.default("Missing model ID in the schedule action data.", "SCHEDULE_ACTION_ERROR", {
|
118
99
|
data
|
119
100
|
});
|
120
101
|
}
|
121
|
-
|
122
102
|
return {
|
123
103
|
query: createUnpublishMutation(data.modelId),
|
124
104
|
variables: {
|
@@ -126,7 +106,5 @@ class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
126
106
|
}
|
127
107
|
};
|
128
108
|
}
|
129
|
-
|
130
109
|
}
|
131
|
-
|
132
110
|
exports.HeadlessCMSGraphQL = HeadlessCMSGraphQL;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["META_FIELDS","ERROR_FIELD","createPublishMutation","modelId","ucFirstModelId","upperFirst","createUnpublishMutation","HeadlessCMSGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","CMS_ENTRY","getUrl","locale","getArn","settings","
|
1
|
+
{"version":3,"names":["META_FIELDS","ERROR_FIELD","createPublishMutation","modelId","ucFirstModelId","upperFirst","createUnpublishMutation","HeadlessCMSGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","CMS_ENTRY","getUrl","locale","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","WebinyError","query","variables","revision","entryId"],"sources":["HeadlessCMSGraphQL.ts"],"sourcesContent":["import {\n ApplicationGraphQL,\n ApplicationGraphQLBody,\n ApwSettings,\n ApplicationGraphQLGetUrlParams,\n ApwScheduleActionData\n} from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport WebinyError from \"@webiny/error\";\nimport upperFirst from \"lodash/upperFirst\";\n\nconst META_FIELDS = `\n title\n publishedOn\n version\n locked\n status\n`;\n\nconst ERROR_FIELD = `\n {\n code\n data\n message\n }\n`;\n\nconst createPublishMutation = (modelId: string): string => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsPublish${ucFirstModelId}($revision: ID!) {\n content: publish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\nconst createUnpublishMutation = (modelId: string) => {\n const ucFirstModelId = upperFirst(modelId);\n\n return `\n mutation CmsUnpublish${ucFirstModelId}($revision: ID!) {\n content: unpublish${ucFirstModelId}(revision: $revision) {\n data {\n id\n meta {\n ${META_FIELDS}\n }\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\ninterface ApplicationGraphQLBodyVariables {\n revision: string;\n}\n\nexport class HeadlessCMSGraphQL extends ApplicationGraphQL {\n public override name = \"apw.scheduler.applicationGraphQL.headlessCms\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.CMS_ENTRY;\n }\n\n public override getUrl({ locale }: ApplicationGraphQLGetUrlParams): string {\n return `/cms/manage/${locale}`;\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 if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createPublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n\n private getUnpublishBody(\n data: ApwScheduleActionData\n ): ApplicationGraphQLBody<ApplicationGraphQLBodyVariables> {\n if (!data.modelId) {\n throw new WebinyError(\n \"Missing model ID in the schedule action data.\",\n \"SCHEDULE_ACTION_ERROR\",\n {\n data\n }\n );\n }\n return {\n query: createUnpublishMutation(data.modelId),\n variables: {\n revision: data.entryId\n }\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAOA;AACA;AACA;AAEA,MAAMA,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,qBAAqB,GAAIC,OAAe,IAAa;EACvD,MAAMC,cAAc,GAAG,IAAAC,mBAAU,EAACF,OAAO,CAAC;EAE1C,OAAQ;AACZ,6BAA6BC,cAAe;AAC5C,8BAA8BA,cAAe;AAC7C;AACA;AACA;AACA,0BAA0BJ,WAAY;AACtC;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;EAEQL,gBAAgB,CACpBf,IAA2B,EAC4B;IACvD,IAAI,CAACA,IAAI,CAACP,OAAO,EAAE;MACf,MAAM,IAAIuB,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACIhB;MACJ,CAAC,CACJ;IACL;IACA,OAAO;MACHiB,KAAK,EAAErB,uBAAuB,CAACI,IAAI,CAACP,OAAO,CAAC;MAC5CyB,SAAS,EAAE;QACPC,QAAQ,EAAEnB,IAAI,CAACoB;MACnB;IACJ,CAAC;EACL;AACJ;AAAC"}
|
@@ -1,37 +1,26 @@
|
|
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.PageBuilderGraphQL = void 0;
|
9
|
-
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
-
|
12
9
|
var _ApplicationGraphQL = require("./ApplicationGraphQL");
|
13
|
-
|
14
10
|
var _types = require("../../../types");
|
15
|
-
|
16
|
-
const PB_PAGE_DATA_FIELD =
|
17
|
-
/* GraphQL */
|
18
|
-
`
|
11
|
+
const PB_PAGE_DATA_FIELD = /* GraphQL */`
|
19
12
|
{
|
20
13
|
id
|
21
14
|
}
|
22
15
|
`;
|
23
|
-
const ERROR_FIELD =
|
24
|
-
/* GraphQL */
|
25
|
-
`
|
16
|
+
const ERROR_FIELD = /* GraphQL */`
|
26
17
|
{
|
27
18
|
code
|
28
19
|
data
|
29
20
|
message
|
30
21
|
}
|
31
22
|
`;
|
32
|
-
const PUBLISH_MUTATION =
|
33
|
-
/* GraphQL */
|
34
|
-
`
|
23
|
+
const PUBLISH_MUTATION = /* GraphQL */`
|
35
24
|
mutation PublishPage($id: ID!) {
|
36
25
|
pageBuilder {
|
37
26
|
publishPage(id: $id) {
|
@@ -41,9 +30,7 @@ const PUBLISH_MUTATION =
|
|
41
30
|
}
|
42
31
|
}
|
43
32
|
`;
|
44
|
-
const UNPUBLISH_MUTATION =
|
45
|
-
/* GraphQL */
|
46
|
-
`
|
33
|
+
const UNPUBLISH_MUTATION = /* GraphQL */`
|
47
34
|
mutation UnpublishPage($id: ID!) {
|
48
35
|
pageBuilder {
|
49
36
|
unpublishPage(id: $id) {
|
@@ -53,38 +40,30 @@ const UNPUBLISH_MUTATION =
|
|
53
40
|
}
|
54
41
|
}
|
55
42
|
`;
|
56
|
-
|
57
43
|
class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
58
44
|
constructor(...args) {
|
59
45
|
super(...args);
|
60
46
|
(0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.pageBuilder");
|
61
47
|
}
|
62
|
-
|
63
48
|
canUse(data) {
|
64
49
|
return data.type === _types.ApwContentTypes.PAGE;
|
65
50
|
}
|
66
|
-
|
67
51
|
getUrl() {
|
68
52
|
return `/graphql`;
|
69
53
|
}
|
70
|
-
|
71
54
|
getArn(settings) {
|
72
55
|
return settings.mainGraphqlFunctionArn;
|
73
56
|
}
|
74
|
-
|
75
57
|
getGraphQLBody(data) {
|
76
58
|
switch (data.action) {
|
77
59
|
case _types.ApwScheduleActionTypes.PUBLISH:
|
78
60
|
return this.getPublishBody(data);
|
79
|
-
|
80
61
|
case _types.ApwScheduleActionTypes.UNPUBLISH:
|
81
62
|
return this.getUnpublishBody(data);
|
82
|
-
|
83
63
|
default:
|
84
64
|
return null;
|
85
65
|
}
|
86
66
|
}
|
87
|
-
|
88
67
|
getPublishBody(data) {
|
89
68
|
return {
|
90
69
|
query: PUBLISH_MUTATION,
|
@@ -93,7 +72,6 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
93
72
|
}
|
94
73
|
};
|
95
74
|
}
|
96
|
-
|
97
75
|
getUnpublishBody(data) {
|
98
76
|
return {
|
99
77
|
query: UNPUBLISH_MUTATION,
|
@@ -102,7 +80,5 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
|
|
102
80
|
}
|
103
81
|
};
|
104
82
|
}
|
105
|
-
|
106
83
|
}
|
107
|
-
|
108
84
|
exports.PageBuilderGraphQL = PageBuilderGraphQL;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getUrl","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import {\n ApplicationGraphQL,\n ApplicationGraphQLBody,\n ApwScheduleActionData\n} from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { 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":"
|
1
|
+
{"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getUrl","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import {\n ApplicationGraphQL,\n ApplicationGraphQLBody,\n ApwScheduleActionData\n} from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { 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":";;;;;;;;AAAA;AAKA;AAGA,MAAMA,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAG,aAAe;AACnC;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,gBAAgB,GAAG,aAAe;AACxC;AACA;AACA;AACA,uBAAuBF,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAED,MAAME,kBAAkB,GAAG,aAAe;AAC1C;AACA;AACA;AACA,uBAAuBH,kBAAmB;AAC1C,wBAAwBC,WAAY;AACpC;AACA;AACA;AACA,CAAC;AAMM,MAAMG,kBAAkB,SAASC,sCAAkB,CAAC;EAAA;IAAA;IAAA,4CAChC,8CAA8C;EAAA;EAErDC,MAAM,CAACC,IAA2B,EAAW;IACzD,OAAOA,IAAI,CAACC,IAAI,KAAKC,sBAAe,CAACC,IAAI;EAC7C;EAEgBC,MAAM,GAAW;IAC7B,OAAQ,UAAS;EACrB;EAEgBC,MAAM,CAACC,QAAqB,EAAU;IAClD,OAAOA,QAAQ,CAACC,sBAAsB;EAC1C;EAEgBC,cAAc,CAACR,IAA2B,EAAiC;IACvF,QAAQA,IAAI,CAACS,MAAM;MACf,KAAKC,6BAAsB,CAACC,OAAO;QAC/B,OAAO,IAAI,CAACC,cAAc,CAACZ,IAAI,CAAC;MACpC,KAAKU,6BAAsB,CAACG,SAAS;QACjC,OAAO,IAAI,CAACC,gBAAgB,CAACd,IAAI,CAAC;MACtC;QACI,OAAO,IAAI;IAAC;EAExB;EAEQY,cAAc,CAClBZ,IAA2B,EAC4B;IACvD,OAAO;MACHe,KAAK,EAAEpB,gBAAgB;MACvBqB,SAAS,EAAE;QACPC,EAAE,EAAEjB,IAAI,CAACkB;MACb;IACJ,CAAC;EACL;EAEQJ,gBAAgB,CACpBd,IAA2B,EAC4B;IACvD,OAAO;MACHe,KAAK,EAAEnB,kBAAkB;MACzBoB,SAAS,EAAE;QACPC,EAAE,EAAEjB,IAAI,CAACkB;MACb;IACJ,CAAC;EACL;AACJ;AAAC"}
|
@@ -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,10 @@ 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
|
};
|
67
|
-
|
68
57
|
exports.createCustomAuth = createCustomAuth;
|
@@ -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":["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":";;;;;;AAAA;AAEA;AAGO,MAAMA,gBAAgB,GAAG,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;AAAC"}
|
@@ -19,4 +19,4 @@ export interface Configuration {
|
|
19
19
|
executeAction: string;
|
20
20
|
};
|
21
21
|
}
|
22
|
-
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/
|
22
|
+
export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
|