From abdacbff09544b097423962bab27335a5f29d592 Mon Sep 17 00:00:00 2001 From: Michael Young Date: Mon, 22 May 2023 15:48:43 +0000 Subject: [PATCH] add packageDocumentation and fix inheritance --- .../amazon/smithy/typescript/codegen/CommandGenerator.java | 3 +++ .../amazon/smithy/typescript/codegen/IndexGenerator.java | 7 +++++++ .../codegen/ServiceBareBonesClientGenerator.java | 5 +++-- .../codegen/integration/AddBaseServiceExceptionClass.java | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) 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 ad485919312..393318a7e6f 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 @@ -362,6 +362,9 @@ private void generateCommandMiddlewareResolver(String configType) { } private void addInputAndOutputTypes() { + writer.writeDocs("@public"); + writer.write("export { __MetadataBearer, $$Command };"); + writeInputType(inputType.getName(), operationIndex.getInput(operation), symbol.getName()); writeOutputType(outputType.getName(), operationIndex.getOutput(operation), symbol.getName()); writer.write(""); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java index b4276ed2d36..73f5bb66946 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java @@ -25,6 +25,7 @@ import software.amazon.smithy.model.knowledge.TopDownIndex; import software.amazon.smithy.model.shapes.OperationShape; import software.amazon.smithy.model.shapes.ServiceShape; +import software.amazon.smithy.model.traits.DocumentationTrait; import software.amazon.smithy.model.traits.PaginatedTrait; import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; import software.amazon.smithy.utils.SmithyInternalApi; @@ -45,6 +46,12 @@ static void writeIndex( ProtocolGenerator protocolGenerator, TypeScriptWriter writer ) { + + writer.write("/* eslint-disable */"); + settings.getService(model).getTrait(DocumentationTrait.class).ifPresent(trait -> + writer.writeDocs(trait.getValue() + "\n\n" + "@packageDocumentation")); + + if (settings.generateClient()) { writeClientExports(settings, model, symbolProvider, writer); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java index d8618fe3341..048d267644b 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java @@ -98,6 +98,7 @@ static String getResolvedConfigTypeName(Symbol symbol) { @Override public void run() { writer.addImport("Client", "__Client", "@aws-sdk/smithy-client"); + writer.write("export { __Client }\n"); writer.addImport("getRuntimeConfig", "__getRuntimeConfig", Paths.get(".", CodegenUtils.SOURCE_FOLDER, "runtimeConfig").toString()); @@ -162,7 +163,7 @@ private void generateConfig() { writer.writeDocs("@public"); // The default configuration type is always just the base-level // Smithy configuration requirements. - writer.write("type $LType = Partial<__SmithyConfiguration<$T>>", configType, + writer.write("export type $LType = Partial<__SmithyConfiguration<$T>>", configType, applicationProtocol.getOptionsType()); writer.write(" & ClientDefaults"); @@ -197,7 +198,7 @@ private void generateConfig() { // each "Input" configuration type. writer.write(""); writer.writeDocs("@public"); - writer.write("type $LType = __SmithyResolvedConfiguration<$T>", + writer.write("export type $LType = __SmithyResolvedConfiguration<$T>", resolvedConfigType, applicationProtocol.getOptionsType()); writer.write(" & Required"); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBaseServiceExceptionClass.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBaseServiceExceptionClass.java index fe67ca432a0..ba887a832f3 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBaseServiceExceptionClass.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBaseServiceExceptionClass.java @@ -67,6 +67,9 @@ private void writeAdditionalFiles( TypeScriptDependency.AWS_SMITHY_CLIENT.packageName); writer.addImport("ServiceExceptionOptions", "__ServiceExceptionOptions", TypeScriptDependency.AWS_SMITHY_CLIENT.packageName); + // Export ServiceException information to allow + // documentation inheritance to consume their types + writer.write("export { __ServiceException, __ServiceExceptionOptions }\n"); writer.writeDocs("@public\n\nBase exception class for all service exceptions from " + serviceName + " service."); writer.openBlock("export class $L extends __ServiceException {", serviceExceptionName);