diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java index 3a5c78b74a9..03144e11a93 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddEventStreamDependency.java @@ -27,9 +27,13 @@ import software.amazon.smithy.model.shapes.OperationShape; import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.typescript.codegen.LanguageTarget; +import software.amazon.smithy.typescript.codegen.TypeScriptCodegenContext; import software.amazon.smithy.typescript.codegen.TypeScriptDependency; import software.amazon.smithy.typescript.codegen.TypeScriptSettings; import software.amazon.smithy.typescript.codegen.TypeScriptWriter; +import software.amazon.smithy.typescript.codegen.sections.SmithyContextCodeSection; +import software.amazon.smithy.utils.CodeInterceptor; +import software.amazon.smithy.utils.CodeSection; import software.amazon.smithy.utils.ListUtils; import software.amazon.smithy.utils.MapUtils; import software.amazon.smithy.utils.SmithyInternalApi; @@ -99,6 +103,31 @@ public Map> getRuntimeConfigWriters( } } + @Override + public List> interceptors( + TypeScriptCodegenContext codegenContext + ) { + return List.of(CodeInterceptor.appender(SmithyContextCodeSection.class, (w, s) -> { + EventStreamIndex eventStreamIndex = EventStreamIndex.of(s.getModel()); + boolean input = eventStreamIndex.getInputInfo(s.getOperation()).isPresent(); + boolean output = eventStreamIndex.getOutputInfo(s.getOperation()).isPresent(); + // If not event streaming for I/O, don't write anything + if (!input && !output) { + return; + } + // Otherwise, write present input and output streaming + w.writeDocs("@internal"); + w.openBlock("eventStream: {", "},", () -> { + if (input) { + w.write("input: true,"); + } + if (output) { + w.write("output: true,"); + } + }); + })); + } + private static boolean hasEventStream( Model model, ServiceShape service