From 4b90b308d7554ecfe0e7814b6fcd5dde603d4dda Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 15:10:26 +0000 Subject: [PATCH 1/7] chore: update smithy hash --- .../amazon/smithy/aws/typescript/codegen/AwsRestXml.java | 2 +- scripts/generate-clients/config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 707cb0ff6f43..1044af24b46a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -187,7 +187,7 @@ private void serializeDocumentBody( String xmlDeclVar = context.getStringStore().var(""); writer.write("body = $L;", xmlDeclVar); - writer.addImport("XmlNode", "__XmlNode", "@aws-sdk/xml-builder"); + writer.addImport("XmlNode", "__XmlNode", AwsDependency.XML_BUILDER); // Handle the @xmlName trait for the input shape. StructureShape inputShape = context.getModel().expectShape(inputShapeId, StructureShape.class); diff --git a/scripts/generate-clients/config.js b/scripts/generate-clients/config.js index 30640d8cbc35..1bb0dfb3ee17 100644 --- a/scripts/generate-clients/config.js +++ b/scripts/generate-clients/config.js @@ -1,7 +1,7 @@ // Update this commit when taking up new changes from smithy-typescript. module.exports = { // Use full commit hash as we explicitly fetch it. - SMITHY_TS_COMMIT: "6e4f8d45234f51eb56a58db6113797d034bfb855", + SMITHY_TS_COMMIT: "cad7ae02e13a97ea11147ca391d78db3fa275008", }; if (module.exports.SMITHY_TS_COMMIT.length < 40) { From 06ff26bc3cb29c31530bad02911c03b8ea49c145 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 15:28:49 +0000 Subject: [PATCH 2/7] chore: client-dynamodb compatibility with checked imports --- .../smithy/aws/typescript/codegen/AwsDependency.java | 6 +++++- .../codegen/DocumentAggregatedClientGenerator.java | 4 ++-- .../codegen/DocumentBareBonesClientGenerator.java | 10 +++++----- .../codegen/DocumentClientCommandGenerator.java | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java index 96a2248c253b..6fb98c3d299c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java @@ -93,7 +93,11 @@ public enum AwsDependency implements Dependency { // feat(experimentalIdentityAndAuth): Conditionally added when @httpBearerAuth is used in an AWS service TOKEN_PROVIDERS(NORMAL_DEPENDENCY, "@aws-sdk/token-providers"), TYPES(NORMAL_DEPENDENCY, "@aws-sdk/types"), - REGION_CONFIG_RESOLVER(NORMAL_DEPENDENCY, "@aws-sdk/region-config-resolver"); + REGION_CONFIG_RESOLVER(NORMAL_DEPENDENCY, "@aws-sdk/region-config-resolver"), + + CLIENT_DYNAMODB_PEER(PEER_DEPENDENCY, "@aws-sdk/client-dynamodb", "^3.0.0"), + UTIL_DYNAMODB(PEER_DEPENDENCY, "@aws-sdk/util-dynamodb", "*"); + public final String packageName; public final String version; diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java index b832cbd76b8e..a614b81e0234 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java @@ -77,8 +77,8 @@ public void run() { private void generateStaticFactoryFrom() { String translateConfig = DocumentClientUtils.CLIENT_TRANSLATE_CONFIG_TYPE; - writer.addImport(serviceName, serviceName, "@aws-sdk/client-dynamodb"); - writer.addImport(translateConfig, translateConfig, Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString()); + writer.addImport(serviceName, serviceName, AwsDependency.CLIENT_DYNAMODB_PEER); + writer.addRelativeImport(translateConfig, translateConfig, Paths.get(".", DocumentClientUtils.CLIENT_NAME)); writer.openBlock("static from(client: $L, translateConfig?: $L) {", "}", serviceName, translateConfig, () -> { writer.write("return new $L(client, translateConfig);", DocumentClientUtils.CLIENT_FULL_NAME); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java index 72e45fdd4f23..3ef078fb6d14 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java @@ -69,8 +69,8 @@ public void run() { String serviceOutputTypes = "ServiceOutputTypes"; // Add required imports. - writer.addImport(serviceName, serviceName, "@aws-sdk/client-dynamodb"); - writer.addImport(configType, configType, "@aws-sdk/client-dynamodb"); + writer.addImport(serviceName, serviceName, AwsDependency.CLIENT_DYNAMODB_PEER); + writer.addImport(configType, configType, AwsDependency.CLIENT_DYNAMODB_PEER); writer.addImport("Client", "__Client", TypeScriptDependency.AWS_SMITHY_CLIENT); writer.writeDocs("@public"); writer.write("export { __Client };"); @@ -101,8 +101,8 @@ public void run() { } private void generateInputOutputImports(String serviceInputTypes, String serviceOutputTypes) { - writer.addImport(serviceInputTypes, String.format("__%s", serviceInputTypes), "@aws-sdk/client-dynamodb"); - writer.addImport(serviceOutputTypes, String.format("__%s", serviceOutputTypes), "@aws-sdk/client-dynamodb"); + writer.addImport(serviceInputTypes, String.format("__%s", serviceInputTypes), AwsDependency.CLIENT_DYNAMODB_PEER); + writer.addImport(serviceOutputTypes, String.format("__%s", serviceOutputTypes), AwsDependency.CLIENT_DYNAMODB_PEER); Set containedOperations = new TreeSet<>(TopDownIndex.of(model).getContainedOperations(service)); @@ -199,7 +199,7 @@ private void generateConfiguration() { } private void generateTranslateConfigOption(String translateOption) { - writer.addImport(translateOption, translateOption, "@aws-sdk/util-dynamodb"); + writer.addImport(translateOption, translateOption, AwsDependency.UTIL_DYNAMODB); writer.write("${1L}?: ${1L};", translateOption); } } 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 833e6525d61b..4acb84e3118f 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 @@ -194,7 +194,7 @@ private void generateCommandMiddlewareResolver(String configType) { .dedent(); writer.openBlock("): $L<$L, $L> {", "}", handler, inputTypeName, outputTypeName, () -> { - writer.addImport(clientCommandClassName, clientCommandLocalName, "@aws-sdk/client-dynamodb"); + writer.addImport(clientCommandClassName, clientCommandLocalName, AwsDependency.CLIENT_DYNAMODB_PEER); String commandVarName = "this.clientCommand"; @@ -312,7 +312,7 @@ private void writeType( ) { writer.writeDocs("@public"); if (optionalShape.isPresent()) { - writer.addImport(originalTypeName, "__" + originalTypeName, "@aws-sdk/client-dynamodb"); + writer.addImport(originalTypeName, "__" + originalTypeName, AwsDependency.CLIENT_DYNAMODB_PEER); if (membersWithAttr.isEmpty()) { writer.write("export type $L = __$L;", typeName, originalTypeName); } else { @@ -339,7 +339,7 @@ private void writeStructureOmitType(StructureShape structureTarget) { .map(memberWithAttr -> "'" + symbolProvider.toMemberName(memberWithAttr) + "'") .collect(Collectors.joining(" | ")); String typeNameToOmit = symbolProvider.toSymbol(structureTarget).getName(); - writer.addImport(typeNameToOmit, typeNameToOmit, "@aws-sdk/client-dynamodb"); + writer.addImport(typeNameToOmit, typeNameToOmit, AwsDependency.CLIENT_DYNAMODB_PEER); writer.openBlock("Omit<$L, $L> & {", "}", typeNameToOmit, memberUnionToOmit, () -> { for (MemberShape memberWithAttr: membersWithAttr) { @@ -387,7 +387,7 @@ private void writeMemberOmitType(MemberShape member) { private void writeNativeAttributeValue() { String nativeAttributeValue = "NativeAttributeValue"; - writer.addImport(nativeAttributeValue, nativeAttributeValue, "@aws-sdk/util-dynamodb"); + writer.addImport(nativeAttributeValue, nativeAttributeValue, AwsDependency.UTIL_DYNAMODB); writer.write(nativeAttributeValue); } From 058efb06d6ad0e8bfe0a5e0d0b1c755f71c3d9d7 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 15:35:33 +0000 Subject: [PATCH 3/7] chore: fix document client codegen --- .../codegen/AddDocumentClientPlugin.java | 9 ++- .../aws/typescript/codegen/AwsDependency.java | 2 +- .../DocumentAggregatedClientGenerator.java | 9 ++- .../DocumentBareBonesClientGenerator.java | 16 +++-- .../DocumentClientCommandGenerator.java | 64 ++++++++++++++++--- .../DocumentClientPaginationGenerator.java | 27 ++++---- lib/lib-dynamodb/src/index.ts | 1 + 7 files changed, 95 insertions(+), 33 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java index 5a3b9ac4e87b..0be1795e0373 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java @@ -48,6 +48,8 @@ public void customize(TypeScriptCodegenContext codegenContext) { SymbolProvider symbolProvider = codegenContext.symbolProvider(); BiConsumer> writerFactory = codegenContext.writerDelegator()::useFileWriter; + codegenContext.writerDelegator(); + writeAdditionalFiles(settings, model, symbolProvider, writerFactory); } @@ -123,7 +125,12 @@ private void writeAdditionalFiles( writer.write("export * from './pagination';"); writer.write("export * from './$L';", DocumentClientUtils.CLIENT_NAME); writer.write("export * from './$L';", DocumentClientUtils.CLIENT_FULL_NAME); - writer.write("export { NumberValueImpl as NumberValue } from \"@aws-sdk/util-dynamodb\";"); + writer.write(""); + writer.write(""" + export { NumberValueImpl as NumberValue } from "@aws-sdk/util-dynamodb"; + export { marshallOptions, unmarshallOptions } from "@aws-sdk/util-dynamodb"; + export { NativeAttributeValue, NativeAttributeBinary, NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb"; + """); }); } } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java index 6fb98c3d299c..d2fdfc726678 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java @@ -96,7 +96,7 @@ public enum AwsDependency implements Dependency { REGION_CONFIG_RESOLVER(NORMAL_DEPENDENCY, "@aws-sdk/region-config-resolver"), CLIENT_DYNAMODB_PEER(PEER_DEPENDENCY, "@aws-sdk/client-dynamodb", "^3.0.0"), - UTIL_DYNAMODB(PEER_DEPENDENCY, "@aws-sdk/util-dynamodb", "*"); + UTIL_DYNAMODB(NORMAL_DEPENDENCY, "@aws-sdk/util-dynamodb", "*"); public final String packageName; diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java index a614b81e0234..38945367f15f 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentAggregatedClientGenerator.java @@ -63,8 +63,12 @@ final class DocumentAggregatedClientGenerator implements Runnable { @Override public void run() { - writer.addImport(DocumentClientUtils.CLIENT_NAME, - DocumentClientUtils.CLIENT_NAME, Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString()); + // Note: using addImport would register this dependency on the dynamodb client, which must be avoided. + writer.write(""" + import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; + """); + writer.addRelativeImport(DocumentClientUtils.CLIENT_NAME, + DocumentClientUtils.CLIENT_NAME, Paths.get(".", DocumentClientUtils.CLIENT_NAME)); writer.writeDocs(DocumentClientUtils.getClientDocs()); writer.openBlock("export class $L extends $L {", "}", DocumentClientUtils.CLIENT_FULL_NAME, DocumentClientUtils.CLIENT_NAME, () -> { @@ -77,7 +81,6 @@ public void run() { private void generateStaticFactoryFrom() { String translateConfig = DocumentClientUtils.CLIENT_TRANSLATE_CONFIG_TYPE; - writer.addImport(serviceName, serviceName, AwsDependency.CLIENT_DYNAMODB_PEER); writer.addRelativeImport(translateConfig, translateConfig, Paths.get(".", DocumentClientUtils.CLIENT_NAME)); writer.openBlock("static from(client: $L, translateConfig?: $L) {", "}", serviceName, translateConfig, () -> { diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java index 3ef078fb6d14..7ed48fd93bf6 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentBareBonesClientGenerator.java @@ -69,8 +69,17 @@ public void run() { String serviceOutputTypes = "ServiceOutputTypes"; // Add required imports. - writer.addImport(serviceName, serviceName, AwsDependency.CLIENT_DYNAMODB_PEER); - writer.addImport(configType, configType, AwsDependency.CLIENT_DYNAMODB_PEER); + // Note: using addImport would register these dependencies on the dynamodb client, which must be avoided. + writer.write(""" + import { + DynamoDBClient, + DynamoDBClientResolvedConfig, + ServiceInputTypes as __ServiceInputTypes, + ServiceOutputTypes as __ServiceOutputTypes, + } from "@aws-sdk/client-dynamodb"; + import { marshallOptions, unmarshallOptions } from "@aws-sdk/util-dynamodb"; + """); + writer.addImport("Client", "__Client", TypeScriptDependency.AWS_SMITHY_CLIENT); writer.writeDocs("@public"); writer.write("export { __Client };"); @@ -101,8 +110,6 @@ public void run() { } private void generateInputOutputImports(String serviceInputTypes, String serviceOutputTypes) { - writer.addImport(serviceInputTypes, String.format("__%s", serviceInputTypes), AwsDependency.CLIENT_DYNAMODB_PEER); - writer.addImport(serviceOutputTypes, String.format("__%s", serviceOutputTypes), AwsDependency.CLIENT_DYNAMODB_PEER); Set containedOperations = new TreeSet<>(TopDownIndex.of(model).getContainedOperations(service)); @@ -199,7 +206,6 @@ private void generateConfiguration() { } private void generateTranslateConfigOption(String translateOption) { - writer.addImport(translateOption, translateOption, AwsDependency.UTIL_DYNAMODB); writer.write("${1L}?: ${1L};", translateOption); } } 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 4acb84e3118f..fd07b4fd5663 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 @@ -15,11 +15,14 @@ package software.amazon.smithy.aws.typescript.codegen; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Optional; +import java.util.TreeMap; import java.util.stream.Collectors; import software.amazon.smithy.codegen.core.CodegenException; import software.amazon.smithy.codegen.core.Symbol; @@ -62,6 +65,7 @@ final class DocumentClientCommandGenerator implements Runnable { private final List outputMembersWithAttr; private final String clientCommandClassName; private final String clientCommandLocalName; + private final Map> orderedUncheckedImports = new TreeMap<>(); DocumentClientCommandGenerator( TypeScriptSettings settings, @@ -97,12 +101,21 @@ final class DocumentClientCommandGenerator implements Runnable { @Override public void run() { - String servicePath = Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString(); + Path servicePath = Paths.get(".", DocumentClientUtils.CLIENT_NAME); String configType = DocumentClientUtils.CLIENT_CONFIG_NAME; + // Note: using addImport would register these dependencies on the dynamodb client, which must be avoided. + writer.write(""" + import { %s as %s } from "%s"; + """.formatted( + clientCommandClassName, + clientCommandLocalName, + AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() + ) + ); // Add required imports. - writer.addImport(configType, configType, servicePath); + writer.addRelativeImport(configType, configType, servicePath); writer.addImport( "DynamoDBDocumentClientCommand", "DynamoDBDocumentClientCommand", @@ -159,6 +172,18 @@ public void run() { writer.pushState(COMMAND_BODY_EXTRA_SECTION).popState(); } ); + + for (List uncheckedImport : orderedUncheckedImports.values()) { + // Note: using addImport would register these dependencies on the dynamodb client, which must be avoided. + writer.write(""" + import { %s as %s } from "%s"; + """.formatted( + uncheckedImport.get(0), + uncheckedImport.get(1), + uncheckedImport.get(2) + ) + ); + } } private void generateCommandConstructor() { @@ -180,9 +205,9 @@ private void generateCommandMiddlewareResolver(String configType) { String handler = "Handler"; String middlewareStack = "MiddlewareStack"; - String servicePath = Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString(); - writer.addImport(serviceInputTypes, serviceInputTypes, servicePath); - writer.addImport(serviceOutputTypes, serviceOutputTypes, servicePath); + Path servicePath = Paths.get(".", DocumentClientUtils.CLIENT_NAME); + writer.addRelativeImport(serviceInputTypes, serviceInputTypes, servicePath); + writer.addRelativeImport(serviceOutputTypes, serviceOutputTypes, servicePath); writer.addImport(handler, handler, TypeScriptDependency.SMITHY_TYPES); writer.addImport(middlewareStack, middlewareStack, TypeScriptDependency.SMITHY_TYPES); @@ -194,8 +219,6 @@ private void generateCommandMiddlewareResolver(String configType) { .dedent(); writer.openBlock("): $L<$L, $L> {", "}", handler, inputTypeName, outputTypeName, () -> { - writer.addImport(clientCommandClassName, clientCommandLocalName, AwsDependency.CLIENT_DYNAMODB_PEER); - String commandVarName = "this.clientCommand"; // marshall middlewares @@ -312,7 +335,14 @@ private void writeType( ) { writer.writeDocs("@public"); if (optionalShape.isPresent()) { - writer.addImport(originalTypeName, "__" + originalTypeName, AwsDependency.CLIENT_DYNAMODB_PEER); + orderedUncheckedImports.put( + originalTypeName + "-c", + List.of( + originalTypeName, + "__" + originalTypeName, + AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() + ) + ); if (membersWithAttr.isEmpty()) { writer.write("export type $L = __$L;", typeName, originalTypeName); } else { @@ -339,7 +369,14 @@ private void writeStructureOmitType(StructureShape structureTarget) { .map(memberWithAttr -> "'" + symbolProvider.toMemberName(memberWithAttr) + "'") .collect(Collectors.joining(" | ")); String typeNameToOmit = symbolProvider.toSymbol(structureTarget).getName(); - writer.addImport(typeNameToOmit, typeNameToOmit, AwsDependency.CLIENT_DYNAMODB_PEER); + orderedUncheckedImports.put( + typeNameToOmit + "-c", + List.of( + typeNameToOmit, + typeNameToOmit, + AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() + ) + ); writer.openBlock("Omit<$L, $L> & {", "}", typeNameToOmit, memberUnionToOmit, () -> { for (MemberShape memberWithAttr: membersWithAttr) { @@ -387,7 +424,14 @@ private void writeMemberOmitType(MemberShape member) { private void writeNativeAttributeValue() { String nativeAttributeValue = "NativeAttributeValue"; - writer.addImport(nativeAttributeValue, nativeAttributeValue, AwsDependency.UTIL_DYNAMODB); + orderedUncheckedImports.put( + nativeAttributeValue + "-u", + List.of( + nativeAttributeValue, + nativeAttributeValue, + AwsDependency.UTIL_DYNAMODB.getPackageName() + ) + ); writer.write(nativeAttributeValue); } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientPaginationGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientPaginationGenerator.java index 5c5d2e709620..83be25f02076 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientPaginationGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientPaginationGenerator.java @@ -15,6 +15,7 @@ package software.amazon.smithy.aws.typescript.codegen; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; import software.amazon.smithy.codegen.core.CodegenException; @@ -77,20 +78,20 @@ final class DocumentClientPaginationGenerator implements Runnable { @Override public void run() { // Import Service Types - String commandFileLocation = Paths.get(".", DocumentClientUtils.CLIENT_COMMANDS_FOLDER, - DocumentClientUtils.getModifiedName(operationTypeName)).toString(); - writer.addImport(operationTypeName, operationTypeName, commandFileLocation); - writer.addImport(inputTypeName, inputTypeName, commandFileLocation); - writer.addImport(outputTypeName, outputTypeName, commandFileLocation); - writer.addImport( + Path commandFileLocation = Paths.get(".", DocumentClientUtils.CLIENT_COMMANDS_FOLDER, + DocumentClientUtils.getModifiedName(operationTypeName)); + writer.addRelativeImport(operationTypeName, operationTypeName, commandFileLocation); + writer.addRelativeImport(inputTypeName, inputTypeName, commandFileLocation); + writer.addRelativeImport(outputTypeName, outputTypeName, commandFileLocation); + writer.addRelativeImport( DocumentClientUtils.CLIENT_NAME, DocumentClientUtils.CLIENT_NAME, - Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString()); + Paths.get(".", DocumentClientUtils.CLIENT_NAME)); // Import Pagination types writer.addImport("Paginator", "Paginator", TypeScriptDependency.SMITHY_TYPES); - writer.addImport(paginationType, paginationType, - Paths.get(".", getInterfaceFilelocation().replace(".ts", "")).toString()); + writer.addRelativeImport(paginationType, paginationType, + Paths.get(".", getInterfaceFilelocation().replace(".ts", ""))); writer.writeDocs("@public"); writer.write("export { Paginator }"); @@ -113,14 +114,14 @@ static String getInterfaceFilelocation() { static void generateServicePaginationInterfaces(TypeScriptWriter writer) { writer.addImport("PaginationConfiguration", "PaginationConfiguration", TypeScriptDependency.SMITHY_TYPES); - writer.addImport( + writer.addRelativeImport( DocumentClientUtils.CLIENT_NAME, DocumentClientUtils.CLIENT_NAME, - Paths.get(".", DocumentClientUtils.CLIENT_NAME).toString()); - writer.addImport( + Paths.get(".", DocumentClientUtils.CLIENT_NAME)); + writer.addRelativeImport( DocumentClientUtils.CLIENT_FULL_NAME, DocumentClientUtils.CLIENT_FULL_NAME, - Paths.get(".", DocumentClientUtils.CLIENT_FULL_NAME).toString()); + Paths.get(".", DocumentClientUtils.CLIENT_FULL_NAME)); writer.writeDocs("@public"); writer.write("export { PaginationConfiguration };"); diff --git a/lib/lib-dynamodb/src/index.ts b/lib/lib-dynamodb/src/index.ts index b2ecf376c43a..07c755ee5cbd 100644 --- a/lib/lib-dynamodb/src/index.ts +++ b/lib/lib-dynamodb/src/index.ts @@ -4,6 +4,7 @@ export * from "./DynamoDBDocumentClient"; // smithy-typescript generated code export * from "./commands"; export * from "./pagination"; + export { NumberValueImpl as NumberValue } from "@aws-sdk/util-dynamodb"; export { marshallOptions, unmarshallOptions } from "@aws-sdk/util-dynamodb"; export { NativeAttributeValue, NativeAttributeBinary, NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb"; From 3da87f7d6f2de3975a4266933249042459641b85 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 17:21:20 +0000 Subject: [PATCH 4/7] chore: codegen for lib-dynamodb --- .../commands/BatchExecuteStatementCommand.ts | 16 ++++++-------- .../src/commands/BatchGetCommand.ts | 12 +++++----- .../src/commands/BatchWriteCommand.ts | 18 +++++++-------- .../src/commands/DeleteCommand.ts | 14 +++++------- .../src/commands/ExecuteStatementCommand.ts | 10 ++++----- .../src/commands/ExecuteTransactionCommand.ts | 14 +++++------- lib/lib-dynamodb/src/commands/GetCommand.ts | 10 ++++----- lib/lib-dynamodb/src/commands/PutCommand.ts | 14 +++++------- lib/lib-dynamodb/src/commands/QueryCommand.ts | 12 +++++----- lib/lib-dynamodb/src/commands/ScanCommand.ts | 12 +++++----- .../src/commands/TransactGetCommand.ts | 16 ++++++-------- .../src/commands/TransactWriteCommand.ts | 22 +++++++++---------- .../src/commands/UpdateCommand.ts | 16 ++++++-------- 13 files changed, 80 insertions(+), 106 deletions(-) diff --git a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts index 91f035e392b8..447b25741d15 100644 --- a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts @@ -1,13 +1,5 @@ // smithy-typescript generated code -import { - BatchExecuteStatementCommand as __BatchExecuteStatementCommand, - BatchExecuteStatementCommandInput as __BatchExecuteStatementCommandInput, - BatchExecuteStatementCommandOutput as __BatchExecuteStatementCommandOutput, - BatchStatementError, - BatchStatementRequest, - BatchStatementResponse, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { BatchExecuteStatementCommand as __BatchExecuteStatementCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -104,3 +96,9 @@ export class BatchExecuteStatementCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { BatchExecuteStatementCommandInput as __BatchExecuteStatementCommandInput } from "@aws-sdk/client-dynamodb"; +import { BatchExecuteStatementCommandOutput as __BatchExecuteStatementCommandOutput } from "@aws-sdk/client-dynamodb"; +import { BatchStatementError as BatchStatementError } from "@aws-sdk/client-dynamodb"; +import { BatchStatementRequest as BatchStatementRequest } from "@aws-sdk/client-dynamodb"; +import { BatchStatementResponse as BatchStatementResponse } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts index 3441f23fbe3b..0376c75b66df 100644 --- a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts @@ -1,11 +1,5 @@ // smithy-typescript generated code -import { - BatchGetItemCommand as __BatchGetItemCommand, - BatchGetItemCommandInput as __BatchGetItemCommandInput, - BatchGetItemCommandOutput as __BatchGetItemCommandOutput, - KeysAndAttributes, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { BatchGetItemCommand as __BatchGetItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -112,3 +106,7 @@ export class BatchGetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { BatchGetItemCommandInput as __BatchGetItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { BatchGetItemCommandOutput as __BatchGetItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { KeysAndAttributes as KeysAndAttributes } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts index 7ad13815f714..b0319a99c73f 100644 --- a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts @@ -1,14 +1,5 @@ // smithy-typescript generated code -import { - BatchWriteItemCommand as __BatchWriteItemCommand, - BatchWriteItemCommandInput as __BatchWriteItemCommandInput, - BatchWriteItemCommandOutput as __BatchWriteItemCommandOutput, - DeleteRequest, - ItemCollectionMetrics, - PutRequest, - WriteRequest, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { BatchWriteItemCommand as __BatchWriteItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -145,3 +136,10 @@ export class BatchWriteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { BatchWriteItemCommandInput as __BatchWriteItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { BatchWriteItemCommandOutput as __BatchWriteItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { DeleteRequest as DeleteRequest } from "@aws-sdk/client-dynamodb"; +import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; +import { PutRequest as PutRequest } from "@aws-sdk/client-dynamodb"; +import { WriteRequest as WriteRequest } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/DeleteCommand.ts b/lib/lib-dynamodb/src/commands/DeleteCommand.ts index 36537394788b..4b621fdaced8 100644 --- a/lib/lib-dynamodb/src/commands/DeleteCommand.ts +++ b/lib/lib-dynamodb/src/commands/DeleteCommand.ts @@ -1,12 +1,5 @@ // smithy-typescript generated code -import { - DeleteItemCommand as __DeleteItemCommand, - DeleteItemCommandInput as __DeleteItemCommandInput, - DeleteItemCommandOutput as __DeleteItemCommandOutput, - ExpectedAttributeValue, - ItemCollectionMetrics, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { DeleteItemCommand as __DeleteItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -104,3 +97,8 @@ export class DeleteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { DeleteItemCommandInput as __DeleteItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { DeleteItemCommandOutput as __DeleteItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; +import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts index 6a8328e786f6..899297d2ce9e 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts @@ -1,10 +1,5 @@ // smithy-typescript generated code -import { - ExecuteStatementCommand as __ExecuteStatementCommand, - ExecuteStatementCommandInput as __ExecuteStatementCommandInput, - ExecuteStatementCommandOutput as __ExecuteStatementCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { ExecuteStatementCommand as __ExecuteStatementCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -85,3 +80,6 @@ export class ExecuteStatementCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { ExecuteStatementCommandInput as __ExecuteStatementCommandInput } from "@aws-sdk/client-dynamodb"; +import { ExecuteStatementCommandOutput as __ExecuteStatementCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts index de06a1f0ad3a..8468de78a06d 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts @@ -1,12 +1,5 @@ // smithy-typescript generated code -import { - ExecuteTransactionCommand as __ExecuteTransactionCommand, - ExecuteTransactionCommandInput as __ExecuteTransactionCommandInput, - ExecuteTransactionCommandOutput as __ExecuteTransactionCommandOutput, - ItemResponse, - ParameterizedStatement, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { ExecuteTransactionCommand as __ExecuteTransactionCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -97,3 +90,8 @@ export class ExecuteTransactionCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { ExecuteTransactionCommandInput as __ExecuteTransactionCommandInput } from "@aws-sdk/client-dynamodb"; +import { ExecuteTransactionCommandOutput as __ExecuteTransactionCommandOutput } from "@aws-sdk/client-dynamodb"; +import { ItemResponse as ItemResponse } from "@aws-sdk/client-dynamodb"; +import { ParameterizedStatement as ParameterizedStatement } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/GetCommand.ts b/lib/lib-dynamodb/src/commands/GetCommand.ts index 023003368bdb..a9f47a836b2e 100644 --- a/lib/lib-dynamodb/src/commands/GetCommand.ts +++ b/lib/lib-dynamodb/src/commands/GetCommand.ts @@ -1,10 +1,5 @@ // smithy-typescript generated code -import { - GetItemCommand as __GetItemCommand, - GetItemCommandInput as __GetItemCommandInput, - GetItemCommandOutput as __GetItemCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { GetItemCommand as __GetItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -81,3 +76,6 @@ export class GetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { GetItemCommandInput as __GetItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { GetItemCommandOutput as __GetItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/PutCommand.ts b/lib/lib-dynamodb/src/commands/PutCommand.ts index d8cf3a68f7a6..b5fa0df1fea9 100644 --- a/lib/lib-dynamodb/src/commands/PutCommand.ts +++ b/lib/lib-dynamodb/src/commands/PutCommand.ts @@ -1,12 +1,5 @@ // smithy-typescript generated code -import { - ExpectedAttributeValue, - ItemCollectionMetrics, - PutItemCommand as __PutItemCommand, - PutItemCommandInput as __PutItemCommandInput, - PutItemCommandOutput as __PutItemCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { PutItemCommand as __PutItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -104,3 +97,8 @@ export class PutCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; +import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; +import { PutItemCommandInput as __PutItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { PutItemCommandOutput as __PutItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/QueryCommand.ts b/lib/lib-dynamodb/src/commands/QueryCommand.ts index fb8c6d186b6f..032e5ad67a96 100644 --- a/lib/lib-dynamodb/src/commands/QueryCommand.ts +++ b/lib/lib-dynamodb/src/commands/QueryCommand.ts @@ -1,11 +1,5 @@ // smithy-typescript generated code -import { - Condition, - QueryCommand as __QueryCommand, - QueryCommandInput as __QueryCommandInput, - QueryCommandOutput as __QueryCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { QueryCommand as __QueryCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -113,3 +107,7 @@ export class QueryCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { Condition as Condition } from "@aws-sdk/client-dynamodb"; +import { QueryCommandInput as __QueryCommandInput } from "@aws-sdk/client-dynamodb"; +import { QueryCommandOutput as __QueryCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ScanCommand.ts b/lib/lib-dynamodb/src/commands/ScanCommand.ts index fbd433033863..19d198e2af14 100644 --- a/lib/lib-dynamodb/src/commands/ScanCommand.ts +++ b/lib/lib-dynamodb/src/commands/ScanCommand.ts @@ -1,11 +1,5 @@ // smithy-typescript generated code -import { - Condition, - ScanCommand as __ScanCommand, - ScanCommandInput as __ScanCommandInput, - ScanCommandOutput as __ScanCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { ScanCommand as __ScanCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -102,3 +96,7 @@ export class ScanCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { Condition as Condition } from "@aws-sdk/client-dynamodb"; +import { ScanCommandInput as __ScanCommandInput } from "@aws-sdk/client-dynamodb"; +import { ScanCommandOutput as __ScanCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts index ce9688fe5add..cad98483ce07 100644 --- a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts @@ -1,13 +1,5 @@ // smithy-typescript generated code -import { - Get, - ItemResponse, - TransactGetItem, - TransactGetItemsCommand as __TransactGetItemsCommand, - TransactGetItemsCommandInput as __TransactGetItemsCommandInput, - TransactGetItemsCommandOutput as __TransactGetItemsCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { TransactGetItemsCommand as __TransactGetItemsCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -104,3 +96,9 @@ export class TransactGetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { Get as Get } from "@aws-sdk/client-dynamodb"; +import { ItemResponse as ItemResponse } from "@aws-sdk/client-dynamodb"; +import { TransactGetItem as TransactGetItem } from "@aws-sdk/client-dynamodb"; +import { TransactGetItemsCommandInput as __TransactGetItemsCommandInput } from "@aws-sdk/client-dynamodb"; +import { TransactGetItemsCommandOutput as __TransactGetItemsCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts index c486ee2f61a8..cba67016ee78 100644 --- a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts @@ -1,16 +1,5 @@ // smithy-typescript generated code -import { - ConditionCheck, - Delete, - ItemCollectionMetrics, - Put, - TransactWriteItem, - TransactWriteItemsCommand as __TransactWriteItemsCommand, - TransactWriteItemsCommandInput as __TransactWriteItemsCommandInput, - TransactWriteItemsCommandOutput as __TransactWriteItemsCommandOutput, - Update, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { TransactWriteItemsCommand as __TransactWriteItemsCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -136,3 +125,12 @@ export class TransactWriteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { ConditionCheck as ConditionCheck } from "@aws-sdk/client-dynamodb"; +import { Delete as Delete } from "@aws-sdk/client-dynamodb"; +import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; +import { Put as Put } from "@aws-sdk/client-dynamodb"; +import { TransactWriteItem as TransactWriteItem } from "@aws-sdk/client-dynamodb"; +import { TransactWriteItemsCommandInput as __TransactWriteItemsCommandInput } from "@aws-sdk/client-dynamodb"; +import { TransactWriteItemsCommandOutput as __TransactWriteItemsCommandOutput } from "@aws-sdk/client-dynamodb"; +import { Update as Update } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/UpdateCommand.ts b/lib/lib-dynamodb/src/commands/UpdateCommand.ts index 378f73a10449..a95deee3797b 100644 --- a/lib/lib-dynamodb/src/commands/UpdateCommand.ts +++ b/lib/lib-dynamodb/src/commands/UpdateCommand.ts @@ -1,13 +1,5 @@ // smithy-typescript generated code -import { - AttributeValueUpdate, - ExpectedAttributeValue, - ItemCollectionMetrics, - UpdateItemCommand as __UpdateItemCommand, - UpdateItemCommandInput as __UpdateItemCommandInput, - UpdateItemCommandOutput as __UpdateItemCommandOutput, -} from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; +import { UpdateItemCommand as __UpdateItemCommand } from "@aws-sdk/client-dynamodb"; import { Command as $Command } from "@smithy/smithy-client"; import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types"; @@ -119,3 +111,9 @@ export class UpdateCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } +import { AttributeValueUpdate as AttributeValueUpdate } from "@aws-sdk/client-dynamodb"; +import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; +import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; +import { UpdateItemCommandInput as __UpdateItemCommandInput } from "@aws-sdk/client-dynamodb"; +import { UpdateItemCommandOutput as __UpdateItemCommandOutput } from "@aws-sdk/client-dynamodb"; +import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; From 9e1b75463da32158bf85b28dc657306296644132 Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 17:40:46 +0000 Subject: [PATCH 5/7] chore: codegen sync --- private/weather-experimental-identity-and-auth/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/weather-experimental-identity-and-auth/package.json b/private/weather-experimental-identity-and-auth/package.json index dd83672025e7..27c05a1c6946 100644 --- a/private/weather-experimental-identity-and-auth/package.json +++ b/private/weather-experimental-identity-and-auth/package.json @@ -27,7 +27,7 @@ "@aws-sdk/util-user-agent-node": "*", "@smithy/config-resolver": "^2.2.0", "@smithy/core": "^1.4.2", - "@smithy/experimental-identity-and-auth": "^0.2.2", + "@smithy/experimental-identity-and-auth": "^0.2.3", "@smithy/fetch-http-handler": "^2.5.0", "@smithy/hash-node": "^2.2.0", "@smithy/invalid-dependency": "^2.2.0", From 9536efc42501d7f7331859d906b2478170a6692b Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 19:02:40 +0000 Subject: [PATCH 6/7] chore: codegen for lib-dynamodb --- .../codegen/AddDocumentClientPlugin.java | 2 - .../DocumentClientCommandGenerator.java | 74 ++++++++++--------- .../commands/BatchExecuteStatementCommand.ts | 15 ++-- .../src/commands/BatchGetCommand.ts | 11 ++- .../src/commands/BatchWriteCommand.ts | 17 +++-- .../src/commands/DeleteCommand.ts | 13 ++-- .../src/commands/ExecuteStatementCommand.ts | 9 ++- .../src/commands/ExecuteTransactionCommand.ts | 13 ++-- lib/lib-dynamodb/src/commands/GetCommand.ts | 9 ++- lib/lib-dynamodb/src/commands/PutCommand.ts | 13 ++-- lib/lib-dynamodb/src/commands/QueryCommand.ts | 11 ++- lib/lib-dynamodb/src/commands/ScanCommand.ts | 11 ++- .../src/commands/TransactGetCommand.ts | 15 ++-- .../src/commands/TransactWriteCommand.ts | 21 +++--- .../src/commands/UpdateCommand.ts | 15 ++-- 15 files changed, 147 insertions(+), 102 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java index 0be1795e0373..fe8cc496b23e 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java @@ -48,8 +48,6 @@ public void customize(TypeScriptCodegenContext codegenContext) { SymbolProvider symbolProvider = codegenContext.symbolProvider(); BiConsumer> writerFactory = codegenContext.writerDelegator()::useFileWriter; - codegenContext.writerDelegator(); - writeAdditionalFiles(settings, model, symbolProvider, writerFactory); } 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 fd07b4fd5663..ffd8f1e7f296 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 @@ -65,7 +65,10 @@ final class DocumentClientCommandGenerator implements Runnable { private final List outputMembersWithAttr; private final String clientCommandClassName; private final String clientCommandLocalName; - private final Map> orderedUncheckedImports = new TreeMap<>(); + /** + * Map of package name to external:local name entries. + */ + private final Map> orderedUncheckedImports = new TreeMap<>(); DocumentClientCommandGenerator( TypeScriptSettings settings, @@ -173,17 +176,23 @@ public void run() { } ); - for (List uncheckedImport : orderedUncheckedImports.values()) { - // Note: using addImport would register these dependencies on the dynamodb client, which must be avoided. - writer.write(""" - import { %s as %s } from "%s"; - """.formatted( - uncheckedImport.get(0), - uncheckedImport.get(1), - uncheckedImport.get(2) - ) - ); - } + // Note: using addImport would register these dependencies on the dynamodb client, which must be avoided. + writer.write(""); + orderedUncheckedImports.forEach((dep, symbols) -> { + writer.openBlock("import type {", """ + } from "%s"; + """.formatted(dep), () -> { + symbols.forEach((externalName, localName) -> { + if (externalName.equals(localName)) { + writer.writeInline(localName).write(","); + } else { + writer.write(""" + %s as %s, + """.formatted(externalName, localName)); + } + }); + }); + }); } private void generateCommandConstructor() { @@ -335,13 +344,10 @@ private void writeType( ) { writer.writeDocs("@public"); if (optionalShape.isPresent()) { - orderedUncheckedImports.put( - originalTypeName + "-c", - List.of( - originalTypeName, - "__" + originalTypeName, - AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() - ) + registerTypeImport( + originalTypeName, + "__" + originalTypeName, + AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() ); if (membersWithAttr.isEmpty()) { writer.write("export type $L = __$L;", typeName, originalTypeName); @@ -369,13 +375,10 @@ private void writeStructureOmitType(StructureShape structureTarget) { .map(memberWithAttr -> "'" + symbolProvider.toMemberName(memberWithAttr) + "'") .collect(Collectors.joining(" | ")); String typeNameToOmit = symbolProvider.toSymbol(structureTarget).getName(); - orderedUncheckedImports.put( - typeNameToOmit + "-c", - List.of( - typeNameToOmit, - typeNameToOmit, - AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() - ) + registerTypeImport( + typeNameToOmit, + typeNameToOmit, + AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName() ); writer.openBlock("Omit<$L, $L> & {", "}", typeNameToOmit, memberUnionToOmit, () -> { @@ -424,13 +427,10 @@ private void writeMemberOmitType(MemberShape member) { private void writeNativeAttributeValue() { String nativeAttributeValue = "NativeAttributeValue"; - orderedUncheckedImports.put( - nativeAttributeValue + "-u", - List.of( - nativeAttributeValue, - nativeAttributeValue, - AwsDependency.UTIL_DYNAMODB.getPackageName() - ) + registerTypeImport( + nativeAttributeValue, + nativeAttributeValue, + AwsDependency.UTIL_DYNAMODB.getPackageName() ); writer.write(nativeAttributeValue); } @@ -446,4 +446,12 @@ private void writeNativeAttributeValue() { private boolean isRequiredMember(MemberShape member) { return member.isRequired() && !member.hasTrait(IdempotencyTokenTrait.class); } + + private void registerTypeImport(String externalName, String localName, String packageName) { + orderedUncheckedImports.putIfAbsent(packageName, new TreeMap<>()); + orderedUncheckedImports.get(packageName) + .put( + externalName, localName + ); + } } diff --git a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts index 447b25741d15..2d9e8fecb4a0 100644 --- a/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts @@ -96,9 +96,12 @@ export class BatchExecuteStatementCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { BatchExecuteStatementCommandInput as __BatchExecuteStatementCommandInput } from "@aws-sdk/client-dynamodb"; -import { BatchExecuteStatementCommandOutput as __BatchExecuteStatementCommandOutput } from "@aws-sdk/client-dynamodb"; -import { BatchStatementError as BatchStatementError } from "@aws-sdk/client-dynamodb"; -import { BatchStatementRequest as BatchStatementRequest } from "@aws-sdk/client-dynamodb"; -import { BatchStatementResponse as BatchStatementResponse } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + BatchExecuteStatementCommandInput as __BatchExecuteStatementCommandInput, + BatchExecuteStatementCommandOutput as __BatchExecuteStatementCommandOutput, + BatchStatementError, + BatchStatementRequest, + BatchStatementResponse, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts index 0376c75b66df..def798d0a011 100644 --- a/lib/lib-dynamodb/src/commands/BatchGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchGetCommand.ts @@ -106,7 +106,10 @@ export class BatchGetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { BatchGetItemCommandInput as __BatchGetItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { BatchGetItemCommandOutput as __BatchGetItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { KeysAndAttributes as KeysAndAttributes } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + BatchGetItemCommandInput as __BatchGetItemCommandInput, + BatchGetItemCommandOutput as __BatchGetItemCommandOutput, + KeysAndAttributes, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts index b0319a99c73f..9de56da1658b 100644 --- a/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/BatchWriteCommand.ts @@ -136,10 +136,13 @@ export class BatchWriteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { BatchWriteItemCommandInput as __BatchWriteItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { BatchWriteItemCommandOutput as __BatchWriteItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { DeleteRequest as DeleteRequest } from "@aws-sdk/client-dynamodb"; -import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; -import { PutRequest as PutRequest } from "@aws-sdk/client-dynamodb"; -import { WriteRequest as WriteRequest } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + BatchWriteItemCommandInput as __BatchWriteItemCommandInput, + BatchWriteItemCommandOutput as __BatchWriteItemCommandOutput, + DeleteRequest, + ItemCollectionMetrics, + PutRequest, + WriteRequest, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/DeleteCommand.ts b/lib/lib-dynamodb/src/commands/DeleteCommand.ts index 4b621fdaced8..f6d6e32a15bf 100644 --- a/lib/lib-dynamodb/src/commands/DeleteCommand.ts +++ b/lib/lib-dynamodb/src/commands/DeleteCommand.ts @@ -97,8 +97,11 @@ export class DeleteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { DeleteItemCommandInput as __DeleteItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { DeleteItemCommandOutput as __DeleteItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; -import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + DeleteItemCommandInput as __DeleteItemCommandInput, + DeleteItemCommandOutput as __DeleteItemCommandOutput, + ExpectedAttributeValue, + ItemCollectionMetrics, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts index 899297d2ce9e..81f0aae6227d 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts @@ -80,6 +80,9 @@ export class ExecuteStatementCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { ExecuteStatementCommandInput as __ExecuteStatementCommandInput } from "@aws-sdk/client-dynamodb"; -import { ExecuteStatementCommandOutput as __ExecuteStatementCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + ExecuteStatementCommandInput as __ExecuteStatementCommandInput, + ExecuteStatementCommandOutput as __ExecuteStatementCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts index 8468de78a06d..6e7d40beefc9 100644 --- a/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts +++ b/lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts @@ -90,8 +90,11 @@ export class ExecuteTransactionCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { ExecuteTransactionCommandInput as __ExecuteTransactionCommandInput } from "@aws-sdk/client-dynamodb"; -import { ExecuteTransactionCommandOutput as __ExecuteTransactionCommandOutput } from "@aws-sdk/client-dynamodb"; -import { ItemResponse as ItemResponse } from "@aws-sdk/client-dynamodb"; -import { ParameterizedStatement as ParameterizedStatement } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + ExecuteTransactionCommandInput as __ExecuteTransactionCommandInput, + ExecuteTransactionCommandOutput as __ExecuteTransactionCommandOutput, + ItemResponse, + ParameterizedStatement, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/GetCommand.ts b/lib/lib-dynamodb/src/commands/GetCommand.ts index a9f47a836b2e..8f46b914210b 100644 --- a/lib/lib-dynamodb/src/commands/GetCommand.ts +++ b/lib/lib-dynamodb/src/commands/GetCommand.ts @@ -76,6 +76,9 @@ export class GetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { GetItemCommandInput as __GetItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { GetItemCommandOutput as __GetItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + GetItemCommandInput as __GetItemCommandInput, + GetItemCommandOutput as __GetItemCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/PutCommand.ts b/lib/lib-dynamodb/src/commands/PutCommand.ts index b5fa0df1fea9..8e345adbb607 100644 --- a/lib/lib-dynamodb/src/commands/PutCommand.ts +++ b/lib/lib-dynamodb/src/commands/PutCommand.ts @@ -97,8 +97,11 @@ export class PutCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; -import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; -import { PutItemCommandInput as __PutItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { PutItemCommandOutput as __PutItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + ExpectedAttributeValue, + ItemCollectionMetrics, + PutItemCommandInput as __PutItemCommandInput, + PutItemCommandOutput as __PutItemCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/QueryCommand.ts b/lib/lib-dynamodb/src/commands/QueryCommand.ts index 032e5ad67a96..726d6a998b10 100644 --- a/lib/lib-dynamodb/src/commands/QueryCommand.ts +++ b/lib/lib-dynamodb/src/commands/QueryCommand.ts @@ -107,7 +107,10 @@ export class QueryCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { Condition as Condition } from "@aws-sdk/client-dynamodb"; -import { QueryCommandInput as __QueryCommandInput } from "@aws-sdk/client-dynamodb"; -import { QueryCommandOutput as __QueryCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + Condition, + QueryCommandInput as __QueryCommandInput, + QueryCommandOutput as __QueryCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/ScanCommand.ts b/lib/lib-dynamodb/src/commands/ScanCommand.ts index 19d198e2af14..ffe1e23829d9 100644 --- a/lib/lib-dynamodb/src/commands/ScanCommand.ts +++ b/lib/lib-dynamodb/src/commands/ScanCommand.ts @@ -96,7 +96,10 @@ export class ScanCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { Condition as Condition } from "@aws-sdk/client-dynamodb"; -import { ScanCommandInput as __ScanCommandInput } from "@aws-sdk/client-dynamodb"; -import { ScanCommandOutput as __ScanCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + Condition, + ScanCommandInput as __ScanCommandInput, + ScanCommandOutput as __ScanCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts index cad98483ce07..389739d5626d 100644 --- a/lib/lib-dynamodb/src/commands/TransactGetCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactGetCommand.ts @@ -96,9 +96,12 @@ export class TransactGetCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { Get as Get } from "@aws-sdk/client-dynamodb"; -import { ItemResponse as ItemResponse } from "@aws-sdk/client-dynamodb"; -import { TransactGetItem as TransactGetItem } from "@aws-sdk/client-dynamodb"; -import { TransactGetItemsCommandInput as __TransactGetItemsCommandInput } from "@aws-sdk/client-dynamodb"; -import { TransactGetItemsCommandOutput as __TransactGetItemsCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + Get, + ItemResponse, + TransactGetItem, + TransactGetItemsCommandInput as __TransactGetItemsCommandInput, + TransactGetItemsCommandOutput as __TransactGetItemsCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts index cba67016ee78..79e3cc2af2f2 100644 --- a/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts +++ b/lib/lib-dynamodb/src/commands/TransactWriteCommand.ts @@ -125,12 +125,15 @@ export class TransactWriteCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { ConditionCheck as ConditionCheck } from "@aws-sdk/client-dynamodb"; -import { Delete as Delete } from "@aws-sdk/client-dynamodb"; -import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; -import { Put as Put } from "@aws-sdk/client-dynamodb"; -import { TransactWriteItem as TransactWriteItem } from "@aws-sdk/client-dynamodb"; -import { TransactWriteItemsCommandInput as __TransactWriteItemsCommandInput } from "@aws-sdk/client-dynamodb"; -import { TransactWriteItemsCommandOutput as __TransactWriteItemsCommandOutput } from "@aws-sdk/client-dynamodb"; -import { Update as Update } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + ConditionCheck, + Delete, + ItemCollectionMetrics, + Put, + TransactWriteItem, + TransactWriteItemsCommandInput as __TransactWriteItemsCommandInput, + TransactWriteItemsCommandOutput as __TransactWriteItemsCommandOutput, + Update, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; diff --git a/lib/lib-dynamodb/src/commands/UpdateCommand.ts b/lib/lib-dynamodb/src/commands/UpdateCommand.ts index a95deee3797b..11e3b65be7c4 100644 --- a/lib/lib-dynamodb/src/commands/UpdateCommand.ts +++ b/lib/lib-dynamodb/src/commands/UpdateCommand.ts @@ -111,9 +111,12 @@ export class UpdateCommand extends DynamoDBDocumentClientCommand< return async () => handler(this.clientCommand); } } -import { AttributeValueUpdate as AttributeValueUpdate } from "@aws-sdk/client-dynamodb"; -import { ExpectedAttributeValue as ExpectedAttributeValue } from "@aws-sdk/client-dynamodb"; -import { ItemCollectionMetrics as ItemCollectionMetrics } from "@aws-sdk/client-dynamodb"; -import { UpdateItemCommandInput as __UpdateItemCommandInput } from "@aws-sdk/client-dynamodb"; -import { UpdateItemCommandOutput as __UpdateItemCommandOutput } from "@aws-sdk/client-dynamodb"; -import { NativeAttributeValue as NativeAttributeValue } from "@aws-sdk/util-dynamodb"; + +import type { + AttributeValueUpdate, + ExpectedAttributeValue, + ItemCollectionMetrics, + UpdateItemCommandInput as __UpdateItemCommandInput, + UpdateItemCommandOutput as __UpdateItemCommandOutput, +} from "@aws-sdk/client-dynamodb"; +import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb"; From 146de2f872dae178fc7c8bd4ead44f9fae6b112d Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 12 Apr 2024 19:13:25 +0000 Subject: [PATCH 7/7] chore: update smithy pkg versions and lockfile --- .../codegen/AddDocumentClientPlugin.java | 8 ++++---- packages/core/package.json | 2 +- packages/middleware-sdk-ec2/package.json | 2 +- packages/middleware-sdk-rds/package.json | 2 +- packages/middleware-sdk-s3/package.json | 2 +- .../package.json | 2 +- packages/middleware-signing/package.json | 2 +- packages/middleware-websocket/package.json | 2 +- packages/polly-request-presigner/package.json | 2 +- packages/rds-signer/package.json | 2 +- packages/s3-presigned-post/package.json | 2 +- packages/signature-v4-crt/package.json | 2 +- .../signature-v4-multi-region/package.json | 2 +- yarn.lock | 18 +++++++++--------- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java index fe8cc496b23e..4b910a0afa9e 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddDocumentClientPlugin.java @@ -125,10 +125,10 @@ private void writeAdditionalFiles( writer.write("export * from './$L';", DocumentClientUtils.CLIENT_FULL_NAME); writer.write(""); writer.write(""" - export { NumberValueImpl as NumberValue } from "@aws-sdk/util-dynamodb"; - export { marshallOptions, unmarshallOptions } from "@aws-sdk/util-dynamodb"; - export { NativeAttributeValue, NativeAttributeBinary, NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb"; - """); +export { NumberValueImpl as NumberValue } from "@aws-sdk/util-dynamodb"; +export { marshallOptions, unmarshallOptions } from "@aws-sdk/util-dynamodb"; +export { NativeAttributeValue, NativeAttributeBinary, NativeScalarAttributeValue } from "@aws-sdk/util-dynamodb"; + """); }); } } diff --git a/packages/core/package.json b/packages/core/package.json index c725ba3faf71..65b136500d53 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -27,7 +27,7 @@ "dependencies": { "@smithy/core": "^1.4.2", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/smithy-client": "^2.5.1", "@smithy/types": "^2.12.0", "fast-xml-parser": "4.2.5", diff --git a/packages/middleware-sdk-ec2/package.json b/packages/middleware-sdk-ec2/package.json index 4d580b56347b..13399f725686 100644 --- a/packages/middleware-sdk-ec2/package.json +++ b/packages/middleware-sdk-ec2/package.json @@ -25,7 +25,7 @@ "@aws-sdk/util-format-url": "*", "@smithy/middleware-endpoint": "^2.5.1", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/smithy-client": "^2.5.1", "@smithy/types": "^2.12.0", "tslib": "^2.6.2" diff --git a/packages/middleware-sdk-rds/package.json b/packages/middleware-sdk-rds/package.json index 8f06717e1614..fad920a9cee6 100644 --- a/packages/middleware-sdk-rds/package.json +++ b/packages/middleware-sdk-rds/package.json @@ -25,7 +25,7 @@ "@aws-sdk/util-format-url": "*", "@smithy/middleware-endpoint": "^2.5.1", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "tslib": "^2.6.2" }, diff --git a/packages/middleware-sdk-s3/package.json b/packages/middleware-sdk-s3/package.json index 5542cd8c43a5..d573c74e6ec7 100644 --- a/packages/middleware-sdk-s3/package.json +++ b/packages/middleware-sdk-s3/package.json @@ -27,7 +27,7 @@ "@aws-sdk/util-arn-parser": "*", "@smithy/node-config-provider": "^2.3.0", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/smithy-client": "^2.5.1", "@smithy/types": "^2.12.0", "@smithy/util-config-provider": "^2.3.0", diff --git a/packages/middleware-sdk-transcribe-streaming/package.json b/packages/middleware-sdk-transcribe-streaming/package.json index 979dc2fb98ff..cb88dce83a0f 100644 --- a/packages/middleware-sdk-transcribe-streaming/package.json +++ b/packages/middleware-sdk-transcribe-streaming/package.json @@ -25,7 +25,7 @@ "@aws-sdk/util-format-url": "*", "@smithy/eventstream-serde-browser": "^2.2.0", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "tslib": "^2.6.2", "uuid": "^9.0.1" diff --git a/packages/middleware-signing/package.json b/packages/middleware-signing/package.json index a63f039ad1de..90ba64b99ed0 100644 --- a/packages/middleware-signing/package.json +++ b/packages/middleware-signing/package.json @@ -25,7 +25,7 @@ "@aws-sdk/types": "*", "@smithy/property-provider": "^2.2.0", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "@smithy/util-middleware": "^2.2.0", "tslib": "^2.6.2" diff --git a/packages/middleware-websocket/package.json b/packages/middleware-websocket/package.json index 5aa772f02643..14af9cae3a36 100644 --- a/packages/middleware-websocket/package.json +++ b/packages/middleware-websocket/package.json @@ -28,7 +28,7 @@ "@smithy/eventstream-serde-browser": "^2.2.0", "@smithy/fetch-http-handler": "^2.5.0", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "@smithy/util-hex-encoding": "^2.2.0", "tslib": "^2.6.2" diff --git a/packages/polly-request-presigner/package.json b/packages/polly-request-presigner/package.json index 7e29846e895c..e3dc0a9b77ad 100644 --- a/packages/polly-request-presigner/package.json +++ b/packages/polly-request-presigner/package.json @@ -25,7 +25,7 @@ "@aws-sdk/types": "*", "@aws-sdk/util-format-url": "*", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "tslib": "^2.6.2" }, diff --git a/packages/rds-signer/package.json b/packages/rds-signer/package.json index c0befa88b321..b992518cccb7 100644 --- a/packages/rds-signer/package.json +++ b/packages/rds-signer/package.json @@ -34,7 +34,7 @@ "@smithy/invalid-dependency": "^2.2.0", "@smithy/node-config-provider": "^2.3.0", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "tslib": "^2.6.2" }, diff --git a/packages/s3-presigned-post/package.json b/packages/s3-presigned-post/package.json index 6d6f36d322c7..7fdf4c8d3817 100644 --- a/packages/s3-presigned-post/package.json +++ b/packages/s3-presigned-post/package.json @@ -26,7 +26,7 @@ "@aws-sdk/types": "*", "@aws-sdk/util-format-url": "*", "@smithy/middleware-endpoint": "^2.5.1", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "@smithy/util-hex-encoding": "^2.2.0", "@smithy/util-utf8": "^2.3.0", diff --git a/packages/signature-v4-crt/package.json b/packages/signature-v4-crt/package.json index b03e393e334d..c3b8f73688e5 100644 --- a/packages/signature-v4-crt/package.json +++ b/packages/signature-v4-crt/package.json @@ -26,7 +26,7 @@ "@aws-sdk/types": "*", "@aws-sdk/util-user-agent-node": "*", "@smithy/querystring-parser": "^2.2.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "@smithy/util-middleware": "^2.2.0", "aws-crt": "^1.18.3", diff --git a/packages/signature-v4-multi-region/package.json b/packages/signature-v4-multi-region/package.json index 07a3efdda848..0e4c9f82f2f8 100644 --- a/packages/signature-v4-multi-region/package.json +++ b/packages/signature-v4-multi-region/package.json @@ -23,7 +23,7 @@ "@aws-sdk/middleware-sdk-s3": "*", "@aws-sdk/types": "*", "@smithy/protocol-http": "^3.3.0", - "@smithy/signature-v4": "^2.2.1", + "@smithy/signature-v4": "^2.3.0", "@smithy/types": "^2.12.0", "tslib": "^2.6.2" }, diff --git a/yarn.lock b/yarn.lock index 865f2592a07b..ca5b3ee76bae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2901,16 +2901,16 @@ "@smithy/types" "^2.12.0" tslib "^2.6.2" -"@smithy/experimental-identity-and-auth@^0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@smithy/experimental-identity-and-auth/-/experimental-identity-and-auth-0.2.2.tgz#54718c72125840b1b6fc317b5105e5ceae1dd965" - integrity sha512-Huu0zW5jBckE+u4lXrTua9jDR4JNiB2Sp9O3shVaTfVVJwYYCZGdFl2Qvg+2TN9hJTVMXuvXakCiRNRQZbw/Zw== +"@smithy/experimental-identity-and-auth@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@smithy/experimental-identity-and-auth/-/experimental-identity-and-auth-0.2.3.tgz#821460377189121eb8dfa304160461d12ba834c9" + integrity sha512-Wbgjn22s/0/Gen+97Vi4WRHcPSVFozVQEWqrtp4l+ztjXrNoWvWmsiJX6ab3CArw0uT4gwLXtW7Ys7uJcKIhsw== dependencies: "@smithy/middleware-endpoint" "^2.5.1" "@smithy/middleware-retry" "^2.3.1" "@smithy/middleware-serde" "^2.3.0" "@smithy/protocol-http" "^3.3.0" - "@smithy/signature-v4" "^2.2.1" + "@smithy/signature-v4" "^2.3.0" "@smithy/types" "^2.12.0" "@smithy/util-middleware" "^2.2.0" tslib "^2.6.2" @@ -3141,10 +3141,10 @@ "@smithy/types" "^2.12.0" tslib "^2.6.2" -"@smithy/signature-v4@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-2.2.1.tgz#9b32571e9785c8f69aa4115517bf2a784f690c4d" - integrity sha512-j5fHgL1iqKTsKJ1mTcw88p0RUcidDu95AWSeZTgiYJb+QcfwWU/UpBnaqiB59FNH5MiAZuSbOBnZlwzeeY2tIw== +"@smithy/signature-v4@^2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-2.3.0.tgz#c30dd4028ae50c607db99459981cce8cdab7a3fd" + integrity sha512-ui/NlpILU+6HAQBfJX8BBsDXuKSNrjTSuOYArRblcrErwKFutjrCNb/OExfVRyj9+26F9J+ZmfWT+fKWuDrH3Q== dependencies: "@smithy/is-array-buffer" "^2.2.0" "@smithy/types" "^2.12.0"