@webiny/api-apw 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.e53eceafb5

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 (310) hide show
  1. package/ApwChangeRequestNotification.d.ts +1 -1
  2. package/ApwChangeRequestNotification.js +4 -6
  3. package/ApwChangeRequestNotification.js.map +1 -1
  4. package/ApwCommentNotification.d.ts +1 -1
  5. package/ApwCommentNotification.js +4 -6
  6. package/ApwCommentNotification.js.map +1 -1
  7. package/ApwContentReviewNotification.d.ts +1 -1
  8. package/ApwContentReviewNotification.js +4 -6
  9. package/ApwContentReviewNotification.js.map +1 -1
  10. package/ApwContentUrlPlugin.d.ts +1 -1
  11. package/ApwContentUrlPlugin.js +4 -6
  12. package/ApwContentUrlPlugin.js.map +1 -1
  13. package/ContentApwSettingsPlugin.d.ts +1 -1
  14. package/ContentApwSettingsPlugin.js +5 -4
  15. package/ContentApwSettingsPlugin.js.map +1 -1
  16. package/README.md +3 -3
  17. package/crud/createChangeRequestMethods.d.ts +1 -1
  18. package/crud/createChangeRequestMethods.js +3 -1
  19. package/crud/createChangeRequestMethods.js.map +1 -1
  20. package/crud/createCommentMethods.d.ts +1 -1
  21. package/crud/createCommentMethods.js +3 -1
  22. package/crud/createCommentMethods.js.map +1 -1
  23. package/crud/createContentReviewMethods.d.ts +2 -2
  24. package/crud/createContentReviewMethods.js +57 -32
  25. package/crud/createContentReviewMethods.js.map +1 -1
  26. package/crud/createReviewerMethods.d.ts +1 -1
  27. package/crud/createReviewerMethods.js +3 -1
  28. package/crud/createReviewerMethods.js.map +1 -1
  29. package/crud/createWorkflowMethods.d.ts +1 -1
  30. package/crud/createWorkflowMethods.js +3 -1
  31. package/crud/createWorkflowMethods.js.map +1 -1
  32. package/crud/index.d.ts +1 -1
  33. package/crud/index.js +6 -5
  34. package/crud/index.js.map +1 -1
  35. package/crud/utils.d.ts +2 -2
  36. package/crud/utils.js +8 -8
  37. package/crud/utils.js.map +1 -1
  38. package/index.d.ts +2 -2
  39. package/index.js +4 -3
  40. package/index.js.map +1 -1
  41. package/package.json +32 -50
  42. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.d.ts +1 -1
  43. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js +5 -5
  44. package/plugins/cms/CmsEntryApwSettingsGetterPlugin.js.map +1 -1
  45. package/plugins/cms/apwEntryPlugins.d.ts +2 -2
  46. package/plugins/cms/apwEntryPlugins.js +19 -7
  47. package/plugins/cms/apwEntryPlugins.js.map +1 -1
  48. package/plugins/cms/index.d.ts +4 -4
  49. package/plugins/cms/index.js +3 -1
  50. package/plugins/cms/index.js.map +1 -1
  51. package/plugins/cms/linkContentReviewToEntry.d.ts +2 -2
  52. package/plugins/cms/linkContentReviewToEntry.js +5 -4
  53. package/plugins/cms/linkContentReviewToEntry.js.map +1 -1
  54. package/plugins/cms/linkWorkflowToEntry.d.ts +2 -2
  55. package/plugins/cms/linkWorkflowToEntry.js +17 -16
  56. package/plugins/cms/linkWorkflowToEntry.js.map +1 -1
  57. package/plugins/cms/notifications/changeRequestNotification.js +3 -1
  58. package/plugins/cms/notifications/changeRequestNotification.js.map +1 -1
  59. package/plugins/cms/notifications/commentNotification.js +3 -1
  60. package/plugins/cms/notifications/commentNotification.js.map +1 -1
  61. package/plugins/cms/notifications/contentReviewNotification.js +3 -1
  62. package/plugins/cms/notifications/contentReviewNotification.js.map +1 -1
  63. package/plugins/cms/notifications/contentUrl.js +3 -1
  64. package/plugins/cms/notifications/contentUrl.js.map +1 -1
  65. package/plugins/cms/triggerContentReview.d.ts +2 -2
  66. package/plugins/cms/triggerContentReview.js +6 -5
  67. package/plugins/cms/triggerContentReview.js.map +1 -1
  68. package/plugins/cms/updateContentReviewStatus.d.ts +3 -3
  69. package/plugins/cms/updateContentReviewStatus.js +15 -13
  70. package/plugins/cms/updateContentReviewStatus.js.map +1 -1
  71. package/plugins/cms/utils.d.ts +5 -4
  72. package/plugins/cms/utils.js +19 -13
  73. package/plugins/cms/utils.js.map +1 -1
  74. package/plugins/context.d.ts +2 -2
  75. package/plugins/context.js +3 -1
  76. package/plugins/context.js.map +1 -1
  77. package/plugins/graphql/changeRequest.gql.d.ts +1 -1
  78. package/plugins/graphql/changeRequest.gql.js +16 -13
  79. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  80. package/plugins/graphql/comment.gql.d.ts +1 -1
  81. package/plugins/graphql/comment.gql.js +41 -36
  82. package/plugins/graphql/comment.gql.js.map +1 -1
  83. package/plugins/graphql/contentReview.gql.d.ts +1 -1
  84. package/plugins/graphql/contentReview.gql.js +26 -17
  85. package/plugins/graphql/contentReview.gql.js.map +1 -1
  86. package/plugins/graphql/reviewer.gql.d.ts +1 -1
  87. package/plugins/graphql/reviewer.gql.js +15 -13
  88. package/plugins/graphql/reviewer.gql.js.map +1 -1
  89. package/plugins/graphql/utils.d.ts +2 -0
  90. package/plugins/graphql/utils.js +10 -0
  91. package/plugins/graphql/utils.js.map +1 -0
  92. package/plugins/graphql/workflow.gql.d.ts +1 -1
  93. package/plugins/graphql/workflow.gql.js +15 -13
  94. package/plugins/graphql/workflow.gql.js.map +1 -1
  95. package/plugins/graphql.d.ts +1 -1
  96. package/plugins/graphql.js +4 -2
  97. package/plugins/graphql.js.map +1 -1
  98. package/plugins/hooks/createReviewerFromIdentity.d.ts +1 -1
  99. package/plugins/hooks/createReviewerFromIdentity.js +4 -2
  100. package/plugins/hooks/createReviewerFromIdentity.js.map +1 -1
  101. package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +1 -1
  102. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +3 -1
  103. package/plugins/hooks/deleteChangeRequestsAfterContentReview.js.map +1 -1
  104. package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +1 -1
  105. package/plugins/hooks/deleteCommentsAfterChangeRequest.js +3 -1
  106. package/plugins/hooks/deleteCommentsAfterChangeRequest.js.map +1 -1
  107. package/plugins/hooks/index.d.ts +1 -1
  108. package/plugins/hooks/index.js +3 -1
  109. package/plugins/hooks/index.js.map +1 -1
  110. package/plugins/hooks/initializeContentReviewSteps.d.ts +1 -1
  111. package/plugins/hooks/initializeContentReviewSteps.js +6 -4
  112. package/plugins/hooks/initializeContentReviewSteps.js.map +1 -1
  113. package/plugins/hooks/initializeNotifications.d.ts +1 -1
  114. package/plugins/hooks/initializeNotifications.js +3 -1
  115. package/plugins/hooks/initializeNotifications.js.map +1 -1
  116. package/plugins/hooks/listContentReviews.d.ts +3 -3
  117. package/plugins/hooks/listContentReviews.js +4 -2
  118. package/plugins/hooks/listContentReviews.js.map +1 -1
  119. package/plugins/hooks/notifications/changeRequestAfterCreate.d.ts +1 -1
  120. package/plugins/hooks/notifications/changeRequestAfterCreate.js +8 -11
  121. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
  122. package/plugins/hooks/notifications/changeRequestUrl.js +3 -1
  123. package/plugins/hooks/notifications/changeRequestUrl.js.map +1 -1
  124. package/plugins/hooks/notifications/commentAfterCreate.d.ts +1 -1
  125. package/plugins/hooks/notifications/commentAfterCreate.js +8 -11
  126. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
  127. package/plugins/hooks/notifications/commentUrl.js +3 -1
  128. package/plugins/hooks/notifications/commentUrl.js.map +1 -1
  129. package/plugins/hooks/notifications/contentReviewAfterCreate.d.ts +1 -1
  130. package/plugins/hooks/notifications/contentReviewAfterCreate.js +9 -12
  131. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
  132. package/plugins/hooks/notifications/contentReviewUrl.js +3 -1
  133. package/plugins/hooks/notifications/contentReviewUrl.js.map +1 -1
  134. package/plugins/hooks/notifications/contentUrl.d.ts +2 -2
  135. package/plugins/hooks/notifications/contentUrl.js +3 -1
  136. package/plugins/hooks/notifications/contentUrl.js.map +1 -1
  137. package/plugins/hooks/notifications/getAppUrl.d.ts +2 -0
  138. package/plugins/hooks/notifications/getAppUrl.js +19 -0
  139. package/plugins/hooks/notifications/getAppUrl.js.map +1 -0
  140. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.d.ts +1 -1
  141. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js +3 -1
  142. package/plugins/hooks/notifications/lastChangeRequestNotificationPlugin.js.map +1 -1
  143. package/plugins/hooks/notifications/lastCommentNotificationPlugin.d.ts +1 -1
  144. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js +3 -1
  145. package/plugins/hooks/notifications/lastCommentNotificationPlugin.js.map +1 -1
  146. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.d.ts +1 -1
  147. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js +3 -1
  148. package/plugins/hooks/notifications/lastContentReviewNotificationPlugin.js.map +1 -1
  149. package/plugins/hooks/notifications/reviewers.d.ts +1 -1
  150. package/plugins/hooks/notifications/reviewers.js +18 -15
  151. package/plugins/hooks/notifications/reviewers.js.map +1 -1
  152. package/plugins/hooks/notifications/sendChangeRequestNotification.d.ts +1 -1
  153. package/plugins/hooks/notifications/sendChangeRequestNotification.js +3 -1
  154. package/plugins/hooks/notifications/sendChangeRequestNotification.js.map +1 -1
  155. package/plugins/hooks/notifications/sendCommentNotification.d.ts +1 -1
  156. package/plugins/hooks/notifications/sendCommentNotification.js +3 -1
  157. package/plugins/hooks/notifications/sendCommentNotification.js.map +1 -1
  158. package/plugins/hooks/notifications/sendContentReviewNotification.d.ts +1 -1
  159. package/plugins/hooks/notifications/sendContentReviewNotification.js +3 -1
  160. package/plugins/hooks/notifications/sendContentReviewNotification.js.map +1 -1
  161. package/plugins/hooks/updatePendingChangeRequests.d.ts +1 -1
  162. package/plugins/hooks/updatePendingChangeRequests.js +8 -6
  163. package/plugins/hooks/updatePendingChangeRequests.js.map +1 -1
  164. package/plugins/hooks/updateTotalComments.d.ts +1 -1
  165. package/plugins/hooks/updateTotalComments.js +22 -15
  166. package/plugins/hooks/updateTotalComments.js.map +1 -1
  167. package/plugins/hooks/validateChangeRequest.d.ts +1 -1
  168. package/plugins/hooks/validateChangeRequest.js +3 -1
  169. package/plugins/hooks/validateChangeRequest.js.map +1 -1
  170. package/plugins/hooks/validateComment.d.ts +1 -1
  171. package/plugins/hooks/validateComment.js +3 -1
  172. package/plugins/hooks/validateComment.js.map +1 -1
  173. package/plugins/hooks/validateContentReview.d.ts +1 -1
  174. package/plugins/hooks/validateContentReview.js +3 -1
  175. package/plugins/hooks/validateContentReview.js.map +1 -1
  176. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.d.ts +2 -1
  177. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js +5 -5
  178. package/plugins/pageBuilder/PageApwSettingsGetterPlugin.js.map +1 -1
  179. package/plugins/pageBuilder/apwContentPagePlugins.d.ts +1 -1
  180. package/plugins/pageBuilder/apwContentPagePlugins.js +3 -1
  181. package/plugins/pageBuilder/apwContentPagePlugins.js.map +1 -1
  182. package/plugins/pageBuilder/extendPbPageSettingsSchema.d.ts +1 -1
  183. package/plugins/pageBuilder/extendPbPageSettingsSchema.js +3 -1
  184. package/plugins/pageBuilder/extendPbPageSettingsSchema.js.map +1 -1
  185. package/plugins/pageBuilder/index.d.ts +4 -4
  186. package/plugins/pageBuilder/index.js +3 -1
  187. package/plugins/pageBuilder/index.js.map +1 -1
  188. package/plugins/pageBuilder/linkContentReviewToPage.d.ts +2 -2
  189. package/plugins/pageBuilder/linkContentReviewToPage.js +16 -12
  190. package/plugins/pageBuilder/linkContentReviewToPage.js.map +1 -1
  191. package/plugins/pageBuilder/linkWorkflowToPage.d.ts +2 -2
  192. package/plugins/pageBuilder/linkWorkflowToPage.js +13 -12
  193. package/plugins/pageBuilder/linkWorkflowToPage.js.map +1 -1
  194. package/plugins/pageBuilder/notifications/changeRequestNotification.js +3 -1
  195. package/plugins/pageBuilder/notifications/changeRequestNotification.js.map +1 -1
  196. package/plugins/pageBuilder/notifications/commentNotification.js +3 -1
  197. package/plugins/pageBuilder/notifications/commentNotification.js.map +1 -1
  198. package/plugins/pageBuilder/notifications/contentReviewNotification.js +3 -1
  199. package/plugins/pageBuilder/notifications/contentReviewNotification.js.map +1 -1
  200. package/plugins/pageBuilder/notifications/contentUrl.js +3 -1
  201. package/plugins/pageBuilder/notifications/contentUrl.js.map +1 -1
  202. package/plugins/pageBuilder/triggerContentReview.d.ts +2 -2
  203. package/plugins/pageBuilder/triggerContentReview.js +5 -4
  204. package/plugins/pageBuilder/triggerContentReview.js.map +1 -1
  205. package/plugins/pageBuilder/updateContentReviewStatus.d.ts +3 -3
  206. package/plugins/pageBuilder/updateContentReviewStatus.js +13 -10
  207. package/plugins/pageBuilder/updateContentReviewStatus.js.map +1 -1
  208. package/plugins/pageBuilder/utils.d.ts +4 -4
  209. package/plugins/pageBuilder/utils.js +7 -6
  210. package/plugins/pageBuilder/utils.js.map +1 -1
  211. package/plugins/utils.d.ts +7 -6
  212. package/plugins/utils.js +12 -8
  213. package/plugins/utils.js.map +1 -1
  214. package/scheduler/createScheduleActionMethods.d.ts +1 -1
  215. package/scheduler/createScheduleActionMethods.js +105 -66
  216. package/scheduler/createScheduleActionMethods.js.map +1 -1
  217. package/scheduler/handlers/executeAction/index.d.ts +2 -2
  218. package/scheduler/handlers/executeAction/index.js +30 -9
  219. package/scheduler/handlers/executeAction/index.js.map +1 -1
  220. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js +5 -4
  221. package/scheduler/handlers/executeAction/plugins/ApplicationGraphQL.js.map +1 -1
  222. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.d.ts +2 -1
  223. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js +6 -7
  224. package/scheduler/handlers/executeAction/plugins/HeadlessCMSGraphQL.js.map +1 -1
  225. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.d.ts +3 -2
  226. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js +4 -7
  227. package/scheduler/handlers/executeAction/plugins/PageBuilderGraphQL.js.map +1 -1
  228. package/scheduler/handlers/executeAction/security.d.ts +2 -2
  229. package/scheduler/handlers/executeAction/security.js +3 -1
  230. package/scheduler/handlers/executeAction/security.js.map +1 -1
  231. package/scheduler/handlers/scheduleAction/index.d.ts +2 -2
  232. package/scheduler/handlers/scheduleAction/index.js +20 -15
  233. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  234. package/scheduler/handlers/scheduleAction/scheduleAction.utils.d.ts +3 -3
  235. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +19 -14
  236. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  237. package/scheduler/handlers/utils.d.ts +2 -3
  238. package/scheduler/handlers/utils.js +20 -13
  239. package/scheduler/handlers/utils.js.map +1 -1
  240. package/scheduler/index.d.ts +1 -1
  241. package/scheduler/index.js +3 -1
  242. package/scheduler/index.js.map +1 -1
  243. package/scheduler/types.d.ts +20 -36
  244. package/scheduler/types.js +11 -17
  245. package/scheduler/types.js.map +1 -1
  246. package/storageOperations/changeRequestStorageOperations.d.ts +2 -2
  247. package/storageOperations/changeRequestStorageOperations.js +44 -23
  248. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  249. package/storageOperations/commentStorageOperations.d.ts +3 -3
  250. package/storageOperations/commentStorageOperations.js +17 -24
  251. package/storageOperations/commentStorageOperations.js.map +1 -1
  252. package/storageOperations/contentReviewStorageOperations.d.ts +3 -3
  253. package/storageOperations/contentReviewStorageOperations.js +20 -25
  254. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  255. package/storageOperations/index.d.ts +3 -9
  256. package/storageOperations/index.js +11 -16
  257. package/storageOperations/index.js.map +1 -1
  258. package/storageOperations/models/changeRequest.model.d.ts +1 -2
  259. package/storageOperations/models/changeRequest.model.js +10 -11
  260. package/storageOperations/models/changeRequest.model.js.map +1 -1
  261. package/storageOperations/models/comment.model.d.ts +1 -2
  262. package/storageOperations/models/comment.model.js +10 -11
  263. package/storageOperations/models/comment.model.js.map +1 -1
  264. package/storageOperations/models/contentReview.model.d.ts +1 -2
  265. package/storageOperations/models/contentReview.model.js +16 -15
  266. package/storageOperations/models/contentReview.model.js.map +1 -1
  267. package/storageOperations/models/index.d.ts +1 -1
  268. package/storageOperations/models/index.js +11 -31
  269. package/storageOperations/models/index.js.map +1 -1
  270. package/storageOperations/models/reviewer.model.d.ts +1 -2
  271. package/storageOperations/models/reviewer.model.js +11 -12
  272. package/storageOperations/models/reviewer.model.js.map +1 -1
  273. package/storageOperations/models/utils.d.ts +2 -2
  274. package/storageOperations/models/utils.js +3 -1
  275. package/storageOperations/models/utils.js.map +1 -1
  276. package/storageOperations/models/workflow.model.d.ts +2 -3
  277. package/storageOperations/models/workflow.model.js +22 -23
  278. package/storageOperations/models/workflow.model.js.map +1 -1
  279. package/storageOperations/reviewerStorageOperations.d.ts +3 -3
  280. package/storageOperations/reviewerStorageOperations.js +24 -34
  281. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  282. package/storageOperations/types.d.ts +2 -2
  283. package/storageOperations/types.js +3 -1
  284. package/storageOperations/types.js.map +1 -1
  285. package/storageOperations/workflowStorageOperations.d.ts +2 -2
  286. package/storageOperations/workflowStorageOperations.js +25 -28
  287. package/storageOperations/workflowStorageOperations.js.map +1 -1
  288. package/types.d.ts +54 -53
  289. package/types.js +121 -29
  290. package/types.js.map +1 -1
  291. package/utils/contentApwSettingsPlugin.d.ts +2 -2
  292. package/utils/contentApwSettingsPlugin.js +3 -1
  293. package/utils/contentApwSettingsPlugin.js.map +1 -1
  294. package/utils/errors.js +3 -1
  295. package/utils/errors.js.map +1 -1
  296. package/utils/fieldResolver.d.ts +2 -2
  297. package/utils/fieldResolver.js +7 -7
  298. package/utils/fieldResolver.js.map +1 -1
  299. package/utils/pickEntryFieldValues.d.ts +3 -0
  300. package/utils/pickEntryFieldValues.js +30 -0
  301. package/utils/pickEntryFieldValues.js.map +1 -0
  302. package/utils/resolve.d.ts +1 -1
  303. package/utils/resolve.js +3 -1
  304. package/utils/resolve.js.map +1 -1
  305. package/plugins/hooks/notifications/appUrl.d.ts +0 -2
  306. package/plugins/hooks/notifications/appUrl.js +0 -18
  307. package/plugins/hooks/notifications/appUrl.js.map +0 -1
  308. package/storageOperations/models/contentModelPluginFactory.d.ts +0 -8
  309. package/storageOperations/models/contentModelPluginFactory.js +0 -19
  310. package/storageOperations/models/contentModelPluginFactory.js.map +0 -1
@@ -7,11 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.shouldRestoreDatetime = exports.moveDateTimeToNextCentury = exports.moveDateTimeToCurrentCentury = exports.isDateTimeInNextCentury = exports.getIsoStringTillMinutes = exports.getApwSettings = exports.encodeToken = exports.documentClient = exports.decodeToken = exports.dateTimeToCronExpression = exports.basePlugins = exports.TOKEN_PREFIX = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
10
- var _dynamodb = require("aws-sdk/clients/dynamodb");
10
+ var _clientDynamodb = require("@webiny/aws-sdk/client-dynamodb");
11
11
  var _handlerDb = _interopRequireDefault(require("@webiny/handler-db"));
12
12
  var _dbDynamodb = require("@webiny/db-dynamodb");
13
13
  var _plugins = _interopRequireDefault(require("@webiny/db-dynamodb/plugins"));
14
- var _handlerLogs = _interopRequireDefault(require("@webiny/handler-logs"));
15
14
  var _types = require("../types");
16
15
  /**
17
16
  * https://day.js.org/docs/en/plugin/utc
@@ -81,8 +80,7 @@ const encodeToken = ({
81
80
  return `${TOKEN_PREFIX}${id}__${tenant}__${locale}`;
82
81
  };
83
82
  exports.encodeToken = encodeToken;
84
- const TOKEN_PREFIX = "apw-";
85
- exports.TOKEN_PREFIX = TOKEN_PREFIX;
83
+ const TOKEN_PREFIX = exports.TOKEN_PREFIX = "apw-";
86
84
  const decodeToken = token => {
87
85
  const auth = token.slice(TOKEN_PREFIX.length);
88
86
  const [id, tenant, locale] = auth.split("__");
@@ -93,12 +91,8 @@ const decodeToken = token => {
93
91
  };
94
92
  };
95
93
  exports.decodeToken = decodeToken;
96
- const documentClient = new _dynamodb.DocumentClient({
97
- convertEmptyValues: true,
98
- region: process.env.AWS_REGION
99
- });
100
- exports.documentClient = documentClient;
101
- const basePlugins = () => [(0, _plugins.default)(), (0, _handlerLogs.default)(), (0, _handlerDb.default)({
94
+ const documentClient = exports.documentClient = (0, _clientDynamodb.getDocumentClient)();
95
+ const basePlugins = () => [(0, _plugins.default)(), (0, _handlerDb.default)({
102
96
  table: process.env.DB_TABLE,
103
97
  driver: new _dbDynamodb.DynamoDbDriver({
104
98
  documentClient
@@ -109,8 +103,19 @@ const basePlugins = () => [(0, _plugins.default)(), (0, _handlerLogs.default)(),
109
103
  * Get APW settings record from DDB.
110
104
  */
111
105
  exports.basePlugins = basePlugins;
106
+ const getVariant = () => {
107
+ /**
108
+ * Variant can only be default for now.
109
+ */
110
+ return "default";
111
+ // const value = process.env.WEBINY_ENV_VARIANT;
112
+ // if (!value || value === "undefined" || typeof value !== "string") {
113
+ // return "";
114
+ // }
115
+ // return String(value);
116
+ };
112
117
  const getApwSettings = async () => {
113
- const variant = process.env.STAGED_ROLLOUTS_VARIANT;
118
+ const variant = getVariant();
114
119
  const params = {
115
120
  TableName: process.env.DB_TABLE,
116
121
  Key: {
@@ -120,11 +125,13 @@ const getApwSettings = async () => {
120
125
  };
121
126
  const {
122
127
  Item
123
- } = await documentClient.get(params).promise();
128
+ } = await documentClient.get(params);
124
129
  return {
125
130
  mainGraphqlFunctionArn: Item ? Item["mainGraphqlFunctionArn"] : "mainGraphqlFunctionArn",
126
131
  eventRuleName: Item ? Item["eventRuleName"] : "eventRuleName",
127
132
  eventTargetId: Item ? Item["eventTargetId"] : "eventTargetId"
128
133
  };
129
134
  };
130
- exports.getApwSettings = getApwSettings;
135
+ exports.getApwSettings = getApwSettings;
136
+
137
+ //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["dayjs","extend","utc","TIME_SEPARATOR","ELAPSED_CRON_EXPRESSION","getIsoStringTillMinutes","datetime","isNaN","Date","parse","slice","lastIndexOf","dateTimeToCronExpression","dayOfWeek","format","moveDateTimeToNextCentury","add","toISOString","moveDateTimeToCurrentCentury","subtract","isDateTimeInNextCentury","isAfter","shouldRestoreDatetime","invocationType","selfInvoked","InvocationTypes","SCHEDULED","today","isExecutionPending","encodeToken","id","tenant","locale","TOKEN_PREFIX","decodeToken","token","auth","length","split","documentClient","DocumentClient","convertEmptyValues","region","process","env","AWS_REGION","basePlugins","dynamoDbPlugins","logsPlugins","dbPlugins","table","DB_TABLE","driver","DynamoDbDriver","getApwSettings","variant","STAGED_ROLLOUTS_VARIANT","params","TableName","Key","PK","SK","Item","get","promise","mainGraphqlFunctionArn","eventRuleName","eventTargetId"],"sources":["utils.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport dbPlugins from \"@webiny/handler-db\";\nimport { DynamoDbDriver } from \"@webiny/db-dynamodb\";\nimport dynamoDbPlugins from \"@webiny/db-dynamodb/plugins\";\nimport logsPlugins from \"@webiny/handler-logs\";\nimport { InvocationTypes } from \"~/scheduler/types\";\n\n/**\n * https://day.js.org/docs/en/plugin/utc\n */\ndayjs.extend(utc);\n\nconst TIME_SEPARATOR = \":\";\nconst ELAPSED_CRON_EXPRESSION = \"* * * * ? 2000\";\n\nexport const getIsoStringTillMinutes = (datetime: string): string => {\n /**\n * Validate datetime.\n */\n if (isNaN(Date.parse(datetime))) {\n return datetime;\n }\n // input = \"2022-03-08T05:41:13.230Z\"\n // output = \"2022-03-08T05:41\"\n return datetime.slice(0, datetime.lastIndexOf(TIME_SEPARATOR));\n};\n\nexport const dateTimeToCronExpression = (datetime: string): string => {\n if (!datetime) {\n return ELAPSED_CRON_EXPRESSION;\n }\n /**\n * You can't specify the Day-of-month and Day-of-week fields in the same cron expression.\n * If you specify a value (or a *) in one of the fields, you must use a ? (question mark) in the other.\n *\n * https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html\n */\n const dayOfWeek = \"?\";\n\n return dayjs.utc(datetime).format(`mm H D M [${dayOfWeek}] YYYY`);\n};\n\nexport const moveDateTimeToNextCentury = (datetime: string): string => {\n return dayjs.utc(datetime).add(100, \"year\").toISOString();\n};\n\nexport const moveDateTimeToCurrentCentury = (datetime: string): string => {\n return dayjs.utc(datetime).subtract(100, \"year\").toISOString();\n};\n\nexport const isDateTimeInNextCentury = (datetime: string): boolean => {\n return dayjs.utc(datetime).isAfter(\"2100-01-01\", \"year\");\n};\n\ninterface ShouldRestoreDatetimeParams {\n invocationType?: InvocationTypes;\n datetime: string;\n}\n\nexport const shouldRestoreDatetime = ({\n invocationType,\n datetime\n}: ShouldRestoreDatetimeParams): boolean => {\n /**\n * \"invocationType\" will not be SCHEDULED when the lambda is called from Main GQL handler.\n *\n * Which means a new content is scheduled for \"publish\"/\"unpublish\" therefore, we need to restore the previously\n * scheduled action if it has not been executed already.\n */\n const selfInvoked = invocationType === InvocationTypes.SCHEDULED;\n\n const today = dayjs.utc();\n const isExecutionPending = dayjs.utc(datetime).isAfter(today);\n\n return !selfInvoked && isExecutionPending;\n};\n\ninterface EncodeTokenParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport const encodeToken = ({ id, tenant, locale }: EncodeTokenParams) => {\n return `${TOKEN_PREFIX}${id}__${tenant}__${locale}`;\n};\n\nexport const TOKEN_PREFIX = \"apw-\";\n\nexport const decodeToken = (token: string): Partial<EncodeTokenParams> => {\n const auth = token.slice(TOKEN_PREFIX.length);\n const [id, tenant, locale] = auth.split(\"__\");\n\n return {\n id,\n tenant,\n locale\n };\n};\n\nexport const documentClient = new DocumentClient({\n convertEmptyValues: true,\n region: process.env.AWS_REGION\n});\n\nexport const basePlugins = () => [\n dynamoDbPlugins(),\n logsPlugins(),\n dbPlugins({\n table: process.env.DB_TABLE,\n driver: new DynamoDbDriver({\n documentClient\n })\n })\n];\n\n/**\n * Get APW settings record from DDB.\n */\nexport interface ApwSettings {\n mainGraphqlFunctionArn: string;\n eventRuleName: string;\n eventTargetId: string;\n}\n\nexport const getApwSettings = async (): Promise<ApwSettings> => {\n const variant = process.env.STAGED_ROLLOUTS_VARIANT;\n\n const params = {\n TableName: process.env.DB_TABLE as string,\n Key: {\n PK: `APW#SETTINGS`,\n SK: variant || \"default\"\n }\n };\n\n const { Item } = await documentClient.get(params).promise();\n\n return {\n mainGraphqlFunctionArn: Item ? Item[\"mainGraphqlFunctionArn\"] : \"mainGraphqlFunctionArn\",\n eventRuleName: Item ? Item[\"eventRuleName\"] : \"eventRuleName\",\n eventTargetId: Item ? Item[\"eventTargetId\"] : \"eventTargetId\"\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACAA,cAAK,CAACC,MAAM,CAACC,YAAG,CAAC;AAEjB,MAAMC,cAAc,GAAG,GAAG;AAC1B,MAAMC,uBAAuB,GAAG,gBAAgB;AAEzC,MAAMC,uBAAuB,GAAIC,QAAgB,IAAa;EACjE;AACJ;AACA;EACI,IAAIC,KAAK,CAACC,IAAI,CAACC,KAAK,CAACH,QAAQ,CAAC,CAAC,EAAE;IAC7B,OAAOA,QAAQ;EACnB;EACA;EACA;EACA,OAAOA,QAAQ,CAACI,KAAK,CAAC,CAAC,EAAEJ,QAAQ,CAACK,WAAW,CAACR,cAAc,CAAC,CAAC;AAClE,CAAC;AAAC;AAEK,MAAMS,wBAAwB,GAAIN,QAAgB,IAAa;EAClE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAOF,uBAAuB;EAClC;EACA;AACJ;AACA;AACA;AACA;AACA;EACI,MAAMS,SAAS,GAAG,GAAG;EAErB,OAAOb,cAAK,CAACE,GAAG,CAACI,QAAQ,CAAC,CAACQ,MAAM,CAAE,aAAYD,SAAU,QAAO,CAAC;AACrE,CAAC;AAAC;AAEK,MAAME,yBAAyB,GAAIT,QAAgB,IAAa;EACnE,OAAON,cAAK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,CAAC;EAE7C,OAAO;IACHR,EAAE;IACFC,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAAC;AAEK,MAAMO,cAAc,GAAG,IAAIC,wBAAc,CAAC;EAC7CC,kBAAkB,EAAE,IAAI;EACxBC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC;AACxB,CAAC,CAAC;AAAC;AAEI,MAAMC,WAAW,GAAG,MAAM,CAC7B,IAAAC,gBAAe,GAAE,EACjB,IAAAC,oBAAW,GAAE,EACb,IAAAC,kBAAS,EAAC;EACNC,KAAK,EAAEP,OAAO,CAACC,GAAG,CAACO,QAAQ;EAC3BC,MAAM,EAAE,IAAIC,0BAAc,CAAC;IACvBd;EACJ,CAAC;AACL,CAAC,CAAC,CACL;;AAED;AACA;AACA;AAFA;AASO,MAAMe,cAAc,GAAG,YAAkC;EAC5D,MAAMC,OAAO,GAAGZ,OAAO,CAACC,GAAG,CAACY,uBAAuB;EAEnD,MAAMC,MAAM,GAAG;IACXC,SAAS,EAAEf,OAAO,CAACC,GAAG,CAACO,QAAkB;IACzCQ,GAAG,EAAE;MACDC,EAAE,EAAG,cAAa;MAClBC,EAAE,EAAEN,OAAO,IAAI;IACnB;EACJ,CAAC;EAED,MAAM;IAAEO;EAAK,CAAC,GAAG,MAAMvB,cAAc,CAACwB,GAAG,CAACN,MAAM,CAAC,CAACO,OAAO,EAAE;EAE3D,OAAO;IACHC,sBAAsB,EAAEH,IAAI,GAAGA,IAAI,CAAC,wBAAwB,CAAC,GAAG,wBAAwB;IACxFI,aAAa,EAAEJ,IAAI,GAAGA,IAAI,CAAC,eAAe,CAAC,GAAG,eAAe;IAC7DK,aAAa,EAAEL,IAAI,GAAGA,IAAI,CAAC,eAAe,CAAC,GAAG;EAClD,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["_dayjs","_interopRequireDefault","require","_utc","_clientDynamodb","_handlerDb","_dbDynamodb","_plugins","_types","dayjs","extend","utc","TIME_SEPARATOR","ELAPSED_CRON_EXPRESSION","getIsoStringTillMinutes","datetime","isNaN","Date","parse","slice","lastIndexOf","exports","dateTimeToCronExpression","dayOfWeek","format","moveDateTimeToNextCentury","add","toISOString","moveDateTimeToCurrentCentury","subtract","isDateTimeInNextCentury","isAfter","shouldRestoreDatetime","invocationType","selfInvoked","InvocationTypes","SCHEDULED","today","isExecutionPending","encodeToken","id","tenant","locale","TOKEN_PREFIX","decodeToken","token","auth","length","split","documentClient","getDocumentClient","basePlugins","dynamoDbPlugins","dbPlugins","table","process","env","DB_TABLE","driver","DynamoDbDriver","getVariant","getApwSettings","variant","params","TableName","Key","PK","SK","Item","get","mainGraphqlFunctionArn","eventRuleName","eventTargetId"],"sources":["utils.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport { getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport dbPlugins from \"@webiny/handler-db\";\nimport { DynamoDbDriver } from \"@webiny/db-dynamodb\";\nimport dynamoDbPlugins from \"@webiny/db-dynamodb/plugins\";\nimport { InvocationTypes } from \"~/scheduler/types\";\n\n/**\n * https://day.js.org/docs/en/plugin/utc\n */\ndayjs.extend(utc);\n\nconst TIME_SEPARATOR = \":\";\nconst ELAPSED_CRON_EXPRESSION = \"* * * * ? 2000\";\n\nexport const getIsoStringTillMinutes = (datetime: string): string => {\n /**\n * Validate datetime.\n */\n if (isNaN(Date.parse(datetime))) {\n return datetime;\n }\n // input = \"2022-03-08T05:41:13.230Z\"\n // output = \"2022-03-08T05:41\"\n return datetime.slice(0, datetime.lastIndexOf(TIME_SEPARATOR));\n};\n\nexport const dateTimeToCronExpression = (datetime: string): string => {\n if (!datetime) {\n return ELAPSED_CRON_EXPRESSION;\n }\n /**\n * You can't specify the Day-of-month and Day-of-week fields in the same cron expression.\n * If you specify a value (or a *) in one of the fields, you must use a ? (question mark) in the other.\n *\n * https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html\n */\n const dayOfWeek = \"?\";\n\n return dayjs.utc(datetime).format(`mm H D M [${dayOfWeek}] YYYY`);\n};\n\nexport const moveDateTimeToNextCentury = (datetime: string): string => {\n return dayjs.utc(datetime).add(100, \"year\").toISOString();\n};\n\nexport const moveDateTimeToCurrentCentury = (datetime: string): string => {\n return dayjs.utc(datetime).subtract(100, \"year\").toISOString();\n};\n\nexport const isDateTimeInNextCentury = (datetime: string): boolean => {\n return dayjs.utc(datetime).isAfter(\"2100-01-01\", \"year\");\n};\n\ninterface ShouldRestoreDatetimeParams {\n invocationType?: InvocationTypes;\n datetime: string;\n}\n\nexport const shouldRestoreDatetime = ({\n invocationType,\n datetime\n}: ShouldRestoreDatetimeParams): boolean => {\n /**\n * \"invocationType\" will not be SCHEDULED when the lambda is called from Main GQL handler.\n *\n * Which means a new content is scheduled for \"publish\"/\"unpublish\" therefore, we need to restore the previously\n * scheduled action if it has not been executed already.\n */\n const selfInvoked = invocationType === InvocationTypes.SCHEDULED;\n\n const today = dayjs.utc();\n const isExecutionPending = dayjs.utc(datetime).isAfter(today);\n\n return !selfInvoked && isExecutionPending;\n};\n\ninterface EncodeTokenParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport const encodeToken = ({ id, tenant, locale }: EncodeTokenParams) => {\n return `${TOKEN_PREFIX}${id}__${tenant}__${locale}`;\n};\n\nexport const TOKEN_PREFIX = \"apw-\";\n\nexport const decodeToken = (token: string): Partial<EncodeTokenParams> => {\n const auth = token.slice(TOKEN_PREFIX.length);\n const [id, tenant, locale] = auth.split(\"__\");\n\n return {\n id,\n tenant,\n locale\n };\n};\n\nexport const documentClient = getDocumentClient();\n\nexport const basePlugins = () => [\n dynamoDbPlugins(),\n dbPlugins({\n table: process.env.DB_TABLE,\n driver: new DynamoDbDriver({\n documentClient\n })\n })\n];\n\n/**\n * Get APW settings record from DDB.\n */\nexport interface ApwSettings {\n mainGraphqlFunctionArn: string;\n eventRuleName: string;\n eventTargetId: string;\n}\n\nconst getVariant = (): string => {\n /**\n * Variant can only be default for now.\n */\n return \"default\";\n // const value = process.env.WEBINY_ENV_VARIANT;\n // if (!value || value === \"undefined\" || typeof value !== \"string\") {\n // return \"\";\n // }\n // return String(value);\n};\n\nexport const getApwSettings = async (): Promise<ApwSettings> => {\n const variant = getVariant();\n\n const params = {\n TableName: process.env.DB_TABLE as string,\n Key: {\n PK: `APW#SETTINGS`,\n SK: variant || \"default\"\n }\n };\n\n const { Item } = await documentClient.get(params);\n\n return {\n mainGraphqlFunctionArn: Item ? Item[\"mainGraphqlFunctionArn\"] : \"mainGraphqlFunctionArn\",\n eventRuleName: Item ? Item[\"eventRuleName\"] : \"eventRuleName\",\n eventTargetId: Item ? Item[\"eventTargetId\"] : \"eventTargetId\"\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACAO,cAAK,CAACC,MAAM,CAACC,YAAG,CAAC;AAEjB,MAAMC,cAAc,GAAG,GAAG;AAC1B,MAAMC,uBAAuB,GAAG,gBAAgB;AAEzC,MAAMC,uBAAuB,GAAIC,QAAgB,IAAa;EACjE;AACJ;AACA;EACI,IAAIC,KAAK,CAACC,IAAI,CAACC,KAAK,CAACH,QAAQ,CAAC,CAAC,EAAE;IAC7B,OAAOA,QAAQ;EACnB;EACA;EACA;EACA,OAAOA,QAAQ,CAACI,KAAK,CAAC,CAAC,EAAEJ,QAAQ,CAACK,WAAW,CAACR,cAAc,CAAC,CAAC;AAClE,CAAC;AAACS,OAAA,CAAAP,uBAAA,GAAAA,uBAAA;AAEK,MAAMQ,wBAAwB,GAAIP,QAAgB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CAAC;EAE5B,MAAMG,MAAM,GAAG;IACXC,SAAS,EAAET,OAAO,CAACC,GAAG,CAACC,QAAkB;IACzCQ,GAAG,EAAE;MACDC,EAAE,EAAE,cAAc;MAClBC,EAAE,EAAEL,OAAO,IAAI;IACnB;EACJ,CAAC;EAED,MAAM;IAAEM;EAAK,CAAC,GAAG,MAAMnB,cAAc,CAACoB,GAAG,CAACN,MAAM,CAAC;EAEjD,OAAO;IACHO,sBAAsB,EAAEF,IAAI,GAAGA,IAAI,CAAC,wBAAwB,CAAC,GAAG,wBAAwB;IACxFG,aAAa,EAAEH,IAAI,GAAGA,IAAI,CAAC,eAAe,CAAC,GAAG,eAAe;IAC7DI,aAAa,EAAEJ,IAAI,GAAGA,IAAI,CAAC,eAAe,CAAC,GAAG;EAClD,CAAC;AACL,CAAC;AAAC/C,OAAA,CAAAwC,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ApwScheduleActionCrud, CreateScheduleActionParams } from "./types";
1
+ import type { ApwScheduleActionCrud, CreateScheduleActionParams } from "./types";
2
2
  export declare const createScheduler: (params: CreateScheduleActionParams) => ApwScheduleActionCrud;
@@ -21,4 +21,6 @@ const createScheduler = params => {
21
21
  storageOperations
22
22
  });
23
23
  };
24
- exports.createScheduler = createScheduler;
24
+ exports.createScheduler = createScheduler;
25
+
26
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createScheduler","params","getLocale","getIdentity","getTenant","getPermission","storageOperations","createScheduleActionMethods"],"sources":["index.ts"],"sourcesContent":["import { createScheduleActionMethods } from \"./createScheduleActionMethods\";\nimport { ApwScheduleActionCrud, CreateScheduleActionParams } from \"./types\";\n\nexport const createScheduler = (params: CreateScheduleActionParams): ApwScheduleActionCrud => {\n const { getLocale, getIdentity, getTenant, getPermission, storageOperations } = params;\n\n return createScheduleActionMethods({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations\n });\n};\n"],"mappings":";;;;;;AAAA;AAGO,MAAMA,eAAe,GAAIC,MAAkC,IAA4B;EAC1F,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,SAAS;IAAEC,aAAa;IAAEC;EAAkB,CAAC,GAAGL,MAAM;EAEtF,OAAO,IAAAM,wDAA2B,EAAC;IAC/BL,SAAS;IACTC,WAAW;IACXC,SAAS;IACTC,aAAa;IACbC;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_createScheduleActionMethods","require","createScheduler","params","getLocale","getIdentity","getTenant","getPermission","storageOperations","createScheduleActionMethods","exports"],"sources":["index.ts"],"sourcesContent":["import { createScheduleActionMethods } from \"./createScheduleActionMethods\";\nimport type { ApwScheduleActionCrud, CreateScheduleActionParams } from \"./types\";\n\nexport const createScheduler = (params: CreateScheduleActionParams): ApwScheduleActionCrud => {\n const { getLocale, getIdentity, getTenant, getPermission, storageOperations } = params;\n\n return createScheduleActionMethods({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,4BAAA,GAAAC,OAAA;AAGO,MAAMC,eAAe,GAAIC,MAAkC,IAA4B;EAC1F,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,SAAS;IAAEC,aAAa;IAAEC;EAAkB,CAAC,GAAGL,MAAM;EAEtF,OAAO,IAAAM,wDAA2B,EAAC;IAC/BL,SAAS;IACTC,WAAW;IACXC,SAAS;IACTC,aAAa;IACbC;EACJ,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { Context } from "@webiny/api/types";
2
- import { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
3
- import { I18NLocale, I18NContext } from "@webiny/api-i18n/types";
4
- import { Tenant } from "@webiny/api-tenancy/types";
5
- import { TenancyContext } from "@webiny/api-tenancy/types";
1
+ import type { Context } from "@webiny/api/types";
2
+ import type { SecurityIdentity, SecurityPermission } from "@webiny/api-security/types";
3
+ import type { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
4
+ import type { TenancyContext, Tenant } from "@webiny/api-tenancy/types";
5
+ import type { ApwIdentity } from "../types";
6
6
  export interface ListWhere {
7
7
  /**
8
8
  * Fields.
@@ -29,25 +29,6 @@ export interface ListParams {
29
29
  limit?: number;
30
30
  after?: string;
31
31
  }
32
- /**
33
- * A interface describing the reference to a user that created some data in the database.
34
- *
35
- * @category General
36
- */
37
- export interface CreatedBy {
38
- /**
39
- * ID if the user.
40
- */
41
- id: string;
42
- /**
43
- * Full name of the user.
44
- */
45
- displayName: string | null;
46
- /**
47
- * Type of the user (admin, user)
48
- */
49
- type: string;
50
- }
51
32
  export interface ListMeta {
52
33
  /**
53
34
  * A cursor for pagination.
@@ -69,8 +50,11 @@ export declare enum ApwContentTypes {
69
50
  export interface BaseFields {
70
51
  id: string;
71
52
  createdOn: string;
72
- savedOn?: string;
73
- createdBy: CreatedBy;
53
+ modifiedOn: string | null;
54
+ savedOn: string;
55
+ createdBy: ApwIdentity;
56
+ modifiedBy: ApwIdentity | null;
57
+ savedBy: ApwIdentity;
74
58
  tenant: string;
75
59
  locale: string;
76
60
  }
@@ -99,13 +83,13 @@ interface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {
99
83
  get(id: string): Promise<TEntry | null>;
100
84
  create(data: TCreateEntryParams): Promise<TEntry>;
101
85
  update(id: string, data: TUpdateEntryParams): Promise<TEntry>;
102
- delete(id: string): Promise<Boolean>;
86
+ delete(id: string): Promise<boolean>;
103
87
  }
104
88
  export interface ApwScheduleActionCrud extends BaseApwCrud<ApwScheduleAction, ApwScheduleActionData, ApwScheduleActionData> {
105
89
  list(params: ListParams): Promise<[ApwScheduleAction[], ListMeta]>;
106
90
  getCurrentTask(): Promise<ApwScheduleAction | null>;
107
91
  updateCurrentTask(item: ApwScheduleAction): Promise<ApwScheduleAction>;
108
- deleteCurrentTask(): Promise<Boolean>;
92
+ deleteCurrentTask(): Promise<boolean>;
109
93
  }
110
94
  export interface ScheduleActionContext extends Context, I18NContext, TenancyContext {
111
95
  scheduleAction: ApwScheduleActionCrud;
@@ -139,31 +123,31 @@ export interface ApwScheduleActionListParams extends ListParams {
139
123
  locale: string;
140
124
  };
141
125
  }
142
- export declare type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;
143
- export declare type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;
144
- export declare type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;
145
- export declare type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;
126
+ export type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;
127
+ export type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;
128
+ export type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;
129
+ export type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;
146
130
  export interface StorageOperationsUpdateScheduleActionParams {
147
131
  item: ApwScheduleAction;
148
132
  input: ApwScheduleActionData;
149
133
  }
150
- export declare type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];
134
+ export type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];
151
135
  export interface StorageOperationsUpdateCurrentTaskParams {
152
136
  item: ApwScheduleAction;
153
137
  }
154
138
  export interface StorageOperationsGetCurrentTaskParams {
155
139
  where: Pick<StorageOperationsGetParams["where"], "tenant" | "locale">;
156
140
  }
157
- export declare type StorageOperationsDeleteCurrentTaskParams = Pick<StorageOperationsDeleteParams, "tenant" | "locale">;
141
+ export type StorageOperationsDeleteCurrentTaskParams = Pick<StorageOperationsDeleteParams, "tenant" | "locale">;
158
142
  export interface ApwScheduleActionStorageOperations {
159
143
  get(params: StorageOperationsGetScheduleActionParams): Promise<ApwScheduleAction | null>;
160
144
  list(params: StorageOperationsListScheduleActionsParams): Promise<StorageOperationsListScheduleActionsResponse>;
161
145
  create(params: StorageOperationsCreateScheduleActionParams): Promise<ApwScheduleAction>;
162
146
  update(params: StorageOperationsUpdateScheduleActionParams): Promise<ApwScheduleAction>;
163
- delete(params: StorageOperationsDeleteScheduleActionParams): Promise<Boolean>;
147
+ delete(params: StorageOperationsDeleteScheduleActionParams): Promise<boolean>;
164
148
  getCurrentTask(params: StorageOperationsGetCurrentTaskParams): Promise<ApwScheduleAction | null>;
165
149
  updateCurrentTask(params: StorageOperationsUpdateCurrentTaskParams): Promise<ApwScheduleAction>;
166
- deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<Boolean>;
150
+ deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<boolean>;
167
151
  }
168
152
  export interface CreateApwContextParams {
169
153
  storageOperations: ApwScheduleActionStorageOperations;
@@ -4,25 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.InvocationTypes = exports.ApwScheduleActionTypes = exports.ApwContentTypes = void 0;
7
- /**
8
- * A interface describing the reference to a user that created some data in the database.
9
- *
10
- * @category General
11
- */
12
- let ApwContentTypes;
13
- exports.ApwContentTypes = ApwContentTypes;
14
- (function (ApwContentTypes) {
7
+ let ApwContentTypes = exports.ApwContentTypes = /*#__PURE__*/function (ApwContentTypes) {
15
8
  ApwContentTypes["PAGE"] = "page";
16
9
  ApwContentTypes["CMS_ENTRY"] = "cms_entry";
17
- })(ApwContentTypes || (exports.ApwContentTypes = ApwContentTypes = {}));
18
- let ApwScheduleActionTypes;
19
- exports.ApwScheduleActionTypes = ApwScheduleActionTypes;
20
- (function (ApwScheduleActionTypes) {
10
+ return ApwContentTypes;
11
+ }({});
12
+ let ApwScheduleActionTypes = exports.ApwScheduleActionTypes = /*#__PURE__*/function (ApwScheduleActionTypes) {
21
13
  ApwScheduleActionTypes["PUBLISH"] = "publish";
22
14
  ApwScheduleActionTypes["UNPUBLISH"] = "unpublish";
23
- })(ApwScheduleActionTypes || (exports.ApwScheduleActionTypes = ApwScheduleActionTypes = {}));
24
- let InvocationTypes;
25
- exports.InvocationTypes = InvocationTypes;
26
- (function (InvocationTypes) {
15
+ return ApwScheduleActionTypes;
16
+ }({});
17
+ let InvocationTypes = exports.InvocationTypes = /*#__PURE__*/function (InvocationTypes) {
27
18
  InvocationTypes["SCHEDULED"] = "scheduled";
28
- })(InvocationTypes || (exports.InvocationTypes = InvocationTypes = {}));
19
+ return InvocationTypes;
20
+ }({});
21
+
22
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ApwContentTypes","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport { I18NLocale, I18NContext } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\n\nexport interface ListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * By datetime field.\n */\n datetime_startsWith?: string;\n}\n\nexport interface ListParams {\n where: ListWhere;\n sort?: (\"datetime_ASC\" | \"datetime_DESC\")[];\n limit?: number;\n after?: string;\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\nexport interface ListMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport enum ApwContentTypes {\n PAGE = \"page\",\n CMS_ENTRY = \"cms_entry\"\n}\n\nexport interface BaseFields {\n id: string;\n createdOn: string;\n savedOn?: string;\n createdBy: CreatedBy;\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleAction extends BaseFields {\n data: ApwScheduleActionData;\n}\n\nexport enum ApwScheduleActionTypes {\n PUBLISH = \"publish\",\n UNPUBLISH = \"unpublish\"\n}\n\nexport interface ApwScheduleActionData {\n action: ApwScheduleActionTypes;\n type: ApwContentTypes;\n datetime: string;\n entryId: string;\n /**\n * We will add modelId to the data for now.\n * TODO extract in separate package?\n */\n modelId?: string;\n}\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\ninterface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {\n get(id: string): Promise<TEntry | null>;\n\n create(data: TCreateEntryParams): Promise<TEntry>;\n\n update(id: string, data: TUpdateEntryParams): Promise<TEntry>;\n\n delete(id: string): Promise<Boolean>;\n}\n\nexport interface ApwScheduleActionCrud\n extends BaseApwCrud<ApwScheduleAction, ApwScheduleActionData, ApwScheduleActionData> {\n list(params: ListParams): Promise<[ApwScheduleAction[], ListMeta]>;\n\n getCurrentTask(): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(item: ApwScheduleAction): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(): Promise<Boolean>;\n}\n\nexport interface ScheduleActionContext extends Context, I18NContext, TenancyContext {\n scheduleAction: ApwScheduleActionCrud;\n}\n\nexport interface CreateScheduleActionParams {\n getLocale: () => I18NLocale;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n getPermission: (name: string) => Promise<SecurityPermission | null>;\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\ninterface CreateApwScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\ninterface StorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n\ninterface StorageOperationsDeleteParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleActionListParams extends ListParams {\n where: ListWhere & {\n tenant: string;\n locale: string;\n };\n}\n\nexport type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;\n\nexport type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;\nexport type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;\n\nexport type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;\n\nexport interface StorageOperationsUpdateScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\nexport type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];\n\nexport interface StorageOperationsUpdateCurrentTaskParams {\n item: ApwScheduleAction;\n}\n\nexport interface StorageOperationsGetCurrentTaskParams {\n where: Pick<StorageOperationsGetParams[\"where\"], \"tenant\" | \"locale\">;\n}\n\nexport type StorageOperationsDeleteCurrentTaskParams = Pick<\n StorageOperationsDeleteParams,\n \"tenant\" | \"locale\"\n>;\n\nexport interface ApwScheduleActionStorageOperations {\n get(params: StorageOperationsGetScheduleActionParams): Promise<ApwScheduleAction | null>;\n\n list(\n params: StorageOperationsListScheduleActionsParams\n ): Promise<StorageOperationsListScheduleActionsResponse>;\n\n create(params: StorageOperationsCreateScheduleActionParams): Promise<ApwScheduleAction>;\n\n update(params: StorageOperationsUpdateScheduleActionParams): Promise<ApwScheduleAction>;\n\n delete(params: StorageOperationsDeleteScheduleActionParams): Promise<Boolean>;\n\n getCurrentTask(\n params: StorageOperationsGetCurrentTaskParams\n ): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(params: StorageOperationsUpdateCurrentTaskParams): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<Boolean>;\n}\n\nexport interface CreateApwContextParams {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n"],"mappings":";;;;;;AAkCA;AACA;AACA;AACA;AACA;AAJA,IAmCYA,eAAe;AAAA;AAAA,WAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,+BAAfA,eAAe;AAAA,IAkBfC,sBAAsB;AAAA;AAAA,WAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,sCAAtBA,sBAAsB;AAAA,IAiBtBC,eAAe;AAAA;AAAA,WAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,+BAAfA,eAAe"}
1
+ {"version":3,"names":["ApwContentTypes","exports","ApwScheduleActionTypes","InvocationTypes"],"sources":["types.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport type { SecurityIdentity, SecurityPermission } from \"@webiny/api-security/types\";\nimport type { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport type { TenancyContext, Tenant } from \"@webiny/api-tenancy/types\";\nimport type { ApwIdentity } from \"~/types\";\n\nexport interface ListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * By datetime field.\n */\n datetime_startsWith?: string;\n}\n\nexport interface ListParams {\n where: ListWhere;\n sort?: (\"datetime_ASC\" | \"datetime_DESC\")[];\n limit?: number;\n after?: string;\n}\n\nexport interface ListMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport enum ApwContentTypes {\n PAGE = \"page\",\n CMS_ENTRY = \"cms_entry\"\n}\n\nexport interface BaseFields {\n id: string;\n\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: ApwIdentity;\n modifiedBy: ApwIdentity | null;\n savedBy: ApwIdentity;\n\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleAction extends BaseFields {\n data: ApwScheduleActionData;\n}\n\nexport enum ApwScheduleActionTypes {\n PUBLISH = \"publish\",\n UNPUBLISH = \"unpublish\"\n}\n\nexport interface ApwScheduleActionData {\n action: ApwScheduleActionTypes;\n type: ApwContentTypes;\n datetime: string;\n entryId: string;\n /**\n * We will add modelId to the data for now.\n * TODO extract in separate package?\n */\n modelId?: string;\n}\n\nexport enum InvocationTypes {\n SCHEDULED = \"scheduled\"\n}\n\ninterface BaseApwCrud<TEntry, TCreateEntryParams, TUpdateEntryParams> {\n get(id: string): Promise<TEntry | null>;\n\n create(data: TCreateEntryParams): Promise<TEntry>;\n\n update(id: string, data: TUpdateEntryParams): Promise<TEntry>;\n\n delete(id: string): Promise<boolean>;\n}\n\nexport interface ApwScheduleActionCrud\n extends BaseApwCrud<ApwScheduleAction, ApwScheduleActionData, ApwScheduleActionData> {\n list(params: ListParams): Promise<[ApwScheduleAction[], ListMeta]>;\n\n getCurrentTask(): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(item: ApwScheduleAction): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(): Promise<boolean>;\n}\n\nexport interface ScheduleActionContext extends Context, I18NContext, TenancyContext {\n scheduleAction: ApwScheduleActionCrud;\n}\n\nexport interface CreateScheduleActionParams {\n getLocale: () => I18NLocale;\n getIdentity: () => SecurityIdentity;\n getTenant: () => Tenant;\n getPermission: (name: string) => Promise<SecurityPermission | null>;\n storageOperations: ApwScheduleActionStorageOperations;\n}\n\ninterface CreateApwScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\ninterface StorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n\ninterface StorageOperationsDeleteParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ApwScheduleActionListParams extends ListParams {\n where: ListWhere & {\n tenant: string;\n locale: string;\n };\n}\n\nexport type StorageOperationsGetScheduleActionParams = StorageOperationsGetParams;\n\nexport type StorageOperationsDeleteScheduleActionParams = StorageOperationsDeleteParams;\nexport type StorageOperationsListScheduleActionsParams = ApwScheduleActionListParams;\n\nexport type StorageOperationsCreateScheduleActionParams = CreateApwScheduleActionParams;\n\nexport interface StorageOperationsUpdateScheduleActionParams {\n item: ApwScheduleAction;\n input: ApwScheduleActionData;\n}\n\nexport type StorageOperationsListScheduleActionsResponse = [ApwScheduleAction[], ListMeta];\n\nexport interface StorageOperationsUpdateCurrentTaskParams {\n item: ApwScheduleAction;\n}\n\nexport interface StorageOperationsGetCurrentTaskParams {\n where: Pick<StorageOperationsGetParams[\"where\"], \"tenant\" | \"locale\">;\n}\n\nexport type StorageOperationsDeleteCurrentTaskParams = Pick<\n StorageOperationsDeleteParams,\n \"tenant\" | \"locale\"\n>;\n\nexport interface ApwScheduleActionStorageOperations {\n get(params: StorageOperationsGetScheduleActionParams): Promise<ApwScheduleAction | null>;\n\n list(\n params: StorageOperationsListScheduleActionsParams\n ): Promise<StorageOperationsListScheduleActionsResponse>;\n\n create(params: StorageOperationsCreateScheduleActionParams): Promise<ApwScheduleAction>;\n\n update(params: StorageOperationsUpdateScheduleActionParams): Promise<ApwScheduleAction>;\n\n delete(params: StorageOperationsDeleteScheduleActionParams): Promise<boolean>;\n\n getCurrentTask(\n params: StorageOperationsGetCurrentTaskParams\n ): Promise<ApwScheduleAction | null>;\n\n updateCurrentTask(params: StorageOperationsUpdateCurrentTaskParams): Promise<ApwScheduleAction>;\n\n deleteCurrentTask(params: StorageOperationsDeleteCurrentTaskParams): Promise<boolean>;\n}\n\nexport interface CreateApwContextParams {\n storageOperations: ApwScheduleActionStorageOperations;\n}\n"],"mappings":";;;;;;IAiDYA,eAAe,GAAAC,OAAA,CAAAD,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA;AAAA,IAuBfE,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAiBtBC,eAAe,GAAAF,OAAA,CAAAE,eAAA,0BAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { ApwChangeRequestStorageOperations } from "./types";
2
- import { CreateApwStorageOperationsParams } from "./index";
1
+ import type { ApwChangeRequestStorageOperations } from "./types";
2
+ import type { CreateApwStorageOperationsParams } from "./index";
3
3
  export declare const createChangeRequestStorageOperations: (params: CreateApwStorageOperationsParams) => ApwChangeRequestStorageOperations;
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.createChangeRequestStorageOperations = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _index = require("./index");
8
+ var _pickEntryFieldValues = require("../utils/pickEntryFieldValues");
10
9
  var _fieldResolver = require("../utils/fieldResolver");
11
10
  var _error = _interopRequireDefault(require("@webiny/error"));
12
11
  const createChangeRequestStorageOperations = params => {
@@ -16,9 +15,7 @@ const createChangeRequestStorageOperations = params => {
16
15
  security
17
16
  } = params;
18
17
  const getChangeRequestModel = async () => {
19
- security.disableAuthorization();
20
18
  const model = await cms.getModel("apwChangeRequestModelDefinition");
21
- security.enableAuthorization();
22
19
  if (!model) {
23
20
  throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
24
21
  }
@@ -28,12 +25,10 @@ const createChangeRequestStorageOperations = params => {
28
25
  id
29
26
  }) => {
30
27
  const model = await getChangeRequestModel();
31
- security.disableAuthorization();
32
28
  const entry = await cms.getEntryById(model, id);
33
- security.enableAuthorization();
34
29
  return (0, _fieldResolver.getFieldValues)({
35
30
  entry,
36
- fields: _index.baseFields,
31
+ fields: _pickEntryFieldValues.baseFields,
37
32
  context: getCmsContext(),
38
33
  transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
39
34
  });
@@ -43,15 +38,16 @@ const createChangeRequestStorageOperations = params => {
43
38
  getChangeRequest,
44
39
  async listChangeRequests(params) {
45
40
  const model = await getChangeRequestModel();
46
- security.disableAuthorization();
47
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
48
- where: (0, _objectSpread2.default)({}, params.where)
49
- }));
50
- security.enableAuthorization();
41
+ const [entries, meta] = await cms.listLatestEntries(model, {
42
+ ...params,
43
+ where: {
44
+ ...params.where
45
+ }
46
+ });
51
47
  try {
52
48
  const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
53
49
  entry,
54
- fields: _index.baseFields,
50
+ fields: _pickEntryFieldValues.baseFields,
55
51
  context: getCmsContext(),
56
52
  transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
57
53
  })));
@@ -62,18 +58,17 @@ const createChangeRequestStorageOperations = params => {
62
58
  },
63
59
  async createChangeRequest(params) {
64
60
  const model = await getChangeRequestModel();
65
- security.disableAuthorization();
66
61
  const entry = await cms.createEntry(model, params.data);
67
- security.enableAuthorization();
68
62
  return (0, _fieldResolver.getFieldValues)({
69
63
  entry,
70
- fields: _index.baseFields,
64
+ fields: _pickEntryFieldValues.baseFields,
71
65
  context: getCmsContext(),
72
66
  transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
73
67
  });
74
68
  },
75
69
  async updateChangeRequest(params) {
76
70
  const model = await getChangeRequestModel();
71
+
77
72
  /**
78
73
  * We're fetching the existing entry here because we're not accepting "app" field as input,
79
74
  * but, we still need to retain its value after the "update" operation.
@@ -81,23 +76,49 @@ const createChangeRequestStorageOperations = params => {
81
76
  const existingEntry = await getChangeRequest({
82
77
  id: params.id
83
78
  });
84
- security.disableAuthorization();
85
- const entry = await cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
86
- security.enableAuthorization();
79
+
80
+ /**
81
+ * Only creator can update the change request
82
+ */
83
+ if (existingEntry.createdBy.id !== security.getIdentity().id) {
84
+ throw new _error.default("A change request can only be updated by its creator.", "ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST");
85
+ }
86
+ const entry = await cms.updateEntry(model, params.id, {
87
+ ...existingEntry,
88
+ ...params.data,
89
+ savedOn: new Date()
90
+ });
87
91
  return (0, _fieldResolver.getFieldValues)({
88
92
  entry,
89
- fields: _index.baseFields,
93
+ fields: _pickEntryFieldValues.baseFields,
90
94
  context: getCmsContext(),
91
95
  transformers: [(0, _fieldResolver.getTransformer)(model, "body")]
92
96
  });
93
97
  },
94
98
  async deleteChangeRequest(params) {
95
99
  const model = await getChangeRequestModel();
96
- security.disableAuthorization();
100
+ if (!security.getIdentity()) {
101
+ return true;
102
+ }
103
+
104
+ /**
105
+ * We're fetching the existing entry
106
+ */
107
+ const existingEntry = await getChangeRequest({
108
+ id: params.id
109
+ });
110
+
111
+ /**
112
+ * Only creator can delete the change request
113
+ */
114
+ if (existingEntry.createdBy.id !== security.getIdentity().id) {
115
+ throw new _error.default("A change request can only be deleted by its creator.", "ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST");
116
+ }
97
117
  await cms.deleteEntry(model, params.id);
98
- security.enableAuthorization();
99
118
  return true;
100
119
  }
101
120
  };
102
121
  };
103
- exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
122
+ exports.createChangeRequestStorageOperations = createChangeRequestStorageOperations;
123
+
124
+ //# sourceMappingURL=changeRequestStorageOperations.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","disableAuthorization","model","getModel","enableAuthorization","WebinyError","getChangeRequest","id","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","listChangeRequests","entries","meta","listLatestEntries","where","all","Promise","map","ex","message","code","data","createChangeRequest","createEntry","updateChangeRequest","existingEntry","updateEntry","deleteChangeRequest","deleteEntry"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import { ApwChangeRequestStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(\"apwChangeRequestModelDefinition\");\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n security.enableAuthorization();\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const entry = await cms.createEntry(model, params.data);\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AAGO,MAAMA,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,YAAY;IACtCD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMC,KAAK,GAAG,MAAML,GAAG,CAACM,QAAQ,CAAC,iCAAiC,CAAC;IACnEJ,QAAQ,CAACK,mBAAmB,EAAE;IAC9B,IAAI,CAACF,KAAK,EAAE;MACR,MAAM,IAAIG,cAAW,CACjB,yDAAyD,EACzD,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMI,gBAAuE,GAAG,OAAO;IACnFC;EACJ,CAAC,KAAK;IACF,MAAML,KAAK,GAAG,MAAMF,qBAAqB,EAAE;IAC3CD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMO,KAAK,GAAG,MAAMX,GAAG,CAACY,YAAY,CAACP,KAAK,EAAEK,EAAE,CAAC;IAC/CR,QAAQ,CAACK,mBAAmB,EAAE;IAC9B,OAAO,IAAAM,6BAAc,EAAC;MAClBF,KAAK;MACLG,MAAM,EAAEC,iBAAU;MAClBC,OAAO,EAAEf,aAAa,EAAE;MACxBgB,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;IAChD,CAAC,CAAC;EACN,CAAC;EACD,OAAO;IACHF,qBAAqB;IACrBM,gBAAgB;IAChB,MAAMU,kBAAkB,CAACpB,M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;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAM4B,mBAAmB,CAAClC,MAAM,EAAE;MAC9B,MAAMM,KAAK,GAAG,MAAMF,qBAAqB,EAAE;MAC3C;AACZ;AACA;AACA;MACY,MAAM+B,aAAa,GAAG,MAAMzB,gBAAgB,CAAC;QAAEC,EAAE,EAAEX,MAAM,CAACW;MAAG,CAAC,CAAC;MAE/DR,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMO,KAAK,GAAG,MAAMX,GAAG,CAACmC,WAAW,CAAC9B,KAAK,EAAEN,MAAM,CAACW,EAAE,8DAC7CwB,aAAa,GACbnC,MAAM,CAAC+B,IAAI,EAChB;MACF5B,QAAQ,CAACK,mBAAmB,EAAE;MAC9B,OAAO,IAAAM,6BAAc,EAAC;QAClBF,KAAK;QACLG,MAAM,EAAEC,iBAAU;QAClBC,OAAO,EAAEf,aAAa,EAAE;QACxBgB,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAM+B,mBAAmB,CAACrC,MAAM,EAAE;MAC9B,MAAMM,KAAK,GAAG,MAAMF,qBAAqB,EAAE;MAC3CD,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMJ,GAAG,CAACqC,WAAW,CAAChC,KAAK,EAAEN,MAAM,CAACW,EAAE,CAAC;MACvCR,QAAQ,CAACK,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["_pickEntryFieldValues","require","_fieldResolver","_error","_interopRequireDefault","createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","model","getModel","WebinyError","getChangeRequest","id","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","listChangeRequests","entries","meta","listLatestEntries","where","all","Promise","map","ex","message","code","data","createChangeRequest","createEntry","updateChangeRequest","existingEntry","createdBy","getIdentity","updateEntry","savedOn","Date","deleteChangeRequest","deleteEntry","exports"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import type { ApwChangeRequestStorageOperations } from \"./types\";\nimport type { CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { baseFields } from \"~/utils/pickEntryFieldValues\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport type { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n const model = await cms.getModel(\"apwChangeRequestModelDefinition\");\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n\n const entry = await cms.getEntryById(model, id);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n const entry = await cms.createEntry(model, params.data);\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can update the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be updated by its creator.\",\n \"ONLY_CREATOR_CAN_UPDATE_CHANGE_REQUEST\"\n );\n }\n\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data,\n savedOn: new Date()\n });\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n if (!security.getIdentity()) {\n return true;\n }\n\n /**\n * We're fetching the existing entry\n */\n const existingEntry = await getChangeRequest({ id: params.id });\n\n /**\n * Only creator can delete the change request\n */\n if (existingEntry.createdBy.id !== security.getIdentity().id) {\n throw new WebinyError(\n \"A change request can only be deleted by its creator.\",\n \"ONLY_CREATOR_CAN_DELETE_CHANGE_REQUEST\"\n );\n }\n\n await cms.deleteEntry(model, params.id);\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGO,MAAMI,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,MAAAA,CAAA,KAAY;IACtC,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAAC,iCAAiC,CAAC;IACnE,IAAI,CAACD,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CACjB,yDAAyD,EACzD,uBACJ,CAAC;IACL;IACA,OAAOF,KAAK;EAChB,CAAC;EACD,MAAMG,gBAAuE,GAAG,MAAAA,CAAO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AmBA,CAACvC,MAAM,EAAE;MAC9B,MAAMK,KAAK,GAAG,MAAMD,qBAAqB,CAAC,CAAC;MAE3C,IAAI,CAACD,QAAQ,CAACgC,WAAW,CAAC,CAAC,EAAE;QACzB,OAAO,IAAI;MACf;;MAEA;AACZ;AACA;MACY,MAAMF,aAAa,GAAG,MAAMzB,gBAAgB,CAAC;QAAEC,EAAE,EAAET,MAAM,CAACS;MAAG,CAAC,CAAC;;MAE/D;AACZ;AACA;MACY,IAAIwB,aAAa,CAACC,SAAS,CAACzB,EAAE,KAAKN,QAAQ,CAACgC,WAAW,CAAC,CAAC,CAAC1B,EAAE,EAAE;QAC1D,MAAM,IAAIF,cAAW,CACjB,sDAAsD,EACtD,wCACJ,CAAC;MACL;MAEA,MAAMN,GAAG,CAACuC,WAAW,CAACnC,KAAK,EAAEL,MAAM,CAACS,EAAE,CAAC;MAEvC,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACgC,OAAA,CAAA1C,oCAAA,GAAAA,oCAAA","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { ApwCommentStorageOperations } from "./types";
2
- import { CreateApwStorageOperationsParams } from "./index";
3
- export declare const createCommentStorageOperations: ({ cms, getCmsContext, security }: CreateApwStorageOperationsParams) => ApwCommentStorageOperations;
1
+ import type { ApwCommentStorageOperations } from "./types";
2
+ import type { CreateApwStorageOperationsParams } from "./index";
3
+ export declare const createCommentStorageOperations: ({ cms, getCmsContext }: CreateApwStorageOperationsParams) => ApwCommentStorageOperations;