diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenUtils.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenUtils.java index fa1663dcfff..b232cb5d04a 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenUtils.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenUtils.java @@ -54,7 +54,7 @@ public static String getOperationSerializerContextType( // Get default SerdeContext. List contextInterfaceList = getDefaultOperationSerdeContextTypes(writer); // If event stream trait exists, add corresponding serde context type to the intersection type. - EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class); + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); if (eventStreamIndex.getInputInfo(operation).isPresent()) { writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types"); contextInterfaceList.add("__EventStreamSerdeContext"); @@ -77,7 +77,7 @@ public static String getOperationDeserializerContextType( // Get default SerdeContext. List contextInterfaceList = getDefaultOperationSerdeContextTypes(writer); // If event stream trait exists, add corresponding serde context type to the intersection type. - EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class); + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); if (eventStreamIndex.getOutputInfo(operation).isPresent()) { writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types"); contextInterfaceList.add("__EventStreamSerdeContext"); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java index 9f98c2e153f..aa6ac3fdc7b 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CodegenVisitor.java @@ -294,7 +294,7 @@ public Void serviceShape(ServiceShape shape) { settings, model, symbolProvider, nonModularName, writer, applicationProtocol).run()); // Generate each operation for the service. - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); Set containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service)); boolean hasPaginatedOperation = false; 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 8a1ec493b4f..c5f5947ddbc 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 @@ -78,7 +78,7 @@ final class CommandGenerator implements Runnable { this.applicationProtocol = applicationProtocol; symbol = symbolProvider.toSymbol(operation); - operationIndex = model.getKnowledge(OperationIndex.class); + operationIndex = OperationIndex.of(model); inputType = symbol.expectProperty("inputType", Symbol.class); outputType = symbol.expectProperty("outputType", Symbol.class); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java index de969d93881..598887345fd 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java @@ -115,8 +115,8 @@ final class HttpProtocolTestGenerator implements Runnable { @Override public void run() { - OperationIndex operationIndex = model.getKnowledge(OperationIndex.class); - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + OperationIndex operationIndex = OperationIndex.of(model); + TopDownIndex topDownIndex = TopDownIndex.of(model); // Use a TreeSet to have a fixed ordering of tests. for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) { @@ -296,7 +296,7 @@ private void writeRequestBodyAssertions(OperationShape operation, HttpRequestTes // Fast check if we have an undescribed or plain text body. if (mediaType == null || mediaType.equals("text/plain")) { // Handle converting to the right comparison format for blob payloads. - HttpBindingIndex httpBindingIndex = model.getKnowledge(HttpBindingIndex.class); + HttpBindingIndex httpBindingIndex = HttpBindingIndex.of(model); List payloadBindings = httpBindingIndex.getRequestBindings(operation, Location.PAYLOAD); if (!payloadBindings.isEmpty() && hasBlobBinding(payloadBindings)) { writer.write("expect(r.body).toMatchObject(Uint8Array.from($S, c => c.charCodeAt(0)));", body); 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 f16cfb93f99..e96fb537d94 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 @@ -54,7 +54,7 @@ static void writeIndex( writer.write("export * from \"./" + nonModularName + "\";"); // write export statements for each command in /commands directory - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); Set containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service)); boolean hasPaginatedOperation = false; for (OperationShape operation : containedOperations) { diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java index 8e2704791bf..2b04b1acd3b 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/NonModularServiceGenerator.java @@ -64,7 +64,7 @@ final class NonModularServiceGenerator implements Runnable { @Override public void run() { - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); // Generate the client and extend from the modular client. writer.writeShapeDocs(service); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java index 3d82ddb32b4..f8709f96ff1 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceGenerator.java @@ -117,7 +117,7 @@ private void writeInputOutputTypeUnion( Function> mapper, Consumer defaultTypeGenerator ) { - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); Set containedOperations = topDownIndex.getContainedOperations(service); List symbols = containedOperations.stream() diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java index 3d634c00a73..3e158d0022d 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java @@ -102,7 +102,7 @@ final class SymbolVisitor implements SymbolProvider, ShapeVisitor { .buildEscaper(); // Get each structure that's used an error. - OperationIndex operationIndex = model.getKnowledge(OperationIndex.class); + OperationIndex operationIndex = OperationIndex.of(model); model.shapes(OperationShape.class).forEach(operationShape -> { errorShapes.addAll(operationIndex.getErrors(operationShape)); }); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java index eb22002091e..f83ebd30718 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptSettings.java @@ -254,7 +254,7 @@ public ShapeId resolveServiceProtocol(Model model, ServiceShape service, Set resolvedProtocols = serviceIndex.getProtocols(service).keySet(); if (resolvedProtocols.isEmpty()) { throw new UnresolvableProtocolException( 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 61aae4832c7..c338a38c314 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 @@ -102,9 +102,9 @@ private static boolean hasEventStream( Model model, ServiceShape service ) { - TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class); + TopDownIndex topDownIndex = TopDownIndex.of(model); Set operations = topDownIndex.getContainedOperations(service); - EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class); + EventStreamIndex eventStreamIndex = EventStreamIndex.of(model); for (OperationShape operation : operations) { if (eventStreamIndex.getInputInfo(operation).isPresent() || eventStreamIndex.getOutputInfo(operation).isPresent()