@webiny/api-apw 0.0.0-unstable.d16f688daf → 0.0.0-unstable.d7f521b032

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 (217) 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 +20 -84
  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 +34 -34
  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 +0 -17
  36. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  37. package/plugins/cms/linkWorkflowToEntry.js +2 -31
  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 +0 -14
  48. package/plugins/cms/triggerContentReview.js.map +1 -1
  49. package/plugins/cms/updateContentReviewStatus.js +0 -18
  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 +1 -8
  57. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  58. package/plugins/graphql/comment.gql.js +1 -8
  59. package/plugins/graphql/comment.gql.js.map +1 -1
  60. package/plugins/graphql/contentReview.gql.js +1 -20
  61. package/plugins/graphql/contentReview.gql.js.map +1 -1
  62. package/plugins/graphql/reviewer.gql.js +1 -8
  63. package/plugins/graphql/reviewer.gql.js.map +1 -1
  64. package/plugins/graphql/workflow.gql.js +1 -8
  65. package/plugins/graphql/workflow.gql.js.map +1 -1
  66. package/plugins/graphql.js +2 -17
  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 +0 -28
  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 +0 -30
  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 +1 -24
  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 +0 -7
  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 +0 -16
  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 +1 -20
  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 +19 -34
  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 +5 -25
  168. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  169. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -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.js +0 -6
  177. package/scheduler/types.js.map +1 -1
  178. package/storageOperations/changeRequestStorageOperations.js +0 -19
  179. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  180. package/storageOperations/commentStorageOperations.js +0 -21
  181. package/storageOperations/commentStorageOperations.js.map +1 -1
  182. package/storageOperations/contentReviewStorageOperations.js +0 -17
  183. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  184. package/storageOperations/index.js +0 -14
  185. package/storageOperations/index.js.map +1 -1
  186. package/storageOperations/models/changeRequest.model.js +0 -9
  187. package/storageOperations/models/changeRequest.model.js.map +1 -1
  188. package/storageOperations/models/comment.model.js +0 -8
  189. package/storageOperations/models/comment.model.js.map +1 -1
  190. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -7
  191. package/storageOperations/models/contentModelPluginFactory.js +1 -10
  192. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  193. package/storageOperations/models/contentReview.model.js +0 -26
  194. package/storageOperations/models/contentReview.model.js.map +1 -1
  195. package/storageOperations/models/index.js +2 -26
  196. package/storageOperations/models/index.js.map +1 -1
  197. package/storageOperations/models/reviewer.model.js +0 -8
  198. package/storageOperations/models/reviewer.model.js.map +1 -1
  199. package/storageOperations/models/utils.js +0 -4
  200. package/storageOperations/models/utils.js.map +1 -1
  201. package/storageOperations/models/workflow.model.js +0 -23
  202. package/storageOperations/models/workflow.model.js.map +1 -1
  203. package/storageOperations/reviewerStorageOperations.js +0 -17
  204. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  205. package/storageOperations/workflowStorageOperations.js +0 -19
  206. package/storageOperations/workflowStorageOperations.js.map +1 -1
  207. package/types.js +0 -14
  208. package/types.js.map +1 -1
  209. package/utils/contentApwSettingsPlugin.js +0 -6
  210. package/utils/contentApwSettingsPlugin.js.map +1 -1
  211. package/utils/errors.js +0 -17
  212. package/utils/errors.js.map +1 -1
  213. package/utils/fieldResolver.js +2 -12
  214. package/utils/fieldResolver.js.map +1 -1
  215. package/utils/resolve.d.ts +1 -1
  216. package/utils/resolve.js +0 -3
  217. package/utils/resolve.js.map +1 -1
@@ -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":["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,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,cAAc,GAAG,IAAAC,mBAAA,EAAWF,OAAX,CAAvB;EAEA,OAAQ;AACZ,+BAA+BC,cAAe;AAC9C,gCAAgCA,cAAe;AAC/C;AACA;AACA;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MH;;AA5DsD"}
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;AACA;AACA,wBAAwBC,WAAY;AACpC;AACA,UAAU;AACV,CAAC;AAED,MAAMK,uBAAuB,GAAIH,OAAe,IAAK;EACjD,MAAMC,cAAc,GAAG,IAAAC,mBAAU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AuB,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,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;
@@ -1 +1 @@
1
- {"version":3,"names":["PB_PAGE_DATA_FIELD","ERROR_FIELD","PUBLISH_MUTATION","UNPUBLISH_MUTATION","PageBuilderGraphQL","ApplicationGraphQL","canUse","data","type","ApwContentTypes","PAGE","getArn","settings","mainGraphqlFunctionArn","getGraphQLBody","action","ApwScheduleActionTypes","PUBLISH","getPublishBody","UNPUBLISH","getUnpublishBody","query","variables","id","entryId"],"sources":["PageBuilderGraphQL.ts"],"sourcesContent":["import { ApplicationGraphQL, ApplicationGraphQLBody } from \"./ApplicationGraphQL\";\nimport { ApwContentTypes, ApwScheduleActionData, ApwScheduleActionTypes } from \"~/scheduler/types\";\nimport { ApwSettings } from \"~/scheduler/handlers/utils\";\n\nconst PB_PAGE_DATA_FIELD = /* GraphQL */ `\n {\n id\n pid\n editor\n category {\n slug\n }\n version\n title\n path\n url\n content\n savedOn\n status\n locked\n publishedOn\n locked\n revisions {\n id\n status\n locked\n version\n }\n settings {\n general {\n snippet\n tags\n layout\n image {\n id\n src\n }\n }\n social {\n meta {\n property\n content\n }\n title\n description\n image {\n id\n src\n }\n }\n seo {\n title\n description\n meta {\n name\n content\n }\n }\n }\n createdFrom\n createdOn\n createdBy {\n id\n displayName\n type\n }\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 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;;AACA;;AAGA,MAAMA,kBAAkB;AAAG;AAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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;;AA1CsD"}
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":";;;;;;;AAAA;;AAEA;;AAGO,MAAMA,gBAAgB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAmD;EAC/E,OAAO,IAAIC,kBAAJ,CAA8B,CAAC;IAAEC;EAAF,CAAD,KAAkB;IACnD,IAAIC,WAAW,GAAG,KAAlB;IAEAD,QAAQ,CAACE,gBAAT,CAA0B,MAAMC,KAAN,IAAe;MACrC,IAAI,CAACA,KAAK,CAACC,UAAN,CAAiBC,mBAAjB,CAAL,EAAqC;QACjC,OAAO,IAAP;MACH;;MAED,MAAM;QAAEC,EAAF;QAAMC,MAAN;QAAcC;MAAd,IAAyB,IAAAC,kBAAA,EAAYN,KAAZ,CAA/B;MACA;AACZ;AACA;;MACY,IAAI,CAACG,EAAD,IAAO,CAACC,MAAR,IAAkB,CAACC,MAAvB,EAA+B;QAC3B,OAAO,IAAP;MACH;MACD;AACZ;AACA;;;MACY,MAAME,IAAI,GAAG,MAAMZ,iBAAiB,CAACa,GAAlB,CAAsB;QACrCC,KAAK,EAAE;UACHN,EADG;UAEHC,MAFG;UAGHC;QAHG;MAD8B,CAAtB,CAAnB;;MAQA,IAAI,CAACE,IAAL,EAAW;QACP,OAAO,IAAP;MACH;;MAEDT,WAAW,GAAG,IAAd;MAEA,OAAOS,IAAI,CAACG,SAAZ;IACH,CA9BD;IAgCAb,QAAQ,CAACc,aAAT,CAAuB,YAAY;MAC/B,IAAI,CAACb,WAAL,EAAkB;QACd,OAAO,IAAP;MACH;;MACD,OAAO,CAAC;QAAEc,IAAI,EAAE;MAAR,CAAD,CAAP;IACH,CALD;EAMH,CAzCM,CAAP;AA0CH,CA3CM"}
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/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
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>)[];
@@ -1,35 +1,27 @@
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.scheduleActionHandlerPlugins = exports.InvocationTypes = void 0;
9
-
10
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
9
  var _utils = require("../utils");
13
-
14
10
  var _scheduleAction = require("./scheduleAction.utils");
15
-
16
11
  var _handlerAws = require("@webiny/handler-aws");
17
-
18
12
  /**
19
13
  * This logic/file should be moved somewhere else as it is relying on AWS specific stuff.
20
14
  */
21
15
  let InvocationTypes;
22
16
  exports.InvocationTypes = InvocationTypes;
23
-
24
17
  (function (InvocationTypes) {
25
18
  InvocationTypes["SCHEDULED"] = "scheduled";
26
19
  })(InvocationTypes || (exports.InvocationTypes = InvocationTypes = {}));
27
-
28
20
  const log = console.log;
21
+
29
22
  /**
30
23
  * Handler that creates a cloudwatch event rule for the schedule action workflow.
31
24
  */
32
-
33
25
  const createScheduleActionLambda = params => {
34
26
  const {
35
27
  cwClient: cloudWatchEventClient,
@@ -50,7 +42,6 @@ const createScheduleActionLambda = params => {
50
42
  /**
51
43
  * If invocationType is "scheduled", execute the action.
52
44
  */
53
-
54
45
  if (invocationType === InvocationTypes.SCHEDULED) {
55
46
  await (0, _scheduleAction.executeTask)({
56
47
  args: payload,
@@ -59,21 +50,20 @@ const createScheduleActionLambda = params => {
59
50
  storageOperations
60
51
  });
61
52
  }
53
+
62
54
  /**
63
55
  * Get current scheduled task from the DB.
64
56
  */
65
-
66
-
67
57
  const currentTask = await storageOperations.getCurrentTask({
68
58
  where: {
69
59
  tenant,
70
60
  locale
71
61
  }
72
62
  });
63
+
73
64
  /**
74
65
  * Get next task from the DB.
75
66
  */
76
-
77
67
  const [[nextItem]] = await storageOperations.list({
78
68
  where: {
79
69
  tenant,
@@ -82,30 +72,24 @@ const createScheduleActionLambda = params => {
82
72
  sort: ["datetime_ASC"],
83
73
  limit: 1
84
74
  });
85
-
86
75
  if (!nextItem) {
87
76
  log(`No item found.`);
88
77
  return;
89
78
  }
90
-
91
79
  const nextTaskDatetime = nextItem.data.datetime;
92
80
  const currentTaskDatetime = currentTask && currentTask.data.datetime;
93
-
94
81
  if ((0, _utils.isDateTimeInNextCentury)(nextTaskDatetime)) {
95
82
  log(`Already processed the task.`);
96
83
  return;
97
84
  }
98
-
99
85
  if (!(0, _scheduleAction.shouldScheduleTask)(nextTaskDatetime, currentTaskDatetime)) {
100
86
  log(`Already scheduled the task.`);
101
87
  return;
102
88
  }
103
-
104
89
  const futureDatetime = (0, _utils.moveDateTimeToNextCentury)(nextItem.data.datetime);
105
90
  /**
106
91
  * Update "datetime" to a future date to mark it as scheduled.
107
92
  */
108
-
109
93
  log(`Update task's datetime to `, futureDatetime);
110
94
  await storageOperations.update({
111
95
  item: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, nextItem), {}, {
@@ -120,7 +104,6 @@ const createScheduleActionLambda = params => {
120
104
  /**
121
105
  * Restore "datetime" of current task so that it can be schedule in next cycle.
122
106
  */
123
-
124
107
  if (currentTaskDatetime && (0, _utils.shouldRestoreDatetime)({
125
108
  invocationType,
126
109
  datetime: currentTaskDatetime
@@ -135,8 +118,6 @@ const createScheduleActionLambda = params => {
135
118
  /**
136
119
  * Schedule Lambda
137
120
  */
138
-
139
-
140
121
  log(`Schedule Lambda Execution...`);
141
122
  await (0, _scheduleAction.scheduleLambdaExecution)({
142
123
  cloudWatchEventClient,
@@ -149,16 +130,15 @@ const createScheduleActionLambda = params => {
149
130
  /**
150
131
  * Update current task.
151
132
  */
152
-
153
133
  await storageOperations.updateCurrentTask({
154
134
  item: nextItem
155
135
  });
156
136
  } catch (ex) {
157
- log("[HANDLER_CREATE_RULE] Error => ", ex); // TODO: Handler error. Maybe save it into DB.
137
+ log("[HANDLER_CREATE_RULE] Error => ", ex);
138
+ // TODO: Handler error. Maybe save it into DB.
158
139
  }
159
140
  });
160
141
  };
161
142
 
162
143
  const scheduleActionHandlerPlugins = config => [(0, _utils.basePlugins)(), createScheduleActionLambda(config)];
163
-
164
144
  exports.scheduleActionHandlerPlugins = scheduleActionHandlerPlugins;