Skip to content

Commit 7bf2e59

Browse files
authored
chore(codegen): make hasEventStreamInput utilities public (#6351)
1 parent 2acbcdb commit 7bf2e59

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public List<RuntimeClientPlugin> getClientPlugins() {
6363
RuntimeClientPlugin.builder()
6464
.withConventions(AwsDependency.MIDDLEWARE_EVENTSTREAM.dependency,
6565
"EventStream", HAS_MIDDLEWARE)
66-
.operationPredicate(AddEventStreamHandlingDependency::hasEventStreamInput)
66+
.operationPredicate((m, s, o) -> hasEventStreamInput(m, o))
6767
.build()
6868
);
6969
}
@@ -138,7 +138,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
138138
}
139139
}
140140

141-
private static boolean hasEventStreamInput(Model model, ServiceShape service) {
141+
public static boolean hasEventStreamInput(Model model, ServiceShape service) {
142142
TopDownIndex topDownIndex = TopDownIndex.of(model);
143143
Set<OperationShape> operations = topDownIndex.getContainedOperations(service);
144144
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
@@ -150,8 +150,7 @@ private static boolean hasEventStreamInput(Model model, ServiceShape service) {
150150
return false;
151151
}
152152

153-
private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) {
154-
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
155-
return eventStreamIndex.getInputInfo(operation).isPresent();
153+
public static boolean hasEventStreamInput(Model model, OperationShape operation) {
154+
return EventStreamIndex.of(model).getInputInfo(operation).isPresent();
156155
}
157156
}

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import software.amazon.smithy.aws.traits.ServiceTrait;
2323
import software.amazon.smithy.codegen.core.SymbolProvider;
2424
import software.amazon.smithy.model.Model;
25-
import software.amazon.smithy.model.knowledge.EventStreamIndex;
26-
import software.amazon.smithy.model.shapes.OperationShape;
2725
import software.amazon.smithy.model.shapes.ServiceShape;
2826
import software.amazon.smithy.typescript.codegen.LanguageTarget;
2927
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
@@ -56,7 +54,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
5654
RuntimeClientPlugin.builder()
5755
.withConventions(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.dependency,
5856
"TranscribeStreaming", RuntimeClientPlugin.Convention.HAS_MIDDLEWARE)
59-
.operationPredicate((m, s, o) -> isTranscribeStreaming(s) && hasEventStreamInput(m, s, o))
57+
.operationPredicate((m, s, o) -> isTranscribeStreaming(s)
58+
&& AddEventStreamHandlingDependency.hasEventStreamInput(m, o))
6059
.build()
6160
);
6261
}
@@ -94,11 +93,6 @@ private static boolean isTranscribeStreaming(ServiceShape service) {
9493
String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse("");
9594
return serviceId.equals("Transcribe Streaming");
9695
}
97-
98-
private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) {
99-
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
100-
return eventStreamIndex.getInputInfo(operation).isPresent();
101-
}
10296
}
10397

10498

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddWebsocketPlugin.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import software.amazon.smithy.codegen.core.CodegenException;
2525
import software.amazon.smithy.codegen.core.SymbolProvider;
2626
import software.amazon.smithy.model.Model;
27-
import software.amazon.smithy.model.knowledge.EventStreamIndex;
2827
import software.amazon.smithy.model.shapes.OperationShape;
2928
import software.amazon.smithy.model.shapes.ServiceShape;
3029
import software.amazon.smithy.typescript.codegen.LanguageTarget;
@@ -62,7 +61,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
6261
.withConventions(AwsDependency.MIDDLEWARE_WEBSOCKET.dependency,
6362
"WebSocket", RuntimeClientPlugin.Convention.HAS_MIDDLEWARE)
6463
.additionalPluginFunctionParamsSupplier((m, s, o) -> getPluginFunctionParams(m, s, o))
65-
.operationPredicate((m, s, o) -> isWebsocketSupported(s) && hasEventStreamRequest(m, o))
64+
.operationPredicate((m, s, o) -> isWebsocketSupported(s)
65+
&& AddEventStreamHandlingDependency.hasEventStreamInput(m, o))
6666
.build(),
6767
RuntimeClientPlugin.builder()
6868
.withConventions(AwsDependency.MIDDLEWARE_WEBSOCKET.dependency, "WebSocket",
@@ -132,11 +132,6 @@ private static boolean isWebsocketSupported(ServiceShape service) {
132132
return websocketServices.contains(serviceId);
133133
}
134134

135-
private static boolean hasEventStreamRequest(Model model, OperationShape operation) {
136-
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
137-
return eventStreamIndex.getInputInfo(operation).isPresent();
138-
}
139-
140135
private static Map<String, Object> getPluginFunctionParams(
141136
Model model,
142137
ServiceShape service,

0 commit comments

Comments
 (0)