diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java index 633ac854cd1..d4df91ccfea 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java @@ -412,14 +412,14 @@ public Void serviceShape(ServiceShape shape) { private void generateClient(ServiceShape shape) { // Generate the bare-bones service client. - writers.useShapeWriter(shape, writer -> new ServiceGenerator( + writers.useShapeWriter(shape, writer -> new ServiceBareBonesClientGenerator( settings, model, symbolProvider, writer, integrations, runtimePlugins, applicationProtocol).run()); // Generate the aggregated service client. Symbol serviceSymbol = symbolProvider.toSymbol(shape); String aggregatedClientName = serviceSymbol.getName().replace("Client", ""); String filename = serviceSymbol.getDefinitionFile().replace("Client", ""); - writers.useFileWriter(filename, writer -> new NonModularServiceGenerator( + writers.useFileWriter(filename, writer -> new ServiceAggregatedClientGenerator( settings, model, symbolProvider, aggregatedClientName, writer, applicationProtocol).run()); // Generate each operation for the service. diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java index 9ca1fd8db65..01b2f8fae48 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java @@ -99,7 +99,7 @@ public void run() { private void generateClientCommand() { Symbol serviceSymbol = symbolProvider.toSymbol(service); - String configType = ServiceGenerator.getResolvedConfigTypeName(serviceSymbol); + String configType = ServiceBareBonesClientGenerator.getResolvedConfigTypeName(serviceSymbol); // Add required imports. writer.addImport(configType, configType, serviceSymbol.getNamespace()); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PaginationGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PaginationGenerator.java index 3f4efeabd55..e4f235ccde2 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PaginationGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PaginationGenerator.java @@ -47,7 +47,7 @@ final class PaginationGenerator implements Runnable { private final String operationName; private final String methodName; - private final String nonModularServiceName; + private final String aggregatedClientName; private final String paginationType; PaginationGenerator( @@ -56,7 +56,7 @@ final class PaginationGenerator implements Runnable { OperationShape operation, SymbolProvider symbolProvider, TypeScriptWriter writer, - String nonModularServiceName + String aggregatedClientName ) { this.writer = writer; @@ -67,11 +67,11 @@ final class PaginationGenerator implements Runnable { this.outputSymbol = symbolProvider.toSymbol(operation).expectProperty("outputType", Symbol.class); this.operationName = operation.getId().getName(); - this.nonModularServiceName = nonModularServiceName; + this.aggregatedClientName = aggregatedClientName; // e.g. listObjects this.methodName = Character.toLowerCase(operationName.charAt(0)) + operationName.substring(1); - this.paginationType = this.nonModularServiceName + "PaginationConfiguration"; + this.paginationType = this.aggregatedClientName + "PaginationConfiguration"; PaginatedIndex paginatedIndex = PaginatedIndex.of(model); Optional paginationInfo = paginatedIndex.getPaginationInfo(service, operation); @@ -92,9 +92,9 @@ public void run() { writer.addImport(outputSymbol.getName(), outputSymbol.getName(), outputSymbol.getNamespace()); - String nonModularLocation = serviceSymbol.getNamespace() - .replace(serviceSymbol.getName(), nonModularServiceName); - writer.addImport(nonModularServiceName, nonModularServiceName, nonModularLocation); + String aggregatedClientLocation = serviceSymbol.getNamespace() + .replace(serviceSymbol.getName(), aggregatedClientName); + writer.addImport(aggregatedClientName, aggregatedClientName, aggregatedClientLocation); writer.addImport(serviceSymbol.getName(), serviceSymbol.getName(), serviceSymbol.getNamespace()); // Import Pagination types @@ -111,18 +111,18 @@ static String getOutputFilelocation(OperationShape operation) { } static void generateServicePaginationInterfaces( - String nonModularServiceName, + String aggregatedClientName, Symbol service, TypeScriptWriter writer ) { writer.addImport("PaginationConfiguration", "PaginationConfiguration", "@aws-sdk/types"); - String nonModularLocation = service.getNamespace().replace(service.getName(), nonModularServiceName); - writer.addImport(nonModularServiceName, nonModularServiceName, nonModularLocation); + String aggregatedClientLocation = service.getNamespace().replace(service.getName(), aggregatedClientName); + writer.addImport(aggregatedClientName, aggregatedClientName, aggregatedClientLocation); writer.addImport(service.getName(), service.getName(), service.getNamespace()); writer.openBlock("export interface $LPaginationConfiguration extends PaginationConfiguration {", - "}", nonModularServiceName, () -> { - writer.write("client: $L | $L;", nonModularServiceName, service.getName()); + "}", aggregatedClientName, () -> { + writer.write("client: $L | $L;", aggregatedClientName, service.getName()); }); } @@ -183,7 +183,7 @@ private void writePager() { writer.write("input[$S] = config.pageSize;", pageSize); } - writer.openBlock("if (config.client instanceof $L) {", "}", nonModularServiceName, () -> { + writer.openBlock("if (config.client instanceof $L) {", "}", aggregatedClientName, () -> { writer.write("page = await makePagedRequest(config.client, input, ...additionalArguments);"); }); writer.openBlock("else if (config.client instanceof $L) {", "}", serviceTypeName, () -> { @@ -191,7 +191,7 @@ private void writePager() { }); writer.openBlock("else {", "}", () -> { writer.write("throw new Error(\"Invalid client, expected $L | $L\");", - nonModularServiceName, serviceTypeName); + aggregatedClientName, serviceTypeName); }); writer.write("yield page;"); @@ -214,7 +214,7 @@ private void writeMethodRequest() { writer.writeDocs("@private"); writer.openBlock( "const makePagedRequest = async (client: $L, input: $L, ...args: any): Promise<$L> => {", - "}", nonModularServiceName, inputSymbol.getName(), + "}", aggregatedClientName, inputSymbol.getName(), outputSymbol.getName(), () -> { writer.write("// @ts-ignore"); writer.write("return await client.$L(input, ...args);", methodName); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceAggregatedClientGenerator.java similarity index 90% rename from smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java rename to smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceAggregatedClientGenerator.java index 3189d14e33d..3e3bd36e5f5 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceAggregatedClientGenerator.java @@ -27,30 +27,30 @@ import software.amazon.smithy.utils.StringUtils; /** - * Generates a non-modular service client. + * Generates aggregated client for service. * - *

This client extends from the modular client and provides named methods + *

This client extends from the bare-bones client and provides named methods * for every operation in the service. Using this client means that all * operations of a service are considered referenced, meaning they will * not be removed by tree-shaking. */ @SmithyInternalApi -final class NonModularServiceGenerator implements Runnable { +final class ServiceAggregatedClientGenerator implements Runnable { private final TypeScriptSettings settings; private final Model model; private final ServiceShape service; private final SymbolProvider symbolProvider; private final TypeScriptWriter writer; - private final String nonModularName; + private final String aggregateClientName; private final Symbol serviceSymbol; private final ApplicationProtocol applicationProtocol; - NonModularServiceGenerator( + ServiceAggregatedClientGenerator( TypeScriptSettings settings, Model model, SymbolProvider symbolProvider, - String nonModularName, + String aggregateClientName, TypeScriptWriter writer, ApplicationProtocol applicationProtocol ) { @@ -59,7 +59,7 @@ final class NonModularServiceGenerator implements Runnable { this.service = settings.getService(model); this.symbolProvider = symbolProvider; this.writer = writer; - this.nonModularName = nonModularName; + this.aggregateClientName = aggregateClientName; this.applicationProtocol = applicationProtocol; serviceSymbol = symbolProvider.toSymbol(service); } @@ -68,9 +68,9 @@ final class NonModularServiceGenerator implements Runnable { public void run() { TopDownIndex topDownIndex = TopDownIndex.of(model); - // Generate the client and extend from the modular client. + // Generate the client and extend from the bare-bones client. writer.writeShapeDocs(service); - writer.openBlock("export class $L extends $T {", "}", nonModularName, serviceSymbol, () -> { + writer.openBlock("export class $L extends $T {", "}", aggregateClientName, serviceSymbol, () -> { Set containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service)); for (OperationShape operation : containedOperations) { Symbol operationSymbol = symbolProvider.toSymbol(operation); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java similarity index 98% rename from smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java rename to smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java index 66d1d4cf5a3..cefb4436247 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java @@ -36,10 +36,10 @@ import software.amazon.smithy.utils.SmithyInternalApi; /** - * Generates a service client and configuration using plugins. + * Generates a bare-bones client and configuration for service using plugins. */ @SmithyInternalApi -final class ServiceGenerator implements Runnable { +final class ServiceBareBonesClientGenerator implements Runnable { static final String CLIENT_CONFIG_SECTION = "client_config"; static final String CLIENT_PROPERTIES_SECTION = "client_properties"; @@ -59,7 +59,7 @@ final class ServiceGenerator implements Runnable { private final List runtimePlugins; private final ApplicationProtocol applicationProtocol; - ServiceGenerator( + ServiceBareBonesClientGenerator( TypeScriptSettings settings, Model model, SymbolProvider symbolProvider, diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceGeneratorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGeneratorTest.java similarity index 93% rename from smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceGeneratorTest.java rename to smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGeneratorTest.java index e70b2e0df8f..b9f95e7dc3e 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceGeneratorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGeneratorTest.java @@ -12,7 +12,7 @@ import software.amazon.smithy.model.node.Node; import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration; -public class ServiceGeneratorTest { +public class ServiceBareBonesClientGeneratorTest { @Test public void hasHooksForService() { // TODO @@ -44,7 +44,7 @@ public void addConfigInterfaceFields( } }); - new ServiceGenerator(settings, model, symbolProvider, writer, integrations, + new ServiceBareBonesClientGenerator(settings, model, symbolProvider, writer, integrations, Collections.emptyList(), applicationProtocol).run(); assertThat(writer.toString(), containsString(" /**\n"