Skip to content

Commit

Permalink
fix(endpoints): add input / resolved / resolveConfig imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Yuan committed Sep 19, 2023
1 parent 421b73e commit d349f24
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait;
import software.amazon.smithy.typescript.codegen.auth.AuthUtils;
import software.amazon.smithy.typescript.codegen.auth.http.integration.HttpAuthTypeScriptIntegration;
import software.amazon.smithy.typescript.codegen.endpointsV2.EndpointsV2Generator;
import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
import software.amazon.smithy.utils.OptionalUtils;
Expand Down Expand Up @@ -190,6 +191,8 @@ private void generateConfig() {
}
}
if (service.hasTrait(EndpointRuleSetTrait.class)) {
writer.addImport("ClientInputEndpointParameters", null,
EndpointsV2Generator.ENDPOINT_PARAMETERS_DEPENDENCY);
writer.write("& ClientInputEndpointParameters");
}
writer.dedent();
Expand Down Expand Up @@ -221,6 +224,8 @@ private void generateConfig() {
}
});
if (service.hasTrait(EndpointRuleSetTrait.class)) {
writer.addImport("ClientResolvedEndpointParameters", null,
EndpointsV2Generator.ENDPOINT_PARAMETERS_DEPENDENCY);
writer.write("& ClientResolvedEndpointParameters");
}
writer.dedent();
Expand Down Expand Up @@ -384,6 +389,8 @@ private void generateConstructor() {

if (service.hasTrait(EndpointRuleSetTrait.class)) {
configVariable++;
writer.addImport("resolveClientEndpointParameters", null,
EndpointsV2Generator.ENDPOINT_PARAMETERS_DEPENDENCY);
writer.write("let $L = $L($L);",
generateConfigVariable(configVariable),
"resolveClientEndpointParameters",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
package software.amazon.smithy.typescript.codegen.endpointsV2;

import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import software.amazon.smithy.codegen.core.SymbolDependency;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.node.ObjectNode;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait;
import software.amazon.smithy.typescript.codegen.CodegenUtils;
import software.amazon.smithy.typescript.codegen.Dependency;
import software.amazon.smithy.typescript.codegen.TypeScriptDelegator;
import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
Expand All @@ -33,9 +37,40 @@
@SmithyInternalApi
public final class EndpointsV2Generator implements Runnable {

static final String ENDPOINT_FOLDER = "endpoint";
static final String ENDPOINT_PARAMETERS_FILE = "EndpointParameters.ts";
static final String ENDPOINT_RESOLVER_FILE = "endpointResolver.ts";
public static final String ENDPOINT_FOLDER = "endpoint";
public static final String ENDPOINT_PARAMETERS_MODULE_NAME = "EndpointParameters";
public static final String ENDPOINT_RESOLVER_MODULE_NAME = "endpointResolver";
public static final String ENDPOINT_PARAMETERS_MODULE =
Paths.get(".", CodegenUtils.SOURCE_FOLDER, EndpointsV2Generator.ENDPOINT_FOLDER,
EndpointsV2Generator.ENDPOINT_PARAMETERS_MODULE_NAME).toString();
public static final Dependency ENDPOINT_PARAMETERS_DEPENDENCY = new Dependency() {
@Override
public String getPackageName() {
return ENDPOINT_PARAMETERS_MODULE;
}

@Override
public List<SymbolDependency> getDependencies() {
return Collections.emptyList();
}
};
public static final String ENDPOINT_RESOLVER_MODULE =
Paths.get(".", CodegenUtils.SOURCE_FOLDER, EndpointsV2Generator.ENDPOINT_FOLDER,
EndpointsV2Generator.ENDPOINT_RESOLVER_MODULE_NAME).toString();
public static final Dependency ENDPOINT_RESOLVER_DEPENDENCY = new Dependency() {
@Override
public String getPackageName() {
return ENDPOINT_RESOLVER_MODULE;
}

@Override
public List<SymbolDependency> getDependencies() {
return Collections.emptyList();
}
};

static final String ENDPOINT_PARAMETERS_FILE = ENDPOINT_PARAMETERS_MODULE_NAME + ".ts";
static final String ENDPOINT_RESOLVER_FILE = ENDPOINT_RESOLVER_MODULE_NAME + ".ts";
static final String ENDPOINT_RULESET_FILE = "ruleset.ts";

private final TypeScriptDelegator delegator;
Expand Down

0 comments on commit d349f24

Please sign in to comment.