@webiny/api-sync-system 6.0.0-alpha.4 → 6.0.0-rc.0

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 (299) hide show
  1. package/README.md +6 -108
  2. package/constants.js +1 -7
  3. package/constants.js.map +1 -1
  4. package/index.js +3 -38
  5. package/index.js.map +1 -1
  6. package/package.json +20 -23
  7. package/resolver/app/RecordHandler.d.ts +6 -6
  8. package/resolver/app/RecordHandler.js +7 -15
  9. package/resolver/app/RecordHandler.js.map +1 -1
  10. package/resolver/app/RecordsValidation.js +6 -14
  11. package/resolver/app/RecordsValidation.js.map +1 -1
  12. package/resolver/app/ResolverApplication.d.ts +1 -1
  13. package/resolver/app/ResolverApplication.js +10 -18
  14. package/resolver/app/ResolverApplication.js.map +1 -1
  15. package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
  16. package/resolver/app/abstractions/RecordHandler.js +1 -5
  17. package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
  18. package/resolver/app/abstractions/RecordsValidation.js +1 -5
  19. package/resolver/app/abstractions/RecordsValidation.js.map +1 -1
  20. package/resolver/app/abstractions/ResolverApplication.js +1 -5
  21. package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
  22. package/resolver/app/abstractions/ResolverRecord.js +1 -5
  23. package/resolver/app/abstractions/ResolverRecord.js.map +1 -1
  24. package/resolver/app/bundler/BaseBundle.d.ts +6 -6
  25. package/resolver/app/bundler/BaseBundle.js +1 -8
  26. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  27. package/resolver/app/bundler/Bundler.d.ts +1 -1
  28. package/resolver/app/bundler/Bundler.js +2 -10
  29. package/resolver/app/bundler/Bundler.js.map +1 -1
  30. package/resolver/app/bundler/Bundles.d.ts +2 -2
  31. package/resolver/app/bundler/Bundles.js +2 -10
  32. package/resolver/app/bundler/Bundles.js.map +1 -1
  33. package/resolver/app/bundler/CommandBundle.d.ts +1 -1
  34. package/resolver/app/bundler/CommandBundle.js +3 -11
  35. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  36. package/resolver/app/bundler/TableBundle.d.ts +1 -1
  37. package/resolver/app/bundler/TableBundle.js +3 -11
  38. package/resolver/app/bundler/TableBundle.js.map +1 -1
  39. package/resolver/app/bundler/types.d.ts +2 -2
  40. package/resolver/app/bundler/types.js +1 -5
  41. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
  42. package/resolver/app/commandHandler/DeleteCommandHandler.js +1 -8
  43. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  44. package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
  45. package/resolver/app/commandHandler/PutCommandHandler.js +1 -8
  46. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  47. package/resolver/app/commandHandler/delete.d.ts +1 -1
  48. package/resolver/app/commandHandler/delete.js +6 -13
  49. package/resolver/app/commandHandler/delete.js.map +1 -1
  50. package/resolver/app/commandHandler/put.d.ts +1 -1
  51. package/resolver/app/commandHandler/put.js +6 -13
  52. package/resolver/app/commandHandler/put.js.map +1 -1
  53. package/resolver/app/data/SourceDataContainer.d.ts +3 -3
  54. package/resolver/app/data/SourceDataContainer.js +1 -8
  55. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  56. package/resolver/app/data/types.d.ts +2 -2
  57. package/resolver/app/data/types.js +1 -5
  58. package/resolver/app/fetcher/Fetcher.d.ts +3 -3
  59. package/resolver/app/fetcher/Fetcher.js +13 -22
  60. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  61. package/resolver/app/fetcher/types.d.ts +2 -2
  62. package/resolver/app/fetcher/types.js +1 -5
  63. package/resolver/app/ingestor/Ingestor.d.ts +1 -1
  64. package/resolver/app/ingestor/Ingestor.js +2 -10
  65. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  66. package/resolver/app/ingestor/IngestorResult.js +3 -11
  67. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  68. package/resolver/app/ingestor/types.d.ts +2 -2
  69. package/resolver/app/ingestor/types.js +1 -5
  70. package/resolver/app/storer/Storer.d.ts +3 -3
  71. package/resolver/app/storer/Storer.js +12 -20
  72. package/resolver/app/storer/Storer.js.map +1 -1
  73. package/resolver/app/storer/types.d.ts +2 -2
  74. package/resolver/app/storer/types.js +1 -5
  75. package/resolver/app/storer/types.js.map +1 -1
  76. package/resolver/app/transform/TransformHandler.d.ts +4 -4
  77. package/resolver/app/transform/TransformHandler.js +5 -12
  78. package/resolver/app/transform/TransformHandler.js.map +1 -1
  79. package/resolver/app/transform/middleware.d.ts +1 -1
  80. package/resolver/app/transform/middleware.js +1 -7
  81. package/resolver/app/transform/middleware.js.map +1 -1
  82. package/resolver/app/utils/Retry.js +4 -12
  83. package/resolver/app/utils/Retry.js.map +1 -1
  84. package/resolver/app/utils/sleep.js +1 -8
  85. package/resolver/app/utils/sleep.js.map +1 -1
  86. package/resolver/app/validation/body.d.ts +6 -6
  87. package/resolver/app/validation/body.js +22 -30
  88. package/resolver/app/validation/body.js.map +1 -1
  89. package/resolver/app/validation/createJsonTransform.js +6 -14
  90. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  91. package/resolver/app/validation/detail.d.ts +6 -6
  92. package/resolver/app/validation/detail.js +16 -24
  93. package/resolver/app/validation/detail.js.map +1 -1
  94. package/resolver/app/validation/event.d.ts +6 -6
  95. package/resolver/app/validation/event.js +19 -27
  96. package/resolver/app/validation/event.js.map +1 -1
  97. package/resolver/app/validation/numericString.js +5 -13
  98. package/resolver/app/validation/numericString.js.map +1 -1
  99. package/resolver/app/validation/system.js +8 -16
  100. package/resolver/app/validation/system.js.map +1 -1
  101. package/resolver/createEventHandlerPlugin.d.ts +2 -1
  102. package/resolver/createEventHandlerPlugin.js +35 -42
  103. package/resolver/createEventHandlerPlugin.js.map +1 -1
  104. package/resolver/createResolverHandler.d.ts +1 -1
  105. package/resolver/createResolverHandler.js +24 -31
  106. package/resolver/createResolverHandler.js.map +1 -1
  107. package/resolver/deployment/Deployment.d.ts +2 -3
  108. package/resolver/deployment/Deployment.js +6 -14
  109. package/resolver/deployment/Deployment.js.map +1 -1
  110. package/resolver/deployment/Deployments.js +2 -10
  111. package/resolver/deployment/Deployments.js.map +1 -1
  112. package/resolver/deployment/DeploymentsFetcher.js +33 -42
  113. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  114. package/resolver/deployment/types.d.ts +4 -4
  115. package/resolver/deployment/types.js +1 -5
  116. package/resolver/deployment/types.js.map +1 -1
  117. package/resolver/lambda/LambdaTrigger.js +5 -12
  118. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  119. package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
  120. package/resolver/plugins/CommandHandlerPlugin.js +3 -11
  121. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  122. package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
  123. package/resolver/plugins/StorerAfterEachPlugin.js +4 -13
  124. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  125. package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
  126. package/resolver/plugins/TransformRecordPlugin.js +3 -11
  127. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  128. package/resolver/recordTypes/fileManager/CopyFile.js +4 -11
  129. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  130. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
  131. package/resolver/recordTypes/fileManager/DeleteFile.js +3 -10
  132. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  133. package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
  134. package/resolver/recordTypes/fileManager/fileManager.js +4 -11
  135. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  136. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
  137. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +7 -14
  138. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  139. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
  140. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +7 -14
  141. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  142. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
  143. package/resolver/recordTypes/fileManager/shouldBeHandled.js +1 -8
  144. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  145. package/resolver/recordTypes/fileManager/types.d.ts +2 -2
  146. package/resolver/recordTypes/fileManager/types.js +1 -5
  147. package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
  148. package/resolver/recordTypes/users/CopyUser.js +3 -10
  149. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  150. package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
  151. package/resolver/recordTypes/users/DeleteUser.js +3 -10
  152. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  153. package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
  154. package/resolver/recordTypes/users/shouldBeHandled.js +1 -8
  155. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  156. package/resolver/recordTypes/users/types.d.ts +1 -1
  157. package/resolver/recordTypes/users/types.js +1 -5
  158. package/resolver/recordTypes/users/types.js.map +1 -1
  159. package/resolver/recordTypes/users/users.js +4 -11
  160. package/resolver/recordTypes/users/users.js.map +1 -1
  161. package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
  162. package/resolver/recordTypes/users/usersOnDelete.js +7 -14
  163. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  164. package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
  165. package/resolver/recordTypes/users/usersOnPut.js +7 -14
  166. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  167. package/sync/FilterOutRecord.d.ts +2 -2
  168. package/sync/FilterOutRecord.js +2 -10
  169. package/sync/FilterOutRecord.js.map +1 -1
  170. package/sync/attachToDynamoDbDocument.d.ts +1 -1
  171. package/sync/attachToDynamoDbDocument.js +9 -17
  172. package/sync/attachToDynamoDbDocument.js.map +1 -1
  173. package/sync/createHandler.js +27 -34
  174. package/sync/createHandler.js.map +1 -1
  175. package/sync/createSendDataToEventBridgeOnRequestEnd.js +6 -13
  176. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
  177. package/sync/createSyncSystem.d.ts +1 -1
  178. package/sync/createSyncSystem.js +6 -13
  179. package/sync/createSyncSystem.js.map +1 -1
  180. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
  181. package/sync/filter/createDefaultFilterOutRecordPlugins.js +9 -19
  182. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  183. package/sync/handler/Handler.d.ts +2 -2
  184. package/sync/handler/Handler.js +9 -17
  185. package/sync/handler/Handler.js.map +1 -1
  186. package/sync/handler/HandlerConverter.js +2 -10
  187. package/sync/handler/HandlerConverter.js.map +1 -1
  188. package/sync/handler/converter/BatchGetCommandConverter.js +6 -14
  189. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  190. package/sync/handler/converter/BatchWriteCommandConverter.js +6 -14
  191. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  192. package/sync/handler/converter/DeleteCommandConverter.js +6 -14
  193. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  194. package/sync/handler/converter/GetCommandConverter.js +6 -14
  195. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  196. package/sync/handler/converter/PutCommandConverter.js +6 -14
  197. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  198. package/sync/handler/converter/QueryCommandConverter.js +6 -14
  199. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  200. package/sync/handler/converter/ScanCommandConverter.js +6 -14
  201. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  202. package/sync/handler/converter/UpdateCommandConverter.js +6 -14
  203. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  204. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
  205. package/sync/handler/converter/commands/BatchWriteCommandValue.js +4 -11
  206. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  207. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
  208. package/sync/handler/converter/commands/DeleteCommandValue.js +3 -10
  209. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  210. package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
  211. package/sync/handler/converter/commands/NullCommandValue.js +1 -8
  212. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  213. package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
  214. package/sync/handler/converter/commands/PutCommandValue.js +3 -10
  215. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  216. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
  217. package/sync/handler/converter/commands/UpdateCommandValue.js +3 -10
  218. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  219. package/sync/handler/types.d.ts +3 -3
  220. package/sync/handler/types.js +1 -5
  221. package/sync/handler/types.js.map +1 -1
  222. package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
  223. package/sync/plugins/FilterOutRecordPlugin.js +3 -11
  224. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  225. package/sync/requestPlugin.d.ts +1 -1
  226. package/sync/requestPlugin.js +19 -20
  227. package/sync/requestPlugin.js.map +1 -1
  228. package/sync/types.js +1 -5
  229. package/sync/utils/getTableType.js +7 -14
  230. package/sync/utils/getTableType.js.map +1 -1
  231. package/sync/utils/manifest.d.ts +1 -1
  232. package/sync/utils/manifest.js +12 -20
  233. package/sync/utils/manifest.js.map +1 -1
  234. package/sync/utils/validateSystemInput.d.ts +1 -1
  235. package/sync/utils/validateSystemInput.js +3 -10
  236. package/sync/utils/validateSystemInput.js.map +1 -1
  237. package/types.d.ts +3 -4
  238. package/types.js +2 -8
  239. package/types.js.map +1 -1
  240. package/utils/createSystemName.js +1 -8
  241. package/utils/createSystemName.js.map +1 -1
  242. package/worker/actions/copyFile/CopyFile.js +13 -21
  243. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  244. package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
  245. package/worker/actions/copyFile/copyFileAction.js +9 -16
  246. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  247. package/worker/actions/copyFile/copyFileSchema.js +8 -16
  248. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  249. package/worker/actions/copyFile/types.js +1 -5
  250. package/worker/actions/createUser/CreateUser.d.ts +1 -1
  251. package/worker/actions/createUser/CreateUser.js +9 -16
  252. package/worker/actions/createUser/CreateUser.js.map +1 -1
  253. package/worker/actions/createUser/createUserAction.d.ts +2 -2
  254. package/worker/actions/createUser/createUserAction.js +9 -16
  255. package/worker/actions/createUser/createUserAction.js.map +1 -1
  256. package/worker/actions/createUser/createUserSchema.js +8 -16
  257. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  258. package/worker/actions/createUser/types.js +1 -5
  259. package/worker/actions/deleteFile/DeleteFile.js +4 -11
  260. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  261. package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
  262. package/worker/actions/deleteFile/deleteFileAction.js +9 -16
  263. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  264. package/worker/actions/deleteFile/deleteFileSchema.js +8 -16
  265. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  266. package/worker/actions/deleteFile/types.js +1 -5
  267. package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
  268. package/worker/actions/deleteUser/DeleteUser.js +7 -14
  269. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  270. package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
  271. package/worker/actions/deleteUser/deleteUserAction.js +9 -16
  272. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  273. package/worker/actions/deleteUser/deleteUserSchema.js +8 -16
  274. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  275. package/worker/actions/deleteUser/types.js +1 -5
  276. package/worker/actions/logValidationError.js +4 -11
  277. package/worker/actions/logValidationError.js.map +1 -1
  278. package/worker/actions/removeCognitoUserAttributes.js +1 -8
  279. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  280. package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
  281. package/worker/actions/updateUser/UpdateUser.js +9 -16
  282. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  283. package/worker/actions/updateUser/types.js +1 -5
  284. package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
  285. package/worker/actions/updateUser/updateUserAction.js +9 -16
  286. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  287. package/worker/actions/updateUser/updateUserSchema.js +8 -16
  288. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  289. package/worker/createWorkerHandler.js +17 -24
  290. package/worker/createWorkerHandler.js.map +1 -1
  291. package/worker/handler/WorkerActionHandler.d.ts +2 -2
  292. package/worker/handler/WorkerActionHandler.js +3 -10
  293. package/worker/handler/WorkerActionHandler.js.map +1 -1
  294. package/worker/handler/eventHandler.js +9 -16
  295. package/worker/handler/eventHandler.js.map +1 -1
  296. package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
  297. package/worker/plugins/WorkerActionPlugin.js +3 -11
  298. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  299. package/worker/types.js +1 -5
package/README.md CHANGED
@@ -1,113 +1,11 @@
1
1
  # @webiny/api-sync-system
2
- [![](https://img.shields.io/npm/dw/@webiny/api-sync-system.svg)](https://www.npmjs.com/package/@webiny/api-sync-system)
3
- [![](https://img.shields.io/npm/v/@webiny/api-sync-system.svg)](https://www.npmjs.com/package/@webiny/api-sync-system)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
2
 
7
- ## Install
8
- ```
9
- yarn add @webiny/api-sync-system
10
- ```
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
11
6
 
12
- ## How To Use?
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
13
8
 
14
- ### Information About `env` and `variant` Parameters
15
- We will use `dev` environment in the examples.
9
+ ---
16
10
 
17
- Variants can be anything you like, for our example we use `blue` and `green`, but you can use `orange`, `black`, `car`,
18
- `horse`, `space`, etc.
19
-
20
- ### Deploy the Sync System
21
-
22
- Deploy the Sync System to the `dev` environment.
23
-
24
- ```bash
25
- yarn webiny deploy sync --env=dev
26
- ```
27
-
28
- ### Deploy `blue` and `green` Webiny
29
-
30
- It imperative the two systems to be in the same environment as the Sync System, as it will automatically connect Webiny deployments in the same environment.
31
-
32
- ```bash
33
- yarn webiny deploy --env=dev --variant=blue && yarn webiny deploy --env=dev --variant=green
34
- ```
35
-
36
- Also, there can be more than two systems, so you can deploy as many as you like, just make sure to use different variants.
37
-
38
- ### Install Webiny Blue Variant
39
-
40
- Do a:
41
- ```
42
- yarn webiny info
43
- ```
44
- Find the `blue` variant Admin URL, and open it in your browser. Install the system by following the instructions.
45
-
46
- At that point, green system should be installed as well.
47
-
48
-
49
- # TODO
50
-
51
- ### Add BlueGreen, Resolver and Work Folders to User Projects
52
- We need to deploy the following folders to the user project:
53
- - blueGreen
54
- - sync/resolver
55
- - sync/worker
56
-
57
- Maybe have it as a CLI command?
58
-
59
- ### Test the Blue / Green Deployment
60
-
61
- - create domains api.bg.webiny.com, admin.bg.webiny.com, website.bg.webiny.com, preview.bg.webiny.com
62
- - deploy the blueGreen application
63
- - make sure the domains are pointing correctly
64
- - switch between blue and green deployments to test the resolver
65
- - create / update entries in blue and green and make sure they are correctly transferred to the other deployment
66
-
67
- ### Cognito User Transfer
68
-
69
- User is currently transferred but password is not so it results in error where user cannot log in and cannot reset
70
- password.
71
- This will be resolved by implementing a login function which will send a code to the user email and log in with that
72
- code.
73
-
74
- ### Filtering out models which we do not want to sync
75
-
76
- Currently, models are filtered out when records are being added into the sync pool. That is ok for creating or updating
77
- records, but when deleting, we do not have the modelId in the item being deleted.
78
-
79
- Maybe implement filtering in the resolver ?
80
-
81
- ### Add proper logging?
82
- Use pino to log all events, separated in proper levels (info, warn, error, debug, etc...).
83
-
84
- ### Move Resolver plugins (file manager, users) into their own packages
85
- We should move the resolver plugins for file manager and users into their own packages, and those packages should register them.
86
-
87
- ### Implement Dependency Injection
88
-
89
- Currently, we need to pass a ton of methods to the Sync system handlers. It would be simple as
90
-
91
- ```typescript
92
- const handler = createSyncResolverHandler({
93
- plugins: [],
94
- debug: process.env.DEBUG === "true",
95
- awsWorkerLambdaArn: process.env.AWS_SYNC_WORKER_LAMBDA_ARN,
96
- });
97
- ```
98
-
99
- if we did not need to pass all creator methods:
100
-
101
- ```typescript
102
- const handler = createSyncResolverHandler({
103
- plugins: [],
104
- debug: process.env.DEBUG === "true",
105
- awsWorkerLambdaArn: process.env.AWS_SYNC_WORKER_LAMBDA_ARN,
106
- createS3Client,
107
- createLambdaClient,
108
- createDocumentClient,
109
- createCognitoIdentityProviderClient
110
- });
111
- ```
112
-
113
- And there might be new methods added in the future.
11
+ _This README file is automatically generated during the publish process._
package/constants.js CHANGED
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SQS_EVENT_NAME = void 0;
7
- const SQS_EVENT_NAME = exports.SQS_EVENT_NAME = "synchronization-input";
1
+ export const SQS_EVENT_NAME = "synchronization-input";
8
2
 
9
3
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["SQS_EVENT_NAME","exports"],"sources":["constants.ts"],"sourcesContent":["export const SQS_EVENT_NAME = \"synchronization-input\" as const;\n"],"mappings":";;;;;;AAAO,MAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,uBAAgC","ignoreList":[]}
1
+ {"version":3,"names":["SQS_EVENT_NAME"],"sources":["constants.ts"],"sourcesContent":["export const SQS_EVENT_NAME = \"synchronization-input\" as const;\n"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAG,uBAAgC","ignoreList":[]}
package/index.js CHANGED
@@ -1,40 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _createWorkerHandler = require("./worker/createWorkerHandler.js");
7
- Object.keys(_createWorkerHandler).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _createWorkerHandler[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _createWorkerHandler[key];
14
- }
15
- });
16
- });
17
- var _createSyncSystem = require("./sync/createSyncSystem.js");
18
- Object.keys(_createSyncSystem).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _createSyncSystem[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _createSyncSystem[key];
25
- }
26
- });
27
- });
28
- var _createResolverHandler = require("./resolver/createResolverHandler.js");
29
- Object.keys(_createResolverHandler).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _createResolverHandler[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _createResolverHandler[key];
36
- }
37
- });
38
- });
1
+ export * from "./worker/createWorkerHandler.js";
2
+ export * from "./sync/createSyncSystem.js";
3
+ export * from "./resolver/createResolverHandler.js";
39
4
 
40
5
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_createWorkerHandler","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createSyncSystem","_createResolverHandler"],"sources":["index.ts"],"sourcesContent":["export * from \"./worker/createWorkerHandler.js\";\nexport * from \"./sync/createSyncSystem.js\";\nexport * from \"./resolver/createResolverHandler.js\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,iBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,iBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,iBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,iBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,sBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,sBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,sBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,sBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
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":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/api-sync-system",
3
- "version": "6.0.0-alpha.4",
3
+ "version": "6.0.0-rc.0",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -10,36 +11,32 @@
10
11
  "author": "Webiny LTD",
11
12
  "license": "MIT",
12
13
  "dependencies": {
13
- "@webiny/api": "6.0.0-alpha.4",
14
- "@webiny/aws-sdk": "6.0.0-alpha.4",
15
- "@webiny/error": "6.0.0-alpha.4",
16
- "@webiny/handler": "6.0.0-alpha.4",
17
- "@webiny/handler-aws": "6.0.0-alpha.4",
18
- "@webiny/plugins": "6.0.0-alpha.4",
19
- "@webiny/utils": "6.0.0-alpha.4",
14
+ "@webiny/api": "6.0.0-rc.0",
15
+ "@webiny/aws-sdk": "6.0.0-rc.0",
16
+ "@webiny/error": "6.0.0-rc.0",
17
+ "@webiny/handler": "6.0.0-rc.0",
18
+ "@webiny/handler-aws": "6.0.0-rc.0",
19
+ "@webiny/plugins": "6.0.0-rc.0",
20
+ "@webiny/utils": "6.0.0-rc.0",
20
21
  "bytes": "3.1.2",
21
- "lodash": "4.17.21",
22
- "semver": "7.6.3",
23
- "zod": "3.23.8"
22
+ "lodash": "4.17.23",
23
+ "semver": "7.7.4",
24
+ "zod": "3.25.76"
24
25
  },
25
26
  "devDependencies": {
26
- "@faker-js/faker": "9.3.0",
27
- "@types/lodash": "4.17.13",
28
- "@webiny/cli": "6.0.0-alpha.4",
29
- "@webiny/project-utils": "6.0.0-alpha.4",
27
+ "@faker-js/faker": "9.9.0",
28
+ "@types/lodash": "4.17.23",
29
+ "@webiny/build-tools": "6.0.0-rc.0",
30
+ "@webiny/project-utils": "6.0.0-rc.0",
30
31
  "aws-sdk-client-mock": "4.1.0",
31
- "jest": "29.7.0",
32
32
  "jest-dynalite": "3.6.1",
33
- "rimraf": "6.0.1",
34
- "typescript": "5.3.3"
33
+ "rimraf": "6.1.3",
34
+ "typescript": "5.9.3",
35
+ "vitest": "4.0.18"
35
36
  },
36
37
  "publishConfig": {
37
38
  "access": "public",
38
39
  "directory": "dist"
39
40
  },
40
- "scripts": {
41
- "build": "node ../cli/bin.js run build",
42
- "watch": "node ../cli/bin.js run watch"
43
- },
44
- "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
41
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
45
42
  }
@@ -1,11 +1,11 @@
1
1
  import type { IRecordHandler, IRecordHandlerHandleParams } from "./abstractions/RecordHandler.js";
2
2
  import type { PluginsContainer } from "@webiny/plugins";
3
- import type { IFetcher } from "./fetcher/types.js";
4
- import type { IStorer } from "./storer/types.js";
5
- import type { IBundler } from "./bundler/types.js";
6
- import type { IDeployments } from "../deployment/types.js";
7
- import type { ITransformHandler } from "./transform/TransformHandler.js";
8
- import type { ISourceDataContainer } from "./data/types.js";
3
+ import type { IFetcher } from "../../resolver/app/fetcher/types.js";
4
+ import type { IStorer } from "../../resolver/app/storer/types.js";
5
+ import type { IBundler } from "../../resolver/app/bundler/types.js";
6
+ import type { IDeployments } from "../../resolver/deployment/types.js";
7
+ import type { ITransformHandler } from "../../resolver/app/transform/TransformHandler.js";
8
+ import type { ISourceDataContainer } from "../../resolver/app/data/types.js";
9
9
  export interface IRecordHandlerParams {
10
10
  fetcher: IFetcher;
11
11
  storer: IStorer;
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createRecordHandler = exports.RecordHandler = void 0;
7
- var _CommandHandlerPlugin = require("../plugins/CommandHandlerPlugin.js");
8
- var _utils = require("@webiny/utils");
9
- class RecordHandler {
1
+ import { CommandHandlerPlugin } from "../plugins/CommandHandlerPlugin.js";
2
+ import { convertException } from "@webiny/utils";
3
+ export class RecordHandler {
10
4
  constructor(params) {
11
5
  this.plugins = params.plugins;
12
6
  this.fetcher = params.fetcher;
@@ -16,7 +10,7 @@ class RecordHandler {
16
10
  this.deployments = params.deployments;
17
11
  this.transformHandler = params.transformHandler;
18
12
  this.createSourceDataContainer = params.createSourceDataContainer;
19
- this.commandHandlerPlugins = this.plugins.byType(_CommandHandlerPlugin.CommandHandlerPlugin.type);
13
+ this.commandHandlerPlugins = this.plugins.byType(CommandHandlerPlugin.type);
20
14
  }
21
15
  async handle(params) {
22
16
  const {
@@ -41,7 +35,7 @@ class RecordHandler {
41
35
  });
42
36
  if (error) {
43
37
  console.error(`Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`);
44
- console.log((0, _utils.convertException)(error));
38
+ console.log(convertException(error));
45
39
  continue;
46
40
  }
47
41
  container.merge(items);
@@ -105,7 +99,7 @@ class RecordHandler {
105
99
  } = params;
106
100
  try {
107
101
  return targetDeployment.getTable(bundle.table.type);
108
- } catch (ex) {
102
+ } catch {
109
103
  return null;
110
104
  }
111
105
  }
@@ -117,10 +111,8 @@ class RecordHandler {
117
111
  return handler;
118
112
  }
119
113
  }
120
- exports.RecordHandler = RecordHandler;
121
- const createRecordHandler = params => {
114
+ export const createRecordHandler = params => {
122
115
  return new RecordHandler(params);
123
116
  };
124
- exports.createRecordHandler = createRecordHandler;
125
117
 
126
118
  //# sourceMappingURL=RecordHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CommandHandlerPlugin","require","_utils","RecordHandler","constructor","params","plugins","fetcher","storer","commandBundler","tableBundler","deployments","transformHandler","createSourceDataContainer","commandHandlerPlugins","byType","CommandHandlerPlugin","type","handle","data","sources","bundle","items","getItems","container","getBundles","error","exec","deployment","source","table","maxBatchSize","console","name","log","convertException","merge","bundlesByCommand","without","targetDeployment","all","map","item","get","PK","SK","filter","targetTable","findTargetTable","result","transform","sourceDeployment","sourceTable","commandHandler","getCommandHandler","command","ex","message","getTable","handler","find","plugin","canHandle","Error","exports","createRecordHandler"],"sources":["RecordHandler.ts"],"sourcesContent":["import type { IRecordHandler, IRecordHandlerHandleParams } from \"./abstractions/RecordHandler.js\";\nimport { CommandHandlerPlugin } from \"../plugins/CommandHandlerPlugin.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { CommandType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IFetcher } from \"~/resolver/app/fetcher/types.js\";\nimport type { IStoreItem, IStorer } from \"~/resolver/app/storer/types.js\";\nimport type { IBundle, IBundler } from \"~/resolver/app/bundler/types.js\";\nimport type { IDeployment, IDeployments } from \"~/resolver/deployment/types.js\";\nimport type { ITransformHandler } from \"~/resolver/app/transform/TransformHandler.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { ISourceDataContainer } from \"~/resolver/app/data/types.js\";\n\nexport interface IRecordHandlerParams {\n fetcher: IFetcher;\n storer: IStorer;\n plugins: PluginsContainer;\n commandBundler: IBundler;\n tableBundler: IBundler;\n deployments: IDeployments;\n transformHandler: ITransformHandler;\n createSourceDataContainer: () => ISourceDataContainer;\n}\n\ninterface IFindTargetTableParams {\n bundle: IBundle;\n targetDeployment: IDeployment;\n}\n\nexport class RecordHandler implements IRecordHandler {\n private readonly plugins: PluginsContainer;\n private readonly commandHandlerPlugins: CommandHandlerPlugin[];\n private readonly fetcher: IFetcher;\n private readonly storer: IStorer;\n private readonly commandBundler: IBundler;\n private readonly tableBundler: IBundler;\n private readonly deployments: IDeployments;\n private readonly transformHandler: ITransformHandler;\n private readonly createSourceDataContainer: () => ISourceDataContainer;\n\n public constructor(params: IRecordHandlerParams) {\n this.plugins = params.plugins;\n this.fetcher = params.fetcher;\n this.storer = params.storer;\n this.commandBundler = params.commandBundler;\n this.tableBundler = params.tableBundler;\n this.deployments = params.deployments;\n this.transformHandler = params.transformHandler;\n this.createSourceDataContainer = params.createSourceDataContainer;\n\n this.commandHandlerPlugins = this.plugins.byType<CommandHandlerPlugin>(\n CommandHandlerPlugin.type\n );\n }\n\n public async handle(params: IRecordHandlerHandleParams): Promise<void> {\n const { data } = params;\n\n const sources = this.tableBundler.bundle({\n items: data.getItems()\n });\n\n const container = this.createSourceDataContainer();\n\n for (const bundle of sources.getBundles()) {\n /**\n * Need to fetch all the records from the source deployment tables.\n */\n const { items, error } = await this.fetcher.exec({\n deployment: bundle.source,\n table: bundle.table,\n items: bundle.items,\n maxBatchSize: 25\n });\n if (error) {\n console.error(\n `Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`\n );\n console.log(convertException(error));\n continue;\n }\n container.merge(items);\n }\n /**\n * We can now handle the records by going through all the items bundled by command, in correct order.\n */\n const bundlesByCommand = this.commandBundler.bundle({\n items: data.getItems()\n });\n for (const bundle of bundlesByCommand.getBundles()) {\n const deployments = this.deployments.without(bundle.source);\n for (const targetDeployment of deployments.all()) {\n /**\n * We need to map keys to actual items from the source deployment.\n */\n const items = bundle.items\n .map(item => {\n return container.get({\n PK: item.PK,\n SK: item.SK,\n table: bundle.table,\n source: bundle.source\n });\n })\n .filter((item): item is IStoreItem => !!item);\n\n const targetTable = this.findTargetTable({\n bundle,\n targetDeployment\n });\n if (!targetTable) {\n console.error(\n `Could not find target table for source table \"${bundle.table.name}\" in deployment \"${bundle.source.name}\".`\n );\n continue;\n }\n\n const result = await this.transformHandler.transform({\n items,\n sourceDeployment: bundle.source,\n sourceTable: bundle.table,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n\n let commandHandler: CommandHandlerPlugin;\n try {\n commandHandler = this.getCommandHandler(bundle.command);\n } catch (ex) {\n console.error(ex.message);\n continue;\n }\n\n await commandHandler.handle({\n storer: this.storer,\n items: result.items,\n bundle,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n }\n }\n }\n\n private findTargetTable(params: IFindTargetTableParams): ITable | null {\n const { bundle, targetDeployment } = params;\n\n try {\n return targetDeployment.getTable(bundle.table.type);\n } catch (ex) {\n return null;\n }\n }\n\n private getCommandHandler(command: CommandType): CommandHandlerPlugin {\n const handler = this.commandHandlerPlugins.find(plugin => plugin.canHandle(command));\n if (!handler) {\n throw new Error(`Could not find a command handler for command: ${command}`);\n }\n\n return handler;\n }\n}\n\nexport const createRecordHandler = (params: IRecordHandlerParams): IRecordHandler => {\n return new RecordHandler(params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AA2BO,MAAME,aAAa,CAA2B;EAW1CC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,MAAM,GAAGH,MAAM,CAACG,MAAM;IAC3B,IAAI,CAACC,cAAc,GAAGJ,MAAM,CAACI,cAAc;IAC3C,IAAI,CAACC,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAI,CAACC,WAAW,GAAGN,MAAM,CAACM,WAAW;IACrC,IAAI,CAACC,gBAAgB,GAAGP,MAAM,CAACO,gBAAgB;IAC/C,IAAI,CAACC,yBAAyB,GAAGR,MAAM,CAACQ,yBAAyB;IAEjE,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACR,OAAO,CAACS,MAAM,CAC5CC,0CAAoB,CAACC,IACzB,CAAC;EACL;EAEA,MAAaC,MAAMA,CAACb,MAAkC,EAAiB;IACnE,MAAM;MAAEc;IAAK,CAAC,GAAGd,MAAM;IAEvB,MAAMe,OAAO,GAAG,IAAI,CAACV,YAAY,CAACW,MAAM,CAAC;MACrCC,KAAK,EAAEH,IAAI,CAACI,QAAQ,CAAC;IACzB,CAAC,CAAC;IAEF,MAAMC,SAAS,GAAG,IAAI,CAACX,yBAAyB,CAAC,CAAC;IAElD,KAAK,MAAMQ,M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AC;IACvD,CAAC,CAAC,OAAOuC,EAAE,EAAE;MACT,OAAO,IAAI;IACf;EACJ;EAEQF,iBAAiBA,CAACC,OAAoB,EAAwB;IAClE,MAAMI,OAAO,GAAG,IAAI,CAAC7C,qBAAqB,CAAC8C,IAAI,CAACC,MAAM,IAAIA,MAAM,CAACC,SAAS,CAACP,OAAO,CAAC,CAAC;IACpF,IAAI,CAACI,OAAO,EAAE;MACV,MAAM,IAAII,KAAK,CAAC,iDAAiDR,OAAO,EAAE,CAAC;IAC/E;IAEA,OAAOI,OAAO;EAClB;AACJ;AAACK,OAAA,CAAA7D,aAAA,GAAAA,aAAA;AAEM,MAAM8D,mBAAmB,GAAI5D,MAA4B,IAAqB;EACjF,OAAO,IAAIF,aAAa,CAACE,MAAM,CAAC;AACpC,CAAC;AAAC2D,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CommandHandlerPlugin","convertException","RecordHandler","constructor","params","plugins","fetcher","storer","commandBundler","tableBundler","deployments","transformHandler","createSourceDataContainer","commandHandlerPlugins","byType","type","handle","data","sources","bundle","items","getItems","container","getBundles","error","exec","deployment","source","table","maxBatchSize","console","name","log","merge","bundlesByCommand","without","targetDeployment","all","map","item","get","PK","SK","filter","targetTable","findTargetTable","result","transform","sourceDeployment","sourceTable","commandHandler","getCommandHandler","command","ex","message","getTable","handler","find","plugin","canHandle","Error","createRecordHandler"],"sources":["RecordHandler.ts"],"sourcesContent":["import type { IRecordHandler, IRecordHandlerHandleParams } from \"./abstractions/RecordHandler.js\";\nimport { CommandHandlerPlugin } from \"../plugins/CommandHandlerPlugin.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { CommandType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IFetcher } from \"~/resolver/app/fetcher/types.js\";\nimport type { IStoreItem, IStorer } from \"~/resolver/app/storer/types.js\";\nimport type { IBundle, IBundler } from \"~/resolver/app/bundler/types.js\";\nimport type { IDeployment, IDeployments } from \"~/resolver/deployment/types.js\";\nimport type { ITransformHandler } from \"~/resolver/app/transform/TransformHandler.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { ISourceDataContainer } from \"~/resolver/app/data/types.js\";\n\nexport interface IRecordHandlerParams {\n fetcher: IFetcher;\n storer: IStorer;\n plugins: PluginsContainer;\n commandBundler: IBundler;\n tableBundler: IBundler;\n deployments: IDeployments;\n transformHandler: ITransformHandler;\n createSourceDataContainer: () => ISourceDataContainer;\n}\n\ninterface IFindTargetTableParams {\n bundle: IBundle;\n targetDeployment: IDeployment;\n}\n\nexport class RecordHandler implements IRecordHandler {\n private readonly plugins: PluginsContainer;\n private readonly commandHandlerPlugins: CommandHandlerPlugin[];\n private readonly fetcher: IFetcher;\n private readonly storer: IStorer;\n private readonly commandBundler: IBundler;\n private readonly tableBundler: IBundler;\n private readonly deployments: IDeployments;\n private readonly transformHandler: ITransformHandler;\n private readonly createSourceDataContainer: () => ISourceDataContainer;\n\n public constructor(params: IRecordHandlerParams) {\n this.plugins = params.plugins;\n this.fetcher = params.fetcher;\n this.storer = params.storer;\n this.commandBundler = params.commandBundler;\n this.tableBundler = params.tableBundler;\n this.deployments = params.deployments;\n this.transformHandler = params.transformHandler;\n this.createSourceDataContainer = params.createSourceDataContainer;\n\n this.commandHandlerPlugins = this.plugins.byType<CommandHandlerPlugin>(\n CommandHandlerPlugin.type\n );\n }\n\n public async handle(params: IRecordHandlerHandleParams): Promise<void> {\n const { data } = params;\n\n const sources = this.tableBundler.bundle({\n items: data.getItems()\n });\n\n const container = this.createSourceDataContainer();\n\n for (const bundle of sources.getBundles()) {\n /**\n * Need to fetch all the records from the source deployment tables.\n */\n const { items, error } = await this.fetcher.exec({\n deployment: bundle.source,\n table: bundle.table,\n items: bundle.items,\n maxBatchSize: 25\n });\n if (error) {\n console.error(\n `Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`\n );\n console.log(convertException(error));\n continue;\n }\n container.merge(items);\n }\n /**\n * We can now handle the records by going through all the items bundled by command, in correct order.\n */\n const bundlesByCommand = this.commandBundler.bundle({\n items: data.getItems()\n });\n for (const bundle of bundlesByCommand.getBundles()) {\n const deployments = this.deployments.without(bundle.source);\n for (const targetDeployment of deployments.all()) {\n /**\n * We need to map keys to actual items from the source deployment.\n */\n const items = bundle.items\n .map(item => {\n return container.get({\n PK: item.PK,\n SK: item.SK,\n table: bundle.table,\n source: bundle.source\n });\n })\n .filter((item): item is IStoreItem => !!item);\n\n const targetTable = this.findTargetTable({\n bundle,\n targetDeployment\n });\n if (!targetTable) {\n console.error(\n `Could not find target table for source table \"${bundle.table.name}\" in deployment \"${bundle.source.name}\".`\n );\n continue;\n }\n\n const result = await this.transformHandler.transform({\n items,\n sourceDeployment: bundle.source,\n sourceTable: bundle.table,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n\n let commandHandler: CommandHandlerPlugin;\n try {\n commandHandler = this.getCommandHandler(bundle.command);\n } catch (ex) {\n console.error(ex.message);\n continue;\n }\n\n await commandHandler.handle({\n storer: this.storer,\n items: result.items,\n bundle,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n }\n }\n }\n\n private findTargetTable(params: IFindTargetTableParams): ITable | null {\n const { bundle, targetDeployment } = params;\n\n try {\n return targetDeployment.getTable(bundle.table.type);\n } catch {\n return null;\n }\n }\n\n private getCommandHandler(command: CommandType): CommandHandlerPlugin {\n const handler = this.commandHandlerPlugins.find(plugin => plugin.canHandle(command));\n if (!handler) {\n throw new Error(`Could not find a command handler for command: ${command}`);\n }\n\n return handler;\n }\n}\n\nexport const createRecordHandler = (params: IRecordHandlerParams): IRecordHandler => {\n return new RecordHandler(params);\n};\n"],"mappings":"AACA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB,QAAQ,eAAe;AA2BhD,OAAO,MAAMC,aAAa,CAA2B;EAW1CC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC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12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createRecordsValidation = exports.RecordsValidation = void 0;
7
- var _utils = require("@webiny/utils");
8
- var _event = require("./validation/event.js");
9
- const validation = (0, _event.createEventValidation)();
10
- class RecordsValidation {
1
+ import { createZodError } from "@webiny/utils";
2
+ import { createEventValidation } from "./validation/event.js";
3
+ const validation = createEventValidation();
4
+ export class RecordsValidation {
11
5
  async validate(records) {
12
6
  const result = await validation.safeParseAsync(records);
13
7
  if (result.error) {
14
8
  return {
15
- error: (0, _utils.createZodError)(result.error)
9
+ error: createZodError(result.error)
16
10
  };
17
11
  }
18
12
  return {
@@ -20,10 +14,8 @@ class RecordsValidation {
20
14
  };
21
15
  }
22
16
  }
23
- exports.RecordsValidation = RecordsValidation;
24
- const createRecordsValidation = () => {
17
+ export const createRecordsValidation = () => {
25
18
  return new RecordsValidation();
26
19
  };
27
- exports.createRecordsValidation = createRecordsValidation;
28
20
 
29
21
  //# sourceMappingURL=RecordsValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_event","validation","createEventValidation","RecordsValidation","validate","records","result","safeParseAsync","error","createZodError","data","exports","createRecordsValidation"],"sources":["RecordsValidation.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport type {\n IRecordsValidation,\n IRecordsValidationResult\n} from \"./abstractions/RecordsValidation.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createEventValidation } from \"~/resolver/app/validation/event.js\";\n\nconst validation = createEventValidation();\n\nexport class RecordsValidation implements IRecordsValidation {\n public async validate(records: SQSRecord[]): Promise<IRecordsValidationResult> {\n const result = await validation.safeParseAsync(records);\n if (result.error) {\n return {\n error: createZodError(result.error)\n };\n }\n return {\n records: result.data\n };\n }\n}\n\nexport const createRecordsValidation = (): IRecordsValidation => {\n return new RecordsValidation();\n};\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAG,IAAAC,4BAAqB,EAAC,CAAC;AAEnC,MAAMC,iBAAiB,CAA+B;EACzD,MAAaC,QAAQA,CAACC,OAAoB,EAAqC;IAC3E,MAAMC,MAAM,GAAG,MAAML,UAAU,CAACM,cAAc,CAACF,OAAO,CAAC;IACvD,IAAIC,MAAM,CAACE,KAAK,EAAE;MACd,OAAO;QACHA,KAAK,EAAE,IAAAC,qBAAc,EAACH,MAAM,CAACE,KAAK;MACtC,CAAC;IACL;IACA,OAAO;MACHH,OAAO,EAAEC,MAAM,CAACI;IACpB,CAAC;EACL;AACJ;AAACC,OAAA,CAAAR,iBAAA,GAAAA,iBAAA;AAEM,MAAMS,uBAAuB,GAAGA,CAAA,KAA0B;EAC7D,OAAO,IAAIT,iBAAiB,CAAC,CAAC;AAClC,CAAC;AAACQ,OAAA,CAAAC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createZodError","createEventValidation","validation","RecordsValidation","validate","records","result","safeParseAsync","error","data","createRecordsValidation"],"sources":["RecordsValidation.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport type {\n IRecordsValidation,\n IRecordsValidationResult\n} from \"./abstractions/RecordsValidation.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createEventValidation } from \"~/resolver/app/validation/event.js\";\n\nconst validation = createEventValidation();\n\nexport class RecordsValidation implements IRecordsValidation {\n public async validate(records: SQSRecord[]): Promise<IRecordsValidationResult> {\n const result = await validation.safeParseAsync(records);\n if (result.error) {\n return {\n error: createZodError(result.error)\n };\n }\n return {\n records: result.data\n };\n }\n}\n\nexport const createRecordsValidation = (): IRecordsValidation => {\n return new RecordsValidation();\n};\n"],"mappings":"AAKA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,qBAAqB;AAE9B,MAAMC,UAAU,GAAGD,qBAAqB,CAAC,CAAC;AAE1C,OAAO,MAAME,iBAAiB,CAA+B;EACzD,MAAaC,QAAQA,CAACC,OAAoB,EAAqC;IAC3E,MAAMC,MAAM,GAAG,MAAMJ,UAAU,CAACK,cAAc,CAACF,OAAO,CAAC;IACvD,IAAIC,MAAM,CAACE,KAAK,EAAE;MACd,OAAO;QACHA,KAAK,EAAER,cAAc,CAACM,MAAM,CAACE,KAAK;MACtC,CAAC;IACL;IACA,OAAO;MACHH,OAAO,EAAEC,MAAM,CAACG;IACpB,CAAC;EACL;AACJ;AAEA,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAA0B;EAC7D,OAAO,IAAIP,iBAAiB,CAAC,CAAC;AAClC,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { IResolverApplication, IResolverApplicationResolveParams } from "./abstractions/ResolverApplication.js";
2
2
  import type { IRecordHandler } from "./abstractions/RecordHandler.js";
3
- import type { IDeployments } from "../deployment/types.js";
3
+ import type { IDeployments } from "../../resolver/deployment/types.js";
4
4
  export interface IResolverApplicationParams {
5
5
  recordHandler: IRecordHandler;
6
6
  deployments: IDeployments;
@@ -1,27 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createResolverApp = exports.ResolverApplication = void 0;
7
- var _RecordsValidation = require("./RecordsValidation.js");
8
- var _utils = require("@webiny/utils");
9
- var _Ingestor = require("./ingestor/Ingestor.js");
10
- var _IngestorResult = require("./ingestor/IngestorResult.js");
11
- class ResolverApplication {
1
+ import { createRecordsValidation } from "./RecordsValidation.js";
2
+ import { convertException } from "@webiny/utils";
3
+ import { createIngestor } from "./ingestor/Ingestor.js";
4
+ import { createIngestorResult } from "./ingestor/IngestorResult.js";
5
+ export class ResolverApplication {
12
6
  constructor(params) {
13
7
  this.recordHandler = params.recordHandler;
14
8
  this.deployments = params.deployments;
15
9
  }
16
10
  async resolve(params) {
17
- const validation = (0, _RecordsValidation.createRecordsValidation)();
11
+ const validation = createRecordsValidation();
18
12
  const result = await validation.validate(params.records);
19
13
  if (result.error) {
20
14
  throw result.error;
21
15
  }
22
- const ingestor = (0, _Ingestor.createIngestor)({
16
+ const ingestor = createIngestor({
23
17
  createIngestorResult: () => {
24
- return (0, _IngestorResult.createIngestorResult)();
18
+ return createIngestorResult();
25
19
  },
26
20
  getSource: name => {
27
21
  return this.deployments.get(name);
@@ -35,14 +29,12 @@ class ResolverApplication {
35
29
  data
36
30
  });
37
31
  } catch (ex) {
38
- console.error((0, _utils.convertException)(ex));
32
+ console.error(convertException(ex));
39
33
  }
40
34
  }
41
35
  }
42
- exports.ResolverApplication = ResolverApplication;
43
- const createResolverApp = params => {
36
+ export const createResolverApp = params => {
44
37
  return new ResolverApplication(params);
45
38
  };
46
- exports.createResolverApp = createResolverApp;
47
39
 
48
40
  //# sourceMappingURL=ResolverApplication.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_RecordsValidation","require","_utils","_Ingestor","_IngestorResult","ResolverApplication","constructor","params","recordHandler","deployments","resolve","validation","createRecordsValidation","result","validate","records","error","ingestor","createIngestor","createIngestorResult","getSource","name","get","data","ingest","handle","ex","console","convertException","exports","createResolverApp"],"sources":["ResolverApplication.ts"],"sourcesContent":["import type {\n IResolverApplication,\n IResolverApplicationResolveParams\n} from \"./abstractions/ResolverApplication.js\";\nimport { createRecordsValidation } from \"./RecordsValidation.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IRecordHandler } from \"./abstractions/RecordHandler.js\";\nimport type { IDeployments } from \"~/resolver/deployment/types.js\";\nimport { createIngestor } from \"./ingestor/Ingestor.js\";\nimport { createIngestorResult } from \"~/resolver/app/ingestor/IngestorResult.js\";\n\nexport interface IResolverApplicationParams {\n recordHandler: IRecordHandler;\n deployments: IDeployments;\n}\n\nexport class ResolverApplication implements IResolverApplication {\n private readonly recordHandler: IRecordHandler;\n private readonly deployments: IDeployments;\n\n public constructor(params: IResolverApplicationParams) {\n this.recordHandler = params.recordHandler;\n this.deployments = params.deployments;\n }\n\n public async resolve(params: IResolverApplicationResolveParams): Promise<void> {\n const validation = createRecordsValidation();\n\n const result = await validation.validate(params.records);\n if (result.error) {\n throw result.error;\n }\n\n const ingestor = createIngestor({\n createIngestorResult: () => {\n return createIngestorResult();\n },\n getSource: name => {\n return this.deployments.get(name);\n }\n });\n\n const data = await ingestor.ingest({\n records: result.records\n });\n\n try {\n await this.recordHandler.handle({\n data\n });\n } catch (ex) {\n console.error(convertException(ex));\n }\n }\n}\n\nexport const createResolverApp = (params: IResolverApplicationParams): IResolverApplication => {\n return new ResolverApplication(params);\n};\n"],"mappings":";;;;;;AAIA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAOO,MAAMI,mBAAmB,CAAiC;EAItDC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa;IACzC,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAACH,MAAyC,EAAiB;IAC3E,MAAMI,UAAU,GAAG,IAAAC,0CAAuB,EAAC,CAAC;IAE5C,MAAMC,MAAM,GAAG,MAAMF,UAAU,CAACG,QAAQ,CAACP,MAAM,CAACQ,OAAO,CAAC;IACxD,IAAIF,MAAM,CAACG,KAAK,EAAE;MACd,MAAMH,MAAM,CAACG,KAAK;IACtB;IAEA,MAAMC,QAAQ,GAAG,IAAAC,wBAAc,EAAC;MAC5BC,oBAAoB,EAAEA,CAAA,KAAM;QACxB,OAAO,IAAAA,oCAAoB,EAAC,CAAC;MACjC,CAAC;MACDC,SAAS,EAAEC,IAAI,IAAI;QACf,OAAO,IAAI,CAACZ,WAAW,CAACa,GAAG,CAACD,IAAI,CAAC;MACrC;IACJ,CAAC,CAAC;IAEF,MAAME,IAAI,GAAG,MAAMN,QAAQ,CAACO,MAAM,CAAC;MAC/BT,OAAO,EAAEF,MAAM,CAACE;IACpB,CAAC,CAAC;IAEF,IAAI;MACA,MAAM,IAAI,CAACP,aAAa,CAACiB,MAAM,CAAC;QAC5BF;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTC,OAAO,CAACX,KAAK,CAAC,IAAAY,uBAAgB,EAACF,EAAE,CAAC,CAAC;IACvC;EACJ;AACJ;AAACG,OAAA,CAAAxB,mBAAA,GAAAA,mBAAA;AAEM,MAAMyB,iBAAiB,GAAIvB,MAAkC,IAA2B;EAC3F,OAAO,IAAIF,mBAAmB,CAACE,MAAM,CAAC;AAC1C,CAAC;AAACsB,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createRecordsValidation","convertException","createIngestor","createIngestorResult","ResolverApplication","constructor","params","recordHandler","deployments","resolve","validation","result","validate","records","error","ingestor","getSource","name","get","data","ingest","handle","ex","console","createResolverApp"],"sources":["ResolverApplication.ts"],"sourcesContent":["import type {\n IResolverApplication,\n IResolverApplicationResolveParams\n} from \"./abstractions/ResolverApplication.js\";\nimport { createRecordsValidation } from \"./RecordsValidation.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IRecordHandler } from \"./abstractions/RecordHandler.js\";\nimport type { IDeployments } from \"~/resolver/deployment/types.js\";\nimport { createIngestor } from \"./ingestor/Ingestor.js\";\nimport { createIngestorResult } from \"~/resolver/app/ingestor/IngestorResult.js\";\n\nexport interface IResolverApplicationParams {\n recordHandler: IRecordHandler;\n deployments: IDeployments;\n}\n\nexport class ResolverApplication implements IResolverApplication {\n private readonly recordHandler: IRecordHandler;\n private readonly deployments: IDeployments;\n\n public constructor(params: IResolverApplicationParams) {\n this.recordHandler = params.recordHandler;\n this.deployments = params.deployments;\n }\n\n public async resolve(params: IResolverApplicationResolveParams): Promise<void> {\n const validation = createRecordsValidation();\n\n const result = await validation.validate(params.records);\n if (result.error) {\n throw result.error;\n }\n\n const ingestor = createIngestor({\n createIngestorResult: () => {\n return createIngestorResult();\n },\n getSource: name => {\n return this.deployments.get(name);\n }\n });\n\n const data = await ingestor.ingest({\n records: result.records\n });\n\n try {\n await this.recordHandler.handle({\n data\n });\n } catch (ex) {\n console.error(convertException(ex));\n }\n }\n}\n\nexport const createResolverApp = (params: IResolverApplicationParams): IResolverApplication => {\n return new ResolverApplication(params);\n};\n"],"mappings":"AAIA,SAASA,uBAAuB;AAChC,SAASC,gBAAgB,QAAQ,eAAe;AAGhD,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAO7B,OAAO,MAAMC,mBAAmB,CAAiC;EAItDC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa;IACzC,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAACH,MAAyC,EAAiB;IAC3E,MAAMI,UAAU,GAAGV,uBAAuB,CAAC,CAAC;IAE5C,MAAMW,MAAM,GAAG,MAAMD,UAAU,CAACE,QAAQ,CAACN,MAAM,CAACO,OAAO,CAAC;IACxD,IAAIF,MAAM,CAACG,KAAK,EAAE;MACd,MAAMH,MAAM,CAACG,KAAK;IACtB;IAEA,MAAMC,QAAQ,GAAGb,cAAc,CAAC;MAC5BC,oBAAoB,EAAEA,CAAA,KAAM;QACxB,OAAOA,oBAAoB,CAAC,CAAC;MACjC,CAAC;MACDa,SAAS,EAAEC,IAAI,IAAI;QACf,OAAO,IAAI,CAACT,WAAW,CAACU,GAAG,CAACD,IAAI,CAAC;MACrC;IACJ,CAAC,CAAC;IAEF,MAAME,IAAI,GAAG,MAAMJ,QAAQ,CAACK,MAAM,CAAC;MAC/BP,OAAO,EAAEF,MAAM,CAACE;IACpB,CAAC,CAAC;IAEF,IAAI;MACA,MAAM,IAAI,CAACN,aAAa,CAACc,MAAM,CAAC;QAC5BF;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTC,OAAO,CAACT,KAAK,CAACb,gBAAgB,CAACqB,EAAE,CAAC,CAAC;IACvC;EACJ;AACJ;AAEA,OAAO,MAAME,iBAAiB,GAAIlB,MAAkC,IAA2B;EAC3F,OAAO,IAAIF,mBAAmB,CAACE,MAAM,CAAC;AAC1C,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { IIngestorResult } from "../ingestor/types.js";
1
+ import type { IIngestorResult } from "../../../resolver/app/ingestor/types.js";
2
2
  export interface IRecordHandlerHandleParams {
3
3
  data: IIngestorResult;
4
4
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=RecordHandler.js.map
@@ -1,5 +1,5 @@
1
- import type { SQSRecord } from "@webiny/aws-sdk/types";
2
- import type { IResolverSQSRecord } from "./ResolverRecord.js";
1
+ import type { SQSRecord } from "@webiny/aws-sdk/types/index.js";
2
+ import type { IResolverSQSRecord } from "../../../resolver/app/abstractions/ResolverRecord.js";
3
3
  export interface IRecordsValidationValid {
4
4
  records: IResolverSQSRecord[];
5
5
  error?: never;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=RecordsValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["RecordsValidation.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types\";\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
+ {"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,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=ResolverApplication.js.map
@@ -7,7 +7,7 @@ export interface IResolverRecordBodyItem {
7
7
  SK: string;
8
8
  command: ExtendedCommandType;
9
9
  /**
10
- * There will be multiple tables that will get populated through the system (regular table and elasticsearch for start).
10
+ * There will be multiple tables that will get populated through the system (regular table and opensearch for start).
11
11
  */
12
12
  tableName: string;
13
13
  tableType: DynamoDBTableType;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=ResolverRecord.js.map
@@ -1 +1 @@
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 elasticsearch 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
+ {"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,9 +1,9 @@
1
- import type { IBundle, IBundleItem } from "./types.js";
2
- import type { IDeployment } from "../../deployment/types";
3
- import type { ITable } from "../../../sync/types";
4
- import type { CommandType } from "../../../types";
5
- import { type ExtendedCommandType } from "../../../types";
6
- import type { IIngestorResultItem } from "../ingestor/types";
1
+ import type { IBundle, IBundleItem } from "../../../resolver/app/bundler/types.js";
2
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
3
+ import type { ITable } from "../../../sync/types.js";
4
+ import type { CommandType } from "../../../types.js";
5
+ import { type ExtendedCommandType } from "../../../types.js";
6
+ import type { IIngestorResultItem } from "../ingestor/types.js";
7
7
  export interface IBaseBundleParams {
8
8
  command: ExtendedCommandType;
9
9
  table: ITable;