diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfig.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfig.java index c08f2a63e551..e9e52e8fe466 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfig.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfig.java @@ -124,7 +124,6 @@ public Map> getRuntimeConfigWriters( + "trait was found on " + service.getId()); } } - runtimeConfigs.putAll(getCredentialProviderConfig(service, target)); runtimeConfigs.putAll(getDefaultConfig(target)); return runtimeConfigs; } @@ -146,6 +145,13 @@ private Map> getDefaultConfig(LanguageTarget TypeScriptDependency.INVALID_DEPENDENCY.packageName); writer.write("region: invalidFunction(\"Region is missing\") as any,"); }, + "credentialDefaultProvider", writer -> { + writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); + writer.addImport("invalidFunction", "invalidFunction", + TypeScriptDependency.INVALID_DEPENDENCY.packageName); + writer.write( + "credentialDefaultProvider: invalidFunction(\"Credential is missing\") as any,"); + }, "maxAttempts", writer -> { writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY); writer.addImport("DEFAULT_MAX_ATTEMPTS", "DEFAULT_MAX_ATTEMPTS", @@ -167,6 +173,12 @@ private Map> getDefaultConfig(LanguageTarget writer.write( "region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),"); }, + "credentialDefaultProvider", writer -> { + writer.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE); + writer.addImport("defaultProvider", "credentialDefaultProvider", + AwsDependency.CREDENTIAL_PROVIDER_NODE.packageName); + writer.write("credentialDefaultProvider,"); + }, "maxAttempts", writer -> { writer.addImport("NODE_MAX_ATTEMPT_CONFIG_OPTIONS", "NODE_MAX_ATTEMPT_CONFIG_OPTIONS", TypeScriptDependency.MIDDLEWARE_RETRY.packageName); @@ -177,34 +189,4 @@ private Map> getDefaultConfig(LanguageTarget return Collections.emptyMap(); } } - - private Map> getCredentialProviderConfig( - ServiceShape service, - LanguageTarget target - ) { - String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse(""); - switch (target) { - case BROWSER: - return MapUtils.of( - "credentialDefaultProvider", writer -> { - writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); - writer.addImport("invalidFunction", "invalidFunction", - TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.write( - "credentialDefaultProvider: invalidFunction(\"Credential is missing\") as any,"); - } - ); - case NODE: - return MapUtils.of( - "credentialDefaultProvider", writer -> { - writer.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE); - writer.addImport("defaultProvider", "credentialDefaultProvider", - AwsDependency.CREDENTIAL_PROVIDER_NODE.packageName); - writer.write("credentialDefaultProvider,"); - } - ); - default: - return Collections.emptyMap(); - } - } }