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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/README.md +6 -108
  2. package/constants.js +2 -7
  3. package/constants.js.map +1 -1
  4. package/index.js +3 -40
  5. package/package.json +29 -26
  6. package/resolver/app/RecordHandler.d.ts +6 -6
  7. package/resolver/app/RecordHandler.js +84 -114
  8. package/resolver/app/RecordHandler.js.map +1 -1
  9. package/resolver/app/RecordsValidation.js +13 -24
  10. package/resolver/app/RecordsValidation.js.map +1 -1
  11. package/resolver/app/ResolverApplication.d.ts +1 -1
  12. package/resolver/app/ResolverApplication.js +27 -42
  13. package/resolver/app/ResolverApplication.js.map +1 -1
  14. package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
  15. package/resolver/app/abstractions/RecordHandler.js +0 -7
  16. package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
  17. package/resolver/app/abstractions/RecordsValidation.js +0 -7
  18. package/resolver/app/abstractions/ResolverApplication.js +0 -7
  19. package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
  20. package/resolver/app/abstractions/ResolverRecord.js +0 -7
  21. package/resolver/app/bundler/BaseBundle.d.ts +6 -6
  22. package/resolver/app/bundler/BaseBundle.js +16 -22
  23. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  24. package/resolver/app/bundler/Bundler.d.ts +1 -1
  25. package/resolver/app/bundler/Bundler.js +12 -25
  26. package/resolver/app/bundler/Bundler.js.map +1 -1
  27. package/resolver/app/bundler/Bundles.d.ts +2 -2
  28. package/resolver/app/bundler/Bundles.js +20 -33
  29. package/resolver/app/bundler/Bundles.js.map +1 -1
  30. package/resolver/app/bundler/CommandBundle.d.ts +1 -1
  31. package/resolver/app/bundler/CommandBundle.js +8 -25
  32. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  33. package/resolver/app/bundler/TableBundle.d.ts +1 -1
  34. package/resolver/app/bundler/TableBundle.js +7 -22
  35. package/resolver/app/bundler/TableBundle.js.map +1 -1
  36. package/resolver/app/bundler/types.d.ts +2 -2
  37. package/resolver/app/bundler/types.js +0 -7
  38. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
  39. package/resolver/app/commandHandler/DeleteCommandHandler.js +21 -35
  40. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  41. package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
  42. package/resolver/app/commandHandler/PutCommandHandler.js +15 -28
  43. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  44. package/resolver/app/commandHandler/delete.d.ts +1 -1
  45. package/resolver/app/commandHandler/delete.js +13 -21
  46. package/resolver/app/commandHandler/delete.js.map +1 -1
  47. package/resolver/app/commandHandler/put.d.ts +1 -1
  48. package/resolver/app/commandHandler/put.js +13 -21
  49. package/resolver/app/commandHandler/put.js.map +1 -1
  50. package/resolver/app/data/SourceDataContainer.d.ts +3 -3
  51. package/resolver/app/data/SourceDataContainer.js +27 -36
  52. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  53. package/resolver/app/data/types.d.ts +2 -2
  54. package/resolver/app/data/types.js +0 -7
  55. package/resolver/app/fetcher/Fetcher.d.ts +3 -3
  56. package/resolver/app/fetcher/Fetcher.js +87 -121
  57. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  58. package/resolver/app/fetcher/types.d.ts +2 -2
  59. package/resolver/app/fetcher/types.js +0 -7
  60. package/resolver/app/ingestor/Ingestor.d.ts +1 -1
  61. package/resolver/app/ingestor/Ingestor.js +26 -39
  62. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  63. package/resolver/app/ingestor/IngestorResult.js +27 -39
  64. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  65. package/resolver/app/ingestor/types.d.ts +2 -2
  66. package/resolver/app/ingestor/types.js +0 -7
  67. package/resolver/app/storer/Storer.d.ts +3 -3
  68. package/resolver/app/storer/Storer.js +73 -95
  69. package/resolver/app/storer/Storer.js.map +1 -1
  70. package/resolver/app/storer/types.d.ts +2 -2
  71. package/resolver/app/storer/types.js +0 -7
  72. package/resolver/app/transform/TransformHandler.d.ts +4 -4
  73. package/resolver/app/transform/TransformHandler.js +46 -64
  74. package/resolver/app/transform/TransformHandler.js.map +1 -1
  75. package/resolver/app/transform/middleware.d.ts +1 -1
  76. package/resolver/app/transform/middleware.js +12 -25
  77. package/resolver/app/transform/middleware.js.map +1 -1
  78. package/resolver/app/utils/Retry.js +21 -32
  79. package/resolver/app/utils/Retry.js.map +1 -1
  80. package/resolver/app/utils/sleep.js +4 -12
  81. package/resolver/app/utils/sleep.js.map +1 -1
  82. package/resolver/app/validation/body.d.ts +25 -124
  83. package/resolver/app/validation/body.js +31 -44
  84. package/resolver/app/validation/body.js.map +1 -1
  85. package/resolver/app/validation/createJsonTransform.d.ts +1 -1
  86. package/resolver/app/validation/createJsonTransform.js +13 -22
  87. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  88. package/resolver/app/validation/detail.d.ts +19 -72
  89. package/resolver/app/validation/detail.js +33 -46
  90. package/resolver/app/validation/detail.js.map +1 -1
  91. package/resolver/app/validation/event.d.ts +29 -188
  92. package/resolver/app/validation/event.js +21 -30
  93. package/resolver/app/validation/event.js.map +1 -1
  94. package/resolver/app/validation/numericString.d.ts +1 -1
  95. package/resolver/app/validation/numericString.js +9 -20
  96. package/resolver/app/validation/numericString.js.map +1 -1
  97. package/resolver/app/validation/system.d.ts +2 -14
  98. package/resolver/app/validation/system.js +9 -18
  99. package/resolver/app/validation/system.js.map +1 -1
  100. package/resolver/createEventHandlerPlugin.d.ts +2 -1
  101. package/resolver/createEventHandlerPlugin.js +85 -121
  102. package/resolver/createEventHandlerPlugin.js.map +1 -1
  103. package/resolver/createResolverHandler.d.ts +1 -1
  104. package/resolver/createResolverHandler.js +60 -75
  105. package/resolver/createResolverHandler.js.map +1 -1
  106. package/resolver/deployment/Deployment.d.ts +2 -3
  107. package/resolver/deployment/Deployment.js +27 -44
  108. package/resolver/deployment/Deployment.js.map +1 -1
  109. package/resolver/deployment/Deployments.js +19 -30
  110. package/resolver/deployment/Deployments.js.map +1 -1
  111. package/resolver/deployment/DeploymentsFetcher.js +82 -102
  112. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  113. package/resolver/deployment/types.d.ts +4 -6
  114. package/resolver/deployment/types.js +0 -7
  115. package/resolver/lambda/LambdaTrigger.js +25 -34
  116. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  117. package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
  118. package/resolver/plugins/CommandHandlerPlugin.js +17 -24
  119. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  120. package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
  121. package/resolver/plugins/StorerAfterEachPlugin.js +21 -29
  122. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  123. package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
  124. package/resolver/plugins/TransformRecordPlugin.js +20 -27
  125. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  126. package/resolver/recordTypes/fileManager/CopyFile.js +44 -74
  127. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  128. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
  129. package/resolver/recordTypes/fileManager/DeleteFile.js +40 -65
  130. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  131. package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
  132. package/resolver/recordTypes/fileManager/fileManager.js +7 -12
  133. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  134. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
  135. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +27 -45
  136. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  137. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
  138. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +27 -45
  139. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  140. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
  141. package/resolver/recordTypes/fileManager/shouldBeHandled.js +10 -34
  142. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  143. package/resolver/recordTypes/fileManager/types.d.ts +2 -2
  144. package/resolver/recordTypes/fileManager/types.js +0 -7
  145. package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
  146. package/resolver/recordTypes/users/CopyUser.js +44 -61
  147. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  148. package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
  149. package/resolver/recordTypes/users/DeleteUser.js +40 -58
  150. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  151. package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
  152. package/resolver/recordTypes/users/shouldBeHandled.js +10 -33
  153. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  154. package/resolver/recordTypes/users/types.d.ts +1 -1
  155. package/resolver/recordTypes/users/types.js +0 -7
  156. package/resolver/recordTypes/users/users.js +7 -12
  157. package/resolver/recordTypes/users/users.js.map +1 -1
  158. package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
  159. package/resolver/recordTypes/users/usersOnDelete.js +26 -44
  160. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  161. package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
  162. package/resolver/recordTypes/users/usersOnPut.js +27 -45
  163. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  164. package/sync/FilterOutRecord.d.ts +2 -2
  165. package/sync/FilterOutRecord.js +8 -24
  166. package/sync/FilterOutRecord.js.map +1 -1
  167. package/sync/attachToDynamoDbDocument.d.ts +1 -1
  168. package/sync/attachToDynamoDbDocument.js +48 -75
  169. package/sync/attachToDynamoDbDocument.js.map +1 -1
  170. package/sync/createHandler.js +44 -60
  171. package/sync/createHandler.js.map +1 -1
  172. package/sync/createSendDataToEventBridgeOnRequestEnd.js +34 -46
  173. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
  174. package/sync/createSyncSystem.d.ts +1 -1
  175. package/sync/createSyncSystem.js +27 -36
  176. package/sync/createSyncSystem.js.map +1 -1
  177. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
  178. package/sync/filter/createDefaultFilterOutRecordPlugins.js +37 -86
  179. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  180. package/sync/handler/Handler.d.ts +2 -2
  181. package/sync/handler/Handler.js +66 -86
  182. package/sync/handler/Handler.js.map +1 -1
  183. package/sync/handler/HandlerConverter.js +20 -36
  184. package/sync/handler/HandlerConverter.js.map +1 -1
  185. package/sync/handler/converter/BatchGetCommandConverter.js +13 -20
  186. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  187. package/sync/handler/converter/BatchWriteCommandConverter.js +13 -20
  188. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  189. package/sync/handler/converter/DeleteCommandConverter.js +13 -20
  190. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  191. package/sync/handler/converter/GetCommandConverter.js +13 -20
  192. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  193. package/sync/handler/converter/PutCommandConverter.js +13 -20
  194. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  195. package/sync/handler/converter/QueryCommandConverter.js +13 -20
  196. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  197. package/sync/handler/converter/ScanCommandConverter.js +13 -20
  198. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  199. package/sync/handler/converter/UpdateCommandConverter.js +13 -20
  200. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  201. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
  202. package/sync/handler/converter/commands/BatchWriteCommandValue.js +34 -44
  203. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  204. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
  205. package/sync/handler/converter/commands/DeleteCommandValue.js +19 -23
  206. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  207. package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
  208. package/sync/handler/converter/commands/NullCommandValue.js +7 -14
  209. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  210. package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
  211. package/sync/handler/converter/commands/PutCommandValue.js +19 -23
  212. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  213. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
  214. package/sync/handler/converter/commands/UpdateCommandValue.js +19 -23
  215. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  216. package/sync/handler/types.d.ts +3 -3
  217. package/sync/handler/types.js +0 -7
  218. package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
  219. package/sync/plugins/FilterOutRecordPlugin.js +18 -28
  220. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  221. package/sync/requestPlugin.d.ts +1 -1
  222. package/sync/requestPlugin.js +39 -55
  223. package/sync/requestPlugin.js.map +1 -1
  224. package/sync/types.js +0 -7
  225. package/sync/utils/getTableType.js +11 -19
  226. package/sync/utils/getTableType.js.map +1 -1
  227. package/sync/utils/manifest.d.ts +3 -7
  228. package/sync/utils/manifest.js +30 -47
  229. package/sync/utils/manifest.js.map +1 -1
  230. package/sync/utils/validateSystemInput.d.ts +1 -1
  231. package/sync/utils/validateSystemInput.js +22 -37
  232. package/sync/utils/validateSystemInput.js.map +1 -1
  233. package/types.d.ts +3 -5
  234. package/types.js +6 -12
  235. package/types.js.map +1 -1
  236. package/utils/createSystemName.js +5 -10
  237. package/utils/createSystemName.js.map +1 -1
  238. package/worker/actions/copyFile/CopyFile.js +185 -268
  239. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  240. package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
  241. package/worker/actions/copyFile/copyFileAction.js +30 -45
  242. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  243. package/worker/actions/copyFile/copyFileSchema.d.ts +6 -38
  244. package/worker/actions/copyFile/copyFileSchema.js +14 -23
  245. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  246. package/worker/actions/copyFile/types.js +0 -7
  247. package/worker/actions/createUser/CreateUser.d.ts +1 -1
  248. package/worker/actions/createUser/CreateUser.js +53 -83
  249. package/worker/actions/createUser/CreateUser.js.map +1 -1
  250. package/worker/actions/createUser/createUserAction.d.ts +2 -2
  251. package/worker/actions/createUser/createUserAction.js +28 -39
  252. package/worker/actions/createUser/createUserAction.js.map +1 -1
  253. package/worker/actions/createUser/createUserSchema.d.ts +6 -38
  254. package/worker/actions/createUser/createUserSchema.js +14 -23
  255. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  256. package/worker/actions/createUser/types.js +0 -7
  257. package/worker/actions/deleteFile/DeleteFile.js +52 -74
  258. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  259. package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
  260. package/worker/actions/deleteFile/deleteFileAction.js +25 -40
  261. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  262. package/worker/actions/deleteFile/deleteFileSchema.d.ts +6 -38
  263. package/worker/actions/deleteFile/deleteFileSchema.js +14 -23
  264. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  265. package/worker/actions/deleteFile/types.js +0 -7
  266. package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
  267. package/worker/actions/deleteUser/DeleteUser.js +39 -60
  268. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  269. package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
  270. package/worker/actions/deleteUser/deleteUserAction.js +26 -37
  271. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  272. package/worker/actions/deleteUser/deleteUserSchema.d.ts +5 -23
  273. package/worker/actions/deleteUser/deleteUserSchema.js +13 -22
  274. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  275. package/worker/actions/deleteUser/types.js +0 -7
  276. package/worker/actions/logValidationError.js +6 -14
  277. package/worker/actions/logValidationError.js.map +1 -1
  278. package/worker/actions/removeCognitoUserAttributes.js +9 -22
  279. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  280. package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
  281. package/worker/actions/updateUser/UpdateUser.js +50 -74
  282. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  283. package/worker/actions/updateUser/types.js +0 -7
  284. package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
  285. package/worker/actions/updateUser/updateUserAction.js +28 -39
  286. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  287. package/worker/actions/updateUser/updateUserSchema.d.ts +6 -38
  288. package/worker/actions/updateUser/updateUserSchema.js +14 -23
  289. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  290. package/worker/createWorkerHandler.js +32 -45
  291. package/worker/createWorkerHandler.js.map +1 -1
  292. package/worker/handler/WorkerActionHandler.d.ts +2 -2
  293. package/worker/handler/WorkerActionHandler.js +19 -28
  294. package/worker/handler/WorkerActionHandler.js.map +1 -1
  295. package/worker/handler/eventHandler.js +18 -27
  296. package/worker/handler/eventHandler.js.map +1 -1
  297. package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
  298. package/worker/plugins/WorkerActionPlugin.js +18 -25
  299. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  300. package/worker/types.js +0 -7
  301. package/index.js.map +0 -1
  302. package/resolver/app/abstractions/RecordHandler.js.map +0 -1
  303. package/resolver/app/abstractions/RecordsValidation.js.map +0 -1
  304. package/resolver/app/abstractions/ResolverApplication.js.map +0 -1
  305. package/resolver/app/abstractions/ResolverRecord.js.map +0 -1
  306. package/resolver/app/bundler/types.js.map +0 -1
  307. package/resolver/app/data/types.js.map +0 -1
  308. package/resolver/app/fetcher/types.js.map +0 -1
  309. package/resolver/app/ingestor/types.js.map +0 -1
  310. package/resolver/app/storer/types.js.map +0 -1
  311. package/resolver/deployment/types.js.map +0 -1
  312. package/resolver/recordTypes/fileManager/types.js.map +0 -1
  313. package/resolver/recordTypes/users/types.js.map +0 -1
  314. package/sync/handler/types.js.map +0 -1
  315. package/sync/types.js.map +0 -1
  316. package/worker/actions/copyFile/types.js.map +0 -1
  317. package/worker/actions/createUser/types.js.map +0 -1
  318. package/worker/actions/deleteFile/types.js.map +0 -1
  319. package/worker/actions/deleteUser/types.js.map +0 -1
  320. package/worker/actions/updateUser/types.js.map +0 -1
  321. package/worker/types.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import type { IStoreItem, IStorer } from "../storer/types";
2
- import type { ITable } from "../../../sync/types";
3
- import type { IDeployment } from "../../deployment/types.js";
4
- import type { IBundle } from "../bundler/types.js";
1
+ import type { IStoreItem, IStorer } from "../storer/types.js";
2
+ import type { ITable } from "../../../sync/types.js";
3
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
4
+ import type { IBundle } from "../../../resolver/app/bundler/types.js";
5
5
  export interface IPutCommandHandlerHandleParams {
6
6
  items: IStoreItem[];
7
7
  bundle: IBundle;
@@ -1,32 +1,19 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PutCommandHandler = void 0;
7
1
  class PutCommandHandler {
8
- constructor(params) {
9
- this.storer = params.storer;
10
- }
11
- async handle(params) {
12
- const {
13
- items,
14
- targetDeployment,
15
- targetTable,
16
- bundle
17
- } = params;
18
- const result = items.filter(item => {
19
- return !!item.PK && !!item.SK;
20
- });
21
- await this.storer.store({
22
- command: "put",
23
- deployment: targetDeployment,
24
- table: targetTable,
25
- items: result,
26
- bundle
27
- });
28
- }
2
+ constructor(params){
3
+ this.storer = params.storer;
4
+ }
5
+ async handle(params) {
6
+ const { items, targetDeployment, targetTable, bundle } = params;
7
+ const result = items.filter((item)=>!!item.PK && !!item.SK);
8
+ await this.storer.store({
9
+ command: "put",
10
+ deployment: targetDeployment,
11
+ table: targetTable,
12
+ items: result,
13
+ bundle
14
+ });
15
+ }
29
16
  }
30
- exports.PutCommandHandler = PutCommandHandler;
17
+ export { PutCommandHandler };
31
18
 
32
19
  //# sourceMappingURL=PutCommandHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PutCommandHandler","constructor","params","storer","handle","items","targetDeployment","targetTable","bundle","result","filter","item","PK","SK","store","command","deployment","table","exports"],"sources":["PutCommandHandler.ts"],"sourcesContent":["import type { IStoreItem, IStorer } from \"../storer/types\";\nimport type { ITable } from \"~/sync/types\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { IBundle } from \"~/resolver/app/bundler/types.js\";\n\nexport interface IPutCommandHandlerHandleParams {\n items: IStoreItem[];\n bundle: IBundle;\n targetDeployment: IDeployment;\n targetTable: ITable;\n}\n\nexport interface IPutCommandHandlerParams {\n storer: IStorer;\n}\n\nexport class PutCommandHandler {\n private readonly storer: IStorer;\n\n public constructor(params: IPutCommandHandlerParams) {\n this.storer = params.storer;\n }\n\n public async handle(params: IPutCommandHandlerHandleParams): Promise<void> {\n const { items, targetDeployment, targetTable, bundle } = params;\n\n const result = items.filter(item => {\n return !!item.PK && !!item.SK;\n });\n\n await this.storer.store({\n command: \"put\",\n deployment: targetDeployment,\n table: targetTable,\n items: result,\n bundle\n });\n }\n}\n"],"mappings":";;;;;;AAgBO,MAAMA,iBAAiB,CAAC;EAGpBC,WAAWA,CAACC,MAAgC,EAAE;IACjD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,MAAMA,CAACF,MAAsC,EAAiB;IACvE,MAAM;MAAEG,KAAK;MAAEC,gBAAgB;MAAEC,WAAW;MAAEC;IAAO,CAAC,GAAGN,MAAM;IAE/D,MAAMO,MAAM,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,IAAI;MAChC,OAAO,CAAC,CAACA,IAAI,CAACC,EAAE,IAAI,CAAC,CAACD,IAAI,CAACE,EAAE;IACjC,CAAC,CAAC;IAEF,MAAM,IAAI,CAACV,MAAM,CAACW,KAAK,CAAC;MACpBC,OAAO,EAAE,KAAK;MACdC,UAAU,EAAEV,gBAAgB;MAC5BW,KAAK,EAAEV,WAAW;MAClBF,KAAK,EAAEI,MAAM;MACbD;IACJ,CAAC,CAAC;EACN;AACJ;AAACU,OAAA,CAAAlB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"resolver/app/commandHandler/PutCommandHandler.js","sources":["../../../../src/resolver/app/commandHandler/PutCommandHandler.ts"],"sourcesContent":["import type { IStoreItem, IStorer } from \"../storer/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { IBundle } from \"~/resolver/app/bundler/types.js\";\n\nexport interface IPutCommandHandlerHandleParams {\n items: IStoreItem[];\n bundle: IBundle;\n targetDeployment: IDeployment;\n targetTable: ITable;\n}\n\nexport interface IPutCommandHandlerParams {\n storer: IStorer;\n}\n\nexport class PutCommandHandler {\n private readonly storer: IStorer;\n\n public constructor(params: IPutCommandHandlerParams) {\n this.storer = params.storer;\n }\n\n public async handle(params: IPutCommandHandlerHandleParams): Promise<void> {\n const { items, targetDeployment, targetTable, bundle } = params;\n\n const result = items.filter(item => {\n return !!item.PK && !!item.SK;\n });\n\n await this.storer.store({\n command: \"put\",\n deployment: targetDeployment,\n table: targetTable,\n items: result,\n bundle\n });\n }\n}\n"],"names":["PutCommandHandler","params","items","targetDeployment","targetTable","bundle","result","item"],"mappings":"AAgBO,MAAMA;IAGT,YAAmBC,MAAgC,CAAE;QACjD,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;IAEA,MAAa,OAAOA,MAAsC,EAAiB;QACvE,MAAM,EAAEC,KAAK,EAAEC,gBAAgB,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGJ;QAEzD,MAAMK,SAASJ,MAAM,MAAM,CAACK,CAAAA,OACjB,CAAC,CAACA,KAAK,EAAE,IAAI,CAAC,CAACA,KAAK,EAAE;QAGjC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACpB,SAAS;YACT,YAAYJ;YACZ,OAAOC;YACP,OAAOE;YACPD;QACJ;IACJ;AACJ"}
@@ -1,2 +1,2 @@
1
- import { CommandHandlerPlugin } from "../../plugins/CommandHandlerPlugin.js";
1
+ import { CommandHandlerPlugin } from "../../../resolver/plugins/CommandHandlerPlugin.js";
2
2
  export declare const createDeleteCommandHandlerPlugin: () => CommandHandlerPlugin;
@@ -1,24 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDeleteCommandHandlerPlugin = void 0;
7
- var _CommandHandlerPlugin = require("../../plugins/CommandHandlerPlugin.js");
8
- var _DeleteCommandHandler = require("./DeleteCommandHandler");
9
- const createDeleteCommandHandlerPlugin = () => {
10
- const plugin = (0, _CommandHandlerPlugin.createCommandHandlerPlugin)({
11
- canHandle: command => {
12
- return command === "delete";
13
- },
14
- handle: async params => {
15
- const handler = new _DeleteCommandHandler.DeleteCommandHandler(params);
16
- return handler.handle(params);
17
- }
18
- });
19
- plugin.name = `${_CommandHandlerPlugin.CommandHandlerPlugin.type}.delete`;
20
- return plugin;
1
+ import { CommandHandlerPlugin, createCommandHandlerPlugin } from "../../plugins/CommandHandlerPlugin.js";
2
+ import { DeleteCommandHandler } from "./DeleteCommandHandler.js";
3
+ const createDeleteCommandHandlerPlugin = ()=>{
4
+ const plugin = createCommandHandlerPlugin({
5
+ canHandle: (command)=>"delete" === command,
6
+ handle: async (params)=>{
7
+ const handler = new DeleteCommandHandler(params);
8
+ return handler.handle(params);
9
+ }
10
+ });
11
+ plugin.name = `${CommandHandlerPlugin.type}.delete`;
12
+ return plugin;
21
13
  };
22
- exports.createDeleteCommandHandlerPlugin = createDeleteCommandHandlerPlugin;
14
+ export { createDeleteCommandHandlerPlugin };
23
15
 
24
16
  //# sourceMappingURL=delete.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CommandHandlerPlugin","require","_DeleteCommandHandler","createDeleteCommandHandlerPlugin","plugin","createCommandHandlerPlugin","canHandle","command","handle","params","handler","DeleteCommandHandler","name","CommandHandlerPlugin","type","exports"],"sources":["delete.ts"],"sourcesContent":["import {\n CommandHandlerPlugin,\n createCommandHandlerPlugin\n} from \"~/resolver/plugins/CommandHandlerPlugin.js\";\nimport { DeleteCommandHandler } from \"./DeleteCommandHandler\";\n\nexport const createDeleteCommandHandlerPlugin = () => {\n const plugin = createCommandHandlerPlugin({\n canHandle: command => {\n return command === \"delete\";\n },\n handle: async params => {\n const handler = new DeleteCommandHandler(params);\n\n return handler.handle(params);\n }\n });\n\n plugin.name = `${CommandHandlerPlugin.type}.delete`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAIA,IAAAC,qBAAA,GAAAD,OAAA;AAEO,MAAME,gCAAgC,GAAGA,CAAA,KAAM;EAClD,MAAMC,MAAM,GAAG,IAAAC,gDAA0B,EAAC;IACtCC,SAAS,EAAEC,OAAO,IAAI;MAClB,OAAOA,OAAO,KAAK,QAAQ;IAC/B,CAAC;IACDC,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAMC,OAAO,GAAG,IAAIC,0CAAoB,CAACF,MAAM,CAAC;MAEhD,OAAOC,OAAO,CAACF,MAAM,CAACC,MAAM,CAAC;IACjC;EACJ,CAAC,CAAC;EAEFL,MAAM,CAACQ,IAAI,GAAG,GAAGC,0CAAoB,CAACC,IAAI,SAAS;EAEnD,OAAOV,MAAM;AACjB,CAAC;AAACW,OAAA,CAAAZ,gCAAA,GAAAA,gCAAA","ignoreList":[]}
1
+ {"version":3,"file":"resolver/app/commandHandler/delete.js","sources":["../../../../src/resolver/app/commandHandler/delete.ts"],"sourcesContent":["import {\n CommandHandlerPlugin,\n createCommandHandlerPlugin\n} from \"~/resolver/plugins/CommandHandlerPlugin.js\";\nimport { DeleteCommandHandler } from \"./DeleteCommandHandler.js\";\n\nexport const createDeleteCommandHandlerPlugin = () => {\n const plugin = createCommandHandlerPlugin({\n canHandle: command => {\n return command === \"delete\";\n },\n handle: async params => {\n const handler = new DeleteCommandHandler(params);\n\n return handler.handle(params);\n }\n });\n\n plugin.name = `${CommandHandlerPlugin.type}.delete`;\n\n return plugin;\n};\n"],"names":["createDeleteCommandHandlerPlugin","plugin","createCommandHandlerPlugin","command","params","handler","DeleteCommandHandler","CommandHandlerPlugin"],"mappings":";;AAMO,MAAMA,mCAAmC;IAC5C,MAAMC,SAASC,2BAA2B;QACtC,WAAWC,CAAAA,UACAA,AAAY,aAAZA;QAEX,QAAQ,OAAMC;YACV,MAAMC,UAAU,IAAIC,qBAAqBF;YAEzC,OAAOC,QAAQ,MAAM,CAACD;QAC1B;IACJ;IAEAH,OAAO,IAAI,GAAG,GAAGM,qBAAqB,IAAI,CAAC,OAAO,CAAC;IAEnD,OAAON;AACX"}
@@ -1,2 +1,2 @@
1
- import { CommandHandlerPlugin } from "../../plugins/CommandHandlerPlugin.js";
1
+ import { CommandHandlerPlugin } from "../../../resolver/plugins/CommandHandlerPlugin.js";
2
2
  export declare const createPutCommandHandlerPlugin: () => CommandHandlerPlugin;
@@ -1,24 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createPutCommandHandlerPlugin = void 0;
7
- var _CommandHandlerPlugin = require("../../plugins/CommandHandlerPlugin.js");
8
- var _PutCommandHandler = require("./PutCommandHandler");
9
- const createPutCommandHandlerPlugin = () => {
10
- const plugin = (0, _CommandHandlerPlugin.createCommandHandlerPlugin)({
11
- canHandle: command => {
12
- return command === "put";
13
- },
14
- handle: async params => {
15
- const handler = new _PutCommandHandler.PutCommandHandler(params);
16
- return handler.handle(params);
17
- }
18
- });
19
- plugin.name = `${_CommandHandlerPlugin.CommandHandlerPlugin.type}.put`;
20
- return plugin;
1
+ import { CommandHandlerPlugin, createCommandHandlerPlugin } from "../../plugins/CommandHandlerPlugin.js";
2
+ import { PutCommandHandler } from "./PutCommandHandler.js";
3
+ const createPutCommandHandlerPlugin = ()=>{
4
+ const plugin = createCommandHandlerPlugin({
5
+ canHandle: (command)=>"put" === command,
6
+ handle: async (params)=>{
7
+ const handler = new PutCommandHandler(params);
8
+ return handler.handle(params);
9
+ }
10
+ });
11
+ plugin.name = `${CommandHandlerPlugin.type}.put`;
12
+ return plugin;
21
13
  };
22
- exports.createPutCommandHandlerPlugin = createPutCommandHandlerPlugin;
14
+ export { createPutCommandHandlerPlugin };
23
15
 
24
16
  //# sourceMappingURL=put.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_CommandHandlerPlugin","require","_PutCommandHandler","createPutCommandHandlerPlugin","plugin","createCommandHandlerPlugin","canHandle","command","handle","params","handler","PutCommandHandler","name","CommandHandlerPlugin","type","exports"],"sources":["put.ts"],"sourcesContent":["import {\n CommandHandlerPlugin,\n createCommandHandlerPlugin\n} from \"~/resolver/plugins/CommandHandlerPlugin.js\";\nimport { PutCommandHandler } from \"./PutCommandHandler\";\n\nexport const createPutCommandHandlerPlugin = () => {\n const plugin = createCommandHandlerPlugin({\n canHandle: command => {\n return command === \"put\";\n },\n handle: async params => {\n const handler = new PutCommandHandler(params);\n\n return handler.handle(params);\n }\n });\n\n plugin.name = `${CommandHandlerPlugin.type}.put`;\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAIA,IAAAC,kBAAA,GAAAD,OAAA;AAEO,MAAME,6BAA6B,GAAGA,CAAA,KAAM;EAC/C,MAAMC,MAAM,GAAG,IAAAC,gDAA0B,EAAC;IACtCC,SAAS,EAAEC,OAAO,IAAI;MAClB,OAAOA,OAAO,KAAK,KAAK;IAC5B,CAAC;IACDC,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAMC,OAAO,GAAG,IAAIC,oCAAiB,CAACF,MAAM,CAAC;MAE7C,OAAOC,OAAO,CAACF,MAAM,CAACC,MAAM,CAAC;IACjC;EACJ,CAAC,CAAC;EAEFL,MAAM,CAACQ,IAAI,GAAG,GAAGC,0CAAoB,CAACC,IAAI,MAAM;EAEhD,OAAOV,MAAM;AACjB,CAAC;AAACW,OAAA,CAAAZ,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"file":"resolver/app/commandHandler/put.js","sources":["../../../../src/resolver/app/commandHandler/put.ts"],"sourcesContent":["import {\n CommandHandlerPlugin,\n createCommandHandlerPlugin\n} from \"~/resolver/plugins/CommandHandlerPlugin.js\";\nimport { PutCommandHandler } from \"./PutCommandHandler.js\";\n\nexport const createPutCommandHandlerPlugin = () => {\n const plugin = createCommandHandlerPlugin({\n canHandle: command => {\n return command === \"put\";\n },\n handle: async params => {\n const handler = new PutCommandHandler(params);\n\n return handler.handle(params);\n }\n });\n\n plugin.name = `${CommandHandlerPlugin.type}.put`;\n\n return plugin;\n};\n"],"names":["createPutCommandHandlerPlugin","plugin","createCommandHandlerPlugin","command","params","handler","PutCommandHandler","CommandHandlerPlugin"],"mappings":";;AAMO,MAAMA,gCAAgC;IACzC,MAAMC,SAASC,2BAA2B;QACtC,WAAWC,CAAAA,UACAA,AAAY,UAAZA;QAEX,QAAQ,OAAMC;YACV,MAAMC,UAAU,IAAIC,kBAAkBF;YAEtC,OAAOC,QAAQ,MAAM,CAACD;QAC1B;IACJ;IAEAH,OAAO,IAAI,GAAG,GAAGM,qBAAqB,IAAI,CAAC,IAAI,CAAC;IAEhD,OAAON;AACX"}
@@ -1,6 +1,6 @@
1
- import type { GenericRecord } from "@webiny/api/types";
2
- import type { IInputItem, IItem, ISourceDataContainer } from "./types.js";
3
- import type { IStoreItem } from "../storer/types.js";
1
+ import type { GenericRecord } from "@webiny/api/types.js";
2
+ import type { IInputItem, IItem, ISourceDataContainer } from "../../../resolver/app/data/types.js";
3
+ import type { IStoreItem } from "../../../resolver/app/storer/types.js";
4
4
  export declare class SourceDataContainer implements ISourceDataContainer {
5
5
  readonly items: GenericRecord<string, IItem>;
6
6
  private constructor();
@@ -1,42 +1,33 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SourceDataContainer = void 0;
7
1
  class SourceDataContainer {
8
- items = {};
9
- constructor() {
10
- // block
11
- }
12
- static create() {
13
- return new SourceDataContainer();
14
- }
15
- get(input) {
16
- const key = this.createKey(input);
17
- const item = this.items[key];
18
- return item?.data || null;
19
- }
20
- add(item, data) {
21
- const key = this.createKey(item);
22
- if (this.items[key]) {
23
- return;
2
+ constructor(){
3
+ this.items = {};
4
+ }
5
+ static create() {
6
+ return new SourceDataContainer();
7
+ }
8
+ get(input) {
9
+ const key = this.createKey(input);
10
+ const item = this.items[key];
11
+ return item?.data || null;
12
+ }
13
+ add(item, data) {
14
+ const key = this.createKey(item);
15
+ if (this.items[key]) return;
16
+ this.items[key] = {
17
+ ...item,
18
+ data
19
+ };
20
+ }
21
+ merge(container) {
22
+ for(const key in container.items){
23
+ const item = container.items[key];
24
+ this.add(item, item.data);
25
+ }
24
26
  }
25
- this.items[key] = {
26
- ...item,
27
- data
28
- };
29
- }
30
- merge(container) {
31
- for (const key in container.items) {
32
- const item = container.items[key];
33
- this.add(item, item.data);
27
+ createKey(item) {
28
+ return `${item.source.name}#${item.table.name}#${item.PK}#${item.SK}`;
34
29
  }
35
- }
36
- createKey(item) {
37
- return `${item.source.name}#${item.table.name}#${item.PK}#${item.SK}`;
38
- }
39
30
  }
40
- exports.SourceDataContainer = SourceDataContainer;
31
+ export { SourceDataContainer };
41
32
 
42
33
  //# sourceMappingURL=SourceDataContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SourceDataContainer","items","constructor","create","get","input","key","createKey","item","data","add","merge","container","source","name","table","PK","SK","exports"],"sources":["SourceDataContainer.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types\";\nimport type { IInputItem, IItem, ISourceDataContainer } from \"~/resolver/app/data/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\n\nexport class SourceDataContainer implements ISourceDataContainer {\n public readonly items: GenericRecord<string, IItem> = {};\n\n private constructor() {\n // block\n }\n\n public static create(): ISourceDataContainer {\n return new SourceDataContainer();\n }\n\n public get(input: IInputItem): IStoreItem | null {\n const key = this.createKey(input);\n const item = this.items[key];\n return item?.data || null;\n }\n\n public add(item: IInputItem, data: IStoreItem | null): void {\n const key = this.createKey(item);\n if (this.items[key]) {\n return;\n }\n\n this.items[key] = {\n ...item,\n data\n };\n }\n\n public merge(container: ISourceDataContainer): void {\n for (const key in container.items) {\n const item = container.items[key];\n this.add(item, item.data);\n }\n }\n\n private createKey(item: IInputItem): string {\n return `${item.source.name}#${item.table.name}#${item.PK}#${item.SK}`;\n }\n}\n"],"mappings":";;;;;;AAIO,MAAMA,mBAAmB,CAAiC;EAC7CC,KAAK,GAAiC,CAAC,CAAC;EAEhDC,WAAWA,CAAA,EAAG;IAClB;EAAA;EAGJ,OAAcC,MAAMA,CAAA,EAAyB;IACzC,OAAO,IAAIH,mBAAmB,CAAC,CAAC;EACpC;EAEOI,GAAGA,CAACC,KAAiB,EAAqB;IAC7C,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;IACjC,MAAMG,IAAI,GAAG,IAAI,CAACP,KAAK,CAACK,GAAG,CAAC;IAC5B,OAAOE,IAAI,EAAEC,IAAI,IAAI,IAAI;EAC7B;EAEOC,GAAGA,CAACF,IAAgB,EAAEC,IAAuB,EAAQ;IACxD,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACC,IAAI,CAAC;IAChC,IAAI,IAAI,CAACP,KAAK,CAACK,GAAG,CAAC,EAAE;MACjB;IACJ;IAEA,IAAI,CAACL,KAAK,CAACK,GAAG,CAAC,GAAG;MACd,GAAGE,IAAI;MACPC;IACJ,CAAC;EACL;EAEOE,KAAKA,CAACC,SAA+B,EAAQ;IAChD,KAAK,MAAMN,GAAG,IAAIM,SAAS,CAACX,KAAK,EAAE;MAC/B,MAAMO,IAAI,GAAGI,SAAS,CAACX,KAAK,CAACK,GAAG,CAAC;MACjC,IAAI,CAACI,GAAG,CAACF,IAAI,EAAEA,IAAI,CAACC,IAAI,CAAC;IAC7B;EACJ;EAEQF,SAASA,CAACC,IAAgB,EAAU;IACxC,OAAO,GAAGA,IAAI,CAACK,MAAM,CAACC,IAAI,IAAIN,IAAI,CAACO,KAAK,CAACD,IAAI,IAAIN,IAAI,CAACQ,EAAE,IAAIR,IAAI,CAACS,EAAE,EAAE;EACzE;AACJ;AAACC,OAAA,CAAAlB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"resolver/app/data/SourceDataContainer.js","sources":["../../../../src/resolver/app/data/SourceDataContainer.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IInputItem, IItem, ISourceDataContainer } from \"~/resolver/app/data/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\n\nexport class SourceDataContainer implements ISourceDataContainer {\n public readonly items: GenericRecord<string, IItem> = {};\n\n private constructor() {\n // block\n }\n\n public static create(): ISourceDataContainer {\n return new SourceDataContainer();\n }\n\n public get(input: IInputItem): IStoreItem | null {\n const key = this.createKey(input);\n const item = this.items[key];\n return item?.data || null;\n }\n\n public add(item: IInputItem, data: IStoreItem | null): void {\n const key = this.createKey(item);\n if (this.items[key]) {\n return;\n }\n\n this.items[key] = {\n ...item,\n data\n };\n }\n\n public merge(container: ISourceDataContainer): void {\n for (const key in container.items) {\n const item = container.items[key];\n this.add(item, item.data);\n }\n }\n\n private createKey(item: IInputItem): string {\n return `${item.source.name}#${item.table.name}#${item.PK}#${item.SK}`;\n }\n}\n"],"names":["SourceDataContainer","input","key","item","data","container"],"mappings":"AAIO,MAAMA;IAGT,aAAsB;aAFN,KAAK,GAAiC,CAAC;IAIvD;IAEA,OAAc,SAA+B;QACzC,OAAO,IAAIA;IACf;IAEO,IAAIC,KAAiB,EAAqB;QAC7C,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,MAAME,OAAO,IAAI,CAAC,KAAK,CAACD,IAAI;QAC5B,OAAOC,MAAM,QAAQ;IACzB;IAEO,IAAIA,IAAgB,EAAEC,IAAuB,EAAQ;QACxD,MAAMF,MAAM,IAAI,CAAC,SAAS,CAACC;QAC3B,IAAI,IAAI,CAAC,KAAK,CAACD,IAAI,EACf;QAGJ,IAAI,CAAC,KAAK,CAACA,IAAI,GAAG;YACd,GAAGC,IAAI;YACPC;QACJ;IACJ;IAEO,MAAMC,SAA+B,EAAQ;QAChD,IAAK,MAAMH,OAAOG,UAAU,KAAK,CAAE;YAC/B,MAAMF,OAAOE,UAAU,KAAK,CAACH,IAAI;YACjC,IAAI,CAAC,GAAG,CAACC,MAAMA,KAAK,IAAI;QAC5B;IACJ;IAEQ,UAAUA,IAAgB,EAAU;QACxC,OAAO,GAAGA,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,EAAEA,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,EAAEA,KAAK,EAAE,CAAC,CAAC,EAAEA,KAAK,EAAE,EAAE;IACzE;AACJ"}
@@ -1,7 +1,7 @@
1
1
  import type { ITable } from "../../../sync/types.js";
2
- import type { IDeployment } from "../../deployment/types.js";
2
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
3
3
  import type { GenericRecord } from "@webiny/api/types.js";
4
- import type { IStoreItem } from "../storer/types.js";
4
+ import type { IStoreItem } from "../../../resolver/app/storer/types.js";
5
5
  export interface IInputItem {
6
6
  PK: string;
7
7
  SK: string;
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
@@ -1,6 +1,6 @@
1
- import type { IFetcher, IFetcherExecParams, IFetcherExecResult } from "./types";
2
- import { type DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
3
- import type { IDeployment } from "../../deployment/types.js";
1
+ import type { IFetcher, IFetcherExecParams, IFetcherExecResult } from "./types.js";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
4
4
  export interface IFetcherParamsCreateDocumentClientCallable {
5
5
  (deployment: Pick<IDeployment, "region">): Pick<DynamoDBDocument, "send">;
6
6
  }
@@ -1,132 +1,98 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createFetcher = exports.Fetcher = void 0;
8
- var _clientDynamodb = require("@webiny/aws-sdk/client-dynamodb");
9
- var _chunk = _interopRequireDefault(require("lodash/chunk"));
10
- var _SourceDataContainer = require("../data/SourceDataContainer.js");
11
- var _utils = require("@webiny/utils");
12
- var _Retry = require("../utils/Retry.js");
1
+ import { BatchGetCommand } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ import chunk from "lodash/chunk.js";
3
+ import { SourceDataContainer } from "../data/SourceDataContainer.js";
4
+ import { convertException } from "@webiny/utils";
5
+ import { createRetry } from "../utils/Retry.js";
13
6
  class Fetcher {
14
- constructor(params) {
15
- this.createDocumentClient = params.createDocumentClient;
16
- this.maxRetries = params.maxRetries || 10;
17
- this.retryDelay = params.retryDelay || 1000;
18
- }
19
- async exec(params) {
20
- const {
21
- deployment,
22
- items: input,
23
- table,
24
- maxBatchSize = 25
25
- } = params;
26
- if (input.length === 0) {
27
- return {
28
- items: _SourceDataContainer.SourceDataContainer.create()
29
- };
7
+ constructor(params){
8
+ this.createDocumentClient = params.createDocumentClient;
9
+ this.maxRetries = params.maxRetries || 10;
10
+ this.retryDelay = params.retryDelay || 1000;
30
11
  }
31
- const client = this.createDocumentClient(deployment);
32
- const results = await this.execute({
33
- client,
34
- table,
35
- maxBatchSize,
36
- records: input
37
- });
38
- const items = _SourceDataContainer.SourceDataContainer.create();
39
- for (const item of input) {
40
- const data = results.find(result => {
41
- return item.PK === result.PK && item.SK === result.SK;
42
- });
43
- items.add({
44
- PK: item.PK,
45
- SK: item.SK,
46
- table,
47
- source: deployment
48
- }, data || null);
12
+ async exec(params) {
13
+ const { deployment, items: input, table, maxBatchSize = 25 } = params;
14
+ if (0 === input.length) return {
15
+ items: SourceDataContainer.create()
16
+ };
17
+ const client = this.createDocumentClient(deployment);
18
+ const results = await this.execute({
19
+ client,
20
+ table,
21
+ maxBatchSize,
22
+ records: input
23
+ });
24
+ const items = SourceDataContainer.create();
25
+ for (const item of input){
26
+ const data = results.find((result)=>item.PK === result.PK && item.SK === result.SK);
27
+ items.add({
28
+ PK: item.PK,
29
+ SK: item.SK,
30
+ table,
31
+ source: deployment
32
+ }, data || null);
33
+ }
34
+ return {
35
+ items
36
+ };
49
37
  }
50
- return {
51
- items
52
- };
53
- }
54
- async execute(params) {
55
- const {
56
- client,
57
- table,
58
- records: items,
59
- maxBatchSize
60
- } = params;
61
- const batches = (0, _chunk.default)(items, maxBatchSize);
62
- const results = [];
63
- for (const batch of batches) {
64
- let keys = this.getKeys(batch);
65
- while (keys.length > 0) {
66
- const command = new _clientDynamodb.BatchGetCommand({
67
- RequestItems: {
68
- [table.name]: {
69
- Keys: keys
38
+ async execute(params) {
39
+ const { client, table, records: items, maxBatchSize } = params;
40
+ const batches = chunk(items, maxBatchSize);
41
+ const results = [];
42
+ for (const batch of batches){
43
+ let keys = this.getKeys(batch);
44
+ while(keys.length > 0){
45
+ const command = new BatchGetCommand({
46
+ RequestItems: {
47
+ [table.name]: {
48
+ Keys: keys
49
+ }
50
+ }
51
+ });
52
+ const { items, unprocessedKeys } = await this.runCommand({
53
+ command,
54
+ client,
55
+ table: table.name
56
+ });
57
+ results.push(...items);
58
+ keys = unprocessedKeys;
70
59
  }
71
- }
60
+ }
61
+ return results;
62
+ }
63
+ async runCommand(params) {
64
+ const { command, table, client } = params;
65
+ const retry = createRetry({
66
+ maxRetries: this.maxRetries,
67
+ retryDelay: this.retryDelay
72
68
  });
73
- const {
74
- items,
75
- unprocessedKeys
76
- } = await this.runCommand({
77
- command,
78
- client,
79
- table: table.name
69
+ return await retry.retry(async ()=>{
70
+ const result = await client.send(command);
71
+ return {
72
+ items: result.Responses?.[table] || [],
73
+ unprocessedKeys: result.UnprocessedKeys?.[table]?.Keys || []
74
+ };
75
+ }, {
76
+ onFail: (ex)=>{
77
+ console.error(`Max retries reached. Could not fetch items from table: ${table}`);
78
+ console.log(convertException(ex));
79
+ console.log(JSON.stringify(command));
80
+ }
80
81
  });
81
- results.push(...items);
82
- keys = unprocessedKeys;
83
- }
84
82
  }
85
- return results;
86
- }
87
- async runCommand(params) {
88
- const {
89
- command,
90
- table,
91
- client
92
- } = params;
93
- const retry = (0, _Retry.createRetry)({
94
- maxRetries: this.maxRetries,
95
- retryDelay: this.retryDelay
96
- });
97
- return await retry.retry(async () => {
98
- const result = await client.send(command);
99
- return {
100
- items: result.Responses?.[table] || [],
101
- unprocessedKeys: result.UnprocessedKeys?.[table]?.Keys || []
102
- };
103
- }, {
104
- onFail: ex => {
105
- console.error(`Max retries reached. Could not fetch items from table: ${table}`);
106
- console.log((0, _utils.convertException)(ex));
107
- console.log(JSON.stringify(command));
108
- }
109
- });
110
- }
111
- getKeys(items) {
112
- const keys = new Map();
113
- for (const item of items) {
114
- const key = `PK:${item.PK}#SK:${item.SK}`;
115
- if (keys.has(key)) {
116
- continue;
117
- }
118
- keys.set(key, {
119
- PK: item.PK,
120
- SK: item.SK
121
- });
83
+ getKeys(items) {
84
+ const keys = new Map();
85
+ for (const item of items){
86
+ const key = `PK:${item.PK}#SK:${item.SK}`;
87
+ if (!keys.has(key)) keys.set(key, {
88
+ PK: item.PK,
89
+ SK: item.SK
90
+ });
91
+ }
92
+ return Array.from(keys.values());
122
93
  }
123
- return Array.from(keys.values());
124
- }
125
94
  }
126
- exports.Fetcher = Fetcher;
127
- const createFetcher = params => {
128
- return new Fetcher(params);
129
- };
130
- exports.createFetcher = createFetcher;
95
+ const createFetcher = (params)=>new Fetcher(params);
96
+ export { Fetcher, createFetcher };
131
97
 
132
98
  //# sourceMappingURL=Fetcher.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_clientDynamodb","require","_chunk","_interopRequireDefault","_SourceDataContainer","_utils","_Retry","Fetcher","constructor","params","createDocumentClient","maxRetries","retryDelay","exec","deployment","items","input","table","maxBatchSize","length","SourceDataContainer","create","client","results","execute","records","item","data","find","result","PK","SK","add","source","batches","lodashChunk","batch","keys","getKeys","command","BatchGetCommand","RequestItems","name","Keys","unprocessedKeys","runCommand","push","retry","createRetry","send","Responses","UnprocessedKeys","onFail","ex","console","error","log","convertException","JSON","stringify","Map","key","has","set","Array","from","values","exports","createFetcher"],"sources":["Fetcher.ts"],"sourcesContent":["import type { IFetcher, IFetcherExecParams, IFetcherExecResult } from \"./types\";\nimport { BatchGetCommand, type DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport lodashChunk from \"lodash/chunk\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport { SourceDataContainer } from \"~/resolver/app/data/SourceDataContainer.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport { createRetry } from \"~/resolver/app/utils/Retry.js\";\n\nexport interface IFetcherParamsCreateDocumentClientCallable {\n (deployment: Pick<IDeployment, \"region\">): Pick<DynamoDBDocument, \"send\">;\n}\n\nexport interface IFetcherParams {\n maxRetries?: number;\n retryDelay?: number;\n createDocumentClient: IFetcherParamsCreateDocumentClientCallable;\n}\n\ninterface IKeys {\n PK: string;\n SK: string;\n}\n\ninterface IFetcherExecuteRunCommandParams {\n command: BatchGetCommand;\n table: string;\n client: Pick<DynamoDBDocument, \"send\">;\n}\n\ninterface IFetcherExecuteRunCommandResult<T = GenericRecord> {\n items: T[];\n unprocessedKeys: IKeys[];\n}\n\ninterface IFetchExecuteExecuteParamsItem {\n PK: string;\n SK: string;\n}\n\ninterface IFetchExecuteExecuteParams {\n maxBatchSize: number;\n client: Pick<DynamoDBDocument, \"send\">;\n table: ITable;\n records: IFetchExecuteExecuteParamsItem[];\n}\n\nexport class Fetcher implements IFetcher {\n private readonly createDocumentClient: IFetcherParamsCreateDocumentClientCallable;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n\n public constructor(params: IFetcherParams) {\n this.createDocumentClient = params.createDocumentClient;\n this.maxRetries = params.maxRetries || 10;\n this.retryDelay = params.retryDelay || 1000;\n }\n\n public async exec(params: IFetcherExecParams): Promise<IFetcherExecResult> {\n const { deployment, items: input, table, maxBatchSize = 25 } = params;\n if (input.length === 0) {\n return {\n items: SourceDataContainer.create()\n };\n }\n\n const client = this.createDocumentClient(deployment);\n\n const results = await this.execute({\n client,\n table,\n maxBatchSize,\n records: input\n });\n\n const items = SourceDataContainer.create();\n\n for (const item of input) {\n const data = results.find(result => {\n return item.PK === result.PK && item.SK === result.SK;\n });\n items.add(\n {\n PK: item.PK,\n SK: item.SK,\n table,\n source: deployment\n },\n data || null\n );\n }\n\n return {\n items\n };\n }\n\n private async execute<T = IStoreItem>(params: IFetchExecuteExecuteParams) {\n const { client, table, records: items, maxBatchSize } = params;\n const batches = lodashChunk(items, maxBatchSize);\n\n const results: T[] = [];\n for (const batch of batches) {\n let keys = this.getKeys(batch);\n\n while (keys.length > 0) {\n const command = new BatchGetCommand({\n RequestItems: {\n [table.name]: {\n Keys: keys\n }\n }\n });\n const { items, unprocessedKeys } = await this.runCommand<T>({\n command,\n client,\n table: table.name\n });\n\n results.push(...items);\n\n keys = unprocessedKeys;\n }\n }\n return results;\n }\n\n private async runCommand<T = GenericRecord>(\n params: IFetcherExecuteRunCommandParams\n ): Promise<IFetcherExecuteRunCommandResult<T>> {\n const { command, table, client } = params;\n\n const retry = createRetry({\n maxRetries: this.maxRetries,\n retryDelay: this.retryDelay\n });\n\n return await retry.retry(\n async () => {\n const result = await client.send(command);\n\n return {\n items: (result.Responses?.[table] || []) as T[],\n unprocessedKeys: (result.UnprocessedKeys?.[table]?.Keys || []) as IKeys[]\n };\n },\n {\n onFail: ex => {\n console.error(\n `Max retries reached. Could not fetch items from table: ${table}`\n );\n console.log(convertException(ex));\n console.log(JSON.stringify(command));\n }\n }\n );\n }\n\n private getKeys(items: IFetchExecuteExecuteParamsItem[]): IKeys[] {\n const keys = new Map<string, IKeys>();\n\n for (const item of items) {\n const key = `PK:${item.PK}#SK:${item.SK}`;\n if (keys.has(key)) {\n continue;\n }\n keys.set(key, {\n PK: item.PK,\n SK: item.SK\n });\n }\n\n return Array.from(keys.values());\n }\n}\n\nexport const createFetcher = (params: IFetcherParams): IFetcher => {\n return new Fetcher(params);\n};\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"resolver/app/fetcher/Fetcher.js","sources":["../../../../src/resolver/app/fetcher/Fetcher.ts"],"sourcesContent":["import type { IFetcher, IFetcherExecParams, IFetcherExecResult } from \"./types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { BatchGetCommand } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport lodashChunk from \"lodash/chunk.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport { SourceDataContainer } from \"~/resolver/app/data/SourceDataContainer.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport { createRetry } from \"~/resolver/app/utils/Retry.js\";\n\nexport interface IFetcherParamsCreateDocumentClientCallable {\n (deployment: Pick<IDeployment, \"region\">): Pick<DynamoDBDocument, \"send\">;\n}\n\nexport interface IFetcherParams {\n maxRetries?: number;\n retryDelay?: number;\n createDocumentClient: IFetcherParamsCreateDocumentClientCallable;\n}\n\ninterface IKeys {\n PK: string;\n SK: string;\n}\n\ninterface IFetcherExecuteRunCommandParams {\n command: BatchGetCommand;\n table: string;\n client: Pick<DynamoDBDocument, \"send\">;\n}\n\ninterface IFetcherExecuteRunCommandResult<T = GenericRecord> {\n items: T[];\n unprocessedKeys: IKeys[];\n}\n\ninterface IFetchExecuteExecuteParamsItem {\n PK: string;\n SK: string;\n}\n\ninterface IFetchExecuteExecuteParams {\n maxBatchSize: number;\n client: Pick<DynamoDBDocument, \"send\">;\n table: ITable;\n records: IFetchExecuteExecuteParamsItem[];\n}\n\nexport class Fetcher implements IFetcher {\n private readonly createDocumentClient: IFetcherParamsCreateDocumentClientCallable;\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n\n public constructor(params: IFetcherParams) {\n this.createDocumentClient = params.createDocumentClient;\n this.maxRetries = params.maxRetries || 10;\n this.retryDelay = params.retryDelay || 1000;\n }\n\n public async exec(params: IFetcherExecParams): Promise<IFetcherExecResult> {\n const { deployment, items: input, table, maxBatchSize = 25 } = params;\n if (input.length === 0) {\n return {\n items: SourceDataContainer.create()\n };\n }\n\n const client = this.createDocumentClient(deployment);\n\n const results = await this.execute({\n client,\n table,\n maxBatchSize,\n records: input\n });\n\n const items = SourceDataContainer.create();\n\n for (const item of input) {\n const data = results.find(result => {\n return item.PK === result.PK && item.SK === result.SK;\n });\n items.add(\n {\n PK: item.PK,\n SK: item.SK,\n table,\n source: deployment\n },\n data || null\n );\n }\n\n return {\n items\n };\n }\n\n private async execute<T = IStoreItem>(params: IFetchExecuteExecuteParams) {\n const { client, table, records: items, maxBatchSize } = params;\n const batches = lodashChunk(items, maxBatchSize);\n\n const results: T[] = [];\n for (const batch of batches) {\n let keys = this.getKeys(batch);\n\n while (keys.length > 0) {\n const command = new BatchGetCommand({\n RequestItems: {\n [table.name]: {\n Keys: keys\n }\n }\n });\n const { items, unprocessedKeys } = await this.runCommand<T>({\n command,\n client,\n table: table.name\n });\n\n results.push(...items);\n\n keys = unprocessedKeys;\n }\n }\n return results;\n }\n\n private async runCommand<T = GenericRecord>(\n params: IFetcherExecuteRunCommandParams\n ): Promise<IFetcherExecuteRunCommandResult<T>> {\n const { command, table, client } = params;\n\n const retry = createRetry({\n maxRetries: this.maxRetries,\n retryDelay: this.retryDelay\n });\n\n return await retry.retry(\n async () => {\n const result = await client.send(command);\n\n return {\n items: (result.Responses?.[table] || []) as T[],\n unprocessedKeys: (result.UnprocessedKeys?.[table]?.Keys || []) as IKeys[]\n };\n },\n {\n onFail: ex => {\n console.error(\n `Max retries reached. Could not fetch items from table: ${table}`\n );\n console.log(convertException(ex));\n console.log(JSON.stringify(command));\n }\n }\n );\n }\n\n private getKeys(items: IFetchExecuteExecuteParamsItem[]): IKeys[] {\n const keys = new Map<string, IKeys>();\n\n for (const item of items) {\n const key = `PK:${item.PK}#SK:${item.SK}`;\n if (keys.has(key)) {\n continue;\n }\n keys.set(key, {\n PK: item.PK,\n SK: item.SK\n });\n }\n\n return Array.from(keys.values());\n }\n}\n\nexport const createFetcher = (params: IFetcherParams): IFetcher => {\n return new Fetcher(params);\n};\n"],"names":["Fetcher","params","deployment","input","table","maxBatchSize","SourceDataContainer","client","results","items","item","data","result","batches","lodashChunk","batch","keys","command","BatchGetCommand","unprocessedKeys","retry","createRetry","ex","console","convertException","JSON","Map","key","Array","createFetcher"],"mappings":"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"}
@@ -1,6 +1,6 @@
1
- import type { IDeployment } from "../../deployment/types.js";
1
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
2
2
  import type { ITable } from "../../../sync/types.js";
3
- import type { ISourceDataContainer } from "../data/types.js";
3
+ import type { ISourceDataContainer } from "../../../resolver/app/data/types.js";
4
4
  export interface IFetcherExecParamsItem {
5
5
  PK: string;
6
6
  SK: string;
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map