@webiny/api-sync-system 0.0.0-unstable.9bd236cf5e → 0.0.0-unstable.ac6ebf63c6

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 (304) hide show
  1. package/README.md +6 -108
  2. package/constants.js +1 -7
  3. package/constants.js.map +1 -1
  4. package/index.js +3 -38
  5. package/index.js.map +1 -1
  6. package/package.json +20 -23
  7. package/resolver/app/RecordHandler.d.ts +6 -6
  8. package/resolver/app/RecordHandler.js +7 -15
  9. package/resolver/app/RecordHandler.js.map +1 -1
  10. package/resolver/app/RecordsValidation.js +6 -14
  11. package/resolver/app/RecordsValidation.js.map +1 -1
  12. package/resolver/app/ResolverApplication.d.ts +1 -1
  13. package/resolver/app/ResolverApplication.js +10 -18
  14. package/resolver/app/ResolverApplication.js.map +1 -1
  15. package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
  16. package/resolver/app/abstractions/RecordHandler.js +1 -5
  17. package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
  18. package/resolver/app/abstractions/RecordsValidation.js +1 -5
  19. package/resolver/app/abstractions/RecordsValidation.js.map +1 -1
  20. package/resolver/app/abstractions/ResolverApplication.js +1 -5
  21. package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
  22. package/resolver/app/abstractions/ResolverRecord.js +1 -5
  23. package/resolver/app/abstractions/ResolverRecord.js.map +1 -1
  24. package/resolver/app/bundler/BaseBundle.d.ts +6 -6
  25. package/resolver/app/bundler/BaseBundle.js +1 -8
  26. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  27. package/resolver/app/bundler/Bundler.d.ts +1 -1
  28. package/resolver/app/bundler/Bundler.js +2 -10
  29. package/resolver/app/bundler/Bundler.js.map +1 -1
  30. package/resolver/app/bundler/Bundles.d.ts +2 -2
  31. package/resolver/app/bundler/Bundles.js +2 -10
  32. package/resolver/app/bundler/Bundles.js.map +1 -1
  33. package/resolver/app/bundler/CommandBundle.d.ts +1 -1
  34. package/resolver/app/bundler/CommandBundle.js +3 -11
  35. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  36. package/resolver/app/bundler/TableBundle.d.ts +1 -1
  37. package/resolver/app/bundler/TableBundle.js +3 -11
  38. package/resolver/app/bundler/TableBundle.js.map +1 -1
  39. package/resolver/app/bundler/types.d.ts +2 -2
  40. package/resolver/app/bundler/types.js +1 -5
  41. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
  42. package/resolver/app/commandHandler/DeleteCommandHandler.js +1 -8
  43. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  44. package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
  45. package/resolver/app/commandHandler/PutCommandHandler.js +1 -8
  46. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  47. package/resolver/app/commandHandler/delete.d.ts +1 -1
  48. package/resolver/app/commandHandler/delete.js +6 -13
  49. package/resolver/app/commandHandler/delete.js.map +1 -1
  50. package/resolver/app/commandHandler/put.d.ts +1 -1
  51. package/resolver/app/commandHandler/put.js +6 -13
  52. package/resolver/app/commandHandler/put.js.map +1 -1
  53. package/resolver/app/data/SourceDataContainer.d.ts +3 -3
  54. package/resolver/app/data/SourceDataContainer.js +1 -8
  55. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  56. package/resolver/app/data/types.d.ts +2 -2
  57. package/resolver/app/data/types.js +1 -5
  58. package/resolver/app/fetcher/Fetcher.d.ts +3 -3
  59. package/resolver/app/fetcher/Fetcher.js +13 -22
  60. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  61. package/resolver/app/fetcher/types.d.ts +2 -2
  62. package/resolver/app/fetcher/types.js +1 -5
  63. package/resolver/app/ingestor/Ingestor.d.ts +1 -1
  64. package/resolver/app/ingestor/Ingestor.js +2 -10
  65. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  66. package/resolver/app/ingestor/IngestorResult.js +3 -11
  67. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  68. package/resolver/app/ingestor/types.d.ts +2 -2
  69. package/resolver/app/ingestor/types.js +1 -5
  70. package/resolver/app/storer/Storer.d.ts +3 -3
  71. package/resolver/app/storer/Storer.js +12 -20
  72. package/resolver/app/storer/Storer.js.map +1 -1
  73. package/resolver/app/storer/types.d.ts +2 -2
  74. package/resolver/app/storer/types.js +1 -5
  75. package/resolver/app/storer/types.js.map +1 -1
  76. package/resolver/app/transform/TransformHandler.d.ts +4 -4
  77. package/resolver/app/transform/TransformHandler.js +5 -12
  78. package/resolver/app/transform/TransformHandler.js.map +1 -1
  79. package/resolver/app/transform/middleware.d.ts +1 -1
  80. package/resolver/app/transform/middleware.js +1 -7
  81. package/resolver/app/transform/middleware.js.map +1 -1
  82. package/resolver/app/utils/Retry.js +4 -12
  83. package/resolver/app/utils/Retry.js.map +1 -1
  84. package/resolver/app/utils/sleep.js +1 -8
  85. package/resolver/app/utils/sleep.js.map +1 -1
  86. package/resolver/app/validation/body.d.ts +43 -43
  87. package/resolver/app/validation/body.js +22 -30
  88. package/resolver/app/validation/body.js.map +1 -1
  89. package/resolver/app/validation/createJsonTransform.js +6 -14
  90. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  91. package/resolver/app/validation/detail.d.ts +22 -22
  92. package/resolver/app/validation/detail.js +16 -24
  93. package/resolver/app/validation/detail.js.map +1 -1
  94. package/resolver/app/validation/event.d.ts +57 -57
  95. package/resolver/app/validation/event.js +19 -27
  96. package/resolver/app/validation/event.js.map +1 -1
  97. package/resolver/app/validation/numericString.js +5 -13
  98. package/resolver/app/validation/numericString.js.map +1 -1
  99. package/resolver/app/validation/system.d.ts +4 -4
  100. package/resolver/app/validation/system.js +8 -16
  101. package/resolver/app/validation/system.js.map +1 -1
  102. package/resolver/createEventHandlerPlugin.d.ts +2 -1
  103. package/resolver/createEventHandlerPlugin.js +35 -42
  104. package/resolver/createEventHandlerPlugin.js.map +1 -1
  105. package/resolver/createResolverHandler.d.ts +1 -1
  106. package/resolver/createResolverHandler.js +24 -31
  107. package/resolver/createResolverHandler.js.map +1 -1
  108. package/resolver/deployment/Deployment.d.ts +2 -3
  109. package/resolver/deployment/Deployment.js +6 -14
  110. package/resolver/deployment/Deployment.js.map +1 -1
  111. package/resolver/deployment/Deployments.js +2 -10
  112. package/resolver/deployment/Deployments.js.map +1 -1
  113. package/resolver/deployment/DeploymentsFetcher.js +33 -42
  114. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  115. package/resolver/deployment/types.d.ts +4 -4
  116. package/resolver/deployment/types.js +1 -5
  117. package/resolver/deployment/types.js.map +1 -1
  118. package/resolver/lambda/LambdaTrigger.js +5 -12
  119. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  120. package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
  121. package/resolver/plugins/CommandHandlerPlugin.js +3 -11
  122. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  123. package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
  124. package/resolver/plugins/StorerAfterEachPlugin.js +4 -13
  125. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  126. package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
  127. package/resolver/plugins/TransformRecordPlugin.js +3 -11
  128. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  129. package/resolver/recordTypes/fileManager/CopyFile.js +4 -11
  130. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  131. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
  132. package/resolver/recordTypes/fileManager/DeleteFile.js +3 -10
  133. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  134. package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
  135. package/resolver/recordTypes/fileManager/fileManager.js +4 -11
  136. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  137. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
  138. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +7 -14
  139. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  140. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
  141. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +7 -14
  142. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  143. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
  144. package/resolver/recordTypes/fileManager/shouldBeHandled.js +1 -8
  145. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  146. package/resolver/recordTypes/fileManager/types.d.ts +2 -2
  147. package/resolver/recordTypes/fileManager/types.js +1 -5
  148. package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
  149. package/resolver/recordTypes/users/CopyUser.js +3 -10
  150. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  151. package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
  152. package/resolver/recordTypes/users/DeleteUser.js +3 -10
  153. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  154. package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
  155. package/resolver/recordTypes/users/shouldBeHandled.js +1 -8
  156. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  157. package/resolver/recordTypes/users/types.d.ts +1 -1
  158. package/resolver/recordTypes/users/types.js +1 -5
  159. package/resolver/recordTypes/users/types.js.map +1 -1
  160. package/resolver/recordTypes/users/users.js +4 -11
  161. package/resolver/recordTypes/users/users.js.map +1 -1
  162. package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
  163. package/resolver/recordTypes/users/usersOnDelete.js +7 -14
  164. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  165. package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
  166. package/resolver/recordTypes/users/usersOnPut.js +7 -14
  167. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  168. package/sync/FilterOutRecord.d.ts +2 -2
  169. package/sync/FilterOutRecord.js +2 -10
  170. package/sync/FilterOutRecord.js.map +1 -1
  171. package/sync/attachToDynamoDbDocument.d.ts +1 -1
  172. package/sync/attachToDynamoDbDocument.js +9 -17
  173. package/sync/attachToDynamoDbDocument.js.map +1 -1
  174. package/sync/createHandler.js +27 -34
  175. package/sync/createHandler.js.map +1 -1
  176. package/sync/createSendDataToEventBridgeOnRequestEnd.js +6 -13
  177. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
  178. package/sync/createSyncSystem.d.ts +1 -1
  179. package/sync/createSyncSystem.js +6 -13
  180. package/sync/createSyncSystem.js.map +1 -1
  181. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
  182. package/sync/filter/createDefaultFilterOutRecordPlugins.js +9 -19
  183. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  184. package/sync/handler/Handler.d.ts +2 -2
  185. package/sync/handler/Handler.js +9 -17
  186. package/sync/handler/Handler.js.map +1 -1
  187. package/sync/handler/HandlerConverter.js +2 -10
  188. package/sync/handler/HandlerConverter.js.map +1 -1
  189. package/sync/handler/converter/BatchGetCommandConverter.js +6 -14
  190. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  191. package/sync/handler/converter/BatchWriteCommandConverter.js +6 -14
  192. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  193. package/sync/handler/converter/DeleteCommandConverter.js +6 -14
  194. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  195. package/sync/handler/converter/GetCommandConverter.js +6 -14
  196. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  197. package/sync/handler/converter/PutCommandConverter.js +6 -14
  198. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  199. package/sync/handler/converter/QueryCommandConverter.js +6 -14
  200. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  201. package/sync/handler/converter/ScanCommandConverter.js +6 -14
  202. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  203. package/sync/handler/converter/UpdateCommandConverter.js +6 -14
  204. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  205. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
  206. package/sync/handler/converter/commands/BatchWriteCommandValue.js +4 -11
  207. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  208. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
  209. package/sync/handler/converter/commands/DeleteCommandValue.js +3 -10
  210. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  211. package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
  212. package/sync/handler/converter/commands/NullCommandValue.js +1 -8
  213. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  214. package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
  215. package/sync/handler/converter/commands/PutCommandValue.js +3 -10
  216. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  217. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
  218. package/sync/handler/converter/commands/UpdateCommandValue.js +3 -10
  219. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  220. package/sync/handler/types.d.ts +3 -3
  221. package/sync/handler/types.js +1 -5
  222. package/sync/handler/types.js.map +1 -1
  223. package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
  224. package/sync/plugins/FilterOutRecordPlugin.js +3 -11
  225. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  226. package/sync/requestPlugin.d.ts +1 -1
  227. package/sync/requestPlugin.js +19 -20
  228. package/sync/requestPlugin.js.map +1 -1
  229. package/sync/types.js +1 -5
  230. package/sync/utils/getTableType.js +7 -14
  231. package/sync/utils/getTableType.js.map +1 -1
  232. package/sync/utils/manifest.d.ts +1 -1
  233. package/sync/utils/manifest.js +12 -20
  234. package/sync/utils/manifest.js.map +1 -1
  235. package/sync/utils/validateSystemInput.d.ts +1 -1
  236. package/sync/utils/validateSystemInput.js +3 -10
  237. package/sync/utils/validateSystemInput.js.map +1 -1
  238. package/types.d.ts +3 -4
  239. package/types.js +2 -8
  240. package/types.js.map +1 -1
  241. package/utils/createSystemName.js +1 -8
  242. package/utils/createSystemName.js.map +1 -1
  243. package/worker/actions/copyFile/CopyFile.js +13 -21
  244. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  245. package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
  246. package/worker/actions/copyFile/copyFileAction.js +9 -16
  247. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  248. package/worker/actions/copyFile/copyFileSchema.d.ts +2 -2
  249. package/worker/actions/copyFile/copyFileSchema.js +8 -16
  250. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  251. package/worker/actions/copyFile/types.js +1 -5
  252. package/worker/actions/createUser/CreateUser.d.ts +1 -1
  253. package/worker/actions/createUser/CreateUser.js +9 -16
  254. package/worker/actions/createUser/CreateUser.js.map +1 -1
  255. package/worker/actions/createUser/createUserAction.d.ts +2 -2
  256. package/worker/actions/createUser/createUserAction.js +9 -16
  257. package/worker/actions/createUser/createUserAction.js.map +1 -1
  258. package/worker/actions/createUser/createUserSchema.d.ts +2 -2
  259. package/worker/actions/createUser/createUserSchema.js +8 -16
  260. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  261. package/worker/actions/createUser/types.js +1 -5
  262. package/worker/actions/deleteFile/DeleteFile.js +4 -11
  263. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  264. package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
  265. package/worker/actions/deleteFile/deleteFileAction.js +9 -16
  266. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  267. package/worker/actions/deleteFile/deleteFileSchema.d.ts +2 -2
  268. package/worker/actions/deleteFile/deleteFileSchema.js +8 -16
  269. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  270. package/worker/actions/deleteFile/types.js +1 -5
  271. package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
  272. package/worker/actions/deleteUser/DeleteUser.js +7 -14
  273. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  274. package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
  275. package/worker/actions/deleteUser/deleteUserAction.js +9 -16
  276. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  277. package/worker/actions/deleteUser/deleteUserSchema.js +8 -16
  278. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  279. package/worker/actions/deleteUser/types.js +1 -5
  280. package/worker/actions/logValidationError.js +4 -11
  281. package/worker/actions/logValidationError.js.map +1 -1
  282. package/worker/actions/removeCognitoUserAttributes.js +1 -8
  283. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  284. package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
  285. package/worker/actions/updateUser/UpdateUser.js +9 -16
  286. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  287. package/worker/actions/updateUser/types.js +1 -5
  288. package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
  289. package/worker/actions/updateUser/updateUserAction.js +9 -16
  290. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  291. package/worker/actions/updateUser/updateUserSchema.d.ts +2 -2
  292. package/worker/actions/updateUser/updateUserSchema.js +8 -16
  293. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  294. package/worker/createWorkerHandler.js +17 -24
  295. package/worker/createWorkerHandler.js.map +1 -1
  296. package/worker/handler/WorkerActionHandler.d.ts +2 -2
  297. package/worker/handler/WorkerActionHandler.js +3 -10
  298. package/worker/handler/WorkerActionHandler.js.map +1 -1
  299. package/worker/handler/eventHandler.js +9 -16
  300. package/worker/handler/eventHandler.js.map +1 -1
  301. package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
  302. package/worker/plugins/WorkerActionPlugin.js +3 -11
  303. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  304. package/worker/types.js +1 -5
@@ -1 +1 @@
1
- {"version":3,"names":["_clientCognitoIdentityProvider","require","DeleteUser","constructor","params","createCognitoIdentityProviderClient","getLambdaTrigger","handle","username","target","exists","userExists","userPoolId","services","cognitoUserPoolId","region","invocationType","payload","action","provider","input","UserPoolId","Username","cmd","AdminGetUserCommand","result","send","$metadata","httpStatusCode","exports"],"sources":["DeleteUser.ts"],"sourcesContent":["import type {\n ICreateCognitoIdentityProviderClientCb,\n IDeleteUser,\n IDeleteUserHandleParams\n} from \"./types\";\nimport type { LambdaTrigger } from \"~/resolver/lambda/LambdaTrigger.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { AdminGetUserCommandInput } from \"@webiny/aws-sdk/client-cognito-identity-provider\";\nimport { AdminGetUserCommand } from \"@webiny/aws-sdk/client-cognito-identity-provider\";\nimport type { IDeleteUserLambdaPayload } from \"~/types.js\";\n\ninterface IGetUserParams {\n username: string;\n userPoolId: string;\n region: string;\n}\n\nexport interface IGetLambdaTriggerCb {\n (): LambdaTrigger<IDeleteUserLambdaPayload>;\n}\n\nexport interface IDeleteUserParams {\n createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb;\n}\n\nexport class DeleteUser implements IDeleteUser {\n private readonly createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb;\n\n public constructor(params: IDeleteUserParams) {\n this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: IDeleteUserHandleParams): Promise<InvokeCommandOutput | null> {\n const { username, target } = params;\n\n const exists = await this.userExists({\n username,\n userPoolId: target.services.cognitoUserPoolId,\n region: target.region\n });\n if (!exists) {\n return null;\n }\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n /**\n * We need to be able to create or update a user, depending on whether it already exists in the target user pool.\n */\n action: \"deleteUser\",\n username,\n target: {\n region: target.region,\n userPoolId: target.services.cognitoUserPoolId\n }\n }\n });\n }\n\n private async userExists(params: IGetUserParams): Promise<boolean> {\n const { userPoolId, username, region } = params;\n\n const provider = this.createCognitoIdentityProviderClient({\n region\n });\n\n const input: AdminGetUserCommandInput = {\n UserPoolId: userPoolId,\n Username: username\n };\n const cmd = new AdminGetUserCommand(input);\n try {\n const result = await provider.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,8BAAA,GAAAC,OAAA;AAkBO,MAAMC,UAAU,CAAwB;EAIpCC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACC,mCAAmC,GAAGD,MAAM,CAACC,mCAAmC;IACrF,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA+B,EAAuC;IACtF,MAAM;MAAEI,QAAQ;MAAEC;IAAO,CAAC,GAAGL,MAAM;IAEnC,MAAMM,MAAM,GAAG,MAAM,IAAI,CAACC,UAAU,CAAC;MACjCH,QAAQ;MACRI,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC,iBAAiB;MAC7CC,MAAM,EAAEN,MAAM,CAACM;IACnB,CAAC,CAAC;IACF,IAAI,CAACL,MAAM,EAAE;MACT,OAAO,IAAI;IACf;IAEA,OAAO,MAAM,IAAI,CAACJ,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCS,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACL;AAChB;AACA;QACgBC,MAAM,EAAE,YAAY;QACpBV,QAAQ;QACRC,MAAM,EAAE;UACJM,MAAM,EAAEN,MAAM,CAACM,MAAM;UACrBH,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC;QAChC;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcH,UAAUA,CAACP,MAAsB,EAAoB;IAC/D,MAAM;MAAEQ,UAAU;MAAEJ,QAAQ;MAAEO;IAAO,CAAC,GAAGX,MAAM;IAE/C,MAAMe,QAAQ,GAAG,IAAI,CAACd,mCAAmC,CAAC;MACtDU;IACJ,CAAC,CAAC;IAEF,MAAMK,KAA+B,GAAG;MACpCC,UAAU,EAAET,UAAU;MACtBU,QAAQ,EAAEd;IACd,CAAC;IACD,MAAMe,GAAG,GAAG,IAAIC,kDAAmB,CAACJ,KAAK,CAAC;IAC1C,IAAI;MACA,MAAMK,MAAM,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAACH,GAAG,CAAC;MACvC,OAAOE,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ;AAACC,OAAA,CAAA3B,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["AdminGetUserCommand","DeleteUser","constructor","params","createCognitoIdentityProviderClient","getLambdaTrigger","handle","username","target","exists","userExists","userPoolId","services","cognitoUserPoolId","region","invocationType","payload","action","provider","input","UserPoolId","Username","cmd","result","send","$metadata","httpStatusCode"],"sources":["DeleteUser.ts"],"sourcesContent":["import type {\n ICreateCognitoIdentityProviderClientCb,\n IDeleteUser,\n IDeleteUserHandleParams\n} from \"./types.js\";\nimport type { LambdaTrigger } from \"~/resolver/lambda/LambdaTrigger.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { AdminGetUserCommandInput } from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport { AdminGetUserCommand } from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport type { IDeleteUserLambdaPayload } from \"~/types.js\";\n\ninterface IGetUserParams {\n username: string;\n userPoolId: string;\n region: string;\n}\n\nexport interface IGetLambdaTriggerCb {\n (): LambdaTrigger<IDeleteUserLambdaPayload>;\n}\n\nexport interface IDeleteUserParams {\n createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb;\n}\n\nexport class DeleteUser implements IDeleteUser {\n private readonly createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb;\n\n public constructor(params: IDeleteUserParams) {\n this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: IDeleteUserHandleParams): Promise<InvokeCommandOutput | null> {\n const { username, target } = params;\n\n const exists = await this.userExists({\n username,\n userPoolId: target.services.cognitoUserPoolId,\n region: target.region\n });\n if (!exists) {\n return null;\n }\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n /**\n * We need to be able to create or update a user, depending on whether it already exists in the target user pool.\n */\n action: \"deleteUser\",\n username,\n target: {\n region: target.region,\n userPoolId: target.services.cognitoUserPoolId\n }\n }\n });\n }\n\n private async userExists(params: IGetUserParams): Promise<boolean> {\n const { userPoolId, username, region } = params;\n\n const provider = this.createCognitoIdentityProviderClient({\n region\n });\n\n const input: AdminGetUserCommandInput = {\n UserPoolId: userPoolId,\n Username: username\n };\n const cmd = new AdminGetUserCommand(input);\n try {\n const result = await provider.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"AAQA,SAASA,mBAAmB,QAAQ,2DAA2D;AAkB/F,OAAO,MAAMC,UAAU,CAAwB;EAIpCC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACC,mCAAmC,GAAGD,MAAM,CAACC,mCAAmC;IACrF,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA+B,EAAuC;IACtF,MAAM;MAAEI,QAAQ;MAAEC;IAAO,CAAC,GAAGL,MAAM;IAEnC,MAAMM,MAAM,GAAG,MAAM,IAAI,CAACC,UAAU,CAAC;MACjCH,QAAQ;MACRI,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC,iBAAiB;MAC7CC,MAAM,EAAEN,MAAM,CAACM;IACnB,CAAC,CAAC;IACF,IAAI,CAACL,MAAM,EAAE;MACT,OAAO,IAAI;IACf;IAEA,OAAO,MAAM,IAAI,CAACJ,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCS,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACL;AAChB;AACA;QACgBC,MAAM,EAAE,YAAY;QACpBV,QAAQ;QACRC,MAAM,EAAE;UACJM,MAAM,EAAEN,MAAM,CAACM,MAAM;UACrBH,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC;QAChC;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcH,UAAUA,CAACP,MAAsB,EAAoB;IAC/D,MAAM;MAAEQ,UAAU;MAAEJ,QAAQ;MAAEO;IAAO,CAAC,GAAGX,MAAM;IAE/C,MAAMe,QAAQ,GAAG,IAAI,CAACd,mCAAmC,CAAC;MACtDU;IACJ,CAAC,CAAC;IAEF,MAAMK,KAA+B,GAAG;MACpCC,UAAU,EAAET,UAAU;MACtBU,QAAQ,EAAEd;IACd,CAAC;IACD,MAAMe,GAAG,GAAG,IAAItB,mBAAmB,CAACmB,KAAK,CAAC;IAC1C,IAAI;MACA,MAAMI,MAAM,GAAG,MAAML,QAAQ,CAACM,IAAI,CAACF,GAAG,CAAC;MACvC,OAAOC,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import type { IStorerAfterEachPluginCanHandleParams } from "../../plugins/StorerAfterEachPlugin.js";
1
+ import type { IStorerAfterEachPluginCanHandleParams } from "../../../resolver/plugins/StorerAfterEachPlugin.js";
2
2
  export declare const shouldBeHandled: (params: IStorerAfterEachPluginCanHandleParams) => boolean;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldBeHandled = void 0;
7
- const shouldBeHandled = params => {
1
+ export const shouldBeHandled = params => {
8
2
  const {
9
3
  item,
10
4
  table,
@@ -31,6 +25,5 @@ const shouldBeHandled = params => {
31
25
  }
32
26
  return true;
33
27
  };
34
- exports.shouldBeHandled = shouldBeHandled;
35
28
 
36
29
  //# sourceMappingURL=shouldBeHandled.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["shouldBeHandled","params","item","table","source","target","type","PK","includes","SK","TYPE","services","cognitoUserPoolId","data","email","exports"],"sources":["shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table, source, target } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.PK.includes(\"#ADMIN_USER#\") === false) {\n return false;\n } else if (item.SK !== \"A\") {\n return false;\n } else if (item.TYPE !== \"adminUsers.user\") {\n return false;\n } else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) {\n return false;\n }\n /**\n * TODO verify that email is always present in Cognito users.\n */\n // @ts-expect-error\n else if (!item.data?.email) {\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,eAAe,GAAIC,MAA6C,IAAc;EACvF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGJ,MAAM;EAC9C,IAAIE,KAAK,CAACG,IAAI,KAAK,SAAS,EAAE;IAC1B,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIJ,IAAI,CAACK,EAAE,CAACC,QAAQ,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;IACnD,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIN,IAAI,CAACO,EAAE,KAAK,GAAG,EAAE;IACxB,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIP,IAAI,CAACQ,IAAI,KAAK,iBAAiB,EAAE;IACxC,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACN,MAAM,CAACO,QAAQ,CAACC,iBAAiB,IAAI,CAACP,MAAM,CAACM,QAAQ,CAACC,iBAAiB,EAAE;IACjF,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAI,CAACV,IAAI,CAACW,IAAI,EAAEC,KAAK,EAAE;IACxB,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAACC,OAAA,CAAAf,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["shouldBeHandled","params","item","table","source","target","type","PK","includes","SK","TYPE","services","cognitoUserPoolId","data","email"],"sources":["shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table, source, target } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.PK.includes(\"#ADMIN_USER#\") === false) {\n return false;\n } else if (item.SK !== \"A\") {\n return false;\n } else if (item.TYPE !== \"adminUsers.user\") {\n return false;\n } else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) {\n return false;\n }\n /**\n * TODO verify that email is always present in Cognito users.\n */\n // @ts-expect-error\n else if (!item.data?.email) {\n return false;\n }\n return true;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAe,GAAIC,MAA6C,IAAc;EACvF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGJ,MAAM;EAC9C,IAAIE,KAAK,CAACG,IAAI,KAAK,SAAS,EAAE;IAC1B,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIJ,IAAI,CAACK,EAAE,CAACC,QAAQ,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE;IACnD,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIN,IAAI,CAACO,EAAE,KAAK,GAAG,EAAE;IACxB,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIP,IAAI,CAACQ,IAAI,KAAK,iBAAiB,EAAE;IACxC,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACN,MAAM,CAACO,QAAQ,CAACC,iBAAiB,IAAI,CAACP,MAAM,CAACM,QAAQ,CAACC,iBAAiB,EAAE;IACjF,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAI,CAACV,IAAI,CAACW,IAAI,EAAEC,KAAK,EAAE;IACxB,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { IDeployment } from "../../deployment/types";
1
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
2
2
  import type { CognitoIdentityProviderClient, CognitoIdentityProviderClientConfig } from "@webiny/aws-sdk/client-cognito-identity-provider/index.js";
3
3
  import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
4
4
  export interface IUserDeploymentServices {
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IDeployment } from \"~/resolver/deployment/types\";\nimport type {\n CognitoIdentityProviderClient,\n CognitoIdentityProviderClientConfig\n} from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\n\nexport interface IUserDeploymentServices {\n cognitoUserPoolId: string;\n}\n\nexport interface ICopyUserHandleParams {\n username: string;\n source: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n target: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n}\n\nexport interface ICopyUser {\n handle(params: ICopyUserHandleParams): Promise<InvokeCommandOutput | null>;\n}\n\nexport interface IDeleteUserHandleParams {\n username: string;\n target: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n}\n\nexport interface IDeleteUser {\n handle(params: IDeleteUserHandleParams): Promise<InvokeCommandOutput | null>;\n}\n\nexport interface ICreateCognitoIdentityProviderClientCb {\n (config: Partial<CognitoIdentityProviderClientConfig>): Pick<\n CognitoIdentityProviderClient,\n \"send\"\n >;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type {\n CognitoIdentityProviderClient,\n CognitoIdentityProviderClientConfig\n} from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\n\nexport interface IUserDeploymentServices {\n cognitoUserPoolId: string;\n}\n\nexport interface ICopyUserHandleParams {\n username: string;\n source: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n target: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n}\n\nexport interface ICopyUser {\n handle(params: ICopyUserHandleParams): Promise<InvokeCommandOutput | null>;\n}\n\nexport interface IDeleteUserHandleParams {\n username: string;\n target: Pick<IDeployment<IUserDeploymentServices>, \"region\" | \"services\">;\n}\n\nexport interface IDeleteUser {\n handle(params: IDeleteUserHandleParams): Promise<InvokeCommandOutput | null>;\n}\n\nexport interface ICreateCognitoIdentityProviderClientCb {\n (\n config: Partial<CognitoIdentityProviderClientConfig>\n ): Pick<CognitoIdentityProviderClient, \"send\">;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,14 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createUsersPlugins = void 0;
7
- var _usersOnPut = require("./usersOnPut.js");
8
- var _usersOnDelete = require("./usersOnDelete.js");
9
- const createUsersPlugins = params => {
10
- return [(0, _usersOnPut.createUserOnPutPlugin)(params), (0, _usersOnDelete.createUserOnDeletePlugin)(params)];
1
+ import { createUserOnPutPlugin } from "./usersOnPut.js";
2
+ import { createUserOnDeletePlugin } from "./usersOnDelete.js";
3
+ export const createUsersPlugins = params => {
4
+ return [createUserOnPutPlugin(params), createUserOnDeletePlugin(params)];
11
5
  };
12
- exports.createUsersPlugins = createUsersPlugins;
13
6
 
14
7
  //# sourceMappingURL=users.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_usersOnPut","require","_usersOnDelete","createUsersPlugins","params","createUserOnPutPlugin","createUserOnDeletePlugin","exports"],"sources":["users.ts"],"sourcesContent":["import { createUserOnPutPlugin } from \"./usersOnPut.js\";\nimport { createUserOnDeletePlugin } from \"./usersOnDelete.js\";\nimport type { ICopyUser, IDeleteUser } from \"./types.js\";\n\nexport interface ICreateUsersPluginsParams {\n copyUser: ICopyUser;\n deleteUser: IDeleteUser;\n}\n\nexport const createUsersPlugins = (params: ICreateUsersPluginsParams) => {\n return [createUserOnPutPlugin(params), createUserOnDeletePlugin(params)];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAQO,MAAME,kBAAkB,GAAIC,MAAiC,IAAK;EACrE,OAAO,CAAC,IAAAC,iCAAqB,EAACD,MAAM,CAAC,EAAE,IAAAE,uCAAwB,EAACF,MAAM,CAAC,CAAC;AAC5E,CAAC;AAACG,OAAA,CAAAJ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createUserOnPutPlugin","createUserOnDeletePlugin","createUsersPlugins","params"],"sources":["users.ts"],"sourcesContent":["import { createUserOnPutPlugin } from \"./usersOnPut.js\";\nimport { createUserOnDeletePlugin } from \"./usersOnDelete.js\";\nimport type { ICopyUser, IDeleteUser } from \"./types.js\";\n\nexport interface ICreateUsersPluginsParams {\n copyUser: ICopyUser;\n deleteUser: IDeleteUser;\n}\n\nexport const createUsersPlugins = (params: ICreateUsersPluginsParams) => {\n return [createUserOnPutPlugin(params), createUserOnDeletePlugin(params)];\n};\n"],"mappings":"AAAA,SAASA,qBAAqB;AAC9B,SAASC,wBAAwB;AAQjC,OAAO,MAAMC,kBAAkB,GAAIC,MAAiC,IAAK;EACrE,OAAO,CAACH,qBAAqB,CAACG,MAAM,CAAC,EAAEF,wBAAwB,CAACE,MAAM,CAAC,CAAC;AAC5E,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { IDeleteUser } from "./types.js";
1
+ import type { IDeleteUser } from "../../../resolver/recordTypes/users/types.js";
2
2
  export interface IDeleteUserOnDeletePluginParams {
3
3
  deleteUser: IDeleteUser;
4
4
  }
5
- export declare const createUserOnDeletePlugin: (params: IDeleteUserOnDeletePluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
5
+ export declare const createUserOnDeletePlugin: (params: IDeleteUserOnDeletePluginParams) => import("~/resolver/plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -1,17 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createUserOnDeletePlugin = void 0;
7
- var _StorerAfterEachPlugin = require("../../plugins/StorerAfterEachPlugin.js");
8
- var _shouldBeHandled = require("./shouldBeHandled.js");
9
- var _utils = require("@webiny/utils");
10
- const createUserOnDeletePlugin = params => {
1
+ import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
2
+ import { shouldBeHandled } from "./shouldBeHandled.js";
3
+ import { convertException } from "@webiny/utils";
4
+ export const createUserOnDeletePlugin = params => {
11
5
  const {
12
6
  deleteUser
13
7
  } = params;
14
- return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("users.onDelete", {
8
+ return createStorerAfterEachPluginWithName("users.onDelete", {
15
9
  canHandle: params => {
16
10
  const {
17
11
  command
@@ -19,7 +13,7 @@ const createUserOnDeletePlugin = params => {
19
13
  if (command !== "delete") {
20
14
  return false;
21
15
  }
22
- return (0, _shouldBeHandled.shouldBeHandled)(params);
16
+ return shouldBeHandled(params);
23
17
  },
24
18
  handle: async params => {
25
19
  const {
@@ -37,11 +31,10 @@ const createUserOnDeletePlugin = params => {
37
31
  });
38
32
  } catch (ex) {
39
33
  console.error("Error while handling users onDelete plugin.");
40
- console.log((0, _utils.convertException)(ex));
34
+ console.log(convertException(ex));
41
35
  }
42
36
  }
43
37
  });
44
38
  };
45
- exports.createUserOnDeletePlugin = createUserOnDeletePlugin;
46
39
 
47
40
  //# sourceMappingURL=usersOnDelete.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_StorerAfterEachPlugin","require","_shouldBeHandled","_utils","createUserOnDeletePlugin","params","deleteUser","createStorerAfterEachPluginWithName","canHandle","command","shouldBeHandled","handle","item","username","data","email","target","ex","console","error","log","convertException","exports"],"sources":["usersOnDelete.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IDeleteUser } from \"~/resolver/recordTypes/users/types.js\";\n\nexport interface IDeleteUserOnDeletePluginParams {\n deleteUser: IDeleteUser;\n}\n\nexport const createUserOnDeletePlugin = (params: IDeleteUserOnDeletePluginParams) => {\n const { deleteUser } = params;\n\n return createStorerAfterEachPluginWithName(\"users.onDelete\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"delete\") {\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 deleteUser.handle({\n target: params.target,\n username\n });\n } catch (ex) {\n console.error(\"Error while handling users onDelete 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,wBAAwB,GAAIC,MAAuC,IAAK;EACjF,MAAM;IAAEC;EAAW,CAAC,GAAGD,MAAM;EAE7B,OAAO,IAAAE,0DAAmC,EAAC,gBAAgB,EAAE;IACzDC,SAAS,EAAEH,MAAM,IAAI;MACjB,MAAM;QAAEI;MAAQ,CAAC,GAAGJ,MAAM;MAC1B,IAAII,OAAO,KAAK,QAAQ,EAAE;QACtB,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,UAAU,CAACK,MAAM,CAAC;UACpBK,MAAM,EAAEX,MAAM,CAACW,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,6CAA6C,CAAC;QAC5DD,OAAO,CAACE,GAAG,CAAC,IAAAC,uBAAgB,EAACJ,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAlB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createStorerAfterEachPluginWithName","shouldBeHandled","convertException","createUserOnDeletePlugin","params","deleteUser","canHandle","command","handle","item","username","data","email","target","ex","console","error","log"],"sources":["usersOnDelete.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IDeleteUser } from \"~/resolver/recordTypes/users/types.js\";\n\nexport interface IDeleteUserOnDeletePluginParams {\n deleteUser: IDeleteUser;\n}\n\nexport const createUserOnDeletePlugin = (params: IDeleteUserOnDeletePluginParams) => {\n const { deleteUser } = params;\n\n return createStorerAfterEachPluginWithName(\"users.onDelete\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"delete\") {\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 deleteUser.handle({\n target: params.target,\n username\n });\n } catch (ex) {\n console.error(\"Error while handling users onDelete plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":"AAAA,SAASA,mCAAmC;AAC5C,SAASC,eAAe;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAOhD,OAAO,MAAMC,wBAAwB,GAAIC,MAAuC,IAAK;EACjF,MAAM;IAAEC;EAAW,CAAC,GAAGD,MAAM;EAE7B,OAAOJ,mCAAmC,CAAC,gBAAgB,EAAE;IACzDM,SAAS,EAAEF,MAAM,IAAI;MACjB,MAAM;QAAEG;MAAQ,CAAC,GAAGH,MAAM;MAC1B,IAAIG,OAAO,KAAK,QAAQ,EAAE;QACtB,OAAO,KAAK;MAChB;MACA,OAAON,eAAe,CAACG,MAAM,CAAC;IAClC,CAAC;IACDI,MAAM,EAAE,MAAMJ,MAAM,IAAI;MACpB,MAAM;QAAEK;MAAK,CAAC,GAAGL,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMM,QAAQ,GAAGD,IAAI,CAACE,IAAI,CAACC,KAAe;MAC1C,IAAI;QACA,MAAMP,UAAU,CAACG,MAAM,CAAC;UACpBK,MAAM,EAAET,MAAM,CAACS,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,6CAA6C,CAAC;QAC5DD,OAAO,CAACE,GAAG,CAACf,gBAAgB,CAACY,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { ICopyUser } from "./types.js";
1
+ import type { ICopyUser } from "../../../resolver/recordTypes/users/types.js";
2
2
  export interface ICreateUserOnPutPluginParams {
3
3
  copyUser: ICopyUser;
4
4
  }
5
- export declare const createUserOnPutPlugin: (params: ICreateUserOnPutPluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
5
+ export declare const createUserOnPutPlugin: (params: ICreateUserOnPutPluginParams) => import("~/resolver/plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -1,17 +1,11 @@
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 => {
1
+ import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
2
+ import { shouldBeHandled } from "./shouldBeHandled.js";
3
+ import { convertException } from "@webiny/utils";
4
+ export const createUserOnPutPlugin = params => {
11
5
  const {
12
6
  copyUser
13
7
  } = params;
14
- return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("users.onPut", {
8
+ return createStorerAfterEachPluginWithName("users.onPut", {
15
9
  canHandle: params => {
16
10
  const {
17
11
  command
@@ -19,7 +13,7 @@ const createUserOnPutPlugin = params => {
19
13
  if (command !== "put") {
20
14
  return false;
21
15
  }
22
- return (0, _shouldBeHandled.shouldBeHandled)(params);
16
+ return shouldBeHandled(params);
23
17
  },
24
18
  handle: async params => {
25
19
  const {
@@ -38,11 +32,10 @@ const createUserOnPutPlugin = params => {
38
32
  });
39
33
  } catch (ex) {
40
34
  console.error("Error while handling users onPut plugin.");
41
- console.log((0, _utils.convertException)(ex));
35
+ console.log(convertException(ex));
42
36
  }
43
37
  }
44
38
  });
45
39
  };
46
- exports.createUserOnPutPlugin = createUserOnPutPlugin;
47
40
 
48
41
  //# 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,"names":["createStorerAfterEachPluginWithName","shouldBeHandled","convertException","createUserOnPutPlugin","params","copyUser","canHandle","command","handle","item","username","data","email","target","source","ex","console","error","log"],"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,SAASA,mCAAmC;AAC5C,SAASC,eAAe;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAOhD,OAAO,MAAMC,qBAAqB,GAAIC,MAAoC,IAAK;EAC3E,MAAM;IAAEC;EAAS,CAAC,GAAGD,MAAM;EAE3B,OAAOJ,mCAAmC,CAAC,aAAa,EAAE;IACtDM,SAAS,EAAEF,MAAM,IAAI;MACjB,MAAM;QAAEG;MAAQ,CAAC,GAAGH,MAAM;MAC1B,IAAIG,OAAO,KAAK,KAAK,EAAE;QACnB,OAAO,KAAK;MAChB;MACA,OAAON,eAAe,CAACG,MAAM,CAAC;IAClC,CAAC;IACDI,MAAM,EAAE,MAAMJ,MAAM,IAAI;MACpB,MAAM;QAAEK;MAAK,CAAC,GAAGL,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMM,QAAQ,GAAGD,IAAI,CAACE,IAAI,CAACC,KAAe;MAC1C,IAAI;QACA,MAAMP,QAAQ,CAACG,MAAM,CAAC;UAClBK,MAAM,EAAET,MAAM,CAACS,MAAM;UACrBC,MAAM,EAAEV,MAAM,CAACU,MAAM;UACrBJ;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOK,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,0CAA0C,CAAC;QACzDD,OAAO,CAACE,GAAG,CAAChB,gBAAgB,CAACa,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -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,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFilterOutRecord = exports.FilterOutRecord = void 0;
7
- class FilterOutRecord {
1
+ export class FilterOutRecord {
8
2
  constructor(plugins) {
9
3
  this.plugins = plugins;
10
4
  }
@@ -20,10 +14,8 @@ class FilterOutRecord {
20
14
  return false;
21
15
  }
22
16
  }
23
- exports.FilterOutRecord = FilterOutRecord;
24
- const createFilterOutRecord = plugins => {
17
+ export const createFilterOutRecord = plugins => {
25
18
  return new FilterOutRecord(plugins);
26
19
  };
27
- exports.createFilterOutRecord = createFilterOutRecord;
28
20
 
29
21
  //# 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,"names":["FilterOutRecord","constructor","plugins","filterOut","item","plugin","execute","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":"AAGA,OAAO,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;AAEA,OAAO,MAAMG,qBAAqB,GAAIL,OAAgC,IAAsB;EACxF,OAAO,IAAIF,eAAe,CAACE,OAAO,CAAC;AACvC,CAAC","ignoreList":[]}
@@ -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,12 +1,6 @@
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 => {
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
+ export const decorateClientWithHandler = params => {
10
4
  const {
11
5
  handler,
12
6
  client
@@ -35,7 +29,7 @@ const decorateClientWithHandler = params => {
35
29
  };
36
30
  // @ts-expect-error
37
31
  client.put = async params => {
38
- const cmd = new _index.PutCommand(params);
32
+ const cmd = new PutCommand(params);
39
33
  handler.add(cmd);
40
34
  // @ts-expect-error
41
35
  return originalPut.apply(client, [params]);
@@ -43,7 +37,7 @@ const decorateClientWithHandler = params => {
43
37
 
44
38
  // @ts-expect-error
45
39
  client.delete = async params => {
46
- const cmd = new _index.DeleteCommand(params);
40
+ const cmd = new DeleteCommand(params);
47
41
  handler.add(cmd);
48
42
  // @ts-expect-error
49
43
  return originalDelete.apply(client, [params]);
@@ -51,29 +45,27 @@ const decorateClientWithHandler = params => {
51
45
 
52
46
  // @ts-expect-error
53
47
  client.batchWrite = async params => {
54
- const cmd = new _index.BatchWriteCommand(params);
48
+ const cmd = new BatchWriteCommand(params);
55
49
  handler.add(cmd);
56
50
  // @ts-expect-error
57
51
  return originalBatchWrite.apply(client, [params]);
58
52
  };
59
53
  client.update = async params => {
60
- const cmd = new _index.UpdateCommand(params);
54
+ const cmd = new UpdateCommand(params);
61
55
  handler.add(cmd);
62
56
  return originalUpdate(params);
63
57
  };
64
58
  return client;
65
59
  };
66
- exports.decorateClientWithHandler = decorateClientWithHandler;
67
- const attachToDynamoDbDocument = ({
60
+ export const attachToDynamoDbDocument = ({
68
61
  handler
69
62
  }) => {
70
- return (0, _getDocumentClient.decorateDocumentClient)(client => {
63
+ return decorateDocumentClient(client => {
71
64
  return decorateClientWithHandler({
72
65
  handler,
73
66
  client
74
67
  });
75
68
  });
76
69
  };
77
- exports.attachToDynamoDbDocument = attachToDynamoDbDocument;
78
70
 
79
71
  //# 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,"names":["decorateDocumentClient","BatchWriteCommand","DeleteCommand","PutCommand","UpdateCommand","decorateClientWithHandler","params","handler","client","__webinyHandler","id","originalSend","send","originalPut","put","originalDelete","delete","originalUpdate","update","originalBatchWrite","batchWrite","add","apply","cmd","attachToDynamoDbDocument"],"sources":["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"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,sDAAsD;AAG7F,SACIC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,aAAa,QACV,0CAA0C;AAWjD,OAAO,MAAMC,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,IAAIpB,UAAU,CAACG,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,IAAIrB,aAAa,CAACI,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,IAAItB,iBAAiB,CAACK,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,IAAInB,aAAa,CAACE,MAAM,CAAC;IACrCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB,OAAON,cAAc,CAACX,MAAM,CAAC;EACjC,CAAC;EAED,OAAOE,MAAM;AACjB,CAAC;AAED,OAAO,MAAMgB,wBAAwB,GAAGA,CAAC;EAAEjB;AAAyC,CAAC,KAAW;EAC5F,OAAOP,sBAAsB,CAACQ,MAAM,IAAI;IACpC,OAAOH,yBAAyB,CAAC;MAC7BE,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,23 +1,17 @@
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 => {
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
+ export const createHandler = params => {
21
15
  const {
22
16
  manifest,
23
17
  commandConverters,
@@ -25,25 +19,25 @@ const createHandler = params => {
25
19
  getEventBridgeClient,
26
20
  getPlugins
27
21
  } = 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()
22
+ const filterOutRecordPlugins = getPlugins().byType(FilterOutRecordPlugin.type);
23
+ const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);
24
+ const converter = createHandlerConverter({
25
+ defaultValue: new NullCommandValue()
32
26
  });
33
27
  /**
34
28
  * We register users command converters because those are tested out first.
35
29
  * Our converters are in some order I got from my head - the most used commands are first.
36
30
  */
37
31
  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)({
32
+ converter.register(createBatchGetCommandConverter());
33
+ converter.register(createGetCommandConverter());
34
+ converter.register(createQueryCommandConverter());
35
+ converter.register(createScanCommandConverter());
36
+ converter.register(createBatchWriteCommandConverter());
37
+ converter.register(createPutCommandConverter());
38
+ converter.register(createDeleteCommandConverter());
39
+ converter.register(createUpdateCommandConverter());
40
+ const handler = createSyncHandler({
47
41
  system,
48
42
  getEventBridgeClient,
49
43
  eventBus: {
@@ -58,6 +52,5 @@ const createHandler = params => {
58
52
  converter
59
53
  };
60
54
  };
61
- exports.createHandler = createHandler;
62
55
 
63
56
  //# 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,"names":["createHandlerConverter","NullCommandValue","createBatchWriteCommandConverter","createPutCommandConverter","createDeleteCommandConverter","createUpdateCommandConverter","createSyncHandler","createBatchGetCommandConverter","createQueryCommandConverter","createScanCommandConverter","createGetCommandConverter","FilterOutRecordPlugin","createFilterOutRecord","createHandler","params","manifest","commandConverters","system","getEventBridgeClient","getPlugins","filterOutRecordPlugins","byType","type","filterOutRecord","converter","defaultValue","register","handler","eventBus","arn","sync","eventBusArn","name","eventBusName"],"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,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,gCAAgC;AACzC,SAASC,yBAAyB;AAClC,SAASC,4BAA4B;AACrC,SAASC,4BAA4B;AACrC,SAASC,iBAAiB;AAG1B,SAASC,8BAA8B;AACvC,SAASC,2BAA2B;AACpC,SAASC,0BAA0B;AACnC,SAASC,yBAAyB;AAElC,SAASC,qBAAqB;AAC9B,SAASC,qBAAqB;AAU9B,OAAO,MAAMC,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,CAC9CV,qBAAqB,CAACW,IAC1B,CAAC;EAED,MAAMC,eAAe,GAAGX,qBAAqB,CAACQ,sBAAsB,CAAC;EAErE,MAAMI,SAAS,GAAGxB,sBAAsB,CAAC;IACrCyB,YAAY,EAAE,IAAIxB,gBAAgB,CAAC;EACvC,CAAC,CAAC;EACF;AACJ;AACA;AACA;EACIuB,SAAS,CAACE,QAAQ,CAACV,iBAAiB,IAAI,EAAE,CAAC;EAC3CQ,SAAS,CAACE,QAAQ,CAACnB,8BAA8B,CAAC,CAAC,CAAC;EACpDiB,SAAS,CAACE,QAAQ,CAAChB,yBAAyB,CAAC,CAAC,CAAC;EAC/Cc,SAAS,CAACE,QAAQ,CAAClB,2BAA2B,CAAC,CAAC,CAAC;EACjDgB,SAAS,CAACE,QAAQ,CAACjB,0BAA0B,CAAC,CAAC,CAAC;EAChDe,SAAS,CAACE,QAAQ,CAACxB,gCAAgC,CAAC,CAAC,CAAC;EACtDsB,SAAS,CAACE,QAAQ,CAACvB,yBAAyB,CAAC,CAAC,CAAC;EAC/CqB,SAAS,CAACE,QAAQ,CAACtB,4BAA4B,CAAC,CAAC,CAAC;EAClDoB,SAAS,CAACE,QAAQ,CAACrB,4BAA4B,CAAC,CAAC,CAAC;EAElD,MAAMsB,OAAO,GAAGrB,iBAAiB,CAAC;IAC9BW,MAAM;IACNC,oBAAoB;IACpBU,QAAQ,EAAE;MACNC,GAAG,EAAEd,QAAQ,CAACe,IAAI,CAACC,WAAW;MAC9BC,IAAI,EAAEjB,QAAQ,CAACe,IAAI,CAACG;IACxB,CAAC;IACDT,SAAS;IACTD;EACJ,CAAC,CAAC;EACF,OAAO;IACHI,OAAO;IACPH;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,16 +1,10 @@
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");
1
+ import { createOnRequestResponseSend, createOnRequestTimeout } from "@webiny/handler";
2
+ import { convertException } from "@webiny/utils/exception.js";
9
3
  const execute = async handler => {
10
4
  try {
11
5
  return await handler.flush();
12
6
  } catch (ex) {
13
- const error = (0, _exception.convertException)(ex);
7
+ const error = convertException(ex);
14
8
  console.error({
15
9
  flushError: error
16
10
  });
@@ -28,8 +22,8 @@ const isOptionsRequest = request => {
28
22
  }
29
23
  return request.method.toUpperCase() === "OPTIONS";
30
24
  };
31
- const createSendDataToEventBridgeOnRequestEnd = handler => {
32
- const onRequestResponseSend = (0, _handler.createOnRequestResponseSend)(async (request, _, payload) => {
25
+ export const createSendDataToEventBridgeOnRequestEnd = handler => {
26
+ const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {
33
27
  if (isOptionsRequest(request)) {
34
28
  return payload;
35
29
  }
@@ -37,7 +31,7 @@ const createSendDataToEventBridgeOnRequestEnd = handler => {
37
31
  return payload;
38
32
  });
39
33
  onRequestResponseSend.name = "sync.onRequestResponseSend";
40
- const onRequestTimeout = (0, _handler.createOnRequestTimeout)(async request => {
34
+ const onRequestTimeout = createOnRequestTimeout(async request => {
41
35
  if (isOptionsRequest(request)) {
42
36
  return;
43
37
  }
@@ -46,6 +40,5 @@ const createSendDataToEventBridgeOnRequestEnd = handler => {
46
40
  onRequestTimeout.name = "sync.onRequestTimeout";
47
41
  return [onRequestResponseSend, onRequestTimeout];
48
42
  };
49
- exports.createSendDataToEventBridgeOnRequestEnd = createSendDataToEventBridgeOnRequestEnd;
50
43
 
51
44
  //# 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,"names":["createOnRequestResponseSend","createOnRequestTimeout","convertException","execute","handler","flush","ex","error","console","flushError","isOptionsRequest","request","method","toUpperCase","createSendDataToEventBridgeOnRequestEnd","onRequestResponseSend","_","payload","name","onRequestTimeout"],"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.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"],"mappings":"AACA,SAASA,2BAA2B,EAAEC,sBAAsB,QAAQ,iBAAiB;AAErF,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAMC,OAAO,GAAG,MAAOC,OAAiB,IAAK;EACzC,IAAI;IACA,OAAO,MAAMA,OAAO,CAACC,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,MAAMC,KAAK,GAAGL,gBAAgB,CAACI,EAAE,CAAC;IAClCE,OAAO,CAACD,KAAK,CAAC;MACVE,UAAU,EAAEF;IAChB,CAAC,CAAC;IACF,OAAO;MACHA;IACJ,CAAC;IACD;AACR;AACA;EACI;AACJ,CAAC;AAED,MAAMG,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;AAED,OAAO,MAAMC,uCAAuC,GAAIV,OAAiB,IAAK;EAC1E,MAAMW,qBAAqB,GAAGf,2BAA2B,CAAC,OAAOW,OAAO,EAAEK,CAAC,EAAEC,OAAO,KAAK;IACrF,IAAIP,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B,OAAOM,OAAO;IAClB;IACA,MAAMd,OAAO,CAACC,OAAO,CAAC;IACtB,OAAOa,OAAO;EAClB,CAAC,CAAC;EACFF,qBAAqB,CAACG,IAAI,GAAG,4BAA4B;EAEzD,MAAMC,gBAAgB,GAAGlB,sBAAsB,CAAC,MAAMU,OAAO,IAAI;IAC7D,IAAID,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B;IACJ;IACA,OAAO,MAAMR,OAAO,CAACC,OAAO,CAAC;EACjC,CAAC,CAAC;EACFe,gBAAgB,CAACD,IAAI,GAAG,uBAAuB;EAE/C,OAAO,CAACH,qBAAqB,EAAEI,gBAAgB,CAAC;AACpD,CAAC","ignoreList":[]}