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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/README.md +6 -108
  2. package/constants.js +1 -7
  3. package/constants.js.map +1 -1
  4. package/index.js +3 -38
  5. package/index.js.map +1 -1
  6. package/package.json +20 -23
  7. package/resolver/app/RecordHandler.d.ts +6 -6
  8. package/resolver/app/RecordHandler.js +7 -15
  9. package/resolver/app/RecordHandler.js.map +1 -1
  10. package/resolver/app/RecordsValidation.js +6 -14
  11. package/resolver/app/RecordsValidation.js.map +1 -1
  12. package/resolver/app/ResolverApplication.d.ts +1 -1
  13. package/resolver/app/ResolverApplication.js +10 -18
  14. package/resolver/app/ResolverApplication.js.map +1 -1
  15. package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
  16. package/resolver/app/abstractions/RecordHandler.js +1 -5
  17. package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
  18. package/resolver/app/abstractions/RecordsValidation.js +1 -5
  19. package/resolver/app/abstractions/RecordsValidation.js.map +1 -1
  20. package/resolver/app/abstractions/ResolverApplication.js +1 -5
  21. package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
  22. package/resolver/app/abstractions/ResolverRecord.js +1 -5
  23. package/resolver/app/abstractions/ResolverRecord.js.map +1 -1
  24. package/resolver/app/bundler/BaseBundle.d.ts +6 -6
  25. package/resolver/app/bundler/BaseBundle.js +1 -8
  26. package/resolver/app/bundler/BaseBundle.js.map +1 -1
  27. package/resolver/app/bundler/Bundler.d.ts +1 -1
  28. package/resolver/app/bundler/Bundler.js +2 -10
  29. package/resolver/app/bundler/Bundler.js.map +1 -1
  30. package/resolver/app/bundler/Bundles.d.ts +2 -2
  31. package/resolver/app/bundler/Bundles.js +2 -10
  32. package/resolver/app/bundler/Bundles.js.map +1 -1
  33. package/resolver/app/bundler/CommandBundle.d.ts +1 -1
  34. package/resolver/app/bundler/CommandBundle.js +3 -11
  35. package/resolver/app/bundler/CommandBundle.js.map +1 -1
  36. package/resolver/app/bundler/TableBundle.d.ts +1 -1
  37. package/resolver/app/bundler/TableBundle.js +3 -11
  38. package/resolver/app/bundler/TableBundle.js.map +1 -1
  39. package/resolver/app/bundler/types.d.ts +2 -2
  40. package/resolver/app/bundler/types.js +1 -5
  41. package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
  42. package/resolver/app/commandHandler/DeleteCommandHandler.js +1 -8
  43. package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
  44. package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
  45. package/resolver/app/commandHandler/PutCommandHandler.js +1 -8
  46. package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
  47. package/resolver/app/commandHandler/delete.d.ts +1 -1
  48. package/resolver/app/commandHandler/delete.js +6 -13
  49. package/resolver/app/commandHandler/delete.js.map +1 -1
  50. package/resolver/app/commandHandler/put.d.ts +1 -1
  51. package/resolver/app/commandHandler/put.js +6 -13
  52. package/resolver/app/commandHandler/put.js.map +1 -1
  53. package/resolver/app/data/SourceDataContainer.d.ts +3 -3
  54. package/resolver/app/data/SourceDataContainer.js +1 -8
  55. package/resolver/app/data/SourceDataContainer.js.map +1 -1
  56. package/resolver/app/data/types.d.ts +2 -2
  57. package/resolver/app/data/types.js +1 -5
  58. package/resolver/app/fetcher/Fetcher.d.ts +3 -3
  59. package/resolver/app/fetcher/Fetcher.js +13 -22
  60. package/resolver/app/fetcher/Fetcher.js.map +1 -1
  61. package/resolver/app/fetcher/types.d.ts +2 -2
  62. package/resolver/app/fetcher/types.js +1 -5
  63. package/resolver/app/ingestor/Ingestor.d.ts +1 -1
  64. package/resolver/app/ingestor/Ingestor.js +2 -10
  65. package/resolver/app/ingestor/Ingestor.js.map +1 -1
  66. package/resolver/app/ingestor/IngestorResult.js +3 -11
  67. package/resolver/app/ingestor/IngestorResult.js.map +1 -1
  68. package/resolver/app/ingestor/types.d.ts +2 -2
  69. package/resolver/app/ingestor/types.js +1 -5
  70. package/resolver/app/storer/Storer.d.ts +3 -3
  71. package/resolver/app/storer/Storer.js +12 -20
  72. package/resolver/app/storer/Storer.js.map +1 -1
  73. package/resolver/app/storer/types.d.ts +2 -2
  74. package/resolver/app/storer/types.js +1 -5
  75. package/resolver/app/storer/types.js.map +1 -1
  76. package/resolver/app/transform/TransformHandler.d.ts +4 -4
  77. package/resolver/app/transform/TransformHandler.js +5 -12
  78. package/resolver/app/transform/TransformHandler.js.map +1 -1
  79. package/resolver/app/transform/middleware.d.ts +1 -1
  80. package/resolver/app/transform/middleware.js +1 -7
  81. package/resolver/app/transform/middleware.js.map +1 -1
  82. package/resolver/app/utils/Retry.js +4 -12
  83. package/resolver/app/utils/Retry.js.map +1 -1
  84. package/resolver/app/utils/sleep.js +1 -8
  85. package/resolver/app/utils/sleep.js.map +1 -1
  86. package/resolver/app/validation/body.d.ts +43 -43
  87. package/resolver/app/validation/body.js +22 -30
  88. package/resolver/app/validation/body.js.map +1 -1
  89. package/resolver/app/validation/createJsonTransform.js +6 -14
  90. package/resolver/app/validation/createJsonTransform.js.map +1 -1
  91. package/resolver/app/validation/detail.d.ts +22 -22
  92. package/resolver/app/validation/detail.js +16 -24
  93. package/resolver/app/validation/detail.js.map +1 -1
  94. package/resolver/app/validation/event.d.ts +57 -57
  95. package/resolver/app/validation/event.js +19 -27
  96. package/resolver/app/validation/event.js.map +1 -1
  97. package/resolver/app/validation/numericString.js +5 -13
  98. package/resolver/app/validation/numericString.js.map +1 -1
  99. package/resolver/app/validation/system.d.ts +4 -4
  100. package/resolver/app/validation/system.js +8 -16
  101. package/resolver/app/validation/system.js.map +1 -1
  102. package/resolver/createEventHandlerPlugin.d.ts +2 -1
  103. package/resolver/createEventHandlerPlugin.js +35 -42
  104. package/resolver/createEventHandlerPlugin.js.map +1 -1
  105. package/resolver/createResolverHandler.d.ts +1 -1
  106. package/resolver/createResolverHandler.js +24 -31
  107. package/resolver/createResolverHandler.js.map +1 -1
  108. package/resolver/deployment/Deployment.d.ts +2 -3
  109. package/resolver/deployment/Deployment.js +6 -14
  110. package/resolver/deployment/Deployment.js.map +1 -1
  111. package/resolver/deployment/Deployments.js +2 -10
  112. package/resolver/deployment/Deployments.js.map +1 -1
  113. package/resolver/deployment/DeploymentsFetcher.js +33 -42
  114. package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
  115. package/resolver/deployment/types.d.ts +4 -4
  116. package/resolver/deployment/types.js +1 -5
  117. package/resolver/deployment/types.js.map +1 -1
  118. package/resolver/lambda/LambdaTrigger.js +5 -12
  119. package/resolver/lambda/LambdaTrigger.js.map +1 -1
  120. package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
  121. package/resolver/plugins/CommandHandlerPlugin.js +3 -11
  122. package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
  123. package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
  124. package/resolver/plugins/StorerAfterEachPlugin.js +4 -13
  125. package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
  126. package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
  127. package/resolver/plugins/TransformRecordPlugin.js +3 -11
  128. package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
  129. package/resolver/recordTypes/fileManager/CopyFile.js +4 -11
  130. package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
  131. package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
  132. package/resolver/recordTypes/fileManager/DeleteFile.js +3 -10
  133. package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
  134. package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
  135. package/resolver/recordTypes/fileManager/fileManager.js +4 -11
  136. package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
  137. package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
  138. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +7 -14
  139. package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
  140. package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
  141. package/resolver/recordTypes/fileManager/fileManagerOnPut.js +7 -14
  142. package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
  143. package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
  144. package/resolver/recordTypes/fileManager/shouldBeHandled.js +1 -8
  145. package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
  146. package/resolver/recordTypes/fileManager/types.d.ts +2 -2
  147. package/resolver/recordTypes/fileManager/types.js +1 -5
  148. package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
  149. package/resolver/recordTypes/users/CopyUser.js +3 -10
  150. package/resolver/recordTypes/users/CopyUser.js.map +1 -1
  151. package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
  152. package/resolver/recordTypes/users/DeleteUser.js +3 -10
  153. package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
  154. package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
  155. package/resolver/recordTypes/users/shouldBeHandled.js +1 -8
  156. package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
  157. package/resolver/recordTypes/users/types.d.ts +1 -1
  158. package/resolver/recordTypes/users/types.js +1 -5
  159. package/resolver/recordTypes/users/types.js.map +1 -1
  160. package/resolver/recordTypes/users/users.js +4 -11
  161. package/resolver/recordTypes/users/users.js.map +1 -1
  162. package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
  163. package/resolver/recordTypes/users/usersOnDelete.js +7 -14
  164. package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
  165. package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
  166. package/resolver/recordTypes/users/usersOnPut.js +7 -14
  167. package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
  168. package/sync/FilterOutRecord.d.ts +2 -2
  169. package/sync/FilterOutRecord.js +2 -10
  170. package/sync/FilterOutRecord.js.map +1 -1
  171. package/sync/attachToDynamoDbDocument.d.ts +1 -1
  172. package/sync/attachToDynamoDbDocument.js +9 -17
  173. package/sync/attachToDynamoDbDocument.js.map +1 -1
  174. package/sync/createHandler.js +27 -34
  175. package/sync/createHandler.js.map +1 -1
  176. package/sync/createSendDataToEventBridgeOnRequestEnd.js +6 -13
  177. package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
  178. package/sync/createSyncSystem.d.ts +1 -1
  179. package/sync/createSyncSystem.js +6 -13
  180. package/sync/createSyncSystem.js.map +1 -1
  181. package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
  182. package/sync/filter/createDefaultFilterOutRecordPlugins.js +9 -19
  183. package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
  184. package/sync/handler/Handler.d.ts +2 -2
  185. package/sync/handler/Handler.js +9 -17
  186. package/sync/handler/Handler.js.map +1 -1
  187. package/sync/handler/HandlerConverter.js +2 -10
  188. package/sync/handler/HandlerConverter.js.map +1 -1
  189. package/sync/handler/converter/BatchGetCommandConverter.js +6 -14
  190. package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
  191. package/sync/handler/converter/BatchWriteCommandConverter.js +6 -14
  192. package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
  193. package/sync/handler/converter/DeleteCommandConverter.js +6 -14
  194. package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
  195. package/sync/handler/converter/GetCommandConverter.js +6 -14
  196. package/sync/handler/converter/GetCommandConverter.js.map +1 -1
  197. package/sync/handler/converter/PutCommandConverter.js +6 -14
  198. package/sync/handler/converter/PutCommandConverter.js.map +1 -1
  199. package/sync/handler/converter/QueryCommandConverter.js +6 -14
  200. package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
  201. package/sync/handler/converter/ScanCommandConverter.js +6 -14
  202. package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
  203. package/sync/handler/converter/UpdateCommandConverter.js +6 -14
  204. package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
  205. package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
  206. package/sync/handler/converter/commands/BatchWriteCommandValue.js +4 -11
  207. package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
  208. package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
  209. package/sync/handler/converter/commands/DeleteCommandValue.js +3 -10
  210. package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
  211. package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
  212. package/sync/handler/converter/commands/NullCommandValue.js +1 -8
  213. package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
  214. package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
  215. package/sync/handler/converter/commands/PutCommandValue.js +3 -10
  216. package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
  217. package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
  218. package/sync/handler/converter/commands/UpdateCommandValue.js +3 -10
  219. package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
  220. package/sync/handler/types.d.ts +3 -3
  221. package/sync/handler/types.js +1 -5
  222. package/sync/handler/types.js.map +1 -1
  223. package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
  224. package/sync/plugins/FilterOutRecordPlugin.js +3 -11
  225. package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
  226. package/sync/requestPlugin.d.ts +1 -1
  227. package/sync/requestPlugin.js +19 -20
  228. package/sync/requestPlugin.js.map +1 -1
  229. package/sync/types.js +1 -5
  230. package/sync/utils/getTableType.js +7 -14
  231. package/sync/utils/getTableType.js.map +1 -1
  232. package/sync/utils/manifest.d.ts +1 -1
  233. package/sync/utils/manifest.js +12 -20
  234. package/sync/utils/manifest.js.map +1 -1
  235. package/sync/utils/validateSystemInput.d.ts +1 -1
  236. package/sync/utils/validateSystemInput.js +3 -10
  237. package/sync/utils/validateSystemInput.js.map +1 -1
  238. package/types.d.ts +3 -4
  239. package/types.js +2 -8
  240. package/types.js.map +1 -1
  241. package/utils/createSystemName.js +1 -8
  242. package/utils/createSystemName.js.map +1 -1
  243. package/worker/actions/copyFile/CopyFile.js +13 -21
  244. package/worker/actions/copyFile/CopyFile.js.map +1 -1
  245. package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
  246. package/worker/actions/copyFile/copyFileAction.js +9 -16
  247. package/worker/actions/copyFile/copyFileAction.js.map +1 -1
  248. package/worker/actions/copyFile/copyFileSchema.d.ts +2 -2
  249. package/worker/actions/copyFile/copyFileSchema.js +8 -16
  250. package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
  251. package/worker/actions/copyFile/types.js +1 -5
  252. package/worker/actions/createUser/CreateUser.d.ts +1 -1
  253. package/worker/actions/createUser/CreateUser.js +9 -16
  254. package/worker/actions/createUser/CreateUser.js.map +1 -1
  255. package/worker/actions/createUser/createUserAction.d.ts +2 -2
  256. package/worker/actions/createUser/createUserAction.js +9 -16
  257. package/worker/actions/createUser/createUserAction.js.map +1 -1
  258. package/worker/actions/createUser/createUserSchema.d.ts +2 -2
  259. package/worker/actions/createUser/createUserSchema.js +8 -16
  260. package/worker/actions/createUser/createUserSchema.js.map +1 -1
  261. package/worker/actions/createUser/types.js +1 -5
  262. package/worker/actions/deleteFile/DeleteFile.js +4 -11
  263. package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
  264. package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
  265. package/worker/actions/deleteFile/deleteFileAction.js +9 -16
  266. package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
  267. package/worker/actions/deleteFile/deleteFileSchema.d.ts +2 -2
  268. package/worker/actions/deleteFile/deleteFileSchema.js +8 -16
  269. package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
  270. package/worker/actions/deleteFile/types.js +1 -5
  271. package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
  272. package/worker/actions/deleteUser/DeleteUser.js +7 -14
  273. package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
  274. package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
  275. package/worker/actions/deleteUser/deleteUserAction.js +9 -16
  276. package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
  277. package/worker/actions/deleteUser/deleteUserSchema.js +8 -16
  278. package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
  279. package/worker/actions/deleteUser/types.js +1 -5
  280. package/worker/actions/logValidationError.js +4 -11
  281. package/worker/actions/logValidationError.js.map +1 -1
  282. package/worker/actions/removeCognitoUserAttributes.js +1 -8
  283. package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
  284. package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
  285. package/worker/actions/updateUser/UpdateUser.js +9 -16
  286. package/worker/actions/updateUser/UpdateUser.js.map +1 -1
  287. package/worker/actions/updateUser/types.js +1 -5
  288. package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
  289. package/worker/actions/updateUser/updateUserAction.js +9 -16
  290. package/worker/actions/updateUser/updateUserAction.js.map +1 -1
  291. package/worker/actions/updateUser/updateUserSchema.d.ts +2 -2
  292. package/worker/actions/updateUser/updateUserSchema.js +8 -16
  293. package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
  294. package/worker/createWorkerHandler.js +17 -24
  295. package/worker/createWorkerHandler.js.map +1 -1
  296. package/worker/handler/WorkerActionHandler.d.ts +2 -2
  297. package/worker/handler/WorkerActionHandler.js +3 -10
  298. package/worker/handler/WorkerActionHandler.js.map +1 -1
  299. package/worker/handler/eventHandler.js +9 -16
  300. package/worker/handler/eventHandler.js.map +1 -1
  301. package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
  302. package/worker/plugins/WorkerActionPlugin.js +3 -11
  303. package/worker/plugins/WorkerActionPlugin.js.map +1 -1
  304. package/worker/types.js +1 -5
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createStorerAfterEachPluginWithName = exports.createStorerAfterEachPlugin = exports.StorerAfterEachPlugin = void 0;
7
- var _Plugin = require("@webiny/plugins/Plugin.js");
8
- class StorerAfterEachPlugin extends _Plugin.Plugin {
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ export class StorerAfterEachPlugin extends Plugin {
9
3
  static type = "syncSystem.storerAfterEachPlugin";
10
4
  constructor(config) {
11
5
  super();
@@ -18,16 +12,13 @@ class StorerAfterEachPlugin extends _Plugin.Plugin {
18
12
  return this.config.handle(params);
19
13
  }
20
14
  }
21
- exports.StorerAfterEachPlugin = StorerAfterEachPlugin;
22
- const createStorerAfterEachPlugin = params => {
15
+ export const createStorerAfterEachPlugin = params => {
23
16
  return new StorerAfterEachPlugin(params);
24
17
  };
25
- exports.createStorerAfterEachPlugin = createStorerAfterEachPlugin;
26
- const createStorerAfterEachPluginWithName = (name, params) => {
18
+ export const createStorerAfterEachPluginWithName = (name, params) => {
27
19
  const plugin = createStorerAfterEachPlugin(params);
28
20
  plugin.name = `${StorerAfterEachPlugin.type}.${name}`;
29
21
  return plugin;
30
22
  };
31
- exports.createStorerAfterEachPluginWithName = createStorerAfterEachPluginWithName;
32
23
 
33
24
  //# sourceMappingURL=StorerAfterEachPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","StorerAfterEachPlugin","Plugin","type","constructor","config","canHandle","params","handle","exports","createStorerAfterEachPlugin","createStorerAfterEachPluginWithName","name","plugin"],"sources":["StorerAfterEachPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { CommandType } from \"~/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\n\nexport interface IStorerAfterEachPluginCanHandleParams {\n command: CommandType;\n target: IDeployment;\n source: IDeployment;\n table: ITable;\n item: IStoreItem;\n}\n\nexport interface IStorerAfterEachPluginHandleParams {\n target: IDeployment;\n source: IDeployment;\n table: ITable;\n item: IStoreItem;\n}\n\nexport interface IStorerAfterEachPluginParams {\n canHandle: (params: IStorerAfterEachPluginCanHandleParams) => boolean;\n handle: (params: IStorerAfterEachPluginHandleParams) => Promise<void>;\n}\n\nexport class StorerAfterEachPlugin extends Plugin {\n public static override readonly type: string = \"syncSystem.storerAfterEachPlugin\";\n\n private readonly config: IStorerAfterEachPluginParams;\n\n public constructor(config: IStorerAfterEachPluginParams) {\n super();\n this.config = config;\n }\n\n public canHandle(params: IStorerAfterEachPluginCanHandleParams): boolean {\n return this.config.canHandle(params);\n }\n\n public handle(params: IStorerAfterEachPluginHandleParams): Promise<void> {\n return this.config.handle(params);\n }\n}\n\nexport const createStorerAfterEachPlugin = (params: IStorerAfterEachPluginParams) => {\n return new StorerAfterEachPlugin(params);\n};\n\nexport const createStorerAfterEachPluginWithName = (\n name: string,\n params: IStorerAfterEachPluginParams\n) => {\n const plugin = createStorerAfterEachPlugin(params);\n plugin.name = `${StorerAfterEachPlugin.type}.${name}`;\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AA0BO,MAAMC,qBAAqB,SAASC,cAAM,CAAC;EAC9C,OAAgCC,IAAI,GAAW,kCAAkC;EAI1EC,WAAWA,CAACC,MAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,SAASA,CAACC,MAA6C,EAAW;IACrE,OAAO,IAAI,CAACF,MAAM,CAACC,SAAS,CAACC,MAAM,CAAC;EACxC;EAEOC,MAAMA,CAACD,MAA0C,EAAiB;IACrE,OAAO,IAAI,CAACF,MAAM,CAACG,MAAM,CAACD,MAAM,CAAC;EACrC;AACJ;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA;AAEM,MAAMS,2BAA2B,GAAIH,MAAoC,IAAK;EACjF,OAAO,IAAIN,qBAAqB,CAACM,MAAM,CAAC;AAC5C,CAAC;AAACE,OAAA,CAAAC,2BAAA,GAAAA,2BAAA;AAEK,MAAMC,mCAAmC,GAAGA,CAC/CC,IAAY,EACZL,MAAoC,KACnC;EACD,MAAMM,MAAM,GAAGH,2BAA2B,CAACH,MAAM,CAAC;EAClDM,MAAM,CAACD,IAAI,GAAG,GAAGX,qBAAqB,CAACE,IAAI,IAAIS,IAAI,EAAE;EACrD,OAAOC,MAAM;AACjB,CAAC;AAACJ,OAAA,CAAAE,mCAAA,GAAAA,mCAAA","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","StorerAfterEachPlugin","type","constructor","config","canHandle","params","handle","createStorerAfterEachPlugin","createStorerAfterEachPluginWithName","name","plugin"],"sources":["StorerAfterEachPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { CommandType } from \"~/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\n\nexport interface IStorerAfterEachPluginCanHandleParams {\n command: CommandType;\n target: IDeployment;\n source: IDeployment;\n table: ITable;\n item: IStoreItem;\n}\n\nexport interface IStorerAfterEachPluginHandleParams {\n target: IDeployment;\n source: IDeployment;\n table: ITable;\n item: IStoreItem;\n}\n\nexport interface IStorerAfterEachPluginParams {\n canHandle: (params: IStorerAfterEachPluginCanHandleParams) => boolean;\n handle: (params: IStorerAfterEachPluginHandleParams) => Promise<void>;\n}\n\nexport class StorerAfterEachPlugin extends Plugin {\n public static override readonly type: string = \"syncSystem.storerAfterEachPlugin\";\n\n private readonly config: IStorerAfterEachPluginParams;\n\n public constructor(config: IStorerAfterEachPluginParams) {\n super();\n this.config = config;\n }\n\n public canHandle(params: IStorerAfterEachPluginCanHandleParams): boolean {\n return this.config.canHandle(params);\n }\n\n public handle(params: IStorerAfterEachPluginHandleParams): Promise<void> {\n return this.config.handle(params);\n }\n}\n\nexport const createStorerAfterEachPlugin = (params: IStorerAfterEachPluginParams) => {\n return new StorerAfterEachPlugin(params);\n};\n\nexport const createStorerAfterEachPluginWithName = (\n name: string,\n params: IStorerAfterEachPluginParams\n) => {\n const plugin = createStorerAfterEachPlugin(params);\n plugin.name = `${StorerAfterEachPlugin.type}.${name}`;\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,2BAA2B;AA0BlD,OAAO,MAAMC,qBAAqB,SAASD,MAAM,CAAC;EAC9C,OAAgCE,IAAI,GAAW,kCAAkC;EAI1EC,WAAWA,CAACC,MAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,SAASA,CAACC,MAA6C,EAAW;IACrE,OAAO,IAAI,CAACF,MAAM,CAACC,SAAS,CAACC,MAAM,CAAC;EACxC;EAEOC,MAAMA,CAACD,MAA0C,EAAiB;IACrE,OAAO,IAAI,CAACF,MAAM,CAACG,MAAM,CAACD,MAAM,CAAC;EACrC;AACJ;AAEA,OAAO,MAAME,2BAA2B,GAAIF,MAAoC,IAAK;EACjF,OAAO,IAAIL,qBAAqB,CAACK,MAAM,CAAC;AAC5C,CAAC;AAED,OAAO,MAAMG,mCAAmC,GAAGA,CAC/CC,IAAY,EACZJ,MAAoC,KACnC;EACD,MAAMK,MAAM,GAAGH,2BAA2B,CAACF,MAAM,CAAC;EAClDK,MAAM,CAACD,IAAI,GAAG,GAAGT,qBAAqB,CAACC,IAAI,IAAIQ,IAAI,EAAE;EACrD,OAAOC,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import type { ITable } from "../../sync/types.js";
3
- import type { IDeployment } from "../deployment/types.js";
4
- import type { IStoreItem } from "../app/storer/types.js";
3
+ import type { IDeployment } from "../../resolver/deployment/types.js";
4
+ import type { IStoreItem } from "../../resolver/app/storer/types.js";
5
5
  import type { DynamoDBTableType } from "../../types.js";
6
6
  import type { PluginsContainer } from "@webiny/plugins/PluginsContainer.js";
7
7
  export interface ITransformRecordPluginConfigTransformCallableParams {
@@ -23,7 +23,7 @@ export interface ITransformRecordPluginConfigTransformCallable {
23
23
  (params: ITransformRecordPluginConfigTransformCallableParams, next: () => Promise<Readonly<IStoreItem>>): Promise<Readonly<IStoreItem>>;
24
24
  }
25
25
  export interface ITransformRecordPluginConfig {
26
- tableType: DynamoDBTableType.REGULAR | DynamoDBTableType.ELASTICSEARCH;
26
+ tableType: DynamoDBTableType.REGULAR | DynamoDBTableType.OPENSEARCH;
27
27
  canTransform: ITransformRecordPluginConfigCanTransformCallable;
28
28
  transform: ITransformRecordPluginConfigTransformCallable;
29
29
  }
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createTransformRecordPlugin = exports.TransformRecordPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class TransformRecordPlugin extends _plugins.Plugin {
1
+ import { Plugin } from "@webiny/plugins";
2
+ export class TransformRecordPlugin extends Plugin {
9
3
  static type = "syncSystem.transformRecordPlugin";
10
4
  constructor(config) {
11
5
  super();
@@ -21,10 +15,8 @@ class TransformRecordPlugin extends _plugins.Plugin {
21
15
  return this.config.transform(params, next);
22
16
  }
23
17
  }
24
- exports.TransformRecordPlugin = TransformRecordPlugin;
25
- const createTransformRecordPlugin = config => {
18
+ export const createTransformRecordPlugin = config => {
26
19
  return new TransformRecordPlugin(config);
27
20
  };
28
- exports.createTransformRecordPlugin = createTransformRecordPlugin;
29
21
 
30
22
  //# sourceMappingURL=TransformRecordPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","TransformRecordPlugin","Plugin","type","constructor","config","isForTableType","tableType","canTransform","params","transform","next","exports","createTransformRecordPlugin"],"sources":["TransformRecordPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { DynamoDBTableType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\n\nexport interface ITransformRecordPluginConfigTransformCallableParams {\n readonly plugins: PluginsContainer;\n readonly record: IStoreItem;\n sourceDeployment: IDeployment;\n targetDeployment: IDeployment;\n sourceTable: ITable;\n targetTable: ITable;\n}\n\nexport interface ITransformRecordPluginConfigCanTransformCallableParams {\n from: Omit<IDeployment, \"getTable\">;\n to: Omit<IDeployment, \"getTable\">;\n}\n\nexport interface ITransformRecordPluginConfigCanTransformCallable {\n (params: ITransformRecordPluginConfigCanTransformCallableParams): boolean;\n}\n\nexport interface ITransformRecordPluginConfigTransformCallable {\n (\n params: ITransformRecordPluginConfigTransformCallableParams,\n next: () => Promise<Readonly<IStoreItem>>\n ): Promise<Readonly<IStoreItem>>;\n}\n\nexport interface ITransformRecordPluginConfig {\n tableType: DynamoDBTableType.REGULAR | DynamoDBTableType.ELASTICSEARCH;\n canTransform: ITransformRecordPluginConfigCanTransformCallable;\n transform: ITransformRecordPluginConfigTransformCallable;\n}\n\nexport class TransformRecordPlugin extends Plugin {\n public static override type: string = \"syncSystem.transformRecordPlugin\";\n\n private readonly config: ITransformRecordPluginConfig;\n\n public constructor(config: ITransformRecordPluginConfig) {\n super();\n this.config = config;\n }\n\n public isForTableType(tableType: DynamoDBTableType): boolean {\n return this.config.tableType === tableType;\n }\n\n public canTransform(params: ITransformRecordPluginConfigCanTransformCallableParams): boolean {\n return this.config.canTransform(params);\n }\n\n public transform(\n params: ITransformRecordPluginConfigTransformCallableParams,\n next: () => Promise<Readonly<IStoreItem>>\n ): Promise<Readonly<IStoreItem>> {\n return this.config.transform(params, next);\n }\n}\n\nexport const createTransformRecordPlugin = (config: ITransformRecordPluginConfig) => {\n return new TransformRecordPlugin(config);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAsCO,MAAMC,qBAAqB,SAASC,eAAM,CAAC;EAC9C,OAAuBC,IAAI,GAAW,kCAAkC;EAIjEC,WAAWA,CAACC,MAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,cAAcA,CAACC,SAA4B,EAAW;IACzD,OAAO,IAAI,CAACF,MAAM,CAACE,SAAS,KAAKA,SAAS;EAC9C;EAEOC,YAAYA,CAACC,MAA8D,EAAW;IACzF,OAAO,IAAI,CAACJ,MAAM,CAACG,YAAY,CAACC,MAAM,CAAC;EAC3C;EAEOC,SAASA,CACZD,MAA2D,EAC3DE,IAAyC,EACZ;IAC7B,OAAO,IAAI,CAACN,MAAM,CAACK,SAAS,CAACD,MAAM,EAAEE,IAAI,CAAC;EAC9C;AACJ;AAACC,OAAA,CAAAX,qBAAA,GAAAA,qBAAA;AAEM,MAAMY,2BAA2B,GAAIR,MAAoC,IAAK;EACjF,OAAO,IAAIJ,qBAAqB,CAACI,MAAM,CAAC;AAC5C,CAAC;AAACO,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","TransformRecordPlugin","type","constructor","config","isForTableType","tableType","canTransform","params","transform","next","createTransformRecordPlugin"],"sources":["TransformRecordPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { IStoreItem } from \"~/resolver/app/storer/types.js\";\nimport type { DynamoDBTableType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\n\nexport interface ITransformRecordPluginConfigTransformCallableParams {\n readonly plugins: PluginsContainer;\n readonly record: IStoreItem;\n sourceDeployment: IDeployment;\n targetDeployment: IDeployment;\n sourceTable: ITable;\n targetTable: ITable;\n}\n\nexport interface ITransformRecordPluginConfigCanTransformCallableParams {\n from: Omit<IDeployment, \"getTable\">;\n to: Omit<IDeployment, \"getTable\">;\n}\n\nexport interface ITransformRecordPluginConfigCanTransformCallable {\n (params: ITransformRecordPluginConfigCanTransformCallableParams): boolean;\n}\n\nexport interface ITransformRecordPluginConfigTransformCallable {\n (\n params: ITransformRecordPluginConfigTransformCallableParams,\n next: () => Promise<Readonly<IStoreItem>>\n ): Promise<Readonly<IStoreItem>>;\n}\n\nexport interface ITransformRecordPluginConfig {\n tableType: DynamoDBTableType.REGULAR | DynamoDBTableType.OPENSEARCH;\n canTransform: ITransformRecordPluginConfigCanTransformCallable;\n transform: ITransformRecordPluginConfigTransformCallable;\n}\n\nexport class TransformRecordPlugin extends Plugin {\n public static override type: string = \"syncSystem.transformRecordPlugin\";\n\n private readonly config: ITransformRecordPluginConfig;\n\n public constructor(config: ITransformRecordPluginConfig) {\n super();\n this.config = config;\n }\n\n public isForTableType(tableType: DynamoDBTableType): boolean {\n return this.config.tableType === tableType;\n }\n\n public canTransform(params: ITransformRecordPluginConfigCanTransformCallableParams): boolean {\n return this.config.canTransform(params);\n }\n\n public transform(\n params: ITransformRecordPluginConfigTransformCallableParams,\n next: () => Promise<Readonly<IStoreItem>>\n ): Promise<Readonly<IStoreItem>> {\n return this.config.transform(params, next);\n }\n}\n\nexport const createTransformRecordPlugin = (config: ITransformRecordPluginConfig) => {\n return new TransformRecordPlugin(config);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAsCxC,OAAO,MAAMC,qBAAqB,SAASD,MAAM,CAAC;EAC9C,OAAuBE,IAAI,GAAW,kCAAkC;EAIjEC,WAAWA,CAACC,MAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,cAAcA,CAACC,SAA4B,EAAW;IACzD,OAAO,IAAI,CAACF,MAAM,CAACE,SAAS,KAAKA,SAAS;EAC9C;EAEOC,YAAYA,CAACC,MAA8D,EAAW;IACzF,OAAO,IAAI,CAACJ,MAAM,CAACG,YAAY,CAACC,MAAM,CAAC;EAC3C;EAEOC,SAASA,CACZD,MAA2D,EAC3DE,IAAyC,EACZ;IAC7B,OAAO,IAAI,CAACN,MAAM,CAACK,SAAS,CAACD,MAAM,EAAEE,IAAI,CAAC;EAC9C;AACJ;AAEA,OAAO,MAAMC,2BAA2B,GAAIP,MAAoC,IAAK;EACjF,OAAO,IAAIH,qBAAqB,CAACG,MAAM,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CopyFile = void 0;
7
- var _index = require("@webiny/aws-sdk/client-s3/index.js");
8
- class CopyFile {
1
+ import { HeadObjectCommand } from "@webiny/aws-sdk/client-s3/index.js";
2
+ export class CopyFile {
9
3
  constructor(params) {
10
4
  this.createS3Client = params.createS3Client;
11
5
  this.getLambdaTrigger = params.getLambdaTrigger;
@@ -62,11 +56,11 @@ class CopyFile {
62
56
  Bucket: bucket,
63
57
  Key: key
64
58
  };
65
- const cmd = new _index.HeadObjectCommand(input);
59
+ const cmd = new HeadObjectCommand(input);
66
60
  try {
67
61
  const result = await client.send(cmd);
68
62
  return result.$metadata?.httpStatusCode === 200 && !!result.ETag;
69
- } catch (ex) {
63
+ } catch {
70
64
  /**
71
65
  * TODO What happens if this fails? To we continue with the copy or end the process?
72
66
  * Do we log the error?
@@ -76,6 +70,5 @@ class CopyFile {
76
70
  }
77
71
  }
78
72
  }
79
- exports.CopyFile = CopyFile;
80
73
 
81
74
  //# sourceMappingURL=CopyFile.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_index","require","CopyFile","constructor","params","createS3Client","getLambdaTrigger","handle","key","source","target","targetClient","region","exists","client","bucket","services","s3Id","invocationType","payload","action","input","Bucket","Key","cmd","HeadObjectCommand","result","send","$metadata","httpStatusCode","ETag","ex","exports"],"sources":["CopyFile.ts"],"sourcesContent":["import type { HeadObjectCommandInput, S3Client } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport type {\n ICopyFile,\n ICopyFileHandleParams,\n ICreateS3ClientCb,\n IGetLambdaTriggerCb\n} from \"./types.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { ICopyFileLambdaPayload } from \"~/types.js\";\n\ninterface IExistsParams {\n client: Pick<S3Client, \"send\">;\n bucket: string;\n key: string;\n}\n\nexport interface ICopyFileParams {\n createS3Client: ICreateS3ClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb<ICopyFileLambdaPayload>;\n}\n\nexport class CopyFile implements ICopyFile {\n private readonly createS3Client: ICreateS3ClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb<ICopyFileLambdaPayload>;\n\n public constructor(params: ICopyFileParams) {\n this.createS3Client = params.createS3Client;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: ICopyFileHandleParams): Promise<InvokeCommandOutput | null> {\n const { key, source, target } = params;\n /**\n * We need to check on the target if the file already exists.\n */\n const targetClient = this.createS3Client({\n region: target.region\n });\n\n const exists = await this.exists({\n client: targetClient,\n bucket: target.services.s3Id,\n key\n });\n\n if (exists) {\n // If the file already exists, we can skip copying it.\n return null;\n }\n\n /**\n * Then we can safely trigger a Lambda function that will copy the file.\n */\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n action: \"copyFile\",\n key,\n source: {\n region: source.region,\n bucket: source.services.s3Id\n },\n target: {\n region: target.region,\n bucket: target.services.s3Id\n }\n }\n });\n }\n\n private async exists(params: IExistsParams): Promise<boolean> {\n const { client, bucket, key } = params;\n const input: HeadObjectCommandInput = {\n Bucket: bucket,\n Key: key\n };\n const cmd = new HeadObjectCommand(input);\n try {\n const result = await client.send(cmd);\n return result.$metadata?.httpStatusCode === 200 && !!result.ETag;\n } catch (ex) {\n /**\n * TODO What happens if this fails? To we continue with the copy or end the process?\n * Do we log the error?\n * For now, we will assume that file does not exist.\n */\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAqBO,MAAMC,QAAQ,CAAsB;EAIhCC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,cAAc,GAAGD,MAAM,CAACC,cAAc;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA6B,EAAuC;IACpF,MAAM;MAAEI,GAAG;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IACtC;AACR;AACA;IACQ,MAAMO,YAAY,GAAG,IAAI,CAACN,cAAc,CAAC;MACrCO,MAAM,EAAEF,MAAM,CAACE;IACnB,CAAC,CAAC;IAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACA,MAAM,CAAC;MAC7BC,MAAM,EAAEH,YAAY;MACpBI,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC,IAAI;MAC5BT;IACJ,CAAC,CAAC;IAEF,IAAIK,MAAM,EAAE;MACR;MACA,OAAO,IAAI;IACf;;IAEA;AACR;AACA;;IAEQ,OAAO,MAAM,IAAI,CAACP,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCW,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACLC,MAAM,EAAE,UAAU;QAClBZ,GAAG;QACHC,MAAM,EAAE;UACJG,MAAM,EAAEH,MAAM,CAACG,MAAM;UACrBG,MAAM,EAAEN,MAAM,CAACO,QAAQ,CAACC;QAC5B,CAAC;QACDP,MAAM,EAAE;UACJE,MAAM,EAAEF,MAAM,CAACE,MAAM;UACrBG,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC;QAC5B;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcJ,MAAMA,CAACT,MAAqB,EAAoB;IAC1D,MAAM;MAAEU,MAAM;MAAEC,MAAM;MAAEP;IAAI,CAAC,GAAGJ,MAAM;IACtC,MAAMiB,KAA6B,GAAG;MAClCC,MAAM,EAAEP,MAAM;MACdQ,GAAG,EAAEf;IACT,CAAC;IACD,MAAMgB,GAAG,GAAG,IAAIC,wBAAiB,CAACJ,KAAK,CAAC;IACxC,IAAI;MACA,MAAMK,MAAM,GAAG,MAAMZ,MAAM,CAACa,IAAI,CAACH,GAAG,CAAC;MACrC,OAAOE,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG,IAAI,CAAC,CAACH,MAAM,CAACI,IAAI;IACpE,CAAC,CAAC,OAAOC,EAAE,EAAE;MACT;AACZ;AACA;AACA;AACA;MACY,OAAO,KAAK;IAChB;EACJ;AACJ;AAACC,OAAA,CAAA9B,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["HeadObjectCommand","CopyFile","constructor","params","createS3Client","getLambdaTrigger","handle","key","source","target","targetClient","region","exists","client","bucket","services","s3Id","invocationType","payload","action","input","Bucket","Key","cmd","result","send","$metadata","httpStatusCode","ETag"],"sources":["CopyFile.ts"],"sourcesContent":["import type { HeadObjectCommandInput, S3Client } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport type {\n ICopyFile,\n ICopyFileHandleParams,\n ICreateS3ClientCb,\n IGetLambdaTriggerCb\n} from \"./types.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { ICopyFileLambdaPayload } from \"~/types.js\";\n\ninterface IExistsParams {\n client: Pick<S3Client, \"send\">;\n bucket: string;\n key: string;\n}\n\nexport interface ICopyFileParams {\n createS3Client: ICreateS3ClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb<ICopyFileLambdaPayload>;\n}\n\nexport class CopyFile implements ICopyFile {\n private readonly createS3Client: ICreateS3ClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb<ICopyFileLambdaPayload>;\n\n public constructor(params: ICopyFileParams) {\n this.createS3Client = params.createS3Client;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: ICopyFileHandleParams): Promise<InvokeCommandOutput | null> {\n const { key, source, target } = params;\n /**\n * We need to check on the target if the file already exists.\n */\n const targetClient = this.createS3Client({\n region: target.region\n });\n\n const exists = await this.exists({\n client: targetClient,\n bucket: target.services.s3Id,\n key\n });\n\n if (exists) {\n // If the file already exists, we can skip copying it.\n return null;\n }\n\n /**\n * Then we can safely trigger a Lambda function that will copy the file.\n */\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n action: \"copyFile\",\n key,\n source: {\n region: source.region,\n bucket: source.services.s3Id\n },\n target: {\n region: target.region,\n bucket: target.services.s3Id\n }\n }\n });\n }\n\n private async exists(params: IExistsParams): Promise<boolean> {\n const { client, bucket, key } = params;\n const input: HeadObjectCommandInput = {\n Bucket: bucket,\n Key: key\n };\n const cmd = new HeadObjectCommand(input);\n try {\n const result = await client.send(cmd);\n return result.$metadata?.httpStatusCode === 200 && !!result.ETag;\n } catch {\n /**\n * TODO What happens if this fails? To we continue with the copy or end the process?\n * Do we log the error?\n * For now, we will assume that file does not exist.\n */\n return false;\n }\n }\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,oCAAoC;AAqBtE,OAAO,MAAMC,QAAQ,CAAsB;EAIhCC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,cAAc,GAAGD,MAAM,CAACC,cAAc;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA6B,EAAuC;IACpF,MAAM;MAAEI,GAAG;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IACtC;AACR;AACA;IACQ,MAAMO,YAAY,GAAG,IAAI,CAACN,cAAc,CAAC;MACrCO,MAAM,EAAEF,MAAM,CAACE;IACnB,CAAC,CAAC;IAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACA,MAAM,CAAC;MAC7BC,MAAM,EAAEH,YAAY;MACpBI,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC,IAAI;MAC5BT;IACJ,CAAC,CAAC;IAEF,IAAIK,MAAM,EAAE;MACR;MACA,OAAO,IAAI;IACf;;IAEA;AACR;AACA;;IAEQ,OAAO,MAAM,IAAI,CAACP,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCW,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACLC,MAAM,EAAE,UAAU;QAClBZ,GAAG;QACHC,MAAM,EAAE;UACJG,MAAM,EAAEH,MAAM,CAACG,MAAM;UACrBG,MAAM,EAAEN,MAAM,CAACO,QAAQ,CAACC;QAC5B,CAAC;QACDP,MAAM,EAAE;UACJE,MAAM,EAAEF,MAAM,CAACE,MAAM;UACrBG,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC;QAC5B;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcJ,MAAMA,CAACT,MAAqB,EAAoB;IAC1D,MAAM;MAAEU,MAAM;MAAEC,MAAM;MAAEP;IAAI,CAAC,GAAGJ,MAAM;IACtC,MAAMiB,KAA6B,GAAG;MAClCC,MAAM,EAAEP,MAAM;MACdQ,GAAG,EAAEf;IACT,CAAC;IACD,MAAMgB,GAAG,GAAG,IAAIvB,iBAAiB,CAACoB,KAAK,CAAC;IACxC,IAAI;MACA,MAAMI,MAAM,GAAG,MAAMX,MAAM,CAACY,IAAI,CAACF,GAAG,CAAC;MACrC,OAAOC,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG,IAAI,CAAC,CAACH,MAAM,CAACI,IAAI;IACpE,CAAC,CAAC,MAAM;MACJ;AACZ;AACA;AACA;AACA;MACY,OAAO,KAAK;IAChB;EACJ;AACJ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ICreateS3ClientCb, IDeleteFile, IDeleteFileHandleParams, IGetLambdaTriggerCb } from "./types.js";
1
+ import type { ICreateS3ClientCb, IDeleteFile, IDeleteFileHandleParams, IGetLambdaTriggerCb } from "../../../resolver/recordTypes/fileManager/types.js";
2
2
  import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
3
3
  import type { IDeleteFileLambdaPayload } from "../../../types.js";
4
4
  export interface IDeleteFileParams {
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DeleteFile = void 0;
7
- var _index = require("@webiny/aws-sdk/client-s3/index.js");
8
- class DeleteFile {
1
+ import { HeadObjectCommand } from "@webiny/aws-sdk/client-s3/index.js";
2
+ export class DeleteFile {
9
3
  constructor(params) {
10
4
  this.createS3Client = params.createS3Client;
11
5
  this.getLambdaTrigger = params.getLambdaTrigger;
@@ -58,7 +52,7 @@ class DeleteFile {
58
52
  Bucket: bucket,
59
53
  Key: key
60
54
  };
61
- const cmd = new _index.HeadObjectCommand(input);
55
+ const cmd = new HeadObjectCommand(input);
62
56
  try {
63
57
  const result = await client.send(cmd);
64
58
  return result.$metadata?.httpStatusCode === 200;
@@ -67,6 +61,5 @@ class DeleteFile {
67
61
  }
68
62
  }
69
63
  }
70
- exports.DeleteFile = DeleteFile;
71
64
 
72
65
  //# sourceMappingURL=DeleteFile.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_index","require","DeleteFile","constructor","params","createS3Client","getLambdaTrigger","handle","key","target","targetClient","region","exists","client","bucket","services","s3Id","invocationType","payload","action","input","Bucket","Key","cmd","HeadObjectCommand","result","send","$metadata","httpStatusCode","exports"],"sources":["DeleteFile.ts"],"sourcesContent":["import type {\n ICreateS3ClientCb,\n IDeleteFile,\n IDeleteFileHandleParams,\n IGetLambdaTriggerCb\n} from \"~/resolver/recordTypes/fileManager/types.js\";\nimport type { HeadObjectCommandInput, S3Client } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { IDeleteFileLambdaPayload } from \"~/types.js\";\n\ninterface IExistsParams {\n client: Pick<S3Client, \"send\">;\n bucket: string;\n key: string;\n}\n\nexport interface IDeleteFileParams {\n createS3Client: ICreateS3ClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb<IDeleteFileLambdaPayload>;\n}\n\nexport class DeleteFile implements IDeleteFile {\n private readonly createS3Client: ICreateS3ClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb<IDeleteFileLambdaPayload>;\n\n public constructor(params: IDeleteFileParams) {\n this.createS3Client = params.createS3Client;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: IDeleteFileHandleParams): Promise<InvokeCommandOutput | null> {\n const { key, target } = params;\n\n /**\n * We need to check on the target if the file already exists.\n */\n\n const targetClient = this.createS3Client({\n region: target.region\n });\n\n const exists = await this.exists({\n client: targetClient,\n bucket: target.services.s3Id,\n key\n });\n if (!exists) {\n // If the file does not exist, we can skip the deletion.\n return null;\n }\n\n /**\n * Then we can safely trigger a Lambda function that will delete the file.\n */\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n action: \"deleteFile\",\n key,\n target: {\n region: target.region,\n bucket: target.services.s3Id\n }\n }\n });\n }\n\n private async exists(params: IExistsParams): Promise<boolean> {\n const { client, bucket, key } = params;\n const input: HeadObjectCommandInput = {\n Bucket: bucket,\n Key: key\n };\n const cmd = new HeadObjectCommand(input);\n try {\n const result = await client.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAeO,MAAMC,UAAU,CAAwB;EAIpCC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACC,cAAc,GAAGD,MAAM,CAACC,cAAc;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA+B,EAAuC;IACtF,MAAM;MAAEI,GAAG;MAAEC;IAAO,CAAC,GAAGL,MAAM;;IAE9B;AACR;AACA;;IAEQ,MAAMM,YAAY,GAAG,IAAI,CAACL,cAAc,CAAC;MACrCM,MAAM,EAAEF,MAAM,CAACE;IACnB,CAAC,CAAC;IAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACA,MAAM,CAAC;MAC7BC,MAAM,EAAEH,YAAY;MACpBI,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC,IAAI;MAC5BR;IACJ,CAAC,CAAC;IACF,IAAI,CAACI,MAAM,EAAE;MACT;MACA,OAAO,IAAI;IACf;;IAEA;AACR;AACA;IACQ,OAAO,MAAM,IAAI,CAACN,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCU,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACLC,MAAM,EAAE,YAAY;QACpBX,GAAG;QACHC,MAAM,EAAE;UACJE,MAAM,EAAEF,MAAM,CAACE,MAAM;UACrBG,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC;QAC5B;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcJ,MAAMA,CAACR,MAAqB,EAAoB;IAC1D,MAAM;MAAES,MAAM;MAAEC,MAAM;MAAEN;IAAI,CAAC,GAAGJ,MAAM;IACtC,MAAMgB,KAA6B,GAAG;MAClCC,MAAM,EAAEP,MAAM;MACdQ,GAAG,EAAEd;IACT,CAAC;IACD,MAAMe,GAAG,GAAG,IAAIC,wBAAiB,CAACJ,KAAK,CAAC;IACxC,IAAI;MACA,MAAMK,MAAM,GAAG,MAAMZ,MAAM,CAACa,IAAI,CAACH,GAAG,CAAC;MACrC,OAAOE,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ;AAACC,OAAA,CAAA3B,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["HeadObjectCommand","DeleteFile","constructor","params","createS3Client","getLambdaTrigger","handle","key","target","targetClient","region","exists","client","bucket","services","s3Id","invocationType","payload","action","input","Bucket","Key","cmd","result","send","$metadata","httpStatusCode"],"sources":["DeleteFile.ts"],"sourcesContent":["import type {\n ICreateS3ClientCb,\n IDeleteFile,\n IDeleteFileHandleParams,\n IGetLambdaTriggerCb\n} from \"~/resolver/recordTypes/fileManager/types.js\";\nimport type { HeadObjectCommandInput, S3Client } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { IDeleteFileLambdaPayload } from \"~/types.js\";\n\ninterface IExistsParams {\n client: Pick<S3Client, \"send\">;\n bucket: string;\n key: string;\n}\n\nexport interface IDeleteFileParams {\n createS3Client: ICreateS3ClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb<IDeleteFileLambdaPayload>;\n}\n\nexport class DeleteFile implements IDeleteFile {\n private readonly createS3Client: ICreateS3ClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb<IDeleteFileLambdaPayload>;\n\n public constructor(params: IDeleteFileParams) {\n this.createS3Client = params.createS3Client;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: IDeleteFileHandleParams): Promise<InvokeCommandOutput | null> {\n const { key, target } = params;\n\n /**\n * We need to check on the target if the file already exists.\n */\n\n const targetClient = this.createS3Client({\n region: target.region\n });\n\n const exists = await this.exists({\n client: targetClient,\n bucket: target.services.s3Id,\n key\n });\n if (!exists) {\n // If the file does not exist, we can skip the deletion.\n return null;\n }\n\n /**\n * Then we can safely trigger a Lambda function that will delete the file.\n */\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n action: \"deleteFile\",\n key,\n target: {\n region: target.region,\n bucket: target.services.s3Id\n }\n }\n });\n }\n\n private async exists(params: IExistsParams): Promise<boolean> {\n const { client, bucket, key } = params;\n const input: HeadObjectCommandInput = {\n Bucket: bucket,\n Key: key\n };\n const cmd = new HeadObjectCommand(input);\n try {\n const result = await client.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,oCAAoC;AAetE,OAAO,MAAMC,UAAU,CAAwB;EAIpCC,WAAWA,CAACC,MAAyB,EAAE;IAC1C,IAAI,CAACC,cAAc,GAAGD,MAAM,CAACC,cAAc;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA+B,EAAuC;IACtF,MAAM;MAAEI,GAAG;MAAEC;IAAO,CAAC,GAAGL,MAAM;;IAE9B;AACR;AACA;;IAEQ,MAAMM,YAAY,GAAG,IAAI,CAACL,cAAc,CAAC;MACrCM,MAAM,EAAEF,MAAM,CAACE;IACnB,CAAC,CAAC;IAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACA,MAAM,CAAC;MAC7BC,MAAM,EAAEH,YAAY;MACpBI,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC,IAAI;MAC5BR;IACJ,CAAC,CAAC;IACF,IAAI,CAACI,MAAM,EAAE;MACT;MACA,OAAO,IAAI;IACf;;IAEA;AACR;AACA;IACQ,OAAO,MAAM,IAAI,CAACN,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCU,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACLC,MAAM,EAAE,YAAY;QACpBX,GAAG;QACHC,MAAM,EAAE;UACJE,MAAM,EAAEF,MAAM,CAACE,MAAM;UACrBG,MAAM,EAAEL,MAAM,CAACM,QAAQ,CAACC;QAC5B;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcJ,MAAMA,CAACR,MAAqB,EAAoB;IAC1D,MAAM;MAAES,MAAM;MAAEC,MAAM;MAAEN;IAAI,CAAC,GAAGJ,MAAM;IACtC,MAAMgB,KAA6B,GAAG;MAClCC,MAAM,EAAEP,MAAM;MACdQ,GAAG,EAAEd;IACT,CAAC;IACD,MAAMe,GAAG,GAAG,IAAItB,iBAAiB,CAACmB,KAAK,CAAC;IACxC,IAAI;MACA,MAAMI,MAAM,GAAG,MAAMX,MAAM,CAACY,IAAI,CAACF,GAAG,CAAC;MACrC,OAAOC,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ICopyFile, IDeleteFile } from "./types.js";
1
+ import type { ICopyFile, IDeleteFile } from "../../../resolver/recordTypes/fileManager/types.js";
2
2
  export interface ICreateFileManagerPluginsParams {
3
3
  copyFile: ICopyFile;
4
4
  deleteFile: IDeleteFile;
@@ -1,14 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFileManagerPlugins = void 0;
7
- var _fileManagerOnPut = require("./fileManagerOnPut.js");
8
- var _fileManagerOnDelete = require("./fileManagerOnDelete.js");
9
- const createFileManagerPlugins = params => {
10
- return [(0, _fileManagerOnPut.createFileManagerOnPutPlugin)(params), (0, _fileManagerOnDelete.createFileManagerOnDeletePlugin)(params)];
1
+ import { createFileManagerOnPutPlugin } from "./fileManagerOnPut.js";
2
+ import { createFileManagerOnDeletePlugin } from "./fileManagerOnDelete.js";
3
+ export const createFileManagerPlugins = params => {
4
+ return [createFileManagerOnPutPlugin(params), createFileManagerOnDeletePlugin(params)];
11
5
  };
12
- exports.createFileManagerPlugins = createFileManagerPlugins;
13
6
 
14
7
  //# sourceMappingURL=fileManager.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_fileManagerOnPut","require","_fileManagerOnDelete","createFileManagerPlugins","params","createFileManagerOnPutPlugin","createFileManagerOnDeletePlugin","exports"],"sources":["fileManager.ts"],"sourcesContent":["import { createFileManagerOnPutPlugin } from \"./fileManagerOnPut.js\";\nimport { createFileManagerOnDeletePlugin } from \"./fileManagerOnDelete.js\";\nimport type { ICopyFile, IDeleteFile } from \"~/resolver/recordTypes/fileManager/types.js\";\n\nexport interface ICreateFileManagerPluginsParams {\n copyFile: ICopyFile;\n deleteFile: IDeleteFile;\n}\n\nexport const createFileManagerPlugins = (params: ICreateFileManagerPluginsParams) => {\n return [createFileManagerOnPutPlugin(params), createFileManagerOnDeletePlugin(params)];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAQO,MAAME,wBAAwB,GAAIC,MAAuC,IAAK;EACjF,OAAO,CAAC,IAAAC,8CAA4B,EAACD,MAAM,CAAC,EAAE,IAAAE,oDAA+B,EAACF,MAAM,CAAC,CAAC;AAC1F,CAAC;AAACG,OAAA,CAAAJ,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createFileManagerOnPutPlugin","createFileManagerOnDeletePlugin","createFileManagerPlugins","params"],"sources":["fileManager.ts"],"sourcesContent":["import { createFileManagerOnPutPlugin } from \"./fileManagerOnPut.js\";\nimport { createFileManagerOnDeletePlugin } from \"./fileManagerOnDelete.js\";\nimport type { ICopyFile, IDeleteFile } from \"~/resolver/recordTypes/fileManager/types.js\";\n\nexport interface ICreateFileManagerPluginsParams {\n copyFile: ICopyFile;\n deleteFile: IDeleteFile;\n}\n\nexport const createFileManagerPlugins = (params: ICreateFileManagerPluginsParams) => {\n return [createFileManagerOnPutPlugin(params), createFileManagerOnDeletePlugin(params)];\n};\n"],"mappings":"AAAA,SAASA,4BAA4B;AACrC,SAASC,+BAA+B;AAQxC,OAAO,MAAMC,wBAAwB,GAAIC,MAAuC,IAAK;EACjF,OAAO,CAACH,4BAA4B,CAACG,MAAM,CAAC,EAAEF,+BAA+B,CAACE,MAAM,CAAC,CAAC;AAC1F,CAAC","ignoreList":[]}
@@ -2,4 +2,4 @@ import type { IDeleteFile } from "./types.js";
2
2
  export interface ICreateFileManagerOnDeletePluginParams {
3
3
  deleteFile: IDeleteFile;
4
4
  }
5
- export declare const createFileManagerOnDeletePlugin: (params: ICreateFileManagerOnDeletePluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
5
+ export declare const createFileManagerOnDeletePlugin: (params: ICreateFileManagerOnDeletePluginParams) => import("~/resolver/plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -1,17 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFileManagerOnDeletePlugin = void 0;
7
- var _StorerAfterEachPlugin = require("../../plugins/StorerAfterEachPlugin.js");
8
- var _shouldBeHandled = require("./shouldBeHandled.js");
9
- var _utils = require("@webiny/utils");
10
- const createFileManagerOnDeletePlugin = params => {
1
+ import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
2
+ import { shouldBeHandled } from "./shouldBeHandled.js";
3
+ import { convertException } from "@webiny/utils";
4
+ export const createFileManagerOnDeletePlugin = params => {
11
5
  const {
12
6
  deleteFile
13
7
  } = params;
14
- return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("fileManager.onDelete", {
8
+ return createStorerAfterEachPluginWithName("fileManager.onDelete", {
15
9
  canHandle: params => {
16
10
  const {
17
11
  command
@@ -19,7 +13,7 @@ const createFileManagerOnDeletePlugin = params => {
19
13
  if (command !== "delete") {
20
14
  return false;
21
15
  }
22
- return (0, _shouldBeHandled.shouldBeHandled)(params);
16
+ return shouldBeHandled(params);
23
17
  },
24
18
  handle: async params => {
25
19
  const {
@@ -38,11 +32,10 @@ const createFileManagerOnDeletePlugin = params => {
38
32
  });
39
33
  } catch (ex) {
40
34
  console.error("Error while handling file manager onDelete plugin.");
41
- console.log((0, _utils.convertException)(ex));
35
+ console.log(convertException(ex));
42
36
  }
43
37
  }
44
38
  });
45
39
  };
46
- exports.createFileManagerOnDeletePlugin = createFileManagerOnDeletePlugin;
47
40
 
48
41
  //# sourceMappingURL=fileManagerOnDelete.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_StorerAfterEachPlugin","require","_shouldBeHandled","_utils","createFileManagerOnDeletePlugin","params","deleteFile","createStorerAfterEachPluginWithName","canHandle","command","shouldBeHandled","handle","item","key","values","target","source","ex","console","error","log","convertException","exports"],"sources":["fileManagerOnDelete.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IDeleteFile } from \"./types.js\";\n\nexport interface ICreateFileManagerOnDeletePluginParams {\n deleteFile: IDeleteFile;\n}\n\nexport const createFileManagerOnDeletePlugin = (params: ICreateFileManagerOnDeletePluginParams) => {\n const { deleteFile } = params;\n\n return createStorerAfterEachPluginWithName(\"fileManager.onDelete\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"delete\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const key = (item.values[\"text@key\"] || item.values[\"key\"]) as string;\n try {\n await deleteFile.handle({\n target: params.target,\n source: params.source,\n key\n });\n } catch (ex) {\n console.error(\"Error while handling file manager onDelete plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,+BAA+B,GAAIC,MAA8C,IAAK;EAC/F,MAAM;IAAEC;EAAW,CAAC,GAAGD,MAAM;EAE7B,OAAO,IAAAE,0DAAmC,EAAC,sBAAsB,EAAE;IAC/DC,SAAS,EAAEH,MAAM,IAAI;MACjB,MAAM;QAAEI;MAAQ,CAAC,GAAGJ,MAAM;MAC1B,IAAII,OAAO,KAAK,QAAQ,EAAE;QACtB,OAAO,KAAK;MAChB;MACA,OAAO,IAAAC,gCAAe,EAACL,MAAM,CAAC;IAClC,CAAC;IACDM,MAAM,EAAE,MAAMN,MAAM,IAAI;MACpB,MAAM;QAAEO;MAAK,CAAC,GAAGP,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMQ,GAAG,GAAID,IAAI,CAACE,MAAM,CAAC,UAAU,CAAC,IAAIF,IAAI,CAACE,MAAM,CAAC,KAAK,CAAY;MACrE,IAAI;QACA,MAAMR,UAAU,CAACK,MAAM,CAAC;UACpBI,MAAM,EAAEV,MAAM,CAACU,MAAM;UACrBC,MAAM,EAAEX,MAAM,CAACW,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;QACnED,OAAO,CAACE,GAAG,CAAC,IAAAC,uBAAgB,EAACJ,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAlB,+BAAA,GAAAA,+BAAA","ignoreList":[]}
1
+ {"version":3,"names":["createStorerAfterEachPluginWithName","shouldBeHandled","convertException","createFileManagerOnDeletePlugin","params","deleteFile","canHandle","command","handle","item","key","values","target","source","ex","console","error","log"],"sources":["fileManagerOnDelete.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IDeleteFile } from \"./types.js\";\n\nexport interface ICreateFileManagerOnDeletePluginParams {\n deleteFile: IDeleteFile;\n}\n\nexport const createFileManagerOnDeletePlugin = (params: ICreateFileManagerOnDeletePluginParams) => {\n const { deleteFile } = params;\n\n return createStorerAfterEachPluginWithName(\"fileManager.onDelete\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"delete\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const key = (item.values[\"text@key\"] || item.values[\"key\"]) as string;\n try {\n await deleteFile.handle({\n target: params.target,\n source: params.source,\n key\n });\n } catch (ex) {\n console.error(\"Error while handling file manager onDelete plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":"AAAA,SAASA,mCAAmC;AAC5C,SAASC,eAAe;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAOhD,OAAO,MAAMC,+BAA+B,GAAIC,MAA8C,IAAK;EAC/F,MAAM;IAAEC;EAAW,CAAC,GAAGD,MAAM;EAE7B,OAAOJ,mCAAmC,CAAC,sBAAsB,EAAE;IAC/DM,SAAS,EAAEF,MAAM,IAAI;MACjB,MAAM;QAAEG;MAAQ,CAAC,GAAGH,MAAM;MAC1B,IAAIG,OAAO,KAAK,QAAQ,EAAE;QACtB,OAAO,KAAK;MAChB;MACA,OAAON,eAAe,CAACG,MAAM,CAAC;IAClC,CAAC;IACDI,MAAM,EAAE,MAAMJ,MAAM,IAAI;MACpB,MAAM;QAAEK;MAAK,CAAC,GAAGL,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMM,GAAG,GAAID,IAAI,CAACE,MAAM,CAAC,UAAU,CAAC,IAAIF,IAAI,CAACE,MAAM,CAAC,KAAK,CAAY;MACrE,IAAI;QACA,MAAMN,UAAU,CAACG,MAAM,CAAC;UACpBI,MAAM,EAAER,MAAM,CAACQ,MAAM;UACrBC,MAAM,EAAET,MAAM,CAACS,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;QACnED,OAAO,CAACE,GAAG,CAACf,gBAAgB,CAACY,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -2,4 +2,4 @@ import type { ICopyFile } from "./types.js";
2
2
  export interface ICreateFileManagerOnPutPluginParams {
3
3
  copyFile: ICopyFile;
4
4
  }
5
- export declare const createFileManagerOnPutPlugin: (params: ICreateFileManagerOnPutPluginParams) => import("../../plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
5
+ export declare const createFileManagerOnPutPlugin: (params: ICreateFileManagerOnPutPluginParams) => import("~/resolver/plugins/StorerAfterEachPlugin.js").StorerAfterEachPlugin;
@@ -1,17 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFileManagerOnPutPlugin = void 0;
7
- var _StorerAfterEachPlugin = require("../../plugins/StorerAfterEachPlugin.js");
8
- var _shouldBeHandled = require("./shouldBeHandled.js");
9
- var _utils = require("@webiny/utils");
10
- const createFileManagerOnPutPlugin = params => {
1
+ import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
2
+ import { shouldBeHandled } from "./shouldBeHandled.js";
3
+ import { convertException } from "@webiny/utils";
4
+ export const createFileManagerOnPutPlugin = params => {
11
5
  const {
12
6
  copyFile
13
7
  } = params;
14
- return (0, _StorerAfterEachPlugin.createStorerAfterEachPluginWithName)("fileManager.onPut", {
8
+ return createStorerAfterEachPluginWithName("fileManager.onPut", {
15
9
  canHandle: params => {
16
10
  const {
17
11
  command
@@ -19,7 +13,7 @@ const createFileManagerOnPutPlugin = params => {
19
13
  if (command !== "put") {
20
14
  return false;
21
15
  }
22
- return (0, _shouldBeHandled.shouldBeHandled)(params);
16
+ return shouldBeHandled(params);
23
17
  },
24
18
  handle: async params => {
25
19
  const {
@@ -38,11 +32,10 @@ const createFileManagerOnPutPlugin = params => {
38
32
  });
39
33
  } catch (ex) {
40
34
  console.error("Error while handling file manager onPut plugin.");
41
- console.log((0, _utils.convertException)(ex));
35
+ console.log(convertException(ex));
42
36
  }
43
37
  }
44
38
  });
45
39
  };
46
- exports.createFileManagerOnPutPlugin = createFileManagerOnPutPlugin;
47
40
 
48
41
  //# sourceMappingURL=fileManagerOnPut.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_StorerAfterEachPlugin","require","_shouldBeHandled","_utils","createFileManagerOnPutPlugin","params","copyFile","createStorerAfterEachPluginWithName","canHandle","command","shouldBeHandled","handle","item","key","values","target","source","ex","console","error","log","convertException","exports"],"sources":["fileManagerOnPut.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { ICopyFile } from \"./types.js\";\n\nexport interface ICreateFileManagerOnPutPluginParams {\n copyFile: ICopyFile;\n}\n\nexport const createFileManagerOnPutPlugin = (params: ICreateFileManagerOnPutPluginParams) => {\n const { copyFile } = params;\n\n return createStorerAfterEachPluginWithName(\"fileManager.onPut\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"put\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const key = (item.values[\"text@key\"] || item.values[\"key\"]) as string;\n try {\n await copyFile.handle({\n target: params.target,\n source: params.source,\n key\n });\n } catch (ex) {\n console.error(\"Error while handling file manager onPut plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAOO,MAAMG,4BAA4B,GAAIC,MAA2C,IAAK;EACzF,MAAM;IAAEC;EAAS,CAAC,GAAGD,MAAM;EAE3B,OAAO,IAAAE,0DAAmC,EAAC,mBAAmB,EAAE;IAC5DC,SAAS,EAAEH,MAAM,IAAI;MACjB,MAAM;QAAEI;MAAQ,CAAC,GAAGJ,MAAM;MAC1B,IAAII,OAAO,KAAK,KAAK,EAAE;QACnB,OAAO,KAAK;MAChB;MACA,OAAO,IAAAC,gCAAe,EAACL,MAAM,CAAC;IAClC,CAAC;IACDM,MAAM,EAAE,MAAMN,MAAM,IAAI;MACpB,MAAM;QAAEO;MAAK,CAAC,GAAGP,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMQ,GAAG,GAAID,IAAI,CAACE,MAAM,CAAC,UAAU,CAAC,IAAIF,IAAI,CAACE,MAAM,CAAC,KAAK,CAAY;MACrE,IAAI;QACA,MAAMR,QAAQ,CAACK,MAAM,CAAC;UAClBI,MAAM,EAAEV,MAAM,CAACU,MAAM;UACrBC,MAAM,EAAEX,MAAM,CAACW,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,iDAAiD,CAAC;QAChED,OAAO,CAACE,GAAG,CAAC,IAAAC,uBAAgB,EAACJ,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACK,OAAA,CAAAlB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["createStorerAfterEachPluginWithName","shouldBeHandled","convertException","createFileManagerOnPutPlugin","params","copyFile","canHandle","command","handle","item","key","values","target","source","ex","console","error","log"],"sources":["fileManagerOnPut.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { ICopyFile } from \"./types.js\";\n\nexport interface ICreateFileManagerOnPutPluginParams {\n copyFile: ICopyFile;\n}\n\nexport const createFileManagerOnPutPlugin = (params: ICreateFileManagerOnPutPluginParams) => {\n const { copyFile } = params;\n\n return createStorerAfterEachPluginWithName(\"fileManager.onPut\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"put\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const key = (item.values[\"text@key\"] || item.values[\"key\"]) as string;\n try {\n await copyFile.handle({\n target: params.target,\n source: params.source,\n key\n });\n } catch (ex) {\n console.error(\"Error while handling file manager onPut plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"mappings":"AAAA,SAASA,mCAAmC;AAC5C,SAASC,eAAe;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAOhD,OAAO,MAAMC,4BAA4B,GAAIC,MAA2C,IAAK;EACzF,MAAM;IAAEC;EAAS,CAAC,GAAGD,MAAM;EAE3B,OAAOJ,mCAAmC,CAAC,mBAAmB,EAAE;IAC5DM,SAAS,EAAEF,MAAM,IAAI;MACjB,MAAM;QAAEG;MAAQ,CAAC,GAAGH,MAAM;MAC1B,IAAIG,OAAO,KAAK,KAAK,EAAE;QACnB,OAAO,KAAK;MAChB;MACA,OAAON,eAAe,CAACG,MAAM,CAAC;IAClC,CAAC;IACDI,MAAM,EAAE,MAAMJ,MAAM,IAAI;MACpB,MAAM;QAAEK;MAAK,CAAC,GAAGL,MAAM;MACvB;AACZ;AACA;MACY;MACA,MAAMM,GAAG,GAAID,IAAI,CAACE,MAAM,CAAC,UAAU,CAAC,IAAIF,IAAI,CAACE,MAAM,CAAC,KAAK,CAAY;MACrE,IAAI;QACA,MAAMN,QAAQ,CAACG,MAAM,CAAC;UAClBI,MAAM,EAAER,MAAM,CAACQ,MAAM;UACrBC,MAAM,EAAET,MAAM,CAACS,MAAM;UACrBH;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOI,EAAE,EAAE;QACTC,OAAO,CAACC,KAAK,CAAC,iDAAiD,CAAC;QAChED,OAAO,CAACE,GAAG,CAACf,gBAAgB,CAACY,EAAE,CAAC,CAAC;MACrC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import type { IStorerAfterEachPluginCanHandleParams } from "../../plugins/StorerAfterEachPlugin.js";
1
+ import type { IStorerAfterEachPluginCanHandleParams } from "../../../resolver/plugins/StorerAfterEachPlugin.js";
2
2
  export declare const shouldBeHandled: (params: IStorerAfterEachPluginCanHandleParams) => boolean;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldBeHandled = void 0;
7
- const shouldBeHandled = params => {
1
+ export const shouldBeHandled = params => {
8
2
  const {
9
3
  item,
10
4
  table
@@ -32,6 +26,5 @@ const shouldBeHandled = params => {
32
26
  */
33
27
  return typeof key === "string" && key.length > 2;
34
28
  };
35
- exports.shouldBeHandled = shouldBeHandled;
36
29
 
37
30
  //# sourceMappingURL=shouldBeHandled.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["shouldBeHandled","params","item","table","type","SK","modelId","values","key","length","exports"],"sources":["shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.SK !== \"L\") {\n return false;\n }\n // TODO use constant from fileManager\n else if (item.modelId !== \"fmFile\") {\n return false;\n } else if (!item.values) {\n return false;\n }\n\n // @ts-expect-error\n const key = item.values[\"text@key\"] || item.values[\"key\"];\n if (!key) {\n return false;\n }\n /**\n * We can check length for being more than 2 characters,\n * because we know that the key is a string.\n */\n return typeof key === \"string\" && key.length > 2;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,eAAe,GAAIC,MAA6C,IAAc;EACvF,MAAM;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAC9B,IAAIE,KAAK,CAACC,IAAI,KAAK,SAAS,EAAE;IAC1B,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIF,IAAI,CAACG,EAAE,KAAK,GAAG,EAAE;IACxB,OAAO,KAAK;EAChB;EACA;EAAA,KACK,IAAIH,IAAI,CAACI,OAAO,KAAK,QAAQ,EAAE;IAChC,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACJ,IAAI,CAACK,MAAM,EAAE;IACrB,OAAO,KAAK;EAChB;;EAEA;EACA,MAAMC,GAAG,GAAGN,IAAI,CAACK,MAAM,CAAC,UAAU,CAAC,IAAIL,IAAI,CAACK,MAAM,CAAC,KAAK,CAAC;EACzD,IAAI,CAACC,GAAG,EAAE;IACN,OAAO,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACC,MAAM,GAAG,CAAC;AACpD,CAAC;AAACC,OAAA,CAAAV,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["shouldBeHandled","params","item","table","type","SK","modelId","values","key","length"],"sources":["shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.SK !== \"L\") {\n return false;\n }\n // TODO use constant from fileManager\n else if (item.modelId !== \"fmFile\") {\n return false;\n } else if (!item.values) {\n return false;\n }\n\n // @ts-expect-error\n const key = item.values[\"text@key\"] || item.values[\"key\"];\n if (!key) {\n return false;\n }\n /**\n * We can check length for being more than 2 characters,\n * because we know that the key is a string.\n */\n return typeof key === \"string\" && key.length > 2;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAe,GAAIC,MAA6C,IAAc;EACvF,MAAM;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAC9B,IAAIE,KAAK,CAACC,IAAI,KAAK,SAAS,EAAE;IAC1B,OAAO,KAAK;EAChB,CAAC,MAAM,IAAIF,IAAI,CAACG,EAAE,KAAK,GAAG,EAAE;IACxB,OAAO,KAAK;EAChB;EACA;EAAA,KACK,IAAIH,IAAI,CAACI,OAAO,KAAK,QAAQ,EAAE;IAChC,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACJ,IAAI,CAACK,MAAM,EAAE;IACrB,OAAO,KAAK;EAChB;;EAEA;EACA,MAAMC,GAAG,GAAGN,IAAI,CAACK,MAAM,CAAC,UAAU,CAAC,IAAIL,IAAI,CAACK,MAAM,CAAC,KAAK,CAAC;EACzD,IAAI,CAACC,GAAG,EAAE;IACN,OAAO,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAO,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACC,MAAM,GAAG,CAAC;AACpD,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import type { LambdaTrigger } from "../../lambda/LambdaTrigger.js";
1
+ import type { LambdaTrigger } from "../../../resolver/lambda/LambdaTrigger.js";
2
2
  import type { S3Client, S3ClientConfig } from "@webiny/aws-sdk/client-s3/index.js";
3
- import type { IDeployment } from "../../deployment/types.js";
3
+ import type { IDeployment } from "../../../resolver/deployment/types.js";
4
4
  import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
5
5
  export interface IGetLambdaTriggerCb<T> {
6
6
  (): LambdaTrigger<T>;
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
@@ -1,5 +1,5 @@
1
- import type { ICopyUser, ICopyUserHandleParams, ICreateCognitoIdentityProviderClientCb } from "./types";
2
- import type { LambdaTrigger } from "../../lambda/LambdaTrigger.js";
1
+ import type { ICopyUser, ICopyUserHandleParams, ICreateCognitoIdentityProviderClientCb } from "./types.js";
2
+ import type { LambdaTrigger } from "../../../resolver/lambda/LambdaTrigger.js";
3
3
  import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
4
4
  import type { ICopyUserLambdaPayload } from "../../../types.js";
5
5
  export interface IGetLambdaTriggerCb {
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CopyUser = void 0;
7
- var _clientCognitoIdentityProvider = require("@webiny/aws-sdk/client-cognito-identity-provider");
8
- class CopyUser {
1
+ import { AdminGetUserCommand } from "@webiny/aws-sdk/client-cognito-identity-provider/index.js";
2
+ export class CopyUser {
9
3
  constructor(params) {
10
4
  this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;
11
5
  this.getLambdaTrigger = params.getLambdaTrigger;
@@ -53,7 +47,7 @@ class CopyUser {
53
47
  UserPoolId: userPoolId,
54
48
  Username: username
55
49
  };
56
- const cmd = new _clientCognitoIdentityProvider.AdminGetUserCommand(input);
50
+ const cmd = new AdminGetUserCommand(input);
57
51
  try {
58
52
  const result = await provider.send(cmd);
59
53
  return result.$metadata?.httpStatusCode === 200;
@@ -62,6 +56,5 @@ class CopyUser {
62
56
  }
63
57
  }
64
58
  }
65
- exports.CopyUser = CopyUser;
66
59
 
67
60
  //# sourceMappingURL=CopyUser.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_clientCognitoIdentityProvider","require","CopyUser","constructor","params","createCognitoIdentityProviderClient","getLambdaTrigger","handle","username","target","source","exists","userExists","userPoolId","services","cognitoUserPoolId","region","invocationType","payload","action","provider","input","UserPoolId","Username","cmd","AdminGetUserCommand","result","send","$metadata","httpStatusCode","exports"],"sources":["CopyUser.ts"],"sourcesContent":["import type {\n ICopyUser,\n ICopyUserHandleParams,\n ICreateCognitoIdentityProviderClientCb\n} from \"./types\";\nimport type { LambdaTrigger } from \"~/resolver/lambda/LambdaTrigger.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { AdminGetUserCommandInput } from \"@webiny/aws-sdk/client-cognito-identity-provider\";\nimport { AdminGetUserCommand } from \"@webiny/aws-sdk/client-cognito-identity-provider\";\nimport type { ICopyUserLambdaPayload } from \"~/types.js\";\n\ninterface IGetUserParams {\n username: string;\n userPoolId: string;\n region: string;\n}\n\nexport interface IGetLambdaTriggerCb {\n (): LambdaTrigger<ICopyUserLambdaPayload>;\n}\n\nexport interface ICopyUserParams {\n createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb;\n}\n\nexport class CopyUser implements ICopyUser {\n private readonly createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb;\n\n public constructor(params: ICopyUserParams) {\n this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: ICopyUserHandleParams): Promise<InvokeCommandOutput | null> {\n const { username, target, source } = params;\n\n const exists = await this.userExists({\n username,\n userPoolId: target.services.cognitoUserPoolId,\n region: target.region\n });\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n /**\n * We need to be able to create or update a user, depending on whether it already exists in the target user pool.\n */\n action: exists ? \"updateUser\" : \"createUser\",\n username,\n source: {\n region: source.region,\n userPoolId: source.services.cognitoUserPoolId\n },\n target: {\n region: target.region,\n userPoolId: target.services.cognitoUserPoolId\n }\n }\n });\n }\n\n private async userExists(params: IGetUserParams): Promise<boolean> {\n const { userPoolId, username, region } = params;\n\n const provider = this.createCognitoIdentityProviderClient({\n region\n });\n\n const input: AdminGetUserCommandInput = {\n UserPoolId: userPoolId,\n Username: username\n };\n const cmd = new AdminGetUserCommand(input);\n try {\n const result = await provider.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,8BAAA,GAAAC,OAAA;AAkBO,MAAMC,QAAQ,CAAsB;EAIhCC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,mCAAmC,GAAGD,MAAM,CAACC,mCAAmC;IACrF,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA6B,EAAuC;IACpF,MAAM;MAAEI,QAAQ;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IAE3C,MAAMO,MAAM,GAAG,MAAM,IAAI,CAACC,UAAU,CAAC;MACjCJ,QAAQ;MACRK,UAAU,EAAEJ,MAAM,CAACK,QAAQ,CAACC,iBAAiB;MAC7CC,MAAM,EAAEP,MAAM,CAACO;IACnB,CAAC,CAAC;IAEF,OAAO,MAAM,IAAI,CAACV,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCU,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACL;AAChB;AACA;QACgBC,MAAM,EAAER,MAAM,GAAG,YAAY,GAAG,YAAY;QAC5CH,QAAQ;QACRE,MAAM,EAAE;UACJM,MAAM,EAAEN,MAAM,CAACM,MAAM;UACrBH,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC;QAChC,CAAC;QACDN,MAAM,EAAE;UACJO,MAAM,EAAEP,MAAM,CAACO,MAAM;UACrBH,UAAU,EAAEJ,MAAM,CAACK,QAAQ,CAACC;QAChC;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcH,UAAUA,CAACR,MAAsB,EAAoB;IAC/D,MAAM;MAAES,UAAU;MAAEL,QAAQ;MAAEQ;IAAO,CAAC,GAAGZ,MAAM;IAE/C,MAAMgB,QAAQ,GAAG,IAAI,CAACf,mCAAmC,CAAC;MACtDW;IACJ,CAAC,CAAC;IAEF,MAAMK,KAA+B,GAAG;MACpCC,UAAU,EAAET,UAAU;MACtBU,QAAQ,EAAEf;IACd,CAAC;IACD,MAAMgB,GAAG,GAAG,IAAIC,kDAAmB,CAACJ,KAAK,CAAC;IAC1C,IAAI;MACA,MAAMK,MAAM,GAAG,MAAMN,QAAQ,CAACO,IAAI,CAACH,GAAG,CAAC;MACvC,OAAOE,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ;AAACC,OAAA,CAAA5B,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["AdminGetUserCommand","CopyUser","constructor","params","createCognitoIdentityProviderClient","getLambdaTrigger","handle","username","target","source","exists","userExists","userPoolId","services","cognitoUserPoolId","region","invocationType","payload","action","provider","input","UserPoolId","Username","cmd","result","send","$metadata","httpStatusCode"],"sources":["CopyUser.ts"],"sourcesContent":["import type {\n ICopyUser,\n ICopyUserHandleParams,\n ICreateCognitoIdentityProviderClientCb\n} from \"./types.js\";\nimport type { LambdaTrigger } from \"~/resolver/lambda/LambdaTrigger.js\";\nimport type { InvokeCommandOutput } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport type { AdminGetUserCommandInput } from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport { AdminGetUserCommand } from \"@webiny/aws-sdk/client-cognito-identity-provider/index.js\";\nimport type { ICopyUserLambdaPayload } from \"~/types.js\";\n\ninterface IGetUserParams {\n username: string;\n userPoolId: string;\n region: string;\n}\n\nexport interface IGetLambdaTriggerCb {\n (): LambdaTrigger<ICopyUserLambdaPayload>;\n}\n\nexport interface ICopyUserParams {\n createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n getLambdaTrigger: IGetLambdaTriggerCb;\n}\n\nexport class CopyUser implements ICopyUser {\n private readonly createCognitoIdentityProviderClient: ICreateCognitoIdentityProviderClientCb;\n private readonly getLambdaTrigger: IGetLambdaTriggerCb;\n\n public constructor(params: ICopyUserParams) {\n this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;\n this.getLambdaTrigger = params.getLambdaTrigger;\n }\n\n public async handle(params: ICopyUserHandleParams): Promise<InvokeCommandOutput | null> {\n const { username, target, source } = params;\n\n const exists = await this.userExists({\n username,\n userPoolId: target.services.cognitoUserPoolId,\n region: target.region\n });\n\n return await this.getLambdaTrigger().handle({\n invocationType: \"Event\",\n payload: {\n /**\n * We need to be able to create or update a user, depending on whether it already exists in the target user pool.\n */\n action: exists ? \"updateUser\" : \"createUser\",\n username,\n source: {\n region: source.region,\n userPoolId: source.services.cognitoUserPoolId\n },\n target: {\n region: target.region,\n userPoolId: target.services.cognitoUserPoolId\n }\n }\n });\n }\n\n private async userExists(params: IGetUserParams): Promise<boolean> {\n const { userPoolId, username, region } = params;\n\n const provider = this.createCognitoIdentityProviderClient({\n region\n });\n\n const input: AdminGetUserCommandInput = {\n UserPoolId: userPoolId,\n Username: username\n };\n const cmd = new AdminGetUserCommand(input);\n try {\n const result = await provider.send(cmd);\n return result.$metadata?.httpStatusCode === 200;\n } catch {\n return false;\n }\n }\n}\n"],"mappings":"AAQA,SAASA,mBAAmB,QAAQ,2DAA2D;AAkB/F,OAAO,MAAMC,QAAQ,CAAsB;EAIhCC,WAAWA,CAACC,MAAuB,EAAE;IACxC,IAAI,CAACC,mCAAmC,GAAGD,MAAM,CAACC,mCAAmC;IACrF,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;EACnD;EAEA,MAAaC,MAAMA,CAACH,MAA6B,EAAuC;IACpF,MAAM;MAAEI,QAAQ;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGN,MAAM;IAE3C,MAAMO,MAAM,GAAG,MAAM,IAAI,CAACC,UAAU,CAAC;MACjCJ,QAAQ;MACRK,UAAU,EAAEJ,MAAM,CAACK,QAAQ,CAACC,iBAAiB;MAC7CC,MAAM,EAAEP,MAAM,CAACO;IACnB,CAAC,CAAC;IAEF,OAAO,MAAM,IAAI,CAACV,gBAAgB,CAAC,CAAC,CAACC,MAAM,CAAC;MACxCU,cAAc,EAAE,OAAO;MACvBC,OAAO,EAAE;QACL;AAChB;AACA;QACgBC,MAAM,EAAER,MAAM,GAAG,YAAY,GAAG,YAAY;QAC5CH,QAAQ;QACRE,MAAM,EAAE;UACJM,MAAM,EAAEN,MAAM,CAACM,MAAM;UACrBH,UAAU,EAAEH,MAAM,CAACI,QAAQ,CAACC;QAChC,CAAC;QACDN,MAAM,EAAE;UACJO,MAAM,EAAEP,MAAM,CAACO,MAAM;UACrBH,UAAU,EAAEJ,MAAM,CAACK,QAAQ,CAACC;QAChC;MACJ;IACJ,CAAC,CAAC;EACN;EAEA,MAAcH,UAAUA,CAACR,MAAsB,EAAoB;IAC/D,MAAM;MAAES,UAAU;MAAEL,QAAQ;MAAEQ;IAAO,CAAC,GAAGZ,MAAM;IAE/C,MAAMgB,QAAQ,GAAG,IAAI,CAACf,mCAAmC,CAAC;MACtDW;IACJ,CAAC,CAAC;IAEF,MAAMK,KAA+B,GAAG;MACpCC,UAAU,EAAET,UAAU;MACtBU,QAAQ,EAAEf;IACd,CAAC;IACD,MAAMgB,GAAG,GAAG,IAAIvB,mBAAmB,CAACoB,KAAK,CAAC;IAC1C,IAAI;MACA,MAAMI,MAAM,GAAG,MAAML,QAAQ,CAACM,IAAI,CAACF,GAAG,CAAC;MACvC,OAAOC,MAAM,CAACE,SAAS,EAAEC,cAAc,KAAK,GAAG;IACnD,CAAC,CAAC,MAAM;MACJ,OAAO,KAAK;IAChB;EACJ;AACJ","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { ICreateCognitoIdentityProviderClientCb, IDeleteUser, IDeleteUserHandleParams } from "./types";
2
- import type { LambdaTrigger } from "../../lambda/LambdaTrigger.js";
1
+ import type { ICreateCognitoIdentityProviderClientCb, IDeleteUser, IDeleteUserHandleParams } from "./types.js";
2
+ import type { LambdaTrigger } from "../../../resolver/lambda/LambdaTrigger.js";
3
3
  import type { InvokeCommandOutput } from "@webiny/aws-sdk/client-lambda/index.js";
4
4
  import type { IDeleteUserLambdaPayload } from "../../../types.js";
5
5
  export interface IGetLambdaTriggerCb {
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DeleteUser = void 0;
7
- var _clientCognitoIdentityProvider = require("@webiny/aws-sdk/client-cognito-identity-provider");
8
- class DeleteUser {
1
+ import { AdminGetUserCommand } from "@webiny/aws-sdk/client-cognito-identity-provider/index.js";
2
+ export class DeleteUser {
9
3
  constructor(params) {
10
4
  this.createCognitoIdentityProviderClient = params.createCognitoIdentityProviderClient;
11
5
  this.getLambdaTrigger = params.getLambdaTrigger;
@@ -51,7 +45,7 @@ class DeleteUser {
51
45
  UserPoolId: userPoolId,
52
46
  Username: username
53
47
  };
54
- const cmd = new _clientCognitoIdentityProvider.AdminGetUserCommand(input);
48
+ const cmd = new AdminGetUserCommand(input);
55
49
  try {
56
50
  const result = await provider.send(cmd);
57
51
  return result.$metadata?.httpStatusCode === 200;
@@ -60,6 +54,5 @@ class DeleteUser {
60
54
  }
61
55
  }
62
56
  }
63
- exports.DeleteUser = DeleteUser;
64
57
 
65
58
  //# sourceMappingURL=DeleteUser.js.map