@webiny/api-sync-system 0.0.0-unstable.06b2ede40f → 0.0.0-unstable.0d717d18dd
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.
- package/README.md +6 -108
- package/constants.js +2 -7
- package/constants.js.map +1 -1
- package/index.d.ts +11 -3
- package/index.js +8 -40
- package/package.json +31 -26
- package/resolver/SyncResolverConfig.d.ts +17 -0
- package/resolver/SyncResolverConfig.js +5 -0
- package/resolver/SyncResolverConfig.js.map +1 -0
- package/resolver/SyncResolverLambdaHandler.d.ts +14 -0
- package/resolver/SyncResolverLambdaHandler.js +159 -0
- package/resolver/SyncResolverLambdaHandler.js.map +1 -0
- package/resolver/app/RecordHandler.d.ts +6 -6
- package/resolver/app/RecordHandler.js +84 -114
- package/resolver/app/RecordHandler.js.map +1 -1
- package/resolver/app/RecordsValidation.js +13 -24
- package/resolver/app/RecordsValidation.js.map +1 -1
- package/resolver/app/ResolverApplication.d.ts +1 -1
- package/resolver/app/ResolverApplication.js +27 -42
- package/resolver/app/ResolverApplication.js.map +1 -1
- package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
- package/resolver/app/abstractions/RecordHandler.js +0 -7
- package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
- package/resolver/app/abstractions/RecordsValidation.js +0 -7
- package/resolver/app/abstractions/ResolverApplication.js +0 -7
- package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
- package/resolver/app/abstractions/ResolverRecord.js +0 -7
- package/resolver/app/bundler/BaseBundle.d.ts +6 -6
- package/resolver/app/bundler/BaseBundle.js +16 -22
- package/resolver/app/bundler/BaseBundle.js.map +1 -1
- package/resolver/app/bundler/Bundler.d.ts +1 -1
- package/resolver/app/bundler/Bundler.js +12 -25
- package/resolver/app/bundler/Bundler.js.map +1 -1
- package/resolver/app/bundler/Bundles.d.ts +2 -2
- package/resolver/app/bundler/Bundles.js +20 -33
- package/resolver/app/bundler/Bundles.js.map +1 -1
- package/resolver/app/bundler/CommandBundle.d.ts +1 -1
- package/resolver/app/bundler/CommandBundle.js +8 -25
- package/resolver/app/bundler/CommandBundle.js.map +1 -1
- package/resolver/app/bundler/TableBundle.d.ts +1 -1
- package/resolver/app/bundler/TableBundle.js +7 -22
- package/resolver/app/bundler/TableBundle.js.map +1 -1
- package/resolver/app/bundler/types.d.ts +2 -2
- package/resolver/app/bundler/types.js +0 -7
- package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
- package/resolver/app/commandHandler/DeleteCommandHandler.js +21 -35
- package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
- package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
- package/resolver/app/commandHandler/PutCommandHandler.js +15 -28
- package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
- package/resolver/app/commandHandler/delete.d.ts +1 -1
- package/resolver/app/commandHandler/delete.js +13 -21
- package/resolver/app/commandHandler/delete.js.map +1 -1
- package/resolver/app/commandHandler/put.d.ts +1 -1
- package/resolver/app/commandHandler/put.js +13 -21
- package/resolver/app/commandHandler/put.js.map +1 -1
- package/resolver/app/data/SourceDataContainer.d.ts +3 -3
- package/resolver/app/data/SourceDataContainer.js +27 -36
- package/resolver/app/data/SourceDataContainer.js.map +1 -1
- package/resolver/app/data/types.d.ts +2 -2
- package/resolver/app/data/types.js +0 -7
- package/resolver/app/fetcher/Fetcher.d.ts +3 -3
- package/resolver/app/fetcher/Fetcher.js +87 -121
- package/resolver/app/fetcher/Fetcher.js.map +1 -1
- package/resolver/app/fetcher/types.d.ts +2 -2
- package/resolver/app/fetcher/types.js +0 -7
- package/resolver/app/ingestor/Ingestor.d.ts +1 -1
- package/resolver/app/ingestor/Ingestor.js +26 -39
- package/resolver/app/ingestor/Ingestor.js.map +1 -1
- package/resolver/app/ingestor/IngestorResult.js +27 -39
- package/resolver/app/ingestor/IngestorResult.js.map +1 -1
- package/resolver/app/ingestor/types.d.ts +2 -2
- package/resolver/app/ingestor/types.js +0 -7
- package/resolver/app/storer/Storer.d.ts +3 -3
- package/resolver/app/storer/Storer.js +73 -95
- package/resolver/app/storer/Storer.js.map +1 -1
- package/resolver/app/storer/types.d.ts +2 -2
- package/resolver/app/storer/types.js +0 -7
- package/resolver/app/transform/TransformHandler.d.ts +4 -4
- package/resolver/app/transform/TransformHandler.js +46 -64
- package/resolver/app/transform/TransformHandler.js.map +1 -1
- package/resolver/app/transform/middleware.d.ts +1 -1
- package/resolver/app/transform/middleware.js +12 -25
- package/resolver/app/transform/middleware.js.map +1 -1
- package/resolver/app/utils/Retry.js +21 -32
- package/resolver/app/utils/Retry.js.map +1 -1
- package/resolver/app/utils/sleep.js +4 -12
- package/resolver/app/utils/sleep.js.map +1 -1
- package/resolver/app/validation/body.d.ts +25 -124
- package/resolver/app/validation/body.js +31 -44
- package/resolver/app/validation/body.js.map +1 -1
- package/resolver/app/validation/createJsonTransform.d.ts +1 -1
- package/resolver/app/validation/createJsonTransform.js +13 -22
- package/resolver/app/validation/createJsonTransform.js.map +1 -1
- package/resolver/app/validation/detail.d.ts +19 -72
- package/resolver/app/validation/detail.js +33 -46
- package/resolver/app/validation/detail.js.map +1 -1
- package/resolver/app/validation/event.d.ts +29 -188
- package/resolver/app/validation/event.js +21 -30
- package/resolver/app/validation/event.js.map +1 -1
- package/resolver/app/validation/numericString.d.ts +1 -1
- package/resolver/app/validation/numericString.js +9 -20
- package/resolver/app/validation/numericString.js.map +1 -1
- package/resolver/app/validation/system.d.ts +2 -14
- package/resolver/app/validation/system.js +9 -18
- package/resolver/app/validation/system.js.map +1 -1
- package/resolver/deployment/Deployment.d.ts +2 -3
- package/resolver/deployment/Deployment.js +27 -44
- package/resolver/deployment/Deployment.js.map +1 -1
- package/resolver/deployment/Deployments.js +19 -30
- package/resolver/deployment/Deployments.js.map +1 -1
- package/resolver/deployment/DeploymentsFetcher.js +82 -102
- package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
- package/resolver/deployment/types.d.ts +4 -6
- package/resolver/deployment/types.js +0 -7
- package/resolver/lambda/LambdaTrigger.js +25 -34
- package/resolver/lambda/LambdaTrigger.js.map +1 -1
- package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
- package/resolver/plugins/CommandHandlerPlugin.js +17 -24
- package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
- package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
- package/resolver/plugins/StorerAfterEachPlugin.js +21 -29
- package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
- package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
- package/resolver/plugins/TransformRecordPlugin.js +20 -27
- package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
- package/resolver/recordTypes/fileManager/CopyFile.js +44 -74
- package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
- package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
- package/resolver/recordTypes/fileManager/DeleteFile.js +40 -65
- package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManager.js +7 -12
- package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +27 -45
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnPut.js +27 -45
- package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
- package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
- package/resolver/recordTypes/fileManager/shouldBeHandled.js +10 -34
- package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
- package/resolver/recordTypes/fileManager/types.d.ts +2 -2
- package/resolver/recordTypes/fileManager/types.js +0 -7
- package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
- package/resolver/recordTypes/users/CopyUser.js +44 -61
- package/resolver/recordTypes/users/CopyUser.js.map +1 -1
- package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
- package/resolver/recordTypes/users/DeleteUser.js +40 -58
- package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
- package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
- package/resolver/recordTypes/users/shouldBeHandled.js +10 -33
- package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
- package/resolver/recordTypes/users/types.d.ts +1 -1
- package/resolver/recordTypes/users/types.js +0 -7
- package/resolver/recordTypes/users/users.js +7 -12
- package/resolver/recordTypes/users/users.js.map +1 -1
- package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
- package/resolver/recordTypes/users/usersOnDelete.js +26 -44
- package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
- package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
- package/resolver/recordTypes/users/usersOnPut.js +27 -45
- package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
- package/sync/ApiGatewaySyncDecorator.d.ts +14 -0
- package/sync/ApiGatewaySyncDecorator.js +49 -0
- package/sync/ApiGatewaySyncDecorator.js.map +1 -0
- package/sync/FilterOutRecord.d.ts +2 -2
- package/sync/FilterOutRecord.js +8 -24
- package/sync/FilterOutRecord.js.map +1 -1
- package/sync/SyncSystemConfig.d.ts +11 -0
- package/sync/SyncSystemConfig.js +5 -0
- package/sync/SyncSystemConfig.js.map +1 -0
- package/sync/attachToDynamoDbDocument.d.ts +1 -1
- package/sync/attachToDynamoDbDocument.js +48 -75
- package/sync/attachToDynamoDbDocument.js.map +1 -1
- package/sync/createHandler.js +44 -60
- package/sync/createHandler.js.map +1 -1
- package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
- package/sync/filter/createDefaultFilterOutRecordPlugins.js +37 -86
- package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
- package/sync/handler/Handler.d.ts +2 -2
- package/sync/handler/Handler.js +66 -86
- package/sync/handler/Handler.js.map +1 -1
- package/sync/handler/HandlerConverter.js +20 -36
- package/sync/handler/HandlerConverter.js.map +1 -1
- package/sync/handler/converter/BatchGetCommandConverter.js +13 -20
- package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
- package/sync/handler/converter/BatchWriteCommandConverter.js +13 -20
- package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
- package/sync/handler/converter/DeleteCommandConverter.js +13 -20
- package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
- package/sync/handler/converter/GetCommandConverter.js +13 -20
- package/sync/handler/converter/GetCommandConverter.js.map +1 -1
- package/sync/handler/converter/PutCommandConverter.js +13 -20
- package/sync/handler/converter/PutCommandConverter.js.map +1 -1
- package/sync/handler/converter/QueryCommandConverter.js +13 -20
- package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
- package/sync/handler/converter/ScanCommandConverter.js +13 -20
- package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
- package/sync/handler/converter/UpdateCommandConverter.js +13 -20
- package/sync/handler/converter/UpdateCommandConverter.js.map +1 -1
- package/sync/handler/converter/commands/BatchWriteCommandValue.d.ts +2 -2
- package/sync/handler/converter/commands/BatchWriteCommandValue.js +34 -44
- package/sync/handler/converter/commands/BatchWriteCommandValue.js.map +1 -1
- package/sync/handler/converter/commands/DeleteCommandValue.d.ts +2 -2
- package/sync/handler/converter/commands/DeleteCommandValue.js +19 -23
- package/sync/handler/converter/commands/DeleteCommandValue.js.map +1 -1
- package/sync/handler/converter/commands/NullCommandValue.d.ts +1 -1
- package/sync/handler/converter/commands/NullCommandValue.js +7 -14
- package/sync/handler/converter/commands/NullCommandValue.js.map +1 -1
- package/sync/handler/converter/commands/PutCommandValue.d.ts +2 -2
- package/sync/handler/converter/commands/PutCommandValue.js +19 -23
- package/sync/handler/converter/commands/PutCommandValue.js.map +1 -1
- package/sync/handler/converter/commands/UpdateCommandValue.d.ts +2 -2
- package/sync/handler/converter/commands/UpdateCommandValue.js +19 -23
- package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
- package/sync/handler/types.d.ts +3 -3
- package/sync/handler/types.js +0 -7
- package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
- package/sync/plugins/FilterOutRecordPlugin.js +18 -28
- package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
- package/sync/types.js +0 -7
- package/sync/utils/getTableType.js +11 -19
- package/sync/utils/getTableType.js.map +1 -1
- package/sync/utils/manifest.d.ts +3 -7
- package/sync/utils/manifest.js +30 -47
- package/sync/utils/manifest.js.map +1 -1
- package/sync/utils/validateSystemInput.d.ts +1 -1
- package/sync/utils/validateSystemInput.js +22 -37
- package/sync/utils/validateSystemInput.js.map +1 -1
- package/types.d.ts +1 -5
- package/types.js +6 -12
- package/types.js.map +1 -1
- package/utils/createSystemName.js +5 -10
- package/utils/createSystemName.js.map +1 -1
- package/worker/SyncWorkerConfig.d.ts +9 -0
- package/worker/SyncWorkerConfig.js +5 -0
- package/worker/SyncWorkerConfig.js.map +1 -0
- package/worker/SyncWorkerEventHandler.d.ts +14 -0
- package/worker/SyncWorkerEventHandler.js +5 -0
- package/worker/SyncWorkerEventHandler.js.map +1 -0
- package/worker/SyncWorkerEventType.d.ts +10 -0
- package/worker/SyncWorkerEventType.js +24 -0
- package/worker/SyncWorkerEventType.js.map +1 -0
- package/worker/SyncWorkerLambdaHandler.d.ts +13 -0
- package/worker/SyncWorkerLambdaHandler.js +61 -0
- package/worker/SyncWorkerLambdaHandler.js.map +1 -0
- package/worker/actions/copyFile/CopyFile.js +185 -268
- package/worker/actions/copyFile/CopyFile.js.map +1 -1
- package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
- package/worker/actions/copyFile/copyFileAction.js +30 -45
- package/worker/actions/copyFile/copyFileAction.js.map +1 -1
- package/worker/actions/copyFile/copyFileSchema.d.ts +6 -38
- package/worker/actions/copyFile/copyFileSchema.js +14 -23
- package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
- package/worker/actions/copyFile/types.js +0 -7
- package/worker/actions/createUser/CreateUser.d.ts +1 -1
- package/worker/actions/createUser/CreateUser.js +53 -83
- package/worker/actions/createUser/CreateUser.js.map +1 -1
- package/worker/actions/createUser/createUserAction.d.ts +2 -2
- package/worker/actions/createUser/createUserAction.js +28 -39
- package/worker/actions/createUser/createUserAction.js.map +1 -1
- package/worker/actions/createUser/createUserSchema.d.ts +6 -38
- package/worker/actions/createUser/createUserSchema.js +14 -23
- package/worker/actions/createUser/createUserSchema.js.map +1 -1
- package/worker/actions/createUser/types.js +0 -7
- package/worker/actions/deleteFile/DeleteFile.js +52 -74
- package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
- package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
- package/worker/actions/deleteFile/deleteFileAction.js +25 -40
- package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
- package/worker/actions/deleteFile/deleteFileSchema.d.ts +6 -38
- package/worker/actions/deleteFile/deleteFileSchema.js +14 -23
- package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
- package/worker/actions/deleteFile/types.js +0 -7
- package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
- package/worker/actions/deleteUser/DeleteUser.js +39 -60
- package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
- package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
- package/worker/actions/deleteUser/deleteUserAction.js +26 -37
- package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
- package/worker/actions/deleteUser/deleteUserSchema.d.ts +5 -23
- package/worker/actions/deleteUser/deleteUserSchema.js +13 -22
- package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
- package/worker/actions/deleteUser/types.js +0 -7
- package/worker/actions/logValidationError.js +6 -14
- package/worker/actions/logValidationError.js.map +1 -1
- package/worker/actions/removeCognitoUserAttributes.js +9 -22
- package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
- package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
- package/worker/actions/updateUser/UpdateUser.js +50 -74
- package/worker/actions/updateUser/UpdateUser.js.map +1 -1
- package/worker/actions/updateUser/types.js +0 -7
- package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
- package/worker/actions/updateUser/updateUserAction.js +28 -39
- package/worker/actions/updateUser/updateUserAction.js.map +1 -1
- package/worker/actions/updateUser/updateUserSchema.d.ts +6 -38
- package/worker/actions/updateUser/updateUserSchema.js +14 -23
- package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
- package/worker/handler/WorkerActionHandler.d.ts +2 -2
- package/worker/handler/WorkerActionHandler.js +19 -28
- package/worker/handler/WorkerActionHandler.js.map +1 -1
- package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
- package/worker/plugins/WorkerActionPlugin.js +18 -25
- package/worker/plugins/WorkerActionPlugin.js.map +1 -1
- package/worker/types.js +0 -7
- package/index.js.map +0 -1
- package/resolver/app/abstractions/RecordHandler.js.map +0 -1
- package/resolver/app/abstractions/RecordsValidation.js.map +0 -1
- package/resolver/app/abstractions/ResolverApplication.js.map +0 -1
- package/resolver/app/abstractions/ResolverRecord.js.map +0 -1
- package/resolver/app/bundler/types.js.map +0 -1
- package/resolver/app/data/types.js.map +0 -1
- package/resolver/app/fetcher/types.js.map +0 -1
- package/resolver/app/ingestor/types.js.map +0 -1
- package/resolver/app/storer/types.js.map +0 -1
- package/resolver/createEventHandlerPlugin.d.ts +0 -10
- package/resolver/createEventHandlerPlugin.js +0 -127
- package/resolver/createEventHandlerPlugin.js.map +0 -1
- package/resolver/createResolverHandler.d.ts +0 -21
- package/resolver/createResolverHandler.js +0 -79
- package/resolver/createResolverHandler.js.map +0 -1
- package/resolver/deployment/types.js.map +0 -1
- package/resolver/recordTypes/fileManager/types.js.map +0 -1
- package/resolver/recordTypes/users/types.js.map +0 -1
- package/sync/createSendDataToEventBridgeOnRequestEnd.d.ts +0 -2
- package/sync/createSendDataToEventBridgeOnRequestEnd.js +0 -51
- package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +0 -1
- package/sync/createSyncSystem.d.ts +0 -16
- package/sync/createSyncSystem.js +0 -42
- package/sync/createSyncSystem.js.map +0 -1
- package/sync/handler/types.js.map +0 -1
- package/sync/requestPlugin.d.ts +0 -9
- package/sync/requestPlugin.js +0 -59
- package/sync/requestPlugin.js.map +0 -1
- package/sync/types.js.map +0 -1
- package/worker/actions/copyFile/types.js.map +0 -1
- package/worker/actions/createUser/types.js.map +0 -1
- package/worker/actions/deleteFile/types.js.map +0 -1
- package/worker/actions/deleteUser/types.js.map +0 -1
- package/worker/actions/updateUser/types.js.map +0 -1
- package/worker/createWorkerHandler.d.ts +0 -11
- package/worker/createWorkerHandler.js +0 -48
- package/worker/createWorkerHandler.js.map +0 -1
- package/worker/handler/eventHandler.d.ts +0 -1
- package/worker/handler/eventHandler.js +0 -31
- package/worker/handler/eventHandler.js.map +0 -1
- package/worker/types.js.map +0 -1
|
@@ -1,48 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = params;
|
|
28
|
-
/**
|
|
29
|
-
* We are 100% positive that the key exists here because canHandle would not allow for handle to be called.
|
|
30
|
-
*/
|
|
31
|
-
// @ts-expect-error
|
|
32
|
-
const username = item.data.email;
|
|
33
|
-
try {
|
|
34
|
-
await copyUser.handle({
|
|
35
|
-
target: params.target,
|
|
36
|
-
source: params.source,
|
|
37
|
-
username
|
|
38
|
-
});
|
|
39
|
-
} catch (ex) {
|
|
40
|
-
console.error("Error while handling users onPut plugin.");
|
|
41
|
-
console.log((0, _utils.convertException)(ex));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
1
|
+
import { createStorerAfterEachPluginWithName } from "../../plugins/StorerAfterEachPlugin.js";
|
|
2
|
+
import { shouldBeHandled } from "./shouldBeHandled.js";
|
|
3
|
+
import { convertException } from "@webiny/utils";
|
|
4
|
+
const createUserOnPutPlugin = (params)=>{
|
|
5
|
+
const { copyUser } = params;
|
|
6
|
+
return createStorerAfterEachPluginWithName("users.onPut", {
|
|
7
|
+
canHandle: (params)=>{
|
|
8
|
+
const { command } = params;
|
|
9
|
+
if ("put" !== command) return false;
|
|
10
|
+
return shouldBeHandled(params);
|
|
11
|
+
},
|
|
12
|
+
handle: async (params)=>{
|
|
13
|
+
const { item } = params;
|
|
14
|
+
const username = item.data.email;
|
|
15
|
+
try {
|
|
16
|
+
await copyUser.handle({
|
|
17
|
+
target: params.target,
|
|
18
|
+
source: params.source,
|
|
19
|
+
username
|
|
20
|
+
});
|
|
21
|
+
} catch (ex) {
|
|
22
|
+
console.error("Error while handling users onPut plugin.");
|
|
23
|
+
console.log(convertException(ex));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
45
27
|
};
|
|
46
|
-
|
|
28
|
+
export { createUserOnPutPlugin };
|
|
47
29
|
|
|
48
30
|
//# sourceMappingURL=usersOnPut.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/recordTypes/users/usersOnPut.js","sources":["../../../../src/resolver/recordTypes/users/usersOnPut.ts"],"sourcesContent":["import { createStorerAfterEachPluginWithName } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\nimport { shouldBeHandled } from \"./shouldBeHandled.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { ICopyUser } from \"~/resolver/recordTypes/users/types.js\";\n\nexport interface ICreateUserOnPutPluginParams {\n copyUser: ICopyUser;\n}\n\nexport const createUserOnPutPlugin = (params: ICreateUserOnPutPluginParams) => {\n const { copyUser } = params;\n\n return createStorerAfterEachPluginWithName(\"users.onPut\", {\n canHandle: params => {\n const { command } = params;\n if (command !== \"put\") {\n return false;\n }\n return shouldBeHandled(params);\n },\n handle: async params => {\n const { item } = params;\n /**\n * We are 100% positive that the key exists here because canHandle would not allow for handle to be called.\n */\n // @ts-expect-error\n const username = item.data.email as string;\n try {\n await copyUser.handle({\n target: params.target,\n source: params.source,\n username\n });\n } catch (ex) {\n console.error(\"Error while handling users onPut plugin.\");\n console.log(convertException(ex));\n }\n }\n });\n};\n"],"names":["createUserOnPutPlugin","params","copyUser","createStorerAfterEachPluginWithName","command","shouldBeHandled","item","username","ex","console","convertException"],"mappings":";;;AASO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,OAAOE,oCAAoC,eAAe;QACtD,WAAWF,CAAAA;YACP,MAAM,EAAEG,OAAO,EAAE,GAAGH;YACpB,IAAIG,AAAY,UAAZA,SACA,OAAO;YAEX,OAAOC,gBAAgBJ;QAC3B;QACA,QAAQ,OAAMA;YACV,MAAM,EAAEK,IAAI,EAAE,GAAGL;YAKjB,MAAMM,WAAWD,KAAK,IAAI,CAAC,KAAK;YAChC,IAAI;gBACA,MAAMJ,SAAS,MAAM,CAAC;oBAClB,QAAQD,OAAO,MAAM;oBACrB,QAAQA,OAAO,MAAM;oBACrBM;gBACJ;YACJ,EAAE,OAAOC,IAAI;gBACTC,QAAQ,KAAK,CAAC;gBACdA,QAAQ,GAAG,CAACC,iBAAiBF;YACjC;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { APIGatewayProxyEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import { ApiGatewayEventHandler } from "@webiny/event-handler-aws/abstractions/handlers/ApiGatewayEventHandler.js";
|
|
3
|
+
import type { EventContext, NextFunction } from "@webiny/event-handler-core";
|
|
4
|
+
import type { ISyncSystemConfig } from "./SyncSystemConfig.js";
|
|
5
|
+
declare class ApiGatewaySyncDecoratorImpl implements ApiGatewayEventHandler.Interface {
|
|
6
|
+
private config;
|
|
7
|
+
private inner;
|
|
8
|
+
constructor(config: ISyncSystemConfig, inner: ApiGatewayEventHandler.Interface);
|
|
9
|
+
execute(ctx: EventContext<APIGatewayProxyEvent>, next: NextFunction): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export declare const ApiGatewaySyncDecorator: typeof ApiGatewaySyncDecoratorImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-aws/abstractions/handlers/ApiGatewayEventHandler.js").IApiGatewayEventHandler>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ApiGatewayEventHandler } from "@webiny/event-handler-aws/abstractions/handlers/ApiGatewayEventHandler.js";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { SyncSystemConfig } from "./SyncSystemConfig.js";
|
|
4
|
+
import { createHandler } from "./createHandler.js";
|
|
5
|
+
import { getManifest } from "./utils/manifest.js";
|
|
6
|
+
import { decorateClientWithHandler } from "./attachToDynamoDbDocument.js";
|
|
7
|
+
import { createDefaultFilterOutRecordPlugins } from "./filter/createDefaultFilterOutRecordPlugins.js";
|
|
8
|
+
class ApiGatewaySyncDecoratorImpl {
|
|
9
|
+
constructor(config, inner){
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.inner = inner;
|
|
12
|
+
}
|
|
13
|
+
async execute(ctx, next) {
|
|
14
|
+
const { data: manifest, error } = await getManifest();
|
|
15
|
+
if (error || !manifest?.sync?.region) {
|
|
16
|
+
if ("true" === process.env.DEBUG) console.warn("[ApiGatewaySyncDecorator] Manifest not available — sync disabled.");
|
|
17
|
+
return this.inner.execute(ctx, next);
|
|
18
|
+
}
|
|
19
|
+
const filterPlugins = [
|
|
20
|
+
...createDefaultFilterOutRecordPlugins(),
|
|
21
|
+
...this.config.plugins || []
|
|
22
|
+
];
|
|
23
|
+
const { handler } = createHandler({
|
|
24
|
+
getEventBridgeClient: this.config.getEventBridgeClient,
|
|
25
|
+
system: this.config.system,
|
|
26
|
+
manifest,
|
|
27
|
+
getPlugins: ()=>new PluginsContainer(filterPlugins)
|
|
28
|
+
});
|
|
29
|
+
const documentClient = this.config.getDocumentClient();
|
|
30
|
+
decorateClientWithHandler({
|
|
31
|
+
handler,
|
|
32
|
+
client: documentClient
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
return await this.inner.execute(ctx, next);
|
|
36
|
+
} finally{
|
|
37
|
+
await handler.flush();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const ApiGatewaySyncDecorator = ApiGatewayEventHandler.createDecorator({
|
|
42
|
+
decorator: ApiGatewaySyncDecoratorImpl,
|
|
43
|
+
dependencies: [
|
|
44
|
+
SyncSystemConfig
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
export { ApiGatewaySyncDecorator };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=ApiGatewaySyncDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync/ApiGatewaySyncDecorator.js","sources":["../../src/sync/ApiGatewaySyncDecorator.ts"],"sourcesContent":["import type { APIGatewayProxyEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { ApiGatewayEventHandler } from \"@webiny/event-handler-aws/abstractions/handlers/ApiGatewayEventHandler.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport type { EventContext, NextFunction } from \"@webiny/event-handler-core\";\nimport { SyncSystemConfig } from \"./SyncSystemConfig.js\";\nimport type { ISyncSystemConfig } from \"./SyncSystemConfig.js\";\nimport { createHandler } from \"~/sync/createHandler.js\";\nimport { getManifest } from \"~/sync/utils/manifest.js\";\nimport { decorateClientWithHandler } from \"~/sync/attachToDynamoDbDocument.js\";\nimport { createDefaultFilterOutRecordPlugins } from \"~/sync/filter/createDefaultFilterOutRecordPlugins.js\";\n\nclass ApiGatewaySyncDecoratorImpl implements ApiGatewayEventHandler.Interface {\n constructor(\n private config: ISyncSystemConfig,\n private inner: ApiGatewayEventHandler.Interface\n ) {}\n\n async execute(ctx: EventContext<APIGatewayProxyEvent>, next: NextFunction): Promise<any> {\n const { data: manifest, error } = await getManifest();\n if (error || !manifest?.sync?.region) {\n if (process.env.DEBUG === \"true\") {\n console.warn(\"[ApiGatewaySyncDecorator] Manifest not available — sync disabled.\");\n }\n return this.inner.execute(ctx, next);\n }\n\n const filterPlugins = [\n ...createDefaultFilterOutRecordPlugins(),\n ...(this.config.plugins || [])\n ];\n\n const { handler } = createHandler({\n getEventBridgeClient: this.config.getEventBridgeClient,\n system: this.config.system,\n manifest,\n getPlugins: () => new PluginsContainer(filterPlugins)\n });\n\n const documentClient = this.config.getDocumentClient();\n decorateClientWithHandler({ handler, client: documentClient as any });\n\n try {\n return await this.inner.execute(ctx, next);\n } finally {\n await handler.flush();\n }\n }\n}\n\nexport const ApiGatewaySyncDecorator = ApiGatewayEventHandler.createDecorator({\n decorator: ApiGatewaySyncDecoratorImpl,\n dependencies: [SyncSystemConfig]\n});\n"],"names":["ApiGatewaySyncDecoratorImpl","config","inner","ctx","next","manifest","error","getManifest","process","console","filterPlugins","createDefaultFilterOutRecordPlugins","handler","createHandler","PluginsContainer","documentClient","decorateClientWithHandler","ApiGatewaySyncDecorator","ApiGatewayEventHandler","SyncSystemConfig"],"mappings":";;;;;;;AAWA,MAAMA;IACF,YACYC,MAAyB,EACzBC,KAAuC,CACjD;aAFUD,MAAM,GAANA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,QAAQC,GAAuC,EAAEC,IAAkB,EAAgB;QACrF,MAAM,EAAE,MAAMC,QAAQ,EAAEC,KAAK,EAAE,GAAG,MAAMC;QACxC,IAAID,SAAS,CAACD,UAAU,MAAM,QAAQ;YAClC,IAAIG,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjBC,QAAQ,IAAI,CAAC;YAEjB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAACN,KAAKC;QACnC;QAEA,MAAMM,gBAAgB;eACfC;eACC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE;SAChC;QAED,MAAM,EAAEC,OAAO,EAAE,GAAGC,cAAc;YAC9B,sBAAsB,IAAI,CAAC,MAAM,CAAC,oBAAoB;YACtD,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1BR;YACA,YAAY,IAAM,IAAIS,iBAAiBJ;QAC3C;QAEA,MAAMK,iBAAiB,IAAI,CAAC,MAAM,CAAC,iBAAiB;QACpDC,0BAA0B;YAAEJ;YAAS,QAAQG;QAAsB;QAEnE,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAACZ,KAAKC;QACzC,SAAU;YACN,MAAMQ,QAAQ,KAAK;QACvB;IACJ;AACJ;AAEO,MAAMK,0BAA0BC,uBAAuB,eAAe,CAAC;IAC1E,WAAWlB;IACX,cAAc;QAACmB;KAAiB;AACpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FilterOutRecordPlugin } from "
|
|
2
|
-
import type { ICommandValueItemExtended } from "
|
|
1
|
+
import type { FilterOutRecordPlugin } from "../sync/plugins/FilterOutRecordPlugin.js";
|
|
2
|
+
import type { ICommandValueItemExtended } from "../sync/types.js";
|
|
3
3
|
export declare class FilterOutRecord {
|
|
4
4
|
private readonly plugins;
|
|
5
5
|
constructor(plugins: FilterOutRecordPlugin[]);
|
package/sync/FilterOutRecord.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createFilterOutRecord = exports.FilterOutRecord = void 0;
|
|
7
1
|
class FilterOutRecord {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
filterOut(item) {
|
|
15
|
-
for (const plugin of this.plugins) {
|
|
16
|
-
if (plugin.execute(item)) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
2
|
+
constructor(plugins){
|
|
3
|
+
this.plugins = plugins;
|
|
4
|
+
}
|
|
5
|
+
filterOut(item) {
|
|
6
|
+
for (const plugin of this.plugins)if (plugin.execute(item)) return true;
|
|
7
|
+
return false;
|
|
19
8
|
}
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
9
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return new FilterOutRecord(plugins);
|
|
26
|
-
};
|
|
27
|
-
exports.createFilterOutRecord = createFilterOutRecord;
|
|
10
|
+
const createFilterOutRecord = (plugins)=>new FilterOutRecord(plugins);
|
|
11
|
+
export { FilterOutRecord, createFilterOutRecord };
|
|
28
12
|
|
|
29
13
|
//# sourceMappingURL=FilterOutRecord.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sync/FilterOutRecord.js","sources":["../../src/sync/FilterOutRecord.ts"],"sourcesContent":["import type { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport type { ICommandValueItemExtended } from \"~/sync/types.js\";\n\nexport class FilterOutRecord {\n private readonly plugins: FilterOutRecordPlugin[];\n\n public constructor(plugins: FilterOutRecordPlugin[]) {\n this.plugins = plugins;\n }\n /**\n * If method returns `true`, the record will be filtered out.\n */\n public filterOut(item: ICommandValueItemExtended): boolean {\n for (const plugin of this.plugins) {\n if (plugin.execute(item)) {\n return true;\n }\n }\n return false;\n }\n}\n\nexport const createFilterOutRecord = (plugins: FilterOutRecordPlugin[]): FilterOutRecord => {\n return new FilterOutRecord(plugins);\n};\n"],"names":["FilterOutRecord","plugins","item","plugin","createFilterOutRecord"],"mappings":"AAGO,MAAMA;IAGT,YAAmBC,OAAgC,CAAE;QACjD,IAAI,CAAC,OAAO,GAAGA;IACnB;IAIO,UAAUC,IAA+B,EAAW;QACvD,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAC7B,IAAIA,OAAO,OAAO,CAACD,OACf,OAAO;QAGf,OAAO;IACX;AACJ;AAEO,MAAME,wBAAwB,CAACH,UAC3B,IAAID,gBAAgBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EventBridgeClient } from "@webiny/aws-sdk/client-eventbridge/index.js";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
+
import type { ISystem } from "./types.js";
|
|
4
|
+
import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
|
|
5
|
+
export interface ISyncSystemConfig {
|
|
6
|
+
getDocumentClient(): Pick<DynamoDBDocument, "send">;
|
|
7
|
+
getEventBridgeClient(): Pick<EventBridgeClient, "send">;
|
|
8
|
+
system: ISystem;
|
|
9
|
+
plugins?: FilterOutRecordPlugin[];
|
|
10
|
+
}
|
|
11
|
+
export declare const SyncSystemConfig: import("@webiny/di").Abstraction<ISyncSystemConfig>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync/SyncSystemConfig.js","sources":["../../src/sync/SyncSystemConfig.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { EventBridgeClient } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { ISystem } from \"./types.js\";\nimport type { FilterOutRecordPlugin } from \"./plugins/FilterOutRecordPlugin.js\";\n\nexport interface ISyncSystemConfig {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n system: ISystem;\n plugins?: FilterOutRecordPlugin[];\n}\n\nexport const SyncSystemConfig = createAbstraction<ISyncSystemConfig>(\"SyncSystemConfig\");\n"],"names":["SyncSystemConfig","createAbstraction"],"mappings":";AAaO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -1,79 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
handler
|
|
12
|
-
client
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { decorateDocumentClient } from "@webiny/aws-sdk/client-dynamodb/getDocumentClient.js";
|
|
2
|
+
import { BatchWriteCommand, DeleteCommand, PutCommand, UpdateCommand } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
+
const decorateClientWithHandler = (params)=>{
|
|
4
|
+
const { handler, client } = params;
|
|
5
|
+
if (client.__webinyHandler?.id === handler.id) return client;
|
|
6
|
+
const originalSend = client.send;
|
|
7
|
+
const originalPut = client.put;
|
|
8
|
+
const originalDelete = client.delete;
|
|
9
|
+
const originalUpdate = client.update;
|
|
10
|
+
const originalBatchWrite = client.batchWrite;
|
|
11
|
+
client.__webinyHandler = handler;
|
|
12
|
+
client.send = async (params)=>{
|
|
13
|
+
handler.add(params);
|
|
14
|
+
return originalSend.apply(client, [
|
|
15
|
+
params
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
client.put = async (params)=>{
|
|
19
|
+
const cmd = new PutCommand(params);
|
|
20
|
+
handler.add(cmd);
|
|
21
|
+
return originalPut.apply(client, [
|
|
22
|
+
params
|
|
23
|
+
]);
|
|
24
|
+
};
|
|
25
|
+
client.delete = async (params)=>{
|
|
26
|
+
const cmd = new DeleteCommand(params);
|
|
27
|
+
handler.add(cmd);
|
|
28
|
+
return originalDelete.apply(client, [
|
|
29
|
+
params
|
|
30
|
+
]);
|
|
31
|
+
};
|
|
32
|
+
client.batchWrite = async (params)=>{
|
|
33
|
+
const cmd = new BatchWriteCommand(params);
|
|
34
|
+
handler.add(cmd);
|
|
35
|
+
return originalBatchWrite.apply(client, [
|
|
36
|
+
params
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
client.update = async (params)=>{
|
|
40
|
+
const cmd = new UpdateCommand(params);
|
|
41
|
+
handler.add(cmd);
|
|
42
|
+
return originalUpdate(params);
|
|
43
|
+
};
|
|
20
44
|
return client;
|
|
21
|
-
}
|
|
22
|
-
const originalSend = client.send;
|
|
23
|
-
const originalPut = client.put;
|
|
24
|
-
const originalDelete = client.delete;
|
|
25
|
-
const originalUpdate = client.update;
|
|
26
|
-
const originalBatchWrite = client.batchWrite;
|
|
27
|
-
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
client.__webinyHandler = handler;
|
|
30
|
-
client.send = async params => {
|
|
31
|
-
// @ts-expect-error
|
|
32
|
-
handler.add(params);
|
|
33
|
-
// @ts-expect-error
|
|
34
|
-
return originalSend.apply(client, [params]);
|
|
35
|
-
};
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
client.put = async params => {
|
|
38
|
-
const cmd = new _index.PutCommand(params);
|
|
39
|
-
handler.add(cmd);
|
|
40
|
-
// @ts-expect-error
|
|
41
|
-
return originalPut.apply(client, [params]);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
client.delete = async params => {
|
|
46
|
-
const cmd = new _index.DeleteCommand(params);
|
|
47
|
-
handler.add(cmd);
|
|
48
|
-
// @ts-expect-error
|
|
49
|
-
return originalDelete.apply(client, [params]);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// @ts-expect-error
|
|
53
|
-
client.batchWrite = async params => {
|
|
54
|
-
const cmd = new _index.BatchWriteCommand(params);
|
|
55
|
-
handler.add(cmd);
|
|
56
|
-
// @ts-expect-error
|
|
57
|
-
return originalBatchWrite.apply(client, [params]);
|
|
58
|
-
};
|
|
59
|
-
client.update = async params => {
|
|
60
|
-
const cmd = new _index.UpdateCommand(params);
|
|
61
|
-
handler.add(cmd);
|
|
62
|
-
return originalUpdate(params);
|
|
63
|
-
};
|
|
64
|
-
return client;
|
|
65
|
-
};
|
|
66
|
-
exports.decorateClientWithHandler = decorateClientWithHandler;
|
|
67
|
-
const attachToDynamoDbDocument = ({
|
|
68
|
-
handler
|
|
69
|
-
}) => {
|
|
70
|
-
return (0, _getDocumentClient.decorateDocumentClient)(client => {
|
|
71
|
-
return decorateClientWithHandler({
|
|
72
|
-
handler,
|
|
73
|
-
client
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
45
|
};
|
|
77
|
-
|
|
46
|
+
const attachToDynamoDbDocument = ({ handler })=>decorateDocumentClient((client)=>decorateClientWithHandler({
|
|
47
|
+
handler,
|
|
48
|
+
client
|
|
49
|
+
}));
|
|
50
|
+
export { attachToDynamoDbDocument, decorateClientWithHandler };
|
|
78
51
|
|
|
79
52
|
//# sourceMappingURL=attachToDynamoDbDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sync/attachToDynamoDbDocument.js","sources":["../../src/sync/attachToDynamoDbDocument.ts"],"sourcesContent":["import { decorateDocumentClient } from \"@webiny/aws-sdk/client-dynamodb/getDocumentClient.js\";\nimport type { IHandler } from \"~/sync/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport {\n BatchWriteCommand,\n DeleteCommand,\n PutCommand,\n UpdateCommand\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport interface IAttachToDynamoDbDocumentParams {\n handler: IHandler;\n}\n\nexport interface IDecorateClientWithHandlerParams {\n handler: IHandler;\n client: DynamoDBDocument;\n}\n\nexport const decorateClientWithHandler = (\n params: IDecorateClientWithHandlerParams\n): DynamoDBDocument => {\n const { handler, client } = params;\n /**\n * Is there a possibility that this is already attached?\n * Let's check for the handler and then skip attaching.\n */\n // @ts-expect-error\n if (client.__webinyHandler?.id === handler.id) {\n return client;\n }\n\n const originalSend = client.send;\n const originalPut = client.put;\n const originalDelete = client.delete;\n const originalUpdate = client.update;\n const originalBatchWrite = client.batchWrite;\n\n // @ts-expect-error\n client.__webinyHandler = handler;\n\n client.send = async params => {\n // @ts-expect-error\n handler.add(params);\n // @ts-expect-error\n return originalSend.apply(client, [params]);\n };\n // @ts-expect-error\n client.put = async params => {\n const cmd = new PutCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalPut.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.delete = async params => {\n const cmd = new DeleteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalDelete.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.batchWrite = async params => {\n const cmd = new BatchWriteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalBatchWrite.apply(client, [params]);\n };\n\n client.update = async params => {\n const cmd = new UpdateCommand(params);\n handler.add(cmd);\n return originalUpdate(params);\n };\n\n return client;\n};\n\nexport const attachToDynamoDbDocument = ({ handler }: IAttachToDynamoDbDocumentParams): void => {\n return decorateDocumentClient(client => {\n return decorateClientWithHandler({\n handler,\n client\n });\n });\n};\n"],"names":["decorateClientWithHandler","params","handler","client","originalSend","originalPut","originalDelete","originalUpdate","originalBatchWrite","cmd","PutCommand","DeleteCommand","BatchWriteCommand","UpdateCommand","attachToDynamoDbDocument","decorateDocumentClient"],"mappings":";;AAmBO,MAAMA,4BAA4B,CACrCC;IAEA,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAM5B,IAAIE,OAAO,eAAe,EAAE,OAAOD,QAAQ,EAAE,EACzC,OAAOC;IAGX,MAAMC,eAAeD,OAAO,IAAI;IAChC,MAAME,cAAcF,OAAO,GAAG;IAC9B,MAAMG,iBAAiBH,OAAO,MAAM;IACpC,MAAMI,iBAAiBJ,OAAO,MAAM;IACpC,MAAMK,qBAAqBL,OAAO,UAAU;IAG5CA,OAAO,eAAe,GAAGD;IAEzBC,OAAO,IAAI,GAAG,OAAMF;QAEhBC,QAAQ,GAAG,CAACD;QAEZ,OAAOG,aAAa,KAAK,CAACD,QAAQ;YAACF;SAAO;IAC9C;IAEAE,OAAO,GAAG,GAAG,OAAMF;QACf,MAAMQ,MAAM,IAAIC,WAAWT;QAC3BC,QAAQ,GAAG,CAACO;QAEZ,OAAOJ,YAAY,KAAK,CAACF,QAAQ;YAACF;SAAO;IAC7C;IAGAE,OAAO,MAAM,GAAG,OAAMF;QAClB,MAAMQ,MAAM,IAAIE,cAAcV;QAC9BC,QAAQ,GAAG,CAACO;QAEZ,OAAOH,eAAe,KAAK,CAACH,QAAQ;YAACF;SAAO;IAChD;IAGAE,OAAO,UAAU,GAAG,OAAMF;QACtB,MAAMQ,MAAM,IAAIG,kBAAkBX;QAClCC,QAAQ,GAAG,CAACO;QAEZ,OAAOD,mBAAmB,KAAK,CAACL,QAAQ;YAACF;SAAO;IACpD;IAEAE,OAAO,MAAM,GAAG,OAAMF;QAClB,MAAMQ,MAAM,IAAII,cAAcZ;QAC9BC,QAAQ,GAAG,CAACO;QACZ,OAAOF,eAAeN;IAC1B;IAEA,OAAOE;AACX;AAEO,MAAMW,2BAA2B,CAAC,EAAEZ,OAAO,EAAmC,GAC1Ea,uBAAuBZ,CAAAA,SACnBH,0BAA0B;YAC7BE;YACAC;QACJ"}
|
package/sync/createHandler.js
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
converter.register((0, _DeleteCommandConverter.createDeleteCommandConverter)());
|
|
45
|
-
converter.register((0, _UpdateCommandConverter.createUpdateCommandConverter)());
|
|
46
|
-
const handler = (0, _Handler.createSyncHandler)({
|
|
47
|
-
system,
|
|
48
|
-
getEventBridgeClient,
|
|
49
|
-
eventBus: {
|
|
50
|
-
arn: manifest.sync.eventBusArn,
|
|
51
|
-
name: manifest.sync.eventBusName
|
|
52
|
-
},
|
|
53
|
-
converter,
|
|
54
|
-
filterOutRecord
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
handler,
|
|
58
|
-
converter
|
|
59
|
-
};
|
|
1
|
+
import { createHandlerConverter } from "./handler/HandlerConverter.js";
|
|
2
|
+
import { NullCommandValue } from "./handler/converter/commands/NullCommandValue.js";
|
|
3
|
+
import { createBatchWriteCommandConverter } from "./handler/converter/BatchWriteCommandConverter.js";
|
|
4
|
+
import { createPutCommandConverter } from "./handler/converter/PutCommandConverter.js";
|
|
5
|
+
import { createDeleteCommandConverter } from "./handler/converter/DeleteCommandConverter.js";
|
|
6
|
+
import { createUpdateCommandConverter } from "./handler/converter/UpdateCommandConverter.js";
|
|
7
|
+
import { createSyncHandler } from "./handler/Handler.js";
|
|
8
|
+
import { createBatchGetCommandConverter } from "./handler/converter/BatchGetCommandConverter.js";
|
|
9
|
+
import { createQueryCommandConverter } from "./handler/converter/QueryCommandConverter.js";
|
|
10
|
+
import { createScanCommandConverter } from "./handler/converter/ScanCommandConverter.js";
|
|
11
|
+
import { createGetCommandConverter } from "./handler/converter/GetCommandConverter.js";
|
|
12
|
+
import { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
|
|
13
|
+
import { createFilterOutRecord } from "./FilterOutRecord.js";
|
|
14
|
+
const createHandler = (params)=>{
|
|
15
|
+
const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;
|
|
16
|
+
const filterOutRecordPlugins = getPlugins().byType(FilterOutRecordPlugin.type);
|
|
17
|
+
const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);
|
|
18
|
+
const converter = createHandlerConverter({
|
|
19
|
+
defaultValue: new NullCommandValue()
|
|
20
|
+
});
|
|
21
|
+
converter.register(commandConverters || []);
|
|
22
|
+
converter.register(createBatchGetCommandConverter());
|
|
23
|
+
converter.register(createGetCommandConverter());
|
|
24
|
+
converter.register(createQueryCommandConverter());
|
|
25
|
+
converter.register(createScanCommandConverter());
|
|
26
|
+
converter.register(createBatchWriteCommandConverter());
|
|
27
|
+
converter.register(createPutCommandConverter());
|
|
28
|
+
converter.register(createDeleteCommandConverter());
|
|
29
|
+
converter.register(createUpdateCommandConverter());
|
|
30
|
+
const handler = createSyncHandler({
|
|
31
|
+
system,
|
|
32
|
+
getEventBridgeClient,
|
|
33
|
+
eventBus: {
|
|
34
|
+
arn: manifest.sync.eventBusArn,
|
|
35
|
+
name: manifest.sync.eventBusName
|
|
36
|
+
},
|
|
37
|
+
converter,
|
|
38
|
+
filterOutRecord
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
handler,
|
|
42
|
+
converter
|
|
43
|
+
};
|
|
60
44
|
};
|
|
61
|
-
|
|
45
|
+
export { createHandler };
|
|
62
46
|
|
|
63
47
|
//# sourceMappingURL=createHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sync/createHandler.js","sources":["../../src/sync/createHandler.ts"],"sourcesContent":["import { createHandlerConverter } from \"~/sync/handler/HandlerConverter.js\";\nimport { NullCommandValue } from \"~/sync/handler/converter/commands/NullCommandValue.js\";\nimport { createBatchWriteCommandConverter } from \"~/sync/handler/converter/BatchWriteCommandConverter.js\";\nimport { createPutCommandConverter } from \"~/sync/handler/converter/PutCommandConverter.js\";\nimport { createDeleteCommandConverter } from \"~/sync/handler/converter/DeleteCommandConverter.js\";\nimport { createUpdateCommandConverter } from \"~/sync/handler/converter/UpdateCommandConverter.js\";\nimport { createSyncHandler } from \"~/sync/handler/Handler.js\";\nimport type { EventBridgeClient } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport type { ICommandConverter, IManifest, ISystem } from \"./types.js\";\nimport { createBatchGetCommandConverter } from \"./handler/converter/BatchGetCommandConverter.js\";\nimport { createQueryCommandConverter } from \"./handler/converter/QueryCommandConverter.js\";\nimport { createScanCommandConverter } from \"~/sync/handler/converter/ScanCommandConverter.js\";\nimport { createGetCommandConverter } from \"./handler/converter/GetCommandConverter.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\nimport { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport { createFilterOutRecord } from \"~/sync/FilterOutRecord.js\";\n\nexport interface ICreateHandlerParams {\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n commandConverters?: ICommandConverter[];\n system: ISystem;\n manifest: IManifest;\n getPlugins: () => PluginsContainer;\n}\n\nexport const createHandler = (params: ICreateHandlerParams) => {\n const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;\n\n const filterOutRecordPlugins = getPlugins().byType<FilterOutRecordPlugin>(\n FilterOutRecordPlugin.type\n );\n\n const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);\n\n const converter = createHandlerConverter({\n defaultValue: new NullCommandValue()\n });\n /**\n * We register users command converters because those are tested out first.\n * Our converters are in some order I got from my head - the most used commands are first.\n */\n converter.register(commandConverters || []);\n converter.register(createBatchGetCommandConverter());\n converter.register(createGetCommandConverter());\n converter.register(createQueryCommandConverter());\n converter.register(createScanCommandConverter());\n converter.register(createBatchWriteCommandConverter());\n converter.register(createPutCommandConverter());\n converter.register(createDeleteCommandConverter());\n converter.register(createUpdateCommandConverter());\n\n const handler = createSyncHandler({\n system,\n getEventBridgeClient,\n eventBus: {\n arn: manifest.sync.eventBusArn,\n name: manifest.sync.eventBusName\n },\n converter,\n filterOutRecord\n });\n return {\n handler,\n converter\n };\n};\n"],"names":["createHandler","params","manifest","commandConverters","system","getEventBridgeClient","getPlugins","filterOutRecordPlugins","FilterOutRecordPlugin","filterOutRecord","createFilterOutRecord","converter","createHandlerConverter","NullCommandValue","createBatchGetCommandConverter","createGetCommandConverter","createQueryCommandConverter","createScanCommandConverter","createBatchWriteCommandConverter","createPutCommandConverter","createDeleteCommandConverter","createUpdateCommandConverter","handler","createSyncHandler"],"mappings":";;;;;;;;;;;;;AAyBO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,MAAM,EAAEC,oBAAoB,EAAEC,UAAU,EAAE,GAAGL;IAElF,MAAMM,yBAAyBD,aAAa,MAAM,CAC9CE,sBAAsB,IAAI;IAG9B,MAAMC,kBAAkBC,sBAAsBH;IAE9C,MAAMI,YAAYC,uBAAuB;QACrC,cAAc,IAAIC;IACtB;IAKAF,UAAU,QAAQ,CAACR,qBAAqB,EAAE;IAC1CQ,UAAU,QAAQ,CAACG;IACnBH,UAAU,QAAQ,CAACI;IACnBJ,UAAU,QAAQ,CAACK;IACnBL,UAAU,QAAQ,CAACM;IACnBN,UAAU,QAAQ,CAACO;IACnBP,UAAU,QAAQ,CAACQ;IACnBR,UAAU,QAAQ,CAACS;IACnBT,UAAU,QAAQ,CAACU;IAEnB,MAAMC,UAAUC,kBAAkB;QAC9BnB;QACAC;QACA,UAAU;YACN,KAAKH,SAAS,IAAI,CAAC,WAAW;YAC9B,MAAMA,SAAS,IAAI,CAAC,YAAY;QACpC;QACAS;QACAF;IACJ;IACA,OAAO;QACHa;QACAX;IACJ;AACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterOutRecordPlugin } from "
|
|
1
|
+
import { FilterOutRecordPlugin } from "../../sync/plugins/FilterOutRecordPlugin.js";
|
|
2
2
|
/**
|
|
3
3
|
* Order keys by what is most like to be filtered out - most inserts/updates/deletes.
|
|
4
4
|
* This is out of my head, so it might not be the best order.
|