@webiny/api-apw 0.0.0-unstable.97a151f74d → 0.0.0-unstable.98511f29f1

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.
Files changed (219) hide show
  1. package/ApwChangeRequestNotification.js +0 -10
  2. package/ApwChangeRequestNotification.js.map +1 -1
  3. package/ApwCommentNotification.js +0 -10
  4. package/ApwCommentNotification.js.map +1 -1
  5. package/ApwContentReviewNotification.js +0 -10
  6. package/ApwContentReviewNotification.js.map +1 -1
  7. package/ApwContentUrlPlugin.js +0 -10
  8. package/ApwContentUrlPlugin.js.map +1 -1
  9. package/ContentApwSettingsPlugin.js +0 -5
  10. package/ContentApwSettingsPlugin.js.map +1 -1
  11. package/crud/createChangeRequestMethods.js +4 -11
  12. package/crud/createChangeRequestMethods.js.map +1 -1
  13. package/crud/createCommentMethods.js +4 -12
  14. package/crud/createCommentMethods.js.map +1 -1
  15. package/crud/createContentReviewMethods.js +39 -88
  16. package/crud/createContentReviewMethods.js.map +1 -1
  17. package/crud/createReviewerMethods.js +4 -12
  18. package/crud/createReviewerMethods.js.map +1 -1
  19. package/crud/createWorkflowMethods.js +4 -17
  20. package/crud/createWorkflowMethods.js.map +1 -1
  21. package/crud/index.js +0 -25
  22. package/crud/index.js.map +1 -1
  23. package/crud/utils.js +0 -28
  24. package/crud/utils.js.map +1 -1
  25. package/index.d.ts +1 -2
  26. package/index.js +1 -15
  27. package/index.js.map +1 -1
  28. package/package.json +40 -47
  29. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +0 -15
  30. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  31. package/plugins/cms/apwEntryPlugins.js +0 -8
  32. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  33. package/plugins/cms/index.js +0 -13
  34. package/plugins/cms/index.js.map +1 -1
  35. package/plugins/cms/linkContentReviewToEntry.js +2 -19
  36. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  37. package/plugins/cms/linkWorkflowToEntry.js +9 -38
  38. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  39. package/plugins/cms/notifications/changeRequestNotification.js +0 -4
  40. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
  41. package/plugins/cms/notifications/commentNotification.js +0 -4
  42. package/plugins/cms/notifications/commentNotification.js.map +1 -1
  43. package/plugins/cms/notifications/contentReviewNotification.js +0 -4
  44. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
  45. package/plugins/cms/notifications/contentUrl.js +1 -8
  46. package/plugins/cms/notifications/contentUrl.js.map +1 -1
  47. package/plugins/cms/triggerContentReview.js +3 -17
  48. package/plugins/cms/triggerContentReview.js.map +1 -1
  49. package/plugins/cms/updateContentReviewStatus.js +4 -22
  50. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  51. package/plugins/cms/utils.js +2 -47
  52. package/plugins/cms/utils.js.map +1 -1
  53. package/plugins/context.d.ts +0 -1
  54. package/plugins/context.js +2 -47
  55. package/plugins/context.js.map +1 -1
  56. package/plugins/graphql/changeRequest.gql.js +3 -10
  57. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  58. package/plugins/graphql/comment.gql.js +3 -10
  59. package/plugins/graphql/comment.gql.js.map +1 -1
  60. package/plugins/graphql/contentReview.gql.js +6 -25
  61. package/plugins/graphql/contentReview.gql.js.map +1 -1
  62. package/plugins/graphql/reviewer.gql.js +3 -10
  63. package/plugins/graphql/reviewer.gql.js.map +1 -1
  64. package/plugins/graphql/workflow.gql.js +3 -10
  65. package/plugins/graphql/workflow.gql.js.map +1 -1
  66. package/plugins/graphql.js +3 -18
  67. package/plugins/graphql.js.map +1 -1
  68. package/plugins/hooks/createReviewerFromIdentity.js +2 -11
  69. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  70. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +1 -9
  71. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  72. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +1 -8
  73. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  74. package/plugins/hooks/index.js +0 -14
  75. package/plugins/hooks/index.js.map +1 -1
  76. package/plugins/hooks/initializeContentReviewSteps.js +10 -17
  77. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  78. package/plugins/hooks/initializeNotifications.js +0 -5
  79. package/plugins/hooks/initializeNotifications.js.map +1 -1
  80. package/plugins/hooks/listContentReviews.js +0 -12
  81. package/plugins/hooks/listContentReviews.js.map +1 -1
  82. package/plugins/hooks/notifications/appUrl.js +0 -4
  83. package/plugins/hooks/notifications/appUrl.js.map +1 -1
  84. package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -36
  85. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
  86. package/plugins/hooks/notifications/changeRequestUrl.js +0 -4
  87. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
  88. package/plugins/hooks/notifications/commentAfterCreate.js +3 -38
  89. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
  90. package/plugins/hooks/notifications/commentUrl.js +0 -4
  91. package/plugins/hooks/notifications/commentUrl.js.map +1 -1
  92. package/plugins/hooks/notifications/contentReviewAfterCreate.js +4 -32
  93. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
  94. package/plugins/hooks/notifications/contentReviewUrl.js +0 -4
  95. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
  96. package/plugins/hooks/notifications/contentUrl.js +0 -5
  97. package/plugins/hooks/notifications/contentUrl.js.map +1 -1
  98. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +0 -4
  99. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
  100. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +0 -4
  101. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
  102. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +0 -4
  103. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
  104. package/plugins/hooks/notifications/reviewers.js +15 -21
  105. package/plugins/hooks/notifications/reviewers.js.map +1 -1
  106. package/plugins/hooks/notifications/sendChangeRequestNotification.js +0 -11
  107. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
  108. package/plugins/hooks/notifications/sendCommentNotification.js +0 -11
  109. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
  110. package/plugins/hooks/notifications/sendContentReviewNotification.js +0 -11
  111. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
  112. package/plugins/hooks/updatePendingChangeRequests.js +0 -8
  113. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  114. package/plugins/hooks/updateTotalComments.js +0 -9
  115. package/plugins/hooks/updateTotalComments.js.map +1 -1
  116. package/plugins/hooks/validateChangeRequest.js +0 -16
  117. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  118. package/plugins/hooks/validateComment.js +1 -12
  119. package/plugins/hooks/validateComment.js.map +1 -1
  120. package/plugins/hooks/validateContentReview.js +0 -6
  121. package/plugins/hooks/validateContentReview.js.map +1 -1
  122. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +0 -15
  123. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  124. package/plugins/pageBuilder/apwContentPagePlugins.js +0 -4
  125. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  126. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +1 -6
  127. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  128. package/plugins/pageBuilder/index.js +0 -11
  129. package/plugins/pageBuilder/index.js.map +1 -1
  130. package/plugins/pageBuilder/linkContentReviewToPage.js +2 -18
  131. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  132. package/plugins/pageBuilder/linkWorkflowToPage.js +1 -31
  133. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  134. package/plugins/pageBuilder/notifications/changeRequestNotification.js +0 -4
  135. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
  136. package/plugins/pageBuilder/notifications/commentNotification.js +0 -4
  137. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
  138. package/plugins/pageBuilder/notifications/contentReviewNotification.js +0 -4
  139. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
  140. package/plugins/pageBuilder/notifications/contentUrl.js +1 -7
  141. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
  142. package/plugins/pageBuilder/triggerContentReview.js +0 -11
  143. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  144. package/plugins/pageBuilder/updateContentReviewStatus.js +0 -12
  145. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  146. package/plugins/pageBuilder/utils.js +1 -35
  147. package/plugins/pageBuilder/utils.js.map +1 -1
  148. package/plugins/utils.js +0 -43
  149. package/plugins/utils.js.map +1 -1
  150. package/scheduler/createScheduleActionMethods.js +3 -27
  151. package/scheduler/createScheduleActionMethods.js.map +1 -1
  152. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  153. package/scheduler/handlers/executeAction/index.js +45 -39
  154. package/scheduler/handlers/executeAction/index.js.map +1 -1
  155. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.d.ts +6 -0
  156. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +14 -5
  157. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  158. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -3
  159. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +7 -23
  160. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  161. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +2 -2
  162. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +7 -86
  163. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  164. package/scheduler/handlers/executeAction/security.js +0 -11
  165. package/scheduler/handlers/executeAction/security.js.map +1 -1
  166. package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
  167. package/scheduler/handlers/scheduleAction/index.js +13 -29
  168. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  169. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +4 -23
  170. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  171. package/scheduler/handlers/utils.d.ts +1 -2
  172. package/scheduler/handlers/utils.js +3 -41
  173. package/scheduler/handlers/utils.js.map +1 -1
  174. package/scheduler/index.js +0 -3
  175. package/scheduler/index.js.map +1 -1
  176. package/scheduler/types.d.ts +2 -20
  177. package/scheduler/types.js +12 -23
  178. package/scheduler/types.js.map +1 -1
  179. package/storageOperations/changeRequestStorageOperations.js +20 -39
  180. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  181. package/storageOperations/commentStorageOperations.js +23 -44
  182. package/storageOperations/commentStorageOperations.js.map +1 -1
  183. package/storageOperations/contentReviewStorageOperations.js +20 -37
  184. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  185. package/storageOperations/index.js +0 -14
  186. package/storageOperations/index.js.map +1 -1
  187. package/storageOperations/models/changeRequest.model.js +0 -9
  188. package/storageOperations/models/changeRequest.model.js.map +1 -1
  189. package/storageOperations/models/comment.model.js +0 -8
  190. package/storageOperations/models/comment.model.js.map +1 -1
  191. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -10
  192. package/storageOperations/models/contentModelPluginFactory.js +3 -11
  193. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  194. package/storageOperations/models/contentReview.model.js +0 -26
  195. package/storageOperations/models/contentReview.model.js.map +1 -1
  196. package/storageOperations/models/index.js +2 -28
  197. package/storageOperations/models/index.js.map +1 -1
  198. package/storageOperations/models/reviewer.model.js +0 -8
  199. package/storageOperations/models/reviewer.model.js.map +1 -1
  200. package/storageOperations/models/utils.js +0 -4
  201. package/storageOperations/models/utils.js.map +1 -1
  202. package/storageOperations/models/workflow.model.js +0 -23
  203. package/storageOperations/models/workflow.model.js.map +1 -1
  204. package/storageOperations/reviewerStorageOperations.js +23 -45
  205. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  206. package/storageOperations/workflowStorageOperations.js +20 -39
  207. package/storageOperations/workflowStorageOperations.js.map +1 -1
  208. package/types.d.ts +6 -5
  209. package/types.js +124 -42
  210. package/types.js.map +1 -1
  211. package/utils/contentApwSettingsPlugin.js +0 -6
  212. package/utils/contentApwSettingsPlugin.js.map +1 -1
  213. package/utils/errors.js +0 -17
  214. package/utils/errors.js.map +1 -1
  215. package/utils/fieldResolver.js +2 -12
  216. package/utils/fieldResolver.js.map +1 -1
  217. package/utils/resolve.d.ts +1 -1
  218. package/utils/resolve.js +0 -3
  219. 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
- var _handler = require("@webiny/handler");
19
-
12
+ var _handlerAws = require("@webiny/handler-aws");
20
13
  /**
21
14
  * Handler that execute the provided action(s) for the schedule action workflow.
22
15
  */
@@ -24,41 +17,33 @@ const createExecuteActionLambda = params => {
24
17
  const {
25
18
  storageOperations
26
19
  } = params;
27
- return (0, _handler.createEvent)(async ({
20
+ return (0, _handlerAws.createRawEventHandler)(async ({
28
21
  payload,
29
22
  context
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,21 +96,28 @@ const createExecuteActionLambda = params => {
118
96
  }));
119
97
  continue;
120
98
  }
121
-
99
+ const url = plugin.getUrl({
100
+ locale,
101
+ tenant
102
+ });
103
+ if (!url) {
104
+ console.error(`There is no url defined, in the Plugin, for type "${item.data.type}".`);
105
+ console.log(JSON.stringify(item));
106
+ continue;
107
+ }
122
108
  const body = plugin.getGraphQLBody(item.data);
123
-
124
109
  if (!body) {
125
110
  console.error(`There is no GraphQL body defined, in the Plugin, for type "${item.data.type}".`);
126
111
  console.log(JSON.stringify(item));
127
112
  continue;
128
- } // Perform the actual action call.
129
-
130
-
113
+ }
114
+ console.log(`Invoking Lambda "${name}" with url "${url}".`);
115
+ // Perform the actual action call.
131
116
  const response = await context.handlerClient.invoke({
132
117
  name,
133
118
  payload: {
134
119
  httpMethod: "POST",
135
- path: `/cms/manage/${locale}`,
120
+ path: url,
136
121
  headers: {
137
122
  ["content-type"]: "application/json",
138
123
  Authorization: (0, _utils.encodeToken)({
@@ -147,20 +132,42 @@ const createExecuteActionLambda = params => {
147
132
  },
148
133
  await: true
149
134
  });
150
-
135
+ /**
136
+ *
137
+ */
138
+ await storageOperations.delete({
139
+ locale,
140
+ tenant,
141
+ id: item.id
142
+ });
143
+ /**
144
+ * Check for the response and log the error if any.
145
+ */
151
146
  if (response !== null && response !== void 0 && response.body) {
147
+ var _response$body$data;
148
+ const error = (_response$body$data = response.body.data) === null || _response$body$data === void 0 || (_response$body$data = _response$body$data.content) === null || _response$body$data === void 0 ? void 0 : _response$body$data.error;
149
+ if (!error) {
150
+ console.log("Invoke successful.");
151
+ continue;
152
+ }
152
153
  console.log(JSON.stringify({
153
- body: response.body
154
+ error
154
155
  }, null, 2));
155
156
  continue;
156
157
  }
157
-
158
158
  console.log(JSON.stringify({
159
159
  response
160
- }, null, 2)); // TODO: Maybe update the status like error in original item in DB.
160
+ }, null, 2));
161
+
162
+ // TODO: Maybe update the status like error in original item in DB.
161
163
  }
162
- } catch (e) {
163
- log("[HANDLER_EXECUTE_ACTION] Error => ", e); // TODO: Maybe update the status like error in original item in DB.
164
+ } catch (ex) {
165
+ console.error("[HANDLER_EXECUTE_ACTION] => ", JSON.stringify({
166
+ message: ex.message,
167
+ code: ex.code,
168
+ data: ex.data
169
+ }));
170
+ // TODO: Maybe update the status like error in original item in DB.
164
171
  }
165
172
  });
166
173
  };
@@ -168,5 +175,4 @@ const createExecuteActionLambda = params => {
168
175
  const executeActionHandlerPlugins = config => [new _api.ContextPlugin(async context => {
169
176
  context.plugins.register([new _PageBuilderGraphQL.PageBuilderGraphQL(), new _HeadlessCMSGraphQL.HeadlessCMSGraphQL()]);
170
177
  }), (0, _utils.basePlugins)(), createExecuteActionLambda(config)];
171
-
172
178
  exports.executeActionHandlerPlugins = executeActionHandlerPlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["createExecuteActionLambda","params","storageOperations","createEvent","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","body","getGraphQLBody","response","handlerClient","invoke","httpMethod","path","headers","Authorization","encodeToken","id","await","e","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 { createEvent } from \"@webiny/handler\";\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 createEvent<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 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 // Perform the actual action call.\n const response = await context.handlerClient.invoke({\n name,\n payload: {\n httpMethod: \"POST\",\n path: `/cms/manage/${locale}`,\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 if (response?.body) {\n console.log(JSON.stringify({ body: response.body }, 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 (e) {\n log(\"[HANDLER_EXECUTE_ACTION] Error => \", e);\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,IAAwBD,MAA9B;EAEA,OAAO,IAAAE,oBAAA,EAAyB,OAAO;IAAEC,OAAF;IAAWC;EAAX,CAAP,KAAgC;IAC5D,MAAMC,GAAG,GAAGC,OAAO,CAACD,G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,IAAIC,sCAAJ,EAA3B,CAAzB;AACH,CAFD,CADkE,EAIlE,IAAAC,kBAAA,GAJkE,EAKlE3D,yBAAyB,CAACsD,MAAD,CALyC,CAA/D"}
1
+ {"version":3,"names":["_utils","require","_api","_PageBuilderGraphQL","_HeadlessCMSGraphQL","_ApplicationGraphQL","_handlerAws","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","_response$body$data","content","ex","message","code","executeActionHandlerPlugins","config","ContextPlugin","register","PageBuilderGraphQL","HeadlessCMSGraphQL","basePlugins","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAaA;AACA;AACA;AACA,MAAMM,yBAAyB,GAAIC,MAAqB,IAAK;EACzD,MAAM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plugin } from "@webiny/plugins/Plugin";
2
2
  import { ApwScheduleActionData } from "../../../types";
3
3
  import { ApwSettings } from "../../utils";
4
+ export { ApwScheduleActionData, ApwSettings };
5
+ export interface ApplicationGraphQLGetUrlParams {
6
+ tenant: string;
7
+ locale: string;
8
+ }
4
9
  export interface ApplicationGraphQLBody<T = Record<string, any>> {
5
10
  query: string;
6
11
  variables: T;
7
12
  }
8
13
  export declare abstract class ApplicationGraphQL extends Plugin {
9
14
  static readonly type: string;
15
+ abstract getUrl(params: ApplicationGraphQLGetUrlParams): string;
10
16
  abstract canUse(data: ApwScheduleActionData): boolean;
11
17
  abstract getArn(settings: ApwSettings): string;
12
18
  abstract getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
@@ -1,17 +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.ApplicationGraphQL = void 0;
9
-
8
+ Object.defineProperty(exports, "ApwScheduleActionData", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _types.ApwScheduleActionData;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "ApwSettings", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _utils.ApwSettings;
18
+ }
19
+ });
10
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
21
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
22
+ var _types = require("../../../types");
23
+ var _utils = require("../../utils");
14
24
  class ApplicationGraphQL extends _Plugin.Plugin {}
15
-
16
25
  exports.ApplicationGraphQL = ApplicationGraphQL;
17
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 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 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;;AASO,MAAeA,kBAAf,SAA0CC,cAA1C,CAAiD;;;8BAAlCD,kB,UAC6B,kC"}
1
+ {"version":3,"names":["_Plugin","require","_types","_utils","ApplicationGraphQL","Plugin","exports","_defineProperty2","default"],"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,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAaO,MAAeG,kBAAkB,SAASC,cAAM,CAAC;AAUvDC,OAAA,CAAAF,kBAAA,GAAAA,kBAAA;AAAA,IAAAG,gBAAA,CAAAC,OAAA,EAVqBJ,kBAAkB,UACW,kCAAkC"}
@@ -1,9 +1,8 @@
1
- import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL";
2
- import { ApwScheduleActionData } from "../../../types";
3
- import { ApwSettings } from "../../utils";
1
+ import { ApplicationGraphQL, ApplicationGraphQLBody, ApwSettings, ApplicationGraphQLGetUrlParams, ApwScheduleActionData } from "./ApplicationGraphQL";
4
2
  export declare class HeadlessCMSGraphQL extends ApplicationGraphQL {
5
3
  name: string;
6
4
  canUse(data: ApwScheduleActionData): boolean;
5
+ getUrl({ locale }: ApplicationGraphQLGetUrlParams): string;
7
6
  getArn(settings: ApwSettings): string;
8
7
  getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
9
8
  private getPublishBody;
@@ -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,41 +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
- (0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.pageBuilder");
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
-
65
+ getUrl({
66
+ locale
67
+ }) {
68
+ return `/cms/manage/${locale}`;
69
+ }
77
70
  getArn(settings) {
78
- return settings.cmsGraphqlFunctionArn;
71
+ return settings.mainGraphqlFunctionArn;
79
72
  }
80
-
81
73
  getGraphQLBody(data) {
82
74
  switch (data.action) {
83
75
  case _types.ApwScheduleActionTypes.PUBLISH:
84
76
  return this.getPublishBody(data);
85
-
86
77
  case _types.ApwScheduleActionTypes.UNPUBLISH:
87
78
  return this.getUnpublishBody(data);
88
-
89
79
  default:
90
80
  return null;
91
81
  }
92
82
  }
93
-
94
83
  getPublishBody(data) {
95
84
  if (!data.modelId) {
96
85
  throw new _error.default("Missing model ID in the schedule action data.", "SCHEDULE_ACTION_ERROR", {
97
86
  data
98
87
  });
99
88
  }
100
-
101
89
  return {
102
90
  query: createPublishMutation(data.modelId),
103
91
  variables: {
@@ -105,14 +93,12 @@ class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
105
93
  }
106
94
  };
107
95
  }
108
-
109
96
  getUnpublishBody(data) {
110
97
  if (!data.modelId) {
111
98
  throw new _error.default("Missing model ID in the schedule action data.", "SCHEDULE_ACTION_ERROR", {
112
99
  data
113
100
  });
114
101
  }
115
-
116
102
  return {
117
103
  query: createUnpublishMutation(data.modelId),
118
104
  variables: {
@@ -120,7 +106,5 @@ class HeadlessCMSGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
120
106
  }
121
107
  };
122
108
  }
123
-
124
109
  }
125
-
126
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","getArn","settings","cmsGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","WebinyError","query","variables","revision","entryId"],"sources":["HeadlessCMSGraphQL.ts"],"sourcesContent":["import { ApplicationGraphQL, ApplicationGraphQLBody } from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\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.pageBuilder\";\n\n public override canUse(data: ApwScheduleActionData): boolean {\n return data.type === ApwContentTypes.CMS_ENTRY;\n }\n\n public override getArn(settings: ApwSettings): string {\n return settings.cmsGraphqlFunctionArn;\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;;AACA;;AAEA;;AACA;;AAEA,MAAMA,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CANA;;AAQA,MAAMC,qBAAqB,GAAIC,OAAD,IAA6B;EACvD,MAAMC,cAAc,GAAG,IAAAC,mBAAA,EAAWF,OAAX,CAAvB;EAEA,OAAQ;AACZ,6BAA6BC,cAAe;AAC5C,8BAA8BA,cAAe;AAC7C;AACA;AACA;AACA,0BAA0BJ,WAAY;AACtC;AACA;AACA,wBAAwBC,WAAY;AACpC;AACA,UAXI;AAYH,CAfD;;AAiBA,MAAMK,uBAAuB,GAAIH,OAAD,IAAqB;EACjD,MAAMC,cA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EnB,uBAAuB,CAACI,IAAI,CAACP,OAAN,CAD3B;MAEHuB,SAAS,EAAE;QACPC,QAAQ,EAAEjB,IAAI,CAACkB;MADR;IAFR,CAAP;EAMH;;AA5DsD"}
1
+ {"version":3,"names":["_ApplicationGraphQL","require","_types","_error","_interopRequireDefault","_upperFirst","META_FIELDS","ERROR_FIELD","createPublishMutation","modelId","ucFirstModelId","upperFirst","createUnpublishMutation","HeadlessCMSGraphQL","ApplicationGraphQL","constructor","args","_defineProperty2","default","canUse","data","type","ApwContentTypes","CMS_ENTRY","getUrl","locale","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","WebinyError","query","variables","revision","entryId","exports"],"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,IAAAA,mBAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,MAAMK,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,WAAW,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAM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AACX,OAAO,EAAE;MACf,MAAM,IAAI2B,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACIhB;MACJ,CACJ,CAAC;IACL;IACA,OAAO;MACHiB,KAAK,EAAE7B,qBAAqB,CAACY,IAAI,CAACX,OAAO,CAAC;MAC1C6B,SAAS,EAAE;QACPC,QAAQ,EAAEnB,IAAI,CAACoB;MACnB;IACJ,CAAC;EACL;EAEQL,gBAAgBA,CACpBf,IAA2B,EAC4B;IACvD,IAAI,CAACA,IAAI,CAACX,OAAO,EAAE;MACf,MAAM,IAAI2B,cAAW,CACjB,+CAA+C,EAC/C,uBAAuB,EACvB;QACIhB;MACJ,CACJ,CAAC;IACL;IACA,OAAO;MACHiB,KAAK,EAAEzB,uBAAuB,CAACQ,IAAI,CAACX,OAAO,CAAC;MAC5C6B,SAAS,EAAE;QACPC,QAAQ,EAAEnB,IAAI,CAACoB;MACnB;IACJ,CAAC;EACL;AACJ;AAACC,OAAA,CAAA5B,kBAAA,GAAAA,kBAAA"}
@@ -1,9 +1,9 @@
1
- import { ApplicationGraphQL, ApplicationGraphQLBody } from "./ApplicationGraphQL";
2
- import { ApwScheduleActionData } from "../../../types";
1
+ import { ApplicationGraphQL, ApplicationGraphQLBody, ApwScheduleActionData } from "./ApplicationGraphQL";
3
2
  import { ApwSettings } from "../../utils";
4
3
  export declare class PageBuilderGraphQL extends ApplicationGraphQL {
5
4
  name: string;
6
5
  canUse(data: ApwScheduleActionData): boolean;
6
+ getUrl(): string;
7
7
  getArn(settings: ApwSettings): string;
8
8
  getGraphQLBody(data: ApwScheduleActionData): ApplicationGraphQLBody | null;
9
9
  private getPublishBody;
@@ -1,96 +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
- 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
14
  }
81
15
  `;
82
- const ERROR_FIELD =
83
- /* GraphQL */
84
- `
16
+ const ERROR_FIELD = /* GraphQL */`
85
17
  {
86
18
  code
87
19
  data
88
20
  message
89
21
  }
90
22
  `;
91
- const PUBLISH_MUTATION =
92
- /* GraphQL */
93
- `
23
+ const PUBLISH_MUTATION = /* GraphQL */`
94
24
  mutation PublishPage($id: ID!) {
95
25
  pageBuilder {
96
26
  publishPage(id: $id) {
@@ -100,9 +30,7 @@ const PUBLISH_MUTATION =
100
30
  }
101
31
  }
102
32
  `;
103
- const UNPUBLISH_MUTATION =
104
- /* GraphQL */
105
- `
33
+ const UNPUBLISH_MUTATION = /* GraphQL */`
106
34
  mutation UnpublishPage($id: ID!) {
107
35
  pageBuilder {
108
36
  unpublishPage(id: $id) {
@@ -112,34 +40,30 @@ const UNPUBLISH_MUTATION =
112
40
  }
113
41
  }
114
42
  `;
115
-
116
43
  class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
117
44
  constructor(...args) {
118
45
  super(...args);
119
46
  (0, _defineProperty2.default)(this, "name", "apw.scheduler.applicationGraphQL.pageBuilder");
120
47
  }
121
-
122
48
  canUse(data) {
123
49
  return data.type === _types.ApwContentTypes.PAGE;
124
50
  }
125
-
51
+ getUrl() {
52
+ return `/graphql`;
53
+ }
126
54
  getArn(settings) {
127
55
  return settings.mainGraphqlFunctionArn;
128
56
  }
129
-
130
57
  getGraphQLBody(data) {
131
58
  switch (data.action) {
132
59
  case _types.ApwScheduleActionTypes.PUBLISH:
133
60
  return this.getPublishBody(data);
134
-
135
61
  case _types.ApwScheduleActionTypes.UNPUBLISH:
136
62
  return this.getUnpublishBody(data);
137
-
138
63
  default:
139
64
  return null;
140
65
  }
141
66
  }
142
-
143
67
  getPublishBody(data) {
144
68
  return {
145
69
  query: PUBLISH_MUTATION,
@@ -148,7 +72,6 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
148
72
  }
149
73
  };
150
74
  }
151
-
152
75
  getUnpublishBody(data) {
153
76
  return {
154
77
  query: UNPUBLISH_MUTATION,
@@ -157,7 +80,5 @@ class PageBuilderGraphQL extends _ApplicationGraphQL.ApplicationGraphQL {
157
80
  }
158
81
  };
159
82
  }
160
-
161
83
  }
162
-
163
84
  exports.PageBuilderGraphQL = PageBuilderGraphQL;