@webiny/api-sync-system 6.0.0-alpha.5 → 6.0.0-rc.0
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 +1 -7
- package/constants.js.map +1 -1
- package/index.js +3 -38
- package/index.js.map +1 -1
- package/package.json +20 -23
- package/resolver/app/RecordHandler.d.ts +6 -6
- package/resolver/app/RecordHandler.js +7 -15
- package/resolver/app/RecordHandler.js.map +1 -1
- package/resolver/app/RecordsValidation.js +6 -14
- package/resolver/app/RecordsValidation.js.map +1 -1
- package/resolver/app/ResolverApplication.d.ts +1 -1
- package/resolver/app/ResolverApplication.js +10 -18
- package/resolver/app/ResolverApplication.js.map +1 -1
- package/resolver/app/abstractions/RecordHandler.d.ts +1 -1
- package/resolver/app/abstractions/RecordHandler.js +1 -5
- package/resolver/app/abstractions/RecordsValidation.d.ts +2 -2
- package/resolver/app/abstractions/RecordsValidation.js +1 -5
- package/resolver/app/abstractions/RecordsValidation.js.map +1 -1
- package/resolver/app/abstractions/ResolverApplication.js +1 -5
- package/resolver/app/abstractions/ResolverRecord.d.ts +1 -1
- package/resolver/app/abstractions/ResolverRecord.js +1 -5
- package/resolver/app/abstractions/ResolverRecord.js.map +1 -1
- package/resolver/app/bundler/BaseBundle.d.ts +6 -6
- package/resolver/app/bundler/BaseBundle.js +1 -8
- package/resolver/app/bundler/BaseBundle.js.map +1 -1
- package/resolver/app/bundler/Bundler.d.ts +1 -1
- package/resolver/app/bundler/Bundler.js +2 -10
- package/resolver/app/bundler/Bundler.js.map +1 -1
- package/resolver/app/bundler/Bundles.d.ts +2 -2
- package/resolver/app/bundler/Bundles.js +2 -10
- package/resolver/app/bundler/Bundles.js.map +1 -1
- package/resolver/app/bundler/CommandBundle.d.ts +1 -1
- package/resolver/app/bundler/CommandBundle.js +3 -11
- package/resolver/app/bundler/CommandBundle.js.map +1 -1
- package/resolver/app/bundler/TableBundle.d.ts +1 -1
- package/resolver/app/bundler/TableBundle.js +3 -11
- package/resolver/app/bundler/TableBundle.js.map +1 -1
- package/resolver/app/bundler/types.d.ts +2 -2
- package/resolver/app/bundler/types.js +1 -5
- package/resolver/app/commandHandler/DeleteCommandHandler.d.ts +3 -3
- package/resolver/app/commandHandler/DeleteCommandHandler.js +1 -8
- package/resolver/app/commandHandler/DeleteCommandHandler.js.map +1 -1
- package/resolver/app/commandHandler/PutCommandHandler.d.ts +4 -4
- package/resolver/app/commandHandler/PutCommandHandler.js +1 -8
- package/resolver/app/commandHandler/PutCommandHandler.js.map +1 -1
- package/resolver/app/commandHandler/delete.d.ts +1 -1
- package/resolver/app/commandHandler/delete.js +6 -13
- package/resolver/app/commandHandler/delete.js.map +1 -1
- package/resolver/app/commandHandler/put.d.ts +1 -1
- package/resolver/app/commandHandler/put.js +6 -13
- package/resolver/app/commandHandler/put.js.map +1 -1
- package/resolver/app/data/SourceDataContainer.d.ts +3 -3
- package/resolver/app/data/SourceDataContainer.js +1 -8
- package/resolver/app/data/SourceDataContainer.js.map +1 -1
- package/resolver/app/data/types.d.ts +2 -2
- package/resolver/app/data/types.js +1 -5
- package/resolver/app/fetcher/Fetcher.d.ts +3 -3
- package/resolver/app/fetcher/Fetcher.js +13 -22
- package/resolver/app/fetcher/Fetcher.js.map +1 -1
- package/resolver/app/fetcher/types.d.ts +2 -2
- package/resolver/app/fetcher/types.js +1 -5
- package/resolver/app/ingestor/Ingestor.d.ts +1 -1
- package/resolver/app/ingestor/Ingestor.js +2 -10
- package/resolver/app/ingestor/Ingestor.js.map +1 -1
- package/resolver/app/ingestor/IngestorResult.js +3 -11
- package/resolver/app/ingestor/IngestorResult.js.map +1 -1
- package/resolver/app/ingestor/types.d.ts +2 -2
- package/resolver/app/ingestor/types.js +1 -5
- package/resolver/app/storer/Storer.d.ts +3 -3
- package/resolver/app/storer/Storer.js +12 -20
- package/resolver/app/storer/Storer.js.map +1 -1
- package/resolver/app/storer/types.d.ts +2 -2
- package/resolver/app/storer/types.js +1 -5
- package/resolver/app/storer/types.js.map +1 -1
- package/resolver/app/transform/TransformHandler.d.ts +4 -4
- package/resolver/app/transform/TransformHandler.js +5 -12
- package/resolver/app/transform/TransformHandler.js.map +1 -1
- package/resolver/app/transform/middleware.d.ts +1 -1
- package/resolver/app/transform/middleware.js +1 -7
- package/resolver/app/transform/middleware.js.map +1 -1
- package/resolver/app/utils/Retry.js +4 -12
- package/resolver/app/utils/Retry.js.map +1 -1
- package/resolver/app/utils/sleep.js +1 -8
- package/resolver/app/utils/sleep.js.map +1 -1
- package/resolver/app/validation/body.d.ts +6 -6
- package/resolver/app/validation/body.js +22 -30
- package/resolver/app/validation/body.js.map +1 -1
- package/resolver/app/validation/createJsonTransform.js +6 -14
- package/resolver/app/validation/createJsonTransform.js.map +1 -1
- package/resolver/app/validation/detail.d.ts +6 -6
- package/resolver/app/validation/detail.js +16 -24
- package/resolver/app/validation/detail.js.map +1 -1
- package/resolver/app/validation/event.d.ts +6 -6
- package/resolver/app/validation/event.js +19 -27
- package/resolver/app/validation/event.js.map +1 -1
- package/resolver/app/validation/numericString.js +5 -13
- package/resolver/app/validation/numericString.js.map +1 -1
- package/resolver/app/validation/system.js +8 -16
- package/resolver/app/validation/system.js.map +1 -1
- package/resolver/createEventHandlerPlugin.d.ts +2 -1
- package/resolver/createEventHandlerPlugin.js +35 -42
- package/resolver/createEventHandlerPlugin.js.map +1 -1
- package/resolver/createResolverHandler.d.ts +1 -1
- package/resolver/createResolverHandler.js +24 -31
- package/resolver/createResolverHandler.js.map +1 -1
- package/resolver/deployment/Deployment.d.ts +2 -3
- package/resolver/deployment/Deployment.js +6 -14
- package/resolver/deployment/Deployment.js.map +1 -1
- package/resolver/deployment/Deployments.js +2 -10
- package/resolver/deployment/Deployments.js.map +1 -1
- package/resolver/deployment/DeploymentsFetcher.js +33 -42
- package/resolver/deployment/DeploymentsFetcher.js.map +1 -1
- package/resolver/deployment/types.d.ts +4 -4
- package/resolver/deployment/types.js +1 -5
- package/resolver/deployment/types.js.map +1 -1
- package/resolver/lambda/LambdaTrigger.js +5 -12
- package/resolver/lambda/LambdaTrigger.js.map +1 -1
- package/resolver/plugins/CommandHandlerPlugin.d.ts +3 -3
- package/resolver/plugins/CommandHandlerPlugin.js +3 -11
- package/resolver/plugins/CommandHandlerPlugin.js.map +1 -1
- package/resolver/plugins/StorerAfterEachPlugin.d.ts +2 -2
- package/resolver/plugins/StorerAfterEachPlugin.js +4 -13
- package/resolver/plugins/StorerAfterEachPlugin.js.map +1 -1
- package/resolver/plugins/TransformRecordPlugin.d.ts +3 -3
- package/resolver/plugins/TransformRecordPlugin.js +3 -11
- package/resolver/plugins/TransformRecordPlugin.js.map +1 -1
- package/resolver/recordTypes/fileManager/CopyFile.js +4 -11
- package/resolver/recordTypes/fileManager/CopyFile.js.map +1 -1
- package/resolver/recordTypes/fileManager/DeleteFile.d.ts +1 -1
- package/resolver/recordTypes/fileManager/DeleteFile.js +3 -10
- package/resolver/recordTypes/fileManager/DeleteFile.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManager.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManager.js +4 -11
- package/resolver/recordTypes/fileManager/fileManager.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.js +7 -14
- package/resolver/recordTypes/fileManager/fileManagerOnDelete.js.map +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnPut.d.ts +1 -1
- package/resolver/recordTypes/fileManager/fileManagerOnPut.js +7 -14
- package/resolver/recordTypes/fileManager/fileManagerOnPut.js.map +1 -1
- package/resolver/recordTypes/fileManager/shouldBeHandled.d.ts +1 -1
- package/resolver/recordTypes/fileManager/shouldBeHandled.js +1 -8
- package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
- package/resolver/recordTypes/fileManager/types.d.ts +2 -2
- package/resolver/recordTypes/fileManager/types.js +1 -5
- package/resolver/recordTypes/users/CopyUser.d.ts +2 -2
- package/resolver/recordTypes/users/CopyUser.js +3 -10
- package/resolver/recordTypes/users/CopyUser.js.map +1 -1
- package/resolver/recordTypes/users/DeleteUser.d.ts +2 -2
- package/resolver/recordTypes/users/DeleteUser.js +3 -10
- package/resolver/recordTypes/users/DeleteUser.js.map +1 -1
- package/resolver/recordTypes/users/shouldBeHandled.d.ts +1 -1
- package/resolver/recordTypes/users/shouldBeHandled.js +1 -8
- package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
- package/resolver/recordTypes/users/types.d.ts +1 -1
- package/resolver/recordTypes/users/types.js +1 -5
- package/resolver/recordTypes/users/types.js.map +1 -1
- package/resolver/recordTypes/users/users.js +4 -11
- package/resolver/recordTypes/users/users.js.map +1 -1
- package/resolver/recordTypes/users/usersOnDelete.d.ts +2 -2
- package/resolver/recordTypes/users/usersOnDelete.js +7 -14
- package/resolver/recordTypes/users/usersOnDelete.js.map +1 -1
- package/resolver/recordTypes/users/usersOnPut.d.ts +2 -2
- package/resolver/recordTypes/users/usersOnPut.js +7 -14
- package/resolver/recordTypes/users/usersOnPut.js.map +1 -1
- package/sync/FilterOutRecord.d.ts +2 -2
- package/sync/FilterOutRecord.js +2 -10
- package/sync/FilterOutRecord.js.map +1 -1
- package/sync/attachToDynamoDbDocument.d.ts +1 -1
- package/sync/attachToDynamoDbDocument.js +9 -17
- package/sync/attachToDynamoDbDocument.js.map +1 -1
- package/sync/createHandler.js +27 -34
- package/sync/createHandler.js.map +1 -1
- package/sync/createSendDataToEventBridgeOnRequestEnd.js +6 -13
- package/sync/createSendDataToEventBridgeOnRequestEnd.js.map +1 -1
- package/sync/createSyncSystem.d.ts +1 -1
- package/sync/createSyncSystem.js +6 -13
- package/sync/createSyncSystem.js.map +1 -1
- package/sync/filter/createDefaultFilterOutRecordPlugins.d.ts +1 -1
- package/sync/filter/createDefaultFilterOutRecordPlugins.js +9 -19
- package/sync/filter/createDefaultFilterOutRecordPlugins.js.map +1 -1
- package/sync/handler/Handler.d.ts +2 -2
- package/sync/handler/Handler.js +9 -17
- package/sync/handler/Handler.js.map +1 -1
- package/sync/handler/HandlerConverter.js +2 -10
- package/sync/handler/HandlerConverter.js.map +1 -1
- package/sync/handler/converter/BatchGetCommandConverter.js +6 -14
- package/sync/handler/converter/BatchGetCommandConverter.js.map +1 -1
- package/sync/handler/converter/BatchWriteCommandConverter.js +6 -14
- package/sync/handler/converter/BatchWriteCommandConverter.js.map +1 -1
- package/sync/handler/converter/DeleteCommandConverter.js +6 -14
- package/sync/handler/converter/DeleteCommandConverter.js.map +1 -1
- package/sync/handler/converter/GetCommandConverter.js +6 -14
- package/sync/handler/converter/GetCommandConverter.js.map +1 -1
- package/sync/handler/converter/PutCommandConverter.js +6 -14
- package/sync/handler/converter/PutCommandConverter.js.map +1 -1
- package/sync/handler/converter/QueryCommandConverter.js +6 -14
- package/sync/handler/converter/QueryCommandConverter.js.map +1 -1
- package/sync/handler/converter/ScanCommandConverter.js +6 -14
- package/sync/handler/converter/ScanCommandConverter.js.map +1 -1
- package/sync/handler/converter/UpdateCommandConverter.js +6 -14
- 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 +4 -11
- 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 +3 -10
- 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 +1 -8
- 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 +3 -10
- 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 +3 -10
- package/sync/handler/converter/commands/UpdateCommandValue.js.map +1 -1
- package/sync/handler/types.d.ts +3 -3
- package/sync/handler/types.js +1 -5
- package/sync/handler/types.js.map +1 -1
- package/sync/plugins/FilterOutRecordPlugin.d.ts +1 -1
- package/sync/plugins/FilterOutRecordPlugin.js +3 -11
- package/sync/plugins/FilterOutRecordPlugin.js.map +1 -1
- package/sync/requestPlugin.d.ts +1 -1
- package/sync/requestPlugin.js +19 -20
- package/sync/requestPlugin.js.map +1 -1
- package/sync/types.js +1 -5
- package/sync/utils/getTableType.js +7 -14
- package/sync/utils/getTableType.js.map +1 -1
- package/sync/utils/manifest.d.ts +1 -1
- package/sync/utils/manifest.js +12 -20
- package/sync/utils/manifest.js.map +1 -1
- package/sync/utils/validateSystemInput.d.ts +1 -1
- package/sync/utils/validateSystemInput.js +3 -10
- package/sync/utils/validateSystemInput.js.map +1 -1
- package/types.d.ts +3 -4
- package/types.js +2 -8
- package/types.js.map +1 -1
- package/utils/createSystemName.js +1 -8
- package/utils/createSystemName.js.map +1 -1
- package/worker/actions/copyFile/CopyFile.js +13 -21
- package/worker/actions/copyFile/CopyFile.js.map +1 -1
- package/worker/actions/copyFile/copyFileAction.d.ts +1 -1
- package/worker/actions/copyFile/copyFileAction.js +9 -16
- package/worker/actions/copyFile/copyFileAction.js.map +1 -1
- package/worker/actions/copyFile/copyFileSchema.js +8 -16
- package/worker/actions/copyFile/copyFileSchema.js.map +1 -1
- package/worker/actions/copyFile/types.js +1 -5
- package/worker/actions/createUser/CreateUser.d.ts +1 -1
- package/worker/actions/createUser/CreateUser.js +9 -16
- package/worker/actions/createUser/CreateUser.js.map +1 -1
- package/worker/actions/createUser/createUserAction.d.ts +2 -2
- package/worker/actions/createUser/createUserAction.js +9 -16
- package/worker/actions/createUser/createUserAction.js.map +1 -1
- package/worker/actions/createUser/createUserSchema.js +8 -16
- package/worker/actions/createUser/createUserSchema.js.map +1 -1
- package/worker/actions/createUser/types.js +1 -5
- package/worker/actions/deleteFile/DeleteFile.js +4 -11
- package/worker/actions/deleteFile/DeleteFile.js.map +1 -1
- package/worker/actions/deleteFile/deleteFileAction.d.ts +1 -1
- package/worker/actions/deleteFile/deleteFileAction.js +9 -16
- package/worker/actions/deleteFile/deleteFileAction.js.map +1 -1
- package/worker/actions/deleteFile/deleteFileSchema.js +8 -16
- package/worker/actions/deleteFile/deleteFileSchema.js.map +1 -1
- package/worker/actions/deleteFile/types.js +1 -5
- package/worker/actions/deleteUser/DeleteUser.d.ts +2 -2
- package/worker/actions/deleteUser/DeleteUser.js +7 -14
- package/worker/actions/deleteUser/DeleteUser.js.map +1 -1
- package/worker/actions/deleteUser/deleteUserAction.d.ts +1 -1
- package/worker/actions/deleteUser/deleteUserAction.js +9 -16
- package/worker/actions/deleteUser/deleteUserAction.js.map +1 -1
- package/worker/actions/deleteUser/deleteUserSchema.js +8 -16
- package/worker/actions/deleteUser/deleteUserSchema.js.map +1 -1
- package/worker/actions/deleteUser/types.js +1 -5
- package/worker/actions/logValidationError.js +4 -11
- package/worker/actions/logValidationError.js.map +1 -1
- package/worker/actions/removeCognitoUserAttributes.js +1 -8
- package/worker/actions/removeCognitoUserAttributes.js.map +1 -1
- package/worker/actions/updateUser/UpdateUser.d.ts +1 -1
- package/worker/actions/updateUser/UpdateUser.js +9 -16
- package/worker/actions/updateUser/UpdateUser.js.map +1 -1
- package/worker/actions/updateUser/types.js +1 -5
- package/worker/actions/updateUser/updateUserAction.d.ts +2 -2
- package/worker/actions/updateUser/updateUserAction.js +9 -16
- package/worker/actions/updateUser/updateUserAction.js.map +1 -1
- package/worker/actions/updateUser/updateUserSchema.js +8 -16
- package/worker/actions/updateUser/updateUserSchema.js.map +1 -1
- package/worker/createWorkerHandler.js +17 -24
- package/worker/createWorkerHandler.js.map +1 -1
- package/worker/handler/WorkerActionHandler.d.ts +2 -2
- package/worker/handler/WorkerActionHandler.js +3 -10
- package/worker/handler/WorkerActionHandler.js.map +1 -1
- package/worker/handler/eventHandler.js +9 -16
- package/worker/handler/eventHandler.js.map +1 -1
- package/worker/plugins/WorkerActionPlugin.d.ts +1 -1
- package/worker/plugins/WorkerActionPlugin.js +3 -11
- package/worker/plugins/WorkerActionPlugin.js.map +1 -1
- package/worker/types.js +1 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["decorateDocumentClient","BatchWriteCommand","DeleteCommand","PutCommand","UpdateCommand","decorateClientWithHandler","params","handler","client","__webinyHandler","id","originalSend","send","originalPut","put","originalDelete","delete","originalUpdate","update","originalBatchWrite","batchWrite","add","apply","cmd","attachToDynamoDbDocument"],"sources":["attachToDynamoDbDocument.ts"],"sourcesContent":["import { decorateDocumentClient } from \"@webiny/aws-sdk/client-dynamodb/getDocumentClient.js\";\nimport type { IHandler } from \"~/sync/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport {\n BatchWriteCommand,\n DeleteCommand,\n PutCommand,\n UpdateCommand\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport interface IAttachToDynamoDbDocumentParams {\n handler: IHandler;\n}\n\nexport interface IDecorateClientWithHandlerParams {\n handler: IHandler;\n client: DynamoDBDocument;\n}\n\nexport const decorateClientWithHandler = (\n params: IDecorateClientWithHandlerParams\n): DynamoDBDocument => {\n const { handler, client } = params;\n /**\n * Is there a possibility that this is already attached?\n * Let's check for the handler and then skip attaching.\n */\n // @ts-expect-error\n if (client.__webinyHandler?.id === handler.id) {\n return client;\n }\n\n const originalSend = client.send;\n const originalPut = client.put;\n const originalDelete = client.delete;\n const originalUpdate = client.update;\n const originalBatchWrite = client.batchWrite;\n\n // @ts-expect-error\n client.__webinyHandler = handler;\n\n client.send = async params => {\n // @ts-expect-error\n handler.add(params);\n // @ts-expect-error\n return originalSend.apply(client, [params]);\n };\n // @ts-expect-error\n client.put = async params => {\n const cmd = new PutCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalPut.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.delete = async params => {\n const cmd = new DeleteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalDelete.apply(client, [params]);\n };\n\n // @ts-expect-error\n client.batchWrite = async params => {\n const cmd = new BatchWriteCommand(params);\n handler.add(cmd);\n // @ts-expect-error\n return originalBatchWrite.apply(client, [params]);\n };\n\n client.update = async params => {\n const cmd = new UpdateCommand(params);\n handler.add(cmd);\n return originalUpdate(params);\n };\n\n return client;\n};\n\nexport const attachToDynamoDbDocument = ({ handler }: IAttachToDynamoDbDocumentParams): void => {\n return decorateDocumentClient(client => {\n return decorateClientWithHandler({\n handler,\n client\n });\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,sDAAsD;AAG7F,SACIC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,aAAa,QACV,0CAA0C;AAWjD,OAAO,MAAMC,yBAAyB,GAClCC,MAAwC,IACrB;EACnB,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAClC;AACJ;AACA;AACA;EACI;EACA,IAAIE,MAAM,CAACC,eAAe,EAAEC,EAAE,KAAKH,OAAO,CAACG,EAAE,EAAE;IAC3C,OAAOF,MAAM;EACjB;EAEA,MAAMG,YAAY,GAAGH,MAAM,CAACI,IAAI;EAChC,MAAMC,WAAW,GAAGL,MAAM,CAACM,GAAG;EAC9B,MAAMC,cAAc,GAAGP,MAAM,CAACQ,MAAM;EACpC,MAAMC,cAAc,GAAGT,MAAM,CAACU,MAAM;EACpC,MAAMC,kBAAkB,GAAGX,MAAM,CAACY,UAAU;;EAE5C;EACAZ,MAAM,CAACC,eAAe,GAAGF,OAAO;EAEhCC,MAAM,CAACI,IAAI,GAAG,MAAMN,MAAM,IAAI;IAC1B;IACAC,OAAO,CAACc,GAAG,CAACf,MAAM,CAAC;IACnB;IACA,OAAOK,YAAY,CAACW,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EAC/C,CAAC;EACD;EACAE,MAAM,CAACM,GAAG,GAAG,MAAMR,MAAM,IAAI;IACzB,MAAMiB,GAAG,GAAG,IAAIpB,UAAU,CAACG,MAAM,CAAC;IAClCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOV,WAAW,CAACS,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EAC9C,CAAC;;EAED;EACAE,MAAM,CAACQ,MAAM,GAAG,MAAMV,MAAM,IAAI;IAC5B,MAAMiB,GAAG,GAAG,IAAIrB,aAAa,CAACI,MAAM,CAAC;IACrCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOR,cAAc,CAACO,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EACjD,CAAC;;EAED;EACAE,MAAM,CAACY,UAAU,GAAG,MAAMd,MAAM,IAAI;IAChC,MAAMiB,GAAG,GAAG,IAAItB,iBAAiB,CAACK,MAAM,CAAC;IACzCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB;IACA,OAAOJ,kBAAkB,CAACG,KAAK,CAACd,MAAM,EAAE,CAACF,MAAM,CAAC,CAAC;EACrD,CAAC;EAEDE,MAAM,CAACU,MAAM,GAAG,MAAMZ,MAAM,IAAI;IAC5B,MAAMiB,GAAG,GAAG,IAAInB,aAAa,CAACE,MAAM,CAAC;IACrCC,OAAO,CAACc,GAAG,CAACE,GAAG,CAAC;IAChB,OAAON,cAAc,CAACX,MAAM,CAAC;EACjC,CAAC;EAED,OAAOE,MAAM;AACjB,CAAC;AAED,OAAO,MAAMgB,wBAAwB,GAAGA,CAAC;EAAEjB;AAAyC,CAAC,KAAW;EAC5F,OAAOP,sBAAsB,CAACQ,MAAM,IAAI;IACpC,OAAOH,yBAAyB,CAAC;MAC7BE,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/sync/createHandler.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _QueryCommandConverter = require("./handler/converter/QueryCommandConverter.js");
|
|
16
|
-
var _ScanCommandConverter = require("./handler/converter/ScanCommandConverter.js");
|
|
17
|
-
var _GetCommandConverter = require("./handler/converter/GetCommandConverter.js");
|
|
18
|
-
var _FilterOutRecordPlugin = require("./plugins/FilterOutRecordPlugin.js");
|
|
19
|
-
var _FilterOutRecord = require("./FilterOutRecord.js");
|
|
20
|
-
const createHandler = params => {
|
|
1
|
+
import { createHandlerConverter } from "./handler/HandlerConverter.js";
|
|
2
|
+
import { NullCommandValue } from "./handler/converter/commands/NullCommandValue.js";
|
|
3
|
+
import { createBatchWriteCommandConverter } from "./handler/converter/BatchWriteCommandConverter.js";
|
|
4
|
+
import { createPutCommandConverter } from "./handler/converter/PutCommandConverter.js";
|
|
5
|
+
import { createDeleteCommandConverter } from "./handler/converter/DeleteCommandConverter.js";
|
|
6
|
+
import { createUpdateCommandConverter } from "./handler/converter/UpdateCommandConverter.js";
|
|
7
|
+
import { createSyncHandler } from "./handler/Handler.js";
|
|
8
|
+
import { createBatchGetCommandConverter } from "./handler/converter/BatchGetCommandConverter.js";
|
|
9
|
+
import { createQueryCommandConverter } from "./handler/converter/QueryCommandConverter.js";
|
|
10
|
+
import { createScanCommandConverter } from "./handler/converter/ScanCommandConverter.js";
|
|
11
|
+
import { createGetCommandConverter } from "./handler/converter/GetCommandConverter.js";
|
|
12
|
+
import { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
|
|
13
|
+
import { createFilterOutRecord } from "./FilterOutRecord.js";
|
|
14
|
+
export const createHandler = params => {
|
|
21
15
|
const {
|
|
22
16
|
manifest,
|
|
23
17
|
commandConverters,
|
|
@@ -25,25 +19,25 @@ const createHandler = params => {
|
|
|
25
19
|
getEventBridgeClient,
|
|
26
20
|
getPlugins
|
|
27
21
|
} = params;
|
|
28
|
-
const filterOutRecordPlugins = getPlugins().byType(
|
|
29
|
-
const filterOutRecord =
|
|
30
|
-
const converter =
|
|
31
|
-
defaultValue: new
|
|
22
|
+
const filterOutRecordPlugins = getPlugins().byType(FilterOutRecordPlugin.type);
|
|
23
|
+
const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);
|
|
24
|
+
const converter = createHandlerConverter({
|
|
25
|
+
defaultValue: new NullCommandValue()
|
|
32
26
|
});
|
|
33
27
|
/**
|
|
34
28
|
* We register users command converters because those are tested out first.
|
|
35
29
|
* Our converters are in some order I got from my head - the most used commands are first.
|
|
36
30
|
*/
|
|
37
31
|
converter.register(commandConverters || []);
|
|
38
|
-
converter.register(
|
|
39
|
-
converter.register(
|
|
40
|
-
converter.register(
|
|
41
|
-
converter.register(
|
|
42
|
-
converter.register(
|
|
43
|
-
converter.register(
|
|
44
|
-
converter.register(
|
|
45
|
-
converter.register(
|
|
46
|
-
const handler =
|
|
32
|
+
converter.register(createBatchGetCommandConverter());
|
|
33
|
+
converter.register(createGetCommandConverter());
|
|
34
|
+
converter.register(createQueryCommandConverter());
|
|
35
|
+
converter.register(createScanCommandConverter());
|
|
36
|
+
converter.register(createBatchWriteCommandConverter());
|
|
37
|
+
converter.register(createPutCommandConverter());
|
|
38
|
+
converter.register(createDeleteCommandConverter());
|
|
39
|
+
converter.register(createUpdateCommandConverter());
|
|
40
|
+
const handler = createSyncHandler({
|
|
47
41
|
system,
|
|
48
42
|
getEventBridgeClient,
|
|
49
43
|
eventBus: {
|
|
@@ -58,6 +52,5 @@ const createHandler = params => {
|
|
|
58
52
|
converter
|
|
59
53
|
};
|
|
60
54
|
};
|
|
61
|
-
exports.createHandler = createHandler;
|
|
62
55
|
|
|
63
56
|
//# sourceMappingURL=createHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createHandlerConverter","NullCommandValue","createBatchWriteCommandConverter","createPutCommandConverter","createDeleteCommandConverter","createUpdateCommandConverter","createSyncHandler","createBatchGetCommandConverter","createQueryCommandConverter","createScanCommandConverter","createGetCommandConverter","FilterOutRecordPlugin","createFilterOutRecord","createHandler","params","manifest","commandConverters","system","getEventBridgeClient","getPlugins","filterOutRecordPlugins","byType","type","filterOutRecord","converter","defaultValue","register","handler","eventBus","arn","sync","eventBusArn","name","eventBusName"],"sources":["createHandler.ts"],"sourcesContent":["import { createHandlerConverter } from \"~/sync/handler/HandlerConverter.js\";\nimport { NullCommandValue } from \"~/sync/handler/converter/commands/NullCommandValue.js\";\nimport { createBatchWriteCommandConverter } from \"~/sync/handler/converter/BatchWriteCommandConverter.js\";\nimport { createPutCommandConverter } from \"~/sync/handler/converter/PutCommandConverter.js\";\nimport { createDeleteCommandConverter } from \"~/sync/handler/converter/DeleteCommandConverter.js\";\nimport { createUpdateCommandConverter } from \"~/sync/handler/converter/UpdateCommandConverter.js\";\nimport { createSyncHandler } from \"~/sync/handler/Handler.js\";\nimport type { EventBridgeClient } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport type { ICommandConverter, IManifest, ISystem } from \"./types.js\";\nimport { createBatchGetCommandConverter } from \"./handler/converter/BatchGetCommandConverter.js\";\nimport { createQueryCommandConverter } from \"./handler/converter/QueryCommandConverter.js\";\nimport { createScanCommandConverter } from \"~/sync/handler/converter/ScanCommandConverter.js\";\nimport { createGetCommandConverter } from \"./handler/converter/GetCommandConverter.js\";\nimport type { PluginsContainer } from \"@webiny/plugins/PluginsContainer.js\";\nimport { FilterOutRecordPlugin } from \"~/sync/plugins/FilterOutRecordPlugin.js\";\nimport { createFilterOutRecord } from \"~/sync/FilterOutRecord.js\";\n\nexport interface ICreateHandlerParams {\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n commandConverters?: ICommandConverter[];\n system: ISystem;\n manifest: IManifest;\n getPlugins: () => PluginsContainer;\n}\n\nexport const createHandler = (params: ICreateHandlerParams) => {\n const { manifest, commandConverters, system, getEventBridgeClient, getPlugins } = params;\n\n const filterOutRecordPlugins = getPlugins().byType<FilterOutRecordPlugin>(\n FilterOutRecordPlugin.type\n );\n\n const filterOutRecord = createFilterOutRecord(filterOutRecordPlugins);\n\n const converter = createHandlerConverter({\n defaultValue: new NullCommandValue()\n });\n /**\n * We register users command converters because those are tested out first.\n * Our converters are in some order I got from my head - the most used commands are first.\n */\n converter.register(commandConverters || []);\n converter.register(createBatchGetCommandConverter());\n converter.register(createGetCommandConverter());\n converter.register(createQueryCommandConverter());\n converter.register(createScanCommandConverter());\n converter.register(createBatchWriteCommandConverter());\n converter.register(createPutCommandConverter());\n converter.register(createDeleteCommandConverter());\n converter.register(createUpdateCommandConverter());\n\n const handler = createSyncHandler({\n system,\n getEventBridgeClient,\n eventBus: {\n arn: manifest.sync.eventBusArn,\n name: manifest.sync.eventBusName\n },\n converter,\n filterOutRecord\n });\n return {\n handler,\n converter\n };\n};\n"],"mappings":"AAAA,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,gCAAgC;AACzC,SAASC,yBAAyB;AAClC,SAASC,4BAA4B;AACrC,SAASC,4BAA4B;AACrC,SAASC,iBAAiB;AAG1B,SAASC,8BAA8B;AACvC,SAASC,2BAA2B;AACpC,SAASC,0BAA0B;AACnC,SAASC,yBAAyB;AAElC,SAASC,qBAAqB;AAC9B,SAASC,qBAAqB;AAU9B,OAAO,MAAMC,aAAa,GAAIC,MAA4B,IAAK;EAC3D,MAAM;IAAEC,QAAQ;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC,oBAAoB;IAAEC;EAAW,CAAC,GAAGL,MAAM;EAExF,MAAMM,sBAAsB,GAAGD,UAAU,CAAC,CAAC,CAACE,MAAM,CAC9CV,qBAAqB,CAACW,IAC1B,CAAC;EAED,MAAMC,eAAe,GAAGX,qBAAqB,CAACQ,sBAAsB,CAAC;EAErE,MAAMI,SAAS,GAAGxB,sBAAsB,CAAC;IACrCyB,YAAY,EAAE,IAAIxB,gBAAgB,CAAC;EACvC,CAAC,CAAC;EACF;AACJ;AACA;AACA;EACIuB,SAAS,CAACE,QAAQ,CAACV,iBAAiB,IAAI,EAAE,CAAC;EAC3CQ,SAAS,CAACE,QAAQ,CAACnB,8BAA8B,CAAC,CAAC,CAAC;EACpDiB,SAAS,CAACE,QAAQ,CAAChB,yBAAyB,CAAC,CAAC,CAAC;EAC/Cc,SAAS,CAACE,QAAQ,CAAClB,2BAA2B,CAAC,CAAC,CAAC;EACjDgB,SAAS,CAACE,QAAQ,CAACjB,0BAA0B,CAAC,CAAC,CAAC;EAChDe,SAAS,CAACE,QAAQ,CAACxB,gCAAgC,CAAC,CAAC,CAAC;EACtDsB,SAAS,CAACE,QAAQ,CAACvB,yBAAyB,CAAC,CAAC,CAAC;EAC/CqB,SAAS,CAACE,QAAQ,CAACtB,4BAA4B,CAAC,CAAC,CAAC;EAClDoB,SAAS,CAACE,QAAQ,CAACrB,4BAA4B,CAAC,CAAC,CAAC;EAElD,MAAMsB,OAAO,GAAGrB,iBAAiB,CAAC;IAC9BW,MAAM;IACNC,oBAAoB;IACpBU,QAAQ,EAAE;MACNC,GAAG,EAAEd,QAAQ,CAACe,IAAI,CAACC,WAAW;MAC9BC,IAAI,EAAEjB,QAAQ,CAACe,IAAI,CAACG;IACxB,CAAC;IACDT,SAAS;IACTD;EACJ,CAAC,CAAC;EACF,OAAO;IACHI,OAAO;IACPH;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSendDataToEventBridgeOnRequestEnd = void 0;
|
|
7
|
-
var _handler = require("@webiny/handler");
|
|
8
|
-
var _exception = require("@webiny/utils/exception.js");
|
|
1
|
+
import { createOnRequestResponseSend, createOnRequestTimeout } from "@webiny/handler";
|
|
2
|
+
import { convertException } from "@webiny/utils/exception.js";
|
|
9
3
|
const execute = async handler => {
|
|
10
4
|
try {
|
|
11
5
|
return await handler.flush();
|
|
12
6
|
} catch (ex) {
|
|
13
|
-
const error =
|
|
7
|
+
const error = convertException(ex);
|
|
14
8
|
console.error({
|
|
15
9
|
flushError: error
|
|
16
10
|
});
|
|
@@ -28,8 +22,8 @@ const isOptionsRequest = request => {
|
|
|
28
22
|
}
|
|
29
23
|
return request.method.toUpperCase() === "OPTIONS";
|
|
30
24
|
};
|
|
31
|
-
const createSendDataToEventBridgeOnRequestEnd = handler => {
|
|
32
|
-
const onRequestResponseSend =
|
|
25
|
+
export const createSendDataToEventBridgeOnRequestEnd = handler => {
|
|
26
|
+
const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {
|
|
33
27
|
if (isOptionsRequest(request)) {
|
|
34
28
|
return payload;
|
|
35
29
|
}
|
|
@@ -37,7 +31,7 @@ const createSendDataToEventBridgeOnRequestEnd = handler => {
|
|
|
37
31
|
return payload;
|
|
38
32
|
});
|
|
39
33
|
onRequestResponseSend.name = "sync.onRequestResponseSend";
|
|
40
|
-
const onRequestTimeout =
|
|
34
|
+
const onRequestTimeout = createOnRequestTimeout(async request => {
|
|
41
35
|
if (isOptionsRequest(request)) {
|
|
42
36
|
return;
|
|
43
37
|
}
|
|
@@ -46,6 +40,5 @@ const createSendDataToEventBridgeOnRequestEnd = handler => {
|
|
|
46
40
|
onRequestTimeout.name = "sync.onRequestTimeout";
|
|
47
41
|
return [onRequestResponseSend, onRequestTimeout];
|
|
48
42
|
};
|
|
49
|
-
exports.createSendDataToEventBridgeOnRequestEnd = createSendDataToEventBridgeOnRequestEnd;
|
|
50
43
|
|
|
51
44
|
//# sourceMappingURL=createSendDataToEventBridgeOnRequestEnd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createOnRequestResponseSend","createOnRequestTimeout","convertException","execute","handler","flush","ex","error","console","flushError","isOptionsRequest","request","method","toUpperCase","createSendDataToEventBridgeOnRequestEnd","onRequestResponseSend","_","payload","name","onRequestTimeout"],"sources":["createSendDataToEventBridgeOnRequestEnd.ts"],"sourcesContent":["import type { IHandler } from \"./types.js\";\nimport { createOnRequestResponseSend, createOnRequestTimeout } from \"@webiny/handler\";\nimport type { Request as FastifyRequest } from \"@webiny/handler/types.js\";\nimport { convertException } from \"@webiny/utils/exception.js\";\n\nconst execute = async (handler: IHandler) => {\n try {\n return await handler.flush();\n } catch (ex) {\n const error = convertException(ex);\n console.error({\n flushError: error\n });\n return {\n error\n };\n /**\n * We do not want to throw an error here, because we are in the request end.\n */\n }\n};\n\nconst isOptionsRequest = (request: FastifyRequest): boolean => {\n if (!request?.method) {\n return false;\n }\n return request.method.toUpperCase() === \"OPTIONS\";\n};\n\nexport const createSendDataToEventBridgeOnRequestEnd = (handler: IHandler) => {\n const onRequestResponseSend = createOnRequestResponseSend(async (request, _, payload) => {\n if (isOptionsRequest(request)) {\n return payload;\n }\n await execute(handler);\n return payload;\n });\n onRequestResponseSend.name = \"sync.onRequestResponseSend\";\n\n const onRequestTimeout = createOnRequestTimeout(async request => {\n if (isOptionsRequest(request)) {\n return;\n }\n return await execute(handler);\n });\n onRequestTimeout.name = \"sync.onRequestTimeout\";\n\n return [onRequestResponseSend, onRequestTimeout];\n};\n"],"mappings":"AACA,SAASA,2BAA2B,EAAEC,sBAAsB,QAAQ,iBAAiB;AAErF,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,MAAMC,OAAO,GAAG,MAAOC,OAAiB,IAAK;EACzC,IAAI;IACA,OAAO,MAAMA,OAAO,CAACC,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC,OAAOC,EAAE,EAAE;IACT,MAAMC,KAAK,GAAGL,gBAAgB,CAACI,EAAE,CAAC;IAClCE,OAAO,CAACD,KAAK,CAAC;MACVE,UAAU,EAAEF;IAChB,CAAC,CAAC;IACF,OAAO;MACHA;IACJ,CAAC;IACD;AACR;AACA;EACI;AACJ,CAAC;AAED,MAAMG,gBAAgB,GAAIC,OAAuB,IAAc;EAC3D,IAAI,CAACA,OAAO,EAAEC,MAAM,EAAE;IAClB,OAAO,KAAK;EAChB;EACA,OAAOD,OAAO,CAACC,MAAM,CAACC,WAAW,CAAC,CAAC,KAAK,SAAS;AACrD,CAAC;AAED,OAAO,MAAMC,uCAAuC,GAAIV,OAAiB,IAAK;EAC1E,MAAMW,qBAAqB,GAAGf,2BAA2B,CAAC,OAAOW,OAAO,EAAEK,CAAC,EAAEC,OAAO,KAAK;IACrF,IAAIP,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B,OAAOM,OAAO;IAClB;IACA,MAAMd,OAAO,CAACC,OAAO,CAAC;IACtB,OAAOa,OAAO;EAClB,CAAC,CAAC;EACFF,qBAAqB,CAACG,IAAI,GAAG,4BAA4B;EAEzD,MAAMC,gBAAgB,GAAGlB,sBAAsB,CAAC,MAAMU,OAAO,IAAI;IAC7D,IAAID,gBAAgB,CAACC,OAAO,CAAC,EAAE;MAC3B;IACJ;IACA,OAAO,MAAMR,OAAO,CAACC,OAAO,CAAC;EACjC,CAAC,CAAC;EACFe,gBAAgB,CAACD,IAAI,GAAG,uBAAuB;EAE/C,OAAO,CAACH,qBAAqB,EAAEI,gBAAgB,CAAC;AACpD,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
2
|
import type { IGetEventBridgeCallable, ISystem } from "./types.js";
|
|
3
3
|
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
4
|
-
import type { PossiblyUndefinedProperties } from "@webiny/api/types";
|
|
4
|
+
import type { PossiblyUndefinedProperties } from "@webiny/api/types.js";
|
|
5
5
|
import type { FilterOutRecordPlugin } from "./plugins/FilterOutRecordPlugin.js";
|
|
6
6
|
export type IAllowedPlugins = FilterOutRecordPlugin;
|
|
7
7
|
export interface ICreateSyncSystemParams {
|
package/sync/createSyncSystem.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSyncSystem = void 0;
|
|
7
|
-
var _validateSystemInput = require("./utils/validateSystemInput.js");
|
|
8
|
-
var _requestPlugin = require("./requestPlugin.js");
|
|
9
|
-
var _createDefaultFilterOutRecordPlugins = require("./filter/createDefaultFilterOutRecordPlugins.js");
|
|
1
|
+
import { validateSystemInput } from "./utils/validateSystemInput.js";
|
|
2
|
+
import { createSyncSystemHandlerOnRequestPlugin } from "./requestPlugin.js";
|
|
3
|
+
import { createDefaultFilterOutRecordPlugins } from "./filter/createDefaultFilterOutRecordPlugins.js";
|
|
10
4
|
const emptyResponse = {
|
|
11
5
|
plugins() {
|
|
12
6
|
return [];
|
|
13
7
|
}
|
|
14
8
|
};
|
|
15
|
-
const createSyncSystem = params => {
|
|
9
|
+
export const createSyncSystem = params => {
|
|
16
10
|
const {
|
|
17
11
|
system,
|
|
18
12
|
error
|
|
19
|
-
} =
|
|
13
|
+
} = validateSystemInput(params.system);
|
|
20
14
|
/**
|
|
21
15
|
* We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.
|
|
22
16
|
*/
|
|
@@ -29,7 +23,7 @@ const createSyncSystem = params => {
|
|
|
29
23
|
}
|
|
30
24
|
return {
|
|
31
25
|
plugins: () => {
|
|
32
|
-
return [...(params.plugins || []), ...
|
|
26
|
+
return [...(params.plugins || []), ...createDefaultFilterOutRecordPlugins(), createSyncSystemHandlerOnRequestPlugin({
|
|
33
27
|
getDocumentClient: params.getDocumentClient,
|
|
34
28
|
getEventBridgeClient: params.getEventBridgeClient,
|
|
35
29
|
system
|
|
@@ -37,6 +31,5 @@ const createSyncSystem = params => {
|
|
|
37
31
|
}
|
|
38
32
|
};
|
|
39
33
|
};
|
|
40
|
-
exports.createSyncSystem = createSyncSystem;
|
|
41
34
|
|
|
42
35
|
//# sourceMappingURL=createSyncSystem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["validateSystemInput","createSyncSystemHandlerOnRequestPlugin","createDefaultFilterOutRecordPlugins","emptyResponse","plugins","createSyncSystem","params","system","error","console","getDocumentClient","getEventBridgeClient"],"sources":["createSyncSystem.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { IGetEventBridgeCallable, ISystem } from \"./types.js\";\nimport { validateSystemInput } from \"./utils/validateSystemInput.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { PossiblyUndefinedProperties } from \"@webiny/api/types.js\";\nimport { createSyncSystemHandlerOnRequestPlugin } from \"./requestPlugin.js\";\nimport type { FilterOutRecordPlugin } from \"./plugins/FilterOutRecordPlugin.js\";\nimport { createDefaultFilterOutRecordPlugins } from \"./filter/createDefaultFilterOutRecordPlugins.js\";\n\nexport type IAllowedPlugins = FilterOutRecordPlugin;\n\nexport interface ICreateSyncSystemParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: PossiblyUndefinedProperties<Omit<ISystem, \"name\">>;\n plugins?: IAllowedPlugins[];\n}\n\nexport interface ICreateSyncSystemResponse {\n plugins(): Plugin[];\n}\n\nconst emptyResponse: ICreateSyncSystemResponse = {\n plugins(): Plugin[] {\n return [];\n }\n};\n\nexport const createSyncSystem = (params: ICreateSyncSystemParams): ICreateSyncSystemResponse => {\n const { system, error } = validateSystemInput(params.system);\n /**\n * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.\n */\n if (error) {\n console.error(error);\n return emptyResponse;\n } else if (!system) {\n console.error(\"Sync System: No system provided. Sync System will not be attached.\");\n return emptyResponse;\n }\n\n return {\n plugins: () => {\n return [\n ...(params.plugins || []),\n ...createDefaultFilterOutRecordPlugins(),\n createSyncSystemHandlerOnRequestPlugin({\n getDocumentClient: params.getDocumentClient,\n getEventBridgeClient: params.getEventBridgeClient,\n system\n })\n ];\n }\n };\n};\n"],"mappings":"AAEA,SAASA,mBAAmB;AAG5B,SAASC,sCAAsC;AAE/C,SAASC,mCAAmC;AAe5C,MAAMC,aAAwC,GAAG;EAC7CC,OAAOA,CAAA,EAAa;IAChB,OAAO,EAAE;EACb;AACJ,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAIC,MAA+B,IAAgC;EAC5F,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGR,mBAAmB,CAACM,MAAM,CAACC,MAAM,CAAC;EAC5D;AACJ;AACA;EACI,IAAIC,KAAK,EAAE;IACPC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IACpB,OAAOL,aAAa;EACxB,CAAC,MAAM,IAAI,CAACI,MAAM,EAAE;IAChBE,OAAO,CAACD,KAAK,CAAC,oEAAoE,CAAC;IACnF,OAAOL,aAAa;EACxB;EAEA,OAAO;IACHC,OAAO,EAAEA,CAAA,KAAM;MACX,OAAO,CACH,IAAIE,MAAM,CAACF,OAAO,IAAI,EAAE,CAAC,EACzB,GAAGF,mCAAmC,CAAC,CAAC,EACxCD,sCAAsC,CAAC;QACnCS,iBAAiB,EAAEJ,MAAM,CAACI,iBAAiB;QAC3CC,oBAAoB,EAAEL,MAAM,CAACK,oBAAoB;QACjDJ;MACJ,CAAC,CAAC,CACL;IACL;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterOutRecordPlugin } from "
|
|
1
|
+
import { FilterOutRecordPlugin } from "../../sync/plugins/FilterOutRecordPlugin.js";
|
|
2
2
|
/**
|
|
3
3
|
* Order keys by what is most like to be filtered out - most inserts/updates/deletes.
|
|
4
4
|
* This is out of my head, so it might not be the best order.
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { createFilterOutRecordPlugin, FilterOutRecordPlugin } from "../plugins/FilterOutRecordPlugin.js";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.startsWithKeys = exports.skipModels = exports.equalKeys = exports.createDefaultFilterOutRecordPlugins = void 0;
|
|
7
|
-
var _FilterOutRecordPlugin = require("../plugins/FilterOutRecordPlugin.js");
|
|
8
3
|
/**
|
|
9
4
|
* Order keys by what is most like to be filtered out - most inserts/updates/deletes.
|
|
10
5
|
* This is out of my head, so it might not be the best order.
|
|
11
6
|
*/
|
|
12
|
-
const equalKeys =
|
|
7
|
+
export const equalKeys = [
|
|
13
8
|
// Logging - every request
|
|
14
9
|
"LOG",
|
|
15
10
|
// P
|
|
@@ -30,7 +25,7 @@ const equalKeys = exports.equalKeys = [
|
|
|
30
25
|
"ADMIN#SETTINGS"].map(key => {
|
|
31
26
|
return key.toLowerCase();
|
|
32
27
|
});
|
|
33
|
-
const startsWithKeys =
|
|
28
|
+
export const startsWithKeys = [
|
|
34
29
|
// Websockets - on every user login
|
|
35
30
|
"WS#",
|
|
36
31
|
// Migrations - on every deployment
|
|
@@ -45,20 +40,16 @@ const startsWithKeys = exports.startsWithKeys = [
|
|
|
45
40
|
* TODO figure out a way to skip these models.
|
|
46
41
|
* When deleting a record, we do not have a modelId in the values.
|
|
47
42
|
*/
|
|
48
|
-
const skipModels =
|
|
49
|
-
// APW
|
|
50
|
-
"apwChangeRequestModelDefinition", "apwCommentModelDefinition", "apwContentReviewModelDefinition", "apwReviewerModelDefinition", "apwWorkflowModelDefnition", "apwWorkflowModelDefinition",
|
|
51
|
-
// AUDIT LOGS
|
|
52
|
-
"acoSearchRecord-auditlogs",
|
|
43
|
+
export const skipModels = [
|
|
53
44
|
// RECORD LOCKING
|
|
54
|
-
"
|
|
45
|
+
"wbyRecordLock",
|
|
55
46
|
// TASKS
|
|
56
|
-
"
|
|
47
|
+
"wbyTaskLog", "wbyTask"].map(key => {
|
|
57
48
|
return key.toLowerCase();
|
|
58
49
|
});
|
|
59
|
-
const createDefaultFilterOutRecordPlugins = () => {
|
|
60
|
-
return [
|
|
61
|
-
name:
|
|
50
|
+
export const createDefaultFilterOutRecordPlugins = () => {
|
|
51
|
+
return [createFilterOutRecordPlugin({
|
|
52
|
+
name: FilterOutRecordPlugin.createName("default"),
|
|
62
53
|
filterOut: record => {
|
|
63
54
|
const pk = record.PK.toLowerCase();
|
|
64
55
|
if (equalKeys.includes(pk)) {
|
|
@@ -83,6 +74,5 @@ const createDefaultFilterOutRecordPlugins = () => {
|
|
|
83
74
|
}
|
|
84
75
|
})];
|
|
85
76
|
};
|
|
86
|
-
exports.createDefaultFilterOutRecordPlugins = createDefaultFilterOutRecordPlugins;
|
|
87
77
|
|
|
88
78
|
//# sourceMappingURL=createDefaultFilterOutRecordPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createFilterOutRecordPlugin","FilterOutRecordPlugin","equalKeys","map","key","toLowerCase","startsWithKeys","skipModels","createDefaultFilterOutRecordPlugins","name","createName","filterOut","record","pk","PK","includes","startsWith","modelId","input","Item"],"sources":["createDefaultFilterOutRecordPlugins.ts"],"sourcesContent":["import {\n createFilterOutRecordPlugin,\n FilterOutRecordPlugin\n} from \"~/sync/plugins/FilterOutRecordPlugin.js\";\n\n/**\n * Order keys by what is most like to be filtered out - most inserts/updates/deletes.\n * This is out of my head, so it might not be the best order.\n */\nexport const equalKeys: string[] = [\n // Logging - every request\n \"LOG\",\n // P\n \"PS#SETTINGS\",\n // Websockets - on every user login\n \"WS#CONNECTIONS\",\n /**\n * packages/db-dynamodb/src/DynamoDbDriver.ts\n */\n //`W#INTERNAL`,\n /**\n * APW settings\n */\n \"APW#SETTINGS\",\n // Deployments - on every deployment\n \"DEPLOYMENTS\",\n // Admin\n \"ADMIN#SETTINGS\"\n].map(key => {\n return key.toLowerCase();\n});\n\nexport const startsWithKeys: string[] = [\n // Websockets - on every user login\n \"WS#\",\n // Migrations - on every deployment\n \"MIGRATION_RUN#\",\n \"MIGRATION#\",\n // Service Manifest - on deployment if something was changed in the service manifest\n \"SERVICE_MANIFEST#\",\n // Deployments - on every deployment\n \"DEPLOYMENT#\"\n].map(key => {\n return key.toLowerCase();\n});\n/**\n * TODO figure out a way to skip these models.\n * When deleting a record, we do not have a modelId in the values.\n */\nexport const skipModels: string[] = [\n // RECORD LOCKING\n \"wbyRecordLock\",\n // TASKS\n \"wbyTaskLog\",\n \"wbyTask\"\n].map(key => {\n return key.toLowerCase();\n});\n\nexport const createDefaultFilterOutRecordPlugins = (): FilterOutRecordPlugin[] => {\n return [\n createFilterOutRecordPlugin({\n name: FilterOutRecordPlugin.createName(\"default\"),\n filterOut: record => {\n const pk = record.PK.toLowerCase();\n if (equalKeys.includes(pk)) {\n return true;\n }\n for (const key of startsWithKeys) {\n if (pk.startsWith(key)) {\n return true;\n }\n }\n /**\n * TODO figure out a way to skip models without using expect-error.\n */\n // @ts-expect-error\n const modelId = record.input?.input?.Item?.modelId?.toLowerCase();\n if (!modelId) {\n return false;\n } else if (skipModels.includes(modelId)) {\n return true;\n }\n return false;\n }\n })\n ];\n};\n"],"mappings":"AAAA,SACIA,2BAA2B,EAC3BC,qBAAqB;;AAGzB;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAmB,GAAG;AAC/B;AACA,KAAK;AACL;AACA,aAAa;AACb;AACA,gBAAgB;AAChB;AACJ;AACA;AACI;AACA;AACJ;AACA;AACI,cAAc;AACd;AACA,aAAa;AACb;AACA,gBAAgB,CACnB,CAACC,GAAG,CAACC,GAAG,IAAI;EACT,OAAOA,GAAG,CAACC,WAAW,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,MAAMC,cAAwB,GAAG;AACpC;AACA,KAAK;AACL;AACA,gBAAgB,EAChB,YAAY;AACZ;AACA,mBAAmB;AACnB;AACA,aAAa,CAChB,CAACH,GAAG,CAACC,GAAG,IAAI;EACT,OAAOA,GAAG,CAACC,WAAW,CAAC,CAAC;AAC5B,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA,OAAO,MAAME,UAAoB,GAAG;AAChC;AACA,eAAe;AACf;AACA,YAAY,EACZ,SAAS,CACZ,CAACJ,GAAG,CAACC,GAAG,IAAI;EACT,OAAOA,GAAG,CAACC,WAAW,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,MAAMG,mCAAmC,GAAGA,CAAA,KAA+B;EAC9E,OAAO,CACHR,2BAA2B,CAAC;IACxBS,IAAI,EAAER,qBAAqB,CAACS,UAAU,CAAC,SAAS,CAAC;IACjDC,SAAS,EAAEC,MAAM,IAAI;MACjB,MAAMC,EAAE,GAAGD,MAAM,CAACE,EAAE,CAACT,WAAW,CAAC,CAAC;MAClC,IAAIH,SAAS,CAACa,QAAQ,CAACF,EAAE,CAAC,EAAE;QACxB,OAAO,IAAI;MACf;MACA,KAAK,MAAMT,GAAG,IAAIE,cAAc,EAAE;QAC9B,IAAIO,EAAE,CAACG,UAAU,CAACZ,GAAG,CAAC,EAAE;UACpB,OAAO,IAAI;QACf;MACJ;MACA;AAChB;AACA;MACgB;MACA,MAAMa,OAAO,GAAGL,MAAM,CAACM,KAAK,EAAEA,KAAK,EAAEC,IAAI,EAAEF,OAAO,EAAEZ,WAAW,CAAC,CAAC;MACjE,IAAI,CAACY,OAAO,EAAE;QACV,OAAO,KAAK;MAChB,CAAC,MAAM,IAAIV,UAAU,CAACQ,QAAQ,CAACE,OAAO,CAAC,EAAE;QACrC,OAAO,IAAI;MACf;MACA,OAAO,KAAK;IAChB;EACJ,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IDynamoDbCommand, IHandler, IHandlerConverter, ISystem } from "../types.js";
|
|
2
|
-
import type { EventBridgeClient, PutEventsCommandOutput } from "@webiny/aws-sdk/client-eventbridge";
|
|
3
|
-
import type { FilterOutRecord } from "
|
|
2
|
+
import type { EventBridgeClient, PutEventsCommandOutput } from "@webiny/aws-sdk/client-eventbridge/index.js";
|
|
3
|
+
import type { FilterOutRecord } from "../../sync/FilterOutRecord.js";
|
|
4
4
|
export interface IHandlerEventBus {
|
|
5
5
|
name: string;
|
|
6
6
|
arn: string;
|
package/sync/handler/Handler.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.createSyncHandler = exports.Handler = void 0;
|
|
7
|
-
var _clientEventbridge = require("@webiny/aws-sdk/client-eventbridge");
|
|
8
|
-
var _utils = require("@webiny/utils");
|
|
9
|
-
var _generateId = require("@webiny/utils/generateId.js");
|
|
10
|
-
class Handler {
|
|
11
|
-
id = (0, _generateId.generateAlphaNumericId)();
|
|
1
|
+
import { PutEventsCommand } from "@webiny/aws-sdk/client-eventbridge/index.js";
|
|
2
|
+
import { convertException } from "@webiny/utils";
|
|
3
|
+
import { generateAlphaNumericId } from "@webiny/utils/generateId.js";
|
|
4
|
+
export class Handler {
|
|
5
|
+
id = generateAlphaNumericId();
|
|
12
6
|
commands = [];
|
|
13
7
|
constructor(params) {
|
|
14
8
|
this.getEventBridgeClient = params.getEventBridgeClient;
|
|
@@ -30,7 +24,7 @@ class Handler {
|
|
|
30
24
|
/**
|
|
31
25
|
* We need a random ID because there can be multiple commands with same items sent - but that does not mean they are duplicates.
|
|
32
26
|
*/
|
|
33
|
-
id:
|
|
27
|
+
id: generateAlphaNumericId(),
|
|
34
28
|
items,
|
|
35
29
|
source: this.system
|
|
36
30
|
};
|
|
@@ -42,14 +36,14 @@ class Handler {
|
|
|
42
36
|
EventBusName: this.eventBus.name
|
|
43
37
|
}]
|
|
44
38
|
};
|
|
45
|
-
const command = new
|
|
39
|
+
const command = new PutEventsCommand(input);
|
|
46
40
|
try {
|
|
47
41
|
const eventBridgeClient = this.getEventBridgeClient();
|
|
48
42
|
return await eventBridgeClient.send(command);
|
|
49
43
|
} catch (ex) {
|
|
50
44
|
console.log("Could not send events to Sync System EventBridge.");
|
|
51
45
|
console.error(ex.message);
|
|
52
|
-
console.error(
|
|
46
|
+
console.error(convertException(ex, ["message"]));
|
|
53
47
|
console.log(JSON.stringify({
|
|
54
48
|
event: items
|
|
55
49
|
}));
|
|
@@ -84,10 +78,8 @@ class Handler {
|
|
|
84
78
|
return everything.length === 0 ? null : everything;
|
|
85
79
|
}
|
|
86
80
|
}
|
|
87
|
-
|
|
88
|
-
const createSyncHandler = params => {
|
|
81
|
+
export const createSyncHandler = params => {
|
|
89
82
|
return new Handler(params);
|
|
90
83
|
};
|
|
91
|
-
exports.createSyncHandler = createSyncHandler;
|
|
92
84
|
|
|
93
85
|
//# sourceMappingURL=Handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PutEventsCommand","convertException","generateAlphaNumericId","Handler","id","commands","constructor","params","getEventBridgeClient","system","converter","eventBus","filterOutRecord","add","input","cmd","convert","push","flush","items","createEventBusEvent","length","detail","source","Entries","DetailType","Detail","JSON","stringify","Source","name","EventBusName","command","eventBridgeClient","send","ex","console","log","error","message","event","Array","from","everything","reduce","commandItems","getItems","item","filterOut","tableName","tableType","PK","SK","createSyncHandler"],"sources":["Handler.ts"],"sourcesContent":["import type {\n ICommandValue,\n ICommandValueItem,\n ICommandValueItemExtended,\n IDynamoDbCommand,\n IHandler,\n IHandlerConverter,\n ISystem\n} from \"../types.js\";\nimport type {\n EventBridgeClient,\n PutEventsCommandInput,\n PutEventsCommandOutput\n} from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { PutEventsCommand } from \"@webiny/aws-sdk/client-eventbridge/index.js\";\nimport { convertException } from \"@webiny/utils\";\nimport { generateAlphaNumericId } from \"@webiny/utils/generateId.js\";\nimport type { IDetail } from \"~/sync/handler/types.js\";\nimport type { NonEmptyArray } from \"@webiny/api/types.js\";\nimport type { FilterOutRecord } from \"~/sync/FilterOutRecord.js\";\n\nexport interface IHandlerEventBus {\n name: string;\n arn: string;\n}\n\nexport interface IHandlerParams {\n getEventBridgeClient(): Pick<EventBridgeClient, \"send\">;\n converter: IHandlerConverter;\n eventBus: IHandlerEventBus;\n system: ISystem;\n filterOutRecord: FilterOutRecord;\n}\n\nexport class Handler implements IHandler {\n public readonly id = generateAlphaNumericId();\n private readonly system: ISystem;\n private readonly getEventBridgeClient: () => Pick<EventBridgeClient, \"send\">;\n private commands: ICommandValue[] = [];\n private readonly converter: IHandlerConverter;\n private readonly eventBus: IHandlerEventBus;\n private readonly filterOutRecord: FilterOutRecord;\n\n public constructor(params: IHandlerParams) {\n this.getEventBridgeClient = params.getEventBridgeClient;\n this.system = params.system;\n this.converter = params.converter;\n this.eventBus = params.eventBus;\n this.filterOutRecord = params.filterOutRecord;\n }\n\n public add(input: IDynamoDbCommand): void {\n const cmd = this.converter.convert(input);\n this.commands.push(cmd);\n }\n\n public async flush(): Promise<PutEventsCommandOutput | null> {\n const items = this.createEventBusEvent();\n\n if (!items?.length) {\n return null;\n }\n\n const detail: IDetail = {\n /**\n * We need a random ID because there can be multiple commands with same items sent - but that does not mean they are duplicates.\n */\n id: generateAlphaNumericId(),\n items,\n source: this.system\n };\n\n const input: PutEventsCommandInput = {\n Entries: [\n {\n DetailType: \"synchronization-input\",\n Detail: JSON.stringify(detail),\n Source: `webiny:${this.system.name}`,\n EventBusName: this.eventBus.name\n }\n ]\n };\n const command = new PutEventsCommand(input);\n\n try {\n const eventBridgeClient = this.getEventBridgeClient();\n return await eventBridgeClient.send(command);\n } catch (ex) {\n console.log(\"Could not send events to Sync System EventBridge.\");\n console.error(ex.message);\n console.error(convertException(ex, [\"message\"]));\n console.log(\n JSON.stringify({\n event: items\n })\n );\n throw ex;\n }\n }\n\n private createEventBusEvent(): NonEmptyArray<ICommandValueItem> | null {\n const commands = Array.from(this.commands);\n /**\n * Remove all existing commands so we can start fresh.\n */\n this.commands = [];\n const everything = commands.reduce<ICommandValueItem[]>((items, cmd) => {\n const commandItems = cmd.getItems();\n if (!commandItems?.length) {\n return items;\n }\n\n for (const item of commandItems) {\n if (this.filterOutRecord.filterOut(item)) {\n continue;\n }\n items.push({\n tableName: item.tableName,\n command: item.command,\n tableType: item.tableType,\n PK: item.PK,\n SK: item.SK\n });\n }\n\n return items;\n }, []);\n\n return everything.length === 0\n ? null\n : (everything as NonEmptyArray<ICommandValueItemExtended>);\n }\n}\n\nexport const createSyncHandler = (params: IHandlerParams): IHandler => {\n return new Handler(params);\n};\n"],"mappings":"AAcA,SAASA,gBAAgB,QAAQ,6CAA6C;AAC9E,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,sBAAsB,QAAQ,6BAA6B;AAkBpE,OAAO,MAAMC,OAAO,CAAqB;EACrBC,EAAE,GAAGF,sBAAsB,CAAC,CAAC;EAGrCG,QAAQ,GAAoB,EAAE;EAK/BC,WAAWA,CAACC,MAAsB,EAAE;IACvC,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,MAAM,GAAGF,MAAM,CAACE,MAAM;IAC3B,IAAI,CAACC,SAAS,GAAGH,MAAM,CAACG,SAAS;IACjC,IAAI,CAACC,QAAQ,GAAGJ,MAAM,CAACI,QAAQ;IAC/B,IAAI,CAACC,eAAe,GAAGL,MAAM,CAACK,eAAe;EACjD;EAEOC,GAAGA,CAACC,KAAuB,EAAQ;IACtC,MAAMC,GAAG,GAAG,IAAI,CAACL,SAAS,CAACM,OAAO,CAACF,KAAK,CAAC;IACzC,IAAI,CAACT,QAAQ,CAACY,IAAI,CAACF,GAAG,CAAC;EAC3B;EAEA,MAAaG,KAAKA,CAAA,EAA2C;IACzD,MAAMC,KAAK,GAAG,IAAI,CAACC,mBAAmB,CAAC,CAAC;IAExC,IAAI,CAACD,KAAK,EAAEE,MAAM,EAAE;MAChB,OAAO,IAAI;IACf;IAEA,MAAMC,MAAe,GAAG;MACpB;AACZ;AACA;MACYlB,EAAE,EAAEF,sBAAsB,CAAC,CAAC;MAC5BiB,KAAK;MACLI,MAAM,EAAE,IAAI,CAACd;IACjB,CAAC;IAED,MAAMK,KAA4B,GAAG;MACjCU,OAAO,EAAE,CACL;QACIC,UAAU,EAAE,uBAAuB;QACnCC,MAAM,EAAEC,IAAI,CAACC,SAAS,CAACN,MAAM,CAAC;QAC9BO,MAAM,EAAE,UAAU,IAAI,CAACpB,MAAM,CAACqB,IAAI,EAAE;QACpCC,YAAY,EAAE,IAAI,CAACpB,QAAQ,CAACmB;MAChC,CAAC;IAET,CAAC;IACD,MAAME,OAAO,GAAG,IAAIhC,gBAAgB,CAACc,KAAK,CAAC;IAE3C,IAAI;MACA,MAAMmB,iBAAiB,GAAG,IAAI,CAACzB,oBAAoB,CAAC,CAAC;MACrD,OAAO,MAAMyB,iBAAiB,CAACC,IAAI,CAACF,OAAO,CAAC;IAChD,CAAC,CAAC,OAAOG,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC,mDAAmD,CAAC;MAChED,OAAO,CAACE,KAAK,CAACH,EAAE,CAACI,OAAO,CAAC;MACzBH,OAAO,CAACE,KAAK,CAACrC,gBAAgB,CAACkC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;MAChDC,OAAO,CAACC,GAAG,CACPV,IAAI,CAACC,SAAS,CAAC;QACXY,KAAK,EAAErB;MACX,CAAC,CACL,CAAC;MACD,MAAMgB,EAAE;IACZ;EACJ;EAEQf,mBAAmBA,CAAA,EAA4C;IACnE,MAAMf,QAAQ,GAAGoC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACrC,QAAQ,CAAC;IAC1C;AACR;AACA;IACQ,IAAI,CAACA,QAAQ,GAAG,EAAE;IAClB,MAAMsC,UAAU,GAAGtC,QAAQ,CAACuC,MAAM,CAAsB,CAACzB,KAAK,EAAEJ,GAAG,KAAK;MACpE,MAAM8B,YAAY,GAAG9B,GAAG,CAAC+B,QAAQ,CAAC,CAAC;MACnC,IAAI,CAACD,YAAY,EAAExB,MAAM,EAAE;QACvB,OAAOF,KAAK;MAChB;MAEA,KAAK,MAAM4B,IAAI,IAAIF,YAAY,EAAE;QAC7B,IAAI,IAAI,CAACjC,eAAe,CAACoC,SAAS,CAACD,IAAI,CAAC,EAAE;UACtC;QACJ;QACA5B,KAAK,CAACF,IAAI,CAAC;UACPgC,SAAS,EAAEF,IAAI,CAACE,SAAS;UACzBjB,OAAO,EAAEe,IAAI,CAACf,OAAO;UACrBkB,SAAS,EAAEH,IAAI,CAACG,SAAS;UACzBC,EAAE,EAAEJ,IAAI,CAACI,EAAE;UACXC,EAAE,EAAEL,IAAI,CAACK;QACb,CAAC,CAAC;MACN;MAEA,OAAOjC,KAAK;IAChB,CAAC,EAAE,EAAE,CAAC;IAEN,OAAOwB,UAAU,CAACtB,MAAM,KAAK,CAAC,GACxB,IAAI,GACHsB,UAAuD;EAClE;AACJ;AAEA,OAAO,MAAMU,iBAAiB,GAAI9C,MAAsB,IAAe;EACnE,OAAO,IAAIJ,OAAO,CAACI,MAAM,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createHandlerConverter = exports.HandlerConverter = void 0;
|
|
7
|
-
class HandlerConverter {
|
|
1
|
+
export class HandlerConverter {
|
|
8
2
|
converters = [];
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.defaultValue = params.defaultValue;
|
|
@@ -34,10 +28,8 @@ class HandlerConverter {
|
|
|
34
28
|
return this.defaultValue;
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
const createHandlerConverter = params => {
|
|
31
|
+
export const createHandlerConverter = params => {
|
|
39
32
|
return new HandlerConverter(params);
|
|
40
33
|
};
|
|
41
|
-
exports.createHandlerConverter = createHandlerConverter;
|
|
42
34
|
|
|
43
35
|
//# sourceMappingURL=HandlerConverter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HandlerConverter","converters","constructor","params","defaultValue","register","input","Array","isArray","push","convert","command","converter","can","process","env","DEBUG","console","error","name","log","JSON","stringify","
|
|
1
|
+
{"version":3,"names":["HandlerConverter","converters","constructor","params","defaultValue","register","input","Array","isArray","push","convert","command","converter","can","process","env","DEBUG","console","error","name","log","JSON","stringify","createHandlerConverter"],"sources":["HandlerConverter.ts"],"sourcesContent":["import type {\n ICommandConverter,\n ICommandValue,\n IDynamoDbCommand,\n IHandlerConverter\n} from \"../types.js\";\n\nexport interface IHandlerConverterParams {\n defaultValue: ICommandValue;\n}\n\nexport class HandlerConverter implements IHandlerConverter {\n private readonly defaultValue: ICommandValue;\n private readonly converters: ICommandConverter[] = [];\n\n public constructor(params: IHandlerConverterParams) {\n this.defaultValue = params.defaultValue;\n }\n\n public register(input: ICommandConverter | ICommandConverter[]): void {\n if (Array.isArray(input)) {\n this.converters.push(...input);\n return;\n }\n\n this.converters.push(input);\n }\n\n public convert(command: IDynamoDbCommand): ICommandValue {\n for (const converter of this.converters) {\n if (converter.can(command)) {\n return converter.convert(command);\n }\n }\n if (process.env.DEBUG === \"true\") {\n console.error(`Unknown command: ${command.constructor?.name || \"unknown\"}`);\n if (!command.constructor?.name) {\n console.error(\n \"Command is not an instance of a class, it might be a plain object. Stringified command is in next line.\"\n );\n console.log(\n JSON.stringify({\n command\n })\n );\n }\n }\n\n return this.defaultValue;\n }\n}\n\nexport const createHandlerConverter = (params: IHandlerConverterParams): IHandlerConverter => {\n return new HandlerConverter(params);\n};\n"],"mappings":"AAWA,OAAO,MAAMA,gBAAgB,CAA8B;EAEtCC,UAAU,GAAwB,EAAE;EAE9CC,WAAWA,CAACC,MAA+B,EAAE;IAChD,IAAI,CAACC,YAAY,GAAGD,MAAM,CAACC,YAAY;EAC3C;EAEOC,QAAQA,CAACC,KAA8C,EAAQ;IAClE,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACtB,IAAI,CAACL,UAAU,CAACQ,IAAI,CAAC,GAAGH,KAAK,CAAC;MAC9B;IACJ;IAEA,IAAI,CAACL,UAAU,CAACQ,IAAI,CAACH,KAAK,CAAC;EAC/B;EAEOI,OAAOA,CAACC,OAAyB,EAAiB;IACrD,KAAK,MAAMC,SAAS,IAAI,IAAI,CAACX,UAAU,EAAE;MACrC,IAAIW,SAAS,CAACC,GAAG,CAACF,OAAO,CAAC,EAAE;QACxB,OAAOC,SAAS,CAACF,OAAO,CAACC,OAAO,CAAC;MACrC;IACJ;IACA,IAAIG,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,EAAE;MAC9BC,OAAO,CAACC,KAAK,CAAC,oBAAoBP,OAAO,CAACT,WAAW,EAAEiB,IAAI,IAAI,SAAS,EAAE,CAAC;MAC3E,IAAI,CAACR,OAAO,CAACT,WAAW,EAAEiB,IAAI,EAAE;QAC5BF,OAAO,CAACC,KAAK,CACT,yGACJ,CAAC;QACDD,OAAO,CAACG,GAAG,CACPC,IAAI,CAACC,SAAS,CAAC;UACXX;QACJ,CAAC,CACL,CAAC;MACL;IACJ;IAEA,OAAO,IAAI,CAACP,YAAY;EAC5B;AACJ;AAEA,OAAO,MAAMmB,sBAAsB,GAAIpB,MAA+B,IAAwB;EAC1F,OAAO,IAAIH,gBAAgB,CAACG,MAAM,CAAC;AACvC,CAAC","ignoreList":[]}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBatchGetCommandConverter = exports.BatchGetCommandConverter = void 0;
|
|
7
|
-
var _index = require("@webiny/aws-sdk/client-dynamodb/index.js");
|
|
8
|
-
var _NullCommandValue = require("./commands/NullCommandValue.js");
|
|
9
|
-
class BatchGetCommandConverter {
|
|
1
|
+
import { BatchGetCommand } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import { NullCommandValue } from "./commands/NullCommandValue.js";
|
|
3
|
+
export class BatchGetCommandConverter {
|
|
10
4
|
name = "batchGet";
|
|
11
5
|
can(input) {
|
|
12
|
-
return input instanceof
|
|
6
|
+
return input instanceof BatchGetCommand;
|
|
13
7
|
}
|
|
14
8
|
convert() {
|
|
15
|
-
return new
|
|
9
|
+
return new NullCommandValue();
|
|
16
10
|
}
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
const createBatchGetCommandConverter = () => {
|
|
12
|
+
export const createBatchGetCommandConverter = () => {
|
|
20
13
|
return new BatchGetCommandConverter();
|
|
21
14
|
};
|
|
22
|
-
exports.createBatchGetCommandConverter = createBatchGetCommandConverter;
|
|
23
15
|
|
|
24
16
|
//# sourceMappingURL=BatchGetCommandConverter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["BatchGetCommand","NullCommandValue","BatchGetCommandConverter","name","can","input","convert","createBatchGetCommandConverter"],"sources":["BatchGetCommandConverter.ts"],"sourcesContent":["import { BatchGetCommand } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { ICommandConverter, IDynamoDbCommand } from \"../../types.js\";\nimport { NullCommandValue } from \"./commands/NullCommandValue.js\";\n\nexport class BatchGetCommandConverter implements ICommandConverter {\n public readonly name: string = \"batchGet\";\n\n public can(input: IDynamoDbCommand): boolean {\n return input instanceof BatchGetCommand;\n }\n\n public convert() {\n return new NullCommandValue();\n }\n}\n\nexport const createBatchGetCommandConverter = (): ICommandConverter => {\n return new BatchGetCommandConverter();\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,0CAA0C;AAE1E,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,wBAAwB,CAA8B;EAC/CC,IAAI,GAAW,UAAU;EAElCC,GAAGA,CAACC,KAAuB,EAAW;IACzC,OAAOA,KAAK,YAAYL,eAAe;EAC3C;EAEOM,OAAOA,CAAA,EAAG;IACb,OAAO,IAAIL,gBAAgB,CAAC,CAAC;EACjC;AACJ;AAEA,OAAO,MAAMM,8BAA8B,GAAGA,CAAA,KAAyB;EACnE,OAAO,IAAIL,wBAAwB,CAAC,CAAC;AACzC,CAAC","ignoreList":[]}
|