From 4f2ddaec85551f22a1874e9042e1a2ef573bf6b4 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 30 Oct 2023 23:43:23 +0100 Subject: [PATCH] chore(idempotency): refactor aws sdk init logic (#1768) --- .../src/persistence/DynamoDBPersistenceLayer.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts index 5d1a651f00..32b55777e4 100644 --- a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts +++ b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts @@ -81,15 +81,17 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer { this.staticPkValue = config.staticPkValue ?? `idempotency#${this.idempotencyKeyPrefix}`; - this.client = new DynamoDBClient(config?.clientConfig ?? {}); - if (config?.awsSdkV3Client) { - if (isSdkClient(config.awsSdkV3Client)) { - this.client = config.awsSdkV3Client; - } else { + if (config.awsSdkV3Client) { + if (!isSdkClient(config.awsSdkV3Client)) { console.warn( 'awsSdkV3Client is not an AWS SDK v3 client, using default client' ); + this.client = new DynamoDBClient(config.clientConfig ?? {}); + } else { + this.client = config.awsSdkV3Client; } + } else { + this.client = new DynamoDBClient(config.clientConfig ?? {}); } addUserAgentMiddleware(this.client, 'idempotency'); }