|
27 | 27 | import software.amazon.smithy.model.shapes.OperationShape;
|
28 | 28 | import software.amazon.smithy.model.shapes.ServiceShape;
|
29 | 29 | import software.amazon.smithy.typescript.codegen.LanguageTarget;
|
| 30 | +import software.amazon.smithy.typescript.codegen.TypeScriptCodegenContext; |
30 | 31 | import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
|
31 | 32 | import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
|
32 | 33 | import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
|
| 34 | +import software.amazon.smithy.typescript.codegen.sections.SmithyContextCodeSection; |
| 35 | +import software.amazon.smithy.utils.CodeInterceptor; |
| 36 | +import software.amazon.smithy.utils.CodeSection; |
33 | 37 | import software.amazon.smithy.utils.ListUtils;
|
34 | 38 | import software.amazon.smithy.utils.MapUtils;
|
35 | 39 | import software.amazon.smithy.utils.SmithyInternalApi;
|
@@ -99,6 +103,31 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
|
99 | 103 | }
|
100 | 104 | }
|
101 | 105 |
|
| 106 | + @Override |
| 107 | + public List<? extends CodeInterceptor<? extends CodeSection, TypeScriptWriter>> interceptors( |
| 108 | + TypeScriptCodegenContext codegenContext |
| 109 | + ) { |
| 110 | + return List.of(CodeInterceptor.appender(SmithyContextCodeSection.class, (w, s) -> { |
| 111 | + EventStreamIndex eventStreamIndex = EventStreamIndex.of(s.getModel()); |
| 112 | + boolean input = eventStreamIndex.getInputInfo(s.getOperation()).isPresent(); |
| 113 | + boolean output = eventStreamIndex.getOutputInfo(s.getOperation()).isPresent(); |
| 114 | + // If not event streaming for I/O, don't write anything |
| 115 | + if (!input && !output) { |
| 116 | + return; |
| 117 | + } |
| 118 | + // Otherwise, write present input and output streaming |
| 119 | + w.writeDocs("@internal"); |
| 120 | + w.openBlock("eventStream: {", "},", () -> { |
| 121 | + if (input) { |
| 122 | + w.write("input: true,"); |
| 123 | + } |
| 124 | + if (output) { |
| 125 | + w.write("output: true,"); |
| 126 | + } |
| 127 | + }); |
| 128 | + })); |
| 129 | + } |
| 130 | + |
102 | 131 | private static boolean hasEventStream(
|
103 | 132 | Model model,
|
104 | 133 | ServiceShape service
|
|
0 commit comments