@webiny/api-sync-system 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -108
- package/constants.js +2 -7
- package/constants.js.map +1 -1
- package/index.js +3 -40
- package/package.json +29 -26
- 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/createEventHandlerPlugin.d.ts +2 -1
- package/resolver/createEventHandlerPlugin.js +85 -121
- package/resolver/createEventHandlerPlugin.js.map +1 -1
- package/resolver/createResolverHandler.d.ts +1 -1
- package/resolver/createResolverHandler.js +60 -75
- package/resolver/createResolverHandler.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/FilterOutRecord.d.ts +2 -2
- package/sync/FilterOutRecord.js +8 -24
- package/sync/FilterOutRecord.js.map +1 -1
- 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/createSendDataToEventBridgeOnRequestEnd.js +34 -46
- package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
- package/sync/createSyncSystem.d.ts +1 -1
- package/sync/createSyncSystem.js +27 -36
- package/sync/createSyncSystem.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/requestPlugin.d.ts +1 -1
- package/sync/requestPlugin.js +39 -55
- package/sync/requestPlugin.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 +3 -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/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/createWorkerHandler.js +32 -45
- package/worker/createWorkerHandler.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/handler/eventHandler.js +18 -27
- package/worker/handler/eventHandler.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/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/handler/types.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/types.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IIngestor, IIngestorIngestParams, IIngestorResult } from "./types.js";
|
|
2
|
-
import type { IDeployment } from "
|
|
2
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
3
3
|
export interface IIngestorParams {
|
|
4
4
|
createIngestorResult: () => IIngestorResult;
|
|
5
5
|
getSource: (name: string) => IDeployment | null;
|
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createIngestor = exports.Ingestor = void 0;
|
|
7
1
|
class Ingestor {
|
|
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
|
-
}
|
|
2
|
+
constructor(params){
|
|
3
|
+
this.createIngestorResult = params.createIngestorResult;
|
|
4
|
+
this.getSource = params.getSource;
|
|
5
|
+
}
|
|
6
|
+
async ingest(params) {
|
|
7
|
+
const { records } = params;
|
|
8
|
+
const result = this.createIngestorResult();
|
|
9
|
+
for (const record of records){
|
|
10
|
+
const detail = record.body.detail;
|
|
11
|
+
const source = this.getSource(detail.source.name);
|
|
12
|
+
if (!source) {
|
|
13
|
+
console.error(`Could not find deployment for SQS Record source: ${detail.source.name}. More info in next log line.`);
|
|
14
|
+
console.log(JSON.stringify({
|
|
15
|
+
source: detail.source,
|
|
16
|
+
items: detail.items
|
|
17
|
+
}));
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
for (const item of detail.items)result.add({
|
|
21
|
+
item,
|
|
22
|
+
source
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
34
26
|
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
27
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return new Ingestor(params);
|
|
41
|
-
};
|
|
42
|
-
exports.createIngestor = createIngestor;
|
|
28
|
+
const createIngestor = (params)=>new Ingestor(params);
|
|
29
|
+
export { Ingestor, createIngestor };
|
|
43
30
|
|
|
44
31
|
//# sourceMappingURL=Ingestor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/ingestor/Ingestor.js","sources":["../../../../src/resolver/app/ingestor/Ingestor.ts"],"sourcesContent":["import type { IIngestor, IIngestorIngestParams, IIngestorResult } from \"./types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\n\nexport interface IIngestorParams {\n createIngestorResult: () => IIngestorResult;\n getSource: (name: string) => IDeployment | null;\n}\n\nexport class Ingestor implements IIngestor {\n private readonly createIngestorResult: () => IIngestorResult;\n private readonly getSource: (name: string) => IDeployment | null;\n\n public constructor(params: IIngestorParams) {\n this.createIngestorResult = params.createIngestorResult;\n this.getSource = params.getSource;\n }\n\n public async ingest(params: IIngestorIngestParams): Promise<IIngestorResult> {\n const { records } = params;\n\n const result = this.createIngestorResult();\n\n for (const record of records) {\n const detail = record.body.detail;\n const source = this.getSource(detail.source.name);\n if (!source) {\n console.error(\n `Could not find deployment for SQS Record source: ${detail.source.name}. More info in next log line.`\n );\n console.log(\n JSON.stringify({\n source: detail.source,\n items: detail.items\n })\n );\n continue;\n }\n\n for (const item of detail.items) {\n result.add({\n item,\n source\n });\n }\n }\n\n return result;\n }\n}\n\nexport const createIngestor = (params: IIngestorParams): IIngestor => {\n return new Ingestor(params);\n};\n"],"names":["Ingestor","params","records","result","record","detail","source","console","JSON","item","createIngestor"],"mappings":"AAQO,MAAMA;IAIT,YAAmBC,MAAuB,CAAE;QACxC,IAAI,CAAC,oBAAoB,GAAGA,OAAO,oBAAoB;QACvD,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;IACrC;IAEA,MAAa,OAAOA,MAA6B,EAA4B;QACzE,MAAM,EAAEC,OAAO,EAAE,GAAGD;QAEpB,MAAME,SAAS,IAAI,CAAC,oBAAoB;QAExC,KAAK,MAAMC,UAAUF,QAAS;YAC1B,MAAMG,SAASD,OAAO,IAAI,CAAC,MAAM;YACjC,MAAME,SAAS,IAAI,CAAC,SAAS,CAACD,OAAO,MAAM,CAAC,IAAI;YAChD,IAAI,CAACC,QAAQ;gBACTC,QAAQ,KAAK,CACT,CAAC,iDAAiD,EAAEF,OAAO,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC;gBAEzGE,QAAQ,GAAG,CACPC,KAAK,SAAS,CAAC;oBACX,QAAQH,OAAO,MAAM;oBACrB,OAAOA,OAAO,KAAK;gBACvB;gBAEJ;YACJ;YAEA,KAAK,MAAMI,QAAQJ,OAAO,KAAK,CAC3BF,OAAO,GAAG,CAAC;gBACPM;gBACAH;YACJ;QAER;QAEA,OAAOH;IACX;AACJ;AAEO,MAAMO,iBAAiB,CAACT,SACpB,IAAID,SAASC"}
|
|
@@ -1,45 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createIngestorResult = exports.IngestorResult = void 0;
|
|
7
1
|
class IngestorResult {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
add(params) {
|
|
3
|
+
const { item, source } = params;
|
|
4
|
+
let table;
|
|
5
|
+
try {
|
|
6
|
+
table = source.getTable(item.tableType);
|
|
7
|
+
} catch {
|
|
8
|
+
console.error(`Could not find table for SQS Record source: ${item.tableName} / ${item.tableType}. More info in next log line.`);
|
|
9
|
+
console.log(JSON.stringify(item));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const command = "delete" === item.command ? "delete" : "put";
|
|
13
|
+
const key = `PK:${item.PK}#SK:${item.SK}#cmd:${command}#source:${source.name}`;
|
|
14
|
+
if (this.items.has(key)) return;
|
|
15
|
+
this.items.set(key, {
|
|
16
|
+
PK: item.PK,
|
|
17
|
+
SK: item.SK,
|
|
18
|
+
source,
|
|
19
|
+
command,
|
|
20
|
+
table
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getItems() {
|
|
24
|
+
return Array.from(this.items.values());
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (this.items.has(key)) {
|
|
25
|
-
return;
|
|
26
|
+
constructor(){
|
|
27
|
+
this.items = new Map();
|
|
26
28
|
}
|
|
27
|
-
this.items.set(key, {
|
|
28
|
-
PK: item.PK,
|
|
29
|
-
SK: item.SK,
|
|
30
|
-
source,
|
|
31
|
-
command,
|
|
32
|
-
table
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
getItems() {
|
|
36
|
-
return Array.from(this.items.values());
|
|
37
|
-
}
|
|
38
29
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return new IngestorResult();
|
|
42
|
-
};
|
|
43
|
-
exports.createIngestorResult = createIngestorResult;
|
|
30
|
+
const createIngestorResult = ()=>new IngestorResult();
|
|
31
|
+
export { IngestorResult, createIngestorResult };
|
|
44
32
|
|
|
45
33
|
//# sourceMappingURL=IngestorResult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/ingestor/IngestorResult.js","sources":["../../../../src/resolver/app/ingestor/IngestorResult.ts"],"sourcesContent":["import type { IIngestorResult, IIngestorResultAddParams, IIngestorResultItem } from \"./types.js\";\nimport type { ITable } from \"~/sync/types.js\";\n\nexport class IngestorResult implements IIngestorResult {\n private readonly items: Map<string, IIngestorResultItem> = new Map();\n\n public add(params: IIngestorResultAddParams): void {\n const { item, source } = params;\n let table: ITable;\n try {\n table = source.getTable(item.tableType);\n } catch {\n console.error(\n `Could not find table for SQS Record source: ${item.tableName} / ${item.tableType}. More info in next log line.`\n );\n console.log(JSON.stringify(item));\n return;\n }\n\n const command = item.command === \"delete\" ? \"delete\" : \"put\";\n\n const key = `PK:${item.PK}#SK:${item.SK}#cmd:${command}#source:${source.name}`;\n\n if (this.items.has(key)) {\n return;\n }\n\n this.items.set(key, {\n PK: item.PK,\n SK: item.SK,\n source,\n command,\n table\n });\n }\n\n public getItems(): IIngestorResultItem[] {\n return Array.from(this.items.values());\n }\n}\n\nexport const createIngestorResult = (): IIngestorResult => {\n return new IngestorResult();\n};\n"],"names":["IngestorResult","params","item","source","table","console","JSON","command","key","Array","Map","createIngestorResult"],"mappings":"AAGO,MAAMA;IAGF,IAAIC,MAAgC,EAAQ;QAC/C,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGF;QACzB,IAAIG;QACJ,IAAI;YACAA,QAAQD,OAAO,QAAQ,CAACD,KAAK,SAAS;QAC1C,EAAE,OAAM;YACJG,QAAQ,KAAK,CACT,CAAC,4CAA4C,EAAEH,KAAK,SAAS,CAAC,GAAG,EAAEA,KAAK,SAAS,CAAC,6BAA6B,CAAC;YAEpHG,QAAQ,GAAG,CAACC,KAAK,SAAS,CAACJ;YAC3B;QACJ;QAEA,MAAMK,UAAUL,AAAiB,aAAjBA,KAAK,OAAO,GAAgB,WAAW;QAEvD,MAAMM,MAAM,CAAC,GAAG,EAAEN,KAAK,EAAE,CAAC,IAAI,EAAEA,KAAK,EAAE,CAAC,KAAK,EAAEK,QAAQ,QAAQ,EAAEJ,OAAO,IAAI,EAAE;QAE9E,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAACK,MACf;QAGJ,IAAI,CAAC,KAAK,CAAC,GAAG,CAACA,KAAK;YAChB,IAAIN,KAAK,EAAE;YACX,IAAIA,KAAK,EAAE;YACXC;YACAI;YACAH;QACJ;IACJ;IAEO,WAAkC;QACrC,OAAOK,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM;IACvC;;aAlCiB,KAAK,GAAqC,IAAIC;;AAmCnE;AAEO,MAAMC,uBAAuB,IACzB,IAAIX"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CommandType } from "../../../types.js";
|
|
2
|
-
import type { IResolverSQSRecord } from "
|
|
2
|
+
import type { IResolverSQSRecord } from "../../../resolver/app/abstractions/ResolverRecord.js";
|
|
3
3
|
import type { IDetailItem } from "../../../sync/handler/types.js";
|
|
4
4
|
import type { ITable } from "../../../sync/types.js";
|
|
5
|
-
import type { IDeployment } from "
|
|
5
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
6
6
|
export interface IIngestorIngestParams {
|
|
7
7
|
records: IResolverSQSRecord[];
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IStoreItem, IStorer, IStorerExecParams } from "./types";
|
|
2
|
-
import type { IDeployment } from "
|
|
1
|
+
import type { IStoreItem, IStorer, IStorerExecParams } from "./types.js";
|
|
2
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
3
3
|
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
4
|
-
import type { CommandType } from "../../../types";
|
|
4
|
+
import type { CommandType } from "../../../types.js";
|
|
5
5
|
import type { ITable } from "../../../sync/types.js";
|
|
6
6
|
export interface IStorerParamsCreateDocumentClientCallable {
|
|
7
7
|
(deployment: Pick<IDeployment, "region">): Pick<DynamoDBDocument, "send">;
|
|
@@ -1,103 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createStorer = exports.Storer = void 0;
|
|
7
|
-
var _index = require("@webiny/aws-sdk/client-dynamodb/index.js");
|
|
8
|
-
var _Retry = require("../utils/Retry");
|
|
9
|
-
var _utils = require("@webiny/utils");
|
|
1
|
+
import { DeleteCommand, PutCommand } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import { createRetry } from "../utils/Retry.js";
|
|
3
|
+
import { convertException } from "@webiny/utils";
|
|
10
4
|
class Storer {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
async store(params) {
|
|
19
|
-
const {
|
|
20
|
-
deployment,
|
|
21
|
-
bundle,
|
|
22
|
-
table,
|
|
23
|
-
command,
|
|
24
|
-
items
|
|
25
|
-
} = params;
|
|
26
|
-
if (items.length === 0) {
|
|
27
|
-
return;
|
|
5
|
+
constructor(params){
|
|
6
|
+
this.maxRetries = params.maxRetries || 10;
|
|
7
|
+
this.retryDelay = params.retryDelay || 1000;
|
|
8
|
+
this.createDocumentClient = params.createDocumentClient;
|
|
9
|
+
this.afterEach = params.afterEach;
|
|
10
|
+
this.onError = params.onError;
|
|
28
11
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
12
|
+
async store(params) {
|
|
13
|
+
const { deployment, bundle, table, command, items } = params;
|
|
14
|
+
if (0 === items.length) return;
|
|
15
|
+
const client = this.createDocumentClient({
|
|
16
|
+
region: deployment.region
|
|
17
|
+
});
|
|
18
|
+
const retry = createRetry({
|
|
19
|
+
maxRetries: this.maxRetries,
|
|
20
|
+
retryDelay: this.retryDelay
|
|
21
|
+
});
|
|
22
|
+
for (const item of items){
|
|
23
|
+
const result = await retry.retry(async ()=>{
|
|
24
|
+
switch(command){
|
|
25
|
+
case "delete":
|
|
26
|
+
return await client.send(new DeleteCommand({
|
|
27
|
+
TableName: table.name,
|
|
28
|
+
Key: {
|
|
29
|
+
PK: item.PK,
|
|
30
|
+
SK: item.SK
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
case "put":
|
|
34
|
+
return await client.send(new PutCommand({
|
|
35
|
+
TableName: table.name,
|
|
36
|
+
Item: item
|
|
37
|
+
}));
|
|
38
|
+
default:
|
|
39
|
+
console.error(`Unsupported command type: ${command}`);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
onFail: async (error)=>{
|
|
44
|
+
console.error("Error executing batch write command.");
|
|
45
|
+
console.log(convertException(error));
|
|
46
|
+
if (!this.onError) return;
|
|
47
|
+
try {
|
|
48
|
+
await this.onError({
|
|
49
|
+
item,
|
|
50
|
+
command,
|
|
51
|
+
table,
|
|
52
|
+
error
|
|
53
|
+
});
|
|
54
|
+
} catch (ex) {
|
|
55
|
+
console.error(`Error in onError callback for command: ${command}`);
|
|
56
|
+
console.log({
|
|
57
|
+
original: convertException(error),
|
|
58
|
+
error: convertException(ex)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
75
62
|
});
|
|
76
|
-
|
|
63
|
+
if (result && this.afterEach) try {
|
|
64
|
+
await this.afterEach({
|
|
65
|
+
table,
|
|
66
|
+
command,
|
|
67
|
+
item,
|
|
68
|
+
source: bundle.source,
|
|
69
|
+
target: deployment
|
|
70
|
+
});
|
|
71
|
+
} catch (ex) {
|
|
72
|
+
console.error(`Error in afterEach callback for command: ${command}`);
|
|
73
|
+
console.log(convertException(ex));
|
|
74
|
+
}
|
|
77
75
|
}
|
|
78
|
-
});
|
|
79
|
-
if (!result || !this.afterEach) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
await this.afterEach({
|
|
84
|
-
table,
|
|
85
|
-
command,
|
|
86
|
-
item,
|
|
87
|
-
source: bundle.source,
|
|
88
|
-
target: deployment
|
|
89
|
-
});
|
|
90
|
-
} catch (ex) {
|
|
91
|
-
console.error(`Error in afterEach callback for command: ${command}`);
|
|
92
|
-
console.log((0, _utils.convertException)(ex));
|
|
93
|
-
}
|
|
94
76
|
}
|
|
95
|
-
}
|
|
96
77
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return new Storer(params);
|
|
100
|
-
};
|
|
101
|
-
exports.createStorer = createStorer;
|
|
78
|
+
const createStorer = (params)=>new Storer(params);
|
|
79
|
+
export { Storer, createStorer };
|
|
102
80
|
|
|
103
81
|
//# sourceMappingURL=Storer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"resolver/app/storer/Storer.js","sources":["../../../../src/resolver/app/storer/Storer.ts"],"sourcesContent":["import type { IStoreItem, IStorer, IStorerExecParams } from \"./types.js\";\nimport type { IDeployment } from \"~/resolver/deployment/types.js\";\nimport type {\n DeleteCommandOutput,\n DynamoDBDocument,\n PutCommandOutput\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { DeleteCommand, PutCommand } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { CommandType } from \"~/types.js\";\nimport type { ITable } from \"~/sync/types.js\";\nimport { createRetry } from \"../utils/Retry.js\";\nimport { convertException } from \"@webiny/utils\";\n\nexport interface IStorerParamsCreateDocumentClientCallable {\n (deployment: Pick<IDeployment, \"region\">): Pick<DynamoDBDocument, \"send\">;\n}\n\nexport interface IStorerOnErrorParams {\n command: CommandType;\n item: IStoreItem;\n table: ITable;\n error: Error;\n}\n\nexport interface IStorerOnErrorCb {\n (params: IStorerOnErrorParams): Promise<void>;\n}\n\nexport interface ISingleStorerAfterEachParams {\n command: CommandType;\n target: IDeployment;\n source: IDeployment;\n table: ITable;\n item: IStoreItem;\n}\n\nexport interface IStorerAfterEachCb {\n (params: ISingleStorerAfterEachParams): Promise<void>;\n}\n\nexport interface IStorerParams {\n maxRetries?: number;\n retryDelay?: number;\n createDocumentClient: IStorerParamsCreateDocumentClientCallable;\n onError?: IStorerOnErrorCb;\n afterEach?: IStorerAfterEachCb;\n}\n\nexport class Storer implements IStorer {\n private readonly maxRetries: number;\n private readonly retryDelay: number;\n private readonly createDocumentClient: IStorerParamsCreateDocumentClientCallable;\n private readonly afterEach?: IStorerAfterEachCb;\n private readonly onError?: IStorerOnErrorCb;\n\n public constructor(params: IStorerParams) {\n this.maxRetries = params.maxRetries || 10;\n this.retryDelay = params.retryDelay || 1000;\n this.createDocumentClient = params.createDocumentClient;\n this.afterEach = params.afterEach;\n this.onError = params.onError;\n }\n\n public async store(params: IStorerExecParams): Promise<void> {\n const { deployment, bundle, table, command, items } = params;\n if (items.length === 0) {\n return;\n }\n const client = this.createDocumentClient({\n region: deployment.region\n });\n\n const retry = createRetry({\n maxRetries: this.maxRetries,\n retryDelay: this.retryDelay\n });\n\n for (const item of items) {\n const result = await retry.retry(\n async (): Promise<DeleteCommandOutput | PutCommandOutput | null> => {\n switch (command) {\n case \"delete\":\n return await client.send(\n new DeleteCommand({\n TableName: table.name,\n Key: {\n PK: item.PK,\n SK: item.SK\n }\n })\n );\n case \"put\":\n return await client.send(\n new PutCommand({\n TableName: table.name,\n Item: item\n })\n );\n\n default:\n console.error(`Unsupported command type: ${command}`);\n return null;\n }\n },\n {\n onFail: async error => {\n console.error(\"Error executing batch write command.\");\n console.log(convertException(error));\n if (!this.onError) {\n return;\n }\n try {\n await this.onError({\n item,\n command,\n table,\n error\n });\n } catch (ex) {\n console.error(`Error in onError callback for command: ${command}`);\n console.log({\n original: convertException(error),\n error: convertException(ex)\n });\n }\n }\n }\n );\n if (!result || !this.afterEach) {\n continue;\n }\n try {\n await this.afterEach({\n table,\n command,\n item,\n source: bundle.source,\n target: deployment\n });\n } catch (ex) {\n console.error(`Error in afterEach callback for command: ${command}`);\n console.log(convertException(ex));\n }\n }\n }\n}\n\nexport const createStorer = (params: IStorerParams): IStorer => {\n return new Storer(params);\n};\n"],"names":["Storer","params","deployment","bundle","table","command","items","client","retry","createRetry","item","result","DeleteCommand","PutCommand","console","error","convertException","ex","createStorer"],"mappings":";;;AAgDO,MAAMA;IAOT,YAAmBC,MAAqB,CAAE;QACtC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU,IAAI;QACvC,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU,IAAI;QACvC,IAAI,CAAC,oBAAoB,GAAGA,OAAO,oBAAoB;QACvD,IAAI,CAAC,SAAS,GAAGA,OAAO,SAAS;QACjC,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;IACjC;IAEA,MAAa,MAAMA,MAAyB,EAAiB;QACzD,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGL;QACtD,IAAIK,AAAiB,MAAjBA,MAAM,MAAM,EACZ;QAEJ,MAAMC,SAAS,IAAI,CAAC,oBAAoB,CAAC;YACrC,QAAQL,WAAW,MAAM;QAC7B;QAEA,MAAMM,QAAQC,YAAY;YACtB,YAAY,IAAI,CAAC,UAAU;YAC3B,YAAY,IAAI,CAAC,UAAU;QAC/B;QAEA,KAAK,MAAMC,QAAQJ,MAAO;YACtB,MAAMK,SAAS,MAAMH,MAAM,KAAK,CAC5B;gBACI,OAAQH;oBACJ,KAAK;wBACD,OAAO,MAAME,OAAO,IAAI,CACpB,IAAIK,cAAc;4BACd,WAAWR,MAAM,IAAI;4BACrB,KAAK;gCACD,IAAIM,KAAK,EAAE;gCACX,IAAIA,KAAK,EAAE;4BACf;wBACJ;oBAER,KAAK;wBACD,OAAO,MAAMH,OAAO,IAAI,CACpB,IAAIM,WAAW;4BACX,WAAWT,MAAM,IAAI;4BACrB,MAAMM;wBACV;oBAGR;wBACII,QAAQ,KAAK,CAAC,CAAC,0BAA0B,EAAET,SAAS;wBACpD,OAAO;gBACf;YACJ,GACA;gBACI,QAAQ,OAAMU;oBACVD,QAAQ,KAAK,CAAC;oBACdA,QAAQ,GAAG,CAACE,iBAAiBD;oBAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,EACb;oBAEJ,IAAI;wBACA,MAAM,IAAI,CAAC,OAAO,CAAC;4BACfL;4BACAL;4BACAD;4BACAW;wBACJ;oBACJ,EAAE,OAAOE,IAAI;wBACTH,QAAQ,KAAK,CAAC,CAAC,uCAAuC,EAAET,SAAS;wBACjES,QAAQ,GAAG,CAAC;4BACR,UAAUE,iBAAiBD;4BAC3B,OAAOC,iBAAiBC;wBAC5B;oBACJ;gBACJ;YACJ;YAEJ,IAAI,AAACN,UAAW,IAAI,CAAC,SAAS,EAG9B,IAAI;gBACA,MAAM,IAAI,CAAC,SAAS,CAAC;oBACjBP;oBACAC;oBACAK;oBACA,QAAQP,OAAO,MAAM;oBACrB,QAAQD;gBACZ;YACJ,EAAE,OAAOe,IAAI;gBACTH,QAAQ,KAAK,CAAC,CAAC,yCAAyC,EAAET,SAAS;gBACnES,QAAQ,GAAG,CAACE,iBAAiBC;YACjC;QACJ;IACJ;AACJ;AAEO,MAAMC,eAAe,CAACjB,SAClB,IAAID,OAAOC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IDeployment } from "
|
|
1
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
2
2
|
import type { ITable } from "../../../sync/types.js";
|
|
3
3
|
import type { CommandType } from "../../../types.js";
|
|
4
4
|
import type { GenericRecord } from "@webiny/api/types.js";
|
|
5
|
-
import type { IBundle } from "../bundler/types";
|
|
5
|
+
import type { IBundle } from "../bundler/types.js";
|
|
6
6
|
export type StoreItemPossibleValues = string | number | boolean | undefined | null | GenericRecord | StoreItemPossibleValues[];
|
|
7
7
|
export interface IStoreItem {
|
|
8
8
|
PK: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ITable } from "../../../sync/types";
|
|
2
|
-
import type { IDeployment } from "
|
|
3
|
-
import type { PluginsContainer } from "@webiny/plugins/types";
|
|
4
|
-
import type { IStoreItem } from "../storer/types";
|
|
1
|
+
import type { ITable } from "../../../sync/types.js";
|
|
2
|
+
import type { IDeployment } from "../../../resolver/deployment/types.js";
|
|
3
|
+
import type { PluginsContainer } from "@webiny/plugins/types.js";
|
|
4
|
+
import type { IStoreItem } from "../storer/types.js";
|
|
5
5
|
export interface IMiddlewareParams {
|
|
6
6
|
readonly plugins: PluginsContainer;
|
|
7
7
|
readonly record: IStoreItem;
|
|
@@ -1,70 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TransformHandler = void 0;
|
|
7
|
-
var _TransformRecordPlugin = require("../../plugins/TransformRecordPlugin.js");
|
|
8
|
-
var _middleware = require("./middleware.js");
|
|
1
|
+
import { TransformRecordPlugin } from "../../plugins/TransformRecordPlugin.js";
|
|
2
|
+
import { middleware } from "./middleware.js";
|
|
9
3
|
class TransformHandler {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
async transform(params) {
|
|
15
|
-
const {
|
|
16
|
-
sourceTable,
|
|
17
|
-
sourceDeployment,
|
|
18
|
-
targetDeployment,
|
|
19
|
-
targetTable,
|
|
20
|
-
items
|
|
21
|
-
} = params;
|
|
22
|
-
if (this.plugins.length === 0) {
|
|
23
|
-
process.env.DEBUG === "true" && console.log("There are no transform plugins registered in the system.");
|
|
24
|
-
return {
|
|
25
|
-
items
|
|
26
|
-
};
|
|
4
|
+
constructor(params){
|
|
5
|
+
this.pluginsContainer = params.plugins;
|
|
6
|
+
this.plugins = params.plugins.byType(TransformRecordPlugin.type);
|
|
27
7
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
8
|
+
async transform(params) {
|
|
9
|
+
const { sourceTable, sourceDeployment, targetDeployment, targetTable, items } = params;
|
|
10
|
+
if (0 === this.plugins.length) {
|
|
11
|
+
"true" === process.env.DEBUG && console.log("There are no transform plugins registered in the system.");
|
|
12
|
+
return {
|
|
13
|
+
items
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const plugins = this.plugins.filter((plugin)=>{
|
|
17
|
+
if (false === plugin.isForTableType(sourceTable.type)) return false;
|
|
18
|
+
return plugin.canTransform({
|
|
19
|
+
from: sourceDeployment,
|
|
20
|
+
to: targetDeployment
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
if (0 === plugins.length) {
|
|
24
|
+
"true" === process.env.DEBUG && console.log("There are no transform plugins registered for the given deployment versions or sourceTable type.", {
|
|
25
|
+
sourceVersion: sourceDeployment.version.format(),
|
|
26
|
+
targetVersion: targetDeployment.version.format(),
|
|
27
|
+
sourceTable
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
items
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const runner = middleware(plugins.map((plugin)=>async (params, next)=>await plugin.transform(params, next)));
|
|
34
|
+
const results = await Promise.all(items.map(async (input)=>{
|
|
35
|
+
const record = Object.freeze(input);
|
|
36
|
+
return await runner({
|
|
37
|
+
plugins: this.pluginsContainer,
|
|
38
|
+
sourceTable,
|
|
39
|
+
sourceDeployment,
|
|
40
|
+
targetDeployment,
|
|
41
|
+
targetTable,
|
|
42
|
+
record
|
|
43
|
+
}, record);
|
|
44
|
+
}));
|
|
45
|
+
return {
|
|
46
|
+
items: results.filter((item)=>!!item)
|
|
47
|
+
};
|
|
46
48
|
}
|
|
47
|
-
const runner = (0, _middleware.middleware)(plugins.map(plugin => {
|
|
48
|
-
return async (params, next) => {
|
|
49
|
-
return await plugin.transform(params, next);
|
|
50
|
-
};
|
|
51
|
-
}));
|
|
52
|
-
const results = await Promise.all(items.map(async input => {
|
|
53
|
-
const record = Object.freeze(input);
|
|
54
|
-
return await runner({
|
|
55
|
-
plugins: this.pluginsContainer,
|
|
56
|
-
sourceTable,
|
|
57
|
-
sourceDeployment,
|
|
58
|
-
targetDeployment,
|
|
59
|
-
targetTable,
|
|
60
|
-
record
|
|
61
|
-
}, record);
|
|
62
|
-
}));
|
|
63
|
-
return {
|
|
64
|
-
items: results.filter(item => !!item)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
49
|
}
|
|
68
|
-
|
|
50
|
+
export { TransformHandler };
|
|
69
51
|
|
|
70
52
|
//# sourceMappingURL=TransformHandler.js.map
|