diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientCommandGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientCommandGenerator.java index ffd8f1e7f296..ad38b391f87a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientCommandGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientCommandGenerator.java @@ -392,11 +392,11 @@ private void writeStructureMemberOmitType(MemberShape member) { String optionalSuffix = isRequiredMember(member) ? "" : "?"; writer.openBlock("${L}${L}: ", ";", symbolProvider.toMemberName(member), optionalSuffix, () -> { - writeMemberOmitType(member); + writeMemberOmitType(member, true); }); } - private void writeMemberOmitType(MemberShape member) { + private void writeMemberOmitType(MemberShape member, boolean allowUndefined) { Shape memberTarget = model.expectShape(member.getTarget()); if (memberTarget.isStructureShape()) { writeStructureOmitType((StructureShape) memberTarget); @@ -413,16 +413,17 @@ private void writeMemberOmitType(MemberShape member) { } else if (memberTarget.isMapShape()) { MemberShape mapMember = ((MapShape) memberTarget).getValue(); writer.openBlock("Record", () -> { - writeMemberOmitType(mapMember); + writeMemberOmitType(mapMember, false); }); } else if (memberTarget instanceof CollectionShape) { MemberShape collectionMember = ((CollectionShape) memberTarget).getMember(); writer.openBlock("(", ")[]", () -> { - writeMemberOmitType(collectionMember); + writeMemberOmitType(collectionMember, false); }); } - String typeSuffix = isRequiredMember(member) ? " | undefined" : ""; - writer.write("${L}", typeSuffix); + if (allowUndefined) { + writer.write(" | undefined"); + } } private void writeNativeAttributeValue() { diff --git a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts index 2d9e8fecb4a0..2f542799d961 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; }; @@ -27,12 +27,16 @@ export type BatchExecuteStatementCommandInput = Omit<__BatchExecuteStatementComm * @public */ export type BatchExecuteStatementCommandOutput = Omit<__BatchExecuteStatementCommandOutput, "Responses"> & { - Responses?: (Omit & { - Error?: Omit & { - Item?: Record; - }; - Item?: Record; - })[]; + Responses?: + | (Omit & { + Error?: + | (Omit & { + Item?: Record | undefined; + }) + | undefined; + Item?: Record | undefined; + })[] + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts index def798d0a011..b4a371ff9f43 100644 --- a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts @@ -30,13 +30,15 @@ export type BatchGetCommandInput = Omit<__BatchGetItemCommandInput, "RequestItem * @public */ export type BatchGetCommandOutput = Omit<__BatchGetItemCommandOutput, "Responses" | "UnprocessedKeys"> & { - Responses?: Record[]>; - UnprocessedKeys?: Record< - string, - Omit & { - Keys: Record[] | undefined; - } - >; + Responses?: Record[]> | undefined; + UnprocessedKeys?: + | Record< + string, + Omit & { + Keys: Record[] | undefined; + } + > + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts index 9de56da1658b..c82b5fbcc600 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; @@ -38,23 +42,31 @@ export type BatchWriteCommandOutput = Omit< __BatchWriteItemCommandOutput, "UnprocessedItems" | "ItemCollectionMetrics" > & { - UnprocessedItems?: Record< - string, - (Omit & { - PutRequest?: Omit & { - Item: Record | undefined; - }; - DeleteRequest?: Omit & { - Key: Record | undefined; - }; - })[] - >; - ItemCollectionMetrics?: Record< - string, - (Omit & { - ItemCollectionKey?: Record; - })[] - >; + UnprocessedItems?: + | Record< + string, + (Omit & { + PutRequest?: + | (Omit & { + Item: Record | undefined; + }) + | undefined; + DeleteRequest?: + | (Omit & { + Key: Record | undefined; + }) + | undefined; + })[] + > + | undefined; + ItemCollectionMetrics?: + | Record< + string, + (Omit & { + ItemCollectionKey?: Record | undefined; + })[] + > + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/DeleteCommand.ts b/lib/lib-dynamodb/src/commands/DeleteCommand.ts index f6d6e32a15bf..5b7e0161b1a6 100644 --- a/lib/lib-dynamodb/src/commands/DeleteCommand.ts +++ b/lib/lib-dynamodb/src/commands/DeleteCommand.ts @@ -17,24 +17,28 @@ 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 | undefined; + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** * @public */ export type DeleteCommandOutput = Omit<__DeleteItemCommandOutput, "Attributes" | "ItemCollectionMetrics"> & { - Attributes?: Record; - ItemCollectionMetrics?: Omit & { - ItemCollectionKey?: Record; - }; + Attributes?: Record | undefined; + ItemCollectionMetrics?: + | (Omit & { + ItemCollectionKey?: Record | undefined; + }) + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts index 81f0aae6227d..3c06c973948c 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts @@ -16,15 +16,15 @@ export { DynamoDBDocumentClientCommand, $Command }; * @public */ export type ExecuteStatementCommandInput = Omit<__ExecuteStatementCommandInput, "Parameters"> & { - Parameters?: NativeAttributeValue[]; + Parameters?: NativeAttributeValue[] | undefined; }; /** * @public */ export type ExecuteStatementCommandOutput = Omit<__ExecuteStatementCommandOutput, "Items" | "LastEvaluatedKey"> & { - Items?: Record[]; - LastEvaluatedKey?: Record; + Items?: Record[] | undefined; + LastEvaluatedKey?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts index 6e7d40beefc9..4f8831742b2a 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; }; @@ -27,9 +27,11 @@ export type ExecuteTransactionCommandInput = Omit<__ExecuteTransactionCommandInp * @public */ export type ExecuteTransactionCommandOutput = Omit<__ExecuteTransactionCommandOutput, "Responses"> & { - Responses?: (Omit & { - Item?: Record; - })[]; + Responses?: + | (Omit & { + Item?: Record | undefined; + })[] + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/GetCommand.ts b/lib/lib-dynamodb/src/commands/GetCommand.ts index 8f46b914210b..b3edd17328e6 100644 --- a/lib/lib-dynamodb/src/commands/GetCommand.ts +++ b/lib/lib-dynamodb/src/commands/GetCommand.ts @@ -23,7 +23,7 @@ export type GetCommandInput = Omit<__GetItemCommandInput, "Key"> & { * @public */ export type GetCommandOutput = Omit<__GetItemCommandOutput, "Item"> & { - Item?: Record; + Item?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/PutCommand.ts b/lib/lib-dynamodb/src/commands/PutCommand.ts index 8e345adbb607..1099c1a93585 100644 --- a/lib/lib-dynamodb/src/commands/PutCommand.ts +++ b/lib/lib-dynamodb/src/commands/PutCommand.ts @@ -17,24 +17,28 @@ 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; }; /** * @public */ export type PutCommandOutput = Omit<__PutItemCommandOutput, "Attributes" | "ItemCollectionMetrics"> & { - Attributes?: Record; - ItemCollectionMetrics?: Omit & { - ItemCollectionKey?: Record; - }; + Attributes?: Record | undefined; + ItemCollectionMetrics?: + | (Omit & { + ItemCollectionKey?: Record | undefined; + }) + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/QueryCommand.ts b/lib/lib-dynamodb/src/commands/QueryCommand.ts index 726d6a998b10..c917d55763eb 100644 --- a/lib/lib-dynamodb/src/commands/QueryCommand.ts +++ b/lib/lib-dynamodb/src/commands/QueryCommand.ts @@ -19,28 +19,32 @@ 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; }; /** * @public */ export type QueryCommandOutput = Omit<__QueryCommandOutput, "Items" | "LastEvaluatedKey"> & { - Items?: Record[]; - LastEvaluatedKey?: Record; + Items?: Record[] | undefined; + LastEvaluatedKey?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/ScanCommand.ts b/lib/lib-dynamodb/src/commands/ScanCommand.ts index ffe1e23829d9..d407bc8b9891 100644 --- a/lib/lib-dynamodb/src/commands/ScanCommand.ts +++ b/lib/lib-dynamodb/src/commands/ScanCommand.ts @@ -19,22 +19,24 @@ 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; }; /** * @public */ export type ScanCommandOutput = Omit<__ScanCommandOutput, "Items" | "LastEvaluatedKey"> & { - Items?: Record[]; - LastEvaluatedKey?: Record; + Items?: Record[] | undefined; + LastEvaluatedKey?: Record | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts index 389739d5626d..ef14b69d9ad8 100644 --- a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts @@ -31,9 +31,11 @@ export type TransactGetCommandInput = Omit<__TransactGetItemsCommandInput, "Tran * @public */ export type TransactGetCommandOutput = Omit<__TransactGetItemsCommandOutput, "Responses"> & { - Responses?: (Omit & { - Item?: Record; - })[]; + Responses?: + | (Omit & { + Item?: Record | undefined; + })[] + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts index 79e3cc2af2f2..651b8858d93b 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; }; @@ -42,12 +50,14 @@ export type TransactWriteCommandInput = Omit<__TransactWriteItemsCommandInput, " * @public */ export type TransactWriteCommandOutput = Omit<__TransactWriteItemsCommandOutput, "ItemCollectionMetrics"> & { - ItemCollectionMetrics?: Record< - string, - (Omit & { - ItemCollectionKey?: Record; - })[] - >; + ItemCollectionMetrics?: + | Record< + string, + (Omit & { + ItemCollectionKey?: Record | undefined; + })[] + > + | undefined; }; /** diff --git a/lib/lib-dynamodb/src/commands/UpdateCommand.ts b/lib/lib-dynamodb/src/commands/UpdateCommand.ts index 11e3b65be7c4..99a13664364a 100644 --- a/lib/lib-dynamodb/src/commands/UpdateCommand.ts +++ b/lib/lib-dynamodb/src/commands/UpdateCommand.ts @@ -20,30 +20,36 @@ 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; + } + > + | undefined; + Expected?: + | Record< + string, + Omit & { + Value?: NativeAttributeValue | undefined; + AttributeValueList?: NativeAttributeValue[] | undefined; + } + > + | undefined; + ExpressionAttributeValues?: Record | undefined; }; /** * @public */ export type UpdateCommandOutput = Omit<__UpdateItemCommandOutput, "Attributes" | "ItemCollectionMetrics"> & { - Attributes?: Record; - ItemCollectionMetrics?: Omit & { - ItemCollectionKey?: Record; - }; + Attributes?: Record | undefined; + ItemCollectionMetrics?: + | (Omit & { + ItemCollectionKey?: Record | undefined; + }) + | undefined; }; /**