@webiny/api-sync-system 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b

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 (321) hide show
  1. package/README.md +6 -108
  2. package/constants.js +2 -7
  3. package/constants.js.map +1 -1
  4. package/index.js +3 -40
  5. package/package.json +29 -26
  6. package/resolver/app/RecordHandler.d.ts +6 -6
  7. package/resolver/app/RecordHandler.js +84 -114
  8. package/resolver/app/RecordHandler.js.map +1 -1
  9. package/resolver/app/RecordsValidation.js +13 -24
  10. package/resolver/app/RecordsValidation.js.map +1 -1
  11. package/resolver/app/ResolverApplication.d.ts +1 -1
  12. package/resolver/app/ResolverApplication.js +27 -42
  13. package/resolver/app/ResolverApplication.js.map +1 -1
  14. package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
  15. package/resolver/app/abstractions/RecordHandler.js +0 -7
  16. package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
  17. package/resolver/app/abstractions/RecordsValidation.js +0 -7
  18. package/resolver/app/abstractions/ResolverApplication.js +0 -7
  19. package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
  20. package/resolver/app/abstractions/ResolverRecord.js +0 -7
  21. package/resolver/app/bundler/BaseBundle.d.ts +6 -6
  22. package/resolver/app/bundler/BaseBundle.js +16 -22
  23. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  24. package/resolver/app/bundler/Bundler.d.ts +1 -1
  25. package/resolver/app/bundler/Bundler.js +12 -25
  26. package/resolver/app/bundler/Bundler.js.map +1 -1
  27. package/resolver/app/bundler/Bundles.d.ts +2 -2
  28. package/resolver/app/bundler/Bundles.js +20 -33
  29. package/resolver/app/bundler/Bundles.js.map +1 -1
  30. package/resolver/app/bundler/CommandBundle.d.ts +1 -1
  31. package/resolver/app/bundler/CommandBundle.js +8 -25
  32. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  33. package/resolver/app/bundler/TableBundle.d.ts +1 -1
  34. package/resolver/app/bundler/TableBundle.js +7 -22
  35. package/resolver/app/bundler/TableBundle.js.map +1 -1
  36. package/resolver/app/bundler/types.d.ts +2 -2
  37. package/resolver/app/bundler/types.js +0 -7
  38. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
  39. package/resolver/app/commandHandler/DeleteCommandHandler.js +21 -35
  40. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  41. package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
  42. package/resolver/app/commandHandler/PutCommandHandler.js +15 -28
  43. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  44. package/resolver/app/commandHandler/delete.d.ts +1 -1
  45. package/resolver/app/commandHandler/delete.js +13 -21
  46. package/resolver/app/commandHandler/delete.js.map +1 -1
  47. package/resolver/app/commandHandler/put.d.ts +1 -1
  48. package/resolver/app/commandHandler/put.js +13 -21
  49. package/resolver/app/commandHandler/put.js.map +1 -1
  50. package/resolver/app/data/SourceDataContainer.d.ts +3 -3
  51. package/resolver/app/data/SourceDataContainer.js +27 -36
  52. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  53. package/resolver/app/data/types.d.ts +2 -2
  54. package/resolver/app/data/types.js +0 -7
  55. package/resolver/app/fetcher/Fetcher.d.ts +3 -3
  56. package/resolver/app/fetcher/Fetcher.js +87 -121
  57. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  58. package/resolver/app/fetcher/types.d.ts +2 -2
  59. package/resolver/app/fetcher/types.js +0 -7
  60. package/resolver/app/ingestor/Ingestor.d.ts +1 -1
  61. package/resolver/app/ingestor/Ingestor.js +26 -39
  62. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  63. package/resolver/app/ingestor/IngestorResult.js +27 -39
  64. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  65. package/resolver/app/ingestor/types.d.ts +2 -2
  66. package/resolver/app/ingestor/types.js +0 -7
  67. package/resolver/app/storer/Storer.d.ts +3 -3
  68. package/resolver/app/storer/Storer.js +73 -95
  69. package/resolver/app/storer/Storer.js.map +1 -1
  70. package/resolver/app/storer/types.d.ts +2 -2
  71. package/resolver/app/storer/types.js +0 -7
  72. package/resolver/app/transform/TransformHandler.d.ts +4 -4
  73. package/resolver/app/transform/TransformHandler.js +46 -64
  74. package/resolver/app/transform/TransformHandler.js.map +1 -1
  75. package/resolver/app/transform/middleware.d.ts +1 -1
  76. package/resolver/app/transform/middleware.js +12 -25
  77. package/resolver/app/transform/middleware.js.map +1 -1
  78. package/resolver/app/utils/Retry.js +21 -32
  79. package/resolver/app/utils/Retry.js.map +1 -1
  80. package/resolver/app/utils/sleep.js +4 -12
  81. package/resolver/app/utils/sleep.js.map +1 -1
  82. package/resolver/app/validation/body.d.ts +25 -124
  83. package/resolver/app/validation/body.js +31 -44
  84. package/resolver/app/validation/body.js.map +1 -1
  85. package/resolver/app/validation/createJsonTransform.d.ts +1 -1
  86. package/resolver/app/validation/createJsonTransform.js +13 -22
  87. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  88. package/resolver/app/validation/detail.d.ts +19 -72
  89. package/resolver/app/validation/detail.js +33 -46
  90. package/resolver/app/validation/detail.js.map +1 -1
  91. package/resolver/app/validation/event.d.ts +29 -188
  92. package/resolver/app/validation/event.js +21 -30
  93. package/resolver/app/validation/event.js.map +1 -1
  94. package/resolver/app/validation/numericString.d.ts +1 -1
  95. package/resolver/app/validation/numericString.js +9 -20
  96. package/resolver/app/validation/numericString.js.map +1 -1
  97. package/resolver/app/validation/system.d.ts +2 -14
  98. package/resolver/app/validation/system.js +9 -18
  99. package/resolver/app/validation/system.js.map +1 -1
  100. package/resolver/createEventHandlerPlugin.d.ts +2 -1
  101. package/resolver/createEventHandlerPlugin.js +85 -121
  102. package/resolver/createEventHandlerPlugin.js.map +1 -1
  103. package/resolver/createResolverHandler.d.ts +1 -1
  104. package/resolver/createResolverHandler.js +60 -75
  105. package/resolver/createResolverHandler.js.map +1 -1
  106. package/resolver/deployment/Deployment.d.ts +2 -3
  107. package/resolver/deployment/Deployment.js +27 -44
  108. package/resolver/deployment/Deployment.js.map +1 -1
  109. package/resolver/deployment/Deployments.js +19 -30
  110. package/resolver/deployment/Deployments.js.map +1 -1
  111. package/resolver/deployment/DeploymentsFetcher.js +82 -102
  112. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  113. package/resolver/deployment/types.d.ts +4 -6
  114. package/resolver/deployment/types.js +0 -7
  115. package/resolver/lambda/LambdaTrigger.js +25 -34
  116. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  117. package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
  118. package/resolver/plugins/CommandHandlerPlugin.js +17 -24
  119. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  120. package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
  121. package/resolver/plugins/StorerAfterEachPlugin.js +21 -29
  122. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  123. package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
  124. package/resolver/plugins/TransformRecordPlugin.js +20 -27
  125. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  126. package/resolver/recordTypes/fileManager/CopyFile.js +44 -74
  127. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  128. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
  129. package/resolver/recordTypes/fileManager/DeleteFile.js +40 -65
  130. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  131. package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
  132. package/resolver/recordTypes/fileManager/fileManager.js +7 -12
  133. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  134. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
  135. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +27 -45
  136. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  137. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
  138. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +27 -45
  139. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  140. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
  141. package/resolver/recordTypes/fileManager/shouldBeHandled.js +10 -34
  142. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  143. package/resolver/recordTypes/fileManager/types.d.ts +2 -2
  144. package/resolver/recordTypes/fileManager/types.js +0 -7
  145. package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
  146. package/resolver/recordTypes/users/CopyUser.js +44 -61
  147. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  148. package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
  149. package/resolver/recordTypes/users/DeleteUser.js +40 -58
  150. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  151. package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
  152. package/resolver/recordTypes/users/shouldBeHandled.js +10 -33
  153. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  154. package/resolver/recordTypes/users/types.d.ts +1 -1
  155. package/resolver/recordTypes/users/types.js +0 -7
  156. package/resolver/recordTypes/users/users.js +7 -12
  157. package/resolver/recordTypes/users/users.js.map +1 -1
  158. package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
  159. package/resolver/recordTypes/users/usersOnDelete.js +26 -44
  160. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  161. package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
  162. package/resolver/recordTypes/users/usersOnPut.js +27 -45
  163. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  164. package/sync/FilterOutRecord.d.ts +2 -2
  165. package/sync/FilterOutRecord.js +8 -24
  166. package/sync/FilterOutRecord.js.map +1 -1
  167. package/sync/attachToDynamoDbDocument.d.ts +1 -1
  168. package/sync/attachToDynamoDbDocument.js +48 -75
  169. package/sync/attachToDynamoDbDocument.js.map +1 -1
  170. package/sync/createHandler.js +44 -60
  171. package/sync/createHandler.js.map +1 -1
  172. package/sync/createSendDataToEventBridgeOnRequestEnd.js +34 -46
  173. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
  174. package/sync/createSyncSystem.d.ts +1 -1
  175. package/sync/createSyncSystem.js +27 -36
  176. package/sync/createSyncSystem.js.map +1 -1
  177. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
  178. package/sync/filter/createDefaultFilterOutRecordPlugins.js +37 -86
  179. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  180. package/sync/handler/Handler.d.ts +2 -2
  181. package/sync/handler/Handler.js +66 -86
  182. package/sync/handler/Handler.js.map +1 -1
  183. package/sync/handler/HandlerConverter.js +20 -36
  184. package/sync/handler/HandlerConverter.js.map +1 -1
  185. package/sync/handler/converter/BatchGetCommandConverter.js +13 -20
  186. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  187. package/sync/handler/converter/BatchWriteCommandConverter.js +13 -20
  188. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  189. package/sync/handler/converter/DeleteCommandConverter.js +13 -20
  190. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  191. package/sync/handler/converter/GetCommandConverter.js +13 -20
  192. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  193. package/sync/handler/converter/PutCommandConverter.js +13 -20
  194. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  195. package/sync/handler/converter/QueryCommandConverter.js +13 -20
  196. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  197. package/sync/handler/converter/ScanCommandConverter.js +13 -20
  198. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  199. package/sync/handler/converter/UpdateCommandConverter.js +13 -20
  200. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  201. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
  202. package/sync/handler/converter/commands/BatchWriteCommandValue.js +34 -44
  203. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  204. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
  205. package/sync/handler/converter/commands/DeleteCommandValue.js +19 -23
  206. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  207. package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
  208. package/sync/handler/converter/commands/NullCommandValue.js +7 -14
  209. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  210. package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
  211. package/sync/handler/converter/commands/PutCommandValue.js +19 -23
  212. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  213. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
  214. package/sync/handler/converter/commands/UpdateCommandValue.js +19 -23
  215. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  216. package/sync/handler/types.d.ts +3 -3
  217. package/sync/handler/types.js +0 -7
  218. package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
  219. package/sync/plugins/FilterOutRecordPlugin.js +18 -28
  220. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  221. package/sync/requestPlugin.d.ts +1 -1
  222. package/sync/requestPlugin.js +39 -55
  223. package/sync/requestPlugin.js.map +1 -1
  224. package/sync/types.js +0 -7
  225. package/sync/utils/getTableType.js +11 -19
  226. package/sync/utils/getTableType.js.map +1 -1
  227. package/sync/utils/manifest.d.ts +3 -7
  228. package/sync/utils/manifest.js +30 -47
  229. package/sync/utils/manifest.js.map +1 -1
  230. package/sync/utils/validateSystemInput.d.ts +1 -1
  231. package/sync/utils/validateSystemInput.js +22 -37
  232. package/sync/utils/validateSystemInput.js.map +1 -1
  233. package/types.d.ts +3 -5
  234. package/types.js +6 -12
  235. package/types.js.map +1 -1
  236. package/utils/createSystemName.js +5 -10
  237. package/utils/createSystemName.js.map +1 -1
  238. package/worker/actions/copyFile/CopyFile.js +185 -268
  239. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  240. package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
  241. package/worker/actions/copyFile/copyFileAction.js +30 -45
  242. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  243. package/worker/actions/copyFile/copyFileSchema.d.ts +6 -38
  244. package/worker/actions/copyFile/copyFileSchema.js +14 -23
  245. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  246. package/worker/actions/copyFile/types.js +0 -7
  247. package/worker/actions/createUser/CreateUser.d.ts +1 -1
  248. package/worker/actions/createUser/CreateUser.js +53 -83
  249. package/worker/actions/createUser/CreateUser.js.map +1 -1
  250. package/worker/actions/createUser/createUserAction.d.ts +2 -2
  251. package/worker/actions/createUser/createUserAction.js +28 -39
  252. package/worker/actions/createUser/createUserAction.js.map +1 -1
  253. package/worker/actions/createUser/createUserSchema.d.ts +6 -38
  254. package/worker/actions/createUser/createUserSchema.js +14 -23
  255. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  256. package/worker/actions/createUser/types.js +0 -7
  257. package/worker/actions/deleteFile/DeleteFile.js +52 -74
  258. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  259. package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
  260. package/worker/actions/deleteFile/deleteFileAction.js +25 -40
  261. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  262. package/worker/actions/deleteFile/deleteFileSchema.d.ts +6 -38
  263. package/worker/actions/deleteFile/deleteFileSchema.js +14 -23
  264. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  265. package/worker/actions/deleteFile/types.js +0 -7
  266. package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
  267. package/worker/actions/deleteUser/DeleteUser.js +39 -60
  268. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  269. package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
  270. package/worker/actions/deleteUser/deleteUserAction.js +26 -37
  271. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  272. package/worker/actions/deleteUser/deleteUserSchema.d.ts +5 -23
  273. package/worker/actions/deleteUser/deleteUserSchema.js +13 -22
  274. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  275. package/worker/actions/deleteUser/types.js +0 -7
  276. package/worker/actions/logValidationError.js +6 -14
  277. package/worker/actions/logValidationError.js.map +1 -1
  278. package/worker/actions/removeCognitoUserAttributes.js +9 -22
  279. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  280. package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
  281. package/worker/actions/updateUser/UpdateUser.js +50 -74
  282. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  283. package/worker/actions/updateUser/types.js +0 -7
  284. package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
  285. package/worker/actions/updateUser/updateUserAction.js +28 -39
  286. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  287. package/worker/actions/updateUser/updateUserSchema.d.ts +6 -38
  288. package/worker/actions/updateUser/updateUserSchema.js +14 -23
  289. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  290. package/worker/createWorkerHandler.js +32 -45
  291. package/worker/createWorkerHandler.js.map +1 -1
  292. package/worker/handler/WorkerActionHandler.d.ts +2 -2
  293. package/worker/handler/WorkerActionHandler.js +19 -28
  294. package/worker/handler/WorkerActionHandler.js.map +1 -1
  295. package/worker/handler/eventHandler.js +18 -27
  296. package/worker/handler/eventHandler.js.map +1 -1
  297. package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
  298. package/worker/plugins/WorkerActionPlugin.js +18 -25
  299. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  300. package/worker/types.js +0 -7
  301. package/index.js.map +0 -1
  302. package/resolver/app/abstractions/RecordHandler.js.map +0 -1
  303. package/resolver/app/abstractions/RecordsValidation.js.map +0 -1
  304. package/resolver/app/abstractions/ResolverApplication.js.map +0 -1
  305. package/resolver/app/abstractions/ResolverRecord.js.map +0 -1
  306. package/resolver/app/bundler/types.js.map +0 -1
  307. package/resolver/app/data/types.js.map +0 -1
  308. package/resolver/app/fetcher/types.js.map +0 -1
  309. package/resolver/app/ingestor/types.js.map +0 -1
  310. package/resolver/app/storer/types.js.map +0 -1
  311. package/resolver/deployment/types.js.map +0 -1
  312. package/resolver/recordTypes/fileManager/types.js.map +0 -1
  313. package/resolver/recordTypes/users/types.js.map +0 -1
  314. package/sync/handler/types.js.map +0 -1
  315. package/sync/types.js.map +0 -1
  316. package/worker/actions/copyFile/types.js.map +0 -1
  317. package/worker/actions/createUser/types.js.map +0 -1
  318. package/worker/actions/deleteFile/types.js.map +0 -1
  319. package/worker/actions/deleteUser/types.js.map +0 -1
  320. package/worker/actions/updateUser/types.js.map +0 -1
  321. package/worker/types.js.map +0 -1
@@ -1,48 +1,30 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createUserOnPutPlugin = void 0;
7
- var _StorerAfterEachPlugin = require("../../plugins/StorerAfterEachPlugin.js");
8
- var _shouldBeHandled = require("./shouldBeHandled.js");
9
- var _utils = require("@webiny/utils");
10
- const createUserOnPutPlugin = params => {
11
- const {
12
- copyUser
13
- } = params;
14
- return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("users.onPut", {
15
- canHandle: params => {
16
- const {
17
- command
18
- } = params;
19
- if (command !== "put") {
20
- return false;
21
- }
22
- return (0, _shouldBeHandled.shouldBeHandled)(params);
23
- },
24
- handle: async params => {
25
- const {
26
- item
27
- } = params;
28
- /**
29
- * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.
30
- */
31
- // @ts-expect-error
32
- const username = item.data.email;
33
- try {
34
- await copyUser.handle({
35
- target: params.target,
36
- source: params.source,
37
- username
38
- });
39
- } catch (ex) {
40
- console.error("Error while handling users onPut plugin.");
41
- console.log((0, _utils.convertException)(ex));
42
- }
43
- }
44
- });
1
+ import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
2
+ import { shouldBeHandled } from "./shouldBeHandled.js";
3
+ import { convertException } from "@webiny/utils";
4
+ const createUserOnPutPlugin = (params)=>{
5
+ const { copyUser } = params;
6
+ return createStorerAfterEachPluginWithName("users.onPut", {
7
+ canHandle: (params)=>{
8
+ const { command } = params;
9
+ if ("put" !== command) return false;
10
+ return shouldBeHandled(params);
11
+ },
12
+ handle: async (params)=>{
13
+ const { item } = params;
14
+ const username = item.data.email;
15
+ try {
16
+ await copyUser.handle({
17
+ target: params.target,
18
+ source: params.source,
19
+ username
20
+ });
21
+ } catch (ex) {
22
+ console.error("Error while handling users onPut plugin.");
23
+ console.log(convertException(ex));
24
+ }
25
+ }
26
+ });
45
27
  };
46
- exports.createUserOnPutPlugin = createUserOnPutPlugin;
28
+ export { createUserOnPutPlugin };
47
29
 
48
30
  //# sourceMappingURL=usersOnPut.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_StorerAfterEachPlugin","require","_shouldBeHandled","_utils","createUserOnPutPlugin","params","copyUser","createStorerAfterEachPluginWithName","canHandle","command","shouldBeHandled","handle","item","username","data","email","target","source","ex","console","error","log","convertException","exports"],"sources":["usersOnPut.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { ICopyUser } from \"~/resolver/recordTypes/users/types.js\";\n\nexport interface ICreateUserOnPutPluginParams {\n copyUser: ICopyUser;\n}\n\nexport const createUserOnPutPlugin = (params: ICreateUserOnPutPluginParams) => {\n const { copyUser } = params;\n\n return createStorerAfterEachPluginWithName(\"users.onPut\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"put\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const username = item.data.email as string;\n try {\n await copyUser.handle({\n target: params.target,\n source: params.source,\n username\n });\n } catch (ex) {\n console.error(\"Error while handling users onPut plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,qBAAqB,GAAIC,MAAoC,IAAK;EAC3E,MAAM;IAAEC;EAAS,CAAC,GAAGD,MAAM;EAE3B,OAAO,IAAAE,0DAAmC,EAAC,aAAa,EAAE;IACtDC,SAAS,EAAEH,MAAM,IAAI;MACjB,MAAM;QAAEI;MAAQ,CAAC,GAAGJ,MAAM;MAC1B,IAAII,OAAO,KAAK,KAAK,EAAE;QACnB,OAAO,KAAK;MAChB;MACA,OAAO,IAAAC,gCAAe,EAACL,MAAM,CAAC;IAClC,CAAC;IACDM,MAAM,EAAE,MAAMN,MAAM,IAAI;MACpB,MAAM;QAAEO;MAAK,CAAC,GAAGP,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMQ,QAAQ,GAAGD,IAAI,CAACE,IAAI,CAACC,KAAe;MAC1C,IAAI;QACA,MAAMT,QAAQ,CAACK,MAAM,CAAC;UAClBK,MAAM,EAAEX,MAAM,CAACW,MAAM;UACrBC,MAAM,EAAEZ,MAAM,CAACY,MAAM;UACrBJ;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOK,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,0CAA0C,CAAC;QACzDD,OAAO,CAACE,GAAG,CAAC,IAAAC,uBAAgB,EAACJ,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"resolver/recordTypes/users/usersOnPut.js","sources":["../../../../src/resolver/recordTypes/users/usersOnPut.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { ICopyUser } from \"~/resolver/recordTypes/users/types.js\";\n\nexport interface ICreateUserOnPutPluginParams {\n copyUser: ICopyUser;\n}\n\nexport const createUserOnPutPlugin = (params: ICreateUserOnPutPluginParams) => {\n const { copyUser } = params;\n\n return createStorerAfterEachPluginWithName(\"users.onPut\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"put\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const username = item.data.email as string;\n try {\n await copyUser.handle({\n target: params.target,\n source: params.source,\n username\n });\n } catch (ex) {\n console.error(\"Error while handling users onPut plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"names":["createUserOnPutPlugin","params","copyUser","createStorerAfterEachPluginWithName","command","shouldBeHandled","item","username","ex","console","convertException"],"mappings":";;;AASO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,OAAOE,oCAAoC,eAAe;QACtD,WAAWF,CAAAA;YACP,MAAM,EAAEG,OAAO,EAAE,GAAGH;YACpB,IAAIG,AAAY,UAAZA,SACA,OAAO;YAEX,OAAOC,gBAAgBJ;QAC3B;QACA,QAAQ,OAAMA;YACV,MAAM,EAAEK,IAAI,EAAE,GAAGL;YAKjB,MAAMM,WAAWD,KAAK,IAAI,CAAC,KAAK;YAChC,IAAI;gBACA,MAAMJ,SAAS,MAAM,CAAC;oBAClB,QAAQD,OAAO,MAAM;oBACrB,QAAQA,OAAO,MAAM;oBACrBM;gBACJ;YACJ,EAAE,OAAOC,IAAI;gBACTC,QAAQ,KAAK,CAAC;gBACdA,QAAQ,GAAG,CAACC,iBAAiBF;YACjC;QACJ;IACJ;AACJ"}
@@ -1,5 +1,5 @@
1
- import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
2
- import type { ICommandValueItemExtended } from "./types.js";
1
+ import type { FilterOutRecordPlugin } from "../sync/plugins/FilterOutRecordPlugin.js";
2
+ import type { ICommandValueItemExtended } from "../sync/types.js";
3
3
  export declare class FilterOutRecord {
4
4
  private readonly plugins;
5
5
  constructor(plugins: FilterOutRecordPlugin[]);
@@ -1,29 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFilterOutRecord = exports.FilterOutRecord = void 0;
7
1
  class FilterOutRecord {
8
- constructor(plugins) {
9
- this.plugins = plugins;
10
- }
11
- /**
12
- * If method returns `true`, the record will be filtered out.
13
- */
14
- filterOut(item) {
15
- for (const plugin of this.plugins) {
16
- if (plugin.execute(item)) {
17
- return true;
18
- }
2
+ constructor(plugins){
3
+ this.plugins = plugins;
4
+ }
5
+ filterOut(item) {
6
+ for (const plugin of this.plugins)if (plugin.execute(item)) return true;
7
+ return false;
19
8
  }
20
- return false;
21
- }
22
9
  }
23
- exports.FilterOutRecord = FilterOutRecord;
24
- const createFilterOutRecord = plugins => {
25
- return new FilterOutRecord(plugins);
26
- };
27
- exports.createFilterOutRecord = createFilterOutRecord;
10
+ const createFilterOutRecord = (plugins)=>new FilterOutRecord(plugins);
11
+ export { FilterOutRecord, createFilterOutRecord };
28
12
 
29
13
  //# sourceMappingURL=FilterOutRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FilterOutRecord","constructor","plugins","filterOut","item","plugin","execute","exports","createFilterOutRecord"],"sources":["FilterOutRecord.ts"],"sourcesContent":["import type { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport type { ICommandValueItemExtended } from \"~/sync/types.js\";\n\nexport class FilterOutRecord {\n private readonly plugins: FilterOutRecordPlugin[];\n\n public constructor(plugins: FilterOutRecordPlugin[]) {\n this.plugins = plugins;\n }\n /**\n * If method returns `true`, the record will be filtered out.\n */\n public filterOut(item: ICommandValueItemExtended): boolean {\n for (const plugin of this.plugins) {\n if (plugin.execute(item)) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport const createFilterOutRecord = (plugins: FilterOutRecordPlugin[]): FilterOutRecord => {\n return new FilterOutRecord(plugins);\n};\n"],"mappings":";;;;;;AAGO,MAAMA,eAAe,CAAC;EAGlBC,WAAWA,CAACC,OAAgC,EAAE;IACjD,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EACA;AACJ;AACA;EACWC,SAASA,CAACC,IAA+B,EAAW;IACvD,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;MAC/B,IAAIG,MAAM,CAACC,OAAO,CAACF,IAAI,CAAC,EAAE;QACtB,OAAO,IAAI;MACf;IACJ;IACA,OAAO,KAAK;EAChB;AACJ;AAACG,OAAA,CAAAP,eAAA,GAAAA,eAAA;AAEM,MAAMQ,qBAAqB,GAAIN,OAAgC,IAAsB;EACxF,OAAO,IAAIF,eAAe,CAACE,OAAO,CAAC;AACvC,CAAC;AAACK,OAAA,CAAAC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"sync/FilterOutRecord.js","sources":["../../src/sync/FilterOutRecord.ts"],"sourcesContent":["import type { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport type { ICommandValueItemExtended } from \"~/sync/types.js\";\n\nexport class FilterOutRecord {\n private readonly plugins: FilterOutRecordPlugin[];\n\n public constructor(plugins: FilterOutRecordPlugin[]) {\n this.plugins = plugins;\n }\n /**\n * If method returns `true`, the record will be filtered out.\n */\n public filterOut(item: ICommandValueItemExtended): boolean {\n for (const plugin of this.plugins) {\n if (plugin.execute(item)) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport const createFilterOutRecord = (plugins: FilterOutRecordPlugin[]): FilterOutRecord => {\n return new FilterOutRecord(plugins);\n};\n"],"names":["FilterOutRecord","plugins","item","plugin","createFilterOutRecord"],"mappings":"AAGO,MAAMA;IAGT,YAAmBC,OAAgC,CAAE;QACjD,IAAI,CAAC,OAAO,GAAGA;IACnB;IAIO,UAAUC,IAA+B,EAAW;QACvD,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAC7B,IAAIA,OAAO,OAAO,CAACD,OACf,OAAO;QAGf,OAAO;IACX;AACJ;AAEO,MAAME,wBAAwB,CAACH,UAC3B,IAAID,gBAAgBC"}
@@ -1,4 +1,4 @@
1
- import type { IHandler } from "./types.js";
1
+ import type { IHandler } from "../sync/types.js";
2
2
  import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
3
  export interface IAttachToDynamoDbDocumentParams {
4
4
  handler: IHandler;
@@ -1,79 +1,52 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.decorateClientWithHandler = exports.attachToDynamoDbDocument = void 0;
7
- var _getDocumentClient = require("@webiny/aws-sdk/client-dynamodb/getDocumentClient");
8
- var _index = require("@webiny/aws-sdk/client-dynamodb/index.js");
9
- const decorateClientWithHandler = params => {
10
- const {
11
- handler,
12
- client
13
- } = params;
14
- /**
15
- * Is there a possibility that this is already attached?
16
- * Let's check for the handler and then skip attaching.
17
- */
18
- // @ts-expect-error
19
- if (client.__webinyHandler?.id === handler.id) {
1
+ import { decorateDocumentClient } from "@webiny/aws-sdk/client-dynamodb/getDocumentClient.js";
2
+ import { BatchWriteCommand, DeleteCommand, PutCommand, UpdateCommand } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
+ const decorateClientWithHandler = (params)=>{
4
+ const { handler, client } = params;
5
+ if (client.__webinyHandler?.id === handler.id) return client;
6
+ const originalSend = client.send;
7
+ const originalPut = client.put;
8
+ const originalDelete = client.delete;
9
+ const originalUpdate = client.update;
10
+ const originalBatchWrite = client.batchWrite;
11
+ client.__webinyHandler = handler;
12
+ client.send = async (params)=>{
13
+ handler.add(params);
14
+ return originalSend.apply(client, [
15
+ params
16
+ ]);
17
+ };
18
+ client.put = async (params)=>{
19
+ const cmd = new PutCommand(params);
20
+ handler.add(cmd);
21
+ return originalPut.apply(client, [
22
+ params
23
+ ]);
24
+ };
25
+ client.delete = async (params)=>{
26
+ const cmd = new DeleteCommand(params);
27
+ handler.add(cmd);
28
+ return originalDelete.apply(client, [
29
+ params
30
+ ]);
31
+ };
32
+ client.batchWrite = async (params)=>{
33
+ const cmd = new BatchWriteCommand(params);
34
+ handler.add(cmd);
35
+ return originalBatchWrite.apply(client, [
36
+ params
37
+ ]);
38
+ };
39
+ client.update = async (params)=>{
40
+ const cmd = new UpdateCommand(params);
41
+ handler.add(cmd);
42
+ return originalUpdate(params);
43
+ };
20
44
  return client;
21
- }
22
- const originalSend = client.send;
23
- const originalPut = client.put;
24
- const originalDelete = client.delete;
25
- const originalUpdate = client.update;
26
- const originalBatchWrite = client.batchWrite;
27
-
28
- // @ts-expect-error
29
- client.__webinyHandler = handler;
30
- client.send = async params => {
31
- // @ts-expect-error
32
- handler.add(params);
33
- // @ts-expect-error
34
- return originalSend.apply(client, [params]);
35
- };
36
- // @ts-expect-error
37
- client.put = async params => {
38
- const cmd = new _index.PutCommand(params);
39
- handler.add(cmd);
40
- // @ts-expect-error
41
- return originalPut.apply(client, [params]);
42
- };
43
-
44
- // @ts-expect-error
45
- client.delete = async params => {
46
- const cmd = new _index.DeleteCommand(params);
47
- handler.add(cmd);
48
- // @ts-expect-error
49
- return originalDelete.apply(client, [params]);
50
- };
51
-
52
- // @ts-expect-error
53
- client.batchWrite = async params => {
54
- const cmd = new _index.BatchWriteCommand(params);
55
- handler.add(cmd);
56
- // @ts-expect-error
57
- return originalBatchWrite.apply(client, [params]);
58
- };
59
- client.update = async params => {
60
- const cmd = new _index.UpdateCommand(params);
61
- handler.add(cmd);
62
- return originalUpdate(params);
63
- };
64
- return client;
65
- };
66
- exports.decorateClientWithHandler = decorateClientWithHandler;
67
- const attachToDynamoDbDocument = ({
68
- handler
69
- }) => {
70
- return (0, _getDocumentClient.decorateDocumentClient)(client => {
71
- return decorateClientWithHandler({
72
- handler,
73
- client
74
- });
75
- });
76
45
  };
77
- exports.attachToDynamoDbDocument = attachToDynamoDbDocument;
46
+ const attachToDynamoDbDocument = ({ handler })=>decorateDocumentClient((client)=>decorateClientWithHandler({
47
+ handler,
48
+ client
49
+ }));
50
+ export { attachToDynamoDbDocument, decorateClientWithHandler };
78
51
 
79
52
  //# sourceMappingURL=attachToDynamoDbDocument.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_getDocumentClient","require","_index","decorateClientWithHandler","params","handler","client","__webinyHandler","id","originalSend","send","originalPut","put","originalDelete","delete","originalUpdate","update","originalBatchWrite","batchWrite","add","apply","cmd","PutCommand","DeleteCommand","BatchWriteCommand","UpdateCommand","exports","attachToDynamoDbDocument","decorateDocumentClient"],"sources":["attachToDynamoDbDocument.ts"],"sourcesContent":["import { decorateDocumentClient } from \"@webiny/aws-sdk/client-dynamodb/getDocumentClient\";\nimport type { IHandler } from \"~/sync/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport {\n BatchWriteCommand,\n DeleteCommand,\n PutCommand,\n UpdateCommand\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport interface IAttachToDynamoDbDocumentParams {\n handler: IHandler;\n}\n\nexport interface IDecorateClientWithHandlerParams {\n handler: IHandler;\n client: DynamoDBDocument;\n}\n\nexport const decorateClientWithHandler = (\n params: IDecorateClientWithHandlerParams\n): DynamoDBDocument => {\n const { handler, client } = params;\n /**\n * Is there a possibility that this is already attached?\n * Let's check for the handler and then skip attaching.\n */\n // @ts-expect-error\n if (client.__webinyHandler?.id === handler.id) {\n return client;\n }\n\n const originalSend = client.send;\n const originalPut = client.put;\n const originalDelete = client.delete;\n const originalUpdate = client.update;\n const originalBatchWrite = client.batchWrite;\n\n // @ts-expect-error\n client.__webinyHandler = handler;\n\n client.send = async params => {\n // @ts-expect-error\n handler.add(params);\n // @ts-expect-error\n return originalSend.apply(client, [params]);\n };\n // @ts-expect-error\n client.put = async params => {\n const cmd = new PutCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalPut.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.delete = async params => {\n const cmd = new DeleteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalDelete.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.batchWrite = async params => {\n const cmd = new BatchWriteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalBatchWrite.apply(client, [params]);\n };\n\n client.update = async params => {\n const cmd = new UpdateCommand(params);\n handler.add(cmd);\n return originalUpdate(params);\n };\n\n return client;\n};\n\nexport const attachToDynamoDbDocument = ({ handler }: IAttachToDynamoDbDocumentParams): void => {\n return decorateDocumentClient(client => {\n return decorateClientWithHandler({\n handler,\n client\n });\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAgBO,MAAME,yBAAyB,GAClCC,MAAwC,IACrB;EACnB,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAClC;AACJ;AACA;AACA;EACI;EACA,IAAIE,MAAM,CAACC,eAAe,EAAEC,EAAE,KAAKH,OAAO,CAACG,EAAE,EAAE;IAC3C,OAAOF,MAAM;EACjB;EAEA,MAAMG,YAAY,GAAGH,MAAM,CAACI,IAAI;EAChC,MAAMC,WAAW,GAAGL,MAAM,CAACM,GAAG;EAC9B,MAAMC,cAAc,GAAGP,MAAM,CAACQ,MAAM;EACpC,MAAMC,cAAc,GAAGT,MAAM,CAACU,MAAM;EACpC,MAAMC,kBAAkB,GAAGX,MAAM,CAACY,UAAU;;EAE5C;EACAZ,MAAM,CAACC,eAAe,GAAGF,OAAO;EAEhCC,MAAM,CAACI,IAAI,GAAG,MAAMN,MAAM,IAAI;IAC1B;IACAC,OAAO,CAACc,GAAG,CAACf,MAAM,CAAC;IACnB;IACA,OAAOK,YAAY,CAACW,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EAC/C,CAAC;EACD;EACAE,MAAM,CAACM,GAAG,GAAG,MAAMR,MAAM,IAAI;IACzB,MAAMiB,GAAG,GAAG,IAAIC,iBAAU,CAAClB,MAAM,CAAC;IAClCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOV,WAAW,CAACS,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EAC9C,CAAC;;EAED;EACAE,MAAM,CAACQ,MAAM,GAAG,MAAMV,MAAM,IAAI;IAC5B,MAAMiB,GAAG,GAAG,IAAIE,oBAAa,CAACnB,MAAM,CAAC;IACrCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOR,cAAc,CAACO,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EACjD,CAAC;;EAED;EACAE,MAAM,CAACY,UAAU,GAAG,MAAMd,MAAM,IAAI;IAChC,MAAMiB,GAAG,GAAG,IAAIG,wBAAiB,CAACpB,MAAM,CAAC;IACzCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOJ,kBAAkB,CAACG,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EACrD,CAAC;EAEDE,MAAM,CAACU,MAAM,GAAG,MAAMZ,MAAM,IAAI;IAC5B,MAAMiB,GAAG,GAAG,IAAII,oBAAa,CAACrB,MAAM,CAAC;IACrCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB,OAAON,cAAc,CAACX,MAAM,CAAC;EACjC,CAAC;EAED,OAAOE,MAAM;AACjB,CAAC;AAACoB,OAAA,CAAAvB,yBAAA,GAAAA,yBAAA;AAEK,MAAMwB,wBAAwB,GAAGA,CAAC;EAAEtB;AAAyC,CAAC,KAAW;EAC5F,OAAO,IAAAuB,yCAAsB,EAACtB,MAAM,IAAI;IACpC,OAAOH,yBAAyB,CAAC;MAC7BE,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACoB,OAAA,CAAAC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"file":"sync/attachToDynamoDbDocument.js","sources":["../../src/sync/attachToDynamoDbDocument.ts"],"sourcesContent":["import { decorateDocumentClient } from \"@webiny/aws-sdk/client-dynamodb/getDocumentClient.js\";\nimport type { IHandler } from \"~/sync/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport {\n BatchWriteCommand,\n DeleteCommand,\n PutCommand,\n UpdateCommand\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport interface IAttachToDynamoDbDocumentParams {\n handler: IHandler;\n}\n\nexport interface IDecorateClientWithHandlerParams {\n handler: IHandler;\n client: DynamoDBDocument;\n}\n\nexport const decorateClientWithHandler = (\n params: IDecorateClientWithHandlerParams\n): DynamoDBDocument => {\n const { handler, client } = params;\n /**\n * Is there a possibility that this is already attached?\n * Let's check for the handler and then skip attaching.\n */\n // @ts-expect-error\n if (client.__webinyHandler?.id === handler.id) {\n return client;\n }\n\n const originalSend = client.send;\n const originalPut = client.put;\n const originalDelete = client.delete;\n const originalUpdate = client.update;\n const originalBatchWrite = client.batchWrite;\n\n // @ts-expect-error\n client.__webinyHandler = handler;\n\n client.send = async params => {\n // @ts-expect-error\n handler.add(params);\n // @ts-expect-error\n return originalSend.apply(client, [params]);\n };\n // @ts-expect-error\n client.put = async params => {\n const cmd = new PutCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalPut.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.delete = async params => {\n const cmd = new DeleteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalDelete.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.batchWrite = async params => {\n const cmd = new BatchWriteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalBatchWrite.apply(client, [params]);\n };\n\n client.update = async params => {\n const cmd = new UpdateCommand(params);\n handler.add(cmd);\n return originalUpdate(params);\n };\n\n return client;\n};\n\nexport const attachToDynamoDbDocument = ({ handler }: IAttachToDynamoDbDocumentParams): void => {\n return decorateDocumentClient(client => {\n return decorateClientWithHandler({\n handler,\n client\n });\n });\n};\n"],"names":["decorateClientWithHandler","params","handler","client","originalSend","originalPut","originalDelete","originalUpdate","originalBatchWrite","cmd","PutCommand","DeleteCommand","BatchWriteCommand","UpdateCommand","attachToDynamoDbDocument","decorateDocumentClient"],"mappings":";;AAmBO,MAAMA,4BAA4B,CACrCC;IAEA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAM5B,IAAIE,OAAO,eAAe,EAAE,OAAOD,QAAQ,EAAE,EACzC,OAAOC;IAGX,MAAMC,eAAeD,OAAO,IAAI;IAChC,MAAME,cAAcF,OAAO,GAAG;IAC9B,MAAMG,iBAAiBH,OAAO,MAAM;IACpC,MAAMI,iBAAiBJ,OAAO,MAAM;IACpC,MAAMK,qBAAqBL,OAAO,UAAU;IAG5CA,OAAO,eAAe,GAAGD;IAEzBC,OAAO,IAAI,GAAG,OAAMF;QAEhBC,QAAQ,GAAG,CAACD;QAEZ,OAAOG,aAAa,KAAK,CAACD,QAAQ;YAACF;SAAO;IAC9C;IAEAE,OAAO,GAAG,GAAG,OAAMF;QACf,MAAMQ,MAAM,IAAIC,WAAWT;QAC3BC,QAAQ,GAAG,CAACO;QAEZ,OAAOJ,YAAY,KAAK,CAACF,QAAQ;YAACF;SAAO;IAC7C;IAGAE,OAAO,MAAM,GAAG,OAAMF;QAClB,MAAMQ,MAAM,IAAIE,cAAcV;QAC9BC,QAAQ,GAAG,CAACO;QAEZ,OAAOH,eAAe,KAAK,CAACH,QAAQ;YAACF;SAAO;IAChD;IAGAE,OAAO,UAAU,GAAG,OAAMF;QACtB,MAAMQ,MAAM,IAAIG,kBAAkBX;QAClCC,QAAQ,GAAG,CAACO;QAEZ,OAAOD,mBAAmB,KAAK,CAACL,QAAQ;YAACF;SAAO;IACpD;IAEAE,OAAO,MAAM,GAAG,OAAMF;QAClB,MAAMQ,MAAM,IAAII,cAAcZ;QAC9BC,QAAQ,GAAG,CAACO;QACZ,OAAOF,eAAeN;IAC1B;IAEA,OAAOE;AACX;AAEO,MAAMW,2BAA2B,CAAC,EAAEZ,OAAO,EAAmC,GAC1Ea,uBAAuBZ,CAAAA,SACnBH,0BAA0B;YAC7BE;YACAC;QACJ"}
@@ -1,63 +1,47 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createHandler = void 0;
7
- var _HandlerConverter = require("./handler/HandlerConverter.js");
8
- var _NullCommandValue = require("./handler/converter/commands/NullCommandValue.js");
9
- var _BatchWriteCommandConverter = require("./handler/converter/BatchWriteCommandConverter.js");
10
- var _PutCommandConverter = require("./handler/converter/PutCommandConverter.js");
11
- var _DeleteCommandConverter = require("./handler/converter/DeleteCommandConverter.js");
12
- var _UpdateCommandConverter = require("./handler/converter/UpdateCommandConverter.js");
13
- var _Handler = require("./handler/Handler.js");
14
- var _BatchGetCommandConverter = require("./handler/converter/BatchGetCommandConverter.js");
15
- var _QueryCommandConverter = require("./handler/converter/QueryCommandConverter.js");
16
- var _ScanCommandConverter = require("./handler/converter/ScanCommandConverter.js");
17
- var _GetCommandConverter = require("./handler/converter/GetCommandConverter.js");
18
- var _FilterOutRecordPlugin = require("./plugins/FilterOutRecordPlugin.js");
19
- var _FilterOutRecord = require("./FilterOutRecord.js");
20
- const createHandler = params => {
21
- const {
22
- manifest,
23
- commandConverters,
24
- system,
25
- getEventBridgeClient,
26
- getPlugins
27
- } = params;
28
- const filterOutRecordPlugins = getPlugins().byType(_FilterOutRecordPlugin.FilterOutRecordPlugin.type);
29
- const filterOutRecord = (0, _FilterOutRecord.createFilterOutRecord)(filterOutRecordPlugins);
30
- const converter = (0, _HandlerConverter.createHandlerConverter)({
31
- defaultValue: new _NullCommandValue.NullCommandValue()
32
- });
33
- /**
34
- * We register users command converters because those are tested out first.
35
- * Our converters are in some order I got from my head - the most used commands are first.
36
- */
37
- converter.register(commandConverters || []);
38
- converter.register((0, _BatchGetCommandConverter.createBatchGetCommandConverter)());
39
- converter.register((0, _GetCommandConverter.createGetCommandConverter)());
40
- converter.register((0, _QueryCommandConverter.createQueryCommandConverter)());
41
- converter.register((0, _ScanCommandConverter.createScanCommandConverter)());
42
- converter.register((0, _BatchWriteCommandConverter.createBatchWriteCommandConverter)());
43
- converter.register((0, _PutCommandConverter.createPutCommandConverter)());
44
- converter.register((0, _DeleteCommandConverter.createDeleteCommandConverter)());
45
- converter.register((0, _UpdateCommandConverter.createUpdateCommandConverter)());
46
- const handler = (0, _Handler.createSyncHandler)({
47
- system,
48
- getEventBridgeClient,
49
- eventBus: {
50
- arn: manifest.sync.eventBusArn,
51
- name: manifest.sync.eventBusName
52
- },
53
- converter,
54
- filterOutRecord
55
- });
56
- return {
57
- handler,
58
- converter
59
- };
1
+ import { createHandlerConverter } from "./handler/HandlerConverter.js";
2
+ import { NullCommandValue } from "./handler/converter/commands/NullCommandValue.js";
3
+ import { createBatchWriteCommandConverter } from "./handler/converter/BatchWriteCommandConverter.js";
4
+ import { createPutCommandConverter } from "./handler/converter/PutCommandConverter.js";
5
+ import { createDeleteCommandConverter } from "./handler/converter/DeleteCommandConverter.js";
6
+ import { createUpdateCommandConverter } from "./handler/converter/UpdateCommandConverter.js";
7
+ import { createSyncHandler } from "./handler/Handler.js";
8
+ import { createBatchGetCommandConverter } from "./handler/converter/BatchGetCommandConverter.js";
9
+ import { createQueryCommandConverter } from "./handler/converter/QueryCommandConverter.js";
10
+ import { createScanCommandConverter } from "./handler/converter/ScanCommandConverter.js";
11
+ import { createGetCommandConverter } from "./handler/converter/GetCommandConverter.js";
12
+ import { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
13
+ import { createFilterOutRecord } from "./FilterOutRecord.js";
14
+ const createHandler = (params)=>{
15
+ const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;
16
+ const filterOutRecordPlugins = getPlugins().byType(FilterOutRecordPlugin.type);
17
+ const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);
18
+ const converter = createHandlerConverter({
19
+ defaultValue: new NullCommandValue()
20
+ });
21
+ converter.register(commandConverters || []);
22
+ converter.register(createBatchGetCommandConverter());
23
+ converter.register(createGetCommandConverter());
24
+ converter.register(createQueryCommandConverter());
25
+ converter.register(createScanCommandConverter());
26
+ converter.register(createBatchWriteCommandConverter());
27
+ converter.register(createPutCommandConverter());
28
+ converter.register(createDeleteCommandConverter());
29
+ converter.register(createUpdateCommandConverter());
30
+ const handler = createSyncHandler({
31
+ system,
32
+ getEventBridgeClient,
33
+ eventBus: {
34
+ arn: manifest.sync.eventBusArn,
35
+ name: manifest.sync.eventBusName
36
+ },
37
+ converter,
38
+ filterOutRecord
39
+ });
40
+ return {
41
+ handler,
42
+ converter
43
+ };
60
44
  };
61
- exports.createHandler = createHandler;
45
+ export { createHandler };
62
46
 
63
47
  //# sourceMappingURL=createHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_HandlerConverter","require","_NullCommandValue","_BatchWriteCommandConverter","_PutCommandConverter","_DeleteCommandConverter","_UpdateCommandConverter","_Handler","_BatchGetCommandConverter","_QueryCommandConverter","_ScanCommandConverter","_GetCommandConverter","_FilterOutRecordPlugin","_FilterOutRecord","createHandler","params","manifest","commandConverters","system","getEventBridgeClient","getPlugins","filterOutRecordPlugins","byType","FilterOutRecordPlugin","type","filterOutRecord","createFilterOutRecord","converter","createHandlerConverter","defaultValue","NullCommandValue","register","createBatchGetCommandConverter","createGetCommandConverter","createQueryCommandConverter","createScanCommandConverter","createBatchWriteCommandConverter","createPutCommandConverter","createDeleteCommandConverter","createUpdateCommandConverter","handler","createSyncHandler","eventBus","arn","sync","eventBusArn","name","eventBusName","exports"],"sources":["createHandler.ts"],"sourcesContent":["import { createHandlerConverter } from \"~/sync/handler/HandlerConverter.js\";\nimport { NullCommandValue } from \"~/sync/handler/converter/commands/NullCommandValue.js\";\nimport { createBatchWriteCommandConverter } from \"~/sync/handler/converter/BatchWriteCommandConverter.js\";\nimport { createPutCommandConverter } from \"~/sync/handler/converter/PutCommandConverter.js\";\nimport { createDeleteCommandConverter } from \"~/sync/handler/converter/DeleteCommandConverter.js\";\nimport { createUpdateCommandConverter } from \"~/sync/handler/converter/UpdateCommandConverter.js\";\nimport { createSyncHandler } from \"~/sync/handler/Handler.js\";\nimport type { EventBridgeClient } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport type { ICommandConverter, IManifest, ISystem } from \"./types.js\";\nimport { createBatchGetCommandConverter } from \"./handler/converter/BatchGetCommandConverter.js\";\nimport { createQueryCommandConverter } from \"./handler/converter/QueryCommandConverter.js\";\nimport { createScanCommandConverter } from \"~/sync/handler/converter/ScanCommandConverter.js\";\nimport { createGetCommandConverter } from \"./handler/converter/GetCommandConverter.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\nimport { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport { createFilterOutRecord } from \"~/sync/FilterOutRecord.js\";\n\nexport interface ICreateHandlerParams {\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n commandConverters?: ICommandConverter[];\n system: ISystem;\n manifest: IManifest;\n getPlugins: () => PluginsContainer;\n}\n\nexport const createHandler = (params: ICreateHandlerParams) => {\n const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;\n\n const filterOutRecordPlugins = getPlugins().byType<FilterOutRecordPlugin>(\n FilterOutRecordPlugin.type\n );\n\n const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);\n\n const converter = createHandlerConverter({\n defaultValue: new NullCommandValue()\n });\n /**\n * We register users command converters because those are tested out first.\n * Our converters are in some order I got from my head - the most used commands are first.\n */\n converter.register(commandConverters || []);\n converter.register(createBatchGetCommandConverter());\n converter.register(createGetCommandConverter());\n converter.register(createQueryCommandConverter());\n converter.register(createScanCommandConverter());\n converter.register(createBatchWriteCommandConverter());\n converter.register(createPutCommandConverter());\n converter.register(createDeleteCommandConverter());\n converter.register(createUpdateCommandConverter());\n\n const handler = createSyncHandler({\n system,\n getEventBridgeClient,\n eventBus: {\n arn: manifest.sync.eventBusArn,\n name: manifest.sync.eventBusName\n },\n converter,\n filterOutRecord\n });\n return {\n handler,\n converter\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAGA,IAAAO,yBAAA,GAAAP,OAAA;AACA,IAAAQ,sBAAA,GAAAR,OAAA;AACA,IAAAS,qBAAA,GAAAT,OAAA;AACA,IAAAU,oBAAA,GAAAV,OAAA;AAEA,IAAAW,sBAAA,GAAAX,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AAUO,MAAMa,aAAa,GAAIC,MAA4B,IAAK;EAC3D,MAAM;IAAEC,QAAQ;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,oBAAoB;IAAEC;EAAW,CAAC,GAAGL,MAAM;EAExF,MAAMM,sBAAsB,GAAGD,UAAU,CAAC,CAAC,CAACE,MAAM,CAC9CC,4CAAqB,CAACC,IAC1B,CAAC;EAED,MAAMC,eAAe,GAAG,IAAAC,sCAAqB,EAACL,sBAAsB,CAAC;EAErE,MAAMM,SAAS,GAAG,IAAAC,wCAAsB,EAAC;IACrCC,YAAY,EAAE,IAAIC,kCAAgB,CAAC;EACvC,CAAC,CAAC;EACF;AACJ;AACA;AACA;EACIH,SAAS,CAACI,QAAQ,CAACd,iBAAiB,IAAI,EAAE,CAAC;EAC3CU,SAAS,CAACI,QAAQ,CAAC,IAAAC,wDAA8B,EAAC,CAAC,CAAC;EACpDL,SAAS,CAACI,QAAQ,CAAC,IAAAE,8CAAyB,EAAC,CAAC,CAAC;EAC/CN,SAAS,CAACI,QAAQ,CAAC,IAAAG,kDAA2B,EAAC,CAAC,CAAC;EACjDP,SAAS,CAACI,QAAQ,CAAC,IAAAI,gDAA0B,EAAC,CAAC,CAAC;EAChDR,SAAS,CAACI,QAAQ,CAAC,IAAAK,4DAAgC,EAAC,CAAC,CAAC;EACtDT,SAAS,CAACI,QAAQ,CAAC,IAAAM,8CAAyB,EAAC,CAAC,CAAC;EAC/CV,SAAS,CAACI,QAAQ,CAAC,IAAAO,oDAA4B,EAAC,CAAC,CAAC;EAClDX,SAAS,CAACI,QAAQ,CAAC,IAAAQ,oDAA4B,EAAC,CAAC,CAAC;EAElD,MAAMC,OAAO,GAAG,IAAAC,0BAAiB,EAAC;IAC9BvB,MAAM;IACNC,oBAAoB;IACpBuB,QAAQ,EAAE;MACNC,GAAG,EAAE3B,QAAQ,CAAC4B,IAAI,CAACC,WAAW;MAC9BC,IAAI,EAAE9B,QAAQ,CAAC4B,IAAI,CAACG;IACxB,CAAC;IACDpB,SAAS;IACTF;EACJ,CAAC,CAAC;EACF,OAAO;IACHe,OAAO;IACPb;EACJ,CAAC;AACL,CAAC;AAACqB,OAAA,CAAAlC,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"sync/createHandler.js","sources":["../../src/sync/createHandler.ts"],"sourcesContent":["import { createHandlerConverter } from \"~/sync/handler/HandlerConverter.js\";\nimport { NullCommandValue } from \"~/sync/handler/converter/commands/NullCommandValue.js\";\nimport { createBatchWriteCommandConverter } from \"~/sync/handler/converter/BatchWriteCommandConverter.js\";\nimport { createPutCommandConverter } from \"~/sync/handler/converter/PutCommandConverter.js\";\nimport { createDeleteCommandConverter } from \"~/sync/handler/converter/DeleteCommandConverter.js\";\nimport { createUpdateCommandConverter } from \"~/sync/handler/converter/UpdateCommandConverter.js\";\nimport { createSyncHandler } from \"~/sync/handler/Handler.js\";\nimport type { EventBridgeClient } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport type { ICommandConverter, IManifest, ISystem } from \"./types.js\";\nimport { createBatchGetCommandConverter } from \"./handler/converter/BatchGetCommandConverter.js\";\nimport { createQueryCommandConverter } from \"./handler/converter/QueryCommandConverter.js\";\nimport { createScanCommandConverter } from \"~/sync/handler/converter/ScanCommandConverter.js\";\nimport { createGetCommandConverter } from \"./handler/converter/GetCommandConverter.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\nimport { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport { createFilterOutRecord } from \"~/sync/FilterOutRecord.js\";\n\nexport interface ICreateHandlerParams {\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n commandConverters?: ICommandConverter[];\n system: ISystem;\n manifest: IManifest;\n getPlugins: () => PluginsContainer;\n}\n\nexport const createHandler = (params: ICreateHandlerParams) => {\n const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;\n\n const filterOutRecordPlugins = getPlugins().byType<FilterOutRecordPlugin>(\n FilterOutRecordPlugin.type\n );\n\n const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);\n\n const converter = createHandlerConverter({\n defaultValue: new NullCommandValue()\n });\n /**\n * We register users command converters because those are tested out first.\n * Our converters are in some order I got from my head - the most used commands are first.\n */\n converter.register(commandConverters || []);\n converter.register(createBatchGetCommandConverter());\n converter.register(createGetCommandConverter());\n converter.register(createQueryCommandConverter());\n converter.register(createScanCommandConverter());\n converter.register(createBatchWriteCommandConverter());\n converter.register(createPutCommandConverter());\n converter.register(createDeleteCommandConverter());\n converter.register(createUpdateCommandConverter());\n\n const handler = createSyncHandler({\n system,\n getEventBridgeClient,\n eventBus: {\n arn: manifest.sync.eventBusArn,\n name: manifest.sync.eventBusName\n },\n converter,\n filterOutRecord\n });\n return {\n handler,\n converter\n };\n};\n"],"names":["createHandler","params","manifest","commandConverters","system","getEventBridgeClient","getPlugins","filterOutRecordPlugins","FilterOutRecordPlugin","filterOutRecord","createFilterOutRecord","converter","createHandlerConverter","NullCommandValue","createBatchGetCommandConverter","createGetCommandConverter","createQueryCommandConverter","createScanCommandConverter","createBatchWriteCommandConverter","createPutCommandConverter","createDeleteCommandConverter","createUpdateCommandConverter","handler","createSyncHandler"],"mappings":";;;;;;;;;;;;;AAyBO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,MAAM,EAAEC,oBAAoB,EAAEC,UAAU,EAAE,GAAGL;IAElF,MAAMM,yBAAyBD,aAAa,MAAM,CAC9CE,sBAAsB,IAAI;IAG9B,MAAMC,kBAAkBC,sBAAsBH;IAE9C,MAAMI,YAAYC,uBAAuB;QACrC,cAAc,IAAIC;IACtB;IAKAF,UAAU,QAAQ,CAACR,qBAAqB,EAAE;IAC1CQ,UAAU,QAAQ,CAACG;IACnBH,UAAU,QAAQ,CAACI;IACnBJ,UAAU,QAAQ,CAACK;IACnBL,UAAU,QAAQ,CAACM;IACnBN,UAAU,QAAQ,CAACO;IACnBP,UAAU,QAAQ,CAACQ;IACnBR,UAAU,QAAQ,CAACS;IACnBT,UAAU,QAAQ,CAACU;IAEnB,MAAMC,UAAUC,kBAAkB;QAC9BnB;QACAC;QACA,UAAU;YACN,KAAKH,SAAS,IAAI,CAAC,WAAW;YAC9B,MAAMA,SAAS,IAAI,CAAC,YAAY;QACpC;QACAS;QACAF;IACJ;IACA,OAAO;QACHa;QACAX;IACJ;AACJ"}
@@ -1,51 +1,39 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSendDataToEventBridgeOnRequestEnd = void 0;
7
- var _handler = require("@webiny/handler");
8
- var _exception = require("@webiny/utils/exception.js");
9
- const execute = async handler => {
10
- try {
11
- return await handler.flush();
12
- } catch (ex) {
13
- const error = (0, _exception.convertException)(ex);
14
- console.error({
15
- flushError: error
16
- });
17
- return {
18
- error
19
- };
20
- /**
21
- * We do not want to throw an error here, because we are in the request end.
22
- */
23
- }
1
+ import { createOnRequestResponseSend, createOnRequestTimeout } from "@webiny/handler";
2
+ import { convertException } from "@webiny/utils/exception.js";
3
+ const execute = async (handler)=>{
4
+ try {
5
+ return await handler.flush();
6
+ } catch (ex) {
7
+ const error = convertException(ex);
8
+ console.error({
9
+ flushError: error
10
+ });
11
+ return {
12
+ error
13
+ };
14
+ }
24
15
  };
25
- const isOptionsRequest = request => {
26
- if (!request?.method) {
27
- return false;
28
- }
29
- return request.method.toUpperCase() === "OPTIONS";
16
+ const isOptionsRequest = (request)=>{
17
+ if (!request?.method) return false;
18
+ return "OPTIONS" === request.method.toUpperCase();
30
19
  };
31
- const createSendDataToEventBridgeOnRequestEnd = handler => {
32
- const onRequestResponseSend = (0, _handler.createOnRequestResponseSend)(async (request, _, payload) => {
33
- if (isOptionsRequest(request)) {
34
- return payload;
35
- }
36
- await execute(handler);
37
- return payload;
38
- });
39
- onRequestResponseSend.name = "sync.onRequestResponseSend";
40
- const onRequestTimeout = (0, _handler.createOnRequestTimeout)(async request => {
41
- if (isOptionsRequest(request)) {
42
- return;
43
- }
44
- return await execute(handler);
45
- });
46
- onRequestTimeout.name = "sync.onRequestTimeout";
47
- return [onRequestResponseSend, onRequestTimeout];
20
+ const createSendDataToEventBridgeOnRequestEnd = (handler)=>{
21
+ const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload)=>{
22
+ if (isOptionsRequest(request)) return payload;
23
+ await execute(handler);
24
+ return payload;
25
+ });
26
+ onRequestResponseSend.name = "sync.onRequestResponseSend";
27
+ const onRequestTimeout = createOnRequestTimeout(async (request)=>{
28
+ if (isOptionsRequest(request)) return;
29
+ return await execute(handler);
30
+ });
31
+ onRequestTimeout.name = "sync.onRequestTimeout";
32
+ return [
33
+ onRequestResponseSend,
34
+ onRequestTimeout
35
+ ];
48
36
  };
49
- exports.createSendDataToEventBridgeOnRequestEnd = createSendDataToEventBridgeOnRequestEnd;
37
+ export { createSendDataToEventBridgeOnRequestEnd };
50
38
 
51
39
  //# sourceMappingURL=createSendDataToEventBridgeOnRequestEnd.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","_exception","execute","handler","flush","ex","error","convertException","console","flushError","isOptionsRequest","request","method","toUpperCase","createSendDataToEventBridgeOnRequestEnd","onRequestResponseSend","createOnRequestResponseSend","_","payload","name","onRequestTimeout","createOnRequestTimeout","exports"],"sources":["createSendDataToEventBridgeOnRequestEnd.ts"],"sourcesContent":["import type { IHandler } from \"./types.js\";\nimport { createOnRequestResponseSend, createOnRequestTimeout } from \"@webiny/handler\";\nimport type { Request as FastifyRequest } from \"@webiny/handler/types\";\nimport { convertException } from \"@webiny/utils/exception.js\";\n\nconst execute = async (handler: IHandler) => {\n try {\n return await handler.flush();\n } catch (ex) {\n const error = convertException(ex);\n console.error({\n flushError: error\n });\n return {\n error\n };\n /**\n * We do not want to throw an error here, because we are in the request end.\n */\n }\n};\n\nconst isOptionsRequest = (request: FastifyRequest): boolean => {\n if (!request?.method) {\n return false;\n }\n return request.method.toUpperCase() === \"OPTIONS\";\n};\n\nexport const createSendDataToEventBridgeOnRequestEnd = (handler: IHandler) => {\n const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {\n if (isOptionsRequest(request)) {\n return payload;\n }\n await execute(handler);\n return payload;\n });\n onRequestResponseSend.name = \"sync.onRequestResponseSend\";\n\n const onRequestTimeout = createOnRequestTimeout(async request => {\n if (isOptionsRequest(request)) {\n return;\n }\n return await execute(handler);\n });\n onRequestTimeout.name = \"sync.onRequestTimeout\";\n\n return [onRequestResponseSend, onRequestTimeout];\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,MAAME,OAAO,GAAG,MAAOC,OAAiB,IAAK;EACzC,IAAI;IACA,OAAO,MAAMA,OAAO,CAACC,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,MAAMC,KAAK,GAAG,IAAAC,2BAAgB,EAACF,EAAE,CAAC;IAClCG,OAAO,CAACF,KAAK,CAAC;MACVG,UAAU,EAAEH;IAChB,CAAC,CAAC;IACF,OAAO;MACHA;IACJ,CAAC;IACD;AACR;AACA;EACI;AACJ,CAAC;AAED,MAAMI,gBAAgB,GAAIC,OAAuB,IAAc;EAC3D,IAAI,CAACA,OAAO,EAAEC,MAAM,EAAE;IAClB,OAAO,KAAK;EAChB;EACA,OAAOD,OAAO,CAACC,MAAM,CAACC,WAAW,CAAC,CAAC,KAAK,SAAS;AACrD,CAAC;AAEM,MAAMC,uCAAuC,GAAIX,OAAiB,IAAK;EAC1E,MAAMY,qBAAqB,GAAG,IAAAC,oCAA2B,EAAC,OAAOL,OAAO,EAAEM,CAAC,EAAEC,OAAO,KAAK;IACrF,IAAIR,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B,OAAOO,OAAO;IAClB;IACA,MAAMhB,OAAO,CAACC,OAAO,CAAC;IACtB,OAAOe,OAAO;EAClB,CAAC,CAAC;EACFH,qBAAqB,CAACI,IAAI,GAAG,4BAA4B;EAEzD,MAAMC,gBAAgB,GAAG,IAAAC,+BAAsB,EAAC,MAAMV,OAAO,IAAI;IAC7D,IAAID,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B;IACJ;IACA,OAAO,MAAMT,OAAO,CAACC,OAAO,CAAC;EACjC,CAAC,CAAC;EACFiB,gBAAgB,CAACD,IAAI,GAAG,uBAAuB;EAE/C,OAAO,CAACJ,qBAAqB,EAAEK,gBAAgB,CAAC;AACpD,CAAC;AAACE,OAAA,CAAAR,uCAAA,GAAAA,uCAAA","ignoreList":[]}
1
+ {"version":3,"file":"sync/createSendDataToEventBridgeOnRequestEnd.js","sources":["../../src/sync/createSendDataToEventBridgeOnRequestEnd.ts"],"sourcesContent":["import type { IHandler } from \"./types.js\";\nimport { createOnRequestResponseSend, createOnRequestTimeout } from \"@webiny/handler\";\nimport type { Request as FastifyRequest } from \"@webiny/handler/types.js\";\nimport { convertException } from \"@webiny/utils/exception.js\";\n\nconst execute = async (handler: IHandler) => {\n try {\n return await handler.flush();\n } catch (ex) {\n const error = convertException(ex);\n console.error({\n flushError: error\n });\n return {\n error\n };\n /**\n * We do not want to throw an error here, because we are in the request end.\n */\n }\n};\n\nconst isOptionsRequest = (request: FastifyRequest): boolean => {\n if (!request?.method) {\n return false;\n }\n return request.method.toUpperCase() === \"OPTIONS\";\n};\n\nexport const createSendDataToEventBridgeOnRequestEnd = (handler: IHandler) => {\n const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {\n if (isOptionsRequest(request)) {\n return payload;\n }\n await execute(handler);\n return payload;\n });\n onRequestResponseSend.name = \"sync.onRequestResponseSend\";\n\n const onRequestTimeout = createOnRequestTimeout(async request => {\n if (isOptionsRequest(request)) {\n return;\n }\n return await execute(handler);\n });\n onRequestTimeout.name = \"sync.onRequestTimeout\";\n\n return [onRequestResponseSend, onRequestTimeout];\n};\n"],"names":["execute","handler","ex","error","convertException","console","isOptionsRequest","request","createSendDataToEventBridgeOnRequestEnd","onRequestResponseSend","createOnRequestResponseSend","_","payload","onRequestTimeout","createOnRequestTimeout"],"mappings":";;AAKA,MAAMA,UAAU,OAAOC;IACnB,IAAI;QACA,OAAO,MAAMA,QAAQ,KAAK;IAC9B,EAAE,OAAOC,IAAI;QACT,MAAMC,QAAQC,iBAAiBF;QAC/BG,QAAQ,KAAK,CAAC;YACV,YAAYF;QAChB;QACA,OAAO;YACHA;QACJ;IAIJ;AACJ;AAEA,MAAMG,mBAAmB,CAACC;IACtB,IAAI,CAACA,SAAS,QACV,OAAO;IAEX,OAAOA,AAAiC,cAAjCA,QAAQ,MAAM,CAAC,WAAW;AACrC;AAEO,MAAMC,0CAA0C,CAACP;IACpD,MAAMQ,wBAAwBC,4BAA4B,OAAOH,SAASI,GAAGC;QACzE,IAAIN,iBAAiBC,UACjB,OAAOK;QAEX,MAAMZ,QAAQC;QACd,OAAOW;IACX;IACAH,sBAAsB,IAAI,GAAG;IAE7B,MAAMI,mBAAmBC,uBAAuB,OAAMP;QAClD,IAAID,iBAAiBC,UACjB;QAEJ,OAAO,MAAMP,QAAQC;IACzB;IACAY,iBAAiB,IAAI,GAAG;IAExB,OAAO;QAACJ;QAAuBI;KAAiB;AACpD"}
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from "@webiny/plugins/types.js";
2
2
  import type { IGetEventBridgeCallable, ISystem } from "./types.js";
3
3
  import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
4
- import type { PossiblyUndefinedProperties } from "@webiny/api/types";
4
+ import type { PossiblyUndefinedProperties } from "@webiny/api/types.js";
5
5
  import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
6
6
  export type IAllowedPlugins = FilterOutRecordPlugin;
7
7
  export interface ICreateSyncSystemParams {