From ccc521ce65c7abc8ef4e54c1f55ec60bef88e024 Mon Sep 17 00:00:00 2001 From: monholm <73996878+monholm@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:53:00 +0100 Subject: [PATCH] fix(lib-dynamodb): input types conflicts with client-dynamodb #6654 added `| undefined` to optional model props, but the types in lib-dynamodb wasn't updated to reflect that change. This leaves consumers using `exactOptionalPropertyTypes: true` with ts errors when trying to use almost any of the commands in lib-dynamodb Fixes #6668 --- .../commands/BatchExecuteStatementCommand.ts | 2 +- .../src/commands/BatchWriteCommand.ts | 16 +++++--- .../src/commands/DeleteCommand.ts | 18 +++++---- .../src/commands/ExecuteStatementCommand.ts | 2 +- .../src/commands/ExecuteTransactionCommand.ts | 2 +- lib/lib-dynamodb/src/commands/PutCommand.ts | 18 +++++---- lib/lib-dynamodb/src/commands/QueryCommand.ts | 32 ++++++++------- lib/lib-dynamodb/src/commands/ScanCommand.ts | 18 +++++---- .../src/commands/TransactWriteCommand.ts | 40 +++++++++++-------- .../src/commands/UpdateCommand.ts | 32 ++++++++------- 10 files changed, 103 insertions(+), 77 deletions(-) diff --git a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts index 2d9e8fecb4a0f..9fc6121f51935 100644 --- a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts @@ -18,7 +18,7 @@ export { DynamoDBDocumentClientCommand, $Command }; export type BatchExecuteStatementCommandInput = Omit<__BatchExecuteStatementCommandInput, "Statements"> & { Statements: | (Omit & { - Parameters?: NativeAttributeValue[]; + Parameters?: NativeAttributeValue[] | undefined; })[] | undefined; }; diff --git a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts index 9de56da1658b7..112fb853718a8 100644 --- a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts @@ -20,12 +20,16 @@ export type BatchWriteCommandInput = Omit<__BatchWriteItemCommandInput, "Request | Record< string, (Omit & { - PutRequest?: Omit & { - Item: Record | undefined; - }; - DeleteRequest?: Omit & { - Key: Record | undefined; - }; + PutRequest?: + | (Omit & { + Item: Record | undefined; + }) + | undefined; + DeleteRequest?: + | (Omit & { + Key: Record | undefined; + }) + | undefined; })[] > | undefined; diff --git a/lib/lib-dynamodb/src/commands/DeleteCommand.ts b/lib/lib-dynamodb/src/commands/DeleteCommand.ts index f6d6e32a15bf7..e13ff24eb2135 100644 --- a/lib/lib-dynamodb/src/commands/DeleteCommand.ts +++ b/lib/lib-dynamodb/src/commands/DeleteCommand.ts @@ -17,14 +17,16 @@ export { DynamoDBDocumentClientCommand, $Command }; */ export type DeleteCommandInput = Omit<__DeleteItemCommandInput, "Key" | "Expected" | "ExpressionAttributeValues"> & { Key: Record | undefined; - Expected?: Record< - string, - Omit & { - Value?: NativeAttributeValue; - AttributeValueList?: NativeAttributeValue[]; - } - >; - ExpressionAttributeValues?: Record; + Expected?: + | Record< + string, + | Omit & { + Value?: NativeAttributeValue; + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts index 81f0aae6227d7..5986af8feb63e 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts @@ -16,7 +16,7 @@ export { DynamoDBDocumentClientCommand, $Command }; * @public */ export type ExecuteStatementCommandInput = Omit<__ExecuteStatementCommandInput, "Parameters"> & { - Parameters?: NativeAttributeValue[]; + Parameters?: NativeAttributeValue[] | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts index 6e7d40beefc9d..585c65b44543a 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts @@ -18,7 +18,7 @@ export { DynamoDBDocumentClientCommand, $Command }; export type ExecuteTransactionCommandInput = Omit<__ExecuteTransactionCommandInput, "TransactStatements"> & { TransactStatements: | (Omit & { - Parameters?: NativeAttributeValue[]; + Parameters?: NativeAttributeValue[] | undefined; })[] | undefined; }; diff --git a/lib/lib-dynamodb/src/commands/PutCommand.ts b/lib/lib-dynamodb/src/commands/PutCommand.ts index 8e345adbb6072..81c4c806ee5ac 100644 --- a/lib/lib-dynamodb/src/commands/PutCommand.ts +++ b/lib/lib-dynamodb/src/commands/PutCommand.ts @@ -17,14 +17,16 @@ export { DynamoDBDocumentClientCommand, $Command }; */ export type PutCommandInput = Omit<__PutItemCommandInput, "Item" | "Expected" | "ExpressionAttributeValues"> & { Item: Record | undefined; - Expected?: Record< - string, - Omit & { - Value?: NativeAttributeValue; - AttributeValueList?: NativeAttributeValue[]; - } - >; - ExpressionAttributeValues?: Record; + Expected?: + | Record< + string, + Omit & { + Value?: NativeAttributeValue | undefined; + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/QueryCommand.ts b/lib/lib-dynamodb/src/commands/QueryCommand.ts index 726d6a998b109..d64883fe06613 100644 --- a/lib/lib-dynamodb/src/commands/QueryCommand.ts +++ b/lib/lib-dynamodb/src/commands/QueryCommand.ts @@ -19,20 +19,24 @@ export type QueryCommandInput = Omit< __QueryCommandInput, "KeyConditions" | "QueryFilter" | "ExclusiveStartKey" | "ExpressionAttributeValues" > & { - KeyConditions?: Record< - string, - Omit & { - AttributeValueList?: NativeAttributeValue[]; - } - >; - QueryFilter?: Record< - string, - Omit & { - AttributeValueList?: NativeAttributeValue[]; - } - >; - ExclusiveStartKey?: Record; - ExpressionAttributeValues?: Record; + KeyConditions?: + | Record< + string, + Omit & { + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + QueryFilter?: + | Record< + string, + Omit & { + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExclusiveStartKey?: Record | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ScanCommand.ts b/lib/lib-dynamodb/src/commands/ScanCommand.ts index ffe1e23829d9c..1a662b528450c 100644 --- a/lib/lib-dynamodb/src/commands/ScanCommand.ts +++ b/lib/lib-dynamodb/src/commands/ScanCommand.ts @@ -19,14 +19,16 @@ export type ScanCommandInput = Omit< __ScanCommandInput, "ScanFilter" | "ExclusiveStartKey" | "ExpressionAttributeValues" > & { - ScanFilter?: Record< - string, - Omit & { - AttributeValueList?: NativeAttributeValue[]; - } - >; - ExclusiveStartKey?: Record; - ExpressionAttributeValues?: Record; + ScanFilter?: + | Record< + string, + Omit & { + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExclusiveStartKey?: Record | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts index 79e3cc2af2f23..8e503f6b80a7b 100644 --- a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts @@ -18,22 +18,30 @@ export { DynamoDBDocumentClientCommand, $Command }; export type TransactWriteCommandInput = Omit<__TransactWriteItemsCommandInput, "TransactItems"> & { TransactItems: | (Omit & { - ConditionCheck?: Omit & { - Key: Record | undefined; - ExpressionAttributeValues?: Record; - }; - Put?: Omit & { - Item: Record | undefined; - ExpressionAttributeValues?: Record; - }; - Delete?: Omit & { - Key: Record | undefined; - ExpressionAttributeValues?: Record; - }; - Update?: Omit & { - Key: Record | undefined; - ExpressionAttributeValues?: Record; - }; + ConditionCheck?: + | (Omit & { + Key: Record | undefined; + ExpressionAttributeValues?: Record | undefined; + }) + | undefined; + Put?: + | (Omit & { + Item: Record | undefined; + ExpressionAttributeValues?: Record | undefined; + }) + | undefined; + Delete?: + | (Omit & { + Key: Record | undefined; + ExpressionAttributeValues?: Record | undefined; + }) + | undefined; + Update?: + | (Omit & { + Key: Record | undefined; + ExpressionAttributeValues?: Record | undefined; + }) + | undefined; })[] | undefined; }; diff --git a/lib/lib-dynamodb/src/commands/UpdateCommand.ts b/lib/lib-dynamodb/src/commands/UpdateCommand.ts index 11e3b65be7c40..351c799f00558 100644 --- a/lib/lib-dynamodb/src/commands/UpdateCommand.ts +++ b/lib/lib-dynamodb/src/commands/UpdateCommand.ts @@ -20,20 +20,24 @@ export type UpdateCommandInput = Omit< "Key" | "AttributeUpdates" | "Expected" | "ExpressionAttributeValues" > & { Key: Record | undefined; - AttributeUpdates?: Record< - string, - Omit & { - Value?: NativeAttributeValue; - } - >; - Expected?: Record< - string, - Omit & { - Value?: NativeAttributeValue; - AttributeValueList?: NativeAttributeValue[]; - } - >; - ExpressionAttributeValues?: Record; + AttributeUpdates?: + | Record< + string, + Omit & { + Value?: NativeAttributeValue; + } + > + | undefined; + Expected?: + | Record< + string, + Omit & { + Value?: NativeAttributeValue; + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExpressionAttributeValues?: Record | undefined; }; /**