@webiny/api-sync-system 0.0.0-unstable.e53eceafb5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/constants.d.ts +1 -0
  4. package/constants.js +9 -0
  5. package/constants.js.map +1 -0
  6. package/index.d.ts +3 -0
  7. package/index.js +40 -0
  8. package/index.js.map +1 -0
  9. package/package.json +45 -0
  10. package/resolver/app/RecordHandler.d.ts +34 -0
  11. package/resolver/app/RecordHandler.js +126 -0
  12. package/resolver/app/RecordHandler.js.map +1 -0
  13. package/resolver/app/RecordsValidation.d.ts +6 -0
  14. package/resolver/app/RecordsValidation.js +29 -0
  15. package/resolver/app/RecordsValidation.js.map +1 -0
  16. package/resolver/app/ResolverApplication.d.ts +14 -0
  17. package/resolver/app/ResolverApplication.js +48 -0
  18. package/resolver/app/ResolverApplication.js.map +1 -0
  19. package/resolver/app/abstractions/RecordHandler.d.ts +7 -0
  20. package/resolver/app/abstractions/RecordHandler.js +7 -0
  21. package/resolver/app/abstractions/RecordHandler.js.map +1 -0
  22. package/resolver/app/abstractions/RecordsValidation.d.ts +14 -0
  23. package/resolver/app/abstractions/RecordsValidation.js +7 -0
  24. package/resolver/app/abstractions/RecordsValidation.js.map +1 -0
  25. package/resolver/app/abstractions/ResolverApplication.d.ts +7 -0
  26. package/resolver/app/abstractions/ResolverApplication.js +7 -0
  27. package/resolver/app/abstractions/ResolverApplication.js.map +1 -0
  28. package/resolver/app/abstractions/ResolverRecord.d.ts +42 -0
  29. package/resolver/app/abstractions/ResolverRecord.js +7 -0
  30. package/resolver/app/abstractions/ResolverRecord.js.map +1 -0
  31. package/resolver/app/bundler/BaseBundle.d.ts +21 -0
  32. package/resolver/app/bundler/BaseBundle.js +26 -0
  33. package/resolver/app/bundler/BaseBundle.js.map +1 -0
  34. package/resolver/app/bundler/Bundler.d.ts +10 -0
  35. package/resolver/app/bundler/Bundler.js +30 -0
  36. package/resolver/app/bundler/Bundler.js.map +1 -0
  37. package/resolver/app/bundler/Bundles.d.ts +14 -0
  38. package/resolver/app/bundler/Bundles.js +38 -0
  39. package/resolver/app/bundler/Bundles.js.map +1 -0
  40. package/resolver/app/bundler/CommandBundle.d.ts +15 -0
  41. package/resolver/app/bundler/CommandBundle.js +28 -0
  42. package/resolver/app/bundler/CommandBundle.js.map +1 -0
  43. package/resolver/app/bundler/TableBundle.d.ts +13 -0
  44. package/resolver/app/bundler/TableBundle.js +25 -0
  45. package/resolver/app/bundler/TableBundle.js.map +1 -0
  46. package/resolver/app/bundler/types.d.ts +29 -0
  47. package/resolver/app/bundler/types.js +7 -0
  48. package/resolver/app/bundler/types.js.map +1 -0
  49. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +18 -0
  50. package/resolver/app/commandHandler/DeleteCommandHandler.js +39 -0
  51. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -0
  52. package/resolver/app/commandHandler/PutCommandHandler.d.ts +18 -0
  53. package/resolver/app/commandHandler/PutCommandHandler.js +32 -0
  54. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -0
  55. package/resolver/app/commandHandler/delete.d.ts +2 -0
  56. package/resolver/app/commandHandler/delete.js +24 -0
  57. package/resolver/app/commandHandler/delete.js.map +1 -0
  58. package/resolver/app/commandHandler/put.d.ts +2 -0
  59. package/resolver/app/commandHandler/put.js +24 -0
  60. package/resolver/app/commandHandler/put.js.map +1 -0
  61. package/resolver/app/data/SourceDataContainer.d.ts +12 -0
  62. package/resolver/app/data/SourceDataContainer.js +42 -0
  63. package/resolver/app/data/SourceDataContainer.js.map +1 -0
  64. package/resolver/app/data/types.d.ts +23 -0
  65. package/resolver/app/data/types.js +7 -0
  66. package/resolver/app/data/types.js.map +1 -0
  67. package/resolver/app/fetcher/Fetcher.d.ts +22 -0
  68. package/resolver/app/fetcher/Fetcher.js +132 -0
  69. package/resolver/app/fetcher/Fetcher.js.map +1 -0
  70. package/resolver/app/fetcher/types.d.ts +25 -0
  71. package/resolver/app/fetcher/types.js +7 -0
  72. package/resolver/app/fetcher/types.js.map +1 -0
  73. package/resolver/app/ingestor/Ingestor.d.ts +13 -0
  74. package/resolver/app/ingestor/Ingestor.js +44 -0
  75. package/resolver/app/ingestor/Ingestor.js.map +1 -0
  76. package/resolver/app/ingestor/IngestorResult.d.ts +7 -0
  77. package/resolver/app/ingestor/IngestorResult.js +45 -0
  78. package/resolver/app/ingestor/IngestorResult.js.map +1 -0
  79. package/resolver/app/ingestor/types.d.ts +26 -0
  80. package/resolver/app/ingestor/types.js +7 -0
  81. package/resolver/app/ingestor/types.js.map +1 -0
  82. package/resolver/app/storer/Storer.d.ts +44 -0
  83. package/resolver/app/storer/Storer.js +103 -0
  84. package/resolver/app/storer/Storer.js.map +1 -0
  85. package/resolver/app/storer/types.d.ts +21 -0
  86. package/resolver/app/storer/types.js +7 -0
  87. package/resolver/app/storer/types.js.map +1 -0
  88. package/resolver/app/transform/TransformHandler.d.ts +34 -0
  89. package/resolver/app/transform/TransformHandler.js +70 -0
  90. package/resolver/app/transform/TransformHandler.js.map +1 -0
  91. package/resolver/app/transform/middleware.d.ts +3 -0
  92. package/resolver/app/transform/middleware.js +29 -0
  93. package/resolver/app/transform/middleware.js.map +1 -0
  94. package/resolver/app/utils/Retry.d.ts +18 -0
  95. package/resolver/app/utils/Retry.js +38 -0
  96. package/resolver/app/utils/Retry.js.map +1 -0
  97. package/resolver/app/utils/sleep.d.ts +1 -0
  98. package/resolver/app/utils/sleep.js +14 -0
  99. package/resolver/app/utils/sleep.js.map +1 -0
  100. package/resolver/app/validation/body.d.ts +142 -0
  101. package/resolver/app/validation/body.js +46 -0
  102. package/resolver/app/validation/body.js.map +1 -0
  103. package/resolver/app/validation/createJsonTransform.d.ts +2 -0
  104. package/resolver/app/validation/createJsonTransform.js +24 -0
  105. package/resolver/app/validation/createJsonTransform.js.map +1 -0
  106. package/resolver/app/validation/detail.d.ts +89 -0
  107. package/resolver/app/validation/detail.js +50 -0
  108. package/resolver/app/validation/detail.js.map +1 -0
  109. package/resolver/app/validation/event.d.ts +217 -0
  110. package/resolver/app/validation/event.js +32 -0
  111. package/resolver/app/validation/event.js.map +1 -0
  112. package/resolver/app/validation/numericString.d.ts +2 -0
  113. package/resolver/app/validation/numericString.js +23 -0
  114. package/resolver/app/validation/numericString.js.map +1 -0
  115. package/resolver/app/validation/system.d.ts +20 -0
  116. package/resolver/app/validation/system.js +20 -0
  117. package/resolver/app/validation/system.js.map +1 -0
  118. package/resolver/createEventHandlerPlugin.d.ts +10 -0
  119. package/resolver/createEventHandlerPlugin.js +127 -0
  120. package/resolver/createEventHandlerPlugin.js.map +1 -0
  121. package/resolver/createResolverHandler.d.ts +21 -0
  122. package/resolver/createResolverHandler.js +79 -0
  123. package/resolver/createResolverHandler.js.map +1 -0
  124. package/resolver/deployment/Deployment.d.ts +17 -0
  125. package/resolver/deployment/Deployment.js +50 -0
  126. package/resolver/deployment/Deployment.js.map +1 -0
  127. package/resolver/deployment/Deployments.d.ts +13 -0
  128. package/resolver/deployment/Deployments.js +34 -0
  129. package/resolver/deployment/Deployments.js.map +1 -0
  130. package/resolver/deployment/DeploymentsFetcher.d.ts +16 -0
  131. package/resolver/deployment/DeploymentsFetcher.js +112 -0
  132. package/resolver/deployment/DeploymentsFetcher.js.map +1 -0
  133. package/resolver/deployment/types.d.ts +34 -0
  134. package/resolver/deployment/types.js +7 -0
  135. package/resolver/deployment/types.js.map +1 -0
  136. package/resolver/lambda/LambdaTrigger.d.ts +18 -0
  137. package/resolver/lambda/LambdaTrigger.js +39 -0
  138. package/resolver/lambda/LambdaTrigger.js.map +1 -0
  139. package/resolver/plugins/CommandHandlerPlugin.d.ts +31 -0
  140. package/resolver/plugins/CommandHandlerPlugin.js +27 -0
  141. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -0
  142. package/resolver/plugins/StorerAfterEachPlugin.d.ts +31 -0
  143. package/resolver/plugins/StorerAfterEachPlugin.js +33 -0
  144. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -0
  145. package/resolver/plugins/TransformRecordPlugin.d.ts +38 -0
  146. package/resolver/plugins/TransformRecordPlugin.js +30 -0
  147. package/resolver/plugins/TransformRecordPlugin.js.map +1 -0
  148. package/resolver/recordTypes/fileManager/CopyFile.d.ts +14 -0
  149. package/resolver/recordTypes/fileManager/CopyFile.js +81 -0
  150. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -0
  151. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +14 -0
  152. package/resolver/recordTypes/fileManager/DeleteFile.js +72 -0
  153. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -0
  154. package/resolver/recordTypes/fileManager/fileManager.d.ts +6 -0
  155. package/resolver/recordTypes/fileManager/fileManager.js +14 -0
  156. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -0
  157. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +5 -0
  158. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +48 -0
  159. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -0
  160. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +5 -0
  161. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +48 -0
  162. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -0
  163. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +2 -0
  164. package/resolver/recordTypes/fileManager/shouldBeHandled.js +37 -0
  165. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -0
  166. package/resolver/recordTypes/fileManager/types.d.ts +26 -0
  167. package/resolver/recordTypes/fileManager/types.js +7 -0
  168. package/resolver/recordTypes/fileManager/types.js.map +1 -0
  169. package/resolver/recordTypes/users/CopyUser.d.ts +18 -0
  170. package/resolver/recordTypes/users/CopyUser.js +67 -0
  171. package/resolver/recordTypes/users/CopyUser.js.map +1 -0
  172. package/resolver/recordTypes/users/DeleteUser.d.ts +18 -0
  173. package/resolver/recordTypes/users/DeleteUser.js +65 -0
  174. package/resolver/recordTypes/users/DeleteUser.js.map +1 -0
  175. package/resolver/recordTypes/users/shouldBeHandled.d.ts +2 -0
  176. package/resolver/recordTypes/users/shouldBeHandled.js +36 -0
  177. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -0
  178. package/resolver/recordTypes/users/types.d.ts +24 -0
  179. package/resolver/recordTypes/users/types.js +7 -0
  180. package/resolver/recordTypes/users/types.js.map +1 -0
  181. package/resolver/recordTypes/users/users.d.ts +6 -0
  182. package/resolver/recordTypes/users/users.js +14 -0
  183. package/resolver/recordTypes/users/users.js.map +1 -0
  184. package/resolver/recordTypes/users/usersOnDelete.d.ts +5 -0
  185. package/resolver/recordTypes/users/usersOnDelete.js +47 -0
  186. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -0
  187. package/resolver/recordTypes/users/usersOnPut.d.ts +5 -0
  188. package/resolver/recordTypes/users/usersOnPut.js +48 -0
  189. package/resolver/recordTypes/users/usersOnPut.js.map +1 -0
  190. package/sync/FilterOutRecord.d.ts +11 -0
  191. package/sync/FilterOutRecord.js +29 -0
  192. package/sync/FilterOutRecord.js.map +1 -0
  193. package/sync/attachToDynamoDbDocument.d.ts +11 -0
  194. package/sync/attachToDynamoDbDocument.js +79 -0
  195. package/sync/attachToDynamoDbDocument.js.map +1 -0
  196. package/sync/createHandler.d.ts +14 -0
  197. package/sync/createHandler.js +63 -0
  198. package/sync/createHandler.js.map +1 -0
  199. package/sync/createSendDataToEventBridgeOnRequestEnd.d.ts +2 -0
  200. package/sync/createSendDataToEventBridgeOnRequestEnd.js +51 -0
  201. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -0
  202. package/sync/createSyncSystem.d.ts +16 -0
  203. package/sync/createSyncSystem.js +42 -0
  204. package/sync/createSyncSystem.js.map +1 -0
  205. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +13 -0
  206. package/sync/filter/createDefaultFilterOutRecordPlugins.js +88 -0
  207. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -0
  208. package/sync/handler/Handler.d.ts +28 -0
  209. package/sync/handler/Handler.js +93 -0
  210. package/sync/handler/Handler.js.map +1 -0
  211. package/sync/handler/HandlerConverter.d.ts +12 -0
  212. package/sync/handler/HandlerConverter.js +43 -0
  213. package/sync/handler/HandlerConverter.js.map +1 -0
  214. package/sync/handler/converter/BatchGetCommandConverter.d.ts +8 -0
  215. package/sync/handler/converter/BatchGetCommandConverter.js +24 -0
  216. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -0
  217. package/sync/handler/converter/BatchWriteCommandConverter.d.ts +9 -0
  218. package/sync/handler/converter/BatchWriteCommandConverter.js +24 -0
  219. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -0
  220. package/sync/handler/converter/DeleteCommandConverter.d.ts +9 -0
  221. package/sync/handler/converter/DeleteCommandConverter.js +24 -0
  222. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -0
  223. package/sync/handler/converter/GetCommandConverter.d.ts +8 -0
  224. package/sync/handler/converter/GetCommandConverter.js +24 -0
  225. package/sync/handler/converter/GetCommandConverter.js.map +1 -0
  226. package/sync/handler/converter/PutCommandConverter.d.ts +9 -0
  227. package/sync/handler/converter/PutCommandConverter.js +24 -0
  228. package/sync/handler/converter/PutCommandConverter.js.map +1 -0
  229. package/sync/handler/converter/QueryCommandConverter.d.ts +8 -0
  230. package/sync/handler/converter/QueryCommandConverter.js +24 -0
  231. package/sync/handler/converter/QueryCommandConverter.js.map +1 -0
  232. package/sync/handler/converter/ScanCommandConverter.d.ts +8 -0
  233. package/sync/handler/converter/ScanCommandConverter.js +24 -0
  234. package/sync/handler/converter/ScanCommandConverter.js.map +1 -0
  235. package/sync/handler/converter/UpdateCommandConverter.d.ts +9 -0
  236. package/sync/handler/converter/UpdateCommandConverter.js +24 -0
  237. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -0
  238. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +9 -0
  239. package/sync/handler/converter/commands/BatchWriteCommandValue.js +51 -0
  240. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -0
  241. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +9 -0
  242. package/sync/handler/converter/commands/DeleteCommandValue.js +27 -0
  243. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -0
  244. package/sync/handler/converter/commands/NullCommandValue.d.ts +8 -0
  245. package/sync/handler/converter/commands/NullCommandValue.js +18 -0
  246. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -0
  247. package/sync/handler/converter/commands/PutCommandValue.d.ts +9 -0
  248. package/sync/handler/converter/commands/PutCommandValue.js +27 -0
  249. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -0
  250. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +9 -0
  251. package/sync/handler/converter/commands/UpdateCommandValue.js +27 -0
  252. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -0
  253. package/sync/handler/types.d.ts +18 -0
  254. package/sync/handler/types.js +7 -0
  255. package/sync/handler/types.js.map +1 -0
  256. package/sync/plugins/FilterOutRecordPlugin.d.ts +23 -0
  257. package/sync/plugins/FilterOutRecordPlugin.js +31 -0
  258. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -0
  259. package/sync/requestPlugin.d.ts +9 -0
  260. package/sync/requestPlugin.js +59 -0
  261. package/sync/requestPlugin.js.map +1 -0
  262. package/sync/types.d.ts +64 -0
  263. package/sync/types.js +7 -0
  264. package/sync/types.js.map +1 -0
  265. package/sync/utils/getTableType.d.ts +2 -0
  266. package/sync/utils/getTableType.js +22 -0
  267. package/sync/utils/getTableType.js.map +1 -0
  268. package/sync/utils/manifest.d.ts +17 -0
  269. package/sync/utils/manifest.js +52 -0
  270. package/sync/utils/manifest.js.map +1 -0
  271. package/sync/utils/validateSystemInput.d.ts +11 -0
  272. package/sync/utils/validateSystemInput.js +44 -0
  273. package/sync/utils/validateSystemInput.js.map +1 -0
  274. package/types.d.ts +42 -0
  275. package/types.js +15 -0
  276. package/types.js.map +1 -0
  277. package/utils/createSystemName.d.ts +5 -0
  278. package/utils/createSystemName.js +12 -0
  279. package/utils/createSystemName.js.map +1 -0
  280. package/worker/actions/copyFile/CopyFile.d.ts +63 -0
  281. package/worker/actions/copyFile/CopyFile.js +283 -0
  282. package/worker/actions/copyFile/CopyFile.js.map +1 -0
  283. package/worker/actions/copyFile/copyFileAction.d.ts +6 -0
  284. package/worker/actions/copyFile/copyFileAction.js +47 -0
  285. package/worker/actions/copyFile/copyFileAction.js.map +1 -0
  286. package/worker/actions/copyFile/copyFileSchema.d.ts +47 -0
  287. package/worker/actions/copyFile/copyFileSchema.js +25 -0
  288. package/worker/actions/copyFile/copyFileSchema.js.map +1 -0
  289. package/worker/actions/copyFile/types.d.ts +10 -0
  290. package/worker/actions/copyFile/types.js +7 -0
  291. package/worker/actions/copyFile/types.js.map +1 -0
  292. package/worker/actions/createUser/CreateUser.d.ts +17 -0
  293. package/worker/actions/createUser/CreateUser.js +90 -0
  294. package/worker/actions/createUser/CreateUser.js.map +1 -0
  295. package/worker/actions/createUser/createUserAction.d.ts +6 -0
  296. package/worker/actions/createUser/createUserAction.js +42 -0
  297. package/worker/actions/createUser/createUserAction.js.map +1 -0
  298. package/worker/actions/createUser/createUserSchema.d.ts +47 -0
  299. package/worker/actions/createUser/createUserSchema.js +25 -0
  300. package/worker/actions/createUser/createUserSchema.js.map +1 -0
  301. package/worker/actions/createUser/types.d.ts +10 -0
  302. package/worker/actions/createUser/types.js +7 -0
  303. package/worker/actions/createUser/types.js.map +1 -0
  304. package/worker/actions/deleteFile/DeleteFile.d.ts +24 -0
  305. package/worker/actions/deleteFile/DeleteFile.js +82 -0
  306. package/worker/actions/deleteFile/DeleteFile.js.map +1 -0
  307. package/worker/actions/deleteFile/deleteFileAction.d.ts +6 -0
  308. package/worker/actions/deleteFile/deleteFileAction.js +42 -0
  309. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -0
  310. package/worker/actions/deleteFile/deleteFileSchema.d.ts +47 -0
  311. package/worker/actions/deleteFile/deleteFileSchema.js +25 -0
  312. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -0
  313. package/worker/actions/deleteFile/types.d.ts +9 -0
  314. package/worker/actions/deleteFile/types.js +7 -0
  315. package/worker/actions/deleteFile/types.js.map +1 -0
  316. package/worker/actions/deleteUser/DeleteUser.d.ts +16 -0
  317. package/worker/actions/deleteUser/DeleteUser.js +67 -0
  318. package/worker/actions/deleteUser/DeleteUser.js.map +1 -0
  319. package/worker/actions/deleteUser/deleteUserAction.d.ts +6 -0
  320. package/worker/actions/deleteUser/deleteUserAction.js +40 -0
  321. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -0
  322. package/worker/actions/deleteUser/deleteUserSchema.d.ts +29 -0
  323. package/worker/actions/deleteUser/deleteUserSchema.js +24 -0
  324. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -0
  325. package/worker/actions/deleteUser/types.d.ts +9 -0
  326. package/worker/actions/deleteUser/types.js +7 -0
  327. package/worker/actions/deleteUser/types.js.map +1 -0
  328. package/worker/actions/logValidationError.d.ts +2 -0
  329. package/worker/actions/logValidationError.js +17 -0
  330. package/worker/actions/logValidationError.js.map +1 -0
  331. package/worker/actions/removeCognitoUserAttributes.d.ts +6 -0
  332. package/worker/actions/removeCognitoUserAttributes.js +24 -0
  333. package/worker/actions/removeCognitoUserAttributes.js.map +1 -0
  334. package/worker/actions/updateUser/UpdateUser.d.ts +17 -0
  335. package/worker/actions/updateUser/UpdateUser.js +81 -0
  336. package/worker/actions/updateUser/UpdateUser.js.map +1 -0
  337. package/worker/actions/updateUser/types.d.ts +10 -0
  338. package/worker/actions/updateUser/types.js +7 -0
  339. package/worker/actions/updateUser/types.js.map +1 -0
  340. package/worker/actions/updateUser/updateUserAction.d.ts +6 -0
  341. package/worker/actions/updateUser/updateUserAction.js +42 -0
  342. package/worker/actions/updateUser/updateUserAction.js.map +1 -0
  343. package/worker/actions/updateUser/updateUserSchema.d.ts +47 -0
  344. package/worker/actions/updateUser/updateUserSchema.js +25 -0
  345. package/worker/actions/updateUser/updateUserSchema.js.map +1 -0
  346. package/worker/createWorkerHandler.d.ts +11 -0
  347. package/worker/createWorkerHandler.js +48 -0
  348. package/worker/createWorkerHandler.js.map +1 -0
  349. package/worker/handler/WorkerActionHandler.d.ts +10 -0
  350. package/worker/handler/WorkerActionHandler.js +33 -0
  351. package/worker/handler/WorkerActionHandler.js.map +1 -0
  352. package/worker/handler/eventHandler.d.ts +1 -0
  353. package/worker/handler/eventHandler.js +31 -0
  354. package/worker/handler/eventHandler.js.map +1 -0
  355. package/worker/plugins/WorkerActionPlugin.d.ts +10 -0
  356. package/worker/plugins/WorkerActionPlugin.js +28 -0
  357. package/worker/plugins/WorkerActionPlugin.js.map +1 -0
  358. package/worker/types.d.ts +14 -0
  359. package/worker/types.js +7 -0
  360. package/worker/types.js.map +1 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shouldBeHandled = void 0;
7
+ const shouldBeHandled = params => {
8
+ const {
9
+ item,
10
+ table,
11
+ source,
12
+ target
13
+ } = params;
14
+ if (table.type !== "regular") {
15
+ return false;
16
+ } else if (item.PK.includes("#ADMIN_USER#") === false) {
17
+ return false;
18
+ } else if (item.SK !== "A") {
19
+ return false;
20
+ } else if (item.TYPE !== "adminUsers.user") {
21
+ return false;
22
+ } else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) {
23
+ return false;
24
+ }
25
+ /**
26
+ * TODO verify that email is always present in Cognito users.
27
+ */
28
+ // @ts-expect-error
29
+ else if (!item.data?.email) {
30
+ return false;
31
+ }
32
+ return true;
33
+ };
34
+ exports.shouldBeHandled = shouldBeHandled;
35
+
36
+ //# sourceMappingURL=shouldBeHandled.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,24 @@
1
+ import type { IDeployment } from "../../deployment/types";
2
+ import type { CognitoIdentityProviderClient, CognitoIdentityProviderClientConfig } from "@webiny/aws-sdk/client-cognito-identity-provider/index.js";
3
+ import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
4
+ export interface IUserDeploymentServices {
5
+ cognitoUserPoolId: string;
6
+ }
7
+ export interface ICopyUserHandleParams {
8
+ username: string;
9
+ source: Pick<IDeployment<IUserDeploymentServices>, "region" | "services">;
10
+ target: Pick<IDeployment<IUserDeploymentServices>, "region" | "services">;
11
+ }
12
+ export interface ICopyUser {
13
+ handle(params: ICopyUserHandleParams): Promise<InvokeCommandOutput | null>;
14
+ }
15
+ export interface IDeleteUserHandleParams {
16
+ username: string;
17
+ target: Pick<IDeployment<IUserDeploymentServices>, "region" | "services">;
18
+ }
19
+ export interface IDeleteUser {
20
+ handle(params: IDeleteUserHandleParams): Promise<InvokeCommandOutput | null>;
21
+ }
22
+ export interface ICreateCognitoIdentityProviderClientCb {
23
+ (config: Partial<CognitoIdentityProviderClientConfig>): Pick<CognitoIdentityProviderClient, "send">;
24
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,6 @@
1
+ import type { ICopyUser, IDeleteUser } from "./types.js";
2
+ export interface ICreateUsersPluginsParams {
3
+ copyUser: ICopyUser;
4
+ deleteUser: IDeleteUser;
5
+ }
6
+ export declare const createUsersPlugins: (params: ICreateUsersPluginsParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin[];
@@ -0,0 +1,14 @@
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)];
11
+ };
12
+ exports.createUsersPlugins = createUsersPlugins;
13
+
14
+ //# sourceMappingURL=users.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,5 @@
1
+ import type { IDeleteUser } from "./types.js";
2
+ export interface IDeleteUserOnDeletePluginParams {
3
+ deleteUser: IDeleteUser;
4
+ }
5
+ export declare const createUserOnDeletePlugin: (params: IDeleteUserOnDeletePluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -0,0 +1,47 @@
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 => {
11
+ const {
12
+ deleteUser
13
+ } = params;
14
+ return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("users.onDelete", {
15
+ canHandle: params => {
16
+ const {
17
+ command
18
+ } = params;
19
+ if (command !== "delete") {
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 deleteUser.handle({
35
+ target: params.target,
36
+ username
37
+ });
38
+ } catch (ex) {
39
+ console.error("Error while handling users onDelete plugin.");
40
+ console.log((0, _utils.convertException)(ex));
41
+ }
42
+ }
43
+ });
44
+ };
45
+ exports.createUserOnDeletePlugin = createUserOnDeletePlugin;
46
+
47
+ //# sourceMappingURL=usersOnDelete.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,5 @@
1
+ import type { ICopyUser } from "./types.js";
2
+ export interface ICreateUserOnPutPluginParams {
3
+ copyUser: ICopyUser;
4
+ }
5
+ export declare const createUserOnPutPlugin: (params: ICreateUserOnPutPluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -0,0 +1,48 @@
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
+ });
45
+ };
46
+ exports.createUserOnPutPlugin = createUserOnPutPlugin;
47
+
48
+ //# sourceMappingURL=usersOnPut.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,11 @@
1
+ import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
2
+ import type { ICommandValueItemExtended } from "./types.js";
3
+ export declare class FilterOutRecord {
4
+ private readonly plugins;
5
+ constructor(plugins: FilterOutRecordPlugin[]);
6
+ /**
7
+ * If method returns `true`, the record will be filtered out.
8
+ */
9
+ filterOut(item: ICommandValueItemExtended): boolean;
10
+ }
11
+ export declare const createFilterOutRecord: (plugins: FilterOutRecordPlugin[]) => FilterOutRecord;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFilterOutRecord = exports.FilterOutRecord = void 0;
7
+ 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
+ }
19
+ }
20
+ return false;
21
+ }
22
+ }
23
+ exports.FilterOutRecord = FilterOutRecord;
24
+ const createFilterOutRecord = plugins => {
25
+ return new FilterOutRecord(plugins);
26
+ };
27
+ exports.createFilterOutRecord = createFilterOutRecord;
28
+
29
+ //# sourceMappingURL=FilterOutRecord.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,11 @@
1
+ import type { IHandler } from "./types.js";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
+ export interface IAttachToDynamoDbDocumentParams {
4
+ handler: IHandler;
5
+ }
6
+ export interface IDecorateClientWithHandlerParams {
7
+ handler: IHandler;
8
+ client: DynamoDBDocument;
9
+ }
10
+ export declare const decorateClientWithHandler: (params: IDecorateClientWithHandlerParams) => DynamoDBDocument;
11
+ export declare const attachToDynamoDbDocument: ({ handler }: IAttachToDynamoDbDocumentParams) => void;
@@ -0,0 +1,79 @@
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) {
20
+ 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
+ };
77
+ exports.attachToDynamoDbDocument = attachToDynamoDbDocument;
78
+
79
+ //# sourceMappingURL=attachToDynamoDbDocument.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,14 @@
1
+ import type { EventBridgeClient } from "@webiny/aws-sdk/client-eventbridge/index.js";
2
+ import type { ICommandConverter, IManifest, ISystem } from "./types.js";
3
+ import type { PluginsContainer } from "@webiny/plugins/PluginsContainer.js";
4
+ export interface ICreateHandlerParams {
5
+ getEventBridgeClient(): Pick<EventBridgeClient, "send">;
6
+ commandConverters?: ICommandConverter[];
7
+ system: ISystem;
8
+ manifest: IManifest;
9
+ getPlugins: () => PluginsContainer;
10
+ }
11
+ export declare const createHandler: (params: ICreateHandlerParams) => {
12
+ handler: import("./types.js").IHandler;
13
+ converter: import("./types.js").IHandlerConverter;
14
+ };
@@ -0,0 +1,63 @@
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
+ };
60
+ };
61
+ exports.createHandler = createHandler;
62
+
63
+ //# sourceMappingURL=createHandler.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,2 @@
1
+ import type { IHandler } from "./types.js";
2
+ export declare const createSendDataToEventBridgeOnRequestEnd: (handler: IHandler) => (import("@webiny/handler").OnRequestResponseSendPlugin | import("@webiny/handler").OnRequestTimeoutPlugin)[];
@@ -0,0 +1,51 @@
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
+ }
24
+ };
25
+ const isOptionsRequest = request => {
26
+ if (!request?.method) {
27
+ return false;
28
+ }
29
+ return request.method.toUpperCase() === "OPTIONS";
30
+ };
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];
48
+ };
49
+ exports.createSendDataToEventBridgeOnRequestEnd = createSendDataToEventBridgeOnRequestEnd;
50
+
51
+ //# sourceMappingURL=createSendDataToEventBridgeOnRequestEnd.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,16 @@
1
+ import type { Plugin } from "@webiny/plugins/types.js";
2
+ import type { IGetEventBridgeCallable, ISystem } from "./types.js";
3
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
4
+ import type { PossiblyUndefinedProperties } from "@webiny/api/types";
5
+ import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
6
+ export type IAllowedPlugins = FilterOutRecordPlugin;
7
+ export interface ICreateSyncSystemParams {
8
+ getDocumentClient(): Pick<DynamoDBDocument, "send">;
9
+ getEventBridgeClient: IGetEventBridgeCallable;
10
+ system: PossiblyUndefinedProperties<Omit<ISystem, "name">>;
11
+ plugins?: IAllowedPlugins[];
12
+ }
13
+ export interface ICreateSyncSystemResponse {
14
+ plugins(): Plugin[];
15
+ }
16
+ export declare const createSyncSystem: (params: ICreateSyncSystemParams) => ICreateSyncSystemResponse;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSyncSystem = void 0;
7
+ var _validateSystemInput = require("./utils/validateSystemInput.js");
8
+ var _requestPlugin = require("./requestPlugin.js");
9
+ var _createDefaultFilterOutRecordPlugins = require("./filter/createDefaultFilterOutRecordPlugins.js");
10
+ const emptyResponse = {
11
+ plugins() {
12
+ return [];
13
+ }
14
+ };
15
+ const createSyncSystem = params => {
16
+ const {
17
+ system,
18
+ error
19
+ } = (0, _validateSystemInput.validateSystemInput)(params.system);
20
+ /**
21
+ * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.
22
+ */
23
+ if (error) {
24
+ console.error(error);
25
+ return emptyResponse;
26
+ } else if (!system) {
27
+ console.error("Sync System: No system provided. Sync System will not be attached.");
28
+ return emptyResponse;
29
+ }
30
+ return {
31
+ plugins: () => {
32
+ return [...(params.plugins || []), ...(0, _createDefaultFilterOutRecordPlugins.createDefaultFilterOutRecordPlugins)(), (0, _requestPlugin.createSyncSystemHandlerOnRequestPlugin)({
33
+ getDocumentClient: params.getDocumentClient,
34
+ getEventBridgeClient: params.getEventBridgeClient,
35
+ system
36
+ })];
37
+ }
38
+ };
39
+ };
40
+ exports.createSyncSystem = createSyncSystem;
41
+
42
+ //# sourceMappingURL=createSyncSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_validateSystemInput","require","_requestPlugin","_createDefaultFilterOutRecordPlugins","emptyResponse","plugins","createSyncSystem","params","system","error","validateSystemInput","console","createDefaultFilterOutRecordPlugins","createSyncSystemHandlerOnRequestPlugin","getDocumentClient","getEventBridgeClient","exports"],"sources":["createSyncSystem.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { IGetEventBridgeCallable, ISystem } from \"./types.js\";\nimport { validateSystemInput } from \"./utils/validateSystemInput.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { PossiblyUndefinedProperties } from \"@webiny/api/types\";\nimport { createSyncSystemHandlerOnRequestPlugin } from \"./requestPlugin.js\";\nimport type { FilterOutRecordPlugin } from \"./plugins/FilterOutRecordPlugin.js\";\nimport { createDefaultFilterOutRecordPlugins } from \"./filter/createDefaultFilterOutRecordPlugins.js\";\n\nexport type IAllowedPlugins = FilterOutRecordPlugin;\n\nexport interface ICreateSyncSystemParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: PossiblyUndefinedProperties<Omit<ISystem, \"name\">>;\n plugins?: IAllowedPlugins[];\n}\n\nexport interface ICreateSyncSystemResponse {\n plugins(): Plugin[];\n}\n\nconst emptyResponse: ICreateSyncSystemResponse = {\n plugins(): Plugin[] {\n return [];\n }\n};\n\nexport const createSyncSystem = (params: ICreateSyncSystemParams): ICreateSyncSystemResponse => {\n const { system, error } = validateSystemInput(params.system);\n /**\n * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.\n */\n if (error) {\n console.error(error);\n return emptyResponse;\n } else if (!system) {\n console.error(\"Sync System: No system provided. Sync System will not be attached.\");\n return emptyResponse;\n }\n\n return {\n plugins: () => {\n return [\n ...(params.plugins || []),\n ...createDefaultFilterOutRecordPlugins(),\n createSyncSystemHandlerOnRequestPlugin({\n getDocumentClient: params.getDocumentClient,\n getEventBridgeClient: params.getEventBridgeClient,\n system\n })\n ];\n }\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,oBAAA,GAAAC,OAAA;AAGA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,oCAAA,GAAAF,OAAA;AAeA,MAAMG,aAAwC,GAAG;EAC7CC,OAAOA,CAAA,EAAa;IAChB,OAAO,EAAE;EACb;AACJ,CAAC;AAEM,MAAMC,gBAAgB,GAAIC,MAA+B,IAAgC;EAC5F,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAG,IAAAC,wCAAmB,EAACH,MAAM,CAACC,MAAM,CAAC;EAC5D;AACJ;AACA;EACI,IAAIC,KAAK,EAAE;IACPE,OAAO,CAACF,KAAK,CAACA,KAAK,CAAC;IACpB,OAAOL,aAAa;EACxB,CAAC,MAAM,IAAI,CAACI,MAAM,EAAE;IAChBG,OAAO,CAACF,KAAK,CAAC,oEAAoE,CAAC;IACnF,OAAOL,aAAa;EACxB;EAEA,OAAO;IACHC,OAAO,EAAEA,CAAA,KAAM;MACX,OAAO,CACH,IAAIE,MAAM,CAACF,OAAO,IAAI,EAAE,CAAC,EACzB,GAAG,IAAAO,wEAAmC,EAAC,CAAC,EACxC,IAAAC,qDAAsC,EAAC;QACnCC,iBAAiB,EAAEP,MAAM,CAACO,iBAAiB;QAC3CC,oBAAoB,EAAER,MAAM,CAACQ,oBAAoB;QACjDP;MACJ,CAAC,CAAC,CACL;IACL;EACJ,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAV,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import { FilterOutRecordPlugin } from "../plugins/FilterOutRecordPlugin.js";
2
+ /**
3
+ * Order keys by what is most like to be filtered out - most inserts/updates/deletes.
4
+ * This is out of my head, so it might not be the best order.
5
+ */
6
+ export declare const equalKeys: string[];
7
+ export declare const startsWithKeys: string[];
8
+ /**
9
+ * TODO figure out a way to skip these models.
10
+ * When deleting a record, we do not have a modelId in the values.
11
+ */
12
+ export declare const skipModels: string[];
13
+ export declare const createDefaultFilterOutRecordPlugins: () => FilterOutRecordPlugin[];