Skip to content

chore(codegen): make hasEventStreamInput utilities public #6351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public List<RuntimeClientPlugin> getClientPlugins() {
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.MIDDLEWARE_EVENTSTREAM.dependency,
"EventStream", HAS_MIDDLEWARE)
.operationPredicate(AddEventStreamHandlingDependency::hasEventStreamInput)
.operationPredicate((m, s, o) -> hasEventStreamInput(m, o))
.build()
);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
}
}

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

private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) {
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
return eventStreamIndex.getInputInfo(operation).isPresent();
public static boolean hasEventStreamInput(Model model, OperationShape operation) {
return EventStreamIndex.of(model).getInputInfo(operation).isPresent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.EventStreamIndex;
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.TypeScriptSettings;
Expand Down Expand Up @@ -56,7 +54,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.dependency,
"TranscribeStreaming", RuntimeClientPlugin.Convention.HAS_MIDDLEWARE)
.operationPredicate((m, s, o) -> isTranscribeStreaming(s) && hasEventStreamInput(m, s, o))
.operationPredicate((m, s, o) -> isTranscribeStreaming(s)
&& AddEventStreamHandlingDependency.hasEventStreamInput(m, o))
.build()
);
}
Expand Down Expand Up @@ -94,11 +93,6 @@ private static boolean isTranscribeStreaming(ServiceShape service) {
String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse("");
return serviceId.equals("Transcribe Streaming");
}

private static boolean hasEventStreamInput(Model model, ServiceShape service, OperationShape operation) {
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
return eventStreamIndex.getInputInfo(operation).isPresent();
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.EventStreamIndex;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.typescript.codegen.LanguageTarget;
Expand Down Expand Up @@ -62,7 +61,8 @@ public List<RuntimeClientPlugin> getClientPlugins() {
.withConventions(AwsDependency.MIDDLEWARE_WEBSOCKET.dependency,
"WebSocket", RuntimeClientPlugin.Convention.HAS_MIDDLEWARE)
.additionalPluginFunctionParamsSupplier((m, s, o) -> getPluginFunctionParams(m, s, o))
.operationPredicate((m, s, o) -> isWebsocketSupported(s) && hasEventStreamRequest(m, o))
.operationPredicate((m, s, o) -> isWebsocketSupported(s)
&& AddEventStreamHandlingDependency.hasEventStreamInput(m, o))
.build(),
RuntimeClientPlugin.builder()
.withConventions(AwsDependency.MIDDLEWARE_WEBSOCKET.dependency, "WebSocket",
Expand Down Expand Up @@ -132,11 +132,6 @@ private static boolean isWebsocketSupported(ServiceShape service) {
return websocketServices.contains(serviceId);
}

private static boolean hasEventStreamRequest(Model model, OperationShape operation) {
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
return eventStreamIndex.getInputInfo(operation).isPresent();
}

private static Map<String, Object> getPluginFunctionParams(
Model model,
ServiceShape service,
Expand Down
Loading