@webiny/api-sync-system 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.e9333b3f0b

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 (276) hide show
  1. package/constants.js +2 -1
  2. package/constants.js.map +1 -1
  3. package/index.d.ts +11 -3
  4. package/index.js +8 -5
  5. package/package.json +23 -18
  6. package/resolver/SyncResolverConfig.d.ts +17 -0
  7. package/resolver/SyncResolverConfig.js +5 -0
  8. package/resolver/SyncResolverConfig.js.map +1 -0
  9. package/resolver/SyncResolverLambdaHandler.d.ts +14 -0
  10. package/resolver/SyncResolverLambdaHandler.js +159 -0
  11. package/resolver/SyncResolverLambdaHandler.js.map +1 -0
  12. package/resolver/app/RecordHandler.js +83 -105
  13. package/resolver/app/RecordHandler.js.map +1 -1
  14. package/resolver/app/RecordsValidation.js +11 -14
  15. package/resolver/app/RecordsValidation.js.map +1 -1
  16. package/resolver/app/ResolverApplication.js +24 -31
  17. package/resolver/app/ResolverApplication.js.map +1 -1
  18. package/resolver/app/abstractions/RecordHandler.js +0 -3
  19. package/resolver/app/abstractions/RecordsValidation.js +0 -3
  20. package/resolver/app/abstractions/ResolverApplication.js +0 -3
  21. package/resolver/app/abstractions/ResolverRecord.js +0 -3
  22. package/resolver/app/bundler/BaseBundle.js +17 -16
  23. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  24. package/resolver/app/bundler/Bundler.js +13 -18
  25. package/resolver/app/bundler/Bundler.js.map +1 -1
  26. package/resolver/app/bundler/Bundles.js +21 -26
  27. package/resolver/app/bundler/Bundles.js.map +1 -1
  28. package/resolver/app/bundler/CommandBundle.js +7 -16
  29. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  30. package/resolver/app/bundler/TableBundle.js +6 -13
  31. package/resolver/app/bundler/TableBundle.js.map +1 -1
  32. package/resolver/app/bundler/types.js +0 -3
  33. package/resolver/app/commandHandler/DeleteCommandHandler.js +22 -29
  34. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  35. package/resolver/app/commandHandler/PutCommandHandler.js +16 -22
  36. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  37. package/resolver/app/commandHandler/delete.js +11 -12
  38. package/resolver/app/commandHandler/delete.js.map +1 -1
  39. package/resolver/app/commandHandler/put.js +11 -12
  40. package/resolver/app/commandHandler/put.js.map +1 -1
  41. package/resolver/app/data/SourceDataContainer.js +28 -30
  42. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  43. package/resolver/app/data/types.js +0 -3
  44. package/resolver/app/fetcher/Fetcher.js +84 -109
  45. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  46. package/resolver/app/fetcher/types.js +0 -3
  47. package/resolver/app/ingestor/Ingestor.js +27 -32
  48. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  49. package/resolver/app/ingestor/IngestorResult.js +28 -32
  50. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  51. package/resolver/app/ingestor/types.js +0 -3
  52. package/resolver/app/storer/Storer.js +71 -85
  53. package/resolver/app/storer/Storer.js.map +1 -1
  54. package/resolver/app/storer/types.js +0 -3
  55. package/resolver/app/transform/TransformHandler.js +45 -56
  56. package/resolver/app/transform/TransformHandler.js.map +1 -1
  57. package/resolver/app/transform/middleware.js +13 -20
  58. package/resolver/app/transform/middleware.js.map +1 -1
  59. package/resolver/app/utils/Retry.js +21 -24
  60. package/resolver/app/utils/Retry.js.map +1 -1
  61. package/resolver/app/utils/sleep.js +4 -5
  62. package/resolver/app/utils/sleep.js.map +1 -1
  63. package/resolver/app/validation/body.d.ts +5 -5
  64. package/resolver/app/validation/body.js +26 -31
  65. package/resolver/app/validation/body.js.map +1 -1
  66. package/resolver/app/validation/createJsonTransform.js +12 -13
  67. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  68. package/resolver/app/validation/detail.d.ts +5 -5
  69. package/resolver/app/validation/detail.js +30 -35
  70. package/resolver/app/validation/detail.js.map +1 -1
  71. package/resolver/app/validation/event.d.ts +5 -5
  72. package/resolver/app/validation/event.js +17 -18
  73. package/resolver/app/validation/event.js.map +1 -1
  74. package/resolver/app/validation/numericString.js +8 -11
  75. package/resolver/app/validation/numericString.js.map +1 -1
  76. package/resolver/app/validation/system.js +8 -9
  77. package/resolver/app/validation/system.js.map +1 -1
  78. package/resolver/deployment/Deployment.js +28 -31
  79. package/resolver/deployment/Deployment.js.map +1 -1
  80. package/resolver/deployment/Deployments.js +20 -23
  81. package/resolver/deployment/Deployments.js.map +1 -1
  82. package/resolver/deployment/DeploymentsFetcher.js +75 -84
  83. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  84. package/resolver/deployment/types.js +0 -3
  85. package/resolver/lambda/LambdaTrigger.js +24 -26
  86. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  87. package/resolver/plugins/CommandHandlerPlugin.js +16 -15
  88. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  89. package/resolver/plugins/StorerAfterEachPlugin.js +20 -19
  90. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  91. package/resolver/plugins/TransformRecordPlugin.js +19 -18
  92. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  93. package/resolver/recordTypes/fileManager/CopyFile.js +44 -67
  94. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  95. package/resolver/recordTypes/fileManager/DeleteFile.js +40 -58
  96. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  97. package/resolver/recordTypes/fileManager/fileManager.js +5 -3
  98. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  99. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +24 -35
  100. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  101. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +24 -35
  102. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  103. package/resolver/recordTypes/fileManager/shouldBeHandled.js +10 -27
  104. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  105. package/resolver/recordTypes/fileManager/types.js +0 -3
  106. package/resolver/recordTypes/users/CopyUser.js +44 -54
  107. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  108. package/resolver/recordTypes/users/DeleteUser.js +40 -51
  109. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  110. package/resolver/recordTypes/users/shouldBeHandled.js +10 -26
  111. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  112. package/resolver/recordTypes/users/types.js +0 -3
  113. package/resolver/recordTypes/users/users.js +5 -3
  114. package/resolver/recordTypes/users/users.js.map +1 -1
  115. package/resolver/recordTypes/users/usersOnDelete.js +23 -34
  116. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  117. package/resolver/recordTypes/users/usersOnPut.js +24 -35
  118. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  119. package/sync/ApiGatewaySyncDecorator.d.ts +14 -0
  120. package/sync/ApiGatewaySyncDecorator.js +49 -0
  121. package/sync/ApiGatewaySyncDecorator.js.map +1 -0
  122. package/sync/FilterOutRecord.js +9 -17
  123. package/sync/FilterOutRecord.js.map +1 -1
  124. package/sync/SyncSystemConfig.d.ts +11 -0
  125. package/sync/SyncSystemConfig.js +5 -0
  126. package/sync/SyncSystemConfig.js.map +1 -0
  127. package/sync/attachToDynamoDbDocument.js +46 -65
  128. package/sync/attachToDynamoDbDocument.js.map +1 -1
  129. package/sync/createHandler.js +31 -40
  130. package/sync/createHandler.js.map +1 -1
  131. package/sync/filter/createDefaultFilterOutRecordPlugins.js +37 -76
  132. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  133. package/sync/handler/Handler.js +64 -76
  134. package/sync/handler/Handler.js.map +1 -1
  135. package/sync/handler/HandlerConverter.js +21 -29
  136. package/sync/handler/HandlerConverter.js.map +1 -1
  137. package/sync/handler/converter/BatchGetCommandConverter.js +12 -11
  138. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  139. package/sync/handler/converter/BatchWriteCommandConverter.js +12 -11
  140. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  141. package/sync/handler/converter/DeleteCommandConverter.js +12 -11
  142. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  143. package/sync/handler/converter/GetCommandConverter.js +12 -11
  144. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  145. package/sync/handler/converter/PutCommandConverter.js +12 -11
  146. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  147. package/sync/handler/converter/QueryCommandConverter.js +12 -11
  148. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  149. package/sync/handler/converter/ScanCommandConverter.js +12 -11
  150. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  151. package/sync/handler/converter/UpdateCommandConverter.js +12 -11
  152. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  153. package/sync/handler/converter/commands/BatchWriteCommandValue.js +34 -37
  154. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  155. package/sync/handler/converter/commands/DeleteCommandValue.js +19 -16
  156. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  157. package/sync/handler/converter/commands/NullCommandValue.js +8 -8
  158. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  159. package/sync/handler/converter/commands/PutCommandValue.js +19 -16
  160. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  161. package/sync/handler/converter/commands/UpdateCommandValue.js +19 -16
  162. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  163. package/sync/handler/types.js +0 -3
  164. package/sync/plugins/FilterOutRecordPlugin.js +17 -19
  165. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  166. package/sync/types.js +0 -3
  167. package/sync/utils/getTableType.js +10 -9
  168. package/sync/utils/getTableType.js.map +1 -1
  169. package/sync/utils/manifest.d.ts +2 -6
  170. package/sync/utils/manifest.js +27 -36
  171. package/sync/utils/manifest.js.map +1 -1
  172. package/sync/utils/validateSystemInput.js +21 -29
  173. package/sync/utils/validateSystemInput.js.map +1 -1
  174. package/types.d.ts +0 -2
  175. package/types.js +6 -5
  176. package/types.js.map +1 -1
  177. package/utils/createSystemName.js +5 -3
  178. package/utils/createSystemName.js.map +1 -1
  179. package/worker/SyncWorkerConfig.d.ts +9 -0
  180. package/worker/SyncWorkerConfig.js +5 -0
  181. package/worker/SyncWorkerConfig.js.map +1 -0
  182. package/worker/SyncWorkerEventHandler.d.ts +14 -0
  183. package/worker/SyncWorkerEventHandler.js +5 -0
  184. package/worker/SyncWorkerEventHandler.js.map +1 -0
  185. package/worker/SyncWorkerEventType.d.ts +10 -0
  186. package/worker/SyncWorkerEventType.js +24 -0
  187. package/worker/SyncWorkerEventType.js.map +1 -0
  188. package/worker/SyncWorkerLambdaHandler.d.ts +13 -0
  189. package/worker/SyncWorkerLambdaHandler.js +61 -0
  190. package/worker/SyncWorkerLambdaHandler.js.map +1 -0
  191. package/worker/actions/copyFile/CopyFile.js +183 -258
  192. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  193. package/worker/actions/copyFile/copyFileAction.js +26 -34
  194. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  195. package/worker/actions/copyFile/copyFileSchema.js +13 -14
  196. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  197. package/worker/actions/copyFile/types.js +0 -3
  198. package/worker/actions/createUser/CreateUser.js +51 -74
  199. package/worker/actions/createUser/CreateUser.js.map +1 -1
  200. package/worker/actions/createUser/createUserAction.js +24 -28
  201. package/worker/actions/createUser/createUserAction.js.map +1 -1
  202. package/worker/actions/createUser/createUserSchema.js +13 -14
  203. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  204. package/worker/actions/createUser/types.js +0 -3
  205. package/worker/actions/deleteFile/DeleteFile.js +52 -67
  206. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  207. package/worker/actions/deleteFile/deleteFileAction.js +21 -29
  208. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  209. package/worker/actions/deleteFile/deleteFileSchema.js +13 -14
  210. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  211. package/worker/actions/deleteFile/types.js +0 -3
  212. package/worker/actions/deleteUser/DeleteUser.js +38 -52
  213. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  214. package/worker/actions/deleteUser/deleteUserAction.js +22 -26
  215. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  216. package/worker/actions/deleteUser/deleteUserSchema.js +12 -13
  217. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  218. package/worker/actions/deleteUser/types.js +0 -3
  219. package/worker/actions/logValidationError.js +5 -6
  220. package/worker/actions/logValidationError.js.map +1 -1
  221. package/worker/actions/removeCognitoUserAttributes.js +9 -15
  222. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  223. package/worker/actions/updateUser/UpdateUser.js +48 -65
  224. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  225. package/worker/actions/updateUser/types.js +0 -3
  226. package/worker/actions/updateUser/updateUserAction.js +24 -28
  227. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  228. package/worker/actions/updateUser/updateUserSchema.js +13 -14
  229. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  230. package/worker/handler/WorkerActionHandler.js +19 -21
  231. package/worker/handler/WorkerActionHandler.js.map +1 -1
  232. package/worker/plugins/WorkerActionPlugin.js +17 -16
  233. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  234. package/worker/types.js +0 -3
  235. package/index.js.map +0 -1
  236. package/resolver/app/abstractions/RecordHandler.js.map +0 -1
  237. package/resolver/app/abstractions/RecordsValidation.js.map +0 -1
  238. package/resolver/app/abstractions/ResolverApplication.js.map +0 -1
  239. package/resolver/app/abstractions/ResolverRecord.js.map +0 -1
  240. package/resolver/app/bundler/types.js.map +0 -1
  241. package/resolver/app/data/types.js.map +0 -1
  242. package/resolver/app/fetcher/types.js.map +0 -1
  243. package/resolver/app/ingestor/types.js.map +0 -1
  244. package/resolver/app/storer/types.js.map +0 -1
  245. package/resolver/createEventHandlerPlugin.d.ts +0 -11
  246. package/resolver/createEventHandlerPlugin.js +0 -120
  247. package/resolver/createEventHandlerPlugin.js.map +0 -1
  248. package/resolver/createResolverHandler.d.ts +0 -21
  249. package/resolver/createResolverHandler.js +0 -72
  250. package/resolver/createResolverHandler.js.map +0 -1
  251. package/resolver/deployment/types.js.map +0 -1
  252. package/resolver/recordTypes/fileManager/types.js.map +0 -1
  253. package/resolver/recordTypes/users/types.js.map +0 -1
  254. package/sync/createSendDataToEventBridgeOnRequestEnd.d.ts +0 -2
  255. package/sync/createSendDataToEventBridgeOnRequestEnd.js +0 -44
  256. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +0 -1
  257. package/sync/createSyncSystem.d.ts +0 -16
  258. package/sync/createSyncSystem.js +0 -35
  259. package/sync/createSyncSystem.js.map +0 -1
  260. package/sync/handler/types.js.map +0 -1
  261. package/sync/requestPlugin.d.ts +0 -9
  262. package/sync/requestPlugin.js +0 -58
  263. package/sync/requestPlugin.js.map +0 -1
  264. package/sync/types.js.map +0 -1
  265. package/worker/actions/copyFile/types.js.map +0 -1
  266. package/worker/actions/createUser/types.js.map +0 -1
  267. package/worker/actions/deleteFile/types.js.map +0 -1
  268. package/worker/actions/deleteUser/types.js.map +0 -1
  269. package/worker/actions/updateUser/types.js.map +0 -1
  270. package/worker/createWorkerHandler.d.ts +0 -11
  271. package/worker/createWorkerHandler.js +0 -41
  272. package/worker/createWorkerHandler.js.map +0 -1
  273. package/worker/handler/eventHandler.d.ts +0 -1
  274. package/worker/handler/eventHandler.js +0 -24
  275. package/worker/handler/eventHandler.js.map +0 -1
  276. package/worker/types.js.map +0 -1
@@ -1,17 +1,16 @@
1
1
  import zod from "zod";
2
- const createDataSchema = type => {
3
- return zod.object({
4
- userPoolId: zod.string().min(1, `${type} UserPoolId is required.`),
5
- region: zod.string().min(1, `${type} Region is required.`)
6
- });
7
- };
8
- export const createUpdateUserSchema = () => {
9
- return zod.object({
10
- action: zod.enum(["updateUser"]),
11
- username: zod.string().min(1, "Username is required."),
12
- source: createDataSchema("Source"),
13
- target: createDataSchema("Target")
14
- });
15
- };
2
+ const createDataSchema = (type)=>zod.object({
3
+ userPoolId: zod.string().min(1, `${type} UserPoolId is required.`),
4
+ region: zod.string().min(1, `${type} Region is required.`)
5
+ });
6
+ const createUpdateUserSchema = ()=>zod.object({
7
+ action: zod["enum"]([
8
+ "updateUser"
9
+ ]),
10
+ username: zod.string().min(1, "Username is required."),
11
+ source: createDataSchema("Source"),
12
+ target: createDataSchema("Target")
13
+ });
14
+ export { createUpdateUserSchema };
16
15
 
17
16
  //# sourceMappingURL=updateUserSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["zod","createDataSchema","type","object","userPoolId","string","min","region","createUpdateUserSchema","action","enum","username","source","target"],"sources":["updateUserSchema.ts"],"sourcesContent":["import zod from \"zod\";\n\nconst createDataSchema = (type: string) => {\n return zod.object({\n userPoolId: zod.string().min(1, `${type} UserPoolId is required.`),\n region: zod.string().min(1, `${type} Region is required.`)\n });\n};\nexport const createUpdateUserSchema = () => {\n return zod.object({\n action: zod.enum([\"updateUser\"]),\n username: zod.string().min(1, \"Username is required.\"),\n source: createDataSchema(\"Source\"),\n target: createDataSchema(\"Target\")\n });\n};\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,MAAMC,gBAAgB,GAAIC,IAAY,IAAK;EACvC,OAAOF,GAAG,CAACG,MAAM,CAAC;IACdC,UAAU,EAAEJ,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE,GAAGJ,IAAI,0BAA0B,CAAC;IAClEK,MAAM,EAAEP,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE,GAAGJ,IAAI,sBAAsB;EAC7D,CAAC,CAAC;AACN,CAAC;AACD,OAAO,MAAMM,sBAAsB,GAAGA,CAAA,KAAM;EACxC,OAAOR,GAAG,CAACG,MAAM,CAAC;IACdM,MAAM,EAAET,GAAG,CAACU,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IAChCC,QAAQ,EAAEX,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;IACtDM,MAAM,EAAEX,gBAAgB,CAAC,QAAQ,CAAC;IAClCY,MAAM,EAAEZ,gBAAgB,CAAC,QAAQ;EACrC,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"worker/actions/updateUser/updateUserSchema.js","sources":["../../../../src/worker/actions/updateUser/updateUserSchema.ts"],"sourcesContent":["import zod from \"zod\";\n\nconst createDataSchema = (type: string) => {\n return zod.object({\n userPoolId: zod.string().min(1, `${type} UserPoolId is required.`),\n region: zod.string().min(1, `${type} Region is required.`)\n });\n};\nexport const createUpdateUserSchema = () => {\n return zod.object({\n action: zod.enum([\"updateUser\"]),\n username: zod.string().min(1, \"Username is required.\"),\n source: createDataSchema(\"Source\"),\n target: createDataSchema(\"Target\")\n });\n};\n"],"names":["createDataSchema","type","zod","createUpdateUserSchema"],"mappings":";AAEA,MAAMA,mBAAmB,CAACC,OACfC,IAAI,MAAM,CAAC;QACd,YAAYA,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,GAAGD,KAAK,wBAAwB,CAAC;QACjE,QAAQC,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG,GAAGD,KAAK,oBAAoB,CAAC;IAC7D;AAEG,MAAME,yBAAyB,IAC3BD,IAAI,MAAM,CAAC;QACd,QAAQA,GAAG,CAAHA,OAAQ,CAAC;YAAC;SAAa;QAC/B,UAAUA,IAAI,MAAM,GAAG,GAAG,CAAC,GAAG;QAC9B,QAAQF,iBAAiB;QACzB,QAAQA,iBAAiB;IAC7B"}
@@ -1,26 +1,24 @@
1
1
  import { WebinyError } from "@webiny/error";
2
- export class WorkerActionHandler {
3
- constructor(params) {
4
- this.plugins = params.plugins;
5
- }
6
- async handle(payload) {
7
- for (const plugin of this.plugins) {
8
- const data = plugin.parse(payload);
9
- if (!data) {
10
- continue;
11
- }
12
- return await plugin.handle({
13
- data
14
- });
2
+ class WorkerActionHandler {
3
+ constructor(params){
4
+ this.plugins = params.plugins;
5
+ }
6
+ async handle(payload) {
7
+ for (const plugin of this.plugins){
8
+ const data = plugin.parse(payload);
9
+ if (data) return await plugin.handle({
10
+ data
11
+ });
12
+ }
13
+ throw new WebinyError({
14
+ message: "Unsupported action on payload.",
15
+ code: "UNSUPPORTED_ACTION",
16
+ data: {
17
+ payload
18
+ }
19
+ });
15
20
  }
16
- throw new WebinyError({
17
- message: "Unsupported action on payload.",
18
- code: "UNSUPPORTED_ACTION",
19
- data: {
20
- payload
21
- }
22
- });
23
- }
24
21
  }
22
+ export { WorkerActionHandler };
25
23
 
26
24
  //# sourceMappingURL=WorkerActionHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","WorkerActionHandler","constructor","params","plugins","handle","payload","plugin","data","parse","message","code"],"sources":["WorkerActionHandler.ts"],"sourcesContent":["import type { IActionHandler } from \"~/worker/types.js\";\nimport type { WorkerActionPlugin } from \"~/worker/plugins/WorkerActionPlugin.js\";\nimport { WebinyError } from \"@webiny/error\";\n\nexport interface IActionHandlerParams {\n plugins: WorkerActionPlugin[];\n}\n\nexport class WorkerActionHandler implements IActionHandler {\n private readonly plugins: WorkerActionPlugin[];\n\n public constructor(params: IActionHandlerParams) {\n this.plugins = params.plugins;\n }\n\n public async handle(payload: unknown): Promise<void> {\n for (const plugin of this.plugins) {\n const data = plugin.parse(payload);\n if (!data) {\n continue;\n }\n return await plugin.handle({\n data\n });\n }\n throw new WebinyError({\n message: \"Unsupported action on payload.\",\n code: \"UNSUPPORTED_ACTION\",\n data: {\n payload\n }\n });\n }\n}\n"],"mappings":"AAEA,SAASA,WAAW,QAAQ,eAAe;AAM3C,OAAO,MAAMC,mBAAmB,CAA2B;EAGhDC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;EACjC;EAEA,MAAaC,MAAMA,CAACC,OAAgB,EAAiB;IACjD,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;MAC/B,MAAMI,IAAI,GAAGD,MAAM,CAACE,KAAK,CAACH,OAAO,CAAC;MAClC,IAAI,CAACE,IAAI,EAAE;QACP;MACJ;MACA,OAAO,MAAMD,MAAM,CAACF,MAAM,CAAC;QACvBG;MACJ,CAAC,CAAC;IACN;IACA,MAAM,IAAIR,WAAW,CAAC;MAClBU,OAAO,EAAE,gCAAgC;MACzCC,IAAI,EAAE,oBAAoB;MAC1BH,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"worker/handler/WorkerActionHandler.js","sources":["../../../src/worker/handler/WorkerActionHandler.ts"],"sourcesContent":["import type { IActionHandler } from \"~/worker/types.js\";\nimport type { WorkerActionPlugin } from \"~/worker/plugins/WorkerActionPlugin.js\";\nimport { WebinyError } from \"@webiny/error\";\n\nexport interface IActionHandlerParams {\n plugins: WorkerActionPlugin[];\n}\n\nexport class WorkerActionHandler implements IActionHandler {\n private readonly plugins: WorkerActionPlugin[];\n\n public constructor(params: IActionHandlerParams) {\n this.plugins = params.plugins;\n }\n\n public async handle(payload: unknown): Promise<void> {\n for (const plugin of this.plugins) {\n const data = plugin.parse(payload);\n if (!data) {\n continue;\n }\n return await plugin.handle({\n data\n });\n }\n throw new WebinyError({\n message: \"Unsupported action on payload.\",\n code: \"UNSUPPORTED_ACTION\",\n data: {\n payload\n }\n });\n }\n}\n"],"names":["WorkerActionHandler","params","payload","plugin","data","WebinyError"],"mappings":";AAQO,MAAMA;IAGT,YAAmBC,MAA4B,CAAE;QAC7C,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;IACjC;IAEA,MAAa,OAAOC,OAAgB,EAAiB;QACjD,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAAE;YAC/B,MAAMC,OAAOD,OAAO,KAAK,CAACD;YAC1B,IAAKE,MAGL,OAAO,MAAMD,OAAO,MAAM,CAAC;gBACvBC;YACJ;QACJ;QACA,MAAM,IAAIC,YAAY;YAClB,SAAS;YACT,MAAM;YACN,MAAM;gBACFH;YACJ;QACJ;IACJ;AACJ"}
@@ -1,20 +1,21 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin.js";
2
- export class WorkerActionPlugin extends Plugin {
3
- static type = "sync.worker.action";
4
- constructor(action) {
5
- super();
6
- this.name = action.name;
7
- this.action = action;
8
- }
9
- parse(input) {
10
- return this.action.parse(input);
11
- }
12
- handle(params) {
13
- return this.action.handle(params);
14
- }
2
+ class WorkerActionPlugin extends Plugin {
3
+ static{
4
+ this.type = "sync.worker.action";
5
+ }
6
+ constructor(action){
7
+ super();
8
+ this.name = action.name;
9
+ this.action = action;
10
+ }
11
+ parse(input) {
12
+ return this.action.parse(input);
13
+ }
14
+ handle(params) {
15
+ return this.action.handle(params);
16
+ }
15
17
  }
16
- export const createWorkerActionPlugin = action => {
17
- return new WorkerActionPlugin(action);
18
- };
18
+ const createWorkerActionPlugin = (action)=>new WorkerActionPlugin(action);
19
+ export { WorkerActionPlugin, createWorkerActionPlugin };
19
20
 
20
21
  //# sourceMappingURL=WorkerActionPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","WorkerActionPlugin","type","constructor","action","name","parse","input","handle","params","createWorkerActionPlugin"],"sources":["WorkerActionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { IWorkerAction, IWorkerActionHandleParams } from \"../types.js\";\n\nexport class WorkerActionPlugin<T = unknown> extends Plugin {\n public static override readonly type: string = \"sync.worker.action\";\n\n private readonly action: IWorkerAction<T>;\n\n public constructor(action: IWorkerAction<T>) {\n super();\n this.name = action.name;\n this.action = action;\n }\n\n public parse(input: unknown): T | undefined {\n return this.action.parse(input);\n }\n\n public handle(params: IWorkerActionHandleParams<T>): Promise<void> {\n return this.action.handle(params);\n }\n}\n\nexport const createWorkerActionPlugin = <T>(action: IWorkerAction<T>): WorkerActionPlugin<T> => {\n return new WorkerActionPlugin<T>(action);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAGlD,OAAO,MAAMC,kBAAkB,SAAsBD,MAAM,CAAC;EACxD,OAAgCE,IAAI,GAAW,oBAAoB;EAI5DC,WAAWA,CAACC,MAAwB,EAAE;IACzC,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACvB,IAAI,CAACD,MAAM,GAAGA,MAAM;EACxB;EAEOE,KAAKA,CAACC,KAAc,EAAiB;IACxC,OAAO,IAAI,CAACH,MAAM,CAACE,KAAK,CAACC,KAAK,CAAC;EACnC;EAEOC,MAAMA,CAACC,MAAoC,EAAiB;IAC/D,OAAO,IAAI,CAACL,MAAM,CAACI,MAAM,CAACC,MAAM,CAAC;EACrC;AACJ;AAEA,OAAO,MAAMC,wBAAwB,GAAON,MAAwB,IAA4B;EAC5F,OAAO,IAAIH,kBAAkB,CAAIG,MAAM,CAAC;AAC5C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"worker/plugins/WorkerActionPlugin.js","sources":["../../../src/worker/plugins/WorkerActionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { IWorkerAction, IWorkerActionHandleParams } from \"../types.js\";\n\nexport class WorkerActionPlugin<T = unknown> extends Plugin {\n public static override readonly type: string = \"sync.worker.action\";\n\n private readonly action: IWorkerAction<T>;\n\n public constructor(action: IWorkerAction<T>) {\n super();\n this.name = action.name;\n this.action = action;\n }\n\n public parse(input: unknown): T | undefined {\n return this.action.parse(input);\n }\n\n public handle(params: IWorkerActionHandleParams<T>): Promise<void> {\n return this.action.handle(params);\n }\n}\n\nexport const createWorkerActionPlugin = <T>(action: IWorkerAction<T>): WorkerActionPlugin<T> => {\n return new WorkerActionPlugin<T>(action);\n};\n"],"names":["WorkerActionPlugin","Plugin","action","input","params","createWorkerActionPlugin"],"mappings":";AAGO,MAAMA,2BAAwCC;;aACjB,IAAI,GAAW;;IAI/C,YAAmBC,MAAwB,CAAE;QACzC,KAAK;QACL,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEO,MAAMC,KAAc,EAAiB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAACA;IAC7B;IAEO,OAAOC,MAAoC,EAAiB;QAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAACA;IAC9B;AACJ;AAEO,MAAMC,2BAA2B,CAAIH,SACjC,IAAIF,mBAAsBE"}
package/worker/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./worker/createWorkerHandler.js\";\nexport * from \"./sync/createSyncSystem.js\";\nexport * from \"./resolver/createResolverHandler.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["RecordHandler.ts"],"sourcesContent":["import type { IIngestorResult } from \"~/resolver/app/ingestor/types.js\";\n\nexport interface IRecordHandlerHandleParams {\n data: IIngestorResult;\n}\n\nexport interface IRecordHandler {\n handle(params: IRecordHandlerHandleParams): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["RecordsValidation.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport type { IResolverSQSRecord } from \"~/resolver/app/abstractions/ResolverRecord.js\";\n\nexport interface IRecordsValidationValid {\n records: IResolverSQSRecord[];\n error?: never;\n}\n\nexport interface IRecordsValidationError {\n records?: never;\n error: Error;\n}\n\nexport type IRecordsValidationResult = IRecordsValidationValid | IRecordsValidationError;\n\nexport interface IRecordsValidation {\n validate(records: SQSRecord[]): Promise<IRecordsValidationResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["ResolverApplication.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types/index.js\";\n\nexport interface IResolverApplicationResolveParams {\n records: SQSRecord[];\n}\n\nexport interface IResolverApplication {\n resolve(params: IResolverApplicationResolveParams): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["ResolverRecord.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IDetail } from \"~/sync/handler/types.js\";\nimport type { DynamoDBTableType, ExtendedCommandType } from \"~/types.js\";\nimport type { SQS_EVENT_NAME } from \"~/constants.js\";\n\nexport interface IResolverRecordBodyItem {\n PK: string;\n SK: string;\n command: ExtendedCommandType;\n /**\n * There will be multiple tables that will get populated through the system (regular table and opensearch for start).\n */\n tableName: string;\n tableType: DynamoDBTableType;\n}\n\nexport interface IResolverSQSRecordBody {\n version: `${number}`;\n id: string;\n \"detail-type\": typeof SQS_EVENT_NAME;\n source: `webiny:${string}`;\n account: `${number}`;\n time: Date;\n region: string;\n resources: unknown[];\n detail: IDetail;\n}\n\nexport interface IResolverSQSRecordAttributes {\n ApproximateReceiveCount: string;\n SentTimestamp: string;\n SenderId: string;\n ApproximateFirstReceiveTimestamp: string;\n}\n\nexport interface IResolverSQSRecord {\n messageId: string;\n receiptHandle: string;\n body: IResolverSQSRecordBody;\n attributes: IResolverSQSRecordAttributes;\n messageAttributes?: GenericRecord;\n md5OfBody: string;\n eventSource: string;\n eventSourceARN: string;\n awsRegion: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IIngestorResultItem } from \"~/resolver/app/ingestor/types.js\";\nimport type { CommandType } from \"~/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\n\nexport interface IBundleItem {\n PK: string;\n SK: string;\n}\n\nexport interface IBundle {\n readonly items: IBundleItem[];\n readonly command: CommandType;\n readonly table: ITable;\n readonly source: IDeployment;\n canAdd(item: IIngestorResultItem): boolean;\n add(item: IIngestorResultItem): void;\n}\n\nexport interface IBundlerBundleParams {\n items: IIngestorResultItem[];\n}\n\nexport interface IBundler {\n bundle(params: IBundlerBundleParams): IBundles;\n}\n\nexport interface IBundlesAddParams {\n item: IIngestorResultItem;\n}\n\nexport interface IBundles {\n add(params: IBundlesAddParams): void;\n getBundles(): IBundle[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\n\nexport interface IInputItem {\n PK: string;\n SK: string;\n table: Pick<ITable, \"name\">;\n source: Pick<IDeployment, \"name\">;\n}\n\nexport interface IItem {\n PK: string;\n SK: string;\n table: Pick<ITable, \"name\">;\n source: Pick<IDeployment, \"name\">;\n data: IStoreItem | null;\n}\n\nexport interface ISourceDataContainer {\n items: GenericRecord<string, IItem>;\n get(item: IInputItem): IStoreItem | null;\n add(item: IInputItem, data: IStoreItem | null): void;\n merge(container: ISourceDataContainer): void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { ISourceDataContainer } from \"~/resolver/app/data/types.js\";\n\nexport interface IFetcherExecParamsItem {\n PK: string;\n SK: string;\n}\n\nexport interface IFetcherExecParams {\n maxBatchSize?: number;\n deployment: IDeployment;\n table: ITable;\n items: IFetcherExecParamsItem[];\n}\n\nexport interface IFetcherExecValidResult {\n error?: never;\n items: ISourceDataContainer;\n}\n\nexport interface IFetcherExecErrorResult {\n error: Error;\n items?: never;\n}\n\nexport type IFetcherExecResult = IFetcherExecValidResult | IFetcherExecErrorResult;\n\nexport interface IFetcher {\n exec(params: IFetcherExecParams): Promise<IFetcherExecResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CommandType } from \"~/types.js\";\nimport type { IResolverSQSRecord } from \"~/resolver/app/abstractions/ResolverRecord.js\";\nimport type { IDetailItem } from \"~/sync/handler/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\n\nexport interface IIngestorIngestParams {\n records: IResolverSQSRecord[];\n}\n\nexport interface IIngestorResultItem {\n PK: string;\n SK: string;\n command: CommandType;\n table: ITable;\n source: IDeployment;\n}\n\nexport interface IIngestorResultAddParams {\n item: IDetailItem;\n source: IDeployment;\n}\n\nexport interface IIngestorResult {\n getItems(): IIngestorResultItem[];\n add(params: IIngestorResultAddParams): void;\n}\n\nexport interface IIngestor {\n ingest(params: IIngestorIngestParams): Promise<IIngestorResult>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { CommandType } from \"~/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IBundle } from \"../bundler/types.js\";\n\nexport type StoreItemPossibleValues =\n | string\n | number\n | boolean\n | undefined\n | null\n | GenericRecord\n | StoreItemPossibleValues[];\n\nexport interface IStoreItem {\n PK: string;\n SK: string;\n [key: string]: StoreItemPossibleValues;\n}\n\nexport interface IStorerExecParams {\n deployment: IDeployment;\n bundle: IBundle;\n command: CommandType;\n table: ITable;\n items: IStoreItem[];\n}\n\nexport interface IStorer {\n store(params: IStorerExecParams): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import type { DynamoDBClientConfig, DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
- import type { Reply as FastifyReply } from "@webiny/handler/types.js";
3
- import { SQSEventHandler } from "@webiny/handler-aws/sqs/plugins/SQSEventHandler.js";
4
- export interface ICreateEventHandlerPluginParams {
5
- tableName: string | undefined;
6
- createDocumentClient: (params: DynamoDBClientConfig) => Pick<DynamoDBDocument, "send">;
7
- }
8
- /**
9
- * TODO maybe add logger?
10
- */
11
- export declare const createEventHandlerPlugin: (params: ICreateEventHandlerPluginParams) => SQSEventHandler<FastifyReply>;
@@ -1,120 +0,0 @@
1
- import { createEventHandler as createSQSEventHandler } from "@webiny/handler-aws/sqs/index.js";
2
- import { createResolverApp } from "./app/ResolverApplication.js";
3
- import { convertException } from "@webiny/utils";
4
- import { createRecordHandler } from "./app/RecordHandler.js";
5
- import { createFetcher } from "./app/fetcher/Fetcher.js";
6
- import { createDeploymentsFetcher } from "./deployment/DeploymentsFetcher.js";
7
- import { WebinyError } from "@webiny/error";
8
- import { createBundler } from "./app/bundler/Bundler.js";
9
- import { createBundles } from "./app/bundler/Bundles.js";
10
- import { createCommandBundle } from "./app/bundler/CommandBundle.js";
11
- import { createTableBundle } from "./app/bundler/TableBundle.js";
12
- import { TransformHandler } from "./app/transform/TransformHandler.js";
13
- import { SQSEventHandler } from "@webiny/handler-aws/sqs/plugins/SQSEventHandler.js";
14
- import { createStorer } from "./app/storer/Storer.js";
15
- import { StorerAfterEachPlugin } from "./plugins/StorerAfterEachPlugin.js";
16
- import { SourceDataContainer } from "./app/data/SourceDataContainer.js";
17
- /**
18
- * TODO maybe add logger?
19
- */
20
- export const createEventHandlerPlugin = params => {
21
- const {
22
- createDocumentClient,
23
- tableName
24
- } = params;
25
- const plugin = createSQSEventHandler(async ({
26
- event,
27
- context,
28
- reply
29
- }) => {
30
- if (!tableName) {
31
- throw new WebinyError({
32
- message: "Table name variable is not set."
33
- });
34
- }
35
- try {
36
- const fetcher = createFetcher({
37
- maxRetries: 10,
38
- retryDelay: 1000,
39
- createDocumentClient: deployment => {
40
- return createDocumentClient({
41
- region: deployment.region
42
- });
43
- }
44
- });
45
- const deploymentsFetcher = createDeploymentsFetcher({
46
- client: createDocumentClient({
47
- region: process.env.AWS_REGION
48
- }),
49
- table: tableName
50
- });
51
- /**
52
- * Fetch all possible deployments, out of which we will filter out the deployment that the records came from.
53
- */
54
- const deployments = await deploymentsFetcher.fetch();
55
- const storerAfterEachPlugins = context.plugins.byType(StorerAfterEachPlugin.type);
56
- const storer = createStorer({
57
- createDocumentClient: deployment => {
58
- return createDocumentClient({
59
- region: deployment.region
60
- });
61
- },
62
- afterEach: async params => {
63
- for (const plugin of storerAfterEachPlugins) {
64
- if (!plugin.canHandle(params)) {
65
- continue;
66
- }
67
- await plugin.handle(params);
68
- }
69
- }
70
- });
71
- const transformHandler = new TransformHandler({
72
- plugins: context.plugins
73
- });
74
- const recordHandler = createRecordHandler({
75
- plugins: context.plugins,
76
- fetcher,
77
- storer,
78
- deployments,
79
- transformHandler,
80
- commandBundler: createBundler({
81
- createBundles: () => {
82
- return createBundles({
83
- createBundle: createCommandBundle
84
- });
85
- }
86
- }),
87
- tableBundler: createBundler({
88
- createBundles: () => {
89
- return createBundles({
90
- createBundle: createTableBundle
91
- });
92
- }
93
- }),
94
- createSourceDataContainer: () => {
95
- return SourceDataContainer.create();
96
- }
97
- });
98
- const app = createResolverApp({
99
- recordHandler,
100
- deployments
101
- });
102
- await app.resolve({
103
- records: event.Records
104
- });
105
- return reply.send({
106
- ok: true
107
- });
108
- } catch (ex) {
109
- const error = convertException(ex);
110
- console.error(error);
111
- return reply.send({
112
- error
113
- });
114
- }
115
- });
116
- plugin.name = `${SQSEventHandler.type}.syncResolver`;
117
- return plugin;
118
- };
119
-
120
- //# sourceMappingURL=createEventHandlerPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createEventHandler","createSQSEventHandler","createResolverApp","convertException","createRecordHandler","createFetcher","createDeploymentsFetcher","WebinyError","createBundler","createBundles","createCommandBundle","createTableBundle","TransformHandler","SQSEventHandler","createStorer","StorerAfterEachPlugin","SourceDataContainer","createEventHandlerPlugin","params","createDocumentClient","tableName","plugin","event","context","reply","message","fetcher","maxRetries","retryDelay","deployment","region","deploymentsFetcher","client","process","env","AWS_REGION","table","deployments","fetch","storerAfterEachPlugins","plugins","byType","type","storer","afterEach","canHandle","handle","transformHandler","recordHandler","commandBundler","createBundle","tableBundler","createSourceDataContainer","create","app","resolve","records","Records","send","ok","ex","error","console","name"],"sources":["createEventHandlerPlugin.ts"],"sourcesContent":["import { createEventHandler as createSQSEventHandler } from \"@webiny/handler-aws/sqs/index.js\";\nimport { createResolverApp } from \"./app/ResolverApplication.js\";\nimport { convertException } from \"@webiny/utils\";\nimport { createRecordHandler } from \"./app/RecordHandler.js\";\nimport { createFetcher } from \"~/resolver/app/fetcher/Fetcher.js\";\nimport { createDeploymentsFetcher } from \"~/resolver/deployment/DeploymentsFetcher.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n DynamoDBClientConfig,\n DynamoDBDocument\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createBundler } from \"~/resolver/app/bundler/Bundler.js\";\nimport { createBundles } from \"~/resolver/app/bundler/Bundles.js\";\nimport { createCommandBundle } from \"~/resolver/app/bundler/CommandBundle.js\";\nimport { createTableBundle } from \"~/resolver/app/bundler/TableBundle.js\";\nimport { TransformHandler } from \"~/resolver/app/transform/TransformHandler.js\";\nimport type { Reply as FastifyReply } from \"@webiny/handler/types.js\";\nimport { SQSEventHandler } from \"@webiny/handler-aws/sqs/plugins/SQSEventHandler.js\";\nimport { createStorer } from \"./app/storer/Storer.js\";\nimport { StorerAfterEachPlugin } from \"./plugins/StorerAfterEachPlugin.js\";\nimport { SourceDataContainer } from \"~/resolver/app/data/SourceDataContainer.js\";\n\nexport interface ICreateEventHandlerPluginParams {\n tableName: string | undefined;\n createDocumentClient: (params: DynamoDBClientConfig) => Pick<DynamoDBDocument, \"send\">;\n}\n/**\n * TODO maybe add logger?\n */\nexport const createEventHandlerPlugin = (params: ICreateEventHandlerPluginParams) => {\n const { createDocumentClient, tableName } = params;\n\n const plugin = createSQSEventHandler(\n async ({ event, context, reply }): Promise<FastifyReply> => {\n if (!tableName) {\n throw new WebinyError({\n message: \"Table name variable is not set.\"\n });\n }\n try {\n const fetcher = createFetcher({\n maxRetries: 10,\n retryDelay: 1000,\n createDocumentClient: deployment => {\n return createDocumentClient({\n region: deployment.region\n });\n }\n });\n\n const deploymentsFetcher = createDeploymentsFetcher({\n client: createDocumentClient({\n region: process.env.AWS_REGION\n }),\n table: tableName\n });\n /**\n * Fetch all possible deployments, out of which we will filter out the deployment that the records came from.\n */\n const deployments = await deploymentsFetcher.fetch();\n\n const storerAfterEachPlugins = context.plugins.byType<StorerAfterEachPlugin>(\n StorerAfterEachPlugin.type\n );\n\n const storer = createStorer({\n createDocumentClient: deployment => {\n return createDocumentClient({\n region: deployment.region\n });\n },\n afterEach: async params => {\n for (const plugin of storerAfterEachPlugins) {\n if (!plugin.canHandle(params)) {\n continue;\n }\n await plugin.handle(params);\n }\n }\n });\n\n const transformHandler = new TransformHandler({\n plugins: context.plugins\n });\n\n const recordHandler = createRecordHandler({\n plugins: context.plugins,\n fetcher,\n storer,\n deployments,\n transformHandler,\n commandBundler: createBundler({\n createBundles: () => {\n return createBundles({\n createBundle: createCommandBundle\n });\n }\n }),\n tableBundler: createBundler({\n createBundles: () => {\n return createBundles({\n createBundle: createTableBundle\n });\n }\n }),\n createSourceDataContainer: () => {\n return SourceDataContainer.create();\n }\n });\n const app = createResolverApp({\n recordHandler,\n deployments\n });\n\n await app.resolve({\n records: event.Records\n });\n return reply.send({\n ok: true\n });\n } catch (ex) {\n const error = convertException(ex);\n console.error(error);\n return reply.send({\n error\n });\n }\n }\n );\n\n plugin.name = `${SQSEventHandler.type}.syncResolver`;\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,kBAAkB,IAAIC,qBAAqB,QAAQ,kCAAkC;AAC9F,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AACtB,SAASC,wBAAwB;AACjC,SAASC,WAAW,QAAQ,eAAe;AAK3C,SAASC,aAAa;AACtB,SAASC,aAAa;AACtB,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AAEzB,SAASC,eAAe,QAAQ,oDAAoD;AACpF,SAASC,YAAY;AACrB,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB;AAM5B;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAIC,MAAuC,IAAK;EACjF,MAAM;IAAEC,oBAAoB;IAAEC;EAAU,CAAC,GAAGF,MAAM;EAElD,MAAMG,MAAM,GAAGpB,qBAAqB,CAChC,OAAO;IAAEqB,KAAK;IAAEC,OAAO;IAAEC;EAAM,CAAC,KAA4B;IACxD,IAAI,CAACJ,SAAS,EAAE;MACZ,MAAM,IAAIb,WAAW,CAAC;QAClBkB,OAAO,EAAE;MACb,CAAC,CAAC;IACN;IACA,IAAI;MACA,MAAMC,OAAO,GAAGrB,aAAa,CAAC;QAC1BsB,UAAU,EAAE,EAAE;QACdC,UAAU,EAAE,IAAI;QAChBT,oBAAoB,EAAEU,UAAU,IAAI;UAChC,OAAOV,oBAAoB,CAAC;YACxBW,MAAM,EAAED,UAAU,CAACC;UACvB,CAAC,CAAC;QACN;MACJ,CAAC,CAAC;MAEF,MAAMC,kBAAkB,GAAGzB,wBAAwB,CAAC;QAChD0B,MAAM,EAAEb,oBAAoB,CAAC;UACzBW,MAAM,EAAEG,OAAO,CAACC,GAAG,CAACC;QACxB,CAAC,CAAC;QACFC,KAAK,EAAEhB;MACX,CAAC,CAAC;MACF;AAChB;AACA;MACgB,MAAMiB,WAAW,GAAG,MAAMN,kBAAkB,CAACO,KAAK,CAAC,CAAC;MAEpD,MAAMC,sBAAsB,GAAGhB,OAAO,CAACiB,OAAO,CAACC,MAAM,CACjD1B,qBAAqB,CAAC2B,IAC1B,CAAC;MAED,MAAMC,MAAM,GAAG7B,YAAY,CAAC;QACxBK,oBAAoB,EAAEU,UAAU,IAAI;UAChC,OAAOV,oBAAoB,CAAC;YACxBW,MAAM,EAAED,UAAU,CAACC;UACvB,CAAC,CAAC;QACN,CAAC;QACDc,SAAS,EAAE,MAAM1B,MAAM,IAAI;UACvB,KAAK,MAAMG,MAAM,IAAIkB,sBAAsB,EAAE;YACzC,IAAI,CAAClB,MAAM,CAACwB,SAAS,CAAC3B,MAAM,CAAC,EAAE;cAC3B;YACJ;YACA,MAAMG,MAAM,CAACyB,MAAM,CAAC5B,MAAM,CAAC;UAC/B;QACJ;MACJ,CAAC,CAAC;MAEF,MAAM6B,gBAAgB,GAAG,IAAInC,gBAAgB,CAAC;QAC1C4B,OAAO,EAAEjB,OAAO,CAACiB;MACrB,CAAC,CAAC;MAEF,MAAMQ,aAAa,GAAG5C,mBAAmB,CAAC;QACtCoC,OAAO,EAAEjB,OAAO,CAACiB,OAAO;QACxBd,OAAO;QACPiB,MAAM;QACNN,WAAW;QACXU,gBAAgB;QAChBE,cAAc,EAAEzC,aAAa,CAAC;UAC1BC,aAAa,EAAEA,CAAA,KAAM;YACjB,OAAOA,aAAa,CAAC;cACjByC,YAAY,EAAExC;YAClB,CAAC,CAAC;UACN;QACJ,CAAC,CAAC;QACFyC,YAAY,EAAE3C,aAAa,CAAC;UACxBC,aAAa,EAAEA,CAAA,KAAM;YACjB,OAAOA,aAAa,CAAC;cACjByC,YAAY,EAAEvC;YAClB,CAAC,CAAC;UACN;QACJ,CAAC,CAAC;QACFyC,yBAAyB,EAAEA,CAAA,KAAM;UAC7B,OAAOpC,mBAAmB,CAACqC,MAAM,CAAC,CAAC;QACvC;MACJ,CAAC,CAAC;MACF,MAAMC,GAAG,GAAGpD,iBAAiB,CAAC;QAC1B8C,aAAa;QACbX;MACJ,CAAC,CAAC;MAEF,MAAMiB,GAAG,CAACC,OAAO,CAAC;QACdC,OAAO,EAAElC,KAAK,CAACmC;MACnB,CAAC,CAAC;MACF,OAAOjC,KAAK,CAACkC,IAAI,CAAC;QACdC,EAAE,EAAE;MACR,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT,MAAMC,KAAK,GAAG1D,gBAAgB,CAACyD,EAAE,CAAC;MAClCE,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;MACpB,OAAOrC,KAAK,CAACkC,IAAI,CAAC;QACdG;MACJ,CAAC,CAAC;IACN;EACJ,CACJ,CAAC;EAEDxC,MAAM,CAAC0C,IAAI,GAAG,GAAGlD,eAAe,CAAC6B,IAAI,eAAe;EAEpD,OAAOrB,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- import type { HandlerCallable, HandlerParams } from "@webiny/handler-aws/sqs/index.js";
2
- import type { TransformRecordPlugin } from "./plugins/TransformRecordPlugin.js";
3
- import type { CommandHandlerPlugin } from "./plugins/CommandHandlerPlugin.js";
4
- import type { DynamoDBClientConfig, DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
5
- import type { LambdaClient, LambdaClientConfig } from "@webiny/aws-sdk/client-lambda/index.js";
6
- import type { S3Client, S3ClientConfig } from "@webiny/aws-sdk/client-s3/index.js";
7
- import type { CognitoIdentityProviderClient, CognitoIdentityProviderClientConfig } from "@webiny/aws-sdk/client-cognito-identity-provider/index.js";
8
- export type AllowedResolverPlugins = TransformRecordPlugin | CommandHandlerPlugin;
9
- export interface ICreateResolverHandlerParams extends HandlerParams {
10
- plugins: AllowedResolverPlugins[];
11
- createS3Client: (params: S3ClientConfig) => Pick<S3Client, "send">;
12
- createLambdaClient: (config: Partial<LambdaClientConfig>) => Pick<LambdaClient, "send">;
13
- createDocumentClient: (params: Partial<DynamoDBClientConfig>) => Pick<DynamoDBDocument, "send">;
14
- createCognitoIdentityProviderClient: (config: Partial<CognitoIdentityProviderClientConfig>) => Pick<CognitoIdentityProviderClient, "send">;
15
- tableName?: string;
16
- awsWorkerLambdaArn?: string;
17
- }
18
- /**
19
- * Handler for the Sync System Resolver - based on SQS handler.
20
- */
21
- export declare const createResolverHandler: (params: ICreateResolverHandlerParams) => HandlerCallable;
@@ -1,72 +0,0 @@
1
- import { createHandler as createSQSHandler } from "@webiny/handler-aws/sqs/index.js";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { createEventHandlerPlugin } from "./createEventHandlerPlugin.js";
4
- import { createPutCommandHandlerPlugin } from "./app/commandHandler/put.js";
5
- import { createDeleteCommandHandlerPlugin } from "./app/commandHandler/delete.js";
6
- import { createFileManagerPlugins } from "./recordTypes/fileManager/fileManager.js";
7
- import { LambdaTrigger } from "./lambda/LambdaTrigger.js";
8
- import { CopyFile } from "./recordTypes/fileManager/CopyFile.js";
9
- import { DeleteFile } from "./recordTypes/fileManager/DeleteFile.js";
10
- import { createUsersPlugins } from "./recordTypes/users/users.js";
11
- import { CopyUser } from "./recordTypes/users/CopyUser.js";
12
- import { DeleteUser } from "./recordTypes/users/DeleteUser.js";
13
- /**
14
- * Handler for the Sync System Resolver - based on SQS handler.
15
- */
16
- export const createResolverHandler = params => {
17
- const awsWorkerLambdaArn = params.awsWorkerLambdaArn || process.env.AWS_SYNC_WORKER_LAMBDA_ARN;
18
- if (!awsWorkerLambdaArn) {
19
- const message = `Missing "process.env.AWS_SYNC_WORKER_LAMBDA_ARN".`;
20
- console.error(message);
21
- throw new Error(message);
22
- }
23
- const lambdaTrigger = new LambdaTrigger({
24
- arn: awsWorkerLambdaArn,
25
- createLambdaClient: params.createLambdaClient
26
- });
27
- const copyFile = new CopyFile({
28
- createS3Client: params.createS3Client,
29
- getLambdaTrigger: () => {
30
- return lambdaTrigger;
31
- }
32
- });
33
- const deleteFile = new DeleteFile({
34
- createS3Client: params.createS3Client,
35
- getLambdaTrigger: () => {
36
- return lambdaTrigger;
37
- }
38
- });
39
- const copyUser = new CopyUser({
40
- createCognitoIdentityProviderClient: params.createCognitoIdentityProviderClient,
41
- getLambdaTrigger: () => {
42
- return lambdaTrigger;
43
- }
44
- });
45
- const deleteUser = new DeleteUser({
46
- createCognitoIdentityProviderClient: params.createCognitoIdentityProviderClient,
47
- getLambdaTrigger: () => {
48
- return lambdaTrigger;
49
- }
50
- });
51
- const plugins = new PluginsContainer([
52
- // TODO move into related packages
53
- createFileManagerPlugins({
54
- copyFile,
55
- deleteFile
56
- }), createUsersPlugins({
57
- copyUser,
58
- deleteUser
59
- }),
60
- // leave here
61
- createEventHandlerPlugin({
62
- createDocumentClient: params.createDocumentClient,
63
- tableName: params.tableName || process.env.DB_TABLE
64
- }), createPutCommandHandlerPlugin(), createDeleteCommandHandlerPlugin()]);
65
- plugins.register(params.plugins);
66
- return createSQSHandler({
67
- ...params,
68
- plugins
69
- });
70
- };
71
-
72
- //# sourceMappingURL=createResolverHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createHandler","createSQSHandler","PluginsContainer","createEventHandlerPlugin","createPutCommandHandlerPlugin","createDeleteCommandHandlerPlugin","createFileManagerPlugins","LambdaTrigger","CopyFile","DeleteFile","createUsersPlugins","CopyUser","DeleteUser","createResolverHandler","params","awsWorkerLambdaArn","process","env","AWS_SYNC_WORKER_LAMBDA_ARN","message","console","error","Error","lambdaTrigger","arn","createLambdaClient","copyFile","createS3Client","getLambdaTrigger","deleteFile","copyUser","createCognitoIdentityProviderClient","deleteUser","plugins","createDocumentClient","tableName","DB_TABLE","register"],"sources":["createResolverHandler.ts"],"sourcesContent":["import type { HandlerCallable, HandlerParams } from \"@webiny/handler-aws/sqs/index.js\";\nimport { createHandler as createSQSHandler } from \"@webiny/handler-aws/sqs/index.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createEventHandlerPlugin } from \"./createEventHandlerPlugin.js\";\nimport type { TransformRecordPlugin } from \"./plugins/TransformRecordPlugin.js\";\nimport type { CommandHandlerPlugin } from \"./plugins/CommandHandlerPlugin.js\";\nimport { createPutCommandHandlerPlugin } from \"./app/commandHandler/put.js\";\nimport { createDeleteCommandHandlerPlugin } from \"./app/commandHandler/delete.js\";\nimport type {\n DynamoDBClientConfig,\n DynamoDBDocument\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createFileManagerPlugins } from \"./recordTypes/fileManager/fileManager.js\";\nimport { LambdaTrigger } from \"./lambda/LambdaTrigger.js\";\nimport type { LambdaClient, LambdaClientConfig } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { S3Client, S3ClientConfig } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { CopyFile } from \"~/resolver/recordTypes/fileManager/CopyFile.js\";\nimport { DeleteFile } from \"./recordTypes/fileManager/DeleteFile.js\";\nimport { createUsersPlugins } from \"~/resolver/recordTypes/users/users.js\";\nimport { CopyUser } from \"./recordTypes/users/CopyUser.js\";\nimport type {\n CognitoIdentityProviderClient,\n CognitoIdentityProviderClientConfig\n} from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport { DeleteUser } from \"./recordTypes/users/DeleteUser.js\";\n\nexport type AllowedResolverPlugins = TransformRecordPlugin | CommandHandlerPlugin;\n\nexport interface ICreateResolverHandlerParams extends HandlerParams {\n plugins: AllowedResolverPlugins[];\n createS3Client: (params: S3ClientConfig) => Pick<S3Client, \"send\">;\n createLambdaClient: (config: Partial<LambdaClientConfig>) => Pick<LambdaClient, \"send\">;\n createDocumentClient: (params: Partial<DynamoDBClientConfig>) => Pick<DynamoDBDocument, \"send\">;\n createCognitoIdentityProviderClient: (\n config: Partial<CognitoIdentityProviderClientConfig>\n ) => Pick<CognitoIdentityProviderClient, \"send\">;\n tableName?: string;\n awsWorkerLambdaArn?: string;\n}\n/**\n * Handler for the Sync System Resolver - based on SQS handler.\n */\nexport const createResolverHandler = (params: ICreateResolverHandlerParams): HandlerCallable => {\n const awsWorkerLambdaArn = params.awsWorkerLambdaArn || process.env.AWS_SYNC_WORKER_LAMBDA_ARN;\n if (!awsWorkerLambdaArn) {\n const message = `Missing \"process.env.AWS_SYNC_WORKER_LAMBDA_ARN\".`;\n console.error(message);\n throw new Error(message);\n }\n\n const lambdaTrigger = new LambdaTrigger({\n arn: awsWorkerLambdaArn,\n createLambdaClient: params.createLambdaClient\n });\n\n const copyFile = new CopyFile({\n createS3Client: params.createS3Client,\n getLambdaTrigger: () => {\n return lambdaTrigger;\n }\n });\n const deleteFile = new DeleteFile({\n createS3Client: params.createS3Client,\n getLambdaTrigger: () => {\n return lambdaTrigger;\n }\n });\n\n const copyUser = new CopyUser({\n createCognitoIdentityProviderClient: params.createCognitoIdentityProviderClient,\n getLambdaTrigger: () => {\n return lambdaTrigger;\n }\n });\n const deleteUser = new DeleteUser({\n createCognitoIdentityProviderClient: params.createCognitoIdentityProviderClient,\n getLambdaTrigger: () => {\n return lambdaTrigger;\n }\n });\n\n const plugins = new PluginsContainer([\n // TODO move into related packages\n createFileManagerPlugins({\n copyFile,\n deleteFile\n }),\n createUsersPlugins({\n copyUser,\n deleteUser\n }),\n // leave here\n createEventHandlerPlugin({\n createDocumentClient: params.createDocumentClient,\n tableName: params.tableName || process.env.DB_TABLE\n }),\n createPutCommandHandlerPlugin(),\n createDeleteCommandHandlerPlugin()\n ]);\n\n plugins.register(params.plugins);\n\n return createSQSHandler({\n ...params,\n plugins\n });\n};\n"],"mappings":"AACA,SAASA,aAAa,IAAIC,gBAAgB,QAAQ,kCAAkC;AACpF,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,wBAAwB;AAGjC,SAASC,6BAA6B;AACtC,SAASC,gCAAgC;AAKzC,SAASC,wBAAwB;AACjC,SAASC,aAAa;AAGtB,SAASC,QAAQ;AACjB,SAASC,UAAU;AACnB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ;AAKjB,SAASC,UAAU;AAenB;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAIC,MAAoC,IAAsB;EAC5F,MAAMC,kBAAkB,GAAGD,MAAM,CAACC,kBAAkB,IAAIC,OAAO,CAACC,GAAG,CAACC,0BAA0B;EAC9F,IAAI,CAACH,kBAAkB,EAAE;IACrB,MAAMI,OAAO,GAAG,mDAAmD;IACnEC,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;IACtB,MAAM,IAAIG,KAAK,CAACH,OAAO,CAAC;EAC5B;EAEA,MAAMI,aAAa,GAAG,IAAIhB,aAAa,CAAC;IACpCiB,GAAG,EAAET,kBAAkB;IACvBU,kBAAkB,EAAEX,MAAM,CAACW;EAC/B,CAAC,CAAC;EAEF,MAAMC,QAAQ,GAAG,IAAIlB,QAAQ,CAAC;IAC1BmB,cAAc,EAAEb,MAAM,CAACa,cAAc;IACrCC,gBAAgB,EAAEA,CAAA,KAAM;MACpB,OAAOL,aAAa;IACxB;EACJ,CAAC,CAAC;EACF,MAAMM,UAAU,GAAG,IAAIpB,UAAU,CAAC;IAC9BkB,cAAc,EAAEb,MAAM,CAACa,cAAc;IACrCC,gBAAgB,EAAEA,CAAA,KAAM;MACpB,OAAOL,aAAa;IACxB;EACJ,CAAC,CAAC;EAEF,MAAMO,QAAQ,GAAG,IAAInB,QAAQ,CAAC;IAC1BoB,mCAAmC,EAAEjB,MAAM,CAACiB,mCAAmC;IAC/EH,gBAAgB,EAAEA,CAAA,KAAM;MACpB,OAAOL,aAAa;IACxB;EACJ,CAAC,CAAC;EACF,MAAMS,UAAU,GAAG,IAAIpB,UAAU,CAAC;IAC9BmB,mCAAmC,EAAEjB,MAAM,CAACiB,mCAAmC;IAC/EH,gBAAgB,EAAEA,CAAA,KAAM;MACpB,OAAOL,aAAa;IACxB;EACJ,CAAC,CAAC;EAEF,MAAMU,OAAO,GAAG,IAAI/B,gBAAgB,CAAC;EACjC;EACAI,wBAAwB,CAAC;IACrBoB,QAAQ;IACRG;EACJ,CAAC,CAAC,EACFnB,kBAAkB,CAAC;IACfoB,QAAQ;IACRE;EACJ,CAAC,CAAC;EACF;EACA7B,wBAAwB,CAAC;IACrB+B,oBAAoB,EAAEpB,MAAM,CAACoB,oBAAoB;IACjDC,SAAS,EAAErB,MAAM,CAACqB,SAAS,IAAInB,OAAO,CAACC,GAAG,CAACmB;EAC/C,CAAC,CAAC,EACFhC,6BAA6B,CAAC,CAAC,EAC/BC,gCAAgC,CAAC,CAAC,CACrC,CAAC;EAEF4B,OAAO,CAACI,QAAQ,CAACvB,MAAM,CAACmB,OAAO,CAAC;EAEhC,OAAOhC,gBAAgB,CAAC;IACpB,GAAGa,MAAM;IACTmB;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { DynamoDBTableType } from \"~/types.js\";\nimport type { SemVer } from \"semver\";\nimport type { ITable } from \"~/sync/types.js\";\n\nexport interface IDeploymentServices {\n s3Id: string;\n s3Arn: string;\n primaryDynamoDbArn: string;\n primaryDynamoDbName: string;\n primaryDynamoDbHashKey: string;\n primaryDynamoDbRangeKey: string;\n opensearchDynamodbTableArn?: string;\n opensearchDynamodbTableName?: string;\n cognitoUserPoolId: string;\n}\n\nexport interface IDeployment<S = IDeploymentServices> {\n name: string;\n env: string;\n variant: string | undefined;\n region: string;\n services: S;\n version: SemVer;\n getTable(type: DynamoDBTableType): ITable;\n}\n\nexport interface IDeployments {\n hasAny(): boolean;\n all(): IDeployment[];\n get(name: string): IDeployment | null;\n without(deployment: Pick<IDeployment, \"name\">): IDeployments;\n}\n\nexport interface IDeploymentsFetcher {\n fetch(): Promise<IDeployments>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { LambdaTrigger } from \"~/resolver/lambda/LambdaTrigger.js\";\nimport type { S3Client, S3ClientConfig } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\n\nexport interface IGetLambdaTriggerCb<T> {\n (): LambdaTrigger<T>;\n}\n\nexport interface ICreateS3ClientCb {\n (params: S3ClientConfig): Pick<S3Client, \"send\">;\n}\n\nexport interface ICopyFileHandleParams {\n key: string;\n source: IDeployment;\n target: IDeployment;\n}\n\nexport interface ICopyFile {\n handle(params: ICopyFileHandleParams): Promise<InvokeCommandOutput | null>;\n}\n\nexport interface IDeleteFileHandleParams {\n key: string;\n source: IDeployment;\n target: IDeployment;\n}\n\nexport interface IDeleteFile {\n handle(params: IDeleteFileHandleParams): Promise<InvokeCommandOutput | null>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
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,2 +0,0 @@
1
- import type { IHandler } from "./types.js";
2
- export declare const createSendDataToEventBridgeOnRequestEnd: (handler: IHandler) => (import("@webiny/handler").OnRequestResponseSendPlugin | import("@webiny/handler").OnRequestTimeoutPlugin)[];
@@ -1,44 +0,0 @@
1
- import { createOnRequestResponseSend, createOnRequestTimeout } from "@webiny/handler";
2
- import { convertException } from "@webiny/utils/exception.js";
3
- const execute = async handler => {
4
- try {
5
- return await handler.flush();
6
- } catch (ex) {
7
- const error = convertException(ex);
8
- console.error({
9
- flushError: error
10
- });
11
- return {
12
- error
13
- };
14
- /**
15
- * We do not want to throw an error here, because we are in the request end.
16
- */
17
- }
18
- };
19
- const isOptionsRequest = request => {
20
- if (!request?.method) {
21
- return false;
22
- }
23
- return request.method.toUpperCase() === "OPTIONS";
24
- };
25
- export const createSendDataToEventBridgeOnRequestEnd = handler => {
26
- const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {
27
- if (isOptionsRequest(request)) {
28
- return payload;
29
- }
30
- await execute(handler);
31
- return payload;
32
- });
33
- onRequestResponseSend.name = "sync.onRequestResponseSend";
34
- const onRequestTimeout = createOnRequestTimeout(async request => {
35
- if (isOptionsRequest(request)) {
36
- return;
37
- }
38
- return await execute(handler);
39
- });
40
- onRequestTimeout.name = "sync.onRequestTimeout";
41
- return [onRequestResponseSend, onRequestTimeout];
42
- };
43
-
44
- //# sourceMappingURL=createSendDataToEventBridgeOnRequestEnd.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,16 +0,0 @@
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.js";
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;
@@ -1,35 +0,0 @@
1
- import { validateSystemInput } from "./utils/validateSystemInput.js";
2
- import { createSyncSystemHandlerOnRequestPlugin } from "./requestPlugin.js";
3
- import { createDefaultFilterOutRecordPlugins } from "./filter/createDefaultFilterOutRecordPlugins.js";
4
- const emptyResponse = {
5
- plugins() {
6
- return [];
7
- }
8
- };
9
- export const createSyncSystem = params => {
10
- const {
11
- system,
12
- error
13
- } = validateSystemInput(params.system);
14
- /**
15
- * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.
16
- */
17
- if (error) {
18
- console.error(error);
19
- return emptyResponse;
20
- } else if (!system) {
21
- console.error("Sync System: No system provided. Sync System will not be attached.");
22
- return emptyResponse;
23
- }
24
- return {
25
- plugins: () => {
26
- return [...(params.plugins || []), ...createDefaultFilterOutRecordPlugins(), createSyncSystemHandlerOnRequestPlugin({
27
- getDocumentClient: params.getDocumentClient,
28
- getEventBridgeClient: params.getEventBridgeClient,
29
- system
30
- })];
31
- }
32
- };
33
- };
34
-
35
- //# sourceMappingURL=createSyncSystem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["validateSystemInput","createSyncSystemHandlerOnRequestPlugin","createDefaultFilterOutRecordPlugins","emptyResponse","plugins","createSyncSystem","params","system","error","console","getDocumentClient","getEventBridgeClient"],"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.js\";\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,SAASA,mBAAmB;AAG5B,SAASC,sCAAsC;AAE/C,SAASC,mCAAmC;AAe5C,MAAMC,aAAwC,GAAG;EAC7CC,OAAOA,CAAA,EAAa;IAChB,OAAO,EAAE;EACb;AACJ,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAIC,MAA+B,IAAgC;EAC5F,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGR,mBAAmB,CAACM,MAAM,CAACC,MAAM,CAAC;EAC5D;AACJ;AACA;EACI,IAAIC,KAAK,EAAE;IACPC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IACpB,OAAOL,aAAa;EACxB,CAAC,MAAM,IAAI,CAACI,MAAM,EAAE;IAChBE,OAAO,CAACD,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,GAAGF,mCAAmC,CAAC,CAAC,EACxCD,sCAAsC,CAAC;QACnCS,iBAAiB,EAAEJ,MAAM,CAACI,iBAAiB;QAC3CC,oBAAoB,EAAEL,MAAM,CAACK,oBAAoB;QACjDJ;MACJ,CAAC,CAAC,CACL;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}