Closed kuhe closed 3 months ago
// endpointResolver.ts (before)
// smithy-typescript generated code
import { EndpointV2, Logger } from "@smithy/types";
import { EndpointParams, resolveEndpoint } from "@smithy/util-endpoints";
import { EndpointParameters } from "./EndpointParameters";
import { ruleSet } from "./ruleset";
export const defaultEndpointResolver = (
endpointParams: EndpointParameters,
context: { logger?: Logger } = {}
): EndpointV2 => {
return resolveEndpoint(ruleSet, {
endpointParams: endpointParams as EndpointParams,
logger: context.logger,
});
};
// endpointResolver.ts (after)
// smithy-typescript generated code
import { awsEndpointFunctions } from "@aws-sdk/util-endpoints";
import { EndpointV2, Logger } from "@smithy/types";
import { customEndpointFunctions, EndpointParams, resolveEndpoint } from "@smithy/util-endpoints";
import { EndpointParameters } from "./EndpointParameters";
import { ruleSet } from "./ruleset";
export const defaultEndpointResolver = (
endpointParams: EndpointParameters,
context: { logger?: Logger } = {}
): EndpointV2 => {
return resolveEndpoint(ruleSet, {
endpointParams: endpointParams as EndpointParams,
logger: context.logger,
});
};
customEndpointFunctions.aws = awsEndpointFunctions;
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Issue
Related to https://github.com/aws/aws-sdk-js-v3/issues/5925 https://github.com/aws/aws-sdk-js-v3/issues/5889 https://github.com/aws/aws-sdk-js-v3/issues/5435
Description
This changes the way we register
awsEndpointFunctions
. Instead of callingWe will do this in each individual client's endpointResolver fn:
This aims to work around two issues:
import "@aws-sdk/util-endpoints";
because it looks like it's unused, even though it's being imported for its side-effects.@smithy/util-endpoints
is duplicated due to multiple versions being depended upon, one of those may not receive the augmentation. By running it inline with the client's code, this ensures that whatever version of@smithy/util-endpoints
being used by the client is augmented by the same.Testing
integration tests cover this, because without the AWS endpoint functions, integration tests will fail, due to being unable to resolve endpoints.