@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,126 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createRecordHandler = exports.RecordHandler = void 0;
|
|
7
|
-
var _CommandHandlerPlugin = require("../plugins/CommandHandlerPlugin.js");
|
|
8
|
-
var _utils = require("@webiny/utils");
|
|
1
|
+
import { CommandHandlerPlugin } from "../plugins/CommandHandlerPlugin.js";
|
|
2
|
+
import { convertException } from "@webiny/utils";
|
|
9
3
|
class RecordHandler {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
async handle(params) {
|
|
22
|
-
const {
|
|
23
|
-
data
|
|
24
|
-
} = params;
|
|
25
|
-
const sources = this.tableBundler.bundle({
|
|
26
|
-
items: data.getItems()
|
|
27
|
-
});
|
|
28
|
-
const container = this.createSourceDataContainer();
|
|
29
|
-
for (const bundle of sources.getBundles()) {
|
|
30
|
-
/**
|
|
31
|
-
* Need to fetch all the records from the source deployment tables.
|
|
32
|
-
*/
|
|
33
|
-
const {
|
|
34
|
-
items,
|
|
35
|
-
error
|
|
36
|
-
} = await this.fetcher.exec({
|
|
37
|
-
deployment: bundle.source,
|
|
38
|
-
table: bundle.table,
|
|
39
|
-
items: bundle.items,
|
|
40
|
-
maxBatchSize: 25
|
|
41
|
-
});
|
|
42
|
-
if (error) {
|
|
43
|
-
console.error(`Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`);
|
|
44
|
-
console.log((0, _utils.convertException)(error));
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
container.merge(items);
|
|
4
|
+
constructor(params){
|
|
5
|
+
this.plugins = params.plugins;
|
|
6
|
+
this.fetcher = params.fetcher;
|
|
7
|
+
this.storer = params.storer;
|
|
8
|
+
this.commandBundler = params.commandBundler;
|
|
9
|
+
this.tableBundler = params.tableBundler;
|
|
10
|
+
this.deployments = params.deployments;
|
|
11
|
+
this.transformHandler = params.transformHandler;
|
|
12
|
+
this.createSourceDataContainer = params.createSourceDataContainer;
|
|
13
|
+
this.commandHandlerPlugins = this.plugins.byType(CommandHandlerPlugin.type);
|
|
48
14
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
items: data.getItems()
|
|
54
|
-
});
|
|
55
|
-
for (const bundle of bundlesByCommand.getBundles()) {
|
|
56
|
-
const deployments = this.deployments.without(bundle.source);
|
|
57
|
-
for (const targetDeployment of deployments.all()) {
|
|
58
|
-
/**
|
|
59
|
-
* We need to map keys to actual items from the source deployment.
|
|
60
|
-
*/
|
|
61
|
-
const items = bundle.items.map(item => {
|
|
62
|
-
return container.get({
|
|
63
|
-
PK: item.PK,
|
|
64
|
-
SK: item.SK,
|
|
65
|
-
table: bundle.table,
|
|
66
|
-
source: bundle.source
|
|
67
|
-
});
|
|
68
|
-
}).filter(item => !!item);
|
|
69
|
-
const targetTable = this.findTargetTable({
|
|
70
|
-
bundle,
|
|
71
|
-
targetDeployment
|
|
15
|
+
async handle(params) {
|
|
16
|
+
const { data } = params;
|
|
17
|
+
const sources = this.tableBundler.bundle({
|
|
18
|
+
items: data.getItems()
|
|
72
19
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
20
|
+
const container = this.createSourceDataContainer();
|
|
21
|
+
for (const bundle of sources.getBundles()){
|
|
22
|
+
const { items, error } = await this.fetcher.exec({
|
|
23
|
+
deployment: bundle.source,
|
|
24
|
+
table: bundle.table,
|
|
25
|
+
items: bundle.items,
|
|
26
|
+
maxBatchSize: 25
|
|
27
|
+
});
|
|
28
|
+
if (error) {
|
|
29
|
+
console.error(`Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`);
|
|
30
|
+
console.log(convertException(error));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
container.merge(items);
|
|
76
34
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
sourceDeployment: bundle.source,
|
|
80
|
-
sourceTable: bundle.table,
|
|
81
|
-
targetDeployment: targetDeployment,
|
|
82
|
-
targetTable: targetTable
|
|
35
|
+
const bundlesByCommand = this.commandBundler.bundle({
|
|
36
|
+
items: data.getItems()
|
|
83
37
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
38
|
+
for (const bundle of bundlesByCommand.getBundles()){
|
|
39
|
+
const deployments = this.deployments.without(bundle.source);
|
|
40
|
+
for (const targetDeployment of deployments.all()){
|
|
41
|
+
const items = bundle.items.map((item)=>container.get({
|
|
42
|
+
PK: item.PK,
|
|
43
|
+
SK: item.SK,
|
|
44
|
+
table: bundle.table,
|
|
45
|
+
source: bundle.source
|
|
46
|
+
})).filter((item)=>!!item);
|
|
47
|
+
const targetTable = this.findTargetTable({
|
|
48
|
+
bundle,
|
|
49
|
+
targetDeployment
|
|
50
|
+
});
|
|
51
|
+
if (!targetTable) {
|
|
52
|
+
console.error(`Could not find target table for source table "${bundle.table.name}" in deployment "${bundle.source.name}".`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const result = await this.transformHandler.transform({
|
|
56
|
+
items,
|
|
57
|
+
sourceDeployment: bundle.source,
|
|
58
|
+
sourceTable: bundle.table,
|
|
59
|
+
targetDeployment: targetDeployment,
|
|
60
|
+
targetTable: targetTable
|
|
61
|
+
});
|
|
62
|
+
let commandHandler;
|
|
63
|
+
try {
|
|
64
|
+
commandHandler = this.getCommandHandler(bundle.command);
|
|
65
|
+
} catch (ex) {
|
|
66
|
+
console.error(ex.message);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
await commandHandler.handle({
|
|
70
|
+
storer: this.storer,
|
|
71
|
+
items: result.items,
|
|
72
|
+
bundle,
|
|
73
|
+
targetDeployment: targetDeployment,
|
|
74
|
+
targetTable: targetTable
|
|
75
|
+
});
|
|
76
|
+
}
|
|
90
77
|
}
|
|
91
|
-
await commandHandler.handle({
|
|
92
|
-
storer: this.storer,
|
|
93
|
-
items: result.items,
|
|
94
|
-
bundle,
|
|
95
|
-
targetDeployment: targetDeployment,
|
|
96
|
-
targetTable: targetTable
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
78
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return targetDeployment.getTable(bundle.table.type);
|
|
108
|
-
} catch (ex) {
|
|
109
|
-
return null;
|
|
79
|
+
findTargetTable(params) {
|
|
80
|
+
const { bundle, targetDeployment } = params;
|
|
81
|
+
try {
|
|
82
|
+
return targetDeployment.getTable(bundle.table.type);
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
110
86
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw new Error(`Could not find a command handler for command: ${command}`);
|
|
87
|
+
getCommandHandler(command) {
|
|
88
|
+
const handler = this.commandHandlerPlugins.find((plugin)=>plugin.canHandle(command));
|
|
89
|
+
if (!handler) throw new Error(`Could not find a command handler for command: ${command}`);
|
|
90
|
+
return handler;
|
|
116
91
|
}
|
|
117
|
-
return handler;
|
|
118
|
-
}
|
|
119
92
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return new RecordHandler(params);
|
|
123
|
-
};
|
|
124
|
-
exports.createRecordHandler = createRecordHandler;
|
|
93
|
+
const createRecordHandler = (params)=>new RecordHandler(params);
|
|
94
|
+
export { RecordHandler, createRecordHandler };
|
|
125
95
|
|
|
126
96
|
//# sourceMappingURL=RecordHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_CommandHandlerPlugin","require","_utils","RecordHandler","constructor","params","plugins","fetcher","storer","commandBundler","tableBundler","deployments","transformHandler","createSourceDataContainer","commandHandlerPlugins","byType","CommandHandlerPlugin","type","handle","data","sources","bundle","items","getItems","container","getBundles","error","exec","deployment","source","table","maxBatchSize","console","name","log","convertException","merge","bundlesByCommand","without","targetDeployment","all","map","item","get","PK","SK","filter","targetTable","findTargetTable","result","transform","sourceDeployment","sourceTable","commandHandler","getCommandHandler","command","ex","message","getTable","handler","find","plugin","canHandle","Error","exports","createRecordHandler"],"sources":["RecordHandler.ts"],"sourcesContent":["import type { IRecordHandler, IRecordHandlerHandleParams } from \"./abstractions/RecordHandler.js\";\nimport { CommandHandlerPlugin } from \"../plugins/CommandHandlerPlugin.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { CommandType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IFetcher } from \"~/resolver/app/fetcher/types.js\";\nimport type { IStoreItem, IStorer } from \"~/resolver/app/storer/types.js\";\nimport type { IBundle, IBundler } from \"~/resolver/app/bundler/types.js\";\nimport type { IDeployment, IDeployments } from \"~/resolver/deployment/types.js\";\nimport type { ITransformHandler } from \"~/resolver/app/transform/TransformHandler.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { ISourceDataContainer } from \"~/resolver/app/data/types.js\";\n\nexport interface IRecordHandlerParams {\n fetcher: IFetcher;\n storer: IStorer;\n plugins: PluginsContainer;\n commandBundler: IBundler;\n tableBundler: IBundler;\n deployments: IDeployments;\n transformHandler: ITransformHandler;\n createSourceDataContainer: () => ISourceDataContainer;\n}\n\ninterface IFindTargetTableParams {\n bundle: IBundle;\n targetDeployment: IDeployment;\n}\n\nexport class RecordHandler implements IRecordHandler {\n private readonly plugins: PluginsContainer;\n private readonly commandHandlerPlugins: CommandHandlerPlugin[];\n private readonly fetcher: IFetcher;\n private readonly storer: IStorer;\n private readonly commandBundler: IBundler;\n private readonly tableBundler: IBundler;\n private readonly deployments: IDeployments;\n private readonly transformHandler: ITransformHandler;\n private readonly createSourceDataContainer: () => ISourceDataContainer;\n\n public constructor(params: IRecordHandlerParams) {\n this.plugins = params.plugins;\n this.fetcher = params.fetcher;\n this.storer = params.storer;\n this.commandBundler = params.commandBundler;\n this.tableBundler = params.tableBundler;\n this.deployments = params.deployments;\n this.transformHandler = params.transformHandler;\n this.createSourceDataContainer = params.createSourceDataContainer;\n\n this.commandHandlerPlugins = this.plugins.byType<CommandHandlerPlugin>(\n CommandHandlerPlugin.type\n );\n }\n\n public async handle(params: IRecordHandlerHandleParams): Promise<void> {\n const { data } = params;\n\n const sources = this.tableBundler.bundle({\n items: data.getItems()\n });\n\n const container = this.createSourceDataContainer();\n\n for (const bundle of sources.getBundles()) {\n /**\n * Need to fetch all the records from the source deployment tables.\n */\n const { items, error } = await this.fetcher.exec({\n deployment: bundle.source,\n table: bundle.table,\n items: bundle.items,\n maxBatchSize: 25\n });\n if (error) {\n console.error(\n `Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`\n );\n console.log(convertException(error));\n continue;\n }\n container.merge(items);\n }\n /**\n * We can now handle the records by going through all the items bundled by command, in correct order.\n */\n const bundlesByCommand = this.commandBundler.bundle({\n items: data.getItems()\n });\n for (const bundle of bundlesByCommand.getBundles()) {\n const deployments = this.deployments.without(bundle.source);\n for (const targetDeployment of deployments.all()) {\n /**\n * We need to map keys to actual items from the source deployment.\n */\n const items = bundle.items\n .map(item => {\n return container.get({\n PK: item.PK,\n SK: item.SK,\n table: bundle.table,\n source: bundle.source\n });\n })\n .filter((item): item is IStoreItem => !!item);\n\n const targetTable = this.findTargetTable({\n bundle,\n targetDeployment\n });\n if (!targetTable) {\n console.error(\n `Could not find target table for source table \"${bundle.table.name}\" in deployment \"${bundle.source.name}\".`\n );\n continue;\n }\n\n const result = await this.transformHandler.transform({\n items,\n sourceDeployment: bundle.source,\n sourceTable: bundle.table,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n\n let commandHandler: CommandHandlerPlugin;\n try {\n commandHandler = this.getCommandHandler(bundle.command);\n } catch (ex) {\n console.error(ex.message);\n continue;\n }\n\n await commandHandler.handle({\n storer: this.storer,\n items: result.items,\n bundle,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n }\n }\n }\n\n private findTargetTable(params: IFindTargetTableParams): ITable | null {\n const { bundle, targetDeployment } = params;\n\n try {\n return targetDeployment.getTable(bundle.table.type);\n } catch (ex) {\n return null;\n }\n }\n\n private getCommandHandler(command: CommandType): CommandHandlerPlugin {\n const handler = this.commandHandlerPlugins.find(plugin => plugin.canHandle(command));\n if (!handler) {\n throw new Error(`Could not find a command handler for command: ${command}`);\n }\n\n return handler;\n }\n}\n\nexport const createRecordHandler = (params: IRecordHandlerParams): IRecordHandler => {\n return new RecordHandler(params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AA2BO,MAAME,aAAa,CAA2B;EAW1CC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,OAAO,GAAGD,MA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F,aAAa,CAACE,MAAM,CAAC;AACpC,CAAC;AAAC2D,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"resolver/app/RecordHandler.js","sources":["../../../src/resolver/app/RecordHandler.ts"],"sourcesContent":["import type { IRecordHandler, IRecordHandlerHandleParams } from \"./abstractions/RecordHandler.js\";\nimport { CommandHandlerPlugin } from \"../plugins/CommandHandlerPlugin.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { CommandType } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { IFetcher } from \"~/resolver/app/fetcher/types.js\";\nimport type { IStoreItem, IStorer } from \"~/resolver/app/storer/types.js\";\nimport type { IBundle, IBundler } from \"~/resolver/app/bundler/types.js\";\nimport type { IDeployment, IDeployments } from \"~/resolver/deployment/types.js\";\nimport type { ITransformHandler } from \"~/resolver/app/transform/TransformHandler.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { ISourceDataContainer } from \"~/resolver/app/data/types.js\";\n\nexport interface IRecordHandlerParams {\n fetcher: IFetcher;\n storer: IStorer;\n plugins: PluginsContainer;\n commandBundler: IBundler;\n tableBundler: IBundler;\n deployments: IDeployments;\n transformHandler: ITransformHandler;\n createSourceDataContainer: () => ISourceDataContainer;\n}\n\ninterface IFindTargetTableParams {\n bundle: IBundle;\n targetDeployment: IDeployment;\n}\n\nexport class RecordHandler implements IRecordHandler {\n private readonly plugins: PluginsContainer;\n private readonly commandHandlerPlugins: CommandHandlerPlugin[];\n private readonly fetcher: IFetcher;\n private readonly storer: IStorer;\n private readonly commandBundler: IBundler;\n private readonly tableBundler: IBundler;\n private readonly deployments: IDeployments;\n private readonly transformHandler: ITransformHandler;\n private readonly createSourceDataContainer: () => ISourceDataContainer;\n\n public constructor(params: IRecordHandlerParams) {\n this.plugins = params.plugins;\n this.fetcher = params.fetcher;\n this.storer = params.storer;\n this.commandBundler = params.commandBundler;\n this.tableBundler = params.tableBundler;\n this.deployments = params.deployments;\n this.transformHandler = params.transformHandler;\n this.createSourceDataContainer = params.createSourceDataContainer;\n\n this.commandHandlerPlugins = this.plugins.byType<CommandHandlerPlugin>(\n CommandHandlerPlugin.type\n );\n }\n\n public async handle(params: IRecordHandlerHandleParams): Promise<void> {\n const { data } = params;\n\n const sources = this.tableBundler.bundle({\n items: data.getItems()\n });\n\n const container = this.createSourceDataContainer();\n\n for (const bundle of sources.getBundles()) {\n /**\n * Need to fetch all the records from the source deployment tables.\n */\n const { items, error } = await this.fetcher.exec({\n deployment: bundle.source,\n table: bundle.table,\n items: bundle.items,\n maxBatchSize: 25\n });\n if (error) {\n console.error(\n `Could not fetch records from the source table (${bundle.source.name} / ${bundle.table.name}). More info in next log line.`\n );\n console.log(convertException(error));\n continue;\n }\n container.merge(items);\n }\n /**\n * We can now handle the records by going through all the items bundled by command, in correct order.\n */\n const bundlesByCommand = this.commandBundler.bundle({\n items: data.getItems()\n });\n for (const bundle of bundlesByCommand.getBundles()) {\n const deployments = this.deployments.without(bundle.source);\n for (const targetDeployment of deployments.all()) {\n /**\n * We need to map keys to actual items from the source deployment.\n */\n const items = bundle.items\n .map(item => {\n return container.get({\n PK: item.PK,\n SK: item.SK,\n table: bundle.table,\n source: bundle.source\n });\n })\n .filter((item): item is IStoreItem => !!item);\n\n const targetTable = this.findTargetTable({\n bundle,\n targetDeployment\n });\n if (!targetTable) {\n console.error(\n `Could not find target table for source table \"${bundle.table.name}\" in deployment \"${bundle.source.name}\".`\n );\n continue;\n }\n\n const result = await this.transformHandler.transform({\n items,\n sourceDeployment: bundle.source,\n sourceTable: bundle.table,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n\n let commandHandler: CommandHandlerPlugin;\n try {\n commandHandler = this.getCommandHandler(bundle.command);\n } catch (ex) {\n console.error(ex.message);\n continue;\n }\n\n await commandHandler.handle({\n storer: this.storer,\n items: result.items,\n bundle,\n targetDeployment: targetDeployment,\n targetTable: targetTable\n });\n }\n }\n }\n\n private findTargetTable(params: IFindTargetTableParams): ITable | null {\n const { bundle, targetDeployment } = params;\n\n try {\n return targetDeployment.getTable(bundle.table.type);\n } catch {\n return null;\n }\n }\n\n private getCommandHandler(command: CommandType): CommandHandlerPlugin {\n const handler = this.commandHandlerPlugins.find(plugin => plugin.canHandle(command));\n if (!handler) {\n throw new Error(`Could not find a command handler for command: ${command}`);\n }\n\n return handler;\n }\n}\n\nexport const createRecordHandler = (params: IRecordHandlerParams): IRecordHandler => {\n return new RecordHandler(params);\n};\n"],"names":["RecordHandler","params","CommandHandlerPlugin","data","sources","container","bundle","items","error","console","convertException","bundlesByCommand","deployments","targetDeployment","item","targetTable","result","commandHandler","ex","command","handler","plugin","Error","createRecordHandler"],"mappings":";;AA6BO,MAAMA;IAWT,YAAmBC,MAA4B,CAAE;QAC7C,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;QAC3B,IAAI,CAAC,cAAc,GAAGA,OAAO,cAAc;QAC3C,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;QACrC,IAAI,CAAC,gBAAgB,GAAGA,OAAO,gBAAgB;QAC/C,IAAI,CAAC,yBAAyB,GAAGA,OAAO,yBAAyB;QAEjE,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAC5CC,qBAAqB,IAAI;IAEjC;IAEA,MAAa,OAAOD,MAAkC,EAAiB;QACnE,MAAM,EAAEE,IAAI,EAAE,GAAGF;QAEjB,MAAMG,UAAU,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YACrC,OAAOD,KAAK,QAAQ;QACxB;QAEA,MAAME,YAAY,IAAI,CAAC,yBAAyB;QAEhD,KAAK,MAAMC,UAAUF,QAAQ,UAAU,GAAI;YAIvC,MAAM,EAAEG,KAAK,EA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AM;oBAC/B,aAAaA,OAAO,KAAK;oBACzB,kBAAkBO;oBAClB,aAAaE;gBACjB;gBAEA,IAAIE;gBACJ,IAAI;oBACAA,iBAAiB,IAAI,CAAC,iBAAiB,CAACX,OAAO,OAAO;gBAC1D,EAAE,OAAOY,IAAI;oBACTT,QAAQ,KAAK,CAACS,GAAG,OAAO;oBACxB;gBACJ;gBAEA,MAAMD,eAAe,MAAM,CAAC;oBACxB,QAAQ,IAAI,CAAC,MAAM;oBACnB,OAAOD,OAAO,KAAK;oBACnBV;oBACA,kBAAkBO;oBAClB,aAAaE;gBACjB;YACJ;QACJ;IACJ;IAEQ,gBAAgBd,MAA8B,EAAiB;QACnE,MAAM,EAAEK,MAAM,EAAEO,gBAAgB,EAAE,GAAGZ;QAErC,IAAI;YACA,OAAOY,iBAAiB,QAAQ,CAACP,OAAO,KAAK,CAAC,IAAI;QACtD,EAAE,OAAM;YACJ,OAAO;QACX;IACJ;IAEQ,kBAAkBa,OAAoB,EAAwB;QAClE,MAAMC,UAAU,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAACC,CAAAA,SAAUA,OAAO,SAAS,CAACF;QAC3E,IAAI,CAACC,SACD,MAAM,IAAIE,MAAM,CAAC,8CAA8C,EAAEH,SAAS;QAG9E,OAAOC;IACX;AACJ;AAEO,MAAMG,sBAAsB,CAACtB,SACzB,IAAID,cAAcC"}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createRecordsValidation = exports.RecordsValidation = void 0;
|
|
7
|
-
var _utils = require("@webiny/utils");
|
|
8
|
-
var _event = require("./validation/event.js");
|
|
9
|
-
const validation = (0, _event.createEventValidation)();
|
|
1
|
+
import { createZodError } from "@webiny/utils";
|
|
2
|
+
import { createEventValidation } from "./validation/event.js";
|
|
3
|
+
const validation = createEventValidation();
|
|
10
4
|
class RecordsValidation {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
async validate(records) {
|
|
6
|
+
const result = await validation.safeParseAsync(records);
|
|
7
|
+
if (result.error) return {
|
|
8
|
+
error: createZodError(result.error)
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
records: result.data
|
|
12
|
+
};
|
|
17
13
|
}
|
|
18
|
-
return {
|
|
19
|
-
records: result.data
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return new RecordsValidation();
|
|
26
|
-
};
|
|
27
|
-
exports.createRecordsValidation = createRecordsValidation;
|
|
15
|
+
const createRecordsValidation = ()=>new RecordsValidation();
|
|
16
|
+
export { RecordsValidation, createRecordsValidation };
|
|
28
17
|
|
|
29
18
|
//# sourceMappingURL=RecordsValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/RecordsValidation.js","sources":["../../../src/resolver/app/RecordsValidation.ts"],"sourcesContent":["import type { SQSRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport type {\n IRecordsValidation,\n IRecordsValidationResult\n} from \"./abstractions/RecordsValidation.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createEventValidation } from \"~/resolver/app/validation/event.js\";\n\nconst validation = createEventValidation();\n\nexport class RecordsValidation implements IRecordsValidation {\n public async validate(records: SQSRecord[]): Promise<IRecordsValidationResult> {\n const result = await validation.safeParseAsync(records);\n if (result.error) {\n return {\n error: createZodError(result.error)\n };\n }\n return {\n records: result.data\n };\n }\n}\n\nexport const createRecordsValidation = (): IRecordsValidation => {\n return new RecordsValidation();\n};\n"],"names":["validation","createEventValidation","RecordsValidation","records","result","createZodError","createRecordsValidation"],"mappings":";;AAQA,MAAMA,aAAaC;AAEZ,MAAMC;IACT,MAAa,SAASC,OAAoB,EAAqC;QAC3E,MAAMC,SAAS,MAAMJ,WAAW,cAAc,CAACG;QAC/C,IAAIC,OAAO,KAAK,EACZ,OAAO;YACH,OAAOC,eAAeD,OAAO,KAAK;QACtC;QAEJ,OAAO;YACH,SAASA,OAAO,IAAI;QACxB;IACJ;AACJ;AAEO,MAAME,0BAA0B,IAC5B,IAAIJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IResolverApplication, IResolverApplicationResolveParams } from "./abstractions/ResolverApplication.js";
|
|
2
2
|
import type { IRecordHandler } from "./abstractions/RecordHandler.js";
|
|
3
|
-
import type { IDeployments } from "
|
|
3
|
+
import type { IDeployments } from "../../resolver/deployment/types.js";
|
|
4
4
|
export interface IResolverApplicationParams {
|
|
5
5
|
recordHandler: IRecordHandler;
|
|
6
6
|
deployments: IDeployments;
|
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.createResolverApp = exports.ResolverApplication = void 0;
|
|
7
|
-
var _RecordsValidation = require("./RecordsValidation.js");
|
|
8
|
-
var _utils = require("@webiny/utils");
|
|
9
|
-
var _Ingestor = require("./ingestor/Ingestor.js");
|
|
10
|
-
var _IngestorResult = require("./ingestor/IngestorResult.js");
|
|
1
|
+
import { createRecordsValidation } from "./RecordsValidation.js";
|
|
2
|
+
import { convertException } from "@webiny/utils";
|
|
3
|
+
import { createIngestor } from "./ingestor/Ingestor.js";
|
|
4
|
+
import { createIngestorResult } from "./ingestor/IngestorResult.js";
|
|
11
5
|
class ResolverApplication {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
async resolve(params) {
|
|
17
|
-
const validation = (0, _RecordsValidation.createRecordsValidation)();
|
|
18
|
-
const result = await validation.validate(params.records);
|
|
19
|
-
if (result.error) {
|
|
20
|
-
throw result.error;
|
|
6
|
+
constructor(params){
|
|
7
|
+
this.recordHandler = params.recordHandler;
|
|
8
|
+
this.deployments = params.deployments;
|
|
21
9
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
10
|
+
async resolve(params) {
|
|
11
|
+
const validation = createRecordsValidation();
|
|
12
|
+
const result = await validation.validate(params.records);
|
|
13
|
+
if (result.error) throw result.error;
|
|
14
|
+
const ingestor = createIngestor({
|
|
15
|
+
createIngestorResult: ()=>createIngestorResult(),
|
|
16
|
+
getSource: (name)=>this.deployments.get(name)
|
|
17
|
+
});
|
|
18
|
+
const data = await ingestor.ingest({
|
|
19
|
+
records: result.records
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
await this.recordHandler.handle({
|
|
23
|
+
data
|
|
24
|
+
});
|
|
25
|
+
} catch (ex) {
|
|
26
|
+
console.error(convertException(ex));
|
|
27
|
+
}
|
|
39
28
|
}
|
|
40
|
-
}
|
|
41
29
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return new ResolverApplication(params);
|
|
45
|
-
};
|
|
46
|
-
exports.createResolverApp = createResolverApp;
|
|
30
|
+
const createResolverApp = (params)=>new ResolverApplication(params);
|
|
31
|
+
export { ResolverApplication, createResolverApp };
|
|
47
32
|
|
|
48
33
|
//# sourceMappingURL=ResolverApplication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/ResolverApplication.js","sources":["../../../src/resolver/app/ResolverApplication.ts"],"sourcesContent":["import type {\n IResolverApplication,\n IResolverApplicationResolveParams\n} from \"./abstractions/ResolverApplication.js\";\nimport { createRecordsValidation } from \"./RecordsValidation.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IRecordHandler } from \"./abstractions/RecordHandler.js\";\nimport type { IDeployments } from \"~/resolver/deployment/types.js\";\nimport { createIngestor } from \"./ingestor/Ingestor.js\";\nimport { createIngestorResult } from \"~/resolver/app/ingestor/IngestorResult.js\";\n\nexport interface IResolverApplicationParams {\n recordHandler: IRecordHandler;\n deployments: IDeployments;\n}\n\nexport class ResolverApplication implements IResolverApplication {\n private readonly recordHandler: IRecordHandler;\n private readonly deployments: IDeployments;\n\n public constructor(params: IResolverApplicationParams) {\n this.recordHandler = params.recordHandler;\n this.deployments = params.deployments;\n }\n\n public async resolve(params: IResolverApplicationResolveParams): Promise<void> {\n const validation = createRecordsValidation();\n\n const result = await validation.validate(params.records);\n if (result.error) {\n throw result.error;\n }\n\n const ingestor = createIngestor({\n createIngestorResult: () => {\n return createIngestorResult();\n },\n getSource: name => {\n return this.deployments.get(name);\n }\n });\n\n const data = await ingestor.ingest({\n records: result.records\n });\n\n try {\n await this.recordHandler.handle({\n data\n });\n } catch (ex) {\n console.error(convertException(ex));\n }\n }\n}\n\nexport const createResolverApp = (params: IResolverApplicationParams): IResolverApplication => {\n return new ResolverApplication(params);\n};\n"],"names":["ResolverApplication","params","validation","createRecordsValidation","result","ingestor","createIngestor","createIngestorResult","name","data","ex","console","convertException","createResolverApp"],"mappings":";;;;AAgBO,MAAMA;IAIT,YAAmBC,MAAkC,CAAE;QACnD,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;QACzC,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;IACzC;IAEA,MAAa,QAAQA,MAAyC,EAAiB;QAC3E,MAAMC,aAAaC;QAEnB,MAAMC,SAAS,MAAMF,WAAW,QAAQ,CAACD,OAAO,OAAO;QACvD,IAAIG,OAAO,KAAK,EACZ,MAAMA,OAAO,KAAK;QAGtB,MAAMC,WAAWC,eAAe;YAC5B,sBAAsB,IACXC;YAEX,WAAWC,CAAAA,OACA,IAAI,CAAC,WAAW,CAAC,GAAG,CAACA;QAEpC;QAEA,MAAMC,OAAO,MAAMJ,SAAS,MAAM,CAAC;YAC/B,SAASD,OAAO,OAAO;QAC3B;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;gBAC5BK;YACJ;QACJ,EAAE,OAAOC,IAAI;YACTC,QAAQ,KAAK,CAACC,iBAAiBF;QACnC;IACJ;AACJ;AAEO,MAAMG,oBAAoB,CAACZ,SACvB,IAAID,oBAAoBC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SQSRecord } from "@webiny/aws-sdk/types";
|
|
2
|
-
import type { IResolverSQSRecord } from "
|
|
1
|
+
import type { SQSRecord } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import type { IResolverSQSRecord } from "../../../resolver/app/abstractions/ResolverRecord.js";
|
|
3
3
|
export interface IRecordsValidationValid {
|
|
4
4
|
records: IResolverSQSRecord[];
|
|
5
5
|
error?: never;
|
|
@@ -7,7 +7,7 @@ export interface IResolverRecordBodyItem {
|
|
|
7
7
|
SK: string;
|
|
8
8
|
command: ExtendedCommandType;
|
|
9
9
|
/**
|
|
10
|
-
* There will be multiple tables that will get populated through the system (regular table and
|
|
10
|
+
* There will be multiple tables that will get populated through the system (regular table and opensearch for start).
|
|
11
11
|
*/
|
|
12
12
|
tableName: string;
|
|
13
13
|
tableType: DynamoDBTableType;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IBundle, IBundleItem } from "
|
|
2
|
-
import type { IDeployment } from "
|
|
3
|
-
import type { ITable } from "../../../sync/types";
|
|
4
|
-
import type { CommandType } from "../../../types";
|
|
5
|
-
import { type ExtendedCommandType } from "../../../types";
|
|
6
|
-
import type { IIngestorResultItem } from "../ingestor/types";
|
|
1
|
+
import type { IBundle, IBundleItem } from "../../../resolver/app/bundler/types.js";
|
|
2
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
3
|
+
import type { ITable } from "../../../sync/types.js";
|
|
4
|
+
import type { CommandType } from "../../../types.js";
|
|
5
|
+
import { type ExtendedCommandType } from "../../../types.js";
|
|
6
|
+
import type { IIngestorResultItem } from "../ingestor/types.js";
|
|
7
7
|
export interface IBaseBundleParams {
|
|
8
8
|
command: ExtendedCommandType;
|
|
9
9
|
table: ITable;
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BaseBundle = void 0;
|
|
7
1
|
class BaseBundle {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
constructor(params){
|
|
3
|
+
this.items = [];
|
|
4
|
+
this.command = this.getCommand(params.command);
|
|
5
|
+
this.table = params.table;
|
|
6
|
+
this.source = params.source;
|
|
7
|
+
}
|
|
8
|
+
getCommand(command) {
|
|
9
|
+
return "delete" === command ? "delete" : "put";
|
|
10
|
+
}
|
|
11
|
+
add(item) {
|
|
12
|
+
this.items.push({
|
|
13
|
+
PK: item.PK,
|
|
14
|
+
SK: item.SK
|
|
15
|
+
});
|
|
16
|
+
}
|
|
23
17
|
}
|
|
24
|
-
|
|
18
|
+
export { BaseBundle };
|
|
25
19
|
|
|
26
20
|
//# sourceMappingURL=BaseBundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/bundler/BaseBundle.js","sources":["../../../../src/resolver/app/bundler/BaseBundle.ts"],"sourcesContent":["import type { IBundle, IBundleItem } from \"~/resolver/app/bundler/types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport type { CommandType } from \"~/types.js\";\nimport { type ExtendedCommandType } from \"~/types.js\";\nimport type { IIngestorResultItem } from \"../ingestor/types.js\";\n\nexport interface IBaseBundleParams {\n command: ExtendedCommandType;\n table: ITable;\n source: IDeployment;\n}\n\nexport abstract class BaseBundle implements IBundle {\n readonly items: IBundleItem[] = [];\n readonly command: CommandType;\n readonly table: ITable;\n readonly source: IDeployment;\n\n public abstract canAdd(item: IIngestorResultItem): boolean;\n\n public constructor(params: IBaseBundleParams) {\n this.command = this.getCommand(params.command);\n this.table = params.table;\n this.source = params.source;\n }\n\n protected getCommand(command: ExtendedCommandType): CommandType {\n return command === \"delete\" ? \"delete\" : \"put\";\n }\n\n public add(item: IIngestorResultItem): void {\n this.items.push({\n PK: item.PK,\n SK: item.SK\n });\n }\n}\n"],"names":["BaseBundle","params","command","item"],"mappings":"AAaO,MAAeA;IAQlB,YAAmBC,MAAyB,CAAE;aAPrC,KAAK,GAAkB,EAAE;QAQ9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAACA,OAAO,OAAO;QAC7C,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;IAEU,WAAWC,OAA4B,EAAe;QAC5D,OAAOA,AAAY,aAAZA,UAAuB,WAAW;IAC7C;IAEO,IAAIC,IAAyB,EAAQ;QACxC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACZ,IAAIA,KAAK,EAAE;YACX,IAAIA,KAAK,EAAE;QACf;IACJ;AACJ"}
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBundler = exports.Bundler = void 0;
|
|
7
1
|
class Bundler {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
item
|
|
19
|
-
});
|
|
2
|
+
constructor(params){
|
|
3
|
+
this.createBundles = params.createBundles;
|
|
4
|
+
}
|
|
5
|
+
bundle(params) {
|
|
6
|
+
const { items } = params;
|
|
7
|
+
const bundles = this.createBundles();
|
|
8
|
+
for (const item of items)bundles.add({
|
|
9
|
+
item
|
|
10
|
+
});
|
|
11
|
+
return bundles;
|
|
20
12
|
}
|
|
21
|
-
return bundles;
|
|
22
|
-
}
|
|
23
13
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return new Bundler(params);
|
|
27
|
-
};
|
|
28
|
-
exports.createBundler = createBundler;
|
|
14
|
+
const createBundler = (params)=>new Bundler(params);
|
|
15
|
+
export { Bundler, createBundler };
|
|
29
16
|
|
|
30
17
|
//# sourceMappingURL=Bundler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/bundler/Bundler.js","sources":["../../../../src/resolver/app/bundler/Bundler.ts"],"sourcesContent":["import type { IBundler, IBundlerBundleParams, IBundles } from \"~/resolver/app/bundler/types.js\";\n\nexport interface IBundlerParams {\n createBundles: () => IBundles;\n}\n\nexport class Bundler implements IBundler {\n private readonly createBundles: () => IBundles;\n\n public constructor(params: IBundlerParams) {\n this.createBundles = params.createBundles;\n }\n\n public bundle(params: IBundlerBundleParams): IBundles {\n const { items } = params;\n\n const bundles = this.createBundles();\n\n for (const item of items) {\n bundles.add({\n item\n });\n }\n\n return bundles;\n }\n}\n\nexport const createBundler = (params: IBundlerParams) => {\n return new Bundler(params);\n};\n"],"names":["Bundler","params","items","bundles","item","createBundler"],"mappings":"AAMO,MAAMA;IAGT,YAAmBC,MAAsB,CAAE;QACvC,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;IAC7C;IAEO,OAAOA,MAA4B,EAAY;QAClD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,MAAME,UAAU,IAAI,CAAC,aAAa;QAElC,KAAK,MAAMC,QAAQF,MACfC,QAAQ,GAAG,CAAC;YACRC;QACJ;QAGJ,OAAOD;IACX;AACJ;AAEO,MAAME,gBAAgB,CAACJ,SACnB,IAAID,QAAQC"}
|