aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

feat(core): add AccountIdEndpointMode config option

Open siddsriv opened this issue 1 year ago • 1 comments
trafficstars

Issue

Internal JS-4633 Part 3

Description

Adds support for AccountIdEndpointMode config option. (client config, env, config file)

Testing

  • [x] Unit tests
  • [x] Generate the option in ClientInputEndpointParameters example:
export interface ClientInputEndpointParameters {
  region?: string | Provider<string>;
  useDualstackEndpoint?: boolean | Provider<boolean>;
  useFipsEndpoint?: boolean | Provider<boolean>;
  endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
  accountId?: string | Provider<string>;
  accountIdEndpointMode?: string | Provider<string>;
}

(this is before the merging of https://github.com/aws/aws-sdk-js-v3/pull/6035 which is why accountId is generated as well)

  • [x] Generate the option in runtimeConfig.ts example:
export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
 .
 .
  return {
    ...clientSharedValues,
    ...config,
    runtime: "node",
    defaultsMode,
    accountIdEndpointMode:
      config?.accountIdEndpointMode ?? loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS),
    bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
  • [x] Generate the option in runtimeConfig.browser.ts example:
export const getRuntimeConfig = (config: DynamoDBClientConfig) => {
  .
  .
  return {
    ...clientSharedValues,
    ...config,
    runtime: "browser",
    defaultsMode,
    accountIdEndpointMode: config?.accountIdEndpointMode ?? (() => Promise.resolve(DEFAULT_ACCOUNT_ID_ENDPOINT_MODE)),
    bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,

Checklist

  • [x] refactor for core/submodules
  • [x] If adding new public functions, did you add the @public tag and enable doc generation on the package?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

siddsriv avatar Apr 30 '24 05:04 siddsriv

possibly requires a careful look: exporting from account-id-endpoints submodule especially for config options since they will be used during runtime. the exports for this dir in package.json look right to me, let me know if i missed anything -- all tests are working okay, though it's a little tough to fully test the new client config option's functioning during runtime. i manually confirmed that everything is being imported correctly and the loading statements are correct in the generated client.

[EDIT]: added a TODO to use addImportSubmodule in our codegen for adding dependency on core/account-id-endpoint when it's available. relying on adding a string based import for that as of now.

siddsriv avatar Jun 21 '24 17:06 siddsriv

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.

github-actions[bot] avatar Aug 08 '24 00:08 github-actions[bot]