diff --git a/clients/client-accessanalyzer/AccessAnalyzerClient.ts b/clients/client-accessanalyzer/AccessAnalyzerClient.ts index 7c38bbf8bba9e..187f566dbadaa 100644 --- a/clients/client-accessanalyzer/AccessAnalyzerClient.ts +++ b/clients/client-accessanalyzer/AccessAnalyzerClient.ts @@ -50,7 +50,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateArchiveRuleCommandInput, UpdateArchiveRuleCommandOutput } from "./commands/UpdateArchiveRuleCommand"; import { UpdateFindingsCommandInput, UpdateFindingsCommandOutput } from "./commands/UpdateFindingsCommand"; import { ValidatePolicyCommandInput, ValidatePolicyCommandOutput } from "./commands/ValidatePolicyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -324,10 +324,7 @@ export class AccessAnalyzerClient extends __Client< readonly config: AccessAnalyzerClientResolvedConfig; constructor(configuration: AccessAnalyzerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-accessanalyzer/runtimeConfig.browser.ts b/clients/client-accessanalyzer/runtimeConfig.browser.ts index 424548636beb7..ec372020aa98d 100644 --- a/clients/client-accessanalyzer/runtimeConfig.browser.ts +++ b/clients/client-accessanalyzer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AccessAnalyzerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AccessAnalyzerClientConfig } from "./AccessAnalyzerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-accessanalyzer/runtimeConfig.native.ts b/clients/client-accessanalyzer/runtimeConfig.native.ts index c00042379c213..4d093d029311d 100644 --- a/clients/client-accessanalyzer/runtimeConfig.native.ts +++ b/clients/client-accessanalyzer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AccessAnalyzerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AccessAnalyzerClientConfig } from "./AccessAnalyzerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-accessanalyzer/runtimeConfig.shared.ts b/clients/client-accessanalyzer/runtimeConfig.shared.ts index 01dd2a1e5c34e..f7f45588b59c8 100644 --- a/clients/client-accessanalyzer/runtimeConfig.shared.ts +++ b/clients/client-accessanalyzer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AccessAnalyzerClientConfig } from "./AccessAnalyzerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => ({ apiVersion: "2019-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AccessAnalyzer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AccessAnalyzer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-accessanalyzer/runtimeConfig.ts b/clients/client-accessanalyzer/runtimeConfig.ts index 8dee0cccc716e..5b2e0803219c0 100644 --- a/clients/client-accessanalyzer/runtimeConfig.ts +++ b/clients/client-accessanalyzer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AccessAnalyzerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AccessAnalyzerClientConfig } from "./AccessAnalyzerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-acm-pca/ACMPCAClient.ts b/clients/client-acm-pca/ACMPCAClient.ts index a81181e9044f7..31f7aed7c1483 100644 --- a/clients/client-acm-pca/ACMPCAClient.ts +++ b/clients/client-acm-pca/ACMPCAClient.ts @@ -60,7 +60,7 @@ import { UpdateCertificateAuthorityCommandInput, UpdateCertificateAuthorityCommandOutput, } from "./commands/UpdateCertificateAuthorityCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -328,10 +328,7 @@ export class ACMPCAClient extends __Client< readonly config: ACMPCAClientResolvedConfig; constructor(configuration: ACMPCAClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-acm-pca/runtimeConfig.browser.ts b/clients/client-acm-pca/runtimeConfig.browser.ts index 582df9b694dcf..f697bc7691fbb 100644 --- a/clients/client-acm-pca/runtimeConfig.browser.ts +++ b/clients/client-acm-pca/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ACMPCAClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ACMPCAClientConfig } from "./ACMPCAClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ACMPCAClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-acm-pca/runtimeConfig.native.ts b/clients/client-acm-pca/runtimeConfig.native.ts index adda57a36ef75..22356f998f118 100644 --- a/clients/client-acm-pca/runtimeConfig.native.ts +++ b/clients/client-acm-pca/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ACMPCAClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ACMPCAClientConfig } from "./ACMPCAClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ACMPCAClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-acm-pca/runtimeConfig.shared.ts b/clients/client-acm-pca/runtimeConfig.shared.ts index e1132dfa74212..05f24099b2a93 100644 --- a/clients/client-acm-pca/runtimeConfig.shared.ts +++ b/clients/client-acm-pca/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ACMPCAClientConfig } from "./ACMPCAClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ACMPCAClientConfig) => ({ apiVersion: "2017-08-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ACM PCA", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ACM PCA", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-acm-pca/runtimeConfig.ts b/clients/client-acm-pca/runtimeConfig.ts index 2a361e683ad05..ba4b39733f1ae 100644 --- a/clients/client-acm-pca/runtimeConfig.ts +++ b/clients/client-acm-pca/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ACMPCAClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ACMPCAClientConfig } from "./ACMPCAClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ACMPCAClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-acm/ACMClient.ts b/clients/client-acm/ACMClient.ts index ccf0c10e74624..28f34801de213 100644 --- a/clients/client-acm/ACMClient.ts +++ b/clients/client-acm/ACMClient.ts @@ -37,7 +37,7 @@ import { UpdateCertificateOptionsCommandInput, UpdateCertificateOptionsCommandOutput, } from "./commands/UpdateCertificateOptionsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -279,10 +279,7 @@ export class ACMClient extends __Client< readonly config: ACMClientResolvedConfig; constructor(configuration: ACMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-acm/runtimeConfig.browser.ts b/clients/client-acm/runtimeConfig.browser.ts index 9cc454e678854..0f4f5dc701d1a 100644 --- a/clients/client-acm/runtimeConfig.browser.ts +++ b/clients/client-acm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ACMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ACMClientConfig } from "./ACMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ACMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-acm/runtimeConfig.native.ts b/clients/client-acm/runtimeConfig.native.ts index 8d784c0143c47..bdefb51dd5ab7 100644 --- a/clients/client-acm/runtimeConfig.native.ts +++ b/clients/client-acm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ACMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ACMClientConfig } from "./ACMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ACMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-acm/runtimeConfig.shared.ts b/clients/client-acm/runtimeConfig.shared.ts index 8f2199bbf4012..0da4e1b7fdf74 100644 --- a/clients/client-acm/runtimeConfig.shared.ts +++ b/clients/client-acm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ACMClientConfig } from "./ACMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ACMClientConfig) => ({ apiVersion: "2015-12-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ACM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ACM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-acm/runtimeConfig.ts b/clients/client-acm/runtimeConfig.ts index 4459ad25aa6ee..34ff7b225f826 100644 --- a/clients/client-acm/runtimeConfig.ts +++ b/clients/client-acm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ACMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ACMClientConfig } from "./ACMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ACMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-alexa-for-business/AlexaForBusinessClient.ts b/clients/client-alexa-for-business/AlexaForBusinessClient.ts index 02a93c1cbaa0c..ffab5501f8fa1 100644 --- a/clients/client-alexa-for-business/AlexaForBusinessClient.ts +++ b/clients/client-alexa-for-business/AlexaForBusinessClient.ts @@ -208,7 +208,7 @@ import { import { UpdateProfileCommandInput, UpdateProfileCommandOutput } from "./commands/UpdateProfileCommand"; import { UpdateRoomCommandInput, UpdateRoomCommandOutput } from "./commands/UpdateRoomCommand"; import { UpdateSkillGroupCommandInput, UpdateSkillGroupCommandOutput } from "./commands/UpdateSkillGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -611,10 +611,7 @@ export class AlexaForBusinessClient extends __Client< readonly config: AlexaForBusinessClientResolvedConfig; constructor(configuration: AlexaForBusinessClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-alexa-for-business/runtimeConfig.browser.ts b/clients/client-alexa-for-business/runtimeConfig.browser.ts index 185d9cba33cb7..a85aa3882700b 100644 --- a/clients/client-alexa-for-business/runtimeConfig.browser.ts +++ b/clients/client-alexa-for-business/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AlexaForBusinessClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AlexaForBusinessClientConfig } from "./AlexaForBusinessClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AlexaForBusinessClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-alexa-for-business/runtimeConfig.native.ts b/clients/client-alexa-for-business/runtimeConfig.native.ts index 2dd6bc88b67cc..632a51d5007cd 100644 --- a/clients/client-alexa-for-business/runtimeConfig.native.ts +++ b/clients/client-alexa-for-business/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AlexaForBusinessClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AlexaForBusinessClientConfig } from "./AlexaForBusinessClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AlexaForBusinessClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-alexa-for-business/runtimeConfig.shared.ts b/clients/client-alexa-for-business/runtimeConfig.shared.ts index ed0bf95faa71b..19e68ce9d7a07 100644 --- a/clients/client-alexa-for-business/runtimeConfig.shared.ts +++ b/clients/client-alexa-for-business/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AlexaForBusinessClientConfig } from "./AlexaForBusinessClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AlexaForBusinessClientConfig) => ({ apiVersion: "2017-11-09", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Alexa For Business", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Alexa For Business", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-alexa-for-business/runtimeConfig.ts b/clients/client-alexa-for-business/runtimeConfig.ts index ca57bff0dd1f1..dffb80b9f5678 100644 --- a/clients/client-alexa-for-business/runtimeConfig.ts +++ b/clients/client-alexa-for-business/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AlexaForBusinessClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AlexaForBusinessClientConfig } from "./AlexaForBusinessClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AlexaForBusinessClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amp/AmpClient.ts b/clients/client-amp/AmpClient.ts index 82198302a14c9..888697226e22b 100644 --- a/clients/client-amp/AmpClient.ts +++ b/clients/client-amp/AmpClient.ts @@ -6,7 +6,7 @@ import { UpdateWorkspaceAliasCommandInput, UpdateWorkspaceAliasCommandOutput, } from "./commands/UpdateWorkspaceAliasCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -226,10 +226,7 @@ export class AmpClient extends __Client< readonly config: AmpClientResolvedConfig; constructor(configuration: AmpClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-amp/runtimeConfig.browser.ts b/clients/client-amp/runtimeConfig.browser.ts index 97386546ad4af..34a2884367450 100644 --- a/clients/client-amp/runtimeConfig.browser.ts +++ b/clients/client-amp/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AmpClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmpClientConfig } from "./AmpClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmpClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amp/runtimeConfig.native.ts b/clients/client-amp/runtimeConfig.native.ts index 65582f1b428bb..73c04881cbc35 100644 --- a/clients/client-amp/runtimeConfig.native.ts +++ b/clients/client-amp/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AmpClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AmpClientConfig } from "./AmpClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AmpClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-amp/runtimeConfig.shared.ts b/clients/client-amp/runtimeConfig.shared.ts index f5585ff6309d4..3d86a96ffff27 100644 --- a/clients/client-amp/runtimeConfig.shared.ts +++ b/clients/client-amp/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AmpClientConfig } from "./AmpClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AmpClientConfig) => ({ apiVersion: "2020-08-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "amp", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "amp", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-amp/runtimeConfig.ts b/clients/client-amp/runtimeConfig.ts index e84a52827944b..eff7e277ddb47 100644 --- a/clients/client-amp/runtimeConfig.ts +++ b/clients/client-amp/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AmpClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmpClientConfig } from "./AmpClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmpClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amplify/AmplifyClient.ts b/clients/client-amplify/AmplifyClient.ts index a3b0ec83704f1..98fe2f7d0c5d0 100644 --- a/clients/client-amplify/AmplifyClient.ts +++ b/clients/client-amplify/AmplifyClient.ts @@ -65,7 +65,7 @@ import { UpdateDomainAssociationCommandOutput, } from "./commands/UpdateDomainAssociationCommand"; import { UpdateWebhookCommandInput, UpdateWebhookCommandOutput } from "./commands/UpdateWebhookCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -354,10 +354,7 @@ export class AmplifyClient extends __Client< readonly config: AmplifyClientResolvedConfig; constructor(configuration: AmplifyClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-amplify/runtimeConfig.browser.ts b/clients/client-amplify/runtimeConfig.browser.ts index 71283152e05fe..5293a17cfe234 100644 --- a/clients/client-amplify/runtimeConfig.browser.ts +++ b/clients/client-amplify/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AmplifyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmplifyClientConfig } from "./AmplifyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmplifyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amplify/runtimeConfig.native.ts b/clients/client-amplify/runtimeConfig.native.ts index 46e727aaaf7c8..f0b05d713b4c0 100644 --- a/clients/client-amplify/runtimeConfig.native.ts +++ b/clients/client-amplify/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AmplifyClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AmplifyClientConfig } from "./AmplifyClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AmplifyClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-amplify/runtimeConfig.shared.ts b/clients/client-amplify/runtimeConfig.shared.ts index da4c5954c7ede..b68484771e1a5 100644 --- a/clients/client-amplify/runtimeConfig.shared.ts +++ b/clients/client-amplify/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AmplifyClientConfig } from "./AmplifyClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AmplifyClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Amplify", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Amplify", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-amplify/runtimeConfig.ts b/clients/client-amplify/runtimeConfig.ts index 9b9da4cb40497..17b13707a85de 100644 --- a/clients/client-amplify/runtimeConfig.ts +++ b/clients/client-amplify/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AmplifyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmplifyClientConfig } from "./AmplifyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmplifyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amplifybackend/AmplifyBackendClient.ts b/clients/client-amplifybackend/AmplifyBackendClient.ts index a60805f815f5c..54e6899124ce4 100644 --- a/clients/client-amplifybackend/AmplifyBackendClient.ts +++ b/clients/client-amplifybackend/AmplifyBackendClient.ts @@ -38,7 +38,7 @@ import { UpdateBackendConfigCommandOutput, } from "./commands/UpdateBackendConfigCommand"; import { UpdateBackendJobCommandInput, UpdateBackendJobCommandOutput } from "./commands/UpdateBackendJobCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -298,10 +298,7 @@ export class AmplifyBackendClient extends __Client< readonly config: AmplifyBackendClientResolvedConfig; constructor(configuration: AmplifyBackendClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-amplifybackend/runtimeConfig.browser.ts b/clients/client-amplifybackend/runtimeConfig.browser.ts index 0c2b9d9f649fe..d6375ebc9268b 100644 --- a/clients/client-amplifybackend/runtimeConfig.browser.ts +++ b/clients/client-amplifybackend/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AmplifyBackendClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmplifyBackendClientConfig } from "./AmplifyBackendClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmplifyBackendClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-amplifybackend/runtimeConfig.native.ts b/clients/client-amplifybackend/runtimeConfig.native.ts index 2ec3163ae205c..d6acc4eae6a06 100644 --- a/clients/client-amplifybackend/runtimeConfig.native.ts +++ b/clients/client-amplifybackend/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AmplifyBackendClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AmplifyBackendClientConfig } from "./AmplifyBackendClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AmplifyBackendClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-amplifybackend/runtimeConfig.shared.ts b/clients/client-amplifybackend/runtimeConfig.shared.ts index 8d7253903bf31..6263392d52b8e 100644 --- a/clients/client-amplifybackend/runtimeConfig.shared.ts +++ b/clients/client-amplifybackend/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AmplifyBackendClientConfig } from "./AmplifyBackendClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AmplifyBackendClientConfig) => ({ apiVersion: "2020-08-11", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AmplifyBackend", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AmplifyBackend", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-amplifybackend/runtimeConfig.ts b/clients/client-amplifybackend/runtimeConfig.ts index b584fba461ff4..850f50df4dcc0 100644 --- a/clients/client-amplifybackend/runtimeConfig.ts +++ b/clients/client-amplifybackend/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AmplifyBackendClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AmplifyBackendClientConfig } from "./AmplifyBackendClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AmplifyBackendClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-api-gateway/APIGatewayClient.ts b/clients/client-api-gateway/APIGatewayClient.ts index bf9613a50aa77..d6e779fd13392 100644 --- a/clients/client-api-gateway/APIGatewayClient.ts +++ b/clients/client-api-gateway/APIGatewayClient.ts @@ -226,7 +226,7 @@ import { UpdateStageCommandInput, UpdateStageCommandOutput } from "./commands/Up import { UpdateUsageCommandInput, UpdateUsageCommandOutput } from "./commands/UpdateUsageCommand"; import { UpdateUsagePlanCommandInput, UpdateUsagePlanCommandOutput } from "./commands/UpdateUsagePlanCommand"; import { UpdateVpcLinkCommandInput, UpdateVpcLinkCommandOutput } from "./commands/UpdateVpcLinkCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -678,10 +678,7 @@ export class APIGatewayClient extends __Client< readonly config: APIGatewayClientResolvedConfig; constructor(configuration: APIGatewayClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-api-gateway/runtimeConfig.browser.ts b/clients/client-api-gateway/runtimeConfig.browser.ts index 80c64fdb18ccb..f4b0d89f4d38c 100644 --- a/clients/client-api-gateway/runtimeConfig.browser.ts +++ b/clients/client-api-gateway/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./APIGatewayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { APIGatewayClientConfig } from "./APIGatewayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: APIGatewayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-api-gateway/runtimeConfig.native.ts b/clients/client-api-gateway/runtimeConfig.native.ts index 49c8f907fda70..796480896384a 100644 --- a/clients/client-api-gateway/runtimeConfig.native.ts +++ b/clients/client-api-gateway/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./APIGatewayClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { APIGatewayClientConfig } from "./APIGatewayClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: APIGatewayClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-api-gateway/runtimeConfig.shared.ts b/clients/client-api-gateway/runtimeConfig.shared.ts index 1660821fa1be9..fb7b75780100a 100644 --- a/clients/client-api-gateway/runtimeConfig.shared.ts +++ b/clients/client-api-gateway/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { APIGatewayClientConfig } from "./APIGatewayClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: APIGatewayClientConfig) => ({ apiVersion: "2015-07-09", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "API Gateway", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "API Gateway", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-api-gateway/runtimeConfig.ts b/clients/client-api-gateway/runtimeConfig.ts index a891c9534e31f..e48d6a2e46352 100644 --- a/clients/client-api-gateway/runtimeConfig.ts +++ b/clients/client-api-gateway/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./APIGatewayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { APIGatewayClientConfig } from "./APIGatewayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: APIGatewayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apigatewaymanagementapi/ApiGatewayManagementApiClient.ts b/clients/client-apigatewaymanagementapi/ApiGatewayManagementApiClient.ts index fbbf0597278b8..7fe5bb7b97142 100644 --- a/clients/client-apigatewaymanagementapi/ApiGatewayManagementApiClient.ts +++ b/clients/client-apigatewaymanagementapi/ApiGatewayManagementApiClient.ts @@ -1,7 +1,7 @@ import { DeleteConnectionCommandInput, DeleteConnectionCommandOutput } from "./commands/DeleteConnectionCommand"; import { GetConnectionCommandInput, GetConnectionCommandOutput } from "./commands/GetConnectionCommand"; import { PostToConnectionCommandInput, PostToConnectionCommandOutput } from "./commands/PostToConnectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -214,10 +214,7 @@ export class ApiGatewayManagementApiClient extends __Client< readonly config: ApiGatewayManagementApiClientResolvedConfig; constructor(configuration: ApiGatewayManagementApiClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-apigatewaymanagementapi/runtimeConfig.browser.ts b/clients/client-apigatewaymanagementapi/runtimeConfig.browser.ts index 20c197c4edd00..99a7f12b2ba67 100644 --- a/clients/client-apigatewaymanagementapi/runtimeConfig.browser.ts +++ b/clients/client-apigatewaymanagementapi/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApiGatewayManagementApiClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApiGatewayManagementApiClientConfig } from "./ApiGatewayManagementApiClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApiGatewayManagementApiClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apigatewaymanagementapi/runtimeConfig.native.ts b/clients/client-apigatewaymanagementapi/runtimeConfig.native.ts index f0b2d5154e558..19a1bc51d9751 100644 --- a/clients/client-apigatewaymanagementapi/runtimeConfig.native.ts +++ b/clients/client-apigatewaymanagementapi/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApiGatewayManagementApiClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApiGatewayManagementApiClientConfig } from "./ApiGatewayManagementApiClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApiGatewayManagementApiClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-apigatewaymanagementapi/runtimeConfig.shared.ts b/clients/client-apigatewaymanagementapi/runtimeConfig.shared.ts index 0457c5ba6d619..43a4ec6346024 100644 --- a/clients/client-apigatewaymanagementapi/runtimeConfig.shared.ts +++ b/clients/client-apigatewaymanagementapi/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApiGatewayManagementApiClientConfig } from "./ApiGatewayManagementApiClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApiGatewayManagementApiClientConfig) => ({ apiVersion: "2018-11-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ApiGatewayManagementApi", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ApiGatewayManagementApi", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-apigatewaymanagementapi/runtimeConfig.ts b/clients/client-apigatewaymanagementapi/runtimeConfig.ts index 56df5c99a911b..e082925247df8 100644 --- a/clients/client-apigatewaymanagementapi/runtimeConfig.ts +++ b/clients/client-apigatewaymanagementapi/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApiGatewayManagementApiClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApiGatewayManagementApiClientConfig } from "./ApiGatewayManagementApiClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApiGatewayManagementApiClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apigatewayv2/ApiGatewayV2Client.ts b/clients/client-apigatewayv2/ApiGatewayV2Client.ts index 093898beeade3..a8d88fa26d579 100644 --- a/clients/client-apigatewayv2/ApiGatewayV2Client.ts +++ b/clients/client-apigatewayv2/ApiGatewayV2Client.ts @@ -109,7 +109,7 @@ import { } from "./commands/UpdateRouteResponseCommand"; import { UpdateStageCommandInput, UpdateStageCommandOutput } from "./commands/UpdateStageCommand"; import { UpdateVpcLinkCommandInput, UpdateVpcLinkCommandOutput } from "./commands/UpdateVpcLinkCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -463,10 +463,7 @@ export class ApiGatewayV2Client extends __Client< readonly config: ApiGatewayV2ClientResolvedConfig; constructor(configuration: ApiGatewayV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-apigatewayv2/runtimeConfig.browser.ts b/clients/client-apigatewayv2/runtimeConfig.browser.ts index 616df18c5839d..d522b5d7dfd8c 100644 --- a/clients/client-apigatewayv2/runtimeConfig.browser.ts +++ b/clients/client-apigatewayv2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApiGatewayV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApiGatewayV2ClientConfig } from "./ApiGatewayV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApiGatewayV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apigatewayv2/runtimeConfig.native.ts b/clients/client-apigatewayv2/runtimeConfig.native.ts index aa921337ba00b..1f443824ac8cf 100644 --- a/clients/client-apigatewayv2/runtimeConfig.native.ts +++ b/clients/client-apigatewayv2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApiGatewayV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApiGatewayV2ClientConfig } from "./ApiGatewayV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApiGatewayV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-apigatewayv2/runtimeConfig.shared.ts b/clients/client-apigatewayv2/runtimeConfig.shared.ts index 47632773995b0..bd9e538f766c2 100644 --- a/clients/client-apigatewayv2/runtimeConfig.shared.ts +++ b/clients/client-apigatewayv2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApiGatewayV2ClientConfig } from "./ApiGatewayV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApiGatewayV2ClientConfig) => ({ apiVersion: "2018-11-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ApiGatewayV2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ApiGatewayV2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-apigatewayv2/runtimeConfig.ts b/clients/client-apigatewayv2/runtimeConfig.ts index 9d8b4be85368b..6ac2e8d3d111b 100644 --- a/clients/client-apigatewayv2/runtimeConfig.ts +++ b/clients/client-apigatewayv2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApiGatewayV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApiGatewayV2ClientConfig } from "./ApiGatewayV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApiGatewayV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-app-mesh/AppMeshClient.ts b/clients/client-app-mesh/AppMeshClient.ts index 0f3590e116fd9..3b0c6a83e9233 100644 --- a/clients/client-app-mesh/AppMeshClient.ts +++ b/clients/client-app-mesh/AppMeshClient.ts @@ -87,7 +87,7 @@ import { UpdateVirtualServiceCommandInput, UpdateVirtualServiceCommandOutput, } from "./commands/UpdateVirtualServiceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -385,10 +385,7 @@ export class AppMeshClient extends __Client< readonly config: AppMeshClientResolvedConfig; constructor(configuration: AppMeshClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-app-mesh/runtimeConfig.browser.ts b/clients/client-app-mesh/runtimeConfig.browser.ts index fcf6736ac87a7..ea7595124d926 100644 --- a/clients/client-app-mesh/runtimeConfig.browser.ts +++ b/clients/client-app-mesh/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppMeshClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppMeshClientConfig } from "./AppMeshClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppMeshClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-app-mesh/runtimeConfig.native.ts b/clients/client-app-mesh/runtimeConfig.native.ts index cdb957625fa28..2b344fc1aeff7 100644 --- a/clients/client-app-mesh/runtimeConfig.native.ts +++ b/clients/client-app-mesh/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppMeshClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppMeshClientConfig } from "./AppMeshClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppMeshClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-app-mesh/runtimeConfig.shared.ts b/clients/client-app-mesh/runtimeConfig.shared.ts index af2dadef34346..02ae0264ef0c0 100644 --- a/clients/client-app-mesh/runtimeConfig.shared.ts +++ b/clients/client-app-mesh/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppMeshClientConfig } from "./AppMeshClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppMeshClientConfig) => ({ apiVersion: "2019-01-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "App Mesh", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "App Mesh", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-app-mesh/runtimeConfig.ts b/clients/client-app-mesh/runtimeConfig.ts index ffa3a4f09a6e1..434f0e9d5b8c9 100644 --- a/clients/client-app-mesh/runtimeConfig.ts +++ b/clients/client-app-mesh/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppMeshClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppMeshClientConfig } from "./AppMeshClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppMeshClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appconfig/AppConfigClient.ts b/clients/client-appconfig/AppConfigClient.ts index 196fe059ca4af..cf2a300f69caa 100644 --- a/clients/client-appconfig/AppConfigClient.ts +++ b/clients/client-appconfig/AppConfigClient.ts @@ -79,7 +79,7 @@ import { ValidateConfigurationCommandInput, ValidateConfigurationCommandOutput, } from "./commands/ValidateConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -403,10 +403,7 @@ export class AppConfigClient extends __Client< readonly config: AppConfigClientResolvedConfig; constructor(configuration: AppConfigClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-appconfig/runtimeConfig.browser.ts b/clients/client-appconfig/runtimeConfig.browser.ts index df97ada09ba95..d651e0aa05dc2 100644 --- a/clients/client-appconfig/runtimeConfig.browser.ts +++ b/clients/client-appconfig/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppConfigClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppConfigClientConfig } from "./AppConfigClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppConfigClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appconfig/runtimeConfig.native.ts b/clients/client-appconfig/runtimeConfig.native.ts index f9ab785138625..380ae3f836a7a 100644 --- a/clients/client-appconfig/runtimeConfig.native.ts +++ b/clients/client-appconfig/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppConfigClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppConfigClientConfig } from "./AppConfigClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppConfigClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-appconfig/runtimeConfig.shared.ts b/clients/client-appconfig/runtimeConfig.shared.ts index e1b514c1a150e..d7ecc8a3fdce4 100644 --- a/clients/client-appconfig/runtimeConfig.shared.ts +++ b/clients/client-appconfig/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppConfigClientConfig } from "./AppConfigClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppConfigClientConfig) => ({ apiVersion: "2019-10-09", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AppConfig", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AppConfig", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-appconfig/runtimeConfig.ts b/clients/client-appconfig/runtimeConfig.ts index f125cb322beee..3fbe330c7e238 100644 --- a/clients/client-appconfig/runtimeConfig.ts +++ b/clients/client-appconfig/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppConfigClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppConfigClientConfig } from "./AppConfigClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppConfigClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appflow/AppflowClient.ts b/clients/client-appflow/AppflowClient.ts index 3f5516c3eaaaf..ec8688b3b127b 100644 --- a/clients/client-appflow/AppflowClient.ts +++ b/clients/client-appflow/AppflowClient.ts @@ -40,7 +40,7 @@ import { UpdateConnectorProfileCommandOutput, } from "./commands/UpdateConnectorProfileCommand"; import { UpdateFlowCommandInput, UpdateFlowCommandOutput } from "./commands/UpdateFlowCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -326,10 +326,7 @@ export class AppflowClient extends __Client< readonly config: AppflowClientResolvedConfig; constructor(configuration: AppflowClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-appflow/runtimeConfig.browser.ts b/clients/client-appflow/runtimeConfig.browser.ts index b1639aaa4ee2c..293ca28aa4a4e 100644 --- a/clients/client-appflow/runtimeConfig.browser.ts +++ b/clients/client-appflow/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppflowClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppflowClientConfig } from "./AppflowClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppflowClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appflow/runtimeConfig.native.ts b/clients/client-appflow/runtimeConfig.native.ts index 64fac1d075c30..a501c9def9845 100644 --- a/clients/client-appflow/runtimeConfig.native.ts +++ b/clients/client-appflow/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppflowClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppflowClientConfig } from "./AppflowClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppflowClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-appflow/runtimeConfig.shared.ts b/clients/client-appflow/runtimeConfig.shared.ts index 6d47bc2f65394..e60f86337d26f 100644 --- a/clients/client-appflow/runtimeConfig.shared.ts +++ b/clients/client-appflow/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppflowClientConfig } from "./AppflowClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppflowClientConfig) => ({ apiVersion: "2020-08-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Appflow", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Appflow", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-appflow/runtimeConfig.ts b/clients/client-appflow/runtimeConfig.ts index 8afc8ff5a8b17..464fab832559d 100644 --- a/clients/client-appflow/runtimeConfig.ts +++ b/clients/client-appflow/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppflowClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppflowClientConfig } from "./AppflowClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppflowClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appintegrations/AppIntegrationsClient.ts b/clients/client-appintegrations/AppIntegrationsClient.ts index 30b23cf6e6da0..db2c277d13b8b 100644 --- a/clients/client-appintegrations/AppIntegrationsClient.ts +++ b/clients/client-appintegrations/AppIntegrationsClient.ts @@ -28,7 +28,7 @@ import { UpdateEventIntegrationCommandInput, UpdateEventIntegrationCommandOutput, } from "./commands/UpdateEventIntegrationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -263,10 +263,7 @@ export class AppIntegrationsClient extends __Client< readonly config: AppIntegrationsClientResolvedConfig; constructor(configuration: AppIntegrationsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-appintegrations/runtimeConfig.browser.ts b/clients/client-appintegrations/runtimeConfig.browser.ts index 35e7150ee4eda..bb317d6583005 100644 --- a/clients/client-appintegrations/runtimeConfig.browser.ts +++ b/clients/client-appintegrations/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppIntegrationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppIntegrationsClientConfig } from "./AppIntegrationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppIntegrationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appintegrations/runtimeConfig.native.ts b/clients/client-appintegrations/runtimeConfig.native.ts index 9250dcb5f8dd2..b7c03eb594ac2 100644 --- a/clients/client-appintegrations/runtimeConfig.native.ts +++ b/clients/client-appintegrations/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppIntegrationsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppIntegrationsClientConfig } from "./AppIntegrationsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppIntegrationsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-appintegrations/runtimeConfig.shared.ts b/clients/client-appintegrations/runtimeConfig.shared.ts index bee7784252d8c..238845e4b1e98 100644 --- a/clients/client-appintegrations/runtimeConfig.shared.ts +++ b/clients/client-appintegrations/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppIntegrationsClientConfig } from "./AppIntegrationsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppIntegrationsClientConfig) => ({ apiVersion: "2020-07-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AppIntegrations", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AppIntegrations", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-appintegrations/runtimeConfig.ts b/clients/client-appintegrations/runtimeConfig.ts index cde7f7307cf85..8ee808f3c9e67 100644 --- a/clients/client-appintegrations/runtimeConfig.ts +++ b/clients/client-appintegrations/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppIntegrationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppIntegrationsClientConfig } from "./AppIntegrationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppIntegrationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-auto-scaling/ApplicationAutoScalingClient.ts b/clients/client-application-auto-scaling/ApplicationAutoScalingClient.ts index 6adb9777b2a25..67b0e16fa9c41 100644 --- a/clients/client-application-auto-scaling/ApplicationAutoScalingClient.ts +++ b/clients/client-application-auto-scaling/ApplicationAutoScalingClient.ts @@ -32,7 +32,7 @@ import { RegisterScalableTargetCommandInput, RegisterScalableTargetCommandOutput, } from "./commands/RegisterScalableTargetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -329,10 +329,7 @@ export class ApplicationAutoScalingClient extends __Client< readonly config: ApplicationAutoScalingClientResolvedConfig; constructor(configuration: ApplicationAutoScalingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-application-auto-scaling/runtimeConfig.browser.ts b/clients/client-application-auto-scaling/runtimeConfig.browser.ts index 8a31a1ebe75a2..d316ee055df93 100644 --- a/clients/client-application-auto-scaling/runtimeConfig.browser.ts +++ b/clients/client-application-auto-scaling/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApplicationAutoScalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationAutoScalingClientConfig } from "./ApplicationAutoScalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationAutoScalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-auto-scaling/runtimeConfig.native.ts b/clients/client-application-auto-scaling/runtimeConfig.native.ts index eb87b464afecd..ecb8ad3429081 100644 --- a/clients/client-application-auto-scaling/runtimeConfig.native.ts +++ b/clients/client-application-auto-scaling/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApplicationAutoScalingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApplicationAutoScalingClientConfig } from "./ApplicationAutoScalingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApplicationAutoScalingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-application-auto-scaling/runtimeConfig.shared.ts b/clients/client-application-auto-scaling/runtimeConfig.shared.ts index 0cbe7f5cf847d..41cbb47f62236 100644 --- a/clients/client-application-auto-scaling/runtimeConfig.shared.ts +++ b/clients/client-application-auto-scaling/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApplicationAutoScalingClientConfig } from "./ApplicationAutoScalingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApplicationAutoScalingClientConfig) => ({ apiVersion: "2016-02-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Application Auto Scaling", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Application Auto Scaling", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-application-auto-scaling/runtimeConfig.ts b/clients/client-application-auto-scaling/runtimeConfig.ts index 99b239089386d..70f30a3040c0d 100644 --- a/clients/client-application-auto-scaling/runtimeConfig.ts +++ b/clients/client-application-auto-scaling/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApplicationAutoScalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationAutoScalingClientConfig } from "./ApplicationAutoScalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationAutoScalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-discovery-service/ApplicationDiscoveryServiceClient.ts b/clients/client-application-discovery-service/ApplicationDiscoveryServiceClient.ts index f82527c5fccfa..4afc236f7646c 100644 --- a/clients/client-application-discovery-service/ApplicationDiscoveryServiceClient.ts +++ b/clients/client-application-discovery-service/ApplicationDiscoveryServiceClient.ts @@ -68,7 +68,7 @@ import { StopDataCollectionByAgentIdsCommandOutput, } from "./commands/StopDataCollectionByAgentIdsCommand"; import { UpdateApplicationCommandInput, UpdateApplicationCommandOutput } from "./commands/UpdateApplicationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -455,10 +455,7 @@ export class ApplicationDiscoveryServiceClient extends __Client< readonly config: ApplicationDiscoveryServiceClientResolvedConfig; constructor(configuration: ApplicationDiscoveryServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-application-discovery-service/runtimeConfig.browser.ts b/clients/client-application-discovery-service/runtimeConfig.browser.ts index d9fd2934ae04f..a79a283e56488 100644 --- a/clients/client-application-discovery-service/runtimeConfig.browser.ts +++ b/clients/client-application-discovery-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApplicationDiscoveryServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationDiscoveryServiceClientConfig } from "./ApplicationDiscoveryServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationDiscoveryServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-discovery-service/runtimeConfig.native.ts b/clients/client-application-discovery-service/runtimeConfig.native.ts index ecd0fd8e9b373..bff59a209dff6 100644 --- a/clients/client-application-discovery-service/runtimeConfig.native.ts +++ b/clients/client-application-discovery-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApplicationDiscoveryServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApplicationDiscoveryServiceClientConfig } from "./ApplicationDiscoveryServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApplicationDiscoveryServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-application-discovery-service/runtimeConfig.shared.ts b/clients/client-application-discovery-service/runtimeConfig.shared.ts index ecd4b72c45866..a9d656fa056cd 100644 --- a/clients/client-application-discovery-service/runtimeConfig.shared.ts +++ b/clients/client-application-discovery-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApplicationDiscoveryServiceClientConfig } from "./ApplicationDiscoveryServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApplicationDiscoveryServiceClientConfig) => ({ apiVersion: "2015-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Application Discovery Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Application Discovery Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-application-discovery-service/runtimeConfig.ts b/clients/client-application-discovery-service/runtimeConfig.ts index 2f1838a59bc08..16ab4e5a31284 100644 --- a/clients/client-application-discovery-service/runtimeConfig.ts +++ b/clients/client-application-discovery-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApplicationDiscoveryServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationDiscoveryServiceClientConfig } from "./ApplicationDiscoveryServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationDiscoveryServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-insights/ApplicationInsightsClient.ts b/clients/client-application-insights/ApplicationInsightsClient.ts index 1829997eb20fd..913dfef0bfa1b 100644 --- a/clients/client-application-insights/ApplicationInsightsClient.ts +++ b/clients/client-application-insights/ApplicationInsightsClient.ts @@ -49,7 +49,7 @@ import { UpdateComponentConfigurationCommandOutput, } from "./commands/UpdateComponentConfigurationCommand"; import { UpdateLogPatternCommandInput, UpdateLogPatternCommandOutput } from "./commands/UpdateLogPatternCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -325,10 +325,7 @@ export class ApplicationInsightsClient extends __Client< readonly config: ApplicationInsightsClientResolvedConfig; constructor(configuration: ApplicationInsightsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-application-insights/runtimeConfig.browser.ts b/clients/client-application-insights/runtimeConfig.browser.ts index 44808d3aba0ef..abbb58018f929 100644 --- a/clients/client-application-insights/runtimeConfig.browser.ts +++ b/clients/client-application-insights/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApplicationInsightsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationInsightsClientConfig } from "./ApplicationInsightsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationInsightsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-application-insights/runtimeConfig.native.ts b/clients/client-application-insights/runtimeConfig.native.ts index 519b6c7c7983d..226e36318e16e 100644 --- a/clients/client-application-insights/runtimeConfig.native.ts +++ b/clients/client-application-insights/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApplicationInsightsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApplicationInsightsClientConfig } from "./ApplicationInsightsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApplicationInsightsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-application-insights/runtimeConfig.shared.ts b/clients/client-application-insights/runtimeConfig.shared.ts index af2c71f44f57c..dc5fcdd0a58b2 100644 --- a/clients/client-application-insights/runtimeConfig.shared.ts +++ b/clients/client-application-insights/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApplicationInsightsClientConfig } from "./ApplicationInsightsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApplicationInsightsClientConfig) => ({ apiVersion: "2018-11-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Application Insights", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Application Insights", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-application-insights/runtimeConfig.ts b/clients/client-application-insights/runtimeConfig.ts index 6b0a96d225aa9..5d6bdfcfac533 100644 --- a/clients/client-application-insights/runtimeConfig.ts +++ b/clients/client-application-insights/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApplicationInsightsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationInsightsClientConfig } from "./ApplicationInsightsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationInsightsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-applicationcostprofiler/ApplicationCostProfilerClient.ts b/clients/client-applicationcostprofiler/ApplicationCostProfilerClient.ts index 19893871d5e93..fc7efb9f8925f 100644 --- a/clients/client-applicationcostprofiler/ApplicationCostProfilerClient.ts +++ b/clients/client-applicationcostprofiler/ApplicationCostProfilerClient.ts @@ -22,7 +22,7 @@ import { UpdateReportDefinitionCommandInput, UpdateReportDefinitionCommandOutput, } from "./commands/UpdateReportDefinitionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -249,10 +249,7 @@ export class ApplicationCostProfilerClient extends __Client< readonly config: ApplicationCostProfilerClientResolvedConfig; constructor(configuration: ApplicationCostProfilerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-applicationcostprofiler/runtimeConfig.browser.ts b/clients/client-applicationcostprofiler/runtimeConfig.browser.ts index 4025cb9303e36..2b961c9f3482e 100644 --- a/clients/client-applicationcostprofiler/runtimeConfig.browser.ts +++ b/clients/client-applicationcostprofiler/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ApplicationCostProfilerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationCostProfilerClientConfig } from "./ApplicationCostProfilerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationCostProfilerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-applicationcostprofiler/runtimeConfig.native.ts b/clients/client-applicationcostprofiler/runtimeConfig.native.ts index c2c893ca1d7c1..a2592181a759b 100644 --- a/clients/client-applicationcostprofiler/runtimeConfig.native.ts +++ b/clients/client-applicationcostprofiler/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ApplicationCostProfilerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ApplicationCostProfilerClientConfig } from "./ApplicationCostProfilerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ApplicationCostProfilerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-applicationcostprofiler/runtimeConfig.shared.ts b/clients/client-applicationcostprofiler/runtimeConfig.shared.ts index 0897774225078..5d44e99b066e6 100644 --- a/clients/client-applicationcostprofiler/runtimeConfig.shared.ts +++ b/clients/client-applicationcostprofiler/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ApplicationCostProfilerClientConfig } from "./ApplicationCostProfilerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ApplicationCostProfilerClientConfig) => ({ apiVersion: "2020-09-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ApplicationCostProfiler", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ApplicationCostProfiler", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-applicationcostprofiler/runtimeConfig.ts b/clients/client-applicationcostprofiler/runtimeConfig.ts index ab1dea0ef29fd..b15ef6c00941c 100644 --- a/clients/client-applicationcostprofiler/runtimeConfig.ts +++ b/clients/client-applicationcostprofiler/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ApplicationCostProfilerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ApplicationCostProfilerClientConfig } from "./ApplicationCostProfilerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ApplicationCostProfilerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apprunner/AppRunnerClient.ts b/clients/client-apprunner/AppRunnerClient.ts index 4eeaa06845158..0c8a9cfcdfae9 100644 --- a/clients/client-apprunner/AppRunnerClient.ts +++ b/clients/client-apprunner/AppRunnerClient.ts @@ -44,7 +44,7 @@ import { StartDeploymentCommandInput, StartDeploymentCommandOutput } from "./com import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateServiceCommandInput, UpdateServiceCommandOutput } from "./commands/UpdateServiceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -317,10 +317,7 @@ export class AppRunnerClient extends __Client< readonly config: AppRunnerClientResolvedConfig; constructor(configuration: AppRunnerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-apprunner/runtimeConfig.browser.ts b/clients/client-apprunner/runtimeConfig.browser.ts index d2d3458310087..204008bcd10aa 100644 --- a/clients/client-apprunner/runtimeConfig.browser.ts +++ b/clients/client-apprunner/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppRunnerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppRunnerClientConfig } from "./AppRunnerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppRunnerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-apprunner/runtimeConfig.native.ts b/clients/client-apprunner/runtimeConfig.native.ts index 2e21b1f75054f..908f340c4a112 100644 --- a/clients/client-apprunner/runtimeConfig.native.ts +++ b/clients/client-apprunner/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppRunnerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppRunnerClientConfig } from "./AppRunnerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppRunnerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-apprunner/runtimeConfig.shared.ts b/clients/client-apprunner/runtimeConfig.shared.ts index ae8bf0c2889d0..5c1842a952c9d 100644 --- a/clients/client-apprunner/runtimeConfig.shared.ts +++ b/clients/client-apprunner/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppRunnerClientConfig } from "./AppRunnerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppRunnerClientConfig) => ({ apiVersion: "2020-05-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AppRunner", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AppRunner", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-apprunner/runtimeConfig.ts b/clients/client-apprunner/runtimeConfig.ts index 55a1762ca3097..b63ecea23e100 100644 --- a/clients/client-apprunner/runtimeConfig.ts +++ b/clients/client-apprunner/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppRunnerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppRunnerClientConfig } from "./AppRunnerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppRunnerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appstream/AppStreamClient.ts b/clients/client-appstream/AppStreamClient.ts index 851c57f03e579..ff69195c872ea 100644 --- a/clients/client-appstream/AppStreamClient.ts +++ b/clients/client-appstream/AppStreamClient.ts @@ -100,7 +100,7 @@ import { UpdateImagePermissionsCommandOutput, } from "./commands/UpdateImagePermissionsCommand"; import { UpdateStackCommandInput, UpdateStackCommandOutput } from "./commands/UpdateStackCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -426,10 +426,7 @@ export class AppStreamClient extends __Client< readonly config: AppStreamClientResolvedConfig; constructor(configuration: AppStreamClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-appstream/runtimeConfig.browser.ts b/clients/client-appstream/runtimeConfig.browser.ts index 911620f684c82..1e88aab058bc4 100644 --- a/clients/client-appstream/runtimeConfig.browser.ts +++ b/clients/client-appstream/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppStreamClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppStreamClientConfig } from "./AppStreamClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppStreamClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appstream/runtimeConfig.native.ts b/clients/client-appstream/runtimeConfig.native.ts index c1a80300960ae..29143f22ffdfa 100644 --- a/clients/client-appstream/runtimeConfig.native.ts +++ b/clients/client-appstream/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppStreamClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppStreamClientConfig } from "./AppStreamClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppStreamClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-appstream/runtimeConfig.shared.ts b/clients/client-appstream/runtimeConfig.shared.ts index ed6cfaa3f35c8..9b814cad013a6 100644 --- a/clients/client-appstream/runtimeConfig.shared.ts +++ b/clients/client-appstream/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppStreamClientConfig } from "./AppStreamClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppStreamClientConfig) => ({ apiVersion: "2016-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AppStream", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AppStream", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-appstream/runtimeConfig.ts b/clients/client-appstream/runtimeConfig.ts index 77aa0598d1f67..ad7622c1c9514 100644 --- a/clients/client-appstream/runtimeConfig.ts +++ b/clients/client-appstream/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppStreamClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppStreamClientConfig } from "./AppStreamClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppStreamClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appsync/AppSyncClient.ts b/clients/client-appsync/AppSyncClient.ts index fb1b5e39a32fa..5cfc6e736e32c 100644 --- a/clients/client-appsync/AppSyncClient.ts +++ b/clients/client-appsync/AppSyncClient.ts @@ -54,7 +54,7 @@ import { UpdateFunctionCommandInput, UpdateFunctionCommandOutput } from "./comma import { UpdateGraphqlApiCommandInput, UpdateGraphqlApiCommandOutput } from "./commands/UpdateGraphqlApiCommand"; import { UpdateResolverCommandInput, UpdateResolverCommandOutput } from "./commands/UpdateResolverCommand"; import { UpdateTypeCommandInput, UpdateTypeCommandOutput } from "./commands/UpdateTypeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -347,10 +347,7 @@ export class AppSyncClient extends __Client< readonly config: AppSyncClientResolvedConfig; constructor(configuration: AppSyncClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-appsync/runtimeConfig.browser.ts b/clients/client-appsync/runtimeConfig.browser.ts index 5dc7aebe93441..ba338ebdf974d 100644 --- a/clients/client-appsync/runtimeConfig.browser.ts +++ b/clients/client-appsync/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AppSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppSyncClientConfig } from "./AppSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-appsync/runtimeConfig.native.ts b/clients/client-appsync/runtimeConfig.native.ts index 654490b403a89..46348942f5d85 100644 --- a/clients/client-appsync/runtimeConfig.native.ts +++ b/clients/client-appsync/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AppSyncClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AppSyncClientConfig } from "./AppSyncClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AppSyncClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-appsync/runtimeConfig.shared.ts b/clients/client-appsync/runtimeConfig.shared.ts index 0489f39874db5..0f75b5f6dabe4 100644 --- a/clients/client-appsync/runtimeConfig.shared.ts +++ b/clients/client-appsync/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AppSyncClientConfig } from "./AppSyncClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AppSyncClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AppSync", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AppSync", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-appsync/runtimeConfig.ts b/clients/client-appsync/runtimeConfig.ts index 1ea96d492d529..01af6305ae79d 100644 --- a/clients/client-appsync/runtimeConfig.ts +++ b/clients/client-appsync/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AppSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AppSyncClientConfig } from "./AppSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AppSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-athena/AthenaClient.ts b/clients/client-athena/AthenaClient.ts index 79ed0e075a532..2d52227909445 100644 --- a/clients/client-athena/AthenaClient.ts +++ b/clients/client-athena/AthenaClient.ts @@ -59,7 +59,7 @@ import { UpdatePreparedStatementCommandOutput, } from "./commands/UpdatePreparedStatementCommand"; import { UpdateWorkGroupCommandInput, UpdateWorkGroupCommandOutput } from "./commands/UpdateWorkGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -349,10 +349,7 @@ export class AthenaClient extends __Client< readonly config: AthenaClientResolvedConfig; constructor(configuration: AthenaClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-athena/runtimeConfig.browser.ts b/clients/client-athena/runtimeConfig.browser.ts index 4af4ba97c133b..58112c98d9aca 100644 --- a/clients/client-athena/runtimeConfig.browser.ts +++ b/clients/client-athena/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AthenaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AthenaClientConfig } from "./AthenaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AthenaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-athena/runtimeConfig.native.ts b/clients/client-athena/runtimeConfig.native.ts index 52bf91eea9a34..67f2064992b49 100644 --- a/clients/client-athena/runtimeConfig.native.ts +++ b/clients/client-athena/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AthenaClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AthenaClientConfig } from "./AthenaClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AthenaClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-athena/runtimeConfig.shared.ts b/clients/client-athena/runtimeConfig.shared.ts index c49b540b0da22..c1c0b24fca4b1 100644 --- a/clients/client-athena/runtimeConfig.shared.ts +++ b/clients/client-athena/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AthenaClientConfig } from "./AthenaClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AthenaClientConfig) => ({ apiVersion: "2017-05-18", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Athena", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Athena", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-athena/runtimeConfig.ts b/clients/client-athena/runtimeConfig.ts index b09318a378dd9..f79fb4732c095 100644 --- a/clients/client-athena/runtimeConfig.ts +++ b/clients/client-athena/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AthenaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AthenaClientConfig } from "./AthenaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AthenaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auditmanager/AuditManagerClient.ts b/clients/client-auditmanager/AuditManagerClient.ts index e550387e23de5..8a14c251c3263 100644 --- a/clients/client-auditmanager/AuditManagerClient.ts +++ b/clients/client-auditmanager/AuditManagerClient.ts @@ -133,7 +133,7 @@ import { ValidateAssessmentReportIntegrityCommandInput, ValidateAssessmentReportIntegrityCommandOutput, } from "./commands/ValidateAssessmentReportIntegrityCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -481,10 +481,7 @@ export class AuditManagerClient extends __Client< readonly config: AuditManagerClientResolvedConfig; constructor(configuration: AuditManagerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-auditmanager/runtimeConfig.browser.ts b/clients/client-auditmanager/runtimeConfig.browser.ts index 1b7fd7ef03e16..9ecccdf24dfd1 100644 --- a/clients/client-auditmanager/runtimeConfig.browser.ts +++ b/clients/client-auditmanager/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AuditManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AuditManagerClientConfig } from "./AuditManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AuditManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auditmanager/runtimeConfig.native.ts b/clients/client-auditmanager/runtimeConfig.native.ts index 39f3318e0feac..fdef0d81e4d13 100644 --- a/clients/client-auditmanager/runtimeConfig.native.ts +++ b/clients/client-auditmanager/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AuditManagerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AuditManagerClientConfig } from "./AuditManagerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AuditManagerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-auditmanager/runtimeConfig.shared.ts b/clients/client-auditmanager/runtimeConfig.shared.ts index 4b1685d4eca67..20d217539d3e5 100644 --- a/clients/client-auditmanager/runtimeConfig.shared.ts +++ b/clients/client-auditmanager/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AuditManagerClientConfig } from "./AuditManagerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AuditManagerClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "AuditManager", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "AuditManager", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-auditmanager/runtimeConfig.ts b/clients/client-auditmanager/runtimeConfig.ts index bbf4aa27a1478..fe79845f0fd3b 100644 --- a/clients/client-auditmanager/runtimeConfig.ts +++ b/clients/client-auditmanager/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AuditManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AuditManagerClientConfig } from "./AuditManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AuditManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auto-scaling-plans/AutoScalingPlansClient.ts b/clients/client-auto-scaling-plans/AutoScalingPlansClient.ts index 7a46225fa09fe..7afbff7a0c330 100644 --- a/clients/client-auto-scaling-plans/AutoScalingPlansClient.ts +++ b/clients/client-auto-scaling-plans/AutoScalingPlansClient.ts @@ -13,7 +13,7 @@ import { GetScalingPlanResourceForecastDataCommandOutput, } from "./commands/GetScalingPlanResourceForecastDataCommand"; import { UpdateScalingPlanCommandInput, UpdateScalingPlanCommandOutput } from "./commands/UpdateScalingPlanCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -269,10 +269,7 @@ export class AutoScalingPlansClient extends __Client< readonly config: AutoScalingPlansClientResolvedConfig; constructor(configuration: AutoScalingPlansClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-auto-scaling-plans/runtimeConfig.browser.ts b/clients/client-auto-scaling-plans/runtimeConfig.browser.ts index b7313c434d679..4952af7c20f39 100644 --- a/clients/client-auto-scaling-plans/runtimeConfig.browser.ts +++ b/clients/client-auto-scaling-plans/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AutoScalingPlansClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AutoScalingPlansClientConfig } from "./AutoScalingPlansClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AutoScalingPlansClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auto-scaling-plans/runtimeConfig.native.ts b/clients/client-auto-scaling-plans/runtimeConfig.native.ts index 0905c54131957..321b9a4e61be1 100644 --- a/clients/client-auto-scaling-plans/runtimeConfig.native.ts +++ b/clients/client-auto-scaling-plans/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AutoScalingPlansClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AutoScalingPlansClientConfig } from "./AutoScalingPlansClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AutoScalingPlansClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-auto-scaling-plans/runtimeConfig.shared.ts b/clients/client-auto-scaling-plans/runtimeConfig.shared.ts index 50bc6d681c7e7..1a65afce7c4dd 100644 --- a/clients/client-auto-scaling-plans/runtimeConfig.shared.ts +++ b/clients/client-auto-scaling-plans/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AutoScalingPlansClientConfig } from "./AutoScalingPlansClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AutoScalingPlansClientConfig) => ({ apiVersion: "2018-01-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Auto Scaling Plans", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Auto Scaling Plans", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-auto-scaling-plans/runtimeConfig.ts b/clients/client-auto-scaling-plans/runtimeConfig.ts index 98519490369b1..febb03bbae09c 100644 --- a/clients/client-auto-scaling-plans/runtimeConfig.ts +++ b/clients/client-auto-scaling-plans/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AutoScalingPlansClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AutoScalingPlansClientConfig } from "./AutoScalingPlansClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AutoScalingPlansClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auto-scaling/AutoScalingClient.ts b/clients/client-auto-scaling/AutoScalingClient.ts index 0fd90f9d6bd21..18535032fbd74 100644 --- a/clients/client-auto-scaling/AutoScalingClient.ts +++ b/clients/client-auto-scaling/AutoScalingClient.ts @@ -185,7 +185,7 @@ import { UpdateAutoScalingGroupCommandInput, UpdateAutoScalingGroupCommandOutput, } from "./commands/UpdateAutoScalingGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -530,10 +530,7 @@ export class AutoScalingClient extends __Client< readonly config: AutoScalingClientResolvedConfig; constructor(configuration: AutoScalingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-auto-scaling/runtimeConfig.browser.ts b/clients/client-auto-scaling/runtimeConfig.browser.ts index f08e8ec1df533..afb25f4edd999 100644 --- a/clients/client-auto-scaling/runtimeConfig.browser.ts +++ b/clients/client-auto-scaling/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./AutoScalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AutoScalingClientConfig } from "./AutoScalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AutoScalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-auto-scaling/runtimeConfig.native.ts b/clients/client-auto-scaling/runtimeConfig.native.ts index b8a92bbc4f9c5..068cce764e9f5 100644 --- a/clients/client-auto-scaling/runtimeConfig.native.ts +++ b/clients/client-auto-scaling/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./AutoScalingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { AutoScalingClientConfig } from "./AutoScalingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: AutoScalingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-auto-scaling/runtimeConfig.shared.ts b/clients/client-auto-scaling/runtimeConfig.shared.ts index 340c7042ad91d..d6a93ec729e94 100644 --- a/clients/client-auto-scaling/runtimeConfig.shared.ts +++ b/clients/client-auto-scaling/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { AutoScalingClientConfig } from "./AutoScalingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: AutoScalingClientConfig) => ({ apiVersion: "2011-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Auto Scaling", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Auto Scaling", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-auto-scaling/runtimeConfig.ts b/clients/client-auto-scaling/runtimeConfig.ts index 97ce8a17801b7..9ab70d182202a 100644 --- a/clients/client-auto-scaling/runtimeConfig.ts +++ b/clients/client-auto-scaling/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./AutoScalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { AutoScalingClientConfig } from "./AutoScalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: AutoScalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-backup/BackupClient.ts b/clients/client-backup/BackupClient.ts index f1273e4bfbacc..27c39804dd785 100644 --- a/clients/client-backup/BackupClient.ts +++ b/clients/client-backup/BackupClient.ts @@ -136,7 +136,7 @@ import { UpdateRegionSettingsCommandInput, UpdateRegionSettingsCommandOutput, } from "./commands/UpdateRegionSettingsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -451,10 +451,7 @@ export class BackupClient extends __Client< readonly config: BackupClientResolvedConfig; constructor(configuration: BackupClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-backup/runtimeConfig.browser.ts b/clients/client-backup/runtimeConfig.browser.ts index ad193624ad78f..fe011e9643591 100644 --- a/clients/client-backup/runtimeConfig.browser.ts +++ b/clients/client-backup/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./BackupClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BackupClientConfig } from "./BackupClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BackupClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-backup/runtimeConfig.native.ts b/clients/client-backup/runtimeConfig.native.ts index 32126933e41a2..a08ae1ad5b901 100644 --- a/clients/client-backup/runtimeConfig.native.ts +++ b/clients/client-backup/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./BackupClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { BackupClientConfig } from "./BackupClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: BackupClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-backup/runtimeConfig.shared.ts b/clients/client-backup/runtimeConfig.shared.ts index a91555241ba5c..c712f778d85d5 100644 --- a/clients/client-backup/runtimeConfig.shared.ts +++ b/clients/client-backup/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { BackupClientConfig } from "./BackupClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: BackupClientConfig) => ({ apiVersion: "2018-11-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Backup", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Backup", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-backup/runtimeConfig.ts b/clients/client-backup/runtimeConfig.ts index 03120297cd84b..0d32525245568 100644 --- a/clients/client-backup/runtimeConfig.ts +++ b/clients/client-backup/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./BackupClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BackupClientConfig } from "./BackupClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BackupClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-batch/BatchClient.ts b/clients/client-batch/BatchClient.ts index 15a8882a9a60d..598907ae2be44 100644 --- a/clients/client-batch/BatchClient.ts +++ b/clients/client-batch/BatchClient.ts @@ -41,7 +41,7 @@ import { UpdateComputeEnvironmentCommandOutput, } from "./commands/UpdateComputeEnvironmentCommand"; import { UpdateJobQueueCommandInput, UpdateJobQueueCommandOutput } from "./commands/UpdateJobQueueCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -298,10 +298,7 @@ export class BatchClient extends __Client< readonly config: BatchClientResolvedConfig; constructor(configuration: BatchClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-batch/runtimeConfig.browser.ts b/clients/client-batch/runtimeConfig.browser.ts index 8fea008eae841..7925b9612d314 100644 --- a/clients/client-batch/runtimeConfig.browser.ts +++ b/clients/client-batch/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./BatchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BatchClientConfig } from "./BatchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BatchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-batch/runtimeConfig.native.ts b/clients/client-batch/runtimeConfig.native.ts index fdb8beb9d309b..fdc9d54e9e36e 100644 --- a/clients/client-batch/runtimeConfig.native.ts +++ b/clients/client-batch/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./BatchClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { BatchClientConfig } from "./BatchClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: BatchClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-batch/runtimeConfig.shared.ts b/clients/client-batch/runtimeConfig.shared.ts index 9bcc09bfd0db1..c257dc78ff7b3 100644 --- a/clients/client-batch/runtimeConfig.shared.ts +++ b/clients/client-batch/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { BatchClientConfig } from "./BatchClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: BatchClientConfig) => ({ apiVersion: "2016-08-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Batch", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Batch", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-batch/runtimeConfig.ts b/clients/client-batch/runtimeConfig.ts index ce60cebe443e6..c134edf238457 100644 --- a/clients/client-batch/runtimeConfig.ts +++ b/clients/client-batch/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./BatchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BatchClientConfig } from "./BatchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BatchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-braket/BraketClient.ts b/clients/client-braket/BraketClient.ts index a3b350f417127..67f2b2d9649bb 100644 --- a/clients/client-braket/BraketClient.ts +++ b/clients/client-braket/BraketClient.ts @@ -10,7 +10,7 @@ import { SearchDevicesCommandInput, SearchDevicesCommandOutput } from "./command import { SearchQuantumTasksCommandInput, SearchQuantumTasksCommandOutput } from "./commands/SearchQuantumTasksCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -238,10 +238,7 @@ export class BraketClient extends __Client< readonly config: BraketClientResolvedConfig; constructor(configuration: BraketClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-braket/runtimeConfig.browser.ts b/clients/client-braket/runtimeConfig.browser.ts index 0cd448919840a..57a219d1a97cd 100644 --- a/clients/client-braket/runtimeConfig.browser.ts +++ b/clients/client-braket/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./BraketClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BraketClientConfig } from "./BraketClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BraketClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-braket/runtimeConfig.native.ts b/clients/client-braket/runtimeConfig.native.ts index 9854850cc854f..dcfa9962a2fea 100644 --- a/clients/client-braket/runtimeConfig.native.ts +++ b/clients/client-braket/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./BraketClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { BraketClientConfig } from "./BraketClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: BraketClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-braket/runtimeConfig.shared.ts b/clients/client-braket/runtimeConfig.shared.ts index cc025b8ef97b5..d1c06d24464d1 100644 --- a/clients/client-braket/runtimeConfig.shared.ts +++ b/clients/client-braket/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { BraketClientConfig } from "./BraketClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: BraketClientConfig) => ({ apiVersion: "2019-09-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Braket", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Braket", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-braket/runtimeConfig.ts b/clients/client-braket/runtimeConfig.ts index 86f82c0d44a50..243de27fbf348 100644 --- a/clients/client-braket/runtimeConfig.ts +++ b/clients/client-braket/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./BraketClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BraketClientConfig } from "./BraketClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BraketClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-budgets/BudgetsClient.ts b/clients/client-budgets/BudgetsClient.ts index d381fc27962ce..4774f477ea204 100644 --- a/clients/client-budgets/BudgetsClient.ts +++ b/clients/client-budgets/BudgetsClient.ts @@ -44,7 +44,7 @@ import { UpdateBudgetActionCommandInput, UpdateBudgetActionCommandOutput } from import { UpdateBudgetCommandInput, UpdateBudgetCommandOutput } from "./commands/UpdateBudgetCommand"; import { UpdateNotificationCommandInput, UpdateNotificationCommandOutput } from "./commands/UpdateNotificationCommand"; import { UpdateSubscriberCommandInput, UpdateSubscriberCommandOutput } from "./commands/UpdateSubscriberCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -340,10 +340,7 @@ export class BudgetsClient extends __Client< readonly config: BudgetsClientResolvedConfig; constructor(configuration: BudgetsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-budgets/runtimeConfig.browser.ts b/clients/client-budgets/runtimeConfig.browser.ts index 9c3f8ebe80e31..5d98acd5772b8 100644 --- a/clients/client-budgets/runtimeConfig.browser.ts +++ b/clients/client-budgets/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./BudgetsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BudgetsClientConfig } from "./BudgetsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BudgetsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-budgets/runtimeConfig.native.ts b/clients/client-budgets/runtimeConfig.native.ts index 71ca5b3adbf23..ae786be00c393 100644 --- a/clients/client-budgets/runtimeConfig.native.ts +++ b/clients/client-budgets/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./BudgetsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { BudgetsClientConfig } from "./BudgetsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: BudgetsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-budgets/runtimeConfig.shared.ts b/clients/client-budgets/runtimeConfig.shared.ts index 5d821abfa43f7..5520c35361edf 100644 --- a/clients/client-budgets/runtimeConfig.shared.ts +++ b/clients/client-budgets/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { BudgetsClientConfig } from "./BudgetsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: BudgetsClientConfig) => ({ apiVersion: "2016-10-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Budgets", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Budgets", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-budgets/runtimeConfig.ts b/clients/client-budgets/runtimeConfig.ts index b2058eb29a75f..9d7425295690e 100644 --- a/clients/client-budgets/runtimeConfig.ts +++ b/clients/client-budgets/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./BudgetsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { BudgetsClientConfig } from "./BudgetsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: BudgetsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-chime/ChimeClient.ts b/clients/client-chime/ChimeClient.ts index e1eadb91c5d91..a2fd5db222315 100644 --- a/clients/client-chime/ChimeClient.ts +++ b/clients/client-chime/ChimeClient.ts @@ -522,7 +522,7 @@ import { UpdateVoiceConnectorGroupCommandInput, UpdateVoiceConnectorGroupCommandOutput, } from "./commands/UpdateVoiceConnectorGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -1147,10 +1147,7 @@ export class ChimeClient extends __Client< readonly config: ChimeClientResolvedConfig; constructor(configuration: ChimeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-chime/runtimeConfig.browser.ts b/clients/client-chime/runtimeConfig.browser.ts index 4e167a2b08b12..7bead02429978 100644 --- a/clients/client-chime/runtimeConfig.browser.ts +++ b/clients/client-chime/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ChimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ChimeClientConfig } from "./ChimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ChimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-chime/runtimeConfig.native.ts b/clients/client-chime/runtimeConfig.native.ts index 61c525ebffc42..9283cddacf2a2 100644 --- a/clients/client-chime/runtimeConfig.native.ts +++ b/clients/client-chime/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ChimeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ChimeClientConfig } from "./ChimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ChimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-chime/runtimeConfig.shared.ts b/clients/client-chime/runtimeConfig.shared.ts index a9d41c9d370ff..8b2cacbe499f4 100644 --- a/clients/client-chime/runtimeConfig.shared.ts +++ b/clients/client-chime/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ChimeClientConfig } from "./ChimeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ChimeClientConfig) => ({ apiVersion: "2018-05-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Chime", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Chime", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-chime/runtimeConfig.ts b/clients/client-chime/runtimeConfig.ts index 5e3e0ec21e9d1..3db8cfe98ac06 100644 --- a/clients/client-chime/runtimeConfig.ts +++ b/clients/client-chime/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ChimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ChimeClientConfig } from "./ChimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ChimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloud9/Cloud9Client.ts b/clients/client-cloud9/Cloud9Client.ts index e3ec2f2050eb7..8b4dc6184659a 100644 --- a/clients/client-cloud9/Cloud9Client.ts +++ b/clients/client-cloud9/Cloud9Client.ts @@ -35,7 +35,7 @@ import { UpdateEnvironmentMembershipCommandInput, UpdateEnvironmentMembershipCommandOutput, } from "./commands/UpdateEnvironmentMembershipCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -337,10 +337,7 @@ export class Cloud9Client extends __Client< readonly config: Cloud9ClientResolvedConfig; constructor(configuration: Cloud9ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloud9/runtimeConfig.browser.ts b/clients/client-cloud9/runtimeConfig.browser.ts index 763cf2a113564..d509cce28b208 100644 --- a/clients/client-cloud9/runtimeConfig.browser.ts +++ b/clients/client-cloud9/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./Cloud9Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Cloud9ClientConfig } from "./Cloud9Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Cloud9ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloud9/runtimeConfig.native.ts b/clients/client-cloud9/runtimeConfig.native.ts index b5bfa055e1938..9d76f1e061d28 100644 --- a/clients/client-cloud9/runtimeConfig.native.ts +++ b/clients/client-cloud9/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./Cloud9Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { Cloud9ClientConfig } from "./Cloud9Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: Cloud9ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloud9/runtimeConfig.shared.ts b/clients/client-cloud9/runtimeConfig.shared.ts index f3e4ffb2e6174..f6ccfa23b88d4 100644 --- a/clients/client-cloud9/runtimeConfig.shared.ts +++ b/clients/client-cloud9/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { Cloud9ClientConfig } from "./Cloud9Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: Cloud9ClientConfig) => ({ apiVersion: "2017-09-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cloud9", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cloud9", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloud9/runtimeConfig.ts b/clients/client-cloud9/runtimeConfig.ts index be391363a2117..ea29fc9775e86 100644 --- a/clients/client-cloud9/runtimeConfig.ts +++ b/clients/client-cloud9/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./Cloud9Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Cloud9ClientConfig } from "./Cloud9Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Cloud9ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-clouddirectory/CloudDirectoryClient.ts b/clients/client-clouddirectory/CloudDirectoryClient.ts index 73afc3850e5fc..a014dd9a1a78d 100644 --- a/clients/client-clouddirectory/CloudDirectoryClient.ts +++ b/clients/client-clouddirectory/CloudDirectoryClient.ts @@ -142,7 +142,7 @@ import { UpgradePublishedSchemaCommandInput, UpgradePublishedSchemaCommandOutput, } from "./commands/UpgradePublishedSchemaCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -489,10 +489,7 @@ export class CloudDirectoryClient extends __Client< readonly config: CloudDirectoryClientResolvedConfig; constructor(configuration: CloudDirectoryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-clouddirectory/runtimeConfig.browser.ts b/clients/client-clouddirectory/runtimeConfig.browser.ts index 4d1089cd137c6..b043e3e6a22a4 100644 --- a/clients/client-clouddirectory/runtimeConfig.browser.ts +++ b/clients/client-clouddirectory/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudDirectoryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudDirectoryClientConfig } from "./CloudDirectoryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudDirectoryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-clouddirectory/runtimeConfig.native.ts b/clients/client-clouddirectory/runtimeConfig.native.ts index 19d66ff266e0b..b57cdb64e6302 100644 --- a/clients/client-clouddirectory/runtimeConfig.native.ts +++ b/clients/client-clouddirectory/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudDirectoryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudDirectoryClientConfig } from "./CloudDirectoryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudDirectoryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-clouddirectory/runtimeConfig.shared.ts b/clients/client-clouddirectory/runtimeConfig.shared.ts index e78dd55e2441c..7537a543fab70 100644 --- a/clients/client-clouddirectory/runtimeConfig.shared.ts +++ b/clients/client-clouddirectory/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudDirectoryClientConfig } from "./CloudDirectoryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudDirectoryClientConfig) => ({ apiVersion: "2017-01-11", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudDirectory", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudDirectory", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-clouddirectory/runtimeConfig.ts b/clients/client-clouddirectory/runtimeConfig.ts index 3db5f431b337b..f2972d4b89672 100644 --- a/clients/client-clouddirectory/runtimeConfig.ts +++ b/clients/client-clouddirectory/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudDirectoryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudDirectoryClientConfig } from "./CloudDirectoryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudDirectoryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudformation/CloudFormationClient.ts b/clients/client-cloudformation/CloudFormationClient.ts index 29615d337a6cc..7b27d59e824c3 100644 --- a/clients/client-cloudformation/CloudFormationClient.ts +++ b/clients/client-cloudformation/CloudFormationClient.ts @@ -136,7 +136,7 @@ import { UpdateTerminationProtectionCommandOutput, } from "./commands/UpdateTerminationProtectionCommand"; import { ValidateTemplateCommandInput, ValidateTemplateCommandOutput } from "./commands/ValidateTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -486,10 +486,7 @@ export class CloudFormationClient extends __Client< readonly config: CloudFormationClientResolvedConfig; constructor(configuration: CloudFormationClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudformation/runtimeConfig.browser.ts b/clients/client-cloudformation/runtimeConfig.browser.ts index 4ab277aee21f9..d9dec74bc00f0 100644 --- a/clients/client-cloudformation/runtimeConfig.browser.ts +++ b/clients/client-cloudformation/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudFormationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudFormationClientConfig } from "./CloudFormationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudFormationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudformation/runtimeConfig.native.ts b/clients/client-cloudformation/runtimeConfig.native.ts index d76c0e3c37bbd..20477947c328a 100644 --- a/clients/client-cloudformation/runtimeConfig.native.ts +++ b/clients/client-cloudformation/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudFormationClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudFormationClientConfig } from "./CloudFormationClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudFormationClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudformation/runtimeConfig.shared.ts b/clients/client-cloudformation/runtimeConfig.shared.ts index b58bda278ff9d..37b4948a5de5b 100644 --- a/clients/client-cloudformation/runtimeConfig.shared.ts +++ b/clients/client-cloudformation/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudFormationClientConfig } from "./CloudFormationClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudFormationClientConfig) => ({ apiVersion: "2010-05-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudFormation", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudFormation", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudformation/runtimeConfig.ts b/clients/client-cloudformation/runtimeConfig.ts index f58933d7ee85c..3bbe114c23f8b 100644 --- a/clients/client-cloudformation/runtimeConfig.ts +++ b/clients/client-cloudformation/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudFormationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudFormationClientConfig } from "./CloudFormationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudFormationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudfront/CloudFrontClient.ts b/clients/client-cloudfront/CloudFrontClient.ts index bd0cf3c95e00a..7bc155d468598 100644 --- a/clients/client-cloudfront/CloudFrontClient.ts +++ b/clients/client-cloudfront/CloudFrontClient.ts @@ -230,7 +230,7 @@ import { UpdateStreamingDistributionCommandInput, UpdateStreamingDistributionCommandOutput, } from "./commands/UpdateStreamingDistributionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -613,10 +613,7 @@ export class CloudFrontClient extends __Client< readonly config: CloudFrontClientResolvedConfig; constructor(configuration: CloudFrontClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudfront/runtimeConfig.browser.ts b/clients/client-cloudfront/runtimeConfig.browser.ts index a76fb470340b6..902d6b299c4cc 100644 --- a/clients/client-cloudfront/runtimeConfig.browser.ts +++ b/clients/client-cloudfront/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudFrontClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudFrontClientConfig } from "./CloudFrontClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudFrontClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudfront/runtimeConfig.native.ts b/clients/client-cloudfront/runtimeConfig.native.ts index 772b6ed797b89..80fefc46c724a 100644 --- a/clients/client-cloudfront/runtimeConfig.native.ts +++ b/clients/client-cloudfront/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudFrontClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudFrontClientConfig } from "./CloudFrontClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudFrontClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudfront/runtimeConfig.shared.ts b/clients/client-cloudfront/runtimeConfig.shared.ts index 2a35df519d2c4..271074be5529a 100644 --- a/clients/client-cloudfront/runtimeConfig.shared.ts +++ b/clients/client-cloudfront/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudFrontClientConfig } from "./CloudFrontClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudFrontClientConfig) => ({ apiVersion: "2020-05-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudFront", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudFront", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudfront/runtimeConfig.ts b/clients/client-cloudfront/runtimeConfig.ts index c4d953e3e47d9..30bdfdb2210a1 100644 --- a/clients/client-cloudfront/runtimeConfig.ts +++ b/clients/client-cloudfront/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudFrontClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudFrontClientConfig } from "./CloudFrontClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudFrontClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudhsm-v2/CloudHSMV2Client.ts b/clients/client-cloudhsm-v2/CloudHSMV2Client.ts index 5dbd39d363715..4d3f3e4a80a5a 100644 --- a/clients/client-cloudhsm-v2/CloudHSMV2Client.ts +++ b/clients/client-cloudhsm-v2/CloudHSMV2Client.ts @@ -16,7 +16,7 @@ import { ModifyClusterCommandInput, ModifyClusterCommandOutput } from "./command import { RestoreBackupCommandInput, RestoreBackupCommandOutput } from "./commands/RestoreBackupCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -257,10 +257,7 @@ export class CloudHSMV2Client extends __Client< readonly config: CloudHSMV2ClientResolvedConfig; constructor(configuration: CloudHSMV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudhsm-v2/runtimeConfig.browser.ts b/clients/client-cloudhsm-v2/runtimeConfig.browser.ts index f41d6b7616f51..156413e6af641 100644 --- a/clients/client-cloudhsm-v2/runtimeConfig.browser.ts +++ b/clients/client-cloudhsm-v2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudHSMV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudHSMV2ClientConfig } from "./CloudHSMV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudHSMV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudhsm-v2/runtimeConfig.native.ts b/clients/client-cloudhsm-v2/runtimeConfig.native.ts index 415b48dd6f425..0f23cd2f33c0f 100644 --- a/clients/client-cloudhsm-v2/runtimeConfig.native.ts +++ b/clients/client-cloudhsm-v2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudHSMV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudHSMV2ClientConfig } from "./CloudHSMV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudHSMV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudhsm-v2/runtimeConfig.shared.ts b/clients/client-cloudhsm-v2/runtimeConfig.shared.ts index f6765127fc694..cc5a30b4f9b29 100644 --- a/clients/client-cloudhsm-v2/runtimeConfig.shared.ts +++ b/clients/client-cloudhsm-v2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudHSMV2ClientConfig } from "./CloudHSMV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudHSMV2ClientConfig) => ({ apiVersion: "2017-04-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudHSM V2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudHSM V2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudhsm-v2/runtimeConfig.ts b/clients/client-cloudhsm-v2/runtimeConfig.ts index 84c861d78c56d..33005cca4fd55 100644 --- a/clients/client-cloudhsm-v2/runtimeConfig.ts +++ b/clients/client-cloudhsm-v2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudHSMV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudHSMV2ClientConfig } from "./CloudHSMV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudHSMV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudhsm/CloudHSMClient.ts b/clients/client-cloudhsm/CloudHSMClient.ts index 15ca381aac4e7..8c68235f2acdf 100644 --- a/clients/client-cloudhsm/CloudHSMClient.ts +++ b/clients/client-cloudhsm/CloudHSMClient.ts @@ -24,7 +24,7 @@ import { RemoveTagsFromResourceCommandInput, RemoveTagsFromResourceCommandOutput, } from "./commands/RemoveTagsFromResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -284,10 +284,7 @@ export class CloudHSMClient extends __Client< readonly config: CloudHSMClientResolvedConfig; constructor(configuration: CloudHSMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudhsm/runtimeConfig.browser.ts b/clients/client-cloudhsm/runtimeConfig.browser.ts index 9a484bd1f2753..d5342e40aaa21 100644 --- a/clients/client-cloudhsm/runtimeConfig.browser.ts +++ b/clients/client-cloudhsm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudHSMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudHSMClientConfig } from "./CloudHSMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudHSMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudhsm/runtimeConfig.native.ts b/clients/client-cloudhsm/runtimeConfig.native.ts index 0f609ee33bc46..cbf82826508b9 100644 --- a/clients/client-cloudhsm/runtimeConfig.native.ts +++ b/clients/client-cloudhsm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudHSMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudHSMClientConfig } from "./CloudHSMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudHSMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudhsm/runtimeConfig.shared.ts b/clients/client-cloudhsm/runtimeConfig.shared.ts index bf88b243cf01d..24c82fc5ccb2d 100644 --- a/clients/client-cloudhsm/runtimeConfig.shared.ts +++ b/clients/client-cloudhsm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudHSMClientConfig } from "./CloudHSMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudHSMClientConfig) => ({ apiVersion: "2014-05-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudHSM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudHSM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudhsm/runtimeConfig.ts b/clients/client-cloudhsm/runtimeConfig.ts index ca350d5fb9fa1..3208507d3991f 100644 --- a/clients/client-cloudhsm/runtimeConfig.ts +++ b/clients/client-cloudhsm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudHSMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudHSMClientConfig } from "./CloudHSMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudHSMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudsearch-domain/CloudSearchDomainClient.ts b/clients/client-cloudsearch-domain/CloudSearchDomainClient.ts index a73687c4e2773..7f188a27256ea 100644 --- a/clients/client-cloudsearch-domain/CloudSearchDomainClient.ts +++ b/clients/client-cloudsearch-domain/CloudSearchDomainClient.ts @@ -1,7 +1,7 @@ import { SearchCommandInput, SearchCommandOutput } from "./commands/SearchCommand"; import { SuggestCommandInput, SuggestCommandOutput } from "./commands/SuggestCommand"; import { UploadDocumentsCommandInput, UploadDocumentsCommandOutput } from "./commands/UploadDocumentsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -214,10 +214,7 @@ export class CloudSearchDomainClient extends __Client< readonly config: CloudSearchDomainClientResolvedConfig; constructor(configuration: CloudSearchDomainClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudsearch-domain/runtimeConfig.browser.ts b/clients/client-cloudsearch-domain/runtimeConfig.browser.ts index 4e82b9877e9aa..23c3fed2b9c36 100644 --- a/clients/client-cloudsearch-domain/runtimeConfig.browser.ts +++ b/clients/client-cloudsearch-domain/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudSearchDomainClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudSearchDomainClientConfig } from "./CloudSearchDomainClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudSearchDomainClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudsearch-domain/runtimeConfig.native.ts b/clients/client-cloudsearch-domain/runtimeConfig.native.ts index 471b3914c23b0..ce0a66d8c1638 100644 --- a/clients/client-cloudsearch-domain/runtimeConfig.native.ts +++ b/clients/client-cloudsearch-domain/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudSearchDomainClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudSearchDomainClientConfig } from "./CloudSearchDomainClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudSearchDomainClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudsearch-domain/runtimeConfig.shared.ts b/clients/client-cloudsearch-domain/runtimeConfig.shared.ts index c64436bd76cf1..f9459ddb86202 100644 --- a/clients/client-cloudsearch-domain/runtimeConfig.shared.ts +++ b/clients/client-cloudsearch-domain/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudSearchDomainClientConfig } from "./CloudSearchDomainClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudSearchDomainClientConfig) => ({ apiVersion: "2013-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudSearch Domain", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudSearch Domain", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudsearch-domain/runtimeConfig.ts b/clients/client-cloudsearch-domain/runtimeConfig.ts index 3306c0d64de77..03eb83ff36d03 100644 --- a/clients/client-cloudsearch-domain/runtimeConfig.ts +++ b/clients/client-cloudsearch-domain/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudSearchDomainClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudSearchDomainClientConfig } from "./CloudSearchDomainClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudSearchDomainClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudsearch/CloudSearchClient.ts b/clients/client-cloudsearch/CloudSearchClient.ts index 82933c748f645..3ed1a77922a33 100644 --- a/clients/client-cloudsearch/CloudSearchClient.ts +++ b/clients/client-cloudsearch/CloudSearchClient.ts @@ -63,7 +63,7 @@ import { UpdateServiceAccessPoliciesCommandInput, UpdateServiceAccessPoliciesCommandOutput, } from "./commands/UpdateServiceAccessPoliciesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -331,10 +331,7 @@ export class CloudSearchClient extends __Client< readonly config: CloudSearchClientResolvedConfig; constructor(configuration: CloudSearchClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudsearch/runtimeConfig.browser.ts b/clients/client-cloudsearch/runtimeConfig.browser.ts index f6edeefbb8003..774716319e2e4 100644 --- a/clients/client-cloudsearch/runtimeConfig.browser.ts +++ b/clients/client-cloudsearch/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudSearchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudSearchClientConfig } from "./CloudSearchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudSearchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudsearch/runtimeConfig.native.ts b/clients/client-cloudsearch/runtimeConfig.native.ts index 205b2f37af34b..c12d94559669c 100644 --- a/clients/client-cloudsearch/runtimeConfig.native.ts +++ b/clients/client-cloudsearch/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudSearchClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudSearchClientConfig } from "./CloudSearchClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudSearchClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudsearch/runtimeConfig.shared.ts b/clients/client-cloudsearch/runtimeConfig.shared.ts index 852e6819ff3f2..24184a693bc51 100644 --- a/clients/client-cloudsearch/runtimeConfig.shared.ts +++ b/clients/client-cloudsearch/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudSearchClientConfig } from "./CloudSearchClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudSearchClientConfig) => ({ apiVersion: "2013-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudSearch", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudSearch", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudsearch/runtimeConfig.ts b/clients/client-cloudsearch/runtimeConfig.ts index 093bef6056bce..9341e1f231a89 100644 --- a/clients/client-cloudsearch/runtimeConfig.ts +++ b/clients/client-cloudsearch/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudSearchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudSearchClientConfig } from "./CloudSearchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudSearchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudtrail/CloudTrailClient.ts b/clients/client-cloudtrail/CloudTrailClient.ts index 8f1846c3857cb..e42ec7c1c3f55 100644 --- a/clients/client-cloudtrail/CloudTrailClient.ts +++ b/clients/client-cloudtrail/CloudTrailClient.ts @@ -22,7 +22,7 @@ import { RemoveTagsCommandInput, RemoveTagsCommandOutput } from "./commands/Remo import { StartLoggingCommandInput, StartLoggingCommandOutput } from "./commands/StartLoggingCommand"; import { StopLoggingCommandInput, StopLoggingCommandOutput } from "./commands/StopLoggingCommand"; import { UpdateTrailCommandInput, UpdateTrailCommandOutput } from "./commands/UpdateTrailCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -282,10 +282,7 @@ export class CloudTrailClient extends __Client< readonly config: CloudTrailClientResolvedConfig; constructor(configuration: CloudTrailClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudtrail/runtimeConfig.browser.ts b/clients/client-cloudtrail/runtimeConfig.browser.ts index 5f403f538ec0c..c6ad5995a4ba6 100644 --- a/clients/client-cloudtrail/runtimeConfig.browser.ts +++ b/clients/client-cloudtrail/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudTrailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudTrailClientConfig } from "./CloudTrailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudTrailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudtrail/runtimeConfig.native.ts b/clients/client-cloudtrail/runtimeConfig.native.ts index 40b4e6f9107cd..bc99d2a4b0f0c 100644 --- a/clients/client-cloudtrail/runtimeConfig.native.ts +++ b/clients/client-cloudtrail/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudTrailClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudTrailClientConfig } from "./CloudTrailClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudTrailClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudtrail/runtimeConfig.shared.ts b/clients/client-cloudtrail/runtimeConfig.shared.ts index 9d4a42f38086d..08565aca1826a 100644 --- a/clients/client-cloudtrail/runtimeConfig.shared.ts +++ b/clients/client-cloudtrail/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudTrailClientConfig } from "./CloudTrailClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudTrailClientConfig) => ({ apiVersion: "2013-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudTrail", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudTrail", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudtrail/runtimeConfig.ts b/clients/client-cloudtrail/runtimeConfig.ts index f31e2148db178..62f098cdb2c52 100644 --- a/clients/client-cloudtrail/runtimeConfig.ts +++ b/clients/client-cloudtrail/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudTrailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudTrailClientConfig } from "./CloudTrailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudTrailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch-events/CloudWatchEventsClient.ts b/clients/client-cloudwatch-events/CloudWatchEventsClient.ts index 73bca9851264d..6ef0d741ce933 100644 --- a/clients/client-cloudwatch-events/CloudWatchEventsClient.ts +++ b/clients/client-cloudwatch-events/CloudWatchEventsClient.ts @@ -97,7 +97,7 @@ import { } from "./commands/UpdateApiDestinationCommand"; import { UpdateArchiveCommandInput, UpdateArchiveCommandOutput } from "./commands/UpdateArchiveCommand"; import { UpdateConnectionCommandInput, UpdateConnectionCommandOutput } from "./commands/UpdateConnectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -429,10 +429,7 @@ export class CloudWatchEventsClient extends __Client< readonly config: CloudWatchEventsClientResolvedConfig; constructor(configuration: CloudWatchEventsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudwatch-events/runtimeConfig.browser.ts b/clients/client-cloudwatch-events/runtimeConfig.browser.ts index 8e08cf68614ba..9087a17f9af19 100644 --- a/clients/client-cloudwatch-events/runtimeConfig.browser.ts +++ b/clients/client-cloudwatch-events/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudWatchEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchEventsClientConfig } from "./CloudWatchEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch-events/runtimeConfig.native.ts b/clients/client-cloudwatch-events/runtimeConfig.native.ts index 0dbc524bed8bd..a01ad3749f229 100644 --- a/clients/client-cloudwatch-events/runtimeConfig.native.ts +++ b/clients/client-cloudwatch-events/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudWatchEventsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudWatchEventsClientConfig } from "./CloudWatchEventsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudWatchEventsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudwatch-events/runtimeConfig.shared.ts b/clients/client-cloudwatch-events/runtimeConfig.shared.ts index 9a95c4c790574..a55678ec8a8a0 100644 --- a/clients/client-cloudwatch-events/runtimeConfig.shared.ts +++ b/clients/client-cloudwatch-events/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudWatchEventsClientConfig } from "./CloudWatchEventsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudWatchEventsClientConfig) => ({ apiVersion: "2015-10-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudWatch Events", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudWatch Events", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudwatch-events/runtimeConfig.ts b/clients/client-cloudwatch-events/runtimeConfig.ts index d5c133ad4b43f..d3711b4fb70cb 100644 --- a/clients/client-cloudwatch-events/runtimeConfig.ts +++ b/clients/client-cloudwatch-events/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudWatchEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchEventsClientConfig } from "./CloudWatchEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch-logs/CloudWatchLogsClient.ts b/clients/client-cloudwatch-logs/CloudWatchLogsClient.ts index 587d2fba73144..1f8c0bb8e1b15 100644 --- a/clients/client-cloudwatch-logs/CloudWatchLogsClient.ts +++ b/clients/client-cloudwatch-logs/CloudWatchLogsClient.ts @@ -76,7 +76,7 @@ import { StopQueryCommandInput, StopQueryCommandOutput } from "./commands/StopQu import { TagLogGroupCommandInput, TagLogGroupCommandOutput } from "./commands/TagLogGroupCommand"; import { TestMetricFilterCommandInput, TestMetricFilterCommandOutput } from "./commands/TestMetricFilterCommand"; import { UntagLogGroupCommandInput, UntagLogGroupCommandOutput } from "./commands/UntagLogGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -403,10 +403,7 @@ export class CloudWatchLogsClient extends __Client< readonly config: CloudWatchLogsClientResolvedConfig; constructor(configuration: CloudWatchLogsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudwatch-logs/runtimeConfig.browser.ts b/clients/client-cloudwatch-logs/runtimeConfig.browser.ts index b02831a9f7184..711b786bbd467 100644 --- a/clients/client-cloudwatch-logs/runtimeConfig.browser.ts +++ b/clients/client-cloudwatch-logs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudWatchLogsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchLogsClientConfig } from "./CloudWatchLogsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchLogsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch-logs/runtimeConfig.native.ts b/clients/client-cloudwatch-logs/runtimeConfig.native.ts index 1a77ed5444f47..f702eceee478e 100644 --- a/clients/client-cloudwatch-logs/runtimeConfig.native.ts +++ b/clients/client-cloudwatch-logs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudWatchLogsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudWatchLogsClientConfig } from "./CloudWatchLogsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudWatchLogsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudwatch-logs/runtimeConfig.shared.ts b/clients/client-cloudwatch-logs/runtimeConfig.shared.ts index d2c3370f544fe..17fcc27c2eb3b 100644 --- a/clients/client-cloudwatch-logs/runtimeConfig.shared.ts +++ b/clients/client-cloudwatch-logs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudWatchLogsClientConfig } from "./CloudWatchLogsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudWatchLogsClientConfig) => ({ apiVersion: "2014-03-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudWatch Logs", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudWatch Logs", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudwatch-logs/runtimeConfig.ts b/clients/client-cloudwatch-logs/runtimeConfig.ts index 8689bed11f69e..df9093a216f69 100644 --- a/clients/client-cloudwatch-logs/runtimeConfig.ts +++ b/clients/client-cloudwatch-logs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudWatchLogsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchLogsClientConfig } from "./CloudWatchLogsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchLogsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch/CloudWatchClient.ts b/clients/client-cloudwatch/CloudWatchClient.ts index 84c4c949538cf..e2ed81feed69c 100644 --- a/clients/client-cloudwatch/CloudWatchClient.ts +++ b/clients/client-cloudwatch/CloudWatchClient.ts @@ -67,7 +67,7 @@ import { StartMetricStreamsCommandInput, StartMetricStreamsCommandOutput } from import { StopMetricStreamsCommandInput, StopMetricStreamsCommandOutput } from "./commands/StopMetricStreamsCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -363,10 +363,7 @@ export class CloudWatchClient extends __Client< readonly config: CloudWatchClientResolvedConfig; constructor(configuration: CloudWatchClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cloudwatch/runtimeConfig.browser.ts b/clients/client-cloudwatch/runtimeConfig.browser.ts index fbc9b8d902b92..8a5d59f8467c7 100644 --- a/clients/client-cloudwatch/runtimeConfig.browser.ts +++ b/clients/client-cloudwatch/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CloudWatchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchClientConfig } from "./CloudWatchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cloudwatch/runtimeConfig.native.ts b/clients/client-cloudwatch/runtimeConfig.native.ts index 0eb815a0d7416..88936e068010b 100644 --- a/clients/client-cloudwatch/runtimeConfig.native.ts +++ b/clients/client-cloudwatch/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CloudWatchClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CloudWatchClientConfig } from "./CloudWatchClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CloudWatchClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cloudwatch/runtimeConfig.shared.ts b/clients/client-cloudwatch/runtimeConfig.shared.ts index 388025d25281b..0cb8e20cb0bea 100644 --- a/clients/client-cloudwatch/runtimeConfig.shared.ts +++ b/clients/client-cloudwatch/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CloudWatchClientConfig } from "./CloudWatchClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CloudWatchClientConfig) => ({ apiVersion: "2010-08-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CloudWatch", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CloudWatch", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cloudwatch/runtimeConfig.ts b/clients/client-cloudwatch/runtimeConfig.ts index 4936b432bd6ee..73df731422cb5 100644 --- a/clients/client-cloudwatch/runtimeConfig.ts +++ b/clients/client-cloudwatch/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CloudWatchClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CloudWatchClientConfig } from "./CloudWatchClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CloudWatchClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeartifact/CodeartifactClient.ts b/clients/client-codeartifact/CodeartifactClient.ts index 848fce0dd5f02..e7e3034105fde 100644 --- a/clients/client-codeartifact/CodeartifactClient.ts +++ b/clients/client-codeartifact/CodeartifactClient.ts @@ -98,7 +98,7 @@ import { UpdatePackageVersionsStatusCommandOutput, } from "./commands/UpdatePackageVersionsStatusCommand"; import { UpdateRepositoryCommandInput, UpdateRepositoryCommandOutput } from "./commands/UpdateRepositoryCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -629,10 +629,7 @@ export class CodeartifactClient extends __Client< readonly config: CodeartifactClientResolvedConfig; constructor(configuration: CodeartifactClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codeartifact/runtimeConfig.browser.ts b/clients/client-codeartifact/runtimeConfig.browser.ts index 65686d7d6b9ac..59da38ec724a2 100644 --- a/clients/client-codeartifact/runtimeConfig.browser.ts +++ b/clients/client-codeartifact/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeartifactClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeartifactClientConfig } from "./CodeartifactClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeartifactClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeartifact/runtimeConfig.native.ts b/clients/client-codeartifact/runtimeConfig.native.ts index 09dbaa9b35b97..9134d3f19b6d0 100644 --- a/clients/client-codeartifact/runtimeConfig.native.ts +++ b/clients/client-codeartifact/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeartifactClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeartifactClientConfig } from "./CodeartifactClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeartifactClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codeartifact/runtimeConfig.shared.ts b/clients/client-codeartifact/runtimeConfig.shared.ts index def84eea61665..a03ba08abdfda 100644 --- a/clients/client-codeartifact/runtimeConfig.shared.ts +++ b/clients/client-codeartifact/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeartifactClientConfig } from "./CodeartifactClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeartifactClientConfig) => ({ apiVersion: "2018-09-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "codeartifact", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "codeartifact", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codeartifact/runtimeConfig.ts b/clients/client-codeartifact/runtimeConfig.ts index 3b847acbca9f4..04922567d036e 100644 --- a/clients/client-codeartifact/runtimeConfig.ts +++ b/clients/client-codeartifact/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeartifactClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeartifactClientConfig } from "./CodeartifactClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeartifactClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codebuild/CodeBuildClient.ts b/clients/client-codebuild/CodeBuildClient.ts index 5598e84293531..f2d26c624b293 100644 --- a/clients/client-codebuild/CodeBuildClient.ts +++ b/clients/client-codebuild/CodeBuildClient.ts @@ -84,7 +84,7 @@ import { StopBuildCommandInput, StopBuildCommandOutput } from "./commands/StopBu import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./commands/UpdateProjectCommand"; import { UpdateReportGroupCommandInput, UpdateReportGroupCommandOutput } from "./commands/UpdateReportGroupCommand"; import { UpdateWebhookCommandInput, UpdateWebhookCommandOutput } from "./commands/UpdateWebhookCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -391,10 +391,7 @@ export class CodeBuildClient extends __Client< readonly config: CodeBuildClientResolvedConfig; constructor(configuration: CodeBuildClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codebuild/runtimeConfig.browser.ts b/clients/client-codebuild/runtimeConfig.browser.ts index 4a002d788414e..79cb5c96c4a86 100644 --- a/clients/client-codebuild/runtimeConfig.browser.ts +++ b/clients/client-codebuild/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeBuildClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeBuildClientConfig } from "./CodeBuildClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeBuildClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codebuild/runtimeConfig.native.ts b/clients/client-codebuild/runtimeConfig.native.ts index 73480f9e872e3..a196e942fd952 100644 --- a/clients/client-codebuild/runtimeConfig.native.ts +++ b/clients/client-codebuild/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeBuildClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeBuildClientConfig } from "./CodeBuildClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeBuildClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codebuild/runtimeConfig.shared.ts b/clients/client-codebuild/runtimeConfig.shared.ts index 910ff02aa6ccd..97f7006aaab09 100644 --- a/clients/client-codebuild/runtimeConfig.shared.ts +++ b/clients/client-codebuild/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeBuildClientConfig } from "./CodeBuildClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeBuildClientConfig) => ({ apiVersion: "2016-10-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeBuild", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeBuild", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codebuild/runtimeConfig.ts b/clients/client-codebuild/runtimeConfig.ts index ac6c23e3e75d3..532416fa19fa8 100644 --- a/clients/client-codebuild/runtimeConfig.ts +++ b/clients/client-codebuild/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeBuildClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeBuildClientConfig } from "./CodeBuildClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeBuildClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codecommit/CodeCommitClient.ts b/clients/client-codecommit/CodeCommitClient.ts index 8515e35001e65..1c2e24bffd633 100644 --- a/clients/client-codecommit/CodeCommitClient.ts +++ b/clients/client-codecommit/CodeCommitClient.ts @@ -219,7 +219,7 @@ import { UpdateRepositoryNameCommandInput, UpdateRepositoryNameCommandOutput, } from "./commands/UpdateRepositoryNameCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -979,10 +979,7 @@ export class CodeCommitClient extends __Client< readonly config: CodeCommitClientResolvedConfig; constructor(configuration: CodeCommitClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codecommit/runtimeConfig.browser.ts b/clients/client-codecommit/runtimeConfig.browser.ts index 5249e7334349d..455eab4a9ddba 100644 --- a/clients/client-codecommit/runtimeConfig.browser.ts +++ b/clients/client-codecommit/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeCommitClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeCommitClientConfig } from "./CodeCommitClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeCommitClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codecommit/runtimeConfig.native.ts b/clients/client-codecommit/runtimeConfig.native.ts index 3c08ecc405cd5..488f92b1a6763 100644 --- a/clients/client-codecommit/runtimeConfig.native.ts +++ b/clients/client-codecommit/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeCommitClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeCommitClientConfig } from "./CodeCommitClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeCommitClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codecommit/runtimeConfig.shared.ts b/clients/client-codecommit/runtimeConfig.shared.ts index 1a26140afa396..a99f80a0f3898 100644 --- a/clients/client-codecommit/runtimeConfig.shared.ts +++ b/clients/client-codecommit/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeCommitClientConfig } from "./CodeCommitClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeCommitClientConfig) => ({ apiVersion: "2015-04-13", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeCommit", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeCommit", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codecommit/runtimeConfig.ts b/clients/client-codecommit/runtimeConfig.ts index fa7883f23f0e4..a37a450f1c5d2 100644 --- a/clients/client-codecommit/runtimeConfig.ts +++ b/clients/client-codecommit/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeCommitClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeCommitClientConfig } from "./CodeCommitClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeCommitClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codedeploy/CodeDeployClient.ts b/clients/client-codedeploy/CodeDeployClient.ts index 1535eb4c8b94b..6e5e5d33dd518 100644 --- a/clients/client-codedeploy/CodeDeployClient.ts +++ b/clients/client-codedeploy/CodeDeployClient.ts @@ -147,7 +147,7 @@ import { UpdateDeploymentGroupCommandInput, UpdateDeploymentGroupCommandOutput, } from "./commands/UpdateDeploymentGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -550,10 +550,7 @@ export class CodeDeployClient extends __Client< readonly config: CodeDeployClientResolvedConfig; constructor(configuration: CodeDeployClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codedeploy/runtimeConfig.browser.ts b/clients/client-codedeploy/runtimeConfig.browser.ts index 5a7ed352bbb41..ccb4bb6b04e89 100644 --- a/clients/client-codedeploy/runtimeConfig.browser.ts +++ b/clients/client-codedeploy/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeDeployClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeDeployClientConfig } from "./CodeDeployClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeDeployClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codedeploy/runtimeConfig.native.ts b/clients/client-codedeploy/runtimeConfig.native.ts index 8f03b9716cb3f..4b0108a9dc39f 100644 --- a/clients/client-codedeploy/runtimeConfig.native.ts +++ b/clients/client-codedeploy/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeDeployClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeDeployClientConfig } from "./CodeDeployClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeDeployClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codedeploy/runtimeConfig.shared.ts b/clients/client-codedeploy/runtimeConfig.shared.ts index 12c1fddcb4391..f3a7437c5e00e 100644 --- a/clients/client-codedeploy/runtimeConfig.shared.ts +++ b/clients/client-codedeploy/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeDeployClientConfig } from "./CodeDeployClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeDeployClientConfig) => ({ apiVersion: "2014-10-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeDeploy", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeDeploy", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codedeploy/runtimeConfig.ts b/clients/client-codedeploy/runtimeConfig.ts index 08c108519e2dd..b6a9b20ac6919 100644 --- a/clients/client-codedeploy/runtimeConfig.ts +++ b/clients/client-codedeploy/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeDeployClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeDeployClientConfig } from "./CodeDeployClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeDeployClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeguru-reviewer/CodeGuruReviewerClient.ts b/clients/client-codeguru-reviewer/CodeGuruReviewerClient.ts index 66c09d5c4e17c..02e84c0b2c0b4 100644 --- a/clients/client-codeguru-reviewer/CodeGuruReviewerClient.ts +++ b/clients/client-codeguru-reviewer/CodeGuruReviewerClient.ts @@ -39,7 +39,7 @@ import { } from "./commands/PutRecommendationFeedbackCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -292,10 +292,7 @@ export class CodeGuruReviewerClient extends __Client< readonly config: CodeGuruReviewerClientResolvedConfig; constructor(configuration: CodeGuruReviewerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codeguru-reviewer/runtimeConfig.browser.ts b/clients/client-codeguru-reviewer/runtimeConfig.browser.ts index d84fcde5a8739..62d370b19e853 100644 --- a/clients/client-codeguru-reviewer/runtimeConfig.browser.ts +++ b/clients/client-codeguru-reviewer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeGuruReviewerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeGuruReviewerClientConfig } from "./CodeGuruReviewerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeGuruReviewerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeguru-reviewer/runtimeConfig.native.ts b/clients/client-codeguru-reviewer/runtimeConfig.native.ts index 411f4596e8928..6452f17d3d57d 100644 --- a/clients/client-codeguru-reviewer/runtimeConfig.native.ts +++ b/clients/client-codeguru-reviewer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeGuruReviewerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeGuruReviewerClientConfig } from "./CodeGuruReviewerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeGuruReviewerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codeguru-reviewer/runtimeConfig.shared.ts b/clients/client-codeguru-reviewer/runtimeConfig.shared.ts index 9c3c6e1b95c53..7d47e1e91aaff 100644 --- a/clients/client-codeguru-reviewer/runtimeConfig.shared.ts +++ b/clients/client-codeguru-reviewer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeGuruReviewerClientConfig } from "./CodeGuruReviewerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeGuruReviewerClientConfig) => ({ apiVersion: "2019-09-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeGuru Reviewer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeGuru Reviewer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codeguru-reviewer/runtimeConfig.ts b/clients/client-codeguru-reviewer/runtimeConfig.ts index 2e7514b0ce024..6511cd9ffedbd 100644 --- a/clients/client-codeguru-reviewer/runtimeConfig.ts +++ b/clients/client-codeguru-reviewer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeGuruReviewerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeGuruReviewerClientConfig } from "./CodeGuruReviewerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeGuruReviewerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeguruprofiler/CodeGuruProfilerClient.ts b/clients/client-codeguruprofiler/CodeGuruProfilerClient.ts index b5c12639a7fb6..c432dec440985 100644 --- a/clients/client-codeguruprofiler/CodeGuruProfilerClient.ts +++ b/clients/client-codeguruprofiler/CodeGuruProfilerClient.ts @@ -57,7 +57,7 @@ import { UpdateProfilingGroupCommandInput, UpdateProfilingGroupCommandOutput, } from "./commands/UpdateProfilingGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -335,10 +335,7 @@ export class CodeGuruProfilerClient extends __Client< readonly config: CodeGuruProfilerClientResolvedConfig; constructor(configuration: CodeGuruProfilerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codeguruprofiler/runtimeConfig.browser.ts b/clients/client-codeguruprofiler/runtimeConfig.browser.ts index 90afb8ecd60d9..e9ddaf536a7d0 100644 --- a/clients/client-codeguruprofiler/runtimeConfig.browser.ts +++ b/clients/client-codeguruprofiler/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeGuruProfilerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeGuruProfilerClientConfig } from "./CodeGuruProfilerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeGuruProfilerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codeguruprofiler/runtimeConfig.native.ts b/clients/client-codeguruprofiler/runtimeConfig.native.ts index 34339882b16b8..4f98bd737c64b 100644 --- a/clients/client-codeguruprofiler/runtimeConfig.native.ts +++ b/clients/client-codeguruprofiler/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeGuruProfilerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeGuruProfilerClientConfig } from "./CodeGuruProfilerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeGuruProfilerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codeguruprofiler/runtimeConfig.shared.ts b/clients/client-codeguruprofiler/runtimeConfig.shared.ts index 9bd6c3da16d1c..2e37e581700df 100644 --- a/clients/client-codeguruprofiler/runtimeConfig.shared.ts +++ b/clients/client-codeguruprofiler/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeGuruProfilerClientConfig } from "./CodeGuruProfilerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeGuruProfilerClientConfig) => ({ apiVersion: "2019-07-18", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeGuruProfiler", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeGuruProfiler", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codeguruprofiler/runtimeConfig.ts b/clients/client-codeguruprofiler/runtimeConfig.ts index 9608111e238ef..59e085e448c53 100644 --- a/clients/client-codeguruprofiler/runtimeConfig.ts +++ b/clients/client-codeguruprofiler/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeGuruProfilerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeGuruProfilerClientConfig } from "./CodeGuruProfilerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeGuruProfilerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codepipeline/CodePipelineClient.ts b/clients/client-codepipeline/CodePipelineClient.ts index af89ec4b47d24..dfc65dcac110e 100644 --- a/clients/client-codepipeline/CodePipelineClient.ts +++ b/clients/client-codepipeline/CodePipelineClient.ts @@ -97,7 +97,7 @@ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/Ta import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateActionTypeCommandInput, UpdateActionTypeCommandOutput } from "./commands/UpdateActionTypeCommand"; import { UpdatePipelineCommandInput, UpdatePipelineCommandOutput } from "./commands/UpdatePipelineCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -579,10 +579,7 @@ export class CodePipelineClient extends __Client< readonly config: CodePipelineClientResolvedConfig; constructor(configuration: CodePipelineClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codepipeline/runtimeConfig.browser.ts b/clients/client-codepipeline/runtimeConfig.browser.ts index 6d888c59b2082..1f2d8a72e1531 100644 --- a/clients/client-codepipeline/runtimeConfig.browser.ts +++ b/clients/client-codepipeline/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodePipelineClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodePipelineClientConfig } from "./CodePipelineClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodePipelineClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codepipeline/runtimeConfig.native.ts b/clients/client-codepipeline/runtimeConfig.native.ts index 74ecdd9b7f529..4fcffa0cedca3 100644 --- a/clients/client-codepipeline/runtimeConfig.native.ts +++ b/clients/client-codepipeline/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodePipelineClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodePipelineClientConfig } from "./CodePipelineClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodePipelineClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codepipeline/runtimeConfig.shared.ts b/clients/client-codepipeline/runtimeConfig.shared.ts index f33bdbfdb92e7..eb5b492ca6f0d 100644 --- a/clients/client-codepipeline/runtimeConfig.shared.ts +++ b/clients/client-codepipeline/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodePipelineClientConfig } from "./CodePipelineClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodePipelineClientConfig) => ({ apiVersion: "2015-07-09", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodePipeline", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodePipeline", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codepipeline/runtimeConfig.ts b/clients/client-codepipeline/runtimeConfig.ts index db4fcfe4d24e7..be6cf1afaa71b 100644 --- a/clients/client-codepipeline/runtimeConfig.ts +++ b/clients/client-codepipeline/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodePipelineClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodePipelineClientConfig } from "./CodePipelineClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodePipelineClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar-connections/CodeStarConnectionsClient.ts b/clients/client-codestar-connections/CodeStarConnectionsClient.ts index 6e9cf8382f836..bff3427512e53 100644 --- a/clients/client-codestar-connections/CodeStarConnectionsClient.ts +++ b/clients/client-codestar-connections/CodeStarConnectionsClient.ts @@ -13,7 +13,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateHostCommandInput, UpdateHostCommandOutput } from "./commands/UpdateHostCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -326,10 +326,7 @@ export class CodeStarConnectionsClient extends __Client< readonly config: CodeStarConnectionsClientResolvedConfig; constructor(configuration: CodeStarConnectionsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codestar-connections/runtimeConfig.browser.ts b/clients/client-codestar-connections/runtimeConfig.browser.ts index d06c2e73da6a9..cff9ae1eedf92 100644 --- a/clients/client-codestar-connections/runtimeConfig.browser.ts +++ b/clients/client-codestar-connections/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeStarConnectionsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeStarConnectionsClientConfig } from "./CodeStarConnectionsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeStarConnectionsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar-connections/runtimeConfig.native.ts b/clients/client-codestar-connections/runtimeConfig.native.ts index 05c6e42ae5029..2c8cea23c005e 100644 --- a/clients/client-codestar-connections/runtimeConfig.native.ts +++ b/clients/client-codestar-connections/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeStarConnectionsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeStarConnectionsClientConfig } from "./CodeStarConnectionsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeStarConnectionsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codestar-connections/runtimeConfig.shared.ts b/clients/client-codestar-connections/runtimeConfig.shared.ts index 1952b4759c6af..f03d78bea11c0 100644 --- a/clients/client-codestar-connections/runtimeConfig.shared.ts +++ b/clients/client-codestar-connections/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeStarConnectionsClientConfig } from "./CodeStarConnectionsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeStarConnectionsClientConfig) => ({ apiVersion: "2019-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeStar connections", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeStar connections", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codestar-connections/runtimeConfig.ts b/clients/client-codestar-connections/runtimeConfig.ts index efc956150df3c..562fb403f7563 100644 --- a/clients/client-codestar-connections/runtimeConfig.ts +++ b/clients/client-codestar-connections/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeStarConnectionsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeStarConnectionsClientConfig } from "./CodeStarConnectionsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeStarConnectionsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar-notifications/CodestarNotificationsClient.ts b/clients/client-codestar-notifications/CodestarNotificationsClient.ts index 68cf9c515c26c..4af57cd9ac58a 100644 --- a/clients/client-codestar-notifications/CodestarNotificationsClient.ts +++ b/clients/client-codestar-notifications/CodestarNotificationsClient.ts @@ -29,7 +29,7 @@ import { UpdateNotificationRuleCommandInput, UpdateNotificationRuleCommandOutput, } from "./commands/UpdateNotificationRuleCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -348,10 +348,7 @@ export class CodestarNotificationsClient extends __Client< readonly config: CodestarNotificationsClientResolvedConfig; constructor(configuration: CodestarNotificationsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codestar-notifications/runtimeConfig.browser.ts b/clients/client-codestar-notifications/runtimeConfig.browser.ts index 37ab622b3bbbe..6697827f2f447 100644 --- a/clients/client-codestar-notifications/runtimeConfig.browser.ts +++ b/clients/client-codestar-notifications/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodestarNotificationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodestarNotificationsClientConfig } from "./CodestarNotificationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodestarNotificationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar-notifications/runtimeConfig.native.ts b/clients/client-codestar-notifications/runtimeConfig.native.ts index 93b13e027b126..92bbb37555ec0 100644 --- a/clients/client-codestar-notifications/runtimeConfig.native.ts +++ b/clients/client-codestar-notifications/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodestarNotificationsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodestarNotificationsClientConfig } from "./CodestarNotificationsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodestarNotificationsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codestar-notifications/runtimeConfig.shared.ts b/clients/client-codestar-notifications/runtimeConfig.shared.ts index be5a576ac0a8f..53c0e07df1ba0 100644 --- a/clients/client-codestar-notifications/runtimeConfig.shared.ts +++ b/clients/client-codestar-notifications/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodestarNotificationsClientConfig } from "./CodestarNotificationsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodestarNotificationsClientConfig) => ({ apiVersion: "2019-10-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "codestar notifications", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "codestar notifications", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codestar-notifications/runtimeConfig.ts b/clients/client-codestar-notifications/runtimeConfig.ts index 54742303c2eef..9775a76fb3bec 100644 --- a/clients/client-codestar-notifications/runtimeConfig.ts +++ b/clients/client-codestar-notifications/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodestarNotificationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodestarNotificationsClientConfig } from "./CodestarNotificationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodestarNotificationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar/CodeStarClient.ts b/clients/client-codestar/CodeStarClient.ts index f4efd5fbc6bcc..59c34aeda7afe 100644 --- a/clients/client-codestar/CodeStarClient.ts +++ b/clients/client-codestar/CodeStarClient.ts @@ -25,7 +25,7 @@ import { UntagProjectCommandInput, UntagProjectCommandOutput } from "./commands/ import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./commands/UpdateProjectCommand"; import { UpdateTeamMemberCommandInput, UpdateTeamMemberCommandOutput } from "./commands/UpdateTeamMemberCommand"; import { UpdateUserProfileCommandInput, UpdateUserProfileCommandOutput } from "./commands/UpdateUserProfileCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -360,10 +360,7 @@ export class CodeStarClient extends __Client< readonly config: CodeStarClientResolvedConfig; constructor(configuration: CodeStarClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-codestar/runtimeConfig.browser.ts b/clients/client-codestar/runtimeConfig.browser.ts index 1daec203c0dbe..0ccfc63ebddd4 100644 --- a/clients/client-codestar/runtimeConfig.browser.ts +++ b/clients/client-codestar/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CodeStarClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeStarClientConfig } from "./CodeStarClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeStarClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-codestar/runtimeConfig.native.ts b/clients/client-codestar/runtimeConfig.native.ts index 46f6ee6588511..a73fdec1c940d 100644 --- a/clients/client-codestar/runtimeConfig.native.ts +++ b/clients/client-codestar/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CodeStarClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CodeStarClientConfig } from "./CodeStarClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CodeStarClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-codestar/runtimeConfig.shared.ts b/clients/client-codestar/runtimeConfig.shared.ts index a512f719919c3..1f5861569efd7 100644 --- a/clients/client-codestar/runtimeConfig.shared.ts +++ b/clients/client-codestar/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CodeStarClientConfig } from "./CodeStarClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CodeStarClientConfig) => ({ apiVersion: "2017-04-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "CodeStar", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "CodeStar", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-codestar/runtimeConfig.ts b/clients/client-codestar/runtimeConfig.ts index 967830a5fdc6e..35edad1cb0091 100644 --- a/clients/client-codestar/runtimeConfig.ts +++ b/clients/client-codestar/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CodeStarClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CodeStarClientConfig } from "./CodeStarClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CodeStarClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-identity-provider/CognitoIdentityProviderClient.ts b/clients/client-cognito-identity-provider/CognitoIdentityProviderClient.ts index 31b99c2ce673b..ebc24733bcaa3 100644 --- a/clients/client-cognito-identity-provider/CognitoIdentityProviderClient.ts +++ b/clients/client-cognito-identity-provider/CognitoIdentityProviderClient.ts @@ -267,7 +267,7 @@ import { VerifyUserAttributeCommandInput, VerifyUserAttributeCommandOutput, } from "./commands/VerifyUserAttributeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -680,10 +680,7 @@ export class CognitoIdentityProviderClient extends __Client< readonly config: CognitoIdentityProviderClientResolvedConfig; constructor(configuration: CognitoIdentityProviderClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cognito-identity-provider/runtimeConfig.browser.ts b/clients/client-cognito-identity-provider/runtimeConfig.browser.ts index 023f2e2d10a5a..63d75f1db140e 100644 --- a/clients/client-cognito-identity-provider/runtimeConfig.browser.ts +++ b/clients/client-cognito-identity-provider/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CognitoIdentityProviderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoIdentityProviderClientConfig } from "./CognitoIdentityProviderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoIdentityProviderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-identity-provider/runtimeConfig.native.ts b/clients/client-cognito-identity-provider/runtimeConfig.native.ts index b3a707e496f51..d74cf9b0a6646 100644 --- a/clients/client-cognito-identity-provider/runtimeConfig.native.ts +++ b/clients/client-cognito-identity-provider/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CognitoIdentityProviderClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CognitoIdentityProviderClientConfig } from "./CognitoIdentityProviderClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CognitoIdentityProviderClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cognito-identity-provider/runtimeConfig.shared.ts b/clients/client-cognito-identity-provider/runtimeConfig.shared.ts index a744bd0180e40..f7bfd581c863a 100644 --- a/clients/client-cognito-identity-provider/runtimeConfig.shared.ts +++ b/clients/client-cognito-identity-provider/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CognitoIdentityProviderClientConfig } from "./CognitoIdentityProviderClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CognitoIdentityProviderClientConfig) => ({ apiVersion: "2016-04-18", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cognito Identity Provider", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cognito Identity Provider", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cognito-identity-provider/runtimeConfig.ts b/clients/client-cognito-identity-provider/runtimeConfig.ts index 875ce54e9ca17..f86ac94c0bbee 100644 --- a/clients/client-cognito-identity-provider/runtimeConfig.ts +++ b/clients/client-cognito-identity-provider/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CognitoIdentityProviderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoIdentityProviderClientConfig } from "./CognitoIdentityProviderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoIdentityProviderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-identity/CognitoIdentityClient.ts b/clients/client-cognito-identity/CognitoIdentityClient.ts index 0690b4118ce63..753b6011fd0a3 100644 --- a/clients/client-cognito-identity/CognitoIdentityClient.ts +++ b/clients/client-cognito-identity/CognitoIdentityClient.ts @@ -54,7 +54,7 @@ import { import { UnlinkIdentityCommandInput, UnlinkIdentityCommandOutput } from "./commands/UnlinkIdentityCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateIdentityPoolCommandInput, UpdateIdentityPoolCommandOutput } from "./commands/UpdateIdentityPoolCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -318,10 +318,7 @@ export class CognitoIdentityClient extends __Client< readonly config: CognitoIdentityClientResolvedConfig; constructor(configuration: CognitoIdentityClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cognito-identity/runtimeConfig.browser.ts b/clients/client-cognito-identity/runtimeConfig.browser.ts index 368fc3c8b653b..b928751e10d45 100644 --- a/clients/client-cognito-identity/runtimeConfig.browser.ts +++ b/clients/client-cognito-identity/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CognitoIdentityClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoIdentityClientConfig } from "./CognitoIdentityClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoIdentityClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-identity/runtimeConfig.native.ts b/clients/client-cognito-identity/runtimeConfig.native.ts index 7c3bc8ee9f4de..4fefa77ed1604 100644 --- a/clients/client-cognito-identity/runtimeConfig.native.ts +++ b/clients/client-cognito-identity/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CognitoIdentityClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CognitoIdentityClientConfig } from "./CognitoIdentityClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CognitoIdentityClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cognito-identity/runtimeConfig.shared.ts b/clients/client-cognito-identity/runtimeConfig.shared.ts index 3dd89173fb1e6..5c934131a68c5 100644 --- a/clients/client-cognito-identity/runtimeConfig.shared.ts +++ b/clients/client-cognito-identity/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CognitoIdentityClientConfig } from "./CognitoIdentityClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CognitoIdentityClientConfig) => ({ apiVersion: "2014-06-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cognito Identity", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cognito Identity", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cognito-identity/runtimeConfig.ts b/clients/client-cognito-identity/runtimeConfig.ts index 46e75c271322f..3a79b257e5889 100644 --- a/clients/client-cognito-identity/runtimeConfig.ts +++ b/clients/client-cognito-identity/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CognitoIdentityClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoIdentityClientConfig } from "./CognitoIdentityClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoIdentityClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-sync/CognitoSyncClient.ts b/clients/client-cognito-sync/CognitoSyncClient.ts index abd50fdbf2004..6d19c030c1518 100644 --- a/clients/client-cognito-sync/CognitoSyncClient.ts +++ b/clients/client-cognito-sync/CognitoSyncClient.ts @@ -36,7 +36,7 @@ import { UnsubscribeFromDatasetCommandOutput, } from "./commands/UnsubscribeFromDatasetCommand"; import { UpdateRecordsCommandInput, UpdateRecordsCommandOutput } from "./commands/UpdateRecordsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -292,10 +292,7 @@ export class CognitoSyncClient extends __Client< readonly config: CognitoSyncClientResolvedConfig; constructor(configuration: CognitoSyncClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cognito-sync/runtimeConfig.browser.ts b/clients/client-cognito-sync/runtimeConfig.browser.ts index 7d9e39c99f0ff..8e775f19c4237 100644 --- a/clients/client-cognito-sync/runtimeConfig.browser.ts +++ b/clients/client-cognito-sync/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CognitoSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoSyncClientConfig } from "./CognitoSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cognito-sync/runtimeConfig.native.ts b/clients/client-cognito-sync/runtimeConfig.native.ts index d8faaf84d4928..477e9c79eba20 100644 --- a/clients/client-cognito-sync/runtimeConfig.native.ts +++ b/clients/client-cognito-sync/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CognitoSyncClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CognitoSyncClientConfig } from "./CognitoSyncClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CognitoSyncClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cognito-sync/runtimeConfig.shared.ts b/clients/client-cognito-sync/runtimeConfig.shared.ts index e3cf8cc06d493..95424ae31495c 100644 --- a/clients/client-cognito-sync/runtimeConfig.shared.ts +++ b/clients/client-cognito-sync/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CognitoSyncClientConfig } from "./CognitoSyncClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CognitoSyncClientConfig) => ({ apiVersion: "2014-06-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cognito Sync", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cognito Sync", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cognito-sync/runtimeConfig.ts b/clients/client-cognito-sync/runtimeConfig.ts index 02adf48f7d426..3c150945c4284 100644 --- a/clients/client-cognito-sync/runtimeConfig.ts +++ b/clients/client-cognito-sync/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CognitoSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CognitoSyncClientConfig } from "./CognitoSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CognitoSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-comprehend/ComprehendClient.ts b/clients/client-comprehend/ComprehendClient.ts index 195e6d671e9d0..8919113c552e7 100644 --- a/clients/client-comprehend/ComprehendClient.ts +++ b/clients/client-comprehend/ComprehendClient.ts @@ -200,7 +200,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateEndpointCommandInput, UpdateEndpointCommandOutput } from "./commands/UpdateEndpointCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -535,10 +535,7 @@ export class ComprehendClient extends __Client< readonly config: ComprehendClientResolvedConfig; constructor(configuration: ComprehendClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-comprehend/runtimeConfig.browser.ts b/clients/client-comprehend/runtimeConfig.browser.ts index bc007735c3994..55d017877341e 100644 --- a/clients/client-comprehend/runtimeConfig.browser.ts +++ b/clients/client-comprehend/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ComprehendClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComprehendClientConfig } from "./ComprehendClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComprehendClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-comprehend/runtimeConfig.native.ts b/clients/client-comprehend/runtimeConfig.native.ts index 10d05465863cf..f5e80e54efd19 100644 --- a/clients/client-comprehend/runtimeConfig.native.ts +++ b/clients/client-comprehend/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ComprehendClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ComprehendClientConfig } from "./ComprehendClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ComprehendClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-comprehend/runtimeConfig.shared.ts b/clients/client-comprehend/runtimeConfig.shared.ts index 966396e7ce801..5818b4127e2f9 100644 --- a/clients/client-comprehend/runtimeConfig.shared.ts +++ b/clients/client-comprehend/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ComprehendClientConfig } from "./ComprehendClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ComprehendClientConfig) => ({ apiVersion: "2017-11-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Comprehend", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Comprehend", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-comprehend/runtimeConfig.ts b/clients/client-comprehend/runtimeConfig.ts index 30fc42690c8a9..f4d9210eb8d59 100644 --- a/clients/client-comprehend/runtimeConfig.ts +++ b/clients/client-comprehend/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ComprehendClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComprehendClientConfig } from "./ComprehendClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComprehendClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-comprehendmedical/ComprehendMedicalClient.ts b/clients/client-comprehendmedical/ComprehendMedicalClient.ts index 0645f8a31103d..52438e7e378ac 100644 --- a/clients/client-comprehendmedical/ComprehendMedicalClient.ts +++ b/clients/client-comprehendmedical/ComprehendMedicalClient.ts @@ -67,7 +67,7 @@ import { StopRxNormInferenceJobCommandInput, StopRxNormInferenceJobCommandOutput, } from "./commands/StopRxNormInferenceJobCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -320,10 +320,7 @@ export class ComprehendMedicalClient extends __Client< readonly config: ComprehendMedicalClientResolvedConfig; constructor(configuration: ComprehendMedicalClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-comprehendmedical/runtimeConfig.browser.ts b/clients/client-comprehendmedical/runtimeConfig.browser.ts index db0f9833bdcda..be62058ff57ed 100644 --- a/clients/client-comprehendmedical/runtimeConfig.browser.ts +++ b/clients/client-comprehendmedical/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ComprehendMedicalClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComprehendMedicalClientConfig } from "./ComprehendMedicalClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComprehendMedicalClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-comprehendmedical/runtimeConfig.native.ts b/clients/client-comprehendmedical/runtimeConfig.native.ts index 32f69b1a43459..0b05c2ceed146 100644 --- a/clients/client-comprehendmedical/runtimeConfig.native.ts +++ b/clients/client-comprehendmedical/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ComprehendMedicalClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ComprehendMedicalClientConfig } from "./ComprehendMedicalClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ComprehendMedicalClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-comprehendmedical/runtimeConfig.shared.ts b/clients/client-comprehendmedical/runtimeConfig.shared.ts index 8e44db532b0e6..2f24087746681 100644 --- a/clients/client-comprehendmedical/runtimeConfig.shared.ts +++ b/clients/client-comprehendmedical/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ComprehendMedicalClientConfig } from "./ComprehendMedicalClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ComprehendMedicalClientConfig) => ({ apiVersion: "2018-10-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ComprehendMedical", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ComprehendMedical", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-comprehendmedical/runtimeConfig.ts b/clients/client-comprehendmedical/runtimeConfig.ts index a962ce13aee45..75cb2636da918 100644 --- a/clients/client-comprehendmedical/runtimeConfig.ts +++ b/clients/client-comprehendmedical/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ComprehendMedicalClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComprehendMedicalClientConfig } from "./ComprehendMedicalClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComprehendMedicalClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-compute-optimizer/ComputeOptimizerClient.ts b/clients/client-compute-optimizer/ComputeOptimizerClient.ts index 56cb6413e500c..40b66563b2a99 100644 --- a/clients/client-compute-optimizer/ComputeOptimizerClient.ts +++ b/clients/client-compute-optimizer/ComputeOptimizerClient.ts @@ -50,7 +50,7 @@ import { UpdateEnrollmentStatusCommandInput, UpdateEnrollmentStatusCommandOutput, } from "./commands/UpdateEnrollmentStatusCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -296,10 +296,7 @@ export class ComputeOptimizerClient extends __Client< readonly config: ComputeOptimizerClientResolvedConfig; constructor(configuration: ComputeOptimizerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-compute-optimizer/runtimeConfig.browser.ts b/clients/client-compute-optimizer/runtimeConfig.browser.ts index 074e3efb85537..463cd5ed4b295 100644 --- a/clients/client-compute-optimizer/runtimeConfig.browser.ts +++ b/clients/client-compute-optimizer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ComputeOptimizerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComputeOptimizerClientConfig } from "./ComputeOptimizerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComputeOptimizerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-compute-optimizer/runtimeConfig.native.ts b/clients/client-compute-optimizer/runtimeConfig.native.ts index 2c03cab12f398..b5d92c3c32d5e 100644 --- a/clients/client-compute-optimizer/runtimeConfig.native.ts +++ b/clients/client-compute-optimizer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ComputeOptimizerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ComputeOptimizerClientConfig } from "./ComputeOptimizerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ComputeOptimizerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-compute-optimizer/runtimeConfig.shared.ts b/clients/client-compute-optimizer/runtimeConfig.shared.ts index d1ec02ce08e4f..57d7512e3d43c 100644 --- a/clients/client-compute-optimizer/runtimeConfig.shared.ts +++ b/clients/client-compute-optimizer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ComputeOptimizerClientConfig } from "./ComputeOptimizerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ComputeOptimizerClientConfig) => ({ apiVersion: "2019-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Compute Optimizer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Compute Optimizer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-compute-optimizer/runtimeConfig.ts b/clients/client-compute-optimizer/runtimeConfig.ts index 27eeff3c3933c..2fb5f95a280b2 100644 --- a/clients/client-compute-optimizer/runtimeConfig.ts +++ b/clients/client-compute-optimizer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ComputeOptimizerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ComputeOptimizerClientConfig } from "./ComputeOptimizerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ComputeOptimizerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-config-service/ConfigServiceClient.ts b/clients/client-config-service/ConfigServiceClient.ts index 233fabfbdd422..60d6f41e46ecf 100644 --- a/clients/client-config-service/ConfigServiceClient.ts +++ b/clients/client-config-service/ConfigServiceClient.ts @@ -306,7 +306,7 @@ import { } from "./commands/StopConfigurationRecorderCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -711,10 +711,7 @@ export class ConfigServiceClient extends __Client< readonly config: ConfigServiceClientResolvedConfig; constructor(configuration: ConfigServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-config-service/runtimeConfig.browser.ts b/clients/client-config-service/runtimeConfig.browser.ts index 1da63e4dd164f..40a30fde70f48 100644 --- a/clients/client-config-service/runtimeConfig.browser.ts +++ b/clients/client-config-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ConfigServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConfigServiceClientConfig } from "./ConfigServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConfigServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-config-service/runtimeConfig.native.ts b/clients/client-config-service/runtimeConfig.native.ts index 99b7485dae97a..fe557cd6e4f2f 100644 --- a/clients/client-config-service/runtimeConfig.native.ts +++ b/clients/client-config-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ConfigServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ConfigServiceClientConfig } from "./ConfigServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ConfigServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-config-service/runtimeConfig.shared.ts b/clients/client-config-service/runtimeConfig.shared.ts index 2283c820e398f..699c6b0090e21 100644 --- a/clients/client-config-service/runtimeConfig.shared.ts +++ b/clients/client-config-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ConfigServiceClientConfig } from "./ConfigServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ConfigServiceClientConfig) => ({ apiVersion: "2014-11-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Config Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Config Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-config-service/runtimeConfig.ts b/clients/client-config-service/runtimeConfig.ts index 5efed5c1cfcde..3d8a9671fcba6 100644 --- a/clients/client-config-service/runtimeConfig.ts +++ b/clients/client-config-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ConfigServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConfigServiceClientConfig } from "./ConfigServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConfigServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connect-contact-lens/ConnectContactLensClient.ts b/clients/client-connect-contact-lens/ConnectContactLensClient.ts index 9f946c980ef19..d2f88be2de429 100644 --- a/clients/client-connect-contact-lens/ConnectContactLensClient.ts +++ b/clients/client-connect-contact-lens/ConnectContactLensClient.ts @@ -2,7 +2,7 @@ import { ListRealtimeContactAnalysisSegmentsCommandInput, ListRealtimeContactAnalysisSegmentsCommandOutput, } from "./commands/ListRealtimeContactAnalysisSegmentsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -224,10 +224,7 @@ export class ConnectContactLensClient extends __Client< readonly config: ConnectContactLensClientResolvedConfig; constructor(configuration: ConnectContactLensClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-connect-contact-lens/runtimeConfig.browser.ts b/clients/client-connect-contact-lens/runtimeConfig.browser.ts index 13b72a06376b5..571cee436c202 100644 --- a/clients/client-connect-contact-lens/runtimeConfig.browser.ts +++ b/clients/client-connect-contact-lens/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ConnectContactLensClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectContactLensClientConfig } from "./ConnectContactLensClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectContactLensClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connect-contact-lens/runtimeConfig.native.ts b/clients/client-connect-contact-lens/runtimeConfig.native.ts index c5d9a7682d359..d5b63ba6b50df 100644 --- a/clients/client-connect-contact-lens/runtimeConfig.native.ts +++ b/clients/client-connect-contact-lens/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ConnectContactLensClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ConnectContactLensClientConfig } from "./ConnectContactLensClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ConnectContactLensClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-connect-contact-lens/runtimeConfig.shared.ts b/clients/client-connect-contact-lens/runtimeConfig.shared.ts index b0347f717fe3d..0f7b1ffa90fc8 100644 --- a/clients/client-connect-contact-lens/runtimeConfig.shared.ts +++ b/clients/client-connect-contact-lens/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ConnectContactLensClientConfig } from "./ConnectContactLensClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ConnectContactLensClientConfig) => ({ apiVersion: "2020-08-21", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Connect Contact Lens", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Connect Contact Lens", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-connect-contact-lens/runtimeConfig.ts b/clients/client-connect-contact-lens/runtimeConfig.ts index 9a78b6d7f0115..7de77b8e64658 100644 --- a/clients/client-connect-contact-lens/runtimeConfig.ts +++ b/clients/client-connect-contact-lens/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ConnectContactLensClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectContactLensClientConfig } from "./ConnectContactLensClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectContactLensClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connect/ConnectClient.ts b/clients/client-connect/ConnectClient.ts index 444f0276b15a6..6a3defc66c0d9 100644 --- a/clients/client-connect/ConnectClient.ts +++ b/clients/client-connect/ConnectClient.ts @@ -295,7 +295,7 @@ import { UpdateUserSecurityProfilesCommandInput, UpdateUserSecurityProfilesCommandOutput, } from "./commands/UpdateUserSecurityProfilesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -724,10 +724,7 @@ export class ConnectClient extends __Client< readonly config: ConnectClientResolvedConfig; constructor(configuration: ConnectClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-connect/runtimeConfig.browser.ts b/clients/client-connect/runtimeConfig.browser.ts index 8ec45caa820ac..1d832d6471cb7 100644 --- a/clients/client-connect/runtimeConfig.browser.ts +++ b/clients/client-connect/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectClientConfig } from "./ConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connect/runtimeConfig.native.ts b/clients/client-connect/runtimeConfig.native.ts index 3cc62baeca06a..8c3b2212bfe67 100644 --- a/clients/client-connect/runtimeConfig.native.ts +++ b/clients/client-connect/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ConnectClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ConnectClientConfig } from "./ConnectClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ConnectClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-connect/runtimeConfig.shared.ts b/clients/client-connect/runtimeConfig.shared.ts index 1ac6bb6741feb..56359a9a3c514 100644 --- a/clients/client-connect/runtimeConfig.shared.ts +++ b/clients/client-connect/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ConnectClientConfig } from "./ConnectClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ConnectClientConfig) => ({ apiVersion: "2017-08-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Connect", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Connect", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-connect/runtimeConfig.ts b/clients/client-connect/runtimeConfig.ts index bfbf87ae70863..d7888b4daa0f9 100644 --- a/clients/client-connect/runtimeConfig.ts +++ b/clients/client-connect/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectClientConfig } from "./ConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connectparticipant/ConnectParticipantClient.ts b/clients/client-connectparticipant/ConnectParticipantClient.ts index 59afebdd5f5b5..12737d70dfe50 100644 --- a/clients/client-connectparticipant/ConnectParticipantClient.ts +++ b/clients/client-connectparticipant/ConnectParticipantClient.ts @@ -18,7 +18,7 @@ import { StartAttachmentUploadCommandInput, StartAttachmentUploadCommandOutput, } from "./commands/StartAttachmentUploadCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -255,10 +255,7 @@ export class ConnectParticipantClient extends __Client< readonly config: ConnectParticipantClientResolvedConfig; constructor(configuration: ConnectParticipantClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-connectparticipant/runtimeConfig.browser.ts b/clients/client-connectparticipant/runtimeConfig.browser.ts index 7f8f88e7861d5..b349be3166df3 100644 --- a/clients/client-connectparticipant/runtimeConfig.browser.ts +++ b/clients/client-connectparticipant/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ConnectParticipantClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectParticipantClientConfig } from "./ConnectParticipantClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectParticipantClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-connectparticipant/runtimeConfig.native.ts b/clients/client-connectparticipant/runtimeConfig.native.ts index b4396ff2db2b4..ff2985ace01ff 100644 --- a/clients/client-connectparticipant/runtimeConfig.native.ts +++ b/clients/client-connectparticipant/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ConnectParticipantClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ConnectParticipantClientConfig } from "./ConnectParticipantClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ConnectParticipantClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-connectparticipant/runtimeConfig.shared.ts b/clients/client-connectparticipant/runtimeConfig.shared.ts index b5ce95df6dbed..c077cf8056a1d 100644 --- a/clients/client-connectparticipant/runtimeConfig.shared.ts +++ b/clients/client-connectparticipant/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ConnectParticipantClientConfig } from "./ConnectParticipantClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ConnectParticipantClientConfig) => ({ apiVersion: "2018-09-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ConnectParticipant", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ConnectParticipant", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-connectparticipant/runtimeConfig.ts b/clients/client-connectparticipant/runtimeConfig.ts index 9d1d4cbc24e0d..f194df2fcc2bd 100644 --- a/clients/client-connectparticipant/runtimeConfig.ts +++ b/clients/client-connectparticipant/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ConnectParticipantClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ConnectParticipantClientConfig } from "./ConnectParticipantClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ConnectParticipantClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cost-and-usage-report-service/CostAndUsageReportServiceClient.ts b/clients/client-cost-and-usage-report-service/CostAndUsageReportServiceClient.ts index f0c6744d3b726..dbe368d356b1d 100644 --- a/clients/client-cost-and-usage-report-service/CostAndUsageReportServiceClient.ts +++ b/clients/client-cost-and-usage-report-service/CostAndUsageReportServiceClient.ts @@ -14,7 +14,7 @@ import { PutReportDefinitionCommandInput, PutReportDefinitionCommandOutput, } from "./commands/PutReportDefinitionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -250,10 +250,7 @@ export class CostAndUsageReportServiceClient extends __Client< readonly config: CostAndUsageReportServiceClientResolvedConfig; constructor(configuration: CostAndUsageReportServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cost-and-usage-report-service/runtimeConfig.browser.ts b/clients/client-cost-and-usage-report-service/runtimeConfig.browser.ts index b871b6f0d4865..788d4cba961ba 100644 --- a/clients/client-cost-and-usage-report-service/runtimeConfig.browser.ts +++ b/clients/client-cost-and-usage-report-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CostAndUsageReportServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CostAndUsageReportServiceClientConfig } from "./CostAndUsageReportServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CostAndUsageReportServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cost-and-usage-report-service/runtimeConfig.native.ts b/clients/client-cost-and-usage-report-service/runtimeConfig.native.ts index 51d1cc77a460b..bec508c37c39e 100644 --- a/clients/client-cost-and-usage-report-service/runtimeConfig.native.ts +++ b/clients/client-cost-and-usage-report-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CostAndUsageReportServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CostAndUsageReportServiceClientConfig } from "./CostAndUsageReportServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CostAndUsageReportServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cost-and-usage-report-service/runtimeConfig.shared.ts b/clients/client-cost-and-usage-report-service/runtimeConfig.shared.ts index 793f70a37c35c..7a26edc74f753 100644 --- a/clients/client-cost-and-usage-report-service/runtimeConfig.shared.ts +++ b/clients/client-cost-and-usage-report-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CostAndUsageReportServiceClientConfig } from "./CostAndUsageReportServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CostAndUsageReportServiceClientConfig) => ({ apiVersion: "2017-01-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cost and Usage Report Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cost and Usage Report Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cost-and-usage-report-service/runtimeConfig.ts b/clients/client-cost-and-usage-report-service/runtimeConfig.ts index e39449ca38aa3..ad5422df17b51 100644 --- a/clients/client-cost-and-usage-report-service/runtimeConfig.ts +++ b/clients/client-cost-and-usage-report-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CostAndUsageReportServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CostAndUsageReportServiceClientConfig } from "./CostAndUsageReportServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CostAndUsageReportServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cost-explorer/CostExplorerClient.ts b/clients/client-cost-explorer/CostExplorerClient.ts index 77154ae2d2c00..9ee518d00f3b0 100644 --- a/clients/client-cost-explorer/CostExplorerClient.ts +++ b/clients/client-cost-explorer/CostExplorerClient.ts @@ -94,7 +94,7 @@ import { UpdateCostCategoryDefinitionCommandInput, UpdateCostCategoryDefinitionCommandOutput, } from "./commands/UpdateCostCategoryDefinitionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -377,10 +377,7 @@ export class CostExplorerClient extends __Client< readonly config: CostExplorerClientResolvedConfig; constructor(configuration: CostExplorerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-cost-explorer/runtimeConfig.browser.ts b/clients/client-cost-explorer/runtimeConfig.browser.ts index 70a649403b616..4a9bd25ddc972 100644 --- a/clients/client-cost-explorer/runtimeConfig.browser.ts +++ b/clients/client-cost-explorer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CostExplorerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CostExplorerClientConfig } from "./CostExplorerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CostExplorerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-cost-explorer/runtimeConfig.native.ts b/clients/client-cost-explorer/runtimeConfig.native.ts index 7353d1404bf81..6175b496c44c4 100644 --- a/clients/client-cost-explorer/runtimeConfig.native.ts +++ b/clients/client-cost-explorer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CostExplorerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CostExplorerClientConfig } from "./CostExplorerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CostExplorerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-cost-explorer/runtimeConfig.shared.ts b/clients/client-cost-explorer/runtimeConfig.shared.ts index 4cd5c7f91d7b2..4ae8b043dde55 100644 --- a/clients/client-cost-explorer/runtimeConfig.shared.ts +++ b/clients/client-cost-explorer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CostExplorerClientConfig } from "./CostExplorerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CostExplorerClientConfig) => ({ apiVersion: "2017-10-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Cost Explorer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Cost Explorer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-cost-explorer/runtimeConfig.ts b/clients/client-cost-explorer/runtimeConfig.ts index 4bc744c46ccd8..bef5cf7eb18d2 100644 --- a/clients/client-cost-explorer/runtimeConfig.ts +++ b/clients/client-cost-explorer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CostExplorerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CostExplorerClientConfig } from "./CostExplorerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CostExplorerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-customer-profiles/CustomerProfilesClient.ts b/clients/client-customer-profiles/CustomerProfilesClient.ts index 2397b0e0d7dd8..db282cb102f02 100644 --- a/clients/client-customer-profiles/CustomerProfilesClient.ts +++ b/clients/client-customer-profiles/CustomerProfilesClient.ts @@ -55,7 +55,7 @@ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/Ta import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateDomainCommandInput, UpdateDomainCommandOutput } from "./commands/UpdateDomainCommand"; import { UpdateProfileCommandInput, UpdateProfileCommandOutput } from "./commands/UpdateProfileCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -340,10 +340,7 @@ export class CustomerProfilesClient extends __Client< readonly config: CustomerProfilesClientResolvedConfig; constructor(configuration: CustomerProfilesClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-customer-profiles/runtimeConfig.browser.ts b/clients/client-customer-profiles/runtimeConfig.browser.ts index 4cd665fb4df83..bb3571391f0f1 100644 --- a/clients/client-customer-profiles/runtimeConfig.browser.ts +++ b/clients/client-customer-profiles/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./CustomerProfilesClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CustomerProfilesClientConfig } from "./CustomerProfilesClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CustomerProfilesClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-customer-profiles/runtimeConfig.native.ts b/clients/client-customer-profiles/runtimeConfig.native.ts index fa03d6d5b0e55..a7df02fcacf0f 100644 --- a/clients/client-customer-profiles/runtimeConfig.native.ts +++ b/clients/client-customer-profiles/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./CustomerProfilesClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { CustomerProfilesClientConfig } from "./CustomerProfilesClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: CustomerProfilesClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-customer-profiles/runtimeConfig.shared.ts b/clients/client-customer-profiles/runtimeConfig.shared.ts index c37bcaa95679f..00928c07418c4 100644 --- a/clients/client-customer-profiles/runtimeConfig.shared.ts +++ b/clients/client-customer-profiles/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { CustomerProfilesClientConfig } from "./CustomerProfilesClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: CustomerProfilesClientConfig) => ({ apiVersion: "2020-08-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Customer Profiles", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Customer Profiles", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-customer-profiles/runtimeConfig.ts b/clients/client-customer-profiles/runtimeConfig.ts index b302036990df2..d8dbf7eee35ba 100644 --- a/clients/client-customer-profiles/runtimeConfig.ts +++ b/clients/client-customer-profiles/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./CustomerProfilesClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { CustomerProfilesClientConfig } from "./CustomerProfilesClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: CustomerProfilesClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-data-pipeline/DataPipelineClient.ts b/clients/client-data-pipeline/DataPipelineClient.ts index e92e452784247..f8989fb696bd2 100644 --- a/clients/client-data-pipeline/DataPipelineClient.ts +++ b/clients/client-data-pipeline/DataPipelineClient.ts @@ -29,7 +29,7 @@ import { ValidatePipelineDefinitionCommandInput, ValidatePipelineDefinitionCommandOutput, } from "./commands/ValidatePipelineDefinitionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -293,10 +293,7 @@ export class DataPipelineClient extends __Client< readonly config: DataPipelineClientResolvedConfig; constructor(configuration: DataPipelineClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-data-pipeline/runtimeConfig.browser.ts b/clients/client-data-pipeline/runtimeConfig.browser.ts index 86a2a25be09db..e4d57aea29be2 100644 --- a/clients/client-data-pipeline/runtimeConfig.browser.ts +++ b/clients/client-data-pipeline/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DataPipelineClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataPipelineClientConfig } from "./DataPipelineClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataPipelineClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-data-pipeline/runtimeConfig.native.ts b/clients/client-data-pipeline/runtimeConfig.native.ts index 1185944d36752..0e6b49560bfd1 100644 --- a/clients/client-data-pipeline/runtimeConfig.native.ts +++ b/clients/client-data-pipeline/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DataPipelineClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DataPipelineClientConfig } from "./DataPipelineClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DataPipelineClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-data-pipeline/runtimeConfig.shared.ts b/clients/client-data-pipeline/runtimeConfig.shared.ts index 7c4d849c03e0a..d4338f572b76d 100644 --- a/clients/client-data-pipeline/runtimeConfig.shared.ts +++ b/clients/client-data-pipeline/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DataPipelineClientConfig } from "./DataPipelineClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DataPipelineClientConfig) => ({ apiVersion: "2012-10-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Data Pipeline", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Data Pipeline", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-data-pipeline/runtimeConfig.ts b/clients/client-data-pipeline/runtimeConfig.ts index c6b554990ae42..36fb50f51ec60 100644 --- a/clients/client-data-pipeline/runtimeConfig.ts +++ b/clients/client-data-pipeline/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DataPipelineClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataPipelineClientConfig } from "./DataPipelineClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataPipelineClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-database-migration-service/DatabaseMigrationServiceClient.ts b/clients/client-database-migration-service/DatabaseMigrationServiceClient.ts index 8814be8058c53..0ca3168094a20 100644 --- a/clients/client-database-migration-service/DatabaseMigrationServiceClient.ts +++ b/clients/client-database-migration-service/DatabaseMigrationServiceClient.ts @@ -179,7 +179,7 @@ import { StopReplicationTaskCommandOutput, } from "./commands/StopReplicationTaskCommand"; import { TestConnectionCommandInput, TestConnectionCommandOutput } from "./commands/TestConnectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -509,10 +509,7 @@ export class DatabaseMigrationServiceClient extends __Client< readonly config: DatabaseMigrationServiceClientResolvedConfig; constructor(configuration: DatabaseMigrationServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-database-migration-service/runtimeConfig.browser.ts b/clients/client-database-migration-service/runtimeConfig.browser.ts index 6945588b47d7d..17f10e4304120 100644 --- a/clients/client-database-migration-service/runtimeConfig.browser.ts +++ b/clients/client-database-migration-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DatabaseMigrationServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DatabaseMigrationServiceClientConfig } from "./DatabaseMigrationServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DatabaseMigrationServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-database-migration-service/runtimeConfig.native.ts b/clients/client-database-migration-service/runtimeConfig.native.ts index dd49071b5c5b7..0fbcf65ac3c06 100644 --- a/clients/client-database-migration-service/runtimeConfig.native.ts +++ b/clients/client-database-migration-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DatabaseMigrationServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DatabaseMigrationServiceClientConfig } from "./DatabaseMigrationServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DatabaseMigrationServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-database-migration-service/runtimeConfig.shared.ts b/clients/client-database-migration-service/runtimeConfig.shared.ts index e8b649446586a..1a22deed676dd 100644 --- a/clients/client-database-migration-service/runtimeConfig.shared.ts +++ b/clients/client-database-migration-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DatabaseMigrationServiceClientConfig } from "./DatabaseMigrationServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DatabaseMigrationServiceClientConfig) => ({ apiVersion: "2016-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Database Migration Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Database Migration Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-database-migration-service/runtimeConfig.ts b/clients/client-database-migration-service/runtimeConfig.ts index 6c4cdd66a0b03..cccb10a031373 100644 --- a/clients/client-database-migration-service/runtimeConfig.ts +++ b/clients/client-database-migration-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DatabaseMigrationServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DatabaseMigrationServiceClientConfig } from "./DatabaseMigrationServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DatabaseMigrationServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-databrew/DataBrewClient.ts b/clients/client-databrew/DataBrewClient.ts index e3f00f218f1ad..54c344831c820 100644 --- a/clients/client-databrew/DataBrewClient.ts +++ b/clients/client-databrew/DataBrewClient.ts @@ -52,7 +52,7 @@ import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./command import { UpdateRecipeCommandInput, UpdateRecipeCommandOutput } from "./commands/UpdateRecipeCommand"; import { UpdateRecipeJobCommandInput, UpdateRecipeJobCommandOutput } from "./commands/UpdateRecipeJobCommand"; import { UpdateScheduleCommandInput, UpdateScheduleCommandOutput } from "./commands/UpdateScheduleCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -343,10 +343,7 @@ export class DataBrewClient extends __Client< readonly config: DataBrewClientResolvedConfig; constructor(configuration: DataBrewClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-databrew/runtimeConfig.browser.ts b/clients/client-databrew/runtimeConfig.browser.ts index 9af3e3743283e..62100bc8a4542 100644 --- a/clients/client-databrew/runtimeConfig.browser.ts +++ b/clients/client-databrew/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DataBrewClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataBrewClientConfig } from "./DataBrewClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataBrewClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-databrew/runtimeConfig.native.ts b/clients/client-databrew/runtimeConfig.native.ts index 77c3853593926..e38ce4273968f 100644 --- a/clients/client-databrew/runtimeConfig.native.ts +++ b/clients/client-databrew/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DataBrewClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DataBrewClientConfig } from "./DataBrewClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DataBrewClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-databrew/runtimeConfig.shared.ts b/clients/client-databrew/runtimeConfig.shared.ts index 5125d0b2b550a..112131f119e6f 100644 --- a/clients/client-databrew/runtimeConfig.shared.ts +++ b/clients/client-databrew/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DataBrewClientConfig } from "./DataBrewClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DataBrewClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DataBrew", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DataBrew", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-databrew/runtimeConfig.ts b/clients/client-databrew/runtimeConfig.ts index 3de8fd1f9fe9a..5a4e2bb4497a8 100644 --- a/clients/client-databrew/runtimeConfig.ts +++ b/clients/client-databrew/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DataBrewClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataBrewClientConfig } from "./DataBrewClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataBrewClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dataexchange/DataExchangeClient.ts b/clients/client-dataexchange/DataExchangeClient.ts index a29f9e8ccc26f..d1bda774a8841 100644 --- a/clients/client-dataexchange/DataExchangeClient.ts +++ b/clients/client-dataexchange/DataExchangeClient.ts @@ -26,7 +26,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateAssetCommandInput, UpdateAssetCommandOutput } from "./commands/UpdateAssetCommand"; import { UpdateDataSetCommandInput, UpdateDataSetCommandOutput } from "./commands/UpdateDataSetCommand"; import { UpdateRevisionCommandInput, UpdateRevisionCommandOutput } from "./commands/UpdateRevisionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -280,10 +280,7 @@ export class DataExchangeClient extends __Client< readonly config: DataExchangeClientResolvedConfig; constructor(configuration: DataExchangeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-dataexchange/runtimeConfig.browser.ts b/clients/client-dataexchange/runtimeConfig.browser.ts index 42d89af617a0d..05286455ae155 100644 --- a/clients/client-dataexchange/runtimeConfig.browser.ts +++ b/clients/client-dataexchange/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DataExchangeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataExchangeClientConfig } from "./DataExchangeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataExchangeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dataexchange/runtimeConfig.native.ts b/clients/client-dataexchange/runtimeConfig.native.ts index a0b97945fb6e2..28609c42eae89 100644 --- a/clients/client-dataexchange/runtimeConfig.native.ts +++ b/clients/client-dataexchange/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DataExchangeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DataExchangeClientConfig } from "./DataExchangeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DataExchangeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-dataexchange/runtimeConfig.shared.ts b/clients/client-dataexchange/runtimeConfig.shared.ts index 38aa43059167d..068f6cb826e8b 100644 --- a/clients/client-dataexchange/runtimeConfig.shared.ts +++ b/clients/client-dataexchange/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DataExchangeClientConfig } from "./DataExchangeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DataExchangeClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DataExchange", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DataExchange", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-dataexchange/runtimeConfig.ts b/clients/client-dataexchange/runtimeConfig.ts index cc1faf6447ef9..5b479c22528c7 100644 --- a/clients/client-dataexchange/runtimeConfig.ts +++ b/clients/client-dataexchange/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DataExchangeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataExchangeClientConfig } from "./DataExchangeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataExchangeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-datasync/DataSyncClient.ts b/clients/client-datasync/DataSyncClient.ts index c86a8478f49a7..0bd0646835450 100644 --- a/clients/client-datasync/DataSyncClient.ts +++ b/clients/client-datasync/DataSyncClient.ts @@ -69,7 +69,7 @@ import { UpdateTaskExecutionCommandInput, UpdateTaskExecutionCommandOutput, } from "./commands/UpdateTaskExecutionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -355,10 +355,7 @@ export class DataSyncClient extends __Client< readonly config: DataSyncClientResolvedConfig; constructor(configuration: DataSyncClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-datasync/runtimeConfig.browser.ts b/clients/client-datasync/runtimeConfig.browser.ts index 8f2c94056ec15..36c3826bc6bcd 100644 --- a/clients/client-datasync/runtimeConfig.browser.ts +++ b/clients/client-datasync/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DataSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataSyncClientConfig } from "./DataSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-datasync/runtimeConfig.native.ts b/clients/client-datasync/runtimeConfig.native.ts index 812f2f29502b8..e369b625b83ba 100644 --- a/clients/client-datasync/runtimeConfig.native.ts +++ b/clients/client-datasync/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DataSyncClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DataSyncClientConfig } from "./DataSyncClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DataSyncClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-datasync/runtimeConfig.shared.ts b/clients/client-datasync/runtimeConfig.shared.ts index 2a7b3a2967c76..f9cdf5b39a910 100644 --- a/clients/client-datasync/runtimeConfig.shared.ts +++ b/clients/client-datasync/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DataSyncClientConfig } from "./DataSyncClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DataSyncClientConfig) => ({ apiVersion: "2018-11-09", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DataSync", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DataSync", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-datasync/runtimeConfig.ts b/clients/client-datasync/runtimeConfig.ts index db6dff098ec8f..059eb56a2102f 100644 --- a/clients/client-datasync/runtimeConfig.ts +++ b/clients/client-datasync/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DataSyncClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DataSyncClientConfig } from "./DataSyncClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DataSyncClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dax/DAXClient.ts b/clients/client-dax/DAXClient.ts index 0edd69a1f21da..4750c6e967e09 100644 --- a/clients/client-dax/DAXClient.ts +++ b/clients/client-dax/DAXClient.ts @@ -43,7 +43,7 @@ import { UpdateParameterGroupCommandOutput, } from "./commands/UpdateParameterGroupCommand"; import { UpdateSubnetGroupCommandInput, UpdateSubnetGroupCommandOutput } from "./commands/UpdateSubnetGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -300,10 +300,7 @@ export class DAXClient extends __Client< readonly config: DAXClientResolvedConfig; constructor(configuration: DAXClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-dax/runtimeConfig.browser.ts b/clients/client-dax/runtimeConfig.browser.ts index 0e864fba3229c..acb5562c9799d 100644 --- a/clients/client-dax/runtimeConfig.browser.ts +++ b/clients/client-dax/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DAXClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DAXClientConfig } from "./DAXClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DAXClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dax/runtimeConfig.native.ts b/clients/client-dax/runtimeConfig.native.ts index d985d3630f059..2fab517976205 100644 --- a/clients/client-dax/runtimeConfig.native.ts +++ b/clients/client-dax/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DAXClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DAXClientConfig } from "./DAXClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DAXClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-dax/runtimeConfig.shared.ts b/clients/client-dax/runtimeConfig.shared.ts index ed5ef0c8f7f64..ecf9d8c628e53 100644 --- a/clients/client-dax/runtimeConfig.shared.ts +++ b/clients/client-dax/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DAXClientConfig } from "./DAXClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DAXClientConfig) => ({ apiVersion: "2017-04-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DAX", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DAX", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-dax/runtimeConfig.ts b/clients/client-dax/runtimeConfig.ts index 4967b7004b74a..7391bd05627c7 100644 --- a/clients/client-dax/runtimeConfig.ts +++ b/clients/client-dax/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DAXClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DAXClientConfig } from "./DAXClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DAXClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-detective/DetectiveClient.ts b/clients/client-detective/DetectiveClient.ts index 2d91fa9412c6c..90fd68be7665c 100644 --- a/clients/client-detective/DetectiveClient.ts +++ b/clients/client-detective/DetectiveClient.ts @@ -22,7 +22,7 @@ import { } from "./commands/StartMonitoringMemberCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -307,10 +307,7 @@ export class DetectiveClient extends __Client< readonly config: DetectiveClientResolvedConfig; constructor(configuration: DetectiveClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-detective/runtimeConfig.browser.ts b/clients/client-detective/runtimeConfig.browser.ts index a4a78abf2c959..88afaefd15e98 100644 --- a/clients/client-detective/runtimeConfig.browser.ts +++ b/clients/client-detective/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DetectiveClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DetectiveClientConfig } from "./DetectiveClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DetectiveClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-detective/runtimeConfig.native.ts b/clients/client-detective/runtimeConfig.native.ts index 2a6de244fd74b..b673d584dc103 100644 --- a/clients/client-detective/runtimeConfig.native.ts +++ b/clients/client-detective/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DetectiveClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DetectiveClientConfig } from "./DetectiveClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DetectiveClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-detective/runtimeConfig.shared.ts b/clients/client-detective/runtimeConfig.shared.ts index 13b6170c02677..cbd3aecdff96f 100644 --- a/clients/client-detective/runtimeConfig.shared.ts +++ b/clients/client-detective/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DetectiveClientConfig } from "./DetectiveClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DetectiveClientConfig) => ({ apiVersion: "2018-10-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Detective", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Detective", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-detective/runtimeConfig.ts b/clients/client-detective/runtimeConfig.ts index 81842f084b1ca..ac29b71ee898a 100644 --- a/clients/client-detective/runtimeConfig.ts +++ b/clients/client-detective/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DetectiveClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DetectiveClientConfig } from "./DetectiveClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DetectiveClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-device-farm/DeviceFarmClient.ts b/clients/client-device-farm/DeviceFarmClient.ts index 5ca7ae179b3a1..09337e2fe8d51 100644 --- a/clients/client-device-farm/DeviceFarmClient.ts +++ b/clients/client-device-farm/DeviceFarmClient.ts @@ -171,7 +171,7 @@ import { UpdateVPCEConfigurationCommandInput, UpdateVPCEConfigurationCommandOutput, } from "./commands/UpdateVPCEConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -549,10 +549,7 @@ export class DeviceFarmClient extends __Client< readonly config: DeviceFarmClientResolvedConfig; constructor(configuration: DeviceFarmClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-device-farm/runtimeConfig.browser.ts b/clients/client-device-farm/runtimeConfig.browser.ts index 69de5c982d930..a8b36d24c814d 100644 --- a/clients/client-device-farm/runtimeConfig.browser.ts +++ b/clients/client-device-farm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DeviceFarmClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DeviceFarmClientConfig } from "./DeviceFarmClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DeviceFarmClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-device-farm/runtimeConfig.native.ts b/clients/client-device-farm/runtimeConfig.native.ts index 3c54769f9c51d..ff60387eea195 100644 --- a/clients/client-device-farm/runtimeConfig.native.ts +++ b/clients/client-device-farm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DeviceFarmClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DeviceFarmClientConfig } from "./DeviceFarmClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DeviceFarmClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-device-farm/runtimeConfig.shared.ts b/clients/client-device-farm/runtimeConfig.shared.ts index 268a31a044c74..cf3d897679ce1 100644 --- a/clients/client-device-farm/runtimeConfig.shared.ts +++ b/clients/client-device-farm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DeviceFarmClientConfig } from "./DeviceFarmClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DeviceFarmClientConfig) => ({ apiVersion: "2015-06-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Device Farm", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Device Farm", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-device-farm/runtimeConfig.ts b/clients/client-device-farm/runtimeConfig.ts index 4a03cfd160cf9..5ef0459d54885 100644 --- a/clients/client-device-farm/runtimeConfig.ts +++ b/clients/client-device-farm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DeviceFarmClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DeviceFarmClientConfig } from "./DeviceFarmClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DeviceFarmClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-devops-guru/DevOpsGuruClient.ts b/clients/client-devops-guru/DevOpsGuruClient.ts index e9e29fda59a24..05ef011bec36a 100644 --- a/clients/client-devops-guru/DevOpsGuruClient.ts +++ b/clients/client-devops-guru/DevOpsGuruClient.ts @@ -58,7 +58,7 @@ import { UpdateServiceIntegrationCommandInput, UpdateServiceIntegrationCommandOutput, } from "./commands/UpdateServiceIntegrationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -331,10 +331,7 @@ export class DevOpsGuruClient extends __Client< readonly config: DevOpsGuruClientResolvedConfig; constructor(configuration: DevOpsGuruClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-devops-guru/runtimeConfig.browser.ts b/clients/client-devops-guru/runtimeConfig.browser.ts index b32119957d435..9c462d8c9c3a8 100644 --- a/clients/client-devops-guru/runtimeConfig.browser.ts +++ b/clients/client-devops-guru/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DevOpsGuruClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DevOpsGuruClientConfig } from "./DevOpsGuruClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DevOpsGuruClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-devops-guru/runtimeConfig.native.ts b/clients/client-devops-guru/runtimeConfig.native.ts index c15cf752f9dac..f30ad35da2fb3 100644 --- a/clients/client-devops-guru/runtimeConfig.native.ts +++ b/clients/client-devops-guru/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DevOpsGuruClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DevOpsGuruClientConfig } from "./DevOpsGuruClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DevOpsGuruClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-devops-guru/runtimeConfig.shared.ts b/clients/client-devops-guru/runtimeConfig.shared.ts index e397449f6b1e3..1e2648d1d5939 100644 --- a/clients/client-devops-guru/runtimeConfig.shared.ts +++ b/clients/client-devops-guru/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DevOpsGuruClientConfig } from "./DevOpsGuruClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DevOpsGuruClientConfig) => ({ apiVersion: "2020-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DevOps Guru", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DevOps Guru", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-devops-guru/runtimeConfig.ts b/clients/client-devops-guru/runtimeConfig.ts index bc159a8661395..76abd09014fa4 100644 --- a/clients/client-devops-guru/runtimeConfig.ts +++ b/clients/client-devops-guru/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DevOpsGuruClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DevOpsGuruClientConfig } from "./DevOpsGuruClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DevOpsGuruClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-direct-connect/DirectConnectClient.ts b/clients/client-direct-connect/DirectConnectClient.ts index ae2cc72a8fe7c..ef8f8ea595f7d 100644 --- a/clients/client-direct-connect/DirectConnectClient.ts +++ b/clients/client-direct-connect/DirectConnectClient.ts @@ -180,7 +180,7 @@ import { UpdateVirtualInterfaceAttributesCommandInput, UpdateVirtualInterfaceAttributesCommandOutput, } from "./commands/UpdateVirtualInterfaceAttributesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -513,10 +513,7 @@ export class DirectConnectClient extends __Client< readonly config: DirectConnectClientResolvedConfig; constructor(configuration: DirectConnectClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-direct-connect/runtimeConfig.browser.ts b/clients/client-direct-connect/runtimeConfig.browser.ts index 5c73175a0f1ec..21d3ecbfd0d0b 100644 --- a/clients/client-direct-connect/runtimeConfig.browser.ts +++ b/clients/client-direct-connect/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DirectConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DirectConnectClientConfig } from "./DirectConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DirectConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-direct-connect/runtimeConfig.native.ts b/clients/client-direct-connect/runtimeConfig.native.ts index 72ff897f0597f..89b80b302aa8f 100644 --- a/clients/client-direct-connect/runtimeConfig.native.ts +++ b/clients/client-direct-connect/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DirectConnectClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DirectConnectClientConfig } from "./DirectConnectClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DirectConnectClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-direct-connect/runtimeConfig.shared.ts b/clients/client-direct-connect/runtimeConfig.shared.ts index 5c79ef8e4ccde..b80eb3005bef4 100644 --- a/clients/client-direct-connect/runtimeConfig.shared.ts +++ b/clients/client-direct-connect/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DirectConnectClientConfig } from "./DirectConnectClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DirectConnectClientConfig) => ({ apiVersion: "2012-10-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Direct Connect", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Direct Connect", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-direct-connect/runtimeConfig.ts b/clients/client-direct-connect/runtimeConfig.ts index 3f42d57b867f0..d35dea98eb000 100644 --- a/clients/client-direct-connect/runtimeConfig.ts +++ b/clients/client-direct-connect/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DirectConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DirectConnectClientConfig } from "./DirectConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DirectConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-directory-service/DirectoryServiceClient.ts b/clients/client-directory-service/DirectoryServiceClient.ts index 8f0e25a49d990..73fcaf1536069 100644 --- a/clients/client-directory-service/DirectoryServiceClient.ts +++ b/clients/client-directory-service/DirectoryServiceClient.ts @@ -141,7 +141,7 @@ import { import { UpdateRadiusCommandInput, UpdateRadiusCommandOutput } from "./commands/UpdateRadiusCommand"; import { UpdateTrustCommandInput, UpdateTrustCommandOutput } from "./commands/UpdateTrustCommand"; import { VerifyTrustCommandInput, VerifyTrustCommandOutput } from "./commands/VerifyTrustCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -480,10 +480,7 @@ export class DirectoryServiceClient extends __Client< readonly config: DirectoryServiceClientResolvedConfig; constructor(configuration: DirectoryServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-directory-service/runtimeConfig.browser.ts b/clients/client-directory-service/runtimeConfig.browser.ts index 3d668fe6f9137..1be3963c1b715 100644 --- a/clients/client-directory-service/runtimeConfig.browser.ts +++ b/clients/client-directory-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DirectoryServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DirectoryServiceClientConfig } from "./DirectoryServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DirectoryServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-directory-service/runtimeConfig.native.ts b/clients/client-directory-service/runtimeConfig.native.ts index 5a76cbb5d1db8..82b5727a09cff 100644 --- a/clients/client-directory-service/runtimeConfig.native.ts +++ b/clients/client-directory-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DirectoryServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DirectoryServiceClientConfig } from "./DirectoryServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DirectoryServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-directory-service/runtimeConfig.shared.ts b/clients/client-directory-service/runtimeConfig.shared.ts index 07d7a1e9e7a5c..2469ccba760d2 100644 --- a/clients/client-directory-service/runtimeConfig.shared.ts +++ b/clients/client-directory-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DirectoryServiceClientConfig } from "./DirectoryServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DirectoryServiceClientConfig) => ({ apiVersion: "2015-04-16", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Directory Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Directory Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-directory-service/runtimeConfig.ts b/clients/client-directory-service/runtimeConfig.ts index cc518d794a702..cb2394a0a0109 100644 --- a/clients/client-directory-service/runtimeConfig.ts +++ b/clients/client-directory-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DirectoryServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DirectoryServiceClientConfig } from "./DirectoryServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DirectoryServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dlm/DLMClient.ts b/clients/client-dlm/DLMClient.ts index 3a6028d35d83b..38f1d877f32c6 100644 --- a/clients/client-dlm/DLMClient.ts +++ b/clients/client-dlm/DLMClient.ts @@ -21,7 +21,7 @@ import { UpdateLifecyclePolicyCommandInput, UpdateLifecyclePolicyCommandOutput, } from "./commands/UpdateLifecyclePolicyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -253,10 +253,7 @@ export class DLMClient extends __Client< readonly config: DLMClientResolvedConfig; constructor(configuration: DLMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-dlm/runtimeConfig.browser.ts b/clients/client-dlm/runtimeConfig.browser.ts index ee0272809cc22..fd564bac50d57 100644 --- a/clients/client-dlm/runtimeConfig.browser.ts +++ b/clients/client-dlm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DLMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DLMClientConfig } from "./DLMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DLMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dlm/runtimeConfig.native.ts b/clients/client-dlm/runtimeConfig.native.ts index 8774d206f873c..e05ec2ab3fbb6 100644 --- a/clients/client-dlm/runtimeConfig.native.ts +++ b/clients/client-dlm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DLMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DLMClientConfig } from "./DLMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DLMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-dlm/runtimeConfig.shared.ts b/clients/client-dlm/runtimeConfig.shared.ts index 981e364b33bff..33c003f3a2aae 100644 --- a/clients/client-dlm/runtimeConfig.shared.ts +++ b/clients/client-dlm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DLMClientConfig } from "./DLMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DLMClientConfig) => ({ apiVersion: "2018-01-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DLM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DLM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-dlm/runtimeConfig.ts b/clients/client-dlm/runtimeConfig.ts index 169355c1e4fe0..73dc87352b45b 100644 --- a/clients/client-dlm/runtimeConfig.ts +++ b/clients/client-dlm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DLMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DLMClientConfig } from "./DLMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DLMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-docdb/DocDBClient.ts b/clients/client-docdb/DocDBClient.ts index f34fdfecf09a1..20f7e9afef850 100644 --- a/clients/client-docdb/DocDBClient.ts +++ b/clients/client-docdb/DocDBClient.ts @@ -171,7 +171,7 @@ import { } from "./commands/RestoreDBClusterToPointInTimeCommand"; import { StartDBClusterCommandInput, StartDBClusterCommandOutput } from "./commands/StartDBClusterCommand"; import { StopDBClusterCommandInput, StopDBClusterCommandOutput } from "./commands/StopDBClusterCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -487,10 +487,7 @@ export class DocDBClient extends __Client< readonly config: DocDBClientResolvedConfig; constructor(configuration: DocDBClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-docdb/runtimeConfig.browser.ts b/clients/client-docdb/runtimeConfig.browser.ts index 67944469964b7..53b0b93f1cb4c 100644 --- a/clients/client-docdb/runtimeConfig.browser.ts +++ b/clients/client-docdb/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DocDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DocDBClientConfig } from "./DocDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DocDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-docdb/runtimeConfig.native.ts b/clients/client-docdb/runtimeConfig.native.ts index 44a73e5f7fc5a..06a6bd4b70bf6 100644 --- a/clients/client-docdb/runtimeConfig.native.ts +++ b/clients/client-docdb/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DocDBClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DocDBClientConfig } from "./DocDBClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DocDBClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-docdb/runtimeConfig.shared.ts b/clients/client-docdb/runtimeConfig.shared.ts index 4dde6e3728c10..a8c2ae41a4b14 100644 --- a/clients/client-docdb/runtimeConfig.shared.ts +++ b/clients/client-docdb/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DocDBClientConfig } from "./DocDBClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DocDBClientConfig) => ({ apiVersion: "2014-10-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DocDB", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DocDB", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-docdb/runtimeConfig.ts b/clients/client-docdb/runtimeConfig.ts index 91ca625b1413f..6f267f1546913 100644 --- a/clients/client-docdb/runtimeConfig.ts +++ b/clients/client-docdb/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DocDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DocDBClientConfig } from "./DocDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DocDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dynamodb-streams/DynamoDBStreamsClient.ts b/clients/client-dynamodb-streams/DynamoDBStreamsClient.ts index 2afd1b949e4f1..b803b43e752d8 100644 --- a/clients/client-dynamodb-streams/DynamoDBStreamsClient.ts +++ b/clients/client-dynamodb-streams/DynamoDBStreamsClient.ts @@ -2,7 +2,7 @@ import { DescribeStreamCommandInput, DescribeStreamCommandOutput } from "./comma import { GetRecordsCommandInput, GetRecordsCommandOutput } from "./commands/GetRecordsCommand"; import { GetShardIteratorCommandInput, GetShardIteratorCommandOutput } from "./commands/GetShardIteratorCommand"; import { ListStreamsCommandInput, ListStreamsCommandOutput } from "./commands/ListStreamsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -225,10 +225,7 @@ export class DynamoDBStreamsClient extends __Client< readonly config: DynamoDBStreamsClientResolvedConfig; constructor(configuration: DynamoDBStreamsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-dynamodb-streams/runtimeConfig.browser.ts b/clients/client-dynamodb-streams/runtimeConfig.browser.ts index e822e4b1946cf..9d70d929e7f6a 100644 --- a/clients/client-dynamodb-streams/runtimeConfig.browser.ts +++ b/clients/client-dynamodb-streams/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DynamoDBStreamsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DynamoDBStreamsClientConfig } from "./DynamoDBStreamsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DynamoDBStreamsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dynamodb-streams/runtimeConfig.native.ts b/clients/client-dynamodb-streams/runtimeConfig.native.ts index e81307c07981b..60b6a01407d8f 100644 --- a/clients/client-dynamodb-streams/runtimeConfig.native.ts +++ b/clients/client-dynamodb-streams/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DynamoDBStreamsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DynamoDBStreamsClientConfig } from "./DynamoDBStreamsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DynamoDBStreamsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-dynamodb-streams/runtimeConfig.shared.ts b/clients/client-dynamodb-streams/runtimeConfig.shared.ts index 66dafc22a41b8..dee631eccef12 100644 --- a/clients/client-dynamodb-streams/runtimeConfig.shared.ts +++ b/clients/client-dynamodb-streams/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DynamoDBStreamsClientConfig } from "./DynamoDBStreamsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DynamoDBStreamsClientConfig) => ({ apiVersion: "2012-08-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DynamoDB Streams", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DynamoDB Streams", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-dynamodb-streams/runtimeConfig.ts b/clients/client-dynamodb-streams/runtimeConfig.ts index fb3f614d080ad..1aa8d5779ac48 100644 --- a/clients/client-dynamodb-streams/runtimeConfig.ts +++ b/clients/client-dynamodb-streams/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DynamoDBStreamsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DynamoDBStreamsClientConfig } from "./DynamoDBStreamsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DynamoDBStreamsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dynamodb/DynamoDBClient.ts b/clients/client-dynamodb/DynamoDBClient.ts index 34ca25b9e3e67..b4eb1e13d4e79 100644 --- a/clients/client-dynamodb/DynamoDBClient.ts +++ b/clients/client-dynamodb/DynamoDBClient.ts @@ -103,7 +103,7 @@ import { UpdateTableReplicaAutoScalingCommandOutput, } from "./commands/UpdateTableReplicaAutoScalingCommand"; import { UpdateTimeToLiveCommandInput, UpdateTimeToLiveCommandOutput } from "./commands/UpdateTimeToLiveCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -445,10 +445,7 @@ export class DynamoDBClient extends __Client< readonly config: DynamoDBClientResolvedConfig; constructor(configuration: DynamoDBClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-dynamodb/runtimeConfig.browser.ts b/clients/client-dynamodb/runtimeConfig.browser.ts index 1374402a4c12e..e0e418fd5927c 100644 --- a/clients/client-dynamodb/runtimeConfig.browser.ts +++ b/clients/client-dynamodb/runtimeConfig.browser.ts @@ -8,30 +8,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./DynamoDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DynamoDBClientConfig } from "./DynamoDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: () => Promise.resolve(undefined), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DynamoDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: config.endpointDiscoveryEnabledProvider ?? (() => Promise.resolve(undefined)), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-dynamodb/runtimeConfig.native.ts b/clients/client-dynamodb/runtimeConfig.native.ts index 77aa4a1b032d7..bb6dc79133d21 100644 --- a/clients/client-dynamodb/runtimeConfig.native.ts +++ b/clients/client-dynamodb/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./DynamoDBClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { DynamoDBClientConfig } from "./DynamoDBClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: DynamoDBClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-dynamodb/runtimeConfig.shared.ts b/clients/client-dynamodb/runtimeConfig.shared.ts index fb606da58f173..aab6347f744bb 100644 --- a/clients/client-dynamodb/runtimeConfig.shared.ts +++ b/clients/client-dynamodb/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { DynamoDBClientConfig } from "./DynamoDBClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: DynamoDBClientConfig) => ({ apiVersion: "2012-08-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "DynamoDB", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "DynamoDB", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-dynamodb/runtimeConfig.ts b/clients/client-dynamodb/runtimeConfig.ts index 06896480e6070..30105babed08d 100644 --- a/clients/client-dynamodb/runtimeConfig.ts +++ b/clients/client-dynamodb/runtimeConfig.ts @@ -12,30 +12,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./DynamoDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { DynamoDBClientConfig } from "./DynamoDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: DynamoDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: + config.endpointDiscoveryEnabledProvider ?? loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ebs/EBSClient.ts b/clients/client-ebs/EBSClient.ts index 3f9351a26a036..b3fadc5fb50e7 100644 --- a/clients/client-ebs/EBSClient.ts +++ b/clients/client-ebs/EBSClient.ts @@ -4,7 +4,7 @@ import { ListChangedBlocksCommandInput, ListChangedBlocksCommandOutput } from ". import { ListSnapshotBlocksCommandInput, ListSnapshotBlocksCommandOutput } from "./commands/ListSnapshotBlocksCommand"; import { PutSnapshotBlockCommandInput, PutSnapshotBlockCommandOutput } from "./commands/PutSnapshotBlockCommand"; import { StartSnapshotCommandInput, StartSnapshotCommandOutput } from "./commands/StartSnapshotCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -245,10 +245,7 @@ export class EBSClient extends __Client< readonly config: EBSClientResolvedConfig; constructor(configuration: EBSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ebs/runtimeConfig.browser.ts b/clients/client-ebs/runtimeConfig.browser.ts index d93476c9c27df..c17a53826af1d 100644 --- a/clients/client-ebs/runtimeConfig.browser.ts +++ b/clients/client-ebs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EBSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EBSClientConfig } from "./EBSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EBSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ebs/runtimeConfig.native.ts b/clients/client-ebs/runtimeConfig.native.ts index 2c68b014c66ae..a11a5399993d1 100644 --- a/clients/client-ebs/runtimeConfig.native.ts +++ b/clients/client-ebs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EBSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EBSClientConfig } from "./EBSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EBSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ebs/runtimeConfig.shared.ts b/clients/client-ebs/runtimeConfig.shared.ts index a89212ea7a922..55b67ca11295c 100644 --- a/clients/client-ebs/runtimeConfig.shared.ts +++ b/clients/client-ebs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EBSClientConfig } from "./EBSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EBSClientConfig) => ({ apiVersion: "2019-11-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EBS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EBS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ebs/runtimeConfig.ts b/clients/client-ebs/runtimeConfig.ts index 0f3f211f3ba09..e6b8c2c62b6c2 100644 --- a/clients/client-ebs/runtimeConfig.ts +++ b/clients/client-ebs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EBSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EBSClientConfig } from "./EBSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EBSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ec2-instance-connect/EC2InstanceConnectClient.ts b/clients/client-ec2-instance-connect/EC2InstanceConnectClient.ts index 6310cb4c57273..2806b97d2e910 100644 --- a/clients/client-ec2-instance-connect/EC2InstanceConnectClient.ts +++ b/clients/client-ec2-instance-connect/EC2InstanceConnectClient.ts @@ -3,7 +3,7 @@ import { SendSerialConsoleSSHPublicKeyCommandInput, SendSerialConsoleSSHPublicKeyCommandOutput, } from "./commands/SendSerialConsoleSSHPublicKeyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -215,10 +215,7 @@ export class EC2InstanceConnectClient extends __Client< readonly config: EC2InstanceConnectClientResolvedConfig; constructor(configuration: EC2InstanceConnectClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ec2-instance-connect/runtimeConfig.browser.ts b/clients/client-ec2-instance-connect/runtimeConfig.browser.ts index e9f024237b482..ab6bf404b55ed 100644 --- a/clients/client-ec2-instance-connect/runtimeConfig.browser.ts +++ b/clients/client-ec2-instance-connect/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EC2InstanceConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2InstanceConnectClientConfig } from "./EC2InstanceConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2InstanceConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ec2-instance-connect/runtimeConfig.native.ts b/clients/client-ec2-instance-connect/runtimeConfig.native.ts index db01c030653a8..c6a7f283ad016 100644 --- a/clients/client-ec2-instance-connect/runtimeConfig.native.ts +++ b/clients/client-ec2-instance-connect/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EC2InstanceConnectClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EC2InstanceConnectClientConfig } from "./EC2InstanceConnectClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EC2InstanceConnectClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ec2-instance-connect/runtimeConfig.shared.ts b/clients/client-ec2-instance-connect/runtimeConfig.shared.ts index b58e602477ed7..130909cc58376 100644 --- a/clients/client-ec2-instance-connect/runtimeConfig.shared.ts +++ b/clients/client-ec2-instance-connect/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EC2InstanceConnectClientConfig } from "./EC2InstanceConnectClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EC2InstanceConnectClientConfig) => ({ apiVersion: "2018-04-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EC2 Instance Connect", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EC2 Instance Connect", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ec2-instance-connect/runtimeConfig.ts b/clients/client-ec2-instance-connect/runtimeConfig.ts index 5481c078f58a6..30c695789e267 100644 --- a/clients/client-ec2-instance-connect/runtimeConfig.ts +++ b/clients/client-ec2-instance-connect/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EC2InstanceConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2InstanceConnectClientConfig } from "./EC2InstanceConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2InstanceConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ec2/EC2Client.ts b/clients/client-ec2/EC2Client.ts index 1c08b47994e01..3de64d03d6f6c 100644 --- a/clients/client-ec2/EC2Client.ts +++ b/clients/client-ec2/EC2Client.ts @@ -1543,7 +1543,7 @@ import { UpdateSecurityGroupRuleDescriptionsIngressCommandOutput, } from "./commands/UpdateSecurityGroupRuleDescriptionsIngressCommand"; import { WithdrawByoipCidrCommandInput, WithdrawByoipCidrCommandOutput } from "./commands/WithdrawByoipCidrCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -2702,10 +2702,7 @@ export class EC2Client extends __Client< readonly config: EC2ClientResolvedConfig; constructor(configuration: EC2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ec2/runtimeConfig.browser.ts b/clients/client-ec2/runtimeConfig.browser.ts index ec3f754888657..5d90ad6764e29 100644 --- a/clients/client-ec2/runtimeConfig.browser.ts +++ b/clients/client-ec2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EC2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2ClientConfig } from "./EC2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ec2/runtimeConfig.native.ts b/clients/client-ec2/runtimeConfig.native.ts index 9c638def19c85..feacabcce215b 100644 --- a/clients/client-ec2/runtimeConfig.native.ts +++ b/clients/client-ec2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EC2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EC2ClientConfig } from "./EC2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EC2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ec2/runtimeConfig.shared.ts b/clients/client-ec2/runtimeConfig.shared.ts index 5bd79b8d34cfb..6caa26acd1329 100644 --- a/clients/client-ec2/runtimeConfig.shared.ts +++ b/clients/client-ec2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EC2ClientConfig } from "./EC2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EC2ClientConfig) => ({ apiVersion: "2016-11-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EC2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EC2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ec2/runtimeConfig.ts b/clients/client-ec2/runtimeConfig.ts index 4e01ff3bd76ff..12f3ced93eb6c 100644 --- a/clients/client-ec2/runtimeConfig.ts +++ b/clients/client-ec2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EC2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2ClientConfig } from "./EC2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecr-public/ECRPUBLICClient.ts b/clients/client-ecr-public/ECRPUBLICClient.ts index 0b5776141c142..f3d51f6d7e0fa 100644 --- a/clients/client-ecr-public/ECRPUBLICClient.ts +++ b/clients/client-ecr-public/ECRPUBLICClient.ts @@ -60,7 +60,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UploadLayerPartCommandInput, UploadLayerPartCommandOutput } from "./commands/UploadLayerPartCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -322,10 +322,7 @@ export class ECRPUBLICClient extends __Client< readonly config: ECRPUBLICClientResolvedConfig; constructor(configuration: ECRPUBLICClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ecr-public/runtimeConfig.browser.ts b/clients/client-ecr-public/runtimeConfig.browser.ts index ca36841d7006e..76c95a942ddbe 100644 --- a/clients/client-ecr-public/runtimeConfig.browser.ts +++ b/clients/client-ecr-public/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ECRPUBLICClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECRPUBLICClientConfig } from "./ECRPUBLICClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECRPUBLICClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecr-public/runtimeConfig.native.ts b/clients/client-ecr-public/runtimeConfig.native.ts index 86a4cd7a1e789..6c9436148db65 100644 --- a/clients/client-ecr-public/runtimeConfig.native.ts +++ b/clients/client-ecr-public/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ECRPUBLICClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ECRPUBLICClientConfig } from "./ECRPUBLICClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ECRPUBLICClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ecr-public/runtimeConfig.shared.ts b/clients/client-ecr-public/runtimeConfig.shared.ts index 7b93255f9d111..b5f610186b747 100644 --- a/clients/client-ecr-public/runtimeConfig.shared.ts +++ b/clients/client-ecr-public/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ECRPUBLICClientConfig } from "./ECRPUBLICClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ECRPUBLICClientConfig) => ({ apiVersion: "2020-10-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ECR PUBLIC", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ECR PUBLIC", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ecr-public/runtimeConfig.ts b/clients/client-ecr-public/runtimeConfig.ts index c4aee5f867c1d..3c569161eecf0 100644 --- a/clients/client-ecr-public/runtimeConfig.ts +++ b/clients/client-ecr-public/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ECRPUBLICClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECRPUBLICClientConfig } from "./ECRPUBLICClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECRPUBLICClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecr/ECRClient.ts b/clients/client-ecr/ECRClient.ts index 47a718486a9c9..7e00b9409efeb 100644 --- a/clients/client-ecr/ECRClient.ts +++ b/clients/client-ecr/ECRClient.ts @@ -86,7 +86,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UploadLayerPartCommandInput, UploadLayerPartCommandOutput } from "./commands/UploadLayerPartCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -370,10 +370,7 @@ export class ECRClient extends __Client< readonly config: ECRClientResolvedConfig; constructor(configuration: ECRClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ecr/runtimeConfig.browser.ts b/clients/client-ecr/runtimeConfig.browser.ts index 9351c18411938..367c9899dbd15 100644 --- a/clients/client-ecr/runtimeConfig.browser.ts +++ b/clients/client-ecr/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ECRClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECRClientConfig } from "./ECRClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECRClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecr/runtimeConfig.native.ts b/clients/client-ecr/runtimeConfig.native.ts index c08f2880cd189..42329907d8eba 100644 --- a/clients/client-ecr/runtimeConfig.native.ts +++ b/clients/client-ecr/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ECRClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ECRClientConfig } from "./ECRClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ECRClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ecr/runtimeConfig.shared.ts b/clients/client-ecr/runtimeConfig.shared.ts index abb836a2f0c8f..144f0c864b489 100644 --- a/clients/client-ecr/runtimeConfig.shared.ts +++ b/clients/client-ecr/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ECRClientConfig } from "./ECRClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ECRClientConfig) => ({ apiVersion: "2015-09-21", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ECR", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ECR", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ecr/runtimeConfig.ts b/clients/client-ecr/runtimeConfig.ts index 4be0b1b695efd..8257a1fdc0fb6 100644 --- a/clients/client-ecr/runtimeConfig.ts +++ b/clients/client-ecr/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ECRClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECRClientConfig } from "./ECRClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECRClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecs/ECSClient.ts b/clients/client-ecs/ECSClient.ts index 825c23b0a2d8e..9000b80ea3d8a 100644 --- a/clients/client-ecs/ECSClient.ts +++ b/clients/client-ecs/ECSClient.ts @@ -128,7 +128,7 @@ import { UpdateServicePrimaryTaskSetCommandOutput, } from "./commands/UpdateServicePrimaryTaskSetCommand"; import { UpdateTaskSetCommandInput, UpdateTaskSetCommandOutput } from "./commands/UpdateTaskSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -454,10 +454,7 @@ export class ECSClient extends __Client< readonly config: ECSClientResolvedConfig; constructor(configuration: ECSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ecs/runtimeConfig.browser.ts b/clients/client-ecs/runtimeConfig.browser.ts index 3bd1bb403a767..f89c4fbb39943 100644 --- a/clients/client-ecs/runtimeConfig.browser.ts +++ b/clients/client-ecs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ECSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECSClientConfig } from "./ECSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ecs/runtimeConfig.native.ts b/clients/client-ecs/runtimeConfig.native.ts index 91f195ff54928..547c6261c9518 100644 --- a/clients/client-ecs/runtimeConfig.native.ts +++ b/clients/client-ecs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ECSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ECSClientConfig } from "./ECSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ECSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ecs/runtimeConfig.shared.ts b/clients/client-ecs/runtimeConfig.shared.ts index 47013405c702b..3ac2f4389a53f 100644 --- a/clients/client-ecs/runtimeConfig.shared.ts +++ b/clients/client-ecs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ECSClientConfig } from "./ECSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ECSClientConfig) => ({ apiVersion: "2014-11-13", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ECS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ECS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ecs/runtimeConfig.ts b/clients/client-ecs/runtimeConfig.ts index ffc969e0496f8..27e058a49d912 100644 --- a/clients/client-ecs/runtimeConfig.ts +++ b/clients/client-ecs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ECSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ECSClientConfig } from "./ECSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ECSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-efs/EFSClient.ts b/clients/client-efs/EFSClient.ts index f84f6ceeb4258..6575803904184 100644 --- a/clients/client-efs/EFSClient.ts +++ b/clients/client-efs/EFSClient.ts @@ -67,7 +67,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateFileSystemCommandInput, UpdateFileSystemCommandOutput } from "./commands/UpdateFileSystemCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -335,10 +335,7 @@ export class EFSClient extends __Client< readonly config: EFSClientResolvedConfig; constructor(configuration: EFSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-efs/runtimeConfig.browser.ts b/clients/client-efs/runtimeConfig.browser.ts index 15fc6599996f5..120bdcab46cd3 100644 --- a/clients/client-efs/runtimeConfig.browser.ts +++ b/clients/client-efs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EFSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EFSClientConfig } from "./EFSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EFSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-efs/runtimeConfig.native.ts b/clients/client-efs/runtimeConfig.native.ts index 9ee547c11ec27..df59b2a970c3f 100644 --- a/clients/client-efs/runtimeConfig.native.ts +++ b/clients/client-efs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EFSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EFSClientConfig } from "./EFSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EFSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-efs/runtimeConfig.shared.ts b/clients/client-efs/runtimeConfig.shared.ts index 2b9348ba27150..d1e66f6d3774c 100644 --- a/clients/client-efs/runtimeConfig.shared.ts +++ b/clients/client-efs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EFSClientConfig } from "./EFSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EFSClientConfig) => ({ apiVersion: "2015-02-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EFS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EFS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-efs/runtimeConfig.ts b/clients/client-efs/runtimeConfig.ts index ec8da3f019591..cd9244181a343 100644 --- a/clients/client-efs/runtimeConfig.ts +++ b/clients/client-efs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EFSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EFSClientConfig } from "./EFSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EFSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-eks/EKSClient.ts b/clients/client-eks/EKSClient.ts index 9c7e8f790dec4..82cb89567c408 100644 --- a/clients/client-eks/EKSClient.ts +++ b/clients/client-eks/EKSClient.ts @@ -75,7 +75,7 @@ import { UpdateNodegroupVersionCommandInput, UpdateNodegroupVersionCommandOutput, } from "./commands/UpdateNodegroupVersionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -358,10 +358,7 @@ export class EKSClient extends __Client< readonly config: EKSClientResolvedConfig; constructor(configuration: EKSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-eks/runtimeConfig.browser.ts b/clients/client-eks/runtimeConfig.browser.ts index d3a8fa8c93e18..96e9708943f4e 100644 --- a/clients/client-eks/runtimeConfig.browser.ts +++ b/clients/client-eks/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EKSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EKSClientConfig } from "./EKSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EKSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-eks/runtimeConfig.native.ts b/clients/client-eks/runtimeConfig.native.ts index 9a2f25d86546f..e789dd8b657a8 100644 --- a/clients/client-eks/runtimeConfig.native.ts +++ b/clients/client-eks/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EKSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EKSClientConfig } from "./EKSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EKSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-eks/runtimeConfig.shared.ts b/clients/client-eks/runtimeConfig.shared.ts index 1006e99f84475..a3bfa26157b5f 100644 --- a/clients/client-eks/runtimeConfig.shared.ts +++ b/clients/client-eks/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EKSClientConfig } from "./EKSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EKSClientConfig) => ({ apiVersion: "2017-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EKS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EKS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-eks/runtimeConfig.ts b/clients/client-eks/runtimeConfig.ts index e97cc20f6c78b..39acf72f84373 100644 --- a/clients/client-eks/runtimeConfig.ts +++ b/clients/client-eks/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EKSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EKSClientConfig } from "./EKSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EKSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-beanstalk/ElasticBeanstalkClient.ts b/clients/client-elastic-beanstalk/ElasticBeanstalkClient.ts index 7c7bb8e95ea47..b54e0727ebfe5 100644 --- a/clients/client-elastic-beanstalk/ElasticBeanstalkClient.ts +++ b/clients/client-elastic-beanstalk/ElasticBeanstalkClient.ts @@ -162,7 +162,7 @@ import { ValidateConfigurationSettingsCommandInput, ValidateConfigurationSettingsCommandOutput, } from "./commands/ValidateConfigurationSettingsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -480,10 +480,7 @@ export class ElasticBeanstalkClient extends __Client< readonly config: ElasticBeanstalkClientResolvedConfig; constructor(configuration: ElasticBeanstalkClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elastic-beanstalk/runtimeConfig.browser.ts b/clients/client-elastic-beanstalk/runtimeConfig.browser.ts index a4dee68422406..ad81a7df8538b 100644 --- a/clients/client-elastic-beanstalk/runtimeConfig.browser.ts +++ b/clients/client-elastic-beanstalk/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticBeanstalkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticBeanstalkClientConfig } from "./ElasticBeanstalkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticBeanstalkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-beanstalk/runtimeConfig.native.ts b/clients/client-elastic-beanstalk/runtimeConfig.native.ts index d3c092a212bd7..e9b55f275d8a8 100644 --- a/clients/client-elastic-beanstalk/runtimeConfig.native.ts +++ b/clients/client-elastic-beanstalk/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticBeanstalkClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticBeanstalkClientConfig } from "./ElasticBeanstalkClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticBeanstalkClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elastic-beanstalk/runtimeConfig.shared.ts b/clients/client-elastic-beanstalk/runtimeConfig.shared.ts index dc6f4c0fa9045..ef06e8a029b90 100644 --- a/clients/client-elastic-beanstalk/runtimeConfig.shared.ts +++ b/clients/client-elastic-beanstalk/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticBeanstalkClientConfig } from "./ElasticBeanstalkClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticBeanstalkClientConfig) => ({ apiVersion: "2010-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elastic Beanstalk", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elastic Beanstalk", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elastic-beanstalk/runtimeConfig.ts b/clients/client-elastic-beanstalk/runtimeConfig.ts index 8942307870a2d..6d537b718e1a5 100644 --- a/clients/client-elastic-beanstalk/runtimeConfig.ts +++ b/clients/client-elastic-beanstalk/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticBeanstalkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticBeanstalkClientConfig } from "./ElasticBeanstalkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticBeanstalkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-inference/ElasticInferenceClient.ts b/clients/client-elastic-inference/ElasticInferenceClient.ts index 796ac791bfdbe..c87aac2f33a1d 100644 --- a/clients/client-elastic-inference/ElasticInferenceClient.ts +++ b/clients/client-elastic-inference/ElasticInferenceClient.ts @@ -16,7 +16,7 @@ import { } from "./commands/ListTagsForResourceCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -240,10 +240,7 @@ export class ElasticInferenceClient extends __Client< readonly config: ElasticInferenceClientResolvedConfig; constructor(configuration: ElasticInferenceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elastic-inference/runtimeConfig.browser.ts b/clients/client-elastic-inference/runtimeConfig.browser.ts index def84bdef198b..a7886262c962d 100644 --- a/clients/client-elastic-inference/runtimeConfig.browser.ts +++ b/clients/client-elastic-inference/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticInferenceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticInferenceClientConfig } from "./ElasticInferenceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticInferenceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-inference/runtimeConfig.native.ts b/clients/client-elastic-inference/runtimeConfig.native.ts index 6b97c510200f8..9eac357a03088 100644 --- a/clients/client-elastic-inference/runtimeConfig.native.ts +++ b/clients/client-elastic-inference/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticInferenceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticInferenceClientConfig } from "./ElasticInferenceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticInferenceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elastic-inference/runtimeConfig.shared.ts b/clients/client-elastic-inference/runtimeConfig.shared.ts index 1e7a6a1ff6ac9..c7bc71743b1f3 100644 --- a/clients/client-elastic-inference/runtimeConfig.shared.ts +++ b/clients/client-elastic-inference/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticInferenceClientConfig } from "./ElasticInferenceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticInferenceClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elastic Inference", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elastic Inference", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elastic-inference/runtimeConfig.ts b/clients/client-elastic-inference/runtimeConfig.ts index 2c98aac421d57..a18e13c482aa9 100644 --- a/clients/client-elastic-inference/runtimeConfig.ts +++ b/clients/client-elastic-inference/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticInferenceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticInferenceClientConfig } from "./ElasticInferenceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticInferenceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-load-balancing-v2/ElasticLoadBalancingV2Client.ts b/clients/client-elastic-load-balancing-v2/ElasticLoadBalancingV2Client.ts index 1f7d5cacb69e8..98f61a5af01c8 100644 --- a/clients/client-elastic-load-balancing-v2/ElasticLoadBalancingV2Client.ts +++ b/clients/client-elastic-load-balancing-v2/ElasticLoadBalancingV2Client.ts @@ -68,7 +68,7 @@ import { SetIpAddressTypeCommandInput, SetIpAddressTypeCommandOutput } from "./c import { SetRulePrioritiesCommandInput, SetRulePrioritiesCommandOutput } from "./commands/SetRulePrioritiesCommand"; import { SetSecurityGroupsCommandInput, SetSecurityGroupsCommandOutput } from "./commands/SetSecurityGroupsCommand"; import { SetSubnetsCommandInput, SetSubnetsCommandOutput } from "./commands/SetSubnetsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -384,10 +384,7 @@ export class ElasticLoadBalancingV2Client extends __Client< readonly config: ElasticLoadBalancingV2ClientResolvedConfig; constructor(configuration: ElasticLoadBalancingV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elastic-load-balancing-v2/runtimeConfig.browser.ts b/clients/client-elastic-load-balancing-v2/runtimeConfig.browser.ts index 93fab2c3ea174..abc7141ed89e1 100644 --- a/clients/client-elastic-load-balancing-v2/runtimeConfig.browser.ts +++ b/clients/client-elastic-load-balancing-v2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticLoadBalancingV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticLoadBalancingV2ClientConfig } from "./ElasticLoadBalancingV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticLoadBalancingV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-load-balancing-v2/runtimeConfig.native.ts b/clients/client-elastic-load-balancing-v2/runtimeConfig.native.ts index 140bf10808279..93305ca1e2a6d 100644 --- a/clients/client-elastic-load-balancing-v2/runtimeConfig.native.ts +++ b/clients/client-elastic-load-balancing-v2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticLoadBalancingV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticLoadBalancingV2ClientConfig } from "./ElasticLoadBalancingV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticLoadBalancingV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elastic-load-balancing-v2/runtimeConfig.shared.ts b/clients/client-elastic-load-balancing-v2/runtimeConfig.shared.ts index 2033f47ae204d..52cf89c111199 100644 --- a/clients/client-elastic-load-balancing-v2/runtimeConfig.shared.ts +++ b/clients/client-elastic-load-balancing-v2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticLoadBalancingV2ClientConfig } from "./ElasticLoadBalancingV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticLoadBalancingV2ClientConfig) => ({ apiVersion: "2015-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elastic Load Balancing v2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elastic Load Balancing v2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elastic-load-balancing-v2/runtimeConfig.ts b/clients/client-elastic-load-balancing-v2/runtimeConfig.ts index aee9fb3a326a7..92bd1e1e11332 100644 --- a/clients/client-elastic-load-balancing-v2/runtimeConfig.ts +++ b/clients/client-elastic-load-balancing-v2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticLoadBalancingV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticLoadBalancingV2ClientConfig } from "./ElasticLoadBalancingV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticLoadBalancingV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-load-balancing/ElasticLoadBalancingClient.ts b/clients/client-elastic-load-balancing/ElasticLoadBalancingClient.ts index d97da0d9b70bc..c49e7a0f94ee2 100644 --- a/clients/client-elastic-load-balancing/ElasticLoadBalancingClient.ts +++ b/clients/client-elastic-load-balancing/ElasticLoadBalancingClient.ts @@ -99,7 +99,7 @@ import { SetLoadBalancerPoliciesOfListenerCommandInput, SetLoadBalancerPoliciesOfListenerCommandOutput, } from "./commands/SetLoadBalancerPoliciesOfListenerCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -387,10 +387,7 @@ export class ElasticLoadBalancingClient extends __Client< readonly config: ElasticLoadBalancingClientResolvedConfig; constructor(configuration: ElasticLoadBalancingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elastic-load-balancing/runtimeConfig.browser.ts b/clients/client-elastic-load-balancing/runtimeConfig.browser.ts index 92635ab461358..7c5854814a17b 100644 --- a/clients/client-elastic-load-balancing/runtimeConfig.browser.ts +++ b/clients/client-elastic-load-balancing/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticLoadBalancingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticLoadBalancingClientConfig } from "./ElasticLoadBalancingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticLoadBalancingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-load-balancing/runtimeConfig.native.ts b/clients/client-elastic-load-balancing/runtimeConfig.native.ts index cb47839b81187..0f623d9c3adb3 100644 --- a/clients/client-elastic-load-balancing/runtimeConfig.native.ts +++ b/clients/client-elastic-load-balancing/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticLoadBalancingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticLoadBalancingClientConfig } from "./ElasticLoadBalancingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticLoadBalancingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elastic-load-balancing/runtimeConfig.shared.ts b/clients/client-elastic-load-balancing/runtimeConfig.shared.ts index 6767433cba88b..c76e8fefc7e2f 100644 --- a/clients/client-elastic-load-balancing/runtimeConfig.shared.ts +++ b/clients/client-elastic-load-balancing/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticLoadBalancingClientConfig } from "./ElasticLoadBalancingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticLoadBalancingClientConfig) => ({ apiVersion: "2012-06-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elastic Load Balancing", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elastic Load Balancing", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elastic-load-balancing/runtimeConfig.ts b/clients/client-elastic-load-balancing/runtimeConfig.ts index cff827042fd2a..7427d893e096e 100644 --- a/clients/client-elastic-load-balancing/runtimeConfig.ts +++ b/clients/client-elastic-load-balancing/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticLoadBalancingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticLoadBalancingClientConfig } from "./ElasticLoadBalancingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticLoadBalancingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-transcoder/ElasticTranscoderClient.ts b/clients/client-elastic-transcoder/ElasticTranscoderClient.ts index 837fe8da04952..627942ffb03ad 100644 --- a/clients/client-elastic-transcoder/ElasticTranscoderClient.ts +++ b/clients/client-elastic-transcoder/ElasticTranscoderClient.ts @@ -21,7 +21,7 @@ import { UpdatePipelineStatusCommandInput, UpdatePipelineStatusCommandOutput, } from "./commands/UpdatePipelineStatusCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -266,10 +266,7 @@ export class ElasticTranscoderClient extends __Client< readonly config: ElasticTranscoderClientResolvedConfig; constructor(configuration: ElasticTranscoderClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elastic-transcoder/runtimeConfig.browser.ts b/clients/client-elastic-transcoder/runtimeConfig.browser.ts index 8317a5a18d454..479db6e5012bd 100644 --- a/clients/client-elastic-transcoder/runtimeConfig.browser.ts +++ b/clients/client-elastic-transcoder/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticTranscoderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticTranscoderClientConfig } from "./ElasticTranscoderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticTranscoderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elastic-transcoder/runtimeConfig.native.ts b/clients/client-elastic-transcoder/runtimeConfig.native.ts index e54ca90ec9f03..57673e5ae3164 100644 --- a/clients/client-elastic-transcoder/runtimeConfig.native.ts +++ b/clients/client-elastic-transcoder/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticTranscoderClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticTranscoderClientConfig } from "./ElasticTranscoderClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticTranscoderClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elastic-transcoder/runtimeConfig.shared.ts b/clients/client-elastic-transcoder/runtimeConfig.shared.ts index c6c6f37b8aa20..8b932fecaf18f 100644 --- a/clients/client-elastic-transcoder/runtimeConfig.shared.ts +++ b/clients/client-elastic-transcoder/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticTranscoderClientConfig } from "./ElasticTranscoderClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticTranscoderClientConfig) => ({ apiVersion: "2012-09-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elastic Transcoder", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elastic Transcoder", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elastic-transcoder/runtimeConfig.ts b/clients/client-elastic-transcoder/runtimeConfig.ts index 727675a8f72ad..5d7251d3c1f1e 100644 --- a/clients/client-elastic-transcoder/runtimeConfig.ts +++ b/clients/client-elastic-transcoder/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticTranscoderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticTranscoderClientConfig } from "./ElasticTranscoderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticTranscoderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elasticache/ElastiCacheClient.ts b/clients/client-elasticache/ElastiCacheClient.ts index 33a6523715b6c..7398610c8e620 100644 --- a/clients/client-elasticache/ElastiCacheClient.ts +++ b/clients/client-elasticache/ElastiCacheClient.ts @@ -195,7 +195,7 @@ import { } from "./commands/RevokeCacheSecurityGroupIngressCommand"; import { StartMigrationCommandInput, StartMigrationCommandOutput } from "./commands/StartMigrationCommand"; import { TestFailoverCommandInput, TestFailoverCommandOutput } from "./commands/TestFailoverCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -544,10 +544,7 @@ export class ElastiCacheClient extends __Client< readonly config: ElastiCacheClientResolvedConfig; constructor(configuration: ElastiCacheClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elasticache/runtimeConfig.browser.ts b/clients/client-elasticache/runtimeConfig.browser.ts index 066856fabc1d4..c12f7c3030714 100644 --- a/clients/client-elasticache/runtimeConfig.browser.ts +++ b/clients/client-elasticache/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElastiCacheClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElastiCacheClientConfig } from "./ElastiCacheClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElastiCacheClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elasticache/runtimeConfig.native.ts b/clients/client-elasticache/runtimeConfig.native.ts index 230192b8e5dd2..ed7edb87ba429 100644 --- a/clients/client-elasticache/runtimeConfig.native.ts +++ b/clients/client-elasticache/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElastiCacheClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElastiCacheClientConfig } from "./ElastiCacheClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElastiCacheClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elasticache/runtimeConfig.shared.ts b/clients/client-elasticache/runtimeConfig.shared.ts index 0761a94a376a9..861fb559db63d 100644 --- a/clients/client-elasticache/runtimeConfig.shared.ts +++ b/clients/client-elasticache/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElastiCacheClientConfig } from "./ElastiCacheClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElastiCacheClientConfig) => ({ apiVersion: "2015-02-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ElastiCache", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ElastiCache", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elasticache/runtimeConfig.ts b/clients/client-elasticache/runtimeConfig.ts index 61e614876d8a8..6b136b30a2839 100644 --- a/clients/client-elasticache/runtimeConfig.ts +++ b/clients/client-elasticache/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElastiCacheClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElastiCacheClientConfig } from "./ElastiCacheClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElastiCacheClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elasticsearch-service/ElasticsearchServiceClient.ts b/clients/client-elasticsearch-service/ElasticsearchServiceClient.ts index 532c8d992f3bd..33fce9670db48 100644 --- a/clients/client-elasticsearch-service/ElasticsearchServiceClient.ts +++ b/clients/client-elasticsearch-service/ElasticsearchServiceClient.ts @@ -122,7 +122,7 @@ import { UpgradeElasticsearchDomainCommandInput, UpgradeElasticsearchDomainCommandOutput, } from "./commands/UpgradeElasticsearchDomainCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -418,10 +418,7 @@ export class ElasticsearchServiceClient extends __Client< readonly config: ElasticsearchServiceClientResolvedConfig; constructor(configuration: ElasticsearchServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-elasticsearch-service/runtimeConfig.browser.ts b/clients/client-elasticsearch-service/runtimeConfig.browser.ts index 7fa4a3eea3acf..41c49a671fd03 100644 --- a/clients/client-elasticsearch-service/runtimeConfig.browser.ts +++ b/clients/client-elasticsearch-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ElasticsearchServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticsearchServiceClientConfig } from "./ElasticsearchServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticsearchServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-elasticsearch-service/runtimeConfig.native.ts b/clients/client-elasticsearch-service/runtimeConfig.native.ts index 82e73453c4427..25a3db5134154 100644 --- a/clients/client-elasticsearch-service/runtimeConfig.native.ts +++ b/clients/client-elasticsearch-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ElasticsearchServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ElasticsearchServiceClientConfig } from "./ElasticsearchServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ElasticsearchServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-elasticsearch-service/runtimeConfig.shared.ts b/clients/client-elasticsearch-service/runtimeConfig.shared.ts index c224b21772210..2e8e06dbb6754 100644 --- a/clients/client-elasticsearch-service/runtimeConfig.shared.ts +++ b/clients/client-elasticsearch-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ElasticsearchServiceClientConfig } from "./ElasticsearchServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ElasticsearchServiceClientConfig) => ({ apiVersion: "2015-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Elasticsearch Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Elasticsearch Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-elasticsearch-service/runtimeConfig.ts b/clients/client-elasticsearch-service/runtimeConfig.ts index 9d0771fccc54a..3b429b8eb047e 100644 --- a/clients/client-elasticsearch-service/runtimeConfig.ts +++ b/clients/client-elasticsearch-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ElasticsearchServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ElasticsearchServiceClientConfig } from "./ElasticsearchServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ElasticsearchServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-emr-containers/EMRContainersClient.ts b/clients/client-emr-containers/EMRContainersClient.ts index 13228d4b6fb7f..c2668c3833de4 100644 --- a/clients/client-emr-containers/EMRContainersClient.ts +++ b/clients/client-emr-containers/EMRContainersClient.ts @@ -40,7 +40,7 @@ import { import { StartJobRunCommandInput, StartJobRunCommandOutput } from "./commands/StartJobRunCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -301,10 +301,7 @@ export class EMRContainersClient extends __Client< readonly config: EMRContainersClientResolvedConfig; constructor(configuration: EMRContainersClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-emr-containers/runtimeConfig.browser.ts b/clients/client-emr-containers/runtimeConfig.browser.ts index fd7e33b3bf67c..6b42cdb68043e 100644 --- a/clients/client-emr-containers/runtimeConfig.browser.ts +++ b/clients/client-emr-containers/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EMRContainersClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EMRContainersClientConfig } from "./EMRContainersClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EMRContainersClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-emr-containers/runtimeConfig.native.ts b/clients/client-emr-containers/runtimeConfig.native.ts index f52635e3f828e..f722d3834dbd1 100644 --- a/clients/client-emr-containers/runtimeConfig.native.ts +++ b/clients/client-emr-containers/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EMRContainersClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EMRContainersClientConfig } from "./EMRContainersClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EMRContainersClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-emr-containers/runtimeConfig.shared.ts b/clients/client-emr-containers/runtimeConfig.shared.ts index f09d04e16714f..6660f5cfbe75d 100644 --- a/clients/client-emr-containers/runtimeConfig.shared.ts +++ b/clients/client-emr-containers/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EMRContainersClientConfig } from "./EMRContainersClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EMRContainersClientConfig) => ({ apiVersion: "2020-10-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EMR containers", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EMR containers", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-emr-containers/runtimeConfig.ts b/clients/client-emr-containers/runtimeConfig.ts index 180122b3f96f5..d91f8145dbde9 100644 --- a/clients/client-emr-containers/runtimeConfig.ts +++ b/clients/client-emr-containers/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EMRContainersClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EMRContainersClientConfig } from "./EMRContainersClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EMRContainersClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-emr/EMRClient.ts b/clients/client-emr/EMRClient.ts index d8ea218c43fe2..5e5e8e0eea656 100644 --- a/clients/client-emr/EMRClient.ts +++ b/clients/client-emr/EMRClient.ts @@ -120,7 +120,7 @@ import { UpdateStudioSessionMappingCommandInput, UpdateStudioSessionMappingCommandOutput, } from "./commands/UpdateStudioSessionMappingCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -427,10 +427,7 @@ export class EMRClient extends __Client< readonly config: EMRClientResolvedConfig; constructor(configuration: EMRClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-emr/runtimeConfig.browser.ts b/clients/client-emr/runtimeConfig.browser.ts index c142e141c221f..1d4a33f508adb 100644 --- a/clients/client-emr/runtimeConfig.browser.ts +++ b/clients/client-emr/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EMRClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EMRClientConfig } from "./EMRClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EMRClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-emr/runtimeConfig.native.ts b/clients/client-emr/runtimeConfig.native.ts index 8581cbcca90f1..cd70b44ad7a9d 100644 --- a/clients/client-emr/runtimeConfig.native.ts +++ b/clients/client-emr/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EMRClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EMRClientConfig } from "./EMRClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EMRClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-emr/runtimeConfig.shared.ts b/clients/client-emr/runtimeConfig.shared.ts index 592e6876ad66a..7eb98c1bfe76a 100644 --- a/clients/client-emr/runtimeConfig.shared.ts +++ b/clients/client-emr/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EMRClientConfig } from "./EMRClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EMRClientConfig) => ({ apiVersion: "2009-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EMR", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EMR", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-emr/runtimeConfig.ts b/clients/client-emr/runtimeConfig.ts index c2df6865cbac3..de85bc0a11c66 100644 --- a/clients/client-emr/runtimeConfig.ts +++ b/clients/client-emr/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EMRClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EMRClientConfig } from "./EMRClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EMRClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-eventbridge/EventBridgeClient.ts b/clients/client-eventbridge/EventBridgeClient.ts index a3da47ccf8f5f..daa4ecb6981c3 100644 --- a/clients/client-eventbridge/EventBridgeClient.ts +++ b/clients/client-eventbridge/EventBridgeClient.ts @@ -97,7 +97,7 @@ import { } from "./commands/UpdateApiDestinationCommand"; import { UpdateArchiveCommandInput, UpdateArchiveCommandOutput } from "./commands/UpdateArchiveCommand"; import { UpdateConnectionCommandInput, UpdateConnectionCommandOutput } from "./commands/UpdateConnectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -429,10 +429,7 @@ export class EventBridgeClient extends __Client< readonly config: EventBridgeClientResolvedConfig; constructor(configuration: EventBridgeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-eventbridge/runtimeConfig.browser.ts b/clients/client-eventbridge/runtimeConfig.browser.ts index c107d993a76de..f4544f513fbbe 100644 --- a/clients/client-eventbridge/runtimeConfig.browser.ts +++ b/clients/client-eventbridge/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EventBridgeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EventBridgeClientConfig } from "./EventBridgeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EventBridgeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-eventbridge/runtimeConfig.native.ts b/clients/client-eventbridge/runtimeConfig.native.ts index 6f4311c2529d2..112e116cd1280 100644 --- a/clients/client-eventbridge/runtimeConfig.native.ts +++ b/clients/client-eventbridge/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EventBridgeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EventBridgeClientConfig } from "./EventBridgeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EventBridgeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-eventbridge/runtimeConfig.shared.ts b/clients/client-eventbridge/runtimeConfig.shared.ts index c3011b606dc89..95c827eb66e18 100644 --- a/clients/client-eventbridge/runtimeConfig.shared.ts +++ b/clients/client-eventbridge/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EventBridgeClientConfig } from "./EventBridgeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EventBridgeClientConfig) => ({ apiVersion: "2015-10-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EventBridge", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EventBridge", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-eventbridge/runtimeConfig.ts b/clients/client-eventbridge/runtimeConfig.ts index d36ecd7e35a50..5477978a91fc0 100644 --- a/clients/client-eventbridge/runtimeConfig.ts +++ b/clients/client-eventbridge/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EventBridgeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EventBridgeClientConfig } from "./EventBridgeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EventBridgeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-finspace-data/FinspaceDataClient.ts b/clients/client-finspace-data/FinspaceDataClient.ts index de0219a1ae27e..8a928de539971 100644 --- a/clients/client-finspace-data/FinspaceDataClient.ts +++ b/clients/client-finspace-data/FinspaceDataClient.ts @@ -4,7 +4,7 @@ import { GetProgrammaticAccessCredentialsCommandOutput, } from "./commands/GetProgrammaticAccessCredentialsCommand"; import { GetWorkingLocationCommandInput, GetWorkingLocationCommandOutput } from "./commands/GetWorkingLocationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -220,10 +220,7 @@ export class FinspaceDataClient extends __Client< readonly config: FinspaceDataClientResolvedConfig; constructor(configuration: FinspaceDataClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-finspace-data/runtimeConfig.browser.ts b/clients/client-finspace-data/runtimeConfig.browser.ts index 52891bf3ae1ff..eb3e9ff0476b9 100644 --- a/clients/client-finspace-data/runtimeConfig.browser.ts +++ b/clients/client-finspace-data/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FinspaceDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FinspaceDataClientConfig } from "./FinspaceDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FinspaceDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-finspace-data/runtimeConfig.native.ts b/clients/client-finspace-data/runtimeConfig.native.ts index cb79dee00b006..37c48ac012186 100644 --- a/clients/client-finspace-data/runtimeConfig.native.ts +++ b/clients/client-finspace-data/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FinspaceDataClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FinspaceDataClientConfig } from "./FinspaceDataClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FinspaceDataClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-finspace-data/runtimeConfig.shared.ts b/clients/client-finspace-data/runtimeConfig.shared.ts index 08e7c061b5928..b4cd2f4e86847 100644 --- a/clients/client-finspace-data/runtimeConfig.shared.ts +++ b/clients/client-finspace-data/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FinspaceDataClientConfig } from "./FinspaceDataClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FinspaceDataClientConfig) => ({ apiVersion: "2020-07-13", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "finspace data", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "finspace data", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-finspace-data/runtimeConfig.ts b/clients/client-finspace-data/runtimeConfig.ts index 76ec9d5f861ca..ecaa3deea09f7 100644 --- a/clients/client-finspace-data/runtimeConfig.ts +++ b/clients/client-finspace-data/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FinspaceDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FinspaceDataClientConfig } from "./FinspaceDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FinspaceDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-finspace/FinspaceClient.ts b/clients/client-finspace/FinspaceClient.ts index 43c1606cdb438..b8530cd5bd5ba 100644 --- a/clients/client-finspace/FinspaceClient.ts +++ b/clients/client-finspace/FinspaceClient.ts @@ -9,7 +9,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateEnvironmentCommandInput, UpdateEnvironmentCommandOutput } from "./commands/UpdateEnvironmentCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -236,10 +236,7 @@ export class FinspaceClient extends __Client< readonly config: FinspaceClientResolvedConfig; constructor(configuration: FinspaceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-finspace/runtimeConfig.browser.ts b/clients/client-finspace/runtimeConfig.browser.ts index ff4b378c39764..dc8621120d4d8 100644 --- a/clients/client-finspace/runtimeConfig.browser.ts +++ b/clients/client-finspace/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FinspaceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FinspaceClientConfig } from "./FinspaceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FinspaceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-finspace/runtimeConfig.native.ts b/clients/client-finspace/runtimeConfig.native.ts index bd3c3a4b0fed5..b2443e797ef82 100644 --- a/clients/client-finspace/runtimeConfig.native.ts +++ b/clients/client-finspace/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FinspaceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FinspaceClientConfig } from "./FinspaceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FinspaceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-finspace/runtimeConfig.shared.ts b/clients/client-finspace/runtimeConfig.shared.ts index d6632ea48470a..4d2b7949be890 100644 --- a/clients/client-finspace/runtimeConfig.shared.ts +++ b/clients/client-finspace/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FinspaceClientConfig } from "./FinspaceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FinspaceClientConfig) => ({ apiVersion: "2021-03-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "finspace", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "finspace", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-finspace/runtimeConfig.ts b/clients/client-finspace/runtimeConfig.ts index f70c994285d82..ef5795be4e94a 100644 --- a/clients/client-finspace/runtimeConfig.ts +++ b/clients/client-finspace/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FinspaceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FinspaceClientConfig } from "./FinspaceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FinspaceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-firehose/FirehoseClient.ts b/clients/client-firehose/FirehoseClient.ts index a370863c91db1..137800e4e858a 100644 --- a/clients/client-firehose/FirehoseClient.ts +++ b/clients/client-firehose/FirehoseClient.ts @@ -34,7 +34,7 @@ import { UntagDeliveryStreamCommandOutput, } from "./commands/UntagDeliveryStreamCommand"; import { UpdateDestinationCommandInput, UpdateDestinationCommandOutput } from "./commands/UpdateDestinationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -271,10 +271,7 @@ export class FirehoseClient extends __Client< readonly config: FirehoseClientResolvedConfig; constructor(configuration: FirehoseClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-firehose/runtimeConfig.browser.ts b/clients/client-firehose/runtimeConfig.browser.ts index c5fd81724c78b..9b91dc7d05568 100644 --- a/clients/client-firehose/runtimeConfig.browser.ts +++ b/clients/client-firehose/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FirehoseClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FirehoseClientConfig } from "./FirehoseClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FirehoseClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-firehose/runtimeConfig.native.ts b/clients/client-firehose/runtimeConfig.native.ts index 1d0be16a72b83..4d6d907ace038 100644 --- a/clients/client-firehose/runtimeConfig.native.ts +++ b/clients/client-firehose/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FirehoseClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FirehoseClientConfig } from "./FirehoseClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FirehoseClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-firehose/runtimeConfig.shared.ts b/clients/client-firehose/runtimeConfig.shared.ts index 22577e7431a11..cd59da498c545 100644 --- a/clients/client-firehose/runtimeConfig.shared.ts +++ b/clients/client-firehose/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FirehoseClientConfig } from "./FirehoseClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FirehoseClientConfig) => ({ apiVersion: "2015-08-04", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Firehose", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Firehose", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-firehose/runtimeConfig.ts b/clients/client-firehose/runtimeConfig.ts index df70e7e58b780..83ae32523eed1 100644 --- a/clients/client-firehose/runtimeConfig.ts +++ b/clients/client-firehose/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FirehoseClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FirehoseClientConfig } from "./FirehoseClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FirehoseClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fis/FisClient.ts b/clients/client-fis/FisClient.ts index 3ab7879890929..11a0c01899061 100644 --- a/clients/client-fis/FisClient.ts +++ b/clients/client-fis/FisClient.ts @@ -30,7 +30,7 @@ import { UpdateExperimentTemplateCommandInput, UpdateExperimentTemplateCommandOutput, } from "./commands/UpdateExperimentTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -269,10 +269,7 @@ export class FisClient extends __Client< readonly config: FisClientResolvedConfig; constructor(configuration: FisClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-fis/runtimeConfig.browser.ts b/clients/client-fis/runtimeConfig.browser.ts index 6bc295394ff11..e0be5c0c99cf2 100644 --- a/clients/client-fis/runtimeConfig.browser.ts +++ b/clients/client-fis/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FisClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FisClientConfig } from "./FisClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FisClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fis/runtimeConfig.native.ts b/clients/client-fis/runtimeConfig.native.ts index 923e5bea38d7f..4084d14f9da95 100644 --- a/clients/client-fis/runtimeConfig.native.ts +++ b/clients/client-fis/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FisClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FisClientConfig } from "./FisClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FisClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-fis/runtimeConfig.shared.ts b/clients/client-fis/runtimeConfig.shared.ts index 0b5003e9ef1ef..817d2bc8927a7 100644 --- a/clients/client-fis/runtimeConfig.shared.ts +++ b/clients/client-fis/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FisClientConfig } from "./FisClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FisClientConfig) => ({ apiVersion: "2020-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "fis", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "fis", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-fis/runtimeConfig.ts b/clients/client-fis/runtimeConfig.ts index 8af6d0d202487..53ec4324e219d 100644 --- a/clients/client-fis/runtimeConfig.ts +++ b/clients/client-fis/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FisClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FisClientConfig } from "./FisClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FisClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fms/FMSClient.ts b/clients/client-fms/FMSClient.ts index 42dba106bba72..2cc46f96e4b85 100644 --- a/clients/client-fms/FMSClient.ts +++ b/clients/client-fms/FMSClient.ts @@ -57,7 +57,7 @@ import { PutPolicyCommandInput, PutPolicyCommandOutput } from "./commands/PutPol import { PutProtocolsListCommandInput, PutProtocolsListCommandOutput } from "./commands/PutProtocolsListCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -325,10 +325,7 @@ export class FMSClient extends __Client< readonly config: FMSClientResolvedConfig; constructor(configuration: FMSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-fms/runtimeConfig.browser.ts b/clients/client-fms/runtimeConfig.browser.ts index d606bdf6d89bc..ff413fbcf4878 100644 --- a/clients/client-fms/runtimeConfig.browser.ts +++ b/clients/client-fms/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FMSClientConfig } from "./FMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fms/runtimeConfig.native.ts b/clients/client-fms/runtimeConfig.native.ts index 926bb74ffa93a..a7cef71e8566f 100644 --- a/clients/client-fms/runtimeConfig.native.ts +++ b/clients/client-fms/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FMSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FMSClientConfig } from "./FMSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FMSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-fms/runtimeConfig.shared.ts b/clients/client-fms/runtimeConfig.shared.ts index 2f823752aa96c..d53ed016bbb39 100644 --- a/clients/client-fms/runtimeConfig.shared.ts +++ b/clients/client-fms/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FMSClientConfig } from "./FMSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FMSClientConfig) => ({ apiVersion: "2018-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "FMS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "FMS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-fms/runtimeConfig.ts b/clients/client-fms/runtimeConfig.ts index 9d0461b4cad8d..6c83d16376c70 100644 --- a/clients/client-fms/runtimeConfig.ts +++ b/clients/client-fms/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FMSClientConfig } from "./FMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-forecast/ForecastClient.ts b/clients/client-forecast/ForecastClient.ts index 5eee3d595be4e..5a9c34ca44f68 100644 --- a/clients/client-forecast/ForecastClient.ts +++ b/clients/client-forecast/ForecastClient.ts @@ -75,7 +75,7 @@ import { StopResourceCommandInput, StopResourceCommandOutput } from "./commands/ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateDatasetGroupCommandInput, UpdateDatasetGroupCommandOutput } from "./commands/UpdateDatasetGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -355,10 +355,7 @@ export class ForecastClient extends __Client< readonly config: ForecastClientResolvedConfig; constructor(configuration: ForecastClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-forecast/runtimeConfig.browser.ts b/clients/client-forecast/runtimeConfig.browser.ts index d933192b78cf7..e2309e951f3c2 100644 --- a/clients/client-forecast/runtimeConfig.browser.ts +++ b/clients/client-forecast/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ForecastClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ForecastClientConfig } from "./ForecastClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ForecastClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-forecast/runtimeConfig.native.ts b/clients/client-forecast/runtimeConfig.native.ts index 4c815dc5996aa..031a2f863fe12 100644 --- a/clients/client-forecast/runtimeConfig.native.ts +++ b/clients/client-forecast/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ForecastClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ForecastClientConfig } from "./ForecastClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ForecastClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-forecast/runtimeConfig.shared.ts b/clients/client-forecast/runtimeConfig.shared.ts index dca83477eba33..5cb077f9dc820 100644 --- a/clients/client-forecast/runtimeConfig.shared.ts +++ b/clients/client-forecast/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ForecastClientConfig } from "./ForecastClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ForecastClientConfig) => ({ apiVersion: "2018-06-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "forecast", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "forecast", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-forecast/runtimeConfig.ts b/clients/client-forecast/runtimeConfig.ts index b276bc2c0531d..905bd9b9c3866 100644 --- a/clients/client-forecast/runtimeConfig.ts +++ b/clients/client-forecast/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ForecastClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ForecastClientConfig } from "./ForecastClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ForecastClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-forecastquery/ForecastqueryClient.ts b/clients/client-forecastquery/ForecastqueryClient.ts index 25e613b70c896..3eaa056435410 100644 --- a/clients/client-forecastquery/ForecastqueryClient.ts +++ b/clients/client-forecastquery/ForecastqueryClient.ts @@ -1,5 +1,5 @@ import { QueryForecastCommandInput, QueryForecastCommandOutput } from "./commands/QueryForecastCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -209,10 +209,7 @@ export class ForecastqueryClient extends __Client< readonly config: ForecastqueryClientResolvedConfig; constructor(configuration: ForecastqueryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-forecastquery/runtimeConfig.browser.ts b/clients/client-forecastquery/runtimeConfig.browser.ts index 8372ca265d8cc..f0f0c9af3e51d 100644 --- a/clients/client-forecastquery/runtimeConfig.browser.ts +++ b/clients/client-forecastquery/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ForecastqueryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ForecastqueryClientConfig } from "./ForecastqueryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ForecastqueryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-forecastquery/runtimeConfig.native.ts b/clients/client-forecastquery/runtimeConfig.native.ts index d1fea02bbf9be..1ce473220198a 100644 --- a/clients/client-forecastquery/runtimeConfig.native.ts +++ b/clients/client-forecastquery/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ForecastqueryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ForecastqueryClientConfig } from "./ForecastqueryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ForecastqueryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-forecastquery/runtimeConfig.shared.ts b/clients/client-forecastquery/runtimeConfig.shared.ts index aaa9839f3b157..96de7f5a545ed 100644 --- a/clients/client-forecastquery/runtimeConfig.shared.ts +++ b/clients/client-forecastquery/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ForecastqueryClientConfig } from "./ForecastqueryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ForecastqueryClientConfig) => ({ apiVersion: "2018-06-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "forecastquery", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "forecastquery", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-forecastquery/runtimeConfig.ts b/clients/client-forecastquery/runtimeConfig.ts index 59ec63bc52528..fcfc78e50952a 100644 --- a/clients/client-forecastquery/runtimeConfig.ts +++ b/clients/client-forecastquery/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ForecastqueryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ForecastqueryClientConfig } from "./ForecastqueryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ForecastqueryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-frauddetector/FraudDetectorClient.ts b/clients/client-frauddetector/FraudDetectorClient.ts index f7edb93c6cf87..49093ff6d6fff 100644 --- a/clients/client-frauddetector/FraudDetectorClient.ts +++ b/clients/client-frauddetector/FraudDetectorClient.ts @@ -103,7 +103,7 @@ import { import { UpdateRuleMetadataCommandInput, UpdateRuleMetadataCommandOutput } from "./commands/UpdateRuleMetadataCommand"; import { UpdateRuleVersionCommandInput, UpdateRuleVersionCommandOutput } from "./commands/UpdateRuleVersionCommand"; import { UpdateVariableCommandInput, UpdateVariableCommandOutput } from "./commands/UpdateVariableCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -429,10 +429,7 @@ export class FraudDetectorClient extends __Client< readonly config: FraudDetectorClientResolvedConfig; constructor(configuration: FraudDetectorClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-frauddetector/runtimeConfig.browser.ts b/clients/client-frauddetector/runtimeConfig.browser.ts index 5c5bc2f865681..09b5b33ea76e1 100644 --- a/clients/client-frauddetector/runtimeConfig.browser.ts +++ b/clients/client-frauddetector/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FraudDetectorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FraudDetectorClientConfig } from "./FraudDetectorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FraudDetectorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-frauddetector/runtimeConfig.native.ts b/clients/client-frauddetector/runtimeConfig.native.ts index 2a43eb2635b32..a678374e27d70 100644 --- a/clients/client-frauddetector/runtimeConfig.native.ts +++ b/clients/client-frauddetector/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FraudDetectorClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FraudDetectorClientConfig } from "./FraudDetectorClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FraudDetectorClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-frauddetector/runtimeConfig.shared.ts b/clients/client-frauddetector/runtimeConfig.shared.ts index a0fdf469c3063..dbab0f6547e6c 100644 --- a/clients/client-frauddetector/runtimeConfig.shared.ts +++ b/clients/client-frauddetector/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FraudDetectorClientConfig } from "./FraudDetectorClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FraudDetectorClientConfig) => ({ apiVersion: "2019-11-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "FraudDetector", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "FraudDetector", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-frauddetector/runtimeConfig.ts b/clients/client-frauddetector/runtimeConfig.ts index c27454bd648ac..b20ce36cbb253 100644 --- a/clients/client-frauddetector/runtimeConfig.ts +++ b/clients/client-frauddetector/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FraudDetectorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FraudDetectorClientConfig } from "./FraudDetectorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FraudDetectorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fsx/FSxClient.ts b/clients/client-fsx/FSxClient.ts index 136ec28735388..41b93833e9735 100644 --- a/clients/client-fsx/FSxClient.ts +++ b/clients/client-fsx/FSxClient.ts @@ -43,7 +43,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateFileSystemCommandInput, UpdateFileSystemCommandOutput } from "./commands/UpdateFileSystemCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -290,10 +290,7 @@ export class FSxClient extends __Client< readonly config: FSxClientResolvedConfig; constructor(configuration: FSxClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-fsx/runtimeConfig.browser.ts b/clients/client-fsx/runtimeConfig.browser.ts index dc57404fbe4bd..45988a7945566 100644 --- a/clients/client-fsx/runtimeConfig.browser.ts +++ b/clients/client-fsx/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./FSxClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FSxClientConfig } from "./FSxClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FSxClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-fsx/runtimeConfig.native.ts b/clients/client-fsx/runtimeConfig.native.ts index 341958b6651fb..243207f4fa826 100644 --- a/clients/client-fsx/runtimeConfig.native.ts +++ b/clients/client-fsx/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./FSxClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { FSxClientConfig } from "./FSxClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: FSxClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-fsx/runtimeConfig.shared.ts b/clients/client-fsx/runtimeConfig.shared.ts index b6a86561d7d36..bd08ffa6d94c8 100644 --- a/clients/client-fsx/runtimeConfig.shared.ts +++ b/clients/client-fsx/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { FSxClientConfig } from "./FSxClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: FSxClientConfig) => ({ apiVersion: "2018-03-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "FSx", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "FSx", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-fsx/runtimeConfig.ts b/clients/client-fsx/runtimeConfig.ts index 29c78c29a184c..8c1e7ffc8b46c 100644 --- a/clients/client-fsx/runtimeConfig.ts +++ b/clients/client-fsx/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./FSxClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { FSxClientConfig } from "./FSxClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: FSxClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-gamelift/GameLiftClient.ts b/clients/client-gamelift/GameLiftClient.ts index 724be605dfee8..96624b876118e 100644 --- a/clients/client-gamelift/GameLiftClient.ts +++ b/clients/client-gamelift/GameLiftClient.ts @@ -264,7 +264,7 @@ import { ValidateMatchmakingRuleSetCommandInput, ValidateMatchmakingRuleSetCommandOutput, } from "./commands/ValidateMatchmakingRuleSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -721,10 +721,7 @@ export class GameLiftClient extends __Client< readonly config: GameLiftClientResolvedConfig; constructor(configuration: GameLiftClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-gamelift/runtimeConfig.browser.ts b/clients/client-gamelift/runtimeConfig.browser.ts index 81972543cda5e..b9daa48fcebbc 100644 --- a/clients/client-gamelift/runtimeConfig.browser.ts +++ b/clients/client-gamelift/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GameLiftClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GameLiftClientConfig } from "./GameLiftClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GameLiftClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-gamelift/runtimeConfig.native.ts b/clients/client-gamelift/runtimeConfig.native.ts index 07213d5cb4bb0..6a584470804a9 100644 --- a/clients/client-gamelift/runtimeConfig.native.ts +++ b/clients/client-gamelift/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GameLiftClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GameLiftClientConfig } from "./GameLiftClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GameLiftClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-gamelift/runtimeConfig.shared.ts b/clients/client-gamelift/runtimeConfig.shared.ts index c4561104679f8..4ba8a3f3db1fd 100644 --- a/clients/client-gamelift/runtimeConfig.shared.ts +++ b/clients/client-gamelift/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GameLiftClientConfig } from "./GameLiftClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GameLiftClientConfig) => ({ apiVersion: "2015-10-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "GameLift", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "GameLift", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-gamelift/runtimeConfig.ts b/clients/client-gamelift/runtimeConfig.ts index 1775eb451c28a..aad3383ccf46e 100644 --- a/clients/client-gamelift/runtimeConfig.ts +++ b/clients/client-gamelift/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GameLiftClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GameLiftClientConfig } from "./GameLiftClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GameLiftClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-glacier/GlacierClient.ts b/clients/client-glacier/GlacierClient.ts index 6d431c106b251..4baded5fbcd31 100644 --- a/clients/client-glacier/GlacierClient.ts +++ b/clients/client-glacier/GlacierClient.ts @@ -79,7 +79,7 @@ import { UploadMultipartPartCommandInput, UploadMultipartPartCommandOutput, } from "./commands/UploadMultipartPartCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -403,10 +403,7 @@ export class GlacierClient extends __Client< readonly config: GlacierClientResolvedConfig; constructor(configuration: GlacierClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-glacier/runtimeConfig.browser.ts b/clients/client-glacier/runtimeConfig.browser.ts index 963db690fca30..18d0141b87bec 100644 --- a/clients/client-glacier/runtimeConfig.browser.ts +++ b/clients/client-glacier/runtimeConfig.browser.ts @@ -9,30 +9,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GlacierClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlacierClientConfig } from "./GlacierClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyChecksumGenerator, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlacierClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyChecksumGenerator: config.bodyChecksumGenerator ?? bodyChecksumGenerator, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-glacier/runtimeConfig.native.ts b/clients/client-glacier/runtimeConfig.native.ts index eb177b65d6059..6b52dcc4ae665 100644 --- a/clients/client-glacier/runtimeConfig.native.ts +++ b/clients/client-glacier/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GlacierClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GlacierClientConfig } from "./GlacierClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GlacierClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-glacier/runtimeConfig.shared.ts b/clients/client-glacier/runtimeConfig.shared.ts index f1d783406304f..b8867e891b053 100644 --- a/clients/client-glacier/runtimeConfig.shared.ts +++ b/clients/client-glacier/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GlacierClientConfig } from "./GlacierClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GlacierClientConfig) => ({ apiVersion: "2012-06-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Glacier", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Glacier", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-glacier/runtimeConfig.ts b/clients/client-glacier/runtimeConfig.ts index 4f9bb4968a404..f428a6b506892 100644 --- a/clients/client-glacier/runtimeConfig.ts +++ b/clients/client-glacier/runtimeConfig.ts @@ -12,30 +12,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GlacierClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlacierClientConfig } from "./GlacierClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyChecksumGenerator, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlacierClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyChecksumGenerator: config.bodyChecksumGenerator ?? bodyChecksumGenerator, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-global-accelerator/GlobalAcceleratorClient.ts b/clients/client-global-accelerator/GlobalAcceleratorClient.ts index b367e3b877dfa..ae82ba25206a1 100644 --- a/clients/client-global-accelerator/GlobalAcceleratorClient.ts +++ b/clients/client-global-accelerator/GlobalAcceleratorClient.ts @@ -138,7 +138,7 @@ import { } from "./commands/UpdateEndpointGroupCommand"; import { UpdateListenerCommandInput, UpdateListenerCommandOutput } from "./commands/UpdateListenerCommand"; import { WithdrawByoipCidrCommandInput, WithdrawByoipCidrCommandOutput } from "./commands/WithdrawByoipCidrCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -589,10 +589,7 @@ export class GlobalAcceleratorClient extends __Client< readonly config: GlobalAcceleratorClientResolvedConfig; constructor(configuration: GlobalAcceleratorClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-global-accelerator/runtimeConfig.browser.ts b/clients/client-global-accelerator/runtimeConfig.browser.ts index 6d4ea4bc61920..a070c1d15fb64 100644 --- a/clients/client-global-accelerator/runtimeConfig.browser.ts +++ b/clients/client-global-accelerator/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GlobalAcceleratorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlobalAcceleratorClientConfig } from "./GlobalAcceleratorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlobalAcceleratorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-global-accelerator/runtimeConfig.native.ts b/clients/client-global-accelerator/runtimeConfig.native.ts index 64c950ccaca99..97bd4c0a5dbd1 100644 --- a/clients/client-global-accelerator/runtimeConfig.native.ts +++ b/clients/client-global-accelerator/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GlobalAcceleratorClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GlobalAcceleratorClientConfig } from "./GlobalAcceleratorClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GlobalAcceleratorClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-global-accelerator/runtimeConfig.shared.ts b/clients/client-global-accelerator/runtimeConfig.shared.ts index cfd534b4bedb0..59ddead7208af 100644 --- a/clients/client-global-accelerator/runtimeConfig.shared.ts +++ b/clients/client-global-accelerator/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GlobalAcceleratorClientConfig } from "./GlobalAcceleratorClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GlobalAcceleratorClientConfig) => ({ apiVersion: "2018-08-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Global Accelerator", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Global Accelerator", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-global-accelerator/runtimeConfig.ts b/clients/client-global-accelerator/runtimeConfig.ts index c6cd378b98e68..992a3f19b7e2d 100644 --- a/clients/client-global-accelerator/runtimeConfig.ts +++ b/clients/client-global-accelerator/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GlobalAcceleratorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlobalAcceleratorClientConfig } from "./GlobalAcceleratorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlobalAcceleratorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-glue/GlueClient.ts b/clients/client-glue/GlueClient.ts index a97302d892c06..d3561fa0b109d 100644 --- a/clients/client-glue/GlueClient.ts +++ b/clients/client-glue/GlueClient.ts @@ -296,7 +296,7 @@ import { UpdateUserDefinedFunctionCommandOutput, } from "./commands/UpdateUserDefinedFunctionCommand"; import { UpdateWorkflowCommandInput, UpdateWorkflowCommandOutput } from "./commands/UpdateWorkflowCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -821,10 +821,7 @@ export class GlueClient extends __Client< readonly config: GlueClientResolvedConfig; constructor(configuration: GlueClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-glue/runtimeConfig.browser.ts b/clients/client-glue/runtimeConfig.browser.ts index 6e4c0b61f65fd..7543e45c05360 100644 --- a/clients/client-glue/runtimeConfig.browser.ts +++ b/clients/client-glue/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GlueClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlueClientConfig } from "./GlueClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlueClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-glue/runtimeConfig.native.ts b/clients/client-glue/runtimeConfig.native.ts index 5d79dc298f35d..5f00c06f749fb 100644 --- a/clients/client-glue/runtimeConfig.native.ts +++ b/clients/client-glue/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GlueClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GlueClientConfig } from "./GlueClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GlueClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-glue/runtimeConfig.shared.ts b/clients/client-glue/runtimeConfig.shared.ts index 791a1f632bd5d..214a06eb76f9e 100644 --- a/clients/client-glue/runtimeConfig.shared.ts +++ b/clients/client-glue/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GlueClientConfig } from "./GlueClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GlueClientConfig) => ({ apiVersion: "2017-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Glue", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Glue", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-glue/runtimeConfig.ts b/clients/client-glue/runtimeConfig.ts index f6bc1ad2b30ab..96ba1076bf0f9 100644 --- a/clients/client-glue/runtimeConfig.ts +++ b/clients/client-glue/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GlueClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GlueClientConfig } from "./GlueClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GlueClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-greengrass/GreengrassClient.ts b/clients/client-greengrass/GreengrassClient.ts index df0eaffede66e..558b786bd09d8 100644 --- a/clients/client-greengrass/GreengrassClient.ts +++ b/clients/client-greengrass/GreengrassClient.ts @@ -318,7 +318,7 @@ import { UpdateThingRuntimeConfigurationCommandInput, UpdateThingRuntimeConfigurationCommandOutput, } from "./commands/UpdateThingRuntimeConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -712,10 +712,7 @@ export class GreengrassClient extends __Client< readonly config: GreengrassClientResolvedConfig; constructor(configuration: GreengrassClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-greengrass/runtimeConfig.browser.ts b/clients/client-greengrass/runtimeConfig.browser.ts index efb6565d8cb20..5b00069633add 100644 --- a/clients/client-greengrass/runtimeConfig.browser.ts +++ b/clients/client-greengrass/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GreengrassClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GreengrassClientConfig } from "./GreengrassClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GreengrassClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-greengrass/runtimeConfig.native.ts b/clients/client-greengrass/runtimeConfig.native.ts index 4c31c3cee9664..5bf1543181bf7 100644 --- a/clients/client-greengrass/runtimeConfig.native.ts +++ b/clients/client-greengrass/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GreengrassClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GreengrassClientConfig } from "./GreengrassClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GreengrassClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-greengrass/runtimeConfig.shared.ts b/clients/client-greengrass/runtimeConfig.shared.ts index 764e7bb793ecc..b0b29241c21fa 100644 --- a/clients/client-greengrass/runtimeConfig.shared.ts +++ b/clients/client-greengrass/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GreengrassClientConfig } from "./GreengrassClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GreengrassClientConfig) => ({ apiVersion: "2017-06-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Greengrass", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Greengrass", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-greengrass/runtimeConfig.ts b/clients/client-greengrass/runtimeConfig.ts index 82a84419ac23e..2fd69badb638e 100644 --- a/clients/client-greengrass/runtimeConfig.ts +++ b/clients/client-greengrass/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GreengrassClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GreengrassClientConfig } from "./GreengrassClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GreengrassClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-greengrassv2/GreengrassV2Client.ts b/clients/client-greengrassv2/GreengrassV2Client.ts index 5de6453f67d96..0059cf5b94aa0 100644 --- a/clients/client-greengrassv2/GreengrassV2Client.ts +++ b/clients/client-greengrassv2/GreengrassV2Client.ts @@ -51,7 +51,7 @@ import { } from "./commands/ResolveComponentCandidatesCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -317,10 +317,7 @@ export class GreengrassV2Client extends __Client< readonly config: GreengrassV2ClientResolvedConfig; constructor(configuration: GreengrassV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-greengrassv2/runtimeConfig.browser.ts b/clients/client-greengrassv2/runtimeConfig.browser.ts index 21e9c6a5755ad..9e74a92a67daf 100644 --- a/clients/client-greengrassv2/runtimeConfig.browser.ts +++ b/clients/client-greengrassv2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GreengrassV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GreengrassV2ClientConfig } from "./GreengrassV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GreengrassV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-greengrassv2/runtimeConfig.native.ts b/clients/client-greengrassv2/runtimeConfig.native.ts index 7e221ab06f863..f3c652fc01d88 100644 --- a/clients/client-greengrassv2/runtimeConfig.native.ts +++ b/clients/client-greengrassv2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GreengrassV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GreengrassV2ClientConfig } from "./GreengrassV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GreengrassV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-greengrassv2/runtimeConfig.shared.ts b/clients/client-greengrassv2/runtimeConfig.shared.ts index 585b44084fd16..0a68ff83b4ecd 100644 --- a/clients/client-greengrassv2/runtimeConfig.shared.ts +++ b/clients/client-greengrassv2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GreengrassV2ClientConfig } from "./GreengrassV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GreengrassV2ClientConfig) => ({ apiVersion: "2020-11-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "GreengrassV2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "GreengrassV2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-greengrassv2/runtimeConfig.ts b/clients/client-greengrassv2/runtimeConfig.ts index 6913c22e736ad..901a768ba898f 100644 --- a/clients/client-greengrassv2/runtimeConfig.ts +++ b/clients/client-greengrassv2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GreengrassV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GreengrassV2ClientConfig } from "./GreengrassV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GreengrassV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-groundstation/GroundStationClient.ts b/clients/client-groundstation/GroundStationClient.ts index 92eac2dce4688..d4c541c1b686a 100644 --- a/clients/client-groundstation/GroundStationClient.ts +++ b/clients/client-groundstation/GroundStationClient.ts @@ -50,7 +50,7 @@ import { UpdateMissionProfileCommandInput, UpdateMissionProfileCommandOutput, } from "./commands/UpdateMissionProfileCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -313,10 +313,7 @@ export class GroundStationClient extends __Client< readonly config: GroundStationClientResolvedConfig; constructor(configuration: GroundStationClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-groundstation/runtimeConfig.browser.ts b/clients/client-groundstation/runtimeConfig.browser.ts index 4205218dd2abc..fe7b375ac437e 100644 --- a/clients/client-groundstation/runtimeConfig.browser.ts +++ b/clients/client-groundstation/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GroundStationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GroundStationClientConfig } from "./GroundStationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GroundStationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-groundstation/runtimeConfig.native.ts b/clients/client-groundstation/runtimeConfig.native.ts index e43db9859a12f..448b205013193 100644 --- a/clients/client-groundstation/runtimeConfig.native.ts +++ b/clients/client-groundstation/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GroundStationClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GroundStationClientConfig } from "./GroundStationClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GroundStationClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-groundstation/runtimeConfig.shared.ts b/clients/client-groundstation/runtimeConfig.shared.ts index b87b24d801e0f..e84d268a68bfb 100644 --- a/clients/client-groundstation/runtimeConfig.shared.ts +++ b/clients/client-groundstation/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GroundStationClientConfig } from "./GroundStationClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GroundStationClientConfig) => ({ apiVersion: "2019-05-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "GroundStation", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "GroundStation", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-groundstation/runtimeConfig.ts b/clients/client-groundstation/runtimeConfig.ts index 44047cb528c36..934e402ecb81d 100644 --- a/clients/client-groundstation/runtimeConfig.ts +++ b/clients/client-groundstation/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GroundStationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GroundStationClientConfig } from "./GroundStationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GroundStationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-guardduty/GuardDutyClient.ts b/clients/client-guardduty/GuardDutyClient.ts index 043bd9b4501e8..0fcb29841b6e0 100644 --- a/clients/client-guardduty/GuardDutyClient.ts +++ b/clients/client-guardduty/GuardDutyClient.ts @@ -128,7 +128,7 @@ import { UpdateThreatIntelSetCommandInput, UpdateThreatIntelSetCommandOutput, } from "./commands/UpdateThreatIntelSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -470,10 +470,7 @@ export class GuardDutyClient extends __Client< readonly config: GuardDutyClientResolvedConfig; constructor(configuration: GuardDutyClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-guardduty/runtimeConfig.browser.ts b/clients/client-guardduty/runtimeConfig.browser.ts index 23f23f17e18ea..3b7c977eb989e 100644 --- a/clients/client-guardduty/runtimeConfig.browser.ts +++ b/clients/client-guardduty/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./GuardDutyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GuardDutyClientConfig } from "./GuardDutyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GuardDutyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-guardduty/runtimeConfig.native.ts b/clients/client-guardduty/runtimeConfig.native.ts index 9f640854ad288..bbe34fc601055 100644 --- a/clients/client-guardduty/runtimeConfig.native.ts +++ b/clients/client-guardduty/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./GuardDutyClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { GuardDutyClientConfig } from "./GuardDutyClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: GuardDutyClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-guardduty/runtimeConfig.shared.ts b/clients/client-guardduty/runtimeConfig.shared.ts index 3115234dc1186..f0b1b406dfa4e 100644 --- a/clients/client-guardduty/runtimeConfig.shared.ts +++ b/clients/client-guardduty/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { GuardDutyClientConfig } from "./GuardDutyClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: GuardDutyClientConfig) => ({ apiVersion: "2017-11-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "GuardDuty", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "GuardDuty", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-guardduty/runtimeConfig.ts b/clients/client-guardduty/runtimeConfig.ts index f344a6cec9770..f674441819e37 100644 --- a/clients/client-guardduty/runtimeConfig.ts +++ b/clients/client-guardduty/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./GuardDutyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { GuardDutyClientConfig } from "./GuardDutyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: GuardDutyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-health/HealthClient.ts b/clients/client-health/HealthClient.ts index 1aef708837270..dc189d25c4412 100644 --- a/clients/client-health/HealthClient.ts +++ b/clients/client-health/HealthClient.ts @@ -44,7 +44,7 @@ import { EnableHealthServiceAccessForOrganizationCommandInput, EnableHealthServiceAccessForOrganizationCommandOutput, } from "./commands/EnableHealthServiceAccessForOrganizationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -329,10 +329,7 @@ export class HealthClient extends __Client< readonly config: HealthClientResolvedConfig; constructor(configuration: HealthClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-health/runtimeConfig.browser.ts b/clients/client-health/runtimeConfig.browser.ts index 25bbcc0246fd4..cf92f97be361e 100644 --- a/clients/client-health/runtimeConfig.browser.ts +++ b/clients/client-health/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./HealthClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HealthClientConfig } from "./HealthClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HealthClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-health/runtimeConfig.native.ts b/clients/client-health/runtimeConfig.native.ts index f885913dc6605..ba4414cfbbb7b 100644 --- a/clients/client-health/runtimeConfig.native.ts +++ b/clients/client-health/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./HealthClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { HealthClientConfig } from "./HealthClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: HealthClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-health/runtimeConfig.shared.ts b/clients/client-health/runtimeConfig.shared.ts index 9d0902421b6f2..749b19072aeb5 100644 --- a/clients/client-health/runtimeConfig.shared.ts +++ b/clients/client-health/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { HealthClientConfig } from "./HealthClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: HealthClientConfig) => ({ apiVersion: "2016-08-04", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Health", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Health", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-health/runtimeConfig.ts b/clients/client-health/runtimeConfig.ts index f6f1cd6751ac9..a4a9a5e422fba 100644 --- a/clients/client-health/runtimeConfig.ts +++ b/clients/client-health/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./HealthClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HealthClientConfig } from "./HealthClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HealthClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-healthlake/HealthLakeClient.ts b/clients/client-healthlake/HealthLakeClient.ts index 2478ef92e01b6..61354d4046fd1 100644 --- a/clients/client-healthlake/HealthLakeClient.ts +++ b/clients/client-healthlake/HealthLakeClient.ts @@ -29,7 +29,7 @@ import { StartFHIRExportJobCommandInput, StartFHIRExportJobCommandOutput } from import { StartFHIRImportJobCommandInput, StartFHIRImportJobCommandOutput } from "./commands/StartFHIRImportJobCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -266,10 +266,7 @@ export class HealthLakeClient extends __Client< readonly config: HealthLakeClientResolvedConfig; constructor(configuration: HealthLakeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-healthlake/runtimeConfig.browser.ts b/clients/client-healthlake/runtimeConfig.browser.ts index f8786589c9005..3b83fece8a938 100644 --- a/clients/client-healthlake/runtimeConfig.browser.ts +++ b/clients/client-healthlake/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./HealthLakeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HealthLakeClientConfig } from "./HealthLakeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HealthLakeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-healthlake/runtimeConfig.native.ts b/clients/client-healthlake/runtimeConfig.native.ts index 238e4fe0670e3..02a80ebe2a904 100644 --- a/clients/client-healthlake/runtimeConfig.native.ts +++ b/clients/client-healthlake/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./HealthLakeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { HealthLakeClientConfig } from "./HealthLakeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: HealthLakeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-healthlake/runtimeConfig.shared.ts b/clients/client-healthlake/runtimeConfig.shared.ts index ebeb423d7821b..87d86b911834d 100644 --- a/clients/client-healthlake/runtimeConfig.shared.ts +++ b/clients/client-healthlake/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { HealthLakeClientConfig } from "./HealthLakeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: HealthLakeClientConfig) => ({ apiVersion: "2017-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "HealthLake", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "HealthLake", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-healthlake/runtimeConfig.ts b/clients/client-healthlake/runtimeConfig.ts index 0743c96888fb5..0342a655eed3c 100644 --- a/clients/client-healthlake/runtimeConfig.ts +++ b/clients/client-healthlake/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./HealthLakeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HealthLakeClientConfig } from "./HealthLakeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HealthLakeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-honeycode/HoneycodeClient.ts b/clients/client-honeycode/HoneycodeClient.ts index 5d7b2fb9445ff..b0be37e26700e 100644 --- a/clients/client-honeycode/HoneycodeClient.ts +++ b/clients/client-honeycode/HoneycodeClient.ts @@ -31,7 +31,7 @@ import { StartTableDataImportJobCommandInput, StartTableDataImportJobCommandOutput, } from "./commands/StartTableDataImportJobCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -269,10 +269,7 @@ export class HoneycodeClient extends __Client< readonly config: HoneycodeClientResolvedConfig; constructor(configuration: HoneycodeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-honeycode/runtimeConfig.browser.ts b/clients/client-honeycode/runtimeConfig.browser.ts index 4320f9c6c6eb4..cc8ef6a609bba 100644 --- a/clients/client-honeycode/runtimeConfig.browser.ts +++ b/clients/client-honeycode/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./HoneycodeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HoneycodeClientConfig } from "./HoneycodeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HoneycodeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-honeycode/runtimeConfig.native.ts b/clients/client-honeycode/runtimeConfig.native.ts index db98524fb4775..c3a556dc6b6e6 100644 --- a/clients/client-honeycode/runtimeConfig.native.ts +++ b/clients/client-honeycode/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./HoneycodeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { HoneycodeClientConfig } from "./HoneycodeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: HoneycodeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-honeycode/runtimeConfig.shared.ts b/clients/client-honeycode/runtimeConfig.shared.ts index bcf52ce37bcc8..748b828c065e7 100644 --- a/clients/client-honeycode/runtimeConfig.shared.ts +++ b/clients/client-honeycode/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { HoneycodeClientConfig } from "./HoneycodeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: HoneycodeClientConfig) => ({ apiVersion: "2020-03-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Honeycode", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Honeycode", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-honeycode/runtimeConfig.ts b/clients/client-honeycode/runtimeConfig.ts index 5f59e70ee7456..f9f3149f2168f 100644 --- a/clients/client-honeycode/runtimeConfig.ts +++ b/clients/client-honeycode/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./HoneycodeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { HoneycodeClientConfig } from "./HoneycodeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: HoneycodeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iam/IAMClient.ts b/clients/client-iam/IAMClient.ts index 7a6159525eaea..50fe6be421340 100644 --- a/clients/client-iam/IAMClient.ts +++ b/clients/client-iam/IAMClient.ts @@ -381,7 +381,7 @@ import { UploadSigningCertificateCommandInput, UploadSigningCertificateCommandOutput, } from "./commands/UploadSigningCertificateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -911,10 +911,7 @@ export class IAMClient extends __Client< readonly config: IAMClientResolvedConfig; constructor(configuration: IAMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iam/runtimeConfig.browser.ts b/clients/client-iam/runtimeConfig.browser.ts index be4b817580024..cbab4359cdada 100644 --- a/clients/client-iam/runtimeConfig.browser.ts +++ b/clients/client-iam/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IAMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IAMClientConfig } from "./IAMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IAMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iam/runtimeConfig.native.ts b/clients/client-iam/runtimeConfig.native.ts index fa0bb70a2745c..d221e60fab82a 100644 --- a/clients/client-iam/runtimeConfig.native.ts +++ b/clients/client-iam/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IAMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IAMClientConfig } from "./IAMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IAMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iam/runtimeConfig.shared.ts b/clients/client-iam/runtimeConfig.shared.ts index 71f47458a42fb..f2c648466388f 100644 --- a/clients/client-iam/runtimeConfig.shared.ts +++ b/clients/client-iam/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IAMClientConfig } from "./IAMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IAMClientConfig) => ({ apiVersion: "2010-05-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IAM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IAM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iam/runtimeConfig.ts b/clients/client-iam/runtimeConfig.ts index 2ee42bb83d563..4b362166f98b5 100644 --- a/clients/client-iam/runtimeConfig.ts +++ b/clients/client-iam/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IAMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IAMClientConfig } from "./IAMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IAMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-identitystore/IdentitystoreClient.ts b/clients/client-identitystore/IdentitystoreClient.ts index 12eb433f45cc4..1e591a8f02831 100644 --- a/clients/client-identitystore/IdentitystoreClient.ts +++ b/clients/client-identitystore/IdentitystoreClient.ts @@ -2,7 +2,7 @@ import { DescribeGroupCommandInput, DescribeGroupCommandOutput } from "./command import { DescribeUserCommandInput, DescribeUserCommandOutput } from "./commands/DescribeUserCommand"; import { ListGroupsCommandInput, ListGroupsCommandOutput } from "./commands/ListGroupsCommand"; import { ListUsersCommandInput, ListUsersCommandOutput } from "./commands/ListUsersCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -217,10 +217,7 @@ export class IdentitystoreClient extends __Client< readonly config: IdentitystoreClientResolvedConfig; constructor(configuration: IdentitystoreClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-identitystore/runtimeConfig.browser.ts b/clients/client-identitystore/runtimeConfig.browser.ts index 1f96d396757b1..6f1e5a1ee0ef6 100644 --- a/clients/client-identitystore/runtimeConfig.browser.ts +++ b/clients/client-identitystore/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IdentitystoreClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IdentitystoreClientConfig } from "./IdentitystoreClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IdentitystoreClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-identitystore/runtimeConfig.native.ts b/clients/client-identitystore/runtimeConfig.native.ts index 75f42610b1869..268e07d288788 100644 --- a/clients/client-identitystore/runtimeConfig.native.ts +++ b/clients/client-identitystore/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IdentitystoreClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IdentitystoreClientConfig } from "./IdentitystoreClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IdentitystoreClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-identitystore/runtimeConfig.shared.ts b/clients/client-identitystore/runtimeConfig.shared.ts index 677413ef79e78..924de6c0e1f2b 100644 --- a/clients/client-identitystore/runtimeConfig.shared.ts +++ b/clients/client-identitystore/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IdentitystoreClientConfig } from "./IdentitystoreClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IdentitystoreClientConfig) => ({ apiVersion: "2020-06-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "identitystore", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "identitystore", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-identitystore/runtimeConfig.ts b/clients/client-identitystore/runtimeConfig.ts index 7ece04e0ccf8d..aa5f8a3930391 100644 --- a/clients/client-identitystore/runtimeConfig.ts +++ b/clients/client-identitystore/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IdentitystoreClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IdentitystoreClientConfig } from "./IdentitystoreClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IdentitystoreClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-imagebuilder/ImagebuilderClient.ts b/clients/client-imagebuilder/ImagebuilderClient.ts index ad83e0fc1bd3e..c7656b002d47a 100644 --- a/clients/client-imagebuilder/ImagebuilderClient.ts +++ b/clients/client-imagebuilder/ImagebuilderClient.ts @@ -125,7 +125,7 @@ import { UpdateInfrastructureConfigurationCommandInput, UpdateInfrastructureConfigurationCommandOutput, } from "./commands/UpdateInfrastructureConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -436,10 +436,7 @@ export class ImagebuilderClient extends __Client< readonly config: ImagebuilderClientResolvedConfig; constructor(configuration: ImagebuilderClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-imagebuilder/runtimeConfig.browser.ts b/clients/client-imagebuilder/runtimeConfig.browser.ts index b1993ccf04fd5..da4a2ed128c61 100644 --- a/clients/client-imagebuilder/runtimeConfig.browser.ts +++ b/clients/client-imagebuilder/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ImagebuilderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ImagebuilderClientConfig } from "./ImagebuilderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ImagebuilderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-imagebuilder/runtimeConfig.native.ts b/clients/client-imagebuilder/runtimeConfig.native.ts index 4e7c9c8346bb4..fb92dff232cd9 100644 --- a/clients/client-imagebuilder/runtimeConfig.native.ts +++ b/clients/client-imagebuilder/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ImagebuilderClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ImagebuilderClientConfig } from "./ImagebuilderClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ImagebuilderClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-imagebuilder/runtimeConfig.shared.ts b/clients/client-imagebuilder/runtimeConfig.shared.ts index bdaedaa5555b8..7618708bd8c83 100644 --- a/clients/client-imagebuilder/runtimeConfig.shared.ts +++ b/clients/client-imagebuilder/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ImagebuilderClientConfig } from "./ImagebuilderClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ImagebuilderClientConfig) => ({ apiVersion: "2019-12-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "imagebuilder", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "imagebuilder", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-imagebuilder/runtimeConfig.ts b/clients/client-imagebuilder/runtimeConfig.ts index cdda4d2d24f44..75676fc8add68 100644 --- a/clients/client-imagebuilder/runtimeConfig.ts +++ b/clients/client-imagebuilder/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ImagebuilderClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ImagebuilderClientConfig } from "./ImagebuilderClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ImagebuilderClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-inspector/InspectorClient.ts b/clients/client-inspector/InspectorClient.ts index 64c02a15f823a..05f20decf983b 100644 --- a/clients/client-inspector/InspectorClient.ts +++ b/clients/client-inspector/InspectorClient.ts @@ -113,7 +113,7 @@ import { UpdateAssessmentTargetCommandInput, UpdateAssessmentTargetCommandOutput, } from "./commands/UpdateAssessmentTargetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -400,10 +400,7 @@ export class InspectorClient extends __Client< readonly config: InspectorClientResolvedConfig; constructor(configuration: InspectorClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-inspector/runtimeConfig.browser.ts b/clients/client-inspector/runtimeConfig.browser.ts index 06f0c4adc832f..84c01966e7024 100644 --- a/clients/client-inspector/runtimeConfig.browser.ts +++ b/clients/client-inspector/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./InspectorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { InspectorClientConfig } from "./InspectorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: InspectorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-inspector/runtimeConfig.native.ts b/clients/client-inspector/runtimeConfig.native.ts index 0f574c84b8276..9916d3f679137 100644 --- a/clients/client-inspector/runtimeConfig.native.ts +++ b/clients/client-inspector/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./InspectorClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { InspectorClientConfig } from "./InspectorClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: InspectorClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-inspector/runtimeConfig.shared.ts b/clients/client-inspector/runtimeConfig.shared.ts index c190603cd03c3..9f2d1d67ccf37 100644 --- a/clients/client-inspector/runtimeConfig.shared.ts +++ b/clients/client-inspector/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { InspectorClientConfig } from "./InspectorClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: InspectorClientConfig) => ({ apiVersion: "2016-02-16", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Inspector", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Inspector", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-inspector/runtimeConfig.ts b/clients/client-inspector/runtimeConfig.ts index 813137db23fdf..500fabf454724 100644 --- a/clients/client-inspector/runtimeConfig.ts +++ b/clients/client-inspector/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./InspectorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { InspectorClientConfig } from "./InspectorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: InspectorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-1click-devices-service/IoT1ClickDevicesServiceClient.ts b/clients/client-iot-1click-devices-service/IoT1ClickDevicesServiceClient.ts index 6a6f45ed8583c..a14af085b58f7 100644 --- a/clients/client-iot-1click-devices-service/IoT1ClickDevicesServiceClient.ts +++ b/clients/client-iot-1click-devices-service/IoT1ClickDevicesServiceClient.ts @@ -23,7 +23,7 @@ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/Ta import { UnclaimDeviceCommandInput, UnclaimDeviceCommandOutput } from "./commands/UnclaimDeviceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateDeviceStateCommandInput, UpdateDeviceStateCommandOutput } from "./commands/UpdateDeviceStateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -261,10 +261,7 @@ export class IoT1ClickDevicesServiceClient extends __Client< readonly config: IoT1ClickDevicesServiceClientResolvedConfig; constructor(configuration: IoT1ClickDevicesServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-1click-devices-service/runtimeConfig.browser.ts b/clients/client-iot-1click-devices-service/runtimeConfig.browser.ts index 8ef4c72cdbc9c..aac868b53e378 100644 --- a/clients/client-iot-1click-devices-service/runtimeConfig.browser.ts +++ b/clients/client-iot-1click-devices-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoT1ClickDevicesServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoT1ClickDevicesServiceClientConfig } from "./IoT1ClickDevicesServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoT1ClickDevicesServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-1click-devices-service/runtimeConfig.native.ts b/clients/client-iot-1click-devices-service/runtimeConfig.native.ts index 8e970f5380016..92a20c7792eb5 100644 --- a/clients/client-iot-1click-devices-service/runtimeConfig.native.ts +++ b/clients/client-iot-1click-devices-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoT1ClickDevicesServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoT1ClickDevicesServiceClientConfig } from "./IoT1ClickDevicesServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoT1ClickDevicesServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-1click-devices-service/runtimeConfig.shared.ts b/clients/client-iot-1click-devices-service/runtimeConfig.shared.ts index 0aec62bf3300f..a4db5db5b163e 100644 --- a/clients/client-iot-1click-devices-service/runtimeConfig.shared.ts +++ b/clients/client-iot-1click-devices-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoT1ClickDevicesServiceClientConfig } from "./IoT1ClickDevicesServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoT1ClickDevicesServiceClientConfig) => ({ apiVersion: "2018-05-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT 1Click Devices Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT 1Click Devices Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-1click-devices-service/runtimeConfig.ts b/clients/client-iot-1click-devices-service/runtimeConfig.ts index b6bc8d7fff1a9..929a62b7d983c 100644 --- a/clients/client-iot-1click-devices-service/runtimeConfig.ts +++ b/clients/client-iot-1click-devices-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoT1ClickDevicesServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoT1ClickDevicesServiceClientConfig } from "./IoT1ClickDevicesServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoT1ClickDevicesServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-1click-projects/IoT1ClickProjectsClient.ts b/clients/client-iot-1click-projects/IoT1ClickProjectsClient.ts index 9d9546c510dec..2185a2858775b 100644 --- a/clients/client-iot-1click-projects/IoT1ClickProjectsClient.ts +++ b/clients/client-iot-1click-projects/IoT1ClickProjectsClient.ts @@ -26,7 +26,7 @@ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/Ta import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdatePlacementCommandInput, UpdatePlacementCommandOutput } from "./commands/UpdatePlacementCommand"; import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./commands/UpdateProjectCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -268,10 +268,7 @@ export class IoT1ClickProjectsClient extends __Client< readonly config: IoT1ClickProjectsClientResolvedConfig; constructor(configuration: IoT1ClickProjectsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-1click-projects/runtimeConfig.browser.ts b/clients/client-iot-1click-projects/runtimeConfig.browser.ts index fce292ccfb85d..85954523d6808 100644 --- a/clients/client-iot-1click-projects/runtimeConfig.browser.ts +++ b/clients/client-iot-1click-projects/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoT1ClickProjectsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoT1ClickProjectsClientConfig } from "./IoT1ClickProjectsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoT1ClickProjectsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-1click-projects/runtimeConfig.native.ts b/clients/client-iot-1click-projects/runtimeConfig.native.ts index 07ce1da32ca37..4635b922d3be6 100644 --- a/clients/client-iot-1click-projects/runtimeConfig.native.ts +++ b/clients/client-iot-1click-projects/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoT1ClickProjectsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoT1ClickProjectsClientConfig } from "./IoT1ClickProjectsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoT1ClickProjectsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-1click-projects/runtimeConfig.shared.ts b/clients/client-iot-1click-projects/runtimeConfig.shared.ts index 106d4272c5c6f..c0e8c308f9e9e 100644 --- a/clients/client-iot-1click-projects/runtimeConfig.shared.ts +++ b/clients/client-iot-1click-projects/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoT1ClickProjectsClientConfig } from "./IoT1ClickProjectsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoT1ClickProjectsClientConfig) => ({ apiVersion: "2018-05-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT 1Click Projects", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT 1Click Projects", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-1click-projects/runtimeConfig.ts b/clients/client-iot-1click-projects/runtimeConfig.ts index c9e42237ad196..e455a2defed26 100644 --- a/clients/client-iot-1click-projects/runtimeConfig.ts +++ b/clients/client-iot-1click-projects/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoT1ClickProjectsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoT1ClickProjectsClientConfig } from "./IoT1ClickProjectsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoT1ClickProjectsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-data-plane/IoTDataPlaneClient.ts b/clients/client-iot-data-plane/IoTDataPlaneClient.ts index 7d5d77e49f8d1..3723b1f1aee03 100644 --- a/clients/client-iot-data-plane/IoTDataPlaneClient.ts +++ b/clients/client-iot-data-plane/IoTDataPlaneClient.ts @@ -6,7 +6,7 @@ import { } from "./commands/ListNamedShadowsForThingCommand"; import { PublishCommandInput, PublishCommandOutput } from "./commands/PublishCommand"; import { UpdateThingShadowCommandInput, UpdateThingShadowCommandOutput } from "./commands/UpdateThingShadowCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -242,10 +242,7 @@ export class IoTDataPlaneClient extends __Client< readonly config: IoTDataPlaneClientResolvedConfig; constructor(configuration: IoTDataPlaneClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-data-plane/runtimeConfig.browser.ts b/clients/client-iot-data-plane/runtimeConfig.browser.ts index 99c3a1328ad87..d3d57f0a40b68 100644 --- a/clients/client-iot-data-plane/runtimeConfig.browser.ts +++ b/clients/client-iot-data-plane/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTDataPlaneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTDataPlaneClientConfig } from "./IoTDataPlaneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTDataPlaneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-data-plane/runtimeConfig.native.ts b/clients/client-iot-data-plane/runtimeConfig.native.ts index 3a72bc8340635..aaf57f58a32a3 100644 --- a/clients/client-iot-data-plane/runtimeConfig.native.ts +++ b/clients/client-iot-data-plane/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTDataPlaneClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTDataPlaneClientConfig } from "./IoTDataPlaneClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTDataPlaneClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-data-plane/runtimeConfig.shared.ts b/clients/client-iot-data-plane/runtimeConfig.shared.ts index d4d649112fb19..1b22298e8de09 100644 --- a/clients/client-iot-data-plane/runtimeConfig.shared.ts +++ b/clients/client-iot-data-plane/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTDataPlaneClientConfig } from "./IoTDataPlaneClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTDataPlaneClientConfig) => ({ apiVersion: "2015-05-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT Data Plane", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT Data Plane", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-data-plane/runtimeConfig.ts b/clients/client-iot-data-plane/runtimeConfig.ts index 2f5aaae42f3c2..7a03cb83ca482 100644 --- a/clients/client-iot-data-plane/runtimeConfig.ts +++ b/clients/client-iot-data-plane/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTDataPlaneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTDataPlaneClientConfig } from "./IoTDataPlaneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTDataPlaneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-events-data/IoTEventsDataClient.ts b/clients/client-iot-events-data/IoTEventsDataClient.ts index 64aaf2c0b777f..d5e52de2f9ce3 100644 --- a/clients/client-iot-events-data/IoTEventsDataClient.ts +++ b/clients/client-iot-events-data/IoTEventsDataClient.ts @@ -15,7 +15,7 @@ import { DescribeAlarmCommandInput, DescribeAlarmCommandOutput } from "./command import { DescribeDetectorCommandInput, DescribeDetectorCommandOutput } from "./commands/DescribeDetectorCommand"; import { ListAlarmsCommandInput, ListAlarmsCommandOutput } from "./commands/ListAlarmsCommand"; import { ListDetectorsCommandInput, ListDetectorsCommandOutput } from "./commands/ListDetectorsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -251,10 +251,7 @@ export class IoTEventsDataClient extends __Client< readonly config: IoTEventsDataClientResolvedConfig; constructor(configuration: IoTEventsDataClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-events-data/runtimeConfig.browser.ts b/clients/client-iot-events-data/runtimeConfig.browser.ts index 34dadf9d8e595..d7f8fc6326a75 100644 --- a/clients/client-iot-events-data/runtimeConfig.browser.ts +++ b/clients/client-iot-events-data/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTEventsDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTEventsDataClientConfig } from "./IoTEventsDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTEventsDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-events-data/runtimeConfig.native.ts b/clients/client-iot-events-data/runtimeConfig.native.ts index eea5d5572a71a..f925574a33f31 100644 --- a/clients/client-iot-events-data/runtimeConfig.native.ts +++ b/clients/client-iot-events-data/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTEventsDataClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTEventsDataClientConfig } from "./IoTEventsDataClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTEventsDataClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-events-data/runtimeConfig.shared.ts b/clients/client-iot-events-data/runtimeConfig.shared.ts index 0980ab6b1eb4e..195f511b14dc1 100644 --- a/clients/client-iot-events-data/runtimeConfig.shared.ts +++ b/clients/client-iot-events-data/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTEventsDataClientConfig } from "./IoTEventsDataClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTEventsDataClientConfig) => ({ apiVersion: "2018-10-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT Events Data", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT Events Data", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-events-data/runtimeConfig.ts b/clients/client-iot-events-data/runtimeConfig.ts index c90789d50b9c9..ebcd80bbd86d1 100644 --- a/clients/client-iot-events-data/runtimeConfig.ts +++ b/clients/client-iot-events-data/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTEventsDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTEventsDataClientConfig } from "./IoTEventsDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTEventsDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-events/IoTEventsClient.ts b/clients/client-iot-events/IoTEventsClient.ts index 6273aff3a25fd..9bc1794f0ce82 100644 --- a/clients/client-iot-events/IoTEventsClient.ts +++ b/clients/client-iot-events/IoTEventsClient.ts @@ -57,7 +57,7 @@ import { UpdateDetectorModelCommandOutput, } from "./commands/UpdateDetectorModelCommand"; import { UpdateInputCommandInput, UpdateInputCommandOutput } from "./commands/UpdateInputCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -321,10 +321,7 @@ export class IoTEventsClient extends __Client< readonly config: IoTEventsClientResolvedConfig; constructor(configuration: IoTEventsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-events/runtimeConfig.browser.ts b/clients/client-iot-events/runtimeConfig.browser.ts index 81259707165f4..328da661ba67f 100644 --- a/clients/client-iot-events/runtimeConfig.browser.ts +++ b/clients/client-iot-events/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTEventsClientConfig } from "./IoTEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-events/runtimeConfig.native.ts b/clients/client-iot-events/runtimeConfig.native.ts index 4890d48961d32..67fca378f7304 100644 --- a/clients/client-iot-events/runtimeConfig.native.ts +++ b/clients/client-iot-events/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTEventsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTEventsClientConfig } from "./IoTEventsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTEventsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-events/runtimeConfig.shared.ts b/clients/client-iot-events/runtimeConfig.shared.ts index 3134862075ee6..359b6d3c556e0 100644 --- a/clients/client-iot-events/runtimeConfig.shared.ts +++ b/clients/client-iot-events/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTEventsClientConfig } from "./IoTEventsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTEventsClientConfig) => ({ apiVersion: "2018-07-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT Events", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT Events", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-events/runtimeConfig.ts b/clients/client-iot-events/runtimeConfig.ts index 098c204f70c6e..f59e61a96a0b1 100644 --- a/clients/client-iot-events/runtimeConfig.ts +++ b/clients/client-iot-events/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTEventsClientConfig } from "./IoTEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-jobs-data-plane/IoTJobsDataPlaneClient.ts b/clients/client-iot-jobs-data-plane/IoTJobsDataPlaneClient.ts index 77bce9b9bba46..1da1adfb1c87d 100644 --- a/clients/client-iot-jobs-data-plane/IoTJobsDataPlaneClient.ts +++ b/clients/client-iot-jobs-data-plane/IoTJobsDataPlaneClient.ts @@ -11,7 +11,7 @@ import { StartNextPendingJobExecutionCommandOutput, } from "./commands/StartNextPendingJobExecutionCommand"; import { UpdateJobExecutionCommandInput, UpdateJobExecutionCommandOutput } from "./commands/UpdateJobExecutionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -239,10 +239,7 @@ export class IoTJobsDataPlaneClient extends __Client< readonly config: IoTJobsDataPlaneClientResolvedConfig; constructor(configuration: IoTJobsDataPlaneClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-jobs-data-plane/runtimeConfig.browser.ts b/clients/client-iot-jobs-data-plane/runtimeConfig.browser.ts index 478e7b273f0fa..2f80c81dfe4f7 100644 --- a/clients/client-iot-jobs-data-plane/runtimeConfig.browser.ts +++ b/clients/client-iot-jobs-data-plane/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTJobsDataPlaneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTJobsDataPlaneClientConfig } from "./IoTJobsDataPlaneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTJobsDataPlaneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-jobs-data-plane/runtimeConfig.native.ts b/clients/client-iot-jobs-data-plane/runtimeConfig.native.ts index 0988305cbe47b..423d1d958cb22 100644 --- a/clients/client-iot-jobs-data-plane/runtimeConfig.native.ts +++ b/clients/client-iot-jobs-data-plane/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTJobsDataPlaneClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTJobsDataPlaneClientConfig } from "./IoTJobsDataPlaneClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTJobsDataPlaneClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-jobs-data-plane/runtimeConfig.shared.ts b/clients/client-iot-jobs-data-plane/runtimeConfig.shared.ts index ad8282653df1f..d4f858ef4a7cc 100644 --- a/clients/client-iot-jobs-data-plane/runtimeConfig.shared.ts +++ b/clients/client-iot-jobs-data-plane/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTJobsDataPlaneClientConfig } from "./IoTJobsDataPlaneClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTJobsDataPlaneClientConfig) => ({ apiVersion: "2017-09-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT Jobs Data Plane", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT Jobs Data Plane", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-jobs-data-plane/runtimeConfig.ts b/clients/client-iot-jobs-data-plane/runtimeConfig.ts index 4c86a4c8d30b1..47daf361a3160 100644 --- a/clients/client-iot-jobs-data-plane/runtimeConfig.ts +++ b/clients/client-iot-jobs-data-plane/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTJobsDataPlaneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTJobsDataPlaneClientConfig } from "./IoTJobsDataPlaneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTJobsDataPlaneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-wireless/IoTWirelessClient.ts b/clients/client-iot-wireless/IoTWirelessClient.ts index 8cbb44adcebb2..776a5b9e1e1d9 100644 --- a/clients/client-iot-wireless/IoTWirelessClient.ts +++ b/clients/client-iot-wireless/IoTWirelessClient.ts @@ -181,7 +181,7 @@ import { UpdateWirelessGatewayCommandInput, UpdateWirelessGatewayCommandOutput, } from "./commands/UpdateWirelessGatewayCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -505,10 +505,7 @@ export class IoTWirelessClient extends __Client< readonly config: IoTWirelessClientResolvedConfig; constructor(configuration: IoTWirelessClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot-wireless/runtimeConfig.browser.ts b/clients/client-iot-wireless/runtimeConfig.browser.ts index 6d09838cddf0a..5bafc877f5738 100644 --- a/clients/client-iot-wireless/runtimeConfig.browser.ts +++ b/clients/client-iot-wireless/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTWirelessClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTWirelessClientConfig } from "./IoTWirelessClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTWirelessClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot-wireless/runtimeConfig.native.ts b/clients/client-iot-wireless/runtimeConfig.native.ts index cb57785f9fa7c..855d3281eae3f 100644 --- a/clients/client-iot-wireless/runtimeConfig.native.ts +++ b/clients/client-iot-wireless/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTWirelessClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTWirelessClientConfig } from "./IoTWirelessClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTWirelessClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot-wireless/runtimeConfig.shared.ts b/clients/client-iot-wireless/runtimeConfig.shared.ts index 8353e6925e918..87be4d64605d3 100644 --- a/clients/client-iot-wireless/runtimeConfig.shared.ts +++ b/clients/client-iot-wireless/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTWirelessClientConfig } from "./IoTWirelessClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTWirelessClientConfig) => ({ apiVersion: "2020-11-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT Wireless", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT Wireless", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot-wireless/runtimeConfig.ts b/clients/client-iot-wireless/runtimeConfig.ts index d616f7e483aa8..5dc4940d70a06 100644 --- a/clients/client-iot-wireless/runtimeConfig.ts +++ b/clients/client-iot-wireless/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTWirelessClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTWirelessClientConfig } from "./IoTWirelessClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTWirelessClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot/IoTClient.ts b/clients/client-iot/IoTClient.ts index b99f068d3a0f8..169398182cdb5 100644 --- a/clients/client-iot/IoTClient.ts +++ b/clients/client-iot/IoTClient.ts @@ -618,7 +618,7 @@ import { ValidateSecurityProfileBehaviorsCommandInput, ValidateSecurityProfileBehaviorsCommandOutput, } from "./commands/ValidateSecurityProfileBehaviorsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -1303,10 +1303,7 @@ export class IoTClient extends __Client< readonly config: IoTClientResolvedConfig; constructor(configuration: IoTClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iot/runtimeConfig.browser.ts b/clients/client-iot/runtimeConfig.browser.ts index d204adede5ee4..6db689dda83a1 100644 --- a/clients/client-iot/runtimeConfig.browser.ts +++ b/clients/client-iot/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTClientConfig } from "./IoTClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iot/runtimeConfig.native.ts b/clients/client-iot/runtimeConfig.native.ts index 8c2a84c66984f..de6fbdc29e047 100644 --- a/clients/client-iot/runtimeConfig.native.ts +++ b/clients/client-iot/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTClientConfig } from "./IoTClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iot/runtimeConfig.shared.ts b/clients/client-iot/runtimeConfig.shared.ts index f52edc8e582d8..d619d030aa618 100644 --- a/clients/client-iot/runtimeConfig.shared.ts +++ b/clients/client-iot/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTClientConfig } from "./IoTClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTClientConfig) => ({ apiVersion: "2015-05-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoT", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoT", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iot/runtimeConfig.ts b/clients/client-iot/runtimeConfig.ts index 511a425f9cd71..fab89af608523 100644 --- a/clients/client-iot/runtimeConfig.ts +++ b/clients/client-iot/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTClientConfig } from "./IoTClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotanalytics/IoTAnalyticsClient.ts b/clients/client-iotanalytics/IoTAnalyticsClient.ts index fd52e31a2ccaa..97c0e52267b61 100644 --- a/clients/client-iotanalytics/IoTAnalyticsClient.ts +++ b/clients/client-iotanalytics/IoTAnalyticsClient.ts @@ -56,7 +56,7 @@ import { UpdateChannelCommandInput, UpdateChannelCommandOutput } from "./command import { UpdateDatasetCommandInput, UpdateDatasetCommandOutput } from "./commands/UpdateDatasetCommand"; import { UpdateDatastoreCommandInput, UpdateDatastoreCommandOutput } from "./commands/UpdateDatastoreCommand"; import { UpdatePipelineCommandInput, UpdatePipelineCommandOutput } from "./commands/UpdatePipelineCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -352,10 +352,7 @@ export class IoTAnalyticsClient extends __Client< readonly config: IoTAnalyticsClientResolvedConfig; constructor(configuration: IoTAnalyticsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotanalytics/runtimeConfig.browser.ts b/clients/client-iotanalytics/runtimeConfig.browser.ts index d57214f8d1ea9..179523da62ce4 100644 --- a/clients/client-iotanalytics/runtimeConfig.browser.ts +++ b/clients/client-iotanalytics/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTAnalyticsClientConfig } from "./IoTAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotanalytics/runtimeConfig.native.ts b/clients/client-iotanalytics/runtimeConfig.native.ts index 43eae9b608946..174810610b29a 100644 --- a/clients/client-iotanalytics/runtimeConfig.native.ts +++ b/clients/client-iotanalytics/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTAnalyticsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTAnalyticsClientConfig } from "./IoTAnalyticsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTAnalyticsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotanalytics/runtimeConfig.shared.ts b/clients/client-iotanalytics/runtimeConfig.shared.ts index 6664dbd7f0834..6e709be0c39fe 100644 --- a/clients/client-iotanalytics/runtimeConfig.shared.ts +++ b/clients/client-iotanalytics/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTAnalyticsClientConfig } from "./IoTAnalyticsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTAnalyticsClientConfig) => ({ apiVersion: "2017-11-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoTAnalytics", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoTAnalytics", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotanalytics/runtimeConfig.ts b/clients/client-iotanalytics/runtimeConfig.ts index 2126bc053d6fc..36dbfbde6e897 100644 --- a/clients/client-iotanalytics/runtimeConfig.ts +++ b/clients/client-iotanalytics/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTAnalyticsClientConfig } from "./IoTAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotdeviceadvisor/IotDeviceAdvisorClient.ts b/clients/client-iotdeviceadvisor/IotDeviceAdvisorClient.ts index 9ac54665c1aac..79b589a17c801 100644 --- a/clients/client-iotdeviceadvisor/IotDeviceAdvisorClient.ts +++ b/clients/client-iotdeviceadvisor/IotDeviceAdvisorClient.ts @@ -26,7 +26,7 @@ import { UpdateSuiteDefinitionCommandInput, UpdateSuiteDefinitionCommandOutput, } from "./commands/UpdateSuiteDefinitionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -262,10 +262,7 @@ export class IotDeviceAdvisorClient extends __Client< readonly config: IotDeviceAdvisorClientResolvedConfig; constructor(configuration: IotDeviceAdvisorClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotdeviceadvisor/runtimeConfig.browser.ts b/clients/client-iotdeviceadvisor/runtimeConfig.browser.ts index 036f299f316eb..cc21dac4eb3be 100644 --- a/clients/client-iotdeviceadvisor/runtimeConfig.browser.ts +++ b/clients/client-iotdeviceadvisor/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IotDeviceAdvisorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IotDeviceAdvisorClientConfig } from "./IotDeviceAdvisorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IotDeviceAdvisorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotdeviceadvisor/runtimeConfig.native.ts b/clients/client-iotdeviceadvisor/runtimeConfig.native.ts index f09a357db83d5..1d82eeafd9fea 100644 --- a/clients/client-iotdeviceadvisor/runtimeConfig.native.ts +++ b/clients/client-iotdeviceadvisor/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IotDeviceAdvisorClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IotDeviceAdvisorClientConfig } from "./IotDeviceAdvisorClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IotDeviceAdvisorClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotdeviceadvisor/runtimeConfig.shared.ts b/clients/client-iotdeviceadvisor/runtimeConfig.shared.ts index 677884775d77a..14174fdff0dff 100644 --- a/clients/client-iotdeviceadvisor/runtimeConfig.shared.ts +++ b/clients/client-iotdeviceadvisor/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IotDeviceAdvisorClientConfig } from "./IotDeviceAdvisorClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IotDeviceAdvisorClientConfig) => ({ apiVersion: "2020-09-18", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IotDeviceAdvisor", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IotDeviceAdvisor", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotdeviceadvisor/runtimeConfig.ts b/clients/client-iotdeviceadvisor/runtimeConfig.ts index 8fefee59aadf5..2e93862053b8e 100644 --- a/clients/client-iotdeviceadvisor/runtimeConfig.ts +++ b/clients/client-iotdeviceadvisor/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IotDeviceAdvisorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IotDeviceAdvisorClientConfig } from "./IotDeviceAdvisorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IotDeviceAdvisorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotfleethub/IoTFleetHubClient.ts b/clients/client-iotfleethub/IoTFleetHubClient.ts index 105c484f5db62..3c69c2016f4ac 100644 --- a/clients/client-iotfleethub/IoTFleetHubClient.ts +++ b/clients/client-iotfleethub/IoTFleetHubClient.ts @@ -12,7 +12,7 @@ import { import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateApplicationCommandInput, UpdateApplicationCommandOutput } from "./commands/UpdateApplicationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -241,10 +241,7 @@ export class IoTFleetHubClient extends __Client< readonly config: IoTFleetHubClientResolvedConfig; constructor(configuration: IoTFleetHubClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotfleethub/runtimeConfig.browser.ts b/clients/client-iotfleethub/runtimeConfig.browser.ts index 7d93c9a336427..83a7e0d8418b2 100644 --- a/clients/client-iotfleethub/runtimeConfig.browser.ts +++ b/clients/client-iotfleethub/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTFleetHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTFleetHubClientConfig } from "./IoTFleetHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTFleetHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotfleethub/runtimeConfig.native.ts b/clients/client-iotfleethub/runtimeConfig.native.ts index b4d54f3901942..15bddb6b57f29 100644 --- a/clients/client-iotfleethub/runtimeConfig.native.ts +++ b/clients/client-iotfleethub/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTFleetHubClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTFleetHubClientConfig } from "./IoTFleetHubClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTFleetHubClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotfleethub/runtimeConfig.shared.ts b/clients/client-iotfleethub/runtimeConfig.shared.ts index 8f7ccb1ce0e90..291046dc167b4 100644 --- a/clients/client-iotfleethub/runtimeConfig.shared.ts +++ b/clients/client-iotfleethub/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTFleetHubClientConfig } from "./IoTFleetHubClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTFleetHubClientConfig) => ({ apiVersion: "2020-11-03", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoTFleetHub", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoTFleetHub", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotfleethub/runtimeConfig.ts b/clients/client-iotfleethub/runtimeConfig.ts index 933c129d72b91..d6e54df8edbab 100644 --- a/clients/client-iotfleethub/runtimeConfig.ts +++ b/clients/client-iotfleethub/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTFleetHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTFleetHubClientConfig } from "./IoTFleetHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTFleetHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotsecuretunneling/IoTSecureTunnelingClient.ts b/clients/client-iotsecuretunneling/IoTSecureTunnelingClient.ts index 7291895b5ba05..09e1c8e8e8018 100644 --- a/clients/client-iotsecuretunneling/IoTSecureTunnelingClient.ts +++ b/clients/client-iotsecuretunneling/IoTSecureTunnelingClient.ts @@ -8,7 +8,7 @@ import { ListTunnelsCommandInput, ListTunnelsCommandOutput } from "./commands/Li import { OpenTunnelCommandInput, OpenTunnelCommandOutput } from "./commands/OpenTunnelCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -236,10 +236,7 @@ export class IoTSecureTunnelingClient extends __Client< readonly config: IoTSecureTunnelingClientResolvedConfig; constructor(configuration: IoTSecureTunnelingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotsecuretunneling/runtimeConfig.browser.ts b/clients/client-iotsecuretunneling/runtimeConfig.browser.ts index 754148ae60e4b..01013153f6ada 100644 --- a/clients/client-iotsecuretunneling/runtimeConfig.browser.ts +++ b/clients/client-iotsecuretunneling/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTSecureTunnelingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTSecureTunnelingClientConfig } from "./IoTSecureTunnelingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTSecureTunnelingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotsecuretunneling/runtimeConfig.native.ts b/clients/client-iotsecuretunneling/runtimeConfig.native.ts index ff20b505833e8..21d4fc7d00e3c 100644 --- a/clients/client-iotsecuretunneling/runtimeConfig.native.ts +++ b/clients/client-iotsecuretunneling/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTSecureTunnelingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTSecureTunnelingClientConfig } from "./IoTSecureTunnelingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTSecureTunnelingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotsecuretunneling/runtimeConfig.shared.ts b/clients/client-iotsecuretunneling/runtimeConfig.shared.ts index 509b7db828f32..c5c92ec34b424 100644 --- a/clients/client-iotsecuretunneling/runtimeConfig.shared.ts +++ b/clients/client-iotsecuretunneling/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTSecureTunnelingClientConfig } from "./IoTSecureTunnelingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTSecureTunnelingClientConfig) => ({ apiVersion: "2018-10-05", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoTSecureTunneling", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoTSecureTunneling", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotsecuretunneling/runtimeConfig.ts b/clients/client-iotsecuretunneling/runtimeConfig.ts index 4c2c553694d27..344916d1ac2be 100644 --- a/clients/client-iotsecuretunneling/runtimeConfig.ts +++ b/clients/client-iotsecuretunneling/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTSecureTunnelingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTSecureTunnelingClientConfig } from "./IoTSecureTunnelingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTSecureTunnelingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotsitewise/IoTSiteWiseClient.ts b/clients/client-iotsitewise/IoTSiteWiseClient.ts index 0f66e236e6dee..d663fa826536d 100644 --- a/clients/client-iotsitewise/IoTSiteWiseClient.ts +++ b/clients/client-iotsitewise/IoTSiteWiseClient.ts @@ -118,7 +118,7 @@ import { import { UpdateGatewayCommandInput, UpdateGatewayCommandOutput } from "./commands/UpdateGatewayCommand"; import { UpdatePortalCommandInput, UpdatePortalCommandOutput } from "./commands/UpdatePortalCommand"; import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./commands/UpdateProjectCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -449,10 +449,7 @@ export class IoTSiteWiseClient extends __Client< readonly config: IoTSiteWiseClientResolvedConfig; constructor(configuration: IoTSiteWiseClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotsitewise/runtimeConfig.browser.ts b/clients/client-iotsitewise/runtimeConfig.browser.ts index 1895814676f90..6bad9b95fa9b0 100644 --- a/clients/client-iotsitewise/runtimeConfig.browser.ts +++ b/clients/client-iotsitewise/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTSiteWiseClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTSiteWiseClientConfig } from "./IoTSiteWiseClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTSiteWiseClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotsitewise/runtimeConfig.native.ts b/clients/client-iotsitewise/runtimeConfig.native.ts index 83e41d3ccf23c..c43466b24ae76 100644 --- a/clients/client-iotsitewise/runtimeConfig.native.ts +++ b/clients/client-iotsitewise/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTSiteWiseClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTSiteWiseClientConfig } from "./IoTSiteWiseClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTSiteWiseClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotsitewise/runtimeConfig.shared.ts b/clients/client-iotsitewise/runtimeConfig.shared.ts index 6a8ceaf5fb75a..f9170625c10cb 100644 --- a/clients/client-iotsitewise/runtimeConfig.shared.ts +++ b/clients/client-iotsitewise/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTSiteWiseClientConfig } from "./IoTSiteWiseClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTSiteWiseClientConfig) => ({ apiVersion: "2019-12-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoTSiteWise", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoTSiteWise", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotsitewise/runtimeConfig.ts b/clients/client-iotsitewise/runtimeConfig.ts index 195ca66f090d7..3a8fd56123f40 100644 --- a/clients/client-iotsitewise/runtimeConfig.ts +++ b/clients/client-iotsitewise/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTSiteWiseClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTSiteWiseClientConfig } from "./IoTSiteWiseClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTSiteWiseClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotthingsgraph/IoTThingsGraphClient.ts b/clients/client-iotthingsgraph/IoTThingsGraphClient.ts index 58902920f3e3f..94c708c379bad 100644 --- a/clients/client-iotthingsgraph/IoTThingsGraphClient.ts +++ b/clients/client-iotthingsgraph/IoTThingsGraphClient.ts @@ -96,7 +96,7 @@ import { UploadEntityDefinitionsCommandInput, UploadEntityDefinitionsCommandOutput, } from "./commands/UploadEntityDefinitionsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -380,10 +380,7 @@ export class IoTThingsGraphClient extends __Client< readonly config: IoTThingsGraphClientResolvedConfig; constructor(configuration: IoTThingsGraphClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-iotthingsgraph/runtimeConfig.browser.ts b/clients/client-iotthingsgraph/runtimeConfig.browser.ts index 4a9668f6b5067..99a7269772c23 100644 --- a/clients/client-iotthingsgraph/runtimeConfig.browser.ts +++ b/clients/client-iotthingsgraph/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IoTThingsGraphClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTThingsGraphClientConfig } from "./IoTThingsGraphClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTThingsGraphClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-iotthingsgraph/runtimeConfig.native.ts b/clients/client-iotthingsgraph/runtimeConfig.native.ts index bdc762a4c6fce..d97fc41d1e3f9 100644 --- a/clients/client-iotthingsgraph/runtimeConfig.native.ts +++ b/clients/client-iotthingsgraph/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IoTThingsGraphClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IoTThingsGraphClientConfig } from "./IoTThingsGraphClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IoTThingsGraphClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-iotthingsgraph/runtimeConfig.shared.ts b/clients/client-iotthingsgraph/runtimeConfig.shared.ts index 0ff116ff72e19..ec1e7f7112e9d 100644 --- a/clients/client-iotthingsgraph/runtimeConfig.shared.ts +++ b/clients/client-iotthingsgraph/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IoTThingsGraphClientConfig } from "./IoTThingsGraphClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IoTThingsGraphClientConfig) => ({ apiVersion: "2018-09-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "IoTThingsGraph", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "IoTThingsGraph", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-iotthingsgraph/runtimeConfig.ts b/clients/client-iotthingsgraph/runtimeConfig.ts index 4cd9d5cd9d040..d91fbaeb29949 100644 --- a/clients/client-iotthingsgraph/runtimeConfig.ts +++ b/clients/client-iotthingsgraph/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IoTThingsGraphClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IoTThingsGraphClientConfig } from "./IoTThingsGraphClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IoTThingsGraphClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ivs/IvsClient.ts b/clients/client-ivs/IvsClient.ts index 76e228b382269..148bb9950a996 100644 --- a/clients/client-ivs/IvsClient.ts +++ b/clients/client-ivs/IvsClient.ts @@ -48,7 +48,7 @@ import { StopStreamCommandInput, StopStreamCommandOutput } from "./commands/Stop import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateChannelCommandInput, UpdateChannelCommandOutput } from "./commands/UpdateChannelCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -669,10 +669,7 @@ export class IvsClient extends __Client< readonly config: IvsClientResolvedConfig; constructor(configuration: IvsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ivs/runtimeConfig.browser.ts b/clients/client-ivs/runtimeConfig.browser.ts index cd8122d706ef6..5f85c9138630a 100644 --- a/clients/client-ivs/runtimeConfig.browser.ts +++ b/clients/client-ivs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./IvsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IvsClientConfig } from "./IvsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IvsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ivs/runtimeConfig.native.ts b/clients/client-ivs/runtimeConfig.native.ts index 73b0c7a6700e9..d1cbe19911e80 100644 --- a/clients/client-ivs/runtimeConfig.native.ts +++ b/clients/client-ivs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./IvsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { IvsClientConfig } from "./IvsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: IvsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ivs/runtimeConfig.shared.ts b/clients/client-ivs/runtimeConfig.shared.ts index 3f31538acfed4..eb40e88a03624 100644 --- a/clients/client-ivs/runtimeConfig.shared.ts +++ b/clients/client-ivs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { IvsClientConfig } from "./IvsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: IvsClientConfig) => ({ apiVersion: "2020-07-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ivs", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ivs", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ivs/runtimeConfig.ts b/clients/client-ivs/runtimeConfig.ts index 810aecbef9674..1cb76cd8d0a46 100644 --- a/clients/client-ivs/runtimeConfig.ts +++ b/clients/client-ivs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./IvsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { IvsClientConfig } from "./IvsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: IvsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kafka/KafkaClient.ts b/clients/client-kafka/KafkaClient.ts index 8dcb34f5b9e84..efe170799c667 100644 --- a/clients/client-kafka/KafkaClient.ts +++ b/clients/client-kafka/KafkaClient.ts @@ -76,7 +76,7 @@ import { UpdateConfigurationCommandOutput, } from "./commands/UpdateConfigurationCommand"; import { UpdateMonitoringCommandInput, UpdateMonitoringCommandOutput } from "./commands/UpdateMonitoringCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -346,10 +346,7 @@ export class KafkaClient extends __Client< readonly config: KafkaClientResolvedConfig; constructor(configuration: KafkaClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kafka/runtimeConfig.browser.ts b/clients/client-kafka/runtimeConfig.browser.ts index f4cc86ab34d31..8562d039dadb7 100644 --- a/clients/client-kafka/runtimeConfig.browser.ts +++ b/clients/client-kafka/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KafkaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KafkaClientConfig } from "./KafkaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KafkaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kafka/runtimeConfig.native.ts b/clients/client-kafka/runtimeConfig.native.ts index a0c270e4236f7..4bc8cfff5ce5f 100644 --- a/clients/client-kafka/runtimeConfig.native.ts +++ b/clients/client-kafka/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KafkaClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KafkaClientConfig } from "./KafkaClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KafkaClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kafka/runtimeConfig.shared.ts b/clients/client-kafka/runtimeConfig.shared.ts index fcc86fce55ece..b3018256d8fba 100644 --- a/clients/client-kafka/runtimeConfig.shared.ts +++ b/clients/client-kafka/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KafkaClientConfig } from "./KafkaClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KafkaClientConfig) => ({ apiVersion: "2018-11-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kafka", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kafka", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kafka/runtimeConfig.ts b/clients/client-kafka/runtimeConfig.ts index 56188b123be44..6b1869378053e 100644 --- a/clients/client-kafka/runtimeConfig.ts +++ b/clients/client-kafka/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KafkaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KafkaClientConfig } from "./KafkaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KafkaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kendra/KendraClient.ts b/clients/client-kendra/KendraClient.ts index 4ecd5ebab87de..ab1c2da1ada3a 100644 --- a/clients/client-kendra/KendraClient.ts +++ b/clients/client-kendra/KendraClient.ts @@ -98,7 +98,7 @@ import { UpdateQuerySuggestionsConfigCommandOutput, } from "./commands/UpdateQuerySuggestionsConfigCommand"; import { UpdateThesaurusCommandInput, UpdateThesaurusCommandOutput } from "./commands/UpdateThesaurusCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -394,10 +394,7 @@ export class KendraClient extends __Client< readonly config: KendraClientResolvedConfig; constructor(configuration: KendraClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kendra/runtimeConfig.browser.ts b/clients/client-kendra/runtimeConfig.browser.ts index 14f47db40ee09..9766e630bfe31 100644 --- a/clients/client-kendra/runtimeConfig.browser.ts +++ b/clients/client-kendra/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KendraClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KendraClientConfig } from "./KendraClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KendraClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kendra/runtimeConfig.native.ts b/clients/client-kendra/runtimeConfig.native.ts index 18ca437ca50b2..4b9896fe5183e 100644 --- a/clients/client-kendra/runtimeConfig.native.ts +++ b/clients/client-kendra/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KendraClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KendraClientConfig } from "./KendraClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KendraClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kendra/runtimeConfig.shared.ts b/clients/client-kendra/runtimeConfig.shared.ts index 90d3816a49d73..2fd4a11e61622 100644 --- a/clients/client-kendra/runtimeConfig.shared.ts +++ b/clients/client-kendra/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KendraClientConfig } from "./KendraClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KendraClientConfig) => ({ apiVersion: "2019-02-03", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "kendra", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "kendra", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kendra/runtimeConfig.ts b/clients/client-kendra/runtimeConfig.ts index b03cba7797e1b..3016ebe9cdd5b 100644 --- a/clients/client-kendra/runtimeConfig.ts +++ b/clients/client-kendra/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KendraClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KendraClientConfig } from "./KendraClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KendraClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-analytics-v2/KinesisAnalyticsV2Client.ts b/clients/client-kinesis-analytics-v2/KinesisAnalyticsV2Client.ts index 1cc64c49ebef7..084a443085724 100644 --- a/clients/client-kinesis-analytics-v2/KinesisAnalyticsV2Client.ts +++ b/clients/client-kinesis-analytics-v2/KinesisAnalyticsV2Client.ts @@ -98,7 +98,7 @@ import { UpdateApplicationMaintenanceConfigurationCommandInput, UpdateApplicationMaintenanceConfigurationCommandOutput, } from "./commands/UpdateApplicationMaintenanceConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -372,10 +372,7 @@ export class KinesisAnalyticsV2Client extends __Client< readonly config: KinesisAnalyticsV2ClientResolvedConfig; constructor(configuration: KinesisAnalyticsV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-analytics-v2/runtimeConfig.browser.ts b/clients/client-kinesis-analytics-v2/runtimeConfig.browser.ts index 9fc07674cc034..b08ab42a0df4e 100644 --- a/clients/client-kinesis-analytics-v2/runtimeConfig.browser.ts +++ b/clients/client-kinesis-analytics-v2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisAnalyticsV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisAnalyticsV2ClientConfig } from "./KinesisAnalyticsV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisAnalyticsV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-analytics-v2/runtimeConfig.native.ts b/clients/client-kinesis-analytics-v2/runtimeConfig.native.ts index 8d05c44e20cfb..192a06fd49856 100644 --- a/clients/client-kinesis-analytics-v2/runtimeConfig.native.ts +++ b/clients/client-kinesis-analytics-v2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisAnalyticsV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisAnalyticsV2ClientConfig } from "./KinesisAnalyticsV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisAnalyticsV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-analytics-v2/runtimeConfig.shared.ts b/clients/client-kinesis-analytics-v2/runtimeConfig.shared.ts index 65c074f0e9b51..07053bda9de1a 100644 --- a/clients/client-kinesis-analytics-v2/runtimeConfig.shared.ts +++ b/clients/client-kinesis-analytics-v2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisAnalyticsV2ClientConfig } from "./KinesisAnalyticsV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisAnalyticsV2ClientConfig) => ({ apiVersion: "2018-05-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Analytics V2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Analytics V2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-analytics-v2/runtimeConfig.ts b/clients/client-kinesis-analytics-v2/runtimeConfig.ts index 0fc91fcf94c00..40d682ea245c6 100644 --- a/clients/client-kinesis-analytics-v2/runtimeConfig.ts +++ b/clients/client-kinesis-analytics-v2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisAnalyticsV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisAnalyticsV2ClientConfig } from "./KinesisAnalyticsV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisAnalyticsV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-analytics/KinesisAnalyticsClient.ts b/clients/client-kinesis-analytics/KinesisAnalyticsClient.ts index d46c113bd5d6f..4d4590b894dd8 100644 --- a/clients/client-kinesis-analytics/KinesisAnalyticsClient.ts +++ b/clients/client-kinesis-analytics/KinesisAnalyticsClient.ts @@ -54,7 +54,7 @@ import { StopApplicationCommandInput, StopApplicationCommandOutput } from "./com import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateApplicationCommandInput, UpdateApplicationCommandOutput } from "./commands/UpdateApplicationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -313,10 +313,7 @@ export class KinesisAnalyticsClient extends __Client< readonly config: KinesisAnalyticsClientResolvedConfig; constructor(configuration: KinesisAnalyticsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-analytics/runtimeConfig.browser.ts b/clients/client-kinesis-analytics/runtimeConfig.browser.ts index 72d84ba75e7a7..d2c7681c79de7 100644 --- a/clients/client-kinesis-analytics/runtimeConfig.browser.ts +++ b/clients/client-kinesis-analytics/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisAnalyticsClientConfig } from "./KinesisAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-analytics/runtimeConfig.native.ts b/clients/client-kinesis-analytics/runtimeConfig.native.ts index 6f28f53aa6c59..a1a9c9f645148 100644 --- a/clients/client-kinesis-analytics/runtimeConfig.native.ts +++ b/clients/client-kinesis-analytics/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisAnalyticsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisAnalyticsClientConfig } from "./KinesisAnalyticsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisAnalyticsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-analytics/runtimeConfig.shared.ts b/clients/client-kinesis-analytics/runtimeConfig.shared.ts index 3b336c22da690..2351e4420bacd 100644 --- a/clients/client-kinesis-analytics/runtimeConfig.shared.ts +++ b/clients/client-kinesis-analytics/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisAnalyticsClientConfig } from "./KinesisAnalyticsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisAnalyticsClientConfig) => ({ apiVersion: "2015-08-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Analytics", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Analytics", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-analytics/runtimeConfig.ts b/clients/client-kinesis-analytics/runtimeConfig.ts index 9ed5d78d30643..22e3866cde013 100644 --- a/clients/client-kinesis-analytics/runtimeConfig.ts +++ b/clients/client-kinesis-analytics/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisAnalyticsClientConfig } from "./KinesisAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-archived-media/KinesisVideoArchivedMediaClient.ts b/clients/client-kinesis-video-archived-media/KinesisVideoArchivedMediaClient.ts index 27eb7cc0e3c1f..749d5b284895e 100644 --- a/clients/client-kinesis-video-archived-media/KinesisVideoArchivedMediaClient.ts +++ b/clients/client-kinesis-video-archived-media/KinesisVideoArchivedMediaClient.ts @@ -12,7 +12,7 @@ import { GetMediaForFragmentListCommandOutput, } from "./commands/GetMediaForFragmentListCommand"; import { ListFragmentsCommandInput, ListFragmentsCommandOutput } from "./commands/ListFragmentsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -233,10 +233,7 @@ export class KinesisVideoArchivedMediaClient extends __Client< readonly config: KinesisVideoArchivedMediaClientResolvedConfig; constructor(configuration: KinesisVideoArchivedMediaClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-video-archived-media/runtimeConfig.browser.ts b/clients/client-kinesis-video-archived-media/runtimeConfig.browser.ts index 240f9f2b4cc6a..46aee5b2aa1a3 100644 --- a/clients/client-kinesis-video-archived-media/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video-archived-media/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisVideoArchivedMediaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-archived-media/runtimeConfig.native.ts b/clients/client-kinesis-video-archived-media/runtimeConfig.native.ts index 7200ae167c419..4d5e2eeb88a18 100644 --- a/clients/client-kinesis-video-archived-media/runtimeConfig.native.ts +++ b/clients/client-kinesis-video-archived-media/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisVideoArchivedMediaClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-video-archived-media/runtimeConfig.shared.ts b/clients/client-kinesis-video-archived-media/runtimeConfig.shared.ts index f1eb004ec059b..25b0cb8de7b7c 100644 --- a/clients/client-kinesis-video-archived-media/runtimeConfig.shared.ts +++ b/clients/client-kinesis-video-archived-media/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) => ({ apiVersion: "2017-09-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Video Archived Media", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Video Archived Media", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-video-archived-media/runtimeConfig.ts b/clients/client-kinesis-video-archived-media/runtimeConfig.ts index 44319a362840f..205bce509e5da 100644 --- a/clients/client-kinesis-video-archived-media/runtimeConfig.ts +++ b/clients/client-kinesis-video-archived-media/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisVideoArchivedMediaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoArchivedMediaClientConfig } from "./KinesisVideoArchivedMediaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoArchivedMediaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-media/KinesisVideoMediaClient.ts b/clients/client-kinesis-video-media/KinesisVideoMediaClient.ts index 0ffe311a73cee..0aeaf38bac01d 100644 --- a/clients/client-kinesis-video-media/KinesisVideoMediaClient.ts +++ b/clients/client-kinesis-video-media/KinesisVideoMediaClient.ts @@ -1,5 +1,5 @@ import { GetMediaCommandInput, GetMediaCommandOutput } from "./commands/GetMediaCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -209,10 +209,7 @@ export class KinesisVideoMediaClient extends __Client< readonly config: KinesisVideoMediaClientResolvedConfig; constructor(configuration: KinesisVideoMediaClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-video-media/runtimeConfig.browser.ts b/clients/client-kinesis-video-media/runtimeConfig.browser.ts index 7bb1fa1852ab3..93262a2f8885b 100644 --- a/clients/client-kinesis-video-media/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video-media/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisVideoMediaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-media/runtimeConfig.native.ts b/clients/client-kinesis-video-media/runtimeConfig.native.ts index 97d29177a3fd7..1615e63802ee3 100644 --- a/clients/client-kinesis-video-media/runtimeConfig.native.ts +++ b/clients/client-kinesis-video-media/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisVideoMediaClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-video-media/runtimeConfig.shared.ts b/clients/client-kinesis-video-media/runtimeConfig.shared.ts index a3cd541e6db50..46d6c7aa077c0 100644 --- a/clients/client-kinesis-video-media/runtimeConfig.shared.ts +++ b/clients/client-kinesis-video-media/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => ({ apiVersion: "2017-09-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Video Media", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Video Media", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-video-media/runtimeConfig.ts b/clients/client-kinesis-video-media/runtimeConfig.ts index 109a7b972d1ce..0b7dce958c000 100644 --- a/clients/client-kinesis-video-media/runtimeConfig.ts +++ b/clients/client-kinesis-video-media/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisVideoMediaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoMediaClientConfig } from "./KinesisVideoMediaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoMediaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-signaling/KinesisVideoSignalingClient.ts b/clients/client-kinesis-video-signaling/KinesisVideoSignalingClient.ts index 93a33bb3b6c97..ef50b45addb91 100644 --- a/clients/client-kinesis-video-signaling/KinesisVideoSignalingClient.ts +++ b/clients/client-kinesis-video-signaling/KinesisVideoSignalingClient.ts @@ -3,7 +3,7 @@ import { SendAlexaOfferToMasterCommandInput, SendAlexaOfferToMasterCommandOutput, } from "./commands/SendAlexaOfferToMasterCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -221,10 +221,7 @@ export class KinesisVideoSignalingClient extends __Client< readonly config: KinesisVideoSignalingClientResolvedConfig; constructor(configuration: KinesisVideoSignalingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-video-signaling/runtimeConfig.browser.ts b/clients/client-kinesis-video-signaling/runtimeConfig.browser.ts index 69e3f395dbe86..d971cedee136e 100644 --- a/clients/client-kinesis-video-signaling/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video-signaling/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisVideoSignalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoSignalingClientConfig } from "./KinesisVideoSignalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoSignalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video-signaling/runtimeConfig.native.ts b/clients/client-kinesis-video-signaling/runtimeConfig.native.ts index b951cbabf0fd2..eb4303d1b4222 100644 --- a/clients/client-kinesis-video-signaling/runtimeConfig.native.ts +++ b/clients/client-kinesis-video-signaling/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisVideoSignalingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisVideoSignalingClientConfig } from "./KinesisVideoSignalingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisVideoSignalingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-video-signaling/runtimeConfig.shared.ts b/clients/client-kinesis-video-signaling/runtimeConfig.shared.ts index bd634dd753024..2624a06a30ea7 100644 --- a/clients/client-kinesis-video-signaling/runtimeConfig.shared.ts +++ b/clients/client-kinesis-video-signaling/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisVideoSignalingClientConfig } from "./KinesisVideoSignalingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisVideoSignalingClientConfig) => ({ apiVersion: "2019-12-04", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Video Signaling", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Video Signaling", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-video-signaling/runtimeConfig.ts b/clients/client-kinesis-video-signaling/runtimeConfig.ts index 09959f85c88de..d1d7f0a6cc610 100644 --- a/clients/client-kinesis-video-signaling/runtimeConfig.ts +++ b/clients/client-kinesis-video-signaling/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisVideoSignalingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoSignalingClientConfig } from "./KinesisVideoSignalingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoSignalingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video/KinesisVideoClient.ts b/clients/client-kinesis-video/KinesisVideoClient.ts index d123bebbc35f8..7daef6f1076e6 100644 --- a/clients/client-kinesis-video/KinesisVideoClient.ts +++ b/clients/client-kinesis-video/KinesisVideoClient.ts @@ -41,7 +41,7 @@ import { UpdateSignalingChannelCommandOutput, } from "./commands/UpdateSignalingChannelCommand"; import { UpdateStreamCommandInput, UpdateStreamCommandOutput } from "./commands/UpdateStreamCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -289,10 +289,7 @@ export class KinesisVideoClient extends __Client< readonly config: KinesisVideoClientResolvedConfig; constructor(configuration: KinesisVideoClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis-video/runtimeConfig.browser.ts b/clients/client-kinesis-video/runtimeConfig.browser.ts index 88f05e0bd7f51..09eb8597af36c 100644 --- a/clients/client-kinesis-video/runtimeConfig.browser.ts +++ b/clients/client-kinesis-video/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisVideoClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoClientConfig } from "./KinesisVideoClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis-video/runtimeConfig.native.ts b/clients/client-kinesis-video/runtimeConfig.native.ts index 38bcc64c3df32..4d1c87ceb3457 100644 --- a/clients/client-kinesis-video/runtimeConfig.native.ts +++ b/clients/client-kinesis-video/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisVideoClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisVideoClientConfig } from "./KinesisVideoClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisVideoClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis-video/runtimeConfig.shared.ts b/clients/client-kinesis-video/runtimeConfig.shared.ts index 6e3a5bc49597f..066ff5635678a 100644 --- a/clients/client-kinesis-video/runtimeConfig.shared.ts +++ b/clients/client-kinesis-video/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisVideoClientConfig } from "./KinesisVideoClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisVideoClientConfig) => ({ apiVersion: "2017-09-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis Video", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis Video", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis-video/runtimeConfig.ts b/clients/client-kinesis-video/runtimeConfig.ts index e4eb8b6f84b5f..c344f6e657ac2 100644 --- a/clients/client-kinesis-video/runtimeConfig.ts +++ b/clients/client-kinesis-video/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisVideoClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisVideoClientConfig } from "./KinesisVideoClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisVideoClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis/KinesisClient.ts b/clients/client-kinesis/KinesisClient.ts index 50485fdba2b24..c743301d8a35b 100644 --- a/clients/client-kinesis/KinesisClient.ts +++ b/clients/client-kinesis/KinesisClient.ts @@ -62,7 +62,7 @@ import { } from "./commands/StopStreamEncryptionCommand"; import { SubscribeToShardCommandInput, SubscribeToShardCommandOutput } from "./commands/SubscribeToShardCommand"; import { UpdateShardCountCommandInput, UpdateShardCountCommandOutput } from "./commands/UpdateShardCountCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -343,10 +343,7 @@ export class KinesisClient extends __Client< readonly config: KinesisClientResolvedConfig; constructor(configuration: KinesisClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kinesis/runtimeConfig.browser.ts b/clients/client-kinesis/runtimeConfig.browser.ts index bac16f631e58e..b36398ee67a80 100644 --- a/clients/client-kinesis/runtimeConfig.browser.ts +++ b/clients/client-kinesis/runtimeConfig.browser.ts @@ -9,30 +9,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KinesisClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisClientConfig } from "./KinesisClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamSerdeProvider, - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kinesis/runtimeConfig.native.ts b/clients/client-kinesis/runtimeConfig.native.ts index 5567c509f70f1..ec82e232a1c69 100644 --- a/clients/client-kinesis/runtimeConfig.native.ts +++ b/clients/client-kinesis/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KinesisClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KinesisClientConfig } from "./KinesisClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KinesisClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kinesis/runtimeConfig.shared.ts b/clients/client-kinesis/runtimeConfig.shared.ts index 0fd263095326c..1c87d24ceb37e 100644 --- a/clients/client-kinesis/runtimeConfig.shared.ts +++ b/clients/client-kinesis/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KinesisClientConfig } from "./KinesisClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KinesisClientConfig) => ({ apiVersion: "2013-12-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Kinesis", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Kinesis", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kinesis/runtimeConfig.ts b/clients/client-kinesis/runtimeConfig.ts index 41c389fcf6dbe..9b0fa80fe2d10 100644 --- a/clients/client-kinesis/runtimeConfig.ts +++ b/clients/client-kinesis/runtimeConfig.ts @@ -12,30 +12,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KinesisClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KinesisClientConfig } from "./KinesisClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamSerdeProvider, - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KinesisClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kms/KMSClient.ts b/clients/client-kms/KMSClient.ts index 7188776d57a70..267f3a54ca30e 100644 --- a/clients/client-kms/KMSClient.ts +++ b/clients/client-kms/KMSClient.ts @@ -94,7 +94,7 @@ import { UpdatePrimaryRegionCommandOutput, } from "./commands/UpdatePrimaryRegionCommand"; import { VerifyCommandInput, VerifyCommandOutput } from "./commands/VerifyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -488,10 +488,7 @@ export class KMSClient extends __Client< readonly config: KMSClientResolvedConfig; constructor(configuration: KMSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-kms/runtimeConfig.browser.ts b/clients/client-kms/runtimeConfig.browser.ts index 230130cd37f2c..013b4271902e2 100644 --- a/clients/client-kms/runtimeConfig.browser.ts +++ b/clients/client-kms/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./KMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KMSClientConfig } from "./KMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-kms/runtimeConfig.native.ts b/clients/client-kms/runtimeConfig.native.ts index 0dfcfe2051572..09025cc4b6b72 100644 --- a/clients/client-kms/runtimeConfig.native.ts +++ b/clients/client-kms/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./KMSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { KMSClientConfig } from "./KMSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: KMSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-kms/runtimeConfig.shared.ts b/clients/client-kms/runtimeConfig.shared.ts index e84ede33c9ea6..c151af1a1b14e 100644 --- a/clients/client-kms/runtimeConfig.shared.ts +++ b/clients/client-kms/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { KMSClientConfig } from "./KMSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: KMSClientConfig) => ({ apiVersion: "2014-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "KMS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "KMS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-kms/runtimeConfig.ts b/clients/client-kms/runtimeConfig.ts index ce5ac1429d297..e8d4c951052e5 100644 --- a/clients/client-kms/runtimeConfig.ts +++ b/clients/client-kms/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./KMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { KMSClientConfig } from "./KMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: KMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lakeformation/LakeFormationClient.ts b/clients/client-lakeformation/LakeFormationClient.ts index 4f61535f209ae..d114b1beae3bb 100644 --- a/clients/client-lakeformation/LakeFormationClient.ts +++ b/clients/client-lakeformation/LakeFormationClient.ts @@ -48,7 +48,7 @@ import { } from "./commands/SearchTablesByLFTagsCommand"; import { UpdateLFTagCommandInput, UpdateLFTagCommandOutput } from "./commands/UpdateLFTagCommand"; import { UpdateResourceCommandInput, UpdateResourceCommandOutput } from "./commands/UpdateResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -305,10 +305,7 @@ export class LakeFormationClient extends __Client< readonly config: LakeFormationClientResolvedConfig; constructor(configuration: LakeFormationClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lakeformation/runtimeConfig.browser.ts b/clients/client-lakeformation/runtimeConfig.browser.ts index dbf629dbec4b1..8117f894d2cec 100644 --- a/clients/client-lakeformation/runtimeConfig.browser.ts +++ b/clients/client-lakeformation/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LakeFormationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LakeFormationClientConfig } from "./LakeFormationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LakeFormationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lakeformation/runtimeConfig.native.ts b/clients/client-lakeformation/runtimeConfig.native.ts index 3e85fc4a31ba8..ee0c111f979db 100644 --- a/clients/client-lakeformation/runtimeConfig.native.ts +++ b/clients/client-lakeformation/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LakeFormationClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LakeFormationClientConfig } from "./LakeFormationClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LakeFormationClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lakeformation/runtimeConfig.shared.ts b/clients/client-lakeformation/runtimeConfig.shared.ts index 186e0225540fe..935ea38cb4a66 100644 --- a/clients/client-lakeformation/runtimeConfig.shared.ts +++ b/clients/client-lakeformation/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LakeFormationClientConfig } from "./LakeFormationClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LakeFormationClientConfig) => ({ apiVersion: "2017-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "LakeFormation", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "LakeFormation", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lakeformation/runtimeConfig.ts b/clients/client-lakeformation/runtimeConfig.ts index 7e159cc5f3ca9..dcabc19ca764b 100644 --- a/clients/client-lakeformation/runtimeConfig.ts +++ b/clients/client-lakeformation/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LakeFormationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LakeFormationClientConfig } from "./LakeFormationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LakeFormationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lambda/LambdaClient.ts b/clients/client-lambda/LambdaClient.ts index b03ca8c641e93..e66bf5f6eee6c 100644 --- a/clients/client-lambda/LambdaClient.ts +++ b/clients/client-lambda/LambdaClient.ts @@ -158,7 +158,7 @@ import { UpdateFunctionEventInvokeConfigCommandInput, UpdateFunctionEventInvokeConfigCommandOutput, } from "./commands/UpdateFunctionEventInvokeConfigCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -490,10 +490,7 @@ export class LambdaClient extends __Client< readonly config: LambdaClientResolvedConfig; constructor(configuration: LambdaClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lambda/runtimeConfig.browser.ts b/clients/client-lambda/runtimeConfig.browser.ts index 714fa0dbbb978..bdddc7b9ca66a 100644 --- a/clients/client-lambda/runtimeConfig.browser.ts +++ b/clients/client-lambda/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LambdaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LambdaClientConfig } from "./LambdaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LambdaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lambda/runtimeConfig.native.ts b/clients/client-lambda/runtimeConfig.native.ts index 9b81ddfb5a741..9a1d443b8f5fd 100644 --- a/clients/client-lambda/runtimeConfig.native.ts +++ b/clients/client-lambda/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LambdaClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LambdaClientConfig } from "./LambdaClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LambdaClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lambda/runtimeConfig.shared.ts b/clients/client-lambda/runtimeConfig.shared.ts index b5eb623f00b73..63c56ec86933a 100644 --- a/clients/client-lambda/runtimeConfig.shared.ts +++ b/clients/client-lambda/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LambdaClientConfig } from "./LambdaClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LambdaClientConfig) => ({ apiVersion: "2015-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lambda", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lambda", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lambda/runtimeConfig.ts b/clients/client-lambda/runtimeConfig.ts index 5f0ca290dcb37..4a441ddd4d275 100644 --- a/clients/client-lambda/runtimeConfig.ts +++ b/clients/client-lambda/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LambdaClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LambdaClientConfig } from "./LambdaClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LambdaClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-model-building-service/LexModelBuildingServiceClient.ts b/clients/client-lex-model-building-service/LexModelBuildingServiceClient.ts index e5e4f4063e77a..0e9a9af8c3ce3 100644 --- a/clients/client-lex-model-building-service/LexModelBuildingServiceClient.ts +++ b/clients/client-lex-model-building-service/LexModelBuildingServiceClient.ts @@ -70,7 +70,7 @@ import { StartImportCommandInput, StartImportCommandOutput } from "./commands/St import { StartMigrationCommandInput, StartMigrationCommandOutput } from "./commands/StartMigrationCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -367,10 +367,7 @@ export class LexModelBuildingServiceClient extends __Client< readonly config: LexModelBuildingServiceClientResolvedConfig; constructor(configuration: LexModelBuildingServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lex-model-building-service/runtimeConfig.browser.ts b/clients/client-lex-model-building-service/runtimeConfig.browser.ts index adb1c99ef4ed0..a93051744aa01 100644 --- a/clients/client-lex-model-building-service/runtimeConfig.browser.ts +++ b/clients/client-lex-model-building-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LexModelBuildingServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexModelBuildingServiceClientConfig } from "./LexModelBuildingServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexModelBuildingServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-model-building-service/runtimeConfig.native.ts b/clients/client-lex-model-building-service/runtimeConfig.native.ts index 48179f9ace7b4..782012a13f587 100644 --- a/clients/client-lex-model-building-service/runtimeConfig.native.ts +++ b/clients/client-lex-model-building-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LexModelBuildingServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LexModelBuildingServiceClientConfig } from "./LexModelBuildingServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LexModelBuildingServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lex-model-building-service/runtimeConfig.shared.ts b/clients/client-lex-model-building-service/runtimeConfig.shared.ts index 1b7e3955744ca..375e02df6627c 100644 --- a/clients/client-lex-model-building-service/runtimeConfig.shared.ts +++ b/clients/client-lex-model-building-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LexModelBuildingServiceClientConfig } from "./LexModelBuildingServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LexModelBuildingServiceClientConfig) => ({ apiVersion: "2017-04-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lex Model Building Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lex Model Building Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lex-model-building-service/runtimeConfig.ts b/clients/client-lex-model-building-service/runtimeConfig.ts index f76265d9592e1..aab767216da75 100644 --- a/clients/client-lex-model-building-service/runtimeConfig.ts +++ b/clients/client-lex-model-building-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LexModelBuildingServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexModelBuildingServiceClientConfig } from "./LexModelBuildingServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexModelBuildingServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-models-v2/LexModelsV2Client.ts b/clients/client-lex-models-v2/LexModelsV2Client.ts index e33e6261a63be..a41b54a9ea631 100644 --- a/clients/client-lex-models-v2/LexModelsV2Client.ts +++ b/clients/client-lex-models-v2/LexModelsV2Client.ts @@ -78,7 +78,7 @@ import { } from "./commands/UpdateResourcePolicyCommand"; import { UpdateSlotCommandInput, UpdateSlotCommandOutput } from "./commands/UpdateSlotCommand"; import { UpdateSlotTypeCommandInput, UpdateSlotTypeCommandOutput } from "./commands/UpdateSlotTypeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -400,10 +400,7 @@ export class LexModelsV2Client extends __Client< readonly config: LexModelsV2ClientResolvedConfig; constructor(configuration: LexModelsV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lex-models-v2/runtimeConfig.browser.ts b/clients/client-lex-models-v2/runtimeConfig.browser.ts index 1bbf9beb8585d..7a7b9d7737523 100644 --- a/clients/client-lex-models-v2/runtimeConfig.browser.ts +++ b/clients/client-lex-models-v2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LexModelsV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexModelsV2ClientConfig } from "./LexModelsV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexModelsV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-models-v2/runtimeConfig.native.ts b/clients/client-lex-models-v2/runtimeConfig.native.ts index eb628367ab0f4..40c02fd41fb29 100644 --- a/clients/client-lex-models-v2/runtimeConfig.native.ts +++ b/clients/client-lex-models-v2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LexModelsV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LexModelsV2ClientConfig } from "./LexModelsV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LexModelsV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lex-models-v2/runtimeConfig.shared.ts b/clients/client-lex-models-v2/runtimeConfig.shared.ts index 0f0e47890046b..40a3a1fd6576b 100644 --- a/clients/client-lex-models-v2/runtimeConfig.shared.ts +++ b/clients/client-lex-models-v2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LexModelsV2ClientConfig } from "./LexModelsV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LexModelsV2ClientConfig) => ({ apiVersion: "2020-08-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lex Models V2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lex Models V2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lex-models-v2/runtimeConfig.ts b/clients/client-lex-models-v2/runtimeConfig.ts index 208b80159c5ef..f2cbbe6d9d121 100644 --- a/clients/client-lex-models-v2/runtimeConfig.ts +++ b/clients/client-lex-models-v2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LexModelsV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexModelsV2ClientConfig } from "./LexModelsV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexModelsV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-runtime-service/LexRuntimeServiceClient.ts b/clients/client-lex-runtime-service/LexRuntimeServiceClient.ts index 4f67c4f0196a5..491fed020d757 100644 --- a/clients/client-lex-runtime-service/LexRuntimeServiceClient.ts +++ b/clients/client-lex-runtime-service/LexRuntimeServiceClient.ts @@ -3,7 +3,7 @@ import { GetSessionCommandInput, GetSessionCommandOutput } from "./commands/GetS import { PostContentCommandInput, PostContentCommandOutput } from "./commands/PostContentCommand"; import { PostTextCommandInput, PostTextCommandOutput } from "./commands/PostTextCommand"; import { PutSessionCommandInput, PutSessionCommandOutput } from "./commands/PutSessionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -234,10 +234,7 @@ export class LexRuntimeServiceClient extends __Client< readonly config: LexRuntimeServiceClientResolvedConfig; constructor(configuration: LexRuntimeServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lex-runtime-service/runtimeConfig.browser.ts b/clients/client-lex-runtime-service/runtimeConfig.browser.ts index 3eeeb370dfd40..53deb97ce5fcd 100644 --- a/clients/client-lex-runtime-service/runtimeConfig.browser.ts +++ b/clients/client-lex-runtime-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LexRuntimeServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-runtime-service/runtimeConfig.native.ts b/clients/client-lex-runtime-service/runtimeConfig.native.ts index 47a39dfd51d78..42836d1de452d 100644 --- a/clients/client-lex-runtime-service/runtimeConfig.native.ts +++ b/clients/client-lex-runtime-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LexRuntimeServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lex-runtime-service/runtimeConfig.shared.ts b/clients/client-lex-runtime-service/runtimeConfig.shared.ts index bd722efdcc3da..95d4cfecfddea 100644 --- a/clients/client-lex-runtime-service/runtimeConfig.shared.ts +++ b/clients/client-lex-runtime-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => ({ apiVersion: "2016-11-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lex Runtime Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lex Runtime Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lex-runtime-service/runtimeConfig.ts b/clients/client-lex-runtime-service/runtimeConfig.ts index d0279c49aa19e..5998674c0f9dd 100644 --- a/clients/client-lex-runtime-service/runtimeConfig.ts +++ b/clients/client-lex-runtime-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LexRuntimeServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexRuntimeServiceClientConfig } from "./LexRuntimeServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexRuntimeServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-runtime-v2/LexRuntimeV2Client.ts b/clients/client-lex-runtime-v2/LexRuntimeV2Client.ts index ff3671c5e9e7d..2af2b66ab7525 100644 --- a/clients/client-lex-runtime-v2/LexRuntimeV2Client.ts +++ b/clients/client-lex-runtime-v2/LexRuntimeV2Client.ts @@ -4,7 +4,7 @@ import { PutSessionCommandInput, PutSessionCommandOutput } from "./commands/PutS import { RecognizeTextCommandInput, RecognizeTextCommandOutput } from "./commands/RecognizeTextCommand"; import { RecognizeUtteranceCommandInput, RecognizeUtteranceCommandOutput } from "./commands/RecognizeUtteranceCommand"; import { StartConversationCommandInput, StartConversationCommandOutput } from "./commands/StartConversationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -253,10 +253,7 @@ export class LexRuntimeV2Client extends __Client< readonly config: LexRuntimeV2ClientResolvedConfig; constructor(configuration: LexRuntimeV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lex-runtime-v2/runtimeConfig.browser.ts b/clients/client-lex-runtime-v2/runtimeConfig.browser.ts index 3e42011ace83d..8740dc76753bd 100644 --- a/clients/client-lex-runtime-v2/runtimeConfig.browser.ts +++ b/clients/client-lex-runtime-v2/runtimeConfig.browser.ts @@ -9,33 +9,37 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LexRuntimeV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamPayloadHandlerProvider: () => ({ - handle: invalidFunction("event stream request is not supported in browser."), - }), - eventStreamSerdeProvider, - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamPayloadHandlerProvider: + config.eventStreamPayloadHandlerProvider ?? + (() => ({ handle: invalidFunction("event stream request is not supported in browser.") })), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lex-runtime-v2/runtimeConfig.native.ts b/clients/client-lex-runtime-v2/runtimeConfig.native.ts index 21acc3d5869f5..7759af6b6fb21 100644 --- a/clients/client-lex-runtime-v2/runtimeConfig.native.ts +++ b/clients/client-lex-runtime-v2/runtimeConfig.native.ts @@ -1,16 +1,20 @@ import { Sha256 } from "@aws-crypto/sha256-js"; import { invalidFunction } from "@aws-sdk/invalid-dependency"; -import { ClientDefaults } from "./LexRuntimeV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - eventStreamPayloadHandlerProvider: () => ({ - handle: invalidFunction("event stream request is not supported in ReactNative."), - }), - sha256: Sha256, +export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + eventStreamPayloadHandlerProvider: + config.eventStreamPayloadHandlerProvider ?? + (() => ({ handle: invalidFunction("event stream request is not supported in ReactNative.") })), + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lex-runtime-v2/runtimeConfig.shared.ts b/clients/client-lex-runtime-v2/runtimeConfig.shared.ts index a4659c2c8f3ea..5f49afca340b8 100644 --- a/clients/client-lex-runtime-v2/runtimeConfig.shared.ts +++ b/clients/client-lex-runtime-v2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => ({ apiVersion: "2020-08-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lex Runtime V2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lex Runtime V2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lex-runtime-v2/runtimeConfig.ts b/clients/client-lex-runtime-v2/runtimeConfig.ts index e2292120f3857..e295fa3332f59 100644 --- a/clients/client-lex-runtime-v2/runtimeConfig.ts +++ b/clients/client-lex-runtime-v2/runtimeConfig.ts @@ -13,31 +13,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LexRuntimeV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LexRuntimeV2ClientConfig } from "./LexRuntimeV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamPayloadHandlerProvider, - eventStreamSerdeProvider, - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttp2Handler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LexRuntimeV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamPayloadHandlerProvider: config.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider, + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttp2Handler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-license-manager/LicenseManagerClient.ts b/clients/client-license-manager/LicenseManagerClient.ts index dfd9b1ee2750e..9624bc11b9f23 100644 --- a/clients/client-license-manager/LicenseManagerClient.ts +++ b/clients/client-license-manager/LicenseManagerClient.ts @@ -115,7 +115,7 @@ import { UpdateServiceSettingsCommandInput, UpdateServiceSettingsCommandOutput, } from "./commands/UpdateServiceSettingsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -417,10 +417,7 @@ export class LicenseManagerClient extends __Client< readonly config: LicenseManagerClientResolvedConfig; constructor(configuration: LicenseManagerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-license-manager/runtimeConfig.browser.ts b/clients/client-license-manager/runtimeConfig.browser.ts index 2d37df8932ea2..6763167e54abd 100644 --- a/clients/client-license-manager/runtimeConfig.browser.ts +++ b/clients/client-license-manager/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LicenseManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LicenseManagerClientConfig } from "./LicenseManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LicenseManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-license-manager/runtimeConfig.native.ts b/clients/client-license-manager/runtimeConfig.native.ts index 170c47b73b9d4..acbb4326de394 100644 --- a/clients/client-license-manager/runtimeConfig.native.ts +++ b/clients/client-license-manager/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LicenseManagerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LicenseManagerClientConfig } from "./LicenseManagerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LicenseManagerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-license-manager/runtimeConfig.shared.ts b/clients/client-license-manager/runtimeConfig.shared.ts index 5e116a37df732..f58e465766d79 100644 --- a/clients/client-license-manager/runtimeConfig.shared.ts +++ b/clients/client-license-manager/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LicenseManagerClientConfig } from "./LicenseManagerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LicenseManagerClientConfig) => ({ apiVersion: "2018-08-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "License Manager", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "License Manager", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-license-manager/runtimeConfig.ts b/clients/client-license-manager/runtimeConfig.ts index bf9acae1ec557..3e15122a7bd29 100644 --- a/clients/client-license-manager/runtimeConfig.ts +++ b/clients/client-license-manager/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LicenseManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LicenseManagerClientConfig } from "./LicenseManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LicenseManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lightsail/LightsailClient.ts b/clients/client-lightsail/LightsailClient.ts index a4c6c17481e59..6a6e84c7c9dfa 100644 --- a/clients/client-lightsail/LightsailClient.ts +++ b/clients/client-lightsail/LightsailClient.ts @@ -376,7 +376,7 @@ import { UpdateRelationalDatabaseParametersCommandInput, UpdateRelationalDatabaseParametersCommandOutput, } from "./commands/UpdateRelationalDatabaseParametersCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -906,10 +906,7 @@ export class LightsailClient extends __Client< readonly config: LightsailClientResolvedConfig; constructor(configuration: LightsailClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lightsail/runtimeConfig.browser.ts b/clients/client-lightsail/runtimeConfig.browser.ts index c267e16a6e41f..37dcab8839fa8 100644 --- a/clients/client-lightsail/runtimeConfig.browser.ts +++ b/clients/client-lightsail/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LightsailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LightsailClientConfig } from "./LightsailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LightsailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lightsail/runtimeConfig.native.ts b/clients/client-lightsail/runtimeConfig.native.ts index 219a2c0e22630..96fbee9722f2b 100644 --- a/clients/client-lightsail/runtimeConfig.native.ts +++ b/clients/client-lightsail/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LightsailClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LightsailClientConfig } from "./LightsailClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LightsailClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lightsail/runtimeConfig.shared.ts b/clients/client-lightsail/runtimeConfig.shared.ts index 2c47929bec5ff..5891055cb9bab 100644 --- a/clients/client-lightsail/runtimeConfig.shared.ts +++ b/clients/client-lightsail/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LightsailClientConfig } from "./LightsailClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LightsailClientConfig) => ({ apiVersion: "2016-11-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Lightsail", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Lightsail", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lightsail/runtimeConfig.ts b/clients/client-lightsail/runtimeConfig.ts index 6e4f3b56c4895..35fcfd8d5ce01 100644 --- a/clients/client-lightsail/runtimeConfig.ts +++ b/clients/client-lightsail/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LightsailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LightsailClientConfig } from "./LightsailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LightsailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-location/LocationClient.ts b/clients/client-location/LocationClient.ts index 9cf3debf389b1..b3158eda9f440 100644 --- a/clients/client-location/LocationClient.ts +++ b/clients/client-location/LocationClient.ts @@ -109,7 +109,7 @@ import { } from "./commands/SearchPlaceIndexForTextCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -409,10 +409,7 @@ export class LocationClient extends __Client< readonly config: LocationClientResolvedConfig; constructor(configuration: LocationClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-location/runtimeConfig.browser.ts b/clients/client-location/runtimeConfig.browser.ts index dddd368016a44..f0f11dc436a2f 100644 --- a/clients/client-location/runtimeConfig.browser.ts +++ b/clients/client-location/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LocationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LocationClientConfig } from "./LocationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LocationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-location/runtimeConfig.native.ts b/clients/client-location/runtimeConfig.native.ts index 59dd64cafe763..dc5e90f6305d6 100644 --- a/clients/client-location/runtimeConfig.native.ts +++ b/clients/client-location/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LocationClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LocationClientConfig } from "./LocationClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LocationClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-location/runtimeConfig.shared.ts b/clients/client-location/runtimeConfig.shared.ts index 1331dcb812bc9..e1465543f59e6 100644 --- a/clients/client-location/runtimeConfig.shared.ts +++ b/clients/client-location/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LocationClientConfig } from "./LocationClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LocationClientConfig) => ({ apiVersion: "2020-11-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Location", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Location", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-location/runtimeConfig.ts b/clients/client-location/runtimeConfig.ts index 7b111b0db8d89..0e91bf395fcbb 100644 --- a/clients/client-location/runtimeConfig.ts +++ b/clients/client-location/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LocationClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LocationClientConfig } from "./LocationClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LocationClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutequipment/LookoutEquipmentClient.ts b/clients/client-lookoutequipment/LookoutEquipmentClient.ts index d2c4efa977173..aa319182ba922 100644 --- a/clients/client-lookoutequipment/LookoutEquipmentClient.ts +++ b/clients/client-lookoutequipment/LookoutEquipmentClient.ts @@ -56,7 +56,7 @@ import { UpdateInferenceSchedulerCommandInput, UpdateInferenceSchedulerCommandOutput, } from "./commands/UpdateInferenceSchedulerCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -311,10 +311,7 @@ export class LookoutEquipmentClient extends __Client< readonly config: LookoutEquipmentClientResolvedConfig; constructor(configuration: LookoutEquipmentClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lookoutequipment/runtimeConfig.browser.ts b/clients/client-lookoutequipment/runtimeConfig.browser.ts index 50fc764ff6e28..3bbbd3d6b0768 100644 --- a/clients/client-lookoutequipment/runtimeConfig.browser.ts +++ b/clients/client-lookoutequipment/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LookoutEquipmentClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutEquipmentClientConfig } from "./LookoutEquipmentClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutEquipmentClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutequipment/runtimeConfig.native.ts b/clients/client-lookoutequipment/runtimeConfig.native.ts index 91bde55e2bd06..e2d82f55e76ef 100644 --- a/clients/client-lookoutequipment/runtimeConfig.native.ts +++ b/clients/client-lookoutequipment/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LookoutEquipmentClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LookoutEquipmentClientConfig } from "./LookoutEquipmentClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LookoutEquipmentClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lookoutequipment/runtimeConfig.shared.ts b/clients/client-lookoutequipment/runtimeConfig.shared.ts index 431e3f44c50a6..0150d461a4618 100644 --- a/clients/client-lookoutequipment/runtimeConfig.shared.ts +++ b/clients/client-lookoutequipment/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LookoutEquipmentClientConfig } from "./LookoutEquipmentClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LookoutEquipmentClientConfig) => ({ apiVersion: "2020-12-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "LookoutEquipment", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "LookoutEquipment", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lookoutequipment/runtimeConfig.ts b/clients/client-lookoutequipment/runtimeConfig.ts index bc076ecf671e5..4ad2507111d8b 100644 --- a/clients/client-lookoutequipment/runtimeConfig.ts +++ b/clients/client-lookoutequipment/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LookoutEquipmentClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutEquipmentClientConfig } from "./LookoutEquipmentClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutEquipmentClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutmetrics/LookoutMetricsClient.ts b/clients/client-lookoutmetrics/LookoutMetricsClient.ts index 14a592bab2fbf..1a4a73e67d051 100644 --- a/clients/client-lookoutmetrics/LookoutMetricsClient.ts +++ b/clients/client-lookoutmetrics/LookoutMetricsClient.ts @@ -56,7 +56,7 @@ import { UpdateAnomalyDetectorCommandOutput, } from "./commands/UpdateAnomalyDetectorCommand"; import { UpdateMetricSetCommandInput, UpdateMetricSetCommandOutput } from "./commands/UpdateMetricSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -318,10 +318,7 @@ export class LookoutMetricsClient extends __Client< readonly config: LookoutMetricsClientResolvedConfig; constructor(configuration: LookoutMetricsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lookoutmetrics/runtimeConfig.browser.ts b/clients/client-lookoutmetrics/runtimeConfig.browser.ts index 6e58ef020b702..d08d93cee7cd0 100644 --- a/clients/client-lookoutmetrics/runtimeConfig.browser.ts +++ b/clients/client-lookoutmetrics/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LookoutMetricsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutMetricsClientConfig } from "./LookoutMetricsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutMetricsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutmetrics/runtimeConfig.native.ts b/clients/client-lookoutmetrics/runtimeConfig.native.ts index cb0d80a169004..69623a0fc2c63 100644 --- a/clients/client-lookoutmetrics/runtimeConfig.native.ts +++ b/clients/client-lookoutmetrics/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LookoutMetricsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LookoutMetricsClientConfig } from "./LookoutMetricsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LookoutMetricsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lookoutmetrics/runtimeConfig.shared.ts b/clients/client-lookoutmetrics/runtimeConfig.shared.ts index 72373fa69ca38..69eb25ecbce1e 100644 --- a/clients/client-lookoutmetrics/runtimeConfig.shared.ts +++ b/clients/client-lookoutmetrics/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LookoutMetricsClientConfig } from "./LookoutMetricsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LookoutMetricsClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "LookoutMetrics", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "LookoutMetrics", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lookoutmetrics/runtimeConfig.ts b/clients/client-lookoutmetrics/runtimeConfig.ts index b3fa3b25b6edf..4ba43e40be556 100644 --- a/clients/client-lookoutmetrics/runtimeConfig.ts +++ b/clients/client-lookoutmetrics/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LookoutMetricsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutMetricsClientConfig } from "./LookoutMetricsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutMetricsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutvision/LookoutVisionClient.ts b/clients/client-lookoutvision/LookoutVisionClient.ts index 9cf6dd05e0c9f..e11ffdee75af9 100644 --- a/clients/client-lookoutvision/LookoutVisionClient.ts +++ b/clients/client-lookoutvision/LookoutVisionClient.ts @@ -23,7 +23,7 @@ import { UpdateDatasetEntriesCommandInput, UpdateDatasetEntriesCommandOutput, } from "./commands/UpdateDatasetEntriesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -277,10 +277,7 @@ export class LookoutVisionClient extends __Client< readonly config: LookoutVisionClientResolvedConfig; constructor(configuration: LookoutVisionClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-lookoutvision/runtimeConfig.browser.ts b/clients/client-lookoutvision/runtimeConfig.browser.ts index fa3e3c210bff5..189c12bae4915 100644 --- a/clients/client-lookoutvision/runtimeConfig.browser.ts +++ b/clients/client-lookoutvision/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./LookoutVisionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutVisionClientConfig } from "./LookoutVisionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutVisionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-lookoutvision/runtimeConfig.native.ts b/clients/client-lookoutvision/runtimeConfig.native.ts index 24c0b654162cc..21110b8630bf3 100644 --- a/clients/client-lookoutvision/runtimeConfig.native.ts +++ b/clients/client-lookoutvision/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./LookoutVisionClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { LookoutVisionClientConfig } from "./LookoutVisionClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: LookoutVisionClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-lookoutvision/runtimeConfig.shared.ts b/clients/client-lookoutvision/runtimeConfig.shared.ts index dd3d2158fe7e4..2b92cd9bd350a 100644 --- a/clients/client-lookoutvision/runtimeConfig.shared.ts +++ b/clients/client-lookoutvision/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { LookoutVisionClientConfig } from "./LookoutVisionClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: LookoutVisionClientConfig) => ({ apiVersion: "2020-11-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "LookoutVision", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "LookoutVision", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-lookoutvision/runtimeConfig.ts b/clients/client-lookoutvision/runtimeConfig.ts index bcb4cbc64f669..977aedcee071a 100644 --- a/clients/client-lookoutvision/runtimeConfig.ts +++ b/clients/client-lookoutvision/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./LookoutVisionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { LookoutVisionClientConfig } from "./LookoutVisionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: LookoutVisionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-machine-learning/MachineLearningClient.ts b/clients/client-machine-learning/MachineLearningClient.ts index d999252c01970..91951b75f1302 100644 --- a/clients/client-machine-learning/MachineLearningClient.ts +++ b/clients/client-machine-learning/MachineLearningClient.ts @@ -59,7 +59,7 @@ import { import { UpdateDataSourceCommandInput, UpdateDataSourceCommandOutput } from "./commands/UpdateDataSourceCommand"; import { UpdateEvaluationCommandInput, UpdateEvaluationCommandOutput } from "./commands/UpdateEvaluationCommand"; import { UpdateMLModelCommandInput, UpdateMLModelCommandOutput } from "./commands/UpdateMLModelCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -326,10 +326,7 @@ export class MachineLearningClient extends __Client< readonly config: MachineLearningClientResolvedConfig; constructor(configuration: MachineLearningClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-machine-learning/runtimeConfig.browser.ts b/clients/client-machine-learning/runtimeConfig.browser.ts index c449a20238bc1..6e32aca7c09ea 100644 --- a/clients/client-machine-learning/runtimeConfig.browser.ts +++ b/clients/client-machine-learning/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MachineLearningClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MachineLearningClientConfig } from "./MachineLearningClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MachineLearningClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-machine-learning/runtimeConfig.native.ts b/clients/client-machine-learning/runtimeConfig.native.ts index 740fd477d9156..6842d86b340a0 100644 --- a/clients/client-machine-learning/runtimeConfig.native.ts +++ b/clients/client-machine-learning/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MachineLearningClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MachineLearningClientConfig } from "./MachineLearningClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MachineLearningClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-machine-learning/runtimeConfig.shared.ts b/clients/client-machine-learning/runtimeConfig.shared.ts index 2e9cf58b899af..5c7984e2685b7 100644 --- a/clients/client-machine-learning/runtimeConfig.shared.ts +++ b/clients/client-machine-learning/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MachineLearningClientConfig } from "./MachineLearningClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MachineLearningClientConfig) => ({ apiVersion: "2014-12-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Machine Learning", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Machine Learning", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-machine-learning/runtimeConfig.ts b/clients/client-machine-learning/runtimeConfig.ts index 6b2d8793aa679..37e55ec0a9296 100644 --- a/clients/client-machine-learning/runtimeConfig.ts +++ b/clients/client-machine-learning/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MachineLearningClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MachineLearningClientConfig } from "./MachineLearningClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MachineLearningClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-macie/MacieClient.ts b/clients/client-macie/MacieClient.ts index df2e5360e5a0a..b22ff250e4f94 100644 --- a/clients/client-macie/MacieClient.ts +++ b/clients/client-macie/MacieClient.ts @@ -17,7 +17,7 @@ import { import { ListMemberAccountsCommandInput, ListMemberAccountsCommandOutput } from "./commands/ListMemberAccountsCommand"; import { ListS3ResourcesCommandInput, ListS3ResourcesCommandOutput } from "./commands/ListS3ResourcesCommand"; import { UpdateS3ResourcesCommandInput, UpdateS3ResourcesCommandOutput } from "./commands/UpdateS3ResourcesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -247,10 +247,7 @@ export class MacieClient extends __Client< readonly config: MacieClientResolvedConfig; constructor(configuration: MacieClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-macie/runtimeConfig.browser.ts b/clients/client-macie/runtimeConfig.browser.ts index eb2997e5c4f50..ea5222a1a9c13 100644 --- a/clients/client-macie/runtimeConfig.browser.ts +++ b/clients/client-macie/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MacieClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MacieClientConfig } from "./MacieClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MacieClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-macie/runtimeConfig.native.ts b/clients/client-macie/runtimeConfig.native.ts index ebe86b2f76443..9761cf41075f9 100644 --- a/clients/client-macie/runtimeConfig.native.ts +++ b/clients/client-macie/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MacieClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MacieClientConfig } from "./MacieClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MacieClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-macie/runtimeConfig.shared.ts b/clients/client-macie/runtimeConfig.shared.ts index 5b577b77e595d..cdfcde30d2636 100644 --- a/clients/client-macie/runtimeConfig.shared.ts +++ b/clients/client-macie/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MacieClientConfig } from "./MacieClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MacieClientConfig) => ({ apiVersion: "2017-12-19", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Macie", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Macie", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-macie/runtimeConfig.ts b/clients/client-macie/runtimeConfig.ts index b5726e6adec17..2d4531519f70a 100644 --- a/clients/client-macie/runtimeConfig.ts +++ b/clients/client-macie/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MacieClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MacieClientConfig } from "./MacieClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MacieClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-macie2/Macie2Client.ts b/clients/client-macie2/Macie2Client.ts index 03c90964a7dbe..23f9f036de9ff 100644 --- a/clients/client-macie2/Macie2Client.ts +++ b/clients/client-macie2/Macie2Client.ts @@ -150,7 +150,7 @@ import { UpdateOrganizationConfigurationCommandInput, UpdateOrganizationConfigurationCommandOutput, } from "./commands/UpdateOrganizationConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -472,10 +472,7 @@ export class Macie2Client extends __Client< readonly config: Macie2ClientResolvedConfig; constructor(configuration: Macie2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-macie2/runtimeConfig.browser.ts b/clients/client-macie2/runtimeConfig.browser.ts index 63705475496b0..79b12691291d6 100644 --- a/clients/client-macie2/runtimeConfig.browser.ts +++ b/clients/client-macie2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./Macie2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Macie2ClientConfig } from "./Macie2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Macie2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-macie2/runtimeConfig.native.ts b/clients/client-macie2/runtimeConfig.native.ts index 5a743cc09da3a..b4f8d93069ed0 100644 --- a/clients/client-macie2/runtimeConfig.native.ts +++ b/clients/client-macie2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./Macie2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { Macie2ClientConfig } from "./Macie2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: Macie2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-macie2/runtimeConfig.shared.ts b/clients/client-macie2/runtimeConfig.shared.ts index 5872b92bbddc6..0d668c406a639 100644 --- a/clients/client-macie2/runtimeConfig.shared.ts +++ b/clients/client-macie2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { Macie2ClientConfig } from "./Macie2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: Macie2ClientConfig) => ({ apiVersion: "2020-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Macie2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Macie2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-macie2/runtimeConfig.ts b/clients/client-macie2/runtimeConfig.ts index a9bad63ad35ba..ee87d5c61aaa0 100644 --- a/clients/client-macie2/runtimeConfig.ts +++ b/clients/client-macie2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./Macie2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Macie2ClientConfig } from "./Macie2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Macie2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-managedblockchain/ManagedBlockchainClient.ts b/clients/client-managedblockchain/ManagedBlockchainClient.ts index 64e0368d89365..112bd50ab712c 100644 --- a/clients/client-managedblockchain/ManagedBlockchainClient.ts +++ b/clients/client-managedblockchain/ManagedBlockchainClient.ts @@ -24,7 +24,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateMemberCommandInput, UpdateMemberCommandOutput } from "./commands/UpdateMemberCommand"; import { UpdateNodeCommandInput, UpdateNodeCommandOutput } from "./commands/UpdateNodeCommand"; import { VoteOnProposalCommandInput, VoteOnProposalCommandOutput } from "./commands/VoteOnProposalCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -283,10 +283,7 @@ export class ManagedBlockchainClient extends __Client< readonly config: ManagedBlockchainClientResolvedConfig; constructor(configuration: ManagedBlockchainClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-managedblockchain/runtimeConfig.browser.ts b/clients/client-managedblockchain/runtimeConfig.browser.ts index 17007163b391a..e0c98bff5e1f7 100644 --- a/clients/client-managedblockchain/runtimeConfig.browser.ts +++ b/clients/client-managedblockchain/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ManagedBlockchainClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ManagedBlockchainClientConfig } from "./ManagedBlockchainClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ManagedBlockchainClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-managedblockchain/runtimeConfig.native.ts b/clients/client-managedblockchain/runtimeConfig.native.ts index bf01aa9c52752..8158e30ac5a03 100644 --- a/clients/client-managedblockchain/runtimeConfig.native.ts +++ b/clients/client-managedblockchain/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ManagedBlockchainClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ManagedBlockchainClientConfig } from "./ManagedBlockchainClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ManagedBlockchainClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-managedblockchain/runtimeConfig.shared.ts b/clients/client-managedblockchain/runtimeConfig.shared.ts index dc908d2f68ce2..eaa5d25fbd362 100644 --- a/clients/client-managedblockchain/runtimeConfig.shared.ts +++ b/clients/client-managedblockchain/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ManagedBlockchainClientConfig } from "./ManagedBlockchainClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ManagedBlockchainClientConfig) => ({ apiVersion: "2018-09-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ManagedBlockchain", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ManagedBlockchain", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-managedblockchain/runtimeConfig.ts b/clients/client-managedblockchain/runtimeConfig.ts index 9acbc1284ab91..6d19c044e279b 100644 --- a/clients/client-managedblockchain/runtimeConfig.ts +++ b/clients/client-managedblockchain/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ManagedBlockchainClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ManagedBlockchainClientConfig } from "./ManagedBlockchainClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ManagedBlockchainClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-catalog/MarketplaceCatalogClient.ts b/clients/client-marketplace-catalog/MarketplaceCatalogClient.ts index 86788c3a15683..815861c0e9fe8 100644 --- a/clients/client-marketplace-catalog/MarketplaceCatalogClient.ts +++ b/clients/client-marketplace-catalog/MarketplaceCatalogClient.ts @@ -4,7 +4,7 @@ import { DescribeEntityCommandInput, DescribeEntityCommandOutput } from "./comma import { ListChangeSetsCommandInput, ListChangeSetsCommandOutput } from "./commands/ListChangeSetsCommand"; import { ListEntitiesCommandInput, ListEntitiesCommandOutput } from "./commands/ListEntitiesCommand"; import { StartChangeSetCommandInput, StartChangeSetCommandOutput } from "./commands/StartChangeSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -232,10 +232,7 @@ export class MarketplaceCatalogClient extends __Client< readonly config: MarketplaceCatalogClientResolvedConfig; constructor(configuration: MarketplaceCatalogClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-marketplace-catalog/runtimeConfig.browser.ts b/clients/client-marketplace-catalog/runtimeConfig.browser.ts index 10c5db77e685a..0bcb2b9431576 100644 --- a/clients/client-marketplace-catalog/runtimeConfig.browser.ts +++ b/clients/client-marketplace-catalog/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MarketplaceCatalogClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceCatalogClientConfig } from "./MarketplaceCatalogClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceCatalogClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-catalog/runtimeConfig.native.ts b/clients/client-marketplace-catalog/runtimeConfig.native.ts index 71011af852c4e..5ea89c06b7ffb 100644 --- a/clients/client-marketplace-catalog/runtimeConfig.native.ts +++ b/clients/client-marketplace-catalog/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MarketplaceCatalogClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MarketplaceCatalogClientConfig } from "./MarketplaceCatalogClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MarketplaceCatalogClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-marketplace-catalog/runtimeConfig.shared.ts b/clients/client-marketplace-catalog/runtimeConfig.shared.ts index d8db0c6ab4c0c..2ea07c1177d65 100644 --- a/clients/client-marketplace-catalog/runtimeConfig.shared.ts +++ b/clients/client-marketplace-catalog/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MarketplaceCatalogClientConfig } from "./MarketplaceCatalogClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MarketplaceCatalogClientConfig) => ({ apiVersion: "2018-09-17", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Marketplace Catalog", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Marketplace Catalog", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-marketplace-catalog/runtimeConfig.ts b/clients/client-marketplace-catalog/runtimeConfig.ts index 22e4c96bf62a5..1ead06a0bc932 100644 --- a/clients/client-marketplace-catalog/runtimeConfig.ts +++ b/clients/client-marketplace-catalog/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MarketplaceCatalogClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceCatalogClientConfig } from "./MarketplaceCatalogClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceCatalogClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-commerce-analytics/MarketplaceCommerceAnalyticsClient.ts b/clients/client-marketplace-commerce-analytics/MarketplaceCommerceAnalyticsClient.ts index be410d380f02b..22006d5a80f9a 100644 --- a/clients/client-marketplace-commerce-analytics/MarketplaceCommerceAnalyticsClient.ts +++ b/clients/client-marketplace-commerce-analytics/MarketplaceCommerceAnalyticsClient.ts @@ -3,7 +3,7 @@ import { StartSupportDataExportCommandInput, StartSupportDataExportCommandOutput, } from "./commands/StartSupportDataExportCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -214,10 +214,7 @@ export class MarketplaceCommerceAnalyticsClient extends __Client< readonly config: MarketplaceCommerceAnalyticsClientResolvedConfig; constructor(configuration: MarketplaceCommerceAnalyticsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-marketplace-commerce-analytics/runtimeConfig.browser.ts b/clients/client-marketplace-commerce-analytics/runtimeConfig.browser.ts index dd24030e1fd61..a4d95a572634a 100644 --- a/clients/client-marketplace-commerce-analytics/runtimeConfig.browser.ts +++ b/clients/client-marketplace-commerce-analytics/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MarketplaceCommerceAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceCommerceAnalyticsClientConfig } from "./MarketplaceCommerceAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceCommerceAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-commerce-analytics/runtimeConfig.native.ts b/clients/client-marketplace-commerce-analytics/runtimeConfig.native.ts index 8e4ffaa2cd972..9624ca81b9508 100644 --- a/clients/client-marketplace-commerce-analytics/runtimeConfig.native.ts +++ b/clients/client-marketplace-commerce-analytics/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MarketplaceCommerceAnalyticsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MarketplaceCommerceAnalyticsClientConfig } from "./MarketplaceCommerceAnalyticsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MarketplaceCommerceAnalyticsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-marketplace-commerce-analytics/runtimeConfig.shared.ts b/clients/client-marketplace-commerce-analytics/runtimeConfig.shared.ts index 14908724025af..063c145fc639a 100644 --- a/clients/client-marketplace-commerce-analytics/runtimeConfig.shared.ts +++ b/clients/client-marketplace-commerce-analytics/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MarketplaceCommerceAnalyticsClientConfig } from "./MarketplaceCommerceAnalyticsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MarketplaceCommerceAnalyticsClientConfig) => ({ apiVersion: "2015-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Marketplace Commerce Analytics", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Marketplace Commerce Analytics", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-marketplace-commerce-analytics/runtimeConfig.ts b/clients/client-marketplace-commerce-analytics/runtimeConfig.ts index c392e298a61f3..8ba61381f1b6f 100644 --- a/clients/client-marketplace-commerce-analytics/runtimeConfig.ts +++ b/clients/client-marketplace-commerce-analytics/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MarketplaceCommerceAnalyticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceCommerceAnalyticsClientConfig } from "./MarketplaceCommerceAnalyticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceCommerceAnalyticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-entitlement-service/MarketplaceEntitlementServiceClient.ts b/clients/client-marketplace-entitlement-service/MarketplaceEntitlementServiceClient.ts index 9730a4755bb5c..abdcd563a5f3c 100644 --- a/clients/client-marketplace-entitlement-service/MarketplaceEntitlementServiceClient.ts +++ b/clients/client-marketplace-entitlement-service/MarketplaceEntitlementServiceClient.ts @@ -1,5 +1,5 @@ import { GetEntitlementsCommandInput, GetEntitlementsCommandOutput } from "./commands/GetEntitlementsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -226,10 +226,7 @@ export class MarketplaceEntitlementServiceClient extends __Client< readonly config: MarketplaceEntitlementServiceClientResolvedConfig; constructor(configuration: MarketplaceEntitlementServiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-marketplace-entitlement-service/runtimeConfig.browser.ts b/clients/client-marketplace-entitlement-service/runtimeConfig.browser.ts index b355bffe5f0b0..84ae854d1b0bd 100644 --- a/clients/client-marketplace-entitlement-service/runtimeConfig.browser.ts +++ b/clients/client-marketplace-entitlement-service/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MarketplaceEntitlementServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceEntitlementServiceClientConfig } from "./MarketplaceEntitlementServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceEntitlementServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-entitlement-service/runtimeConfig.native.ts b/clients/client-marketplace-entitlement-service/runtimeConfig.native.ts index a4e7eed644242..17515cbe98c7e 100644 --- a/clients/client-marketplace-entitlement-service/runtimeConfig.native.ts +++ b/clients/client-marketplace-entitlement-service/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MarketplaceEntitlementServiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MarketplaceEntitlementServiceClientConfig } from "./MarketplaceEntitlementServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MarketplaceEntitlementServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-marketplace-entitlement-service/runtimeConfig.shared.ts b/clients/client-marketplace-entitlement-service/runtimeConfig.shared.ts index b2d72441a1a75..7d12cdb07b53d 100644 --- a/clients/client-marketplace-entitlement-service/runtimeConfig.shared.ts +++ b/clients/client-marketplace-entitlement-service/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MarketplaceEntitlementServiceClientConfig } from "./MarketplaceEntitlementServiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MarketplaceEntitlementServiceClientConfig) => ({ apiVersion: "2017-01-11", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Marketplace Entitlement Service", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Marketplace Entitlement Service", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-marketplace-entitlement-service/runtimeConfig.ts b/clients/client-marketplace-entitlement-service/runtimeConfig.ts index 89c3e8fec579d..9ed6fadb656c6 100644 --- a/clients/client-marketplace-entitlement-service/runtimeConfig.ts +++ b/clients/client-marketplace-entitlement-service/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MarketplaceEntitlementServiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceEntitlementServiceClientConfig } from "./MarketplaceEntitlementServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceEntitlementServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-metering/MarketplaceMeteringClient.ts b/clients/client-marketplace-metering/MarketplaceMeteringClient.ts index 10a62d7c5fda6..8d821f31c2886 100644 --- a/clients/client-marketplace-metering/MarketplaceMeteringClient.ts +++ b/clients/client-marketplace-metering/MarketplaceMeteringClient.ts @@ -2,7 +2,7 @@ import { BatchMeterUsageCommandInput, BatchMeterUsageCommandOutput } from "./com import { MeterUsageCommandInput, MeterUsageCommandOutput } from "./commands/MeterUsageCommand"; import { RegisterUsageCommandInput, RegisterUsageCommandOutput } from "./commands/RegisterUsageCommand"; import { ResolveCustomerCommandInput, ResolveCustomerCommandOutput } from "./commands/ResolveCustomerCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -276,10 +276,7 @@ export class MarketplaceMeteringClient extends __Client< readonly config: MarketplaceMeteringClientResolvedConfig; constructor(configuration: MarketplaceMeteringClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-marketplace-metering/runtimeConfig.browser.ts b/clients/client-marketplace-metering/runtimeConfig.browser.ts index 70c1e1ce2d16e..39c81273d9886 100644 --- a/clients/client-marketplace-metering/runtimeConfig.browser.ts +++ b/clients/client-marketplace-metering/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MarketplaceMeteringClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceMeteringClientConfig } from "./MarketplaceMeteringClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceMeteringClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-marketplace-metering/runtimeConfig.native.ts b/clients/client-marketplace-metering/runtimeConfig.native.ts index 44b50c7a21de9..8b8292bc9850c 100644 --- a/clients/client-marketplace-metering/runtimeConfig.native.ts +++ b/clients/client-marketplace-metering/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MarketplaceMeteringClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MarketplaceMeteringClientConfig } from "./MarketplaceMeteringClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MarketplaceMeteringClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-marketplace-metering/runtimeConfig.shared.ts b/clients/client-marketplace-metering/runtimeConfig.shared.ts index 20d06e231452b..259ea3e789a77 100644 --- a/clients/client-marketplace-metering/runtimeConfig.shared.ts +++ b/clients/client-marketplace-metering/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MarketplaceMeteringClientConfig } from "./MarketplaceMeteringClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MarketplaceMeteringClientConfig) => ({ apiVersion: "2016-01-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Marketplace Metering", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Marketplace Metering", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-marketplace-metering/runtimeConfig.ts b/clients/client-marketplace-metering/runtimeConfig.ts index 1a6f821713c07..53e3784f9dfcc 100644 --- a/clients/client-marketplace-metering/runtimeConfig.ts +++ b/clients/client-marketplace-metering/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MarketplaceMeteringClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MarketplaceMeteringClientConfig } from "./MarketplaceMeteringClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MarketplaceMeteringClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediaconnect/MediaConnectClient.ts b/clients/client-mediaconnect/MediaConnectClient.ts index ea24f20f0097c..bbc5ce9294a51 100644 --- a/clients/client-mediaconnect/MediaConnectClient.ts +++ b/clients/client-mediaconnect/MediaConnectClient.ts @@ -58,7 +58,7 @@ import { } from "./commands/UpdateFlowMediaStreamCommand"; import { UpdateFlowOutputCommandInput, UpdateFlowOutputCommandOutput } from "./commands/UpdateFlowOutputCommand"; import { UpdateFlowSourceCommandInput, UpdateFlowSourceCommandOutput } from "./commands/UpdateFlowSourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -328,10 +328,7 @@ export class MediaConnectClient extends __Client< readonly config: MediaConnectClientResolvedConfig; constructor(configuration: MediaConnectClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediaconnect/runtimeConfig.browser.ts b/clients/client-mediaconnect/runtimeConfig.browser.ts index ca438c2884dab..19402b6da068f 100644 --- a/clients/client-mediaconnect/runtimeConfig.browser.ts +++ b/clients/client-mediaconnect/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaConnectClientConfig } from "./MediaConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediaconnect/runtimeConfig.native.ts b/clients/client-mediaconnect/runtimeConfig.native.ts index a842c347f9029..44cee921ec25c 100644 --- a/clients/client-mediaconnect/runtimeConfig.native.ts +++ b/clients/client-mediaconnect/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaConnectClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaConnectClientConfig } from "./MediaConnectClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaConnectClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediaconnect/runtimeConfig.shared.ts b/clients/client-mediaconnect/runtimeConfig.shared.ts index 1eb706d414fe2..8cecb4ab28ac7 100644 --- a/clients/client-mediaconnect/runtimeConfig.shared.ts +++ b/clients/client-mediaconnect/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaConnectClientConfig } from "./MediaConnectClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaConnectClientConfig) => ({ apiVersion: "2018-11-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaConnect", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaConnect", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediaconnect/runtimeConfig.ts b/clients/client-mediaconnect/runtimeConfig.ts index 2adbbec9eb065..85502d8a7df70 100644 --- a/clients/client-mediaconnect/runtimeConfig.ts +++ b/clients/client-mediaconnect/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaConnectClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaConnectClientConfig } from "./MediaConnectClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaConnectClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediaconvert/MediaConvertClient.ts b/clients/client-mediaconvert/MediaConvertClient.ts index 36b4b96927b2d..0701bf8cbeac1 100644 --- a/clients/client-mediaconvert/MediaConvertClient.ts +++ b/clients/client-mediaconvert/MediaConvertClient.ts @@ -32,7 +32,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateJobTemplateCommandInput, UpdateJobTemplateCommandOutput } from "./commands/UpdateJobTemplateCommand"; import { UpdatePresetCommandInput, UpdatePresetCommandOutput } from "./commands/UpdatePresetCommand"; import { UpdateQueueCommandInput, UpdateQueueCommandOutput } from "./commands/UpdateQueueCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -292,10 +292,7 @@ export class MediaConvertClient extends __Client< readonly config: MediaConvertClientResolvedConfig; constructor(configuration: MediaConvertClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediaconvert/runtimeConfig.browser.ts b/clients/client-mediaconvert/runtimeConfig.browser.ts index 6252a41079af0..107cf3c18f751 100644 --- a/clients/client-mediaconvert/runtimeConfig.browser.ts +++ b/clients/client-mediaconvert/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaConvertClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaConvertClientConfig } from "./MediaConvertClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaConvertClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediaconvert/runtimeConfig.native.ts b/clients/client-mediaconvert/runtimeConfig.native.ts index a43e5545e37c2..6a0ca580eb7d1 100644 --- a/clients/client-mediaconvert/runtimeConfig.native.ts +++ b/clients/client-mediaconvert/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaConvertClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaConvertClientConfig } from "./MediaConvertClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaConvertClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediaconvert/runtimeConfig.shared.ts b/clients/client-mediaconvert/runtimeConfig.shared.ts index f21a70321a52c..4e0273b13b51f 100644 --- a/clients/client-mediaconvert/runtimeConfig.shared.ts +++ b/clients/client-mediaconvert/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaConvertClientConfig } from "./MediaConvertClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaConvertClientConfig) => ({ apiVersion: "2017-08-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaConvert", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaConvert", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediaconvert/runtimeConfig.ts b/clients/client-mediaconvert/runtimeConfig.ts index 66b3587b8ba8e..cf508455f0d2a 100644 --- a/clients/client-mediaconvert/runtimeConfig.ts +++ b/clients/client-mediaconvert/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaConvertClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaConvertClientConfig } from "./MediaConvertClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaConvertClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-medialive/MediaLiveClient.ts b/clients/client-medialive/MediaLiveClient.ts index 5567a70866edb..c64abcb75b985 100644 --- a/clients/client-medialive/MediaLiveClient.ts +++ b/clients/client-medialive/MediaLiveClient.ts @@ -114,7 +114,7 @@ import { UpdateMultiplexProgramCommandOutput, } from "./commands/UpdateMultiplexProgramCommand"; import { UpdateReservationCommandInput, UpdateReservationCommandOutput } from "./commands/UpdateReservationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -436,10 +436,7 @@ export class MediaLiveClient extends __Client< readonly config: MediaLiveClientResolvedConfig; constructor(configuration: MediaLiveClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-medialive/runtimeConfig.browser.ts b/clients/client-medialive/runtimeConfig.browser.ts index cbe80e7e34154..151492f6b3025 100644 --- a/clients/client-medialive/runtimeConfig.browser.ts +++ b/clients/client-medialive/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaLiveClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaLiveClientConfig } from "./MediaLiveClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaLiveClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-medialive/runtimeConfig.native.ts b/clients/client-medialive/runtimeConfig.native.ts index 8fb78383d4b08..ed3797f0668ee 100644 --- a/clients/client-medialive/runtimeConfig.native.ts +++ b/clients/client-medialive/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaLiveClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaLiveClientConfig } from "./MediaLiveClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaLiveClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-medialive/runtimeConfig.shared.ts b/clients/client-medialive/runtimeConfig.shared.ts index fe37478106c6a..9135f59d2cba5 100644 --- a/clients/client-medialive/runtimeConfig.shared.ts +++ b/clients/client-medialive/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaLiveClientConfig } from "./MediaLiveClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaLiveClientConfig) => ({ apiVersion: "2017-10-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaLive", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaLive", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-medialive/runtimeConfig.ts b/clients/client-medialive/runtimeConfig.ts index 1c4227a37ca7a..8f88dc21bf6af 100644 --- a/clients/client-medialive/runtimeConfig.ts +++ b/clients/client-medialive/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaLiveClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaLiveClientConfig } from "./MediaLiveClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaLiveClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediapackage-vod/MediaPackageVodClient.ts b/clients/client-mediapackage-vod/MediaPackageVodClient.ts index 705c4b50d8aca..ae8c8687a0090 100644 --- a/clients/client-mediapackage-vod/MediaPackageVodClient.ts +++ b/clients/client-mediapackage-vod/MediaPackageVodClient.ts @@ -45,7 +45,7 @@ import { UpdatePackagingGroupCommandInput, UpdatePackagingGroupCommandOutput, } from "./commands/UpdatePackagingGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -289,10 +289,7 @@ export class MediaPackageVodClient extends __Client< readonly config: MediaPackageVodClientResolvedConfig; constructor(configuration: MediaPackageVodClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediapackage-vod/runtimeConfig.browser.ts b/clients/client-mediapackage-vod/runtimeConfig.browser.ts index 9fb8c743a31fb..9997c30313596 100644 --- a/clients/client-mediapackage-vod/runtimeConfig.browser.ts +++ b/clients/client-mediapackage-vod/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaPackageVodClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaPackageVodClientConfig } from "./MediaPackageVodClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaPackageVodClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediapackage-vod/runtimeConfig.native.ts b/clients/client-mediapackage-vod/runtimeConfig.native.ts index ea05c7d3e96fe..490b2d171e363 100644 --- a/clients/client-mediapackage-vod/runtimeConfig.native.ts +++ b/clients/client-mediapackage-vod/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaPackageVodClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaPackageVodClientConfig } from "./MediaPackageVodClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaPackageVodClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediapackage-vod/runtimeConfig.shared.ts b/clients/client-mediapackage-vod/runtimeConfig.shared.ts index 21ec29fcdf59a..4a0a7d0f02025 100644 --- a/clients/client-mediapackage-vod/runtimeConfig.shared.ts +++ b/clients/client-mediapackage-vod/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaPackageVodClientConfig } from "./MediaPackageVodClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaPackageVodClientConfig) => ({ apiVersion: "2018-11-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaPackage Vod", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaPackage Vod", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediapackage-vod/runtimeConfig.ts b/clients/client-mediapackage-vod/runtimeConfig.ts index 1809e089c40e7..a604f995de562 100644 --- a/clients/client-mediapackage-vod/runtimeConfig.ts +++ b/clients/client-mediapackage-vod/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaPackageVodClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaPackageVodClientConfig } from "./MediaPackageVodClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaPackageVodClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediapackage/MediaPackageClient.ts b/clients/client-mediapackage/MediaPackageClient.ts index 4bb9badb8f6b2..e18ffc136ec1e 100644 --- a/clients/client-mediapackage/MediaPackageClient.ts +++ b/clients/client-mediapackage/MediaPackageClient.ts @@ -41,7 +41,7 @@ import { UpdateOriginEndpointCommandInput, UpdateOriginEndpointCommandOutput, } from "./commands/UpdateOriginEndpointCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -289,10 +289,7 @@ export class MediaPackageClient extends __Client< readonly config: MediaPackageClientResolvedConfig; constructor(configuration: MediaPackageClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediapackage/runtimeConfig.browser.ts b/clients/client-mediapackage/runtimeConfig.browser.ts index bee8e94a1c2ff..61666e1594aa7 100644 --- a/clients/client-mediapackage/runtimeConfig.browser.ts +++ b/clients/client-mediapackage/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaPackageClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaPackageClientConfig } from "./MediaPackageClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaPackageClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediapackage/runtimeConfig.native.ts b/clients/client-mediapackage/runtimeConfig.native.ts index 16f498ee7185e..94a68712a298c 100644 --- a/clients/client-mediapackage/runtimeConfig.native.ts +++ b/clients/client-mediapackage/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaPackageClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaPackageClientConfig } from "./MediaPackageClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaPackageClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediapackage/runtimeConfig.shared.ts b/clients/client-mediapackage/runtimeConfig.shared.ts index 8204142818b7e..458c7ed644269 100644 --- a/clients/client-mediapackage/runtimeConfig.shared.ts +++ b/clients/client-mediapackage/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaPackageClientConfig } from "./MediaPackageClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaPackageClientConfig) => ({ apiVersion: "2017-10-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaPackage", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaPackage", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediapackage/runtimeConfig.ts b/clients/client-mediapackage/runtimeConfig.ts index b9856dc5b3c1a..f09912607eeb7 100644 --- a/clients/client-mediapackage/runtimeConfig.ts +++ b/clients/client-mediapackage/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaPackageClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaPackageClientConfig } from "./MediaPackageClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaPackageClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediastore-data/MediaStoreDataClient.ts b/clients/client-mediastore-data/MediaStoreDataClient.ts index 8536d9d9ea76d..d52e50b29eb28 100644 --- a/clients/client-mediastore-data/MediaStoreDataClient.ts +++ b/clients/client-mediastore-data/MediaStoreDataClient.ts @@ -3,7 +3,7 @@ import { DescribeObjectCommandInput, DescribeObjectCommandOutput } from "./comma import { GetObjectCommandInput, GetObjectCommandOutput } from "./commands/GetObjectCommand"; import { ListItemsCommandInput, ListItemsCommandOutput } from "./commands/ListItemsCommand"; import { PutObjectCommandInput, PutObjectCommandOutput } from "./commands/PutObjectCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -225,10 +225,7 @@ export class MediaStoreDataClient extends __Client< readonly config: MediaStoreDataClientResolvedConfig; constructor(configuration: MediaStoreDataClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediastore-data/runtimeConfig.browser.ts b/clients/client-mediastore-data/runtimeConfig.browser.ts index a62e587a75d35..ed1b7db9f593d 100644 --- a/clients/client-mediastore-data/runtimeConfig.browser.ts +++ b/clients/client-mediastore-data/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaStoreDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediastore-data/runtimeConfig.native.ts b/clients/client-mediastore-data/runtimeConfig.native.ts index d0a62a39d4fb8..2bf097d28c53c 100644 --- a/clients/client-mediastore-data/runtimeConfig.native.ts +++ b/clients/client-mediastore-data/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaStoreDataClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediastore-data/runtimeConfig.shared.ts b/clients/client-mediastore-data/runtimeConfig.shared.ts index c3dd7797b3de7..9511d38fbdc78 100644 --- a/clients/client-mediastore-data/runtimeConfig.shared.ts +++ b/clients/client-mediastore-data/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => ({ apiVersion: "2017-09-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaStore Data", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaStore Data", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediastore-data/runtimeConfig.ts b/clients/client-mediastore-data/runtimeConfig.ts index c8a6dce8ad880..5507b7676a35d 100644 --- a/clients/client-mediastore-data/runtimeConfig.ts +++ b/clients/client-mediastore-data/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaStoreDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaStoreDataClientConfig } from "./MediaStoreDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaStoreDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediastore/MediaStoreClient.ts b/clients/client-mediastore/MediaStoreClient.ts index 9428a50bff6f4..0d9800db9f7ed 100644 --- a/clients/client-mediastore/MediaStoreClient.ts +++ b/clients/client-mediastore/MediaStoreClient.ts @@ -28,7 +28,7 @@ import { StartAccessLoggingCommandInput, StartAccessLoggingCommandOutput } from import { StopAccessLoggingCommandInput, StopAccessLoggingCommandOutput } from "./commands/StopAccessLoggingCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -281,10 +281,7 @@ export class MediaStoreClient extends __Client< readonly config: MediaStoreClientResolvedConfig; constructor(configuration: MediaStoreClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediastore/runtimeConfig.browser.ts b/clients/client-mediastore/runtimeConfig.browser.ts index b384e785c1b4e..558513a134410 100644 --- a/clients/client-mediastore/runtimeConfig.browser.ts +++ b/clients/client-mediastore/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaStoreClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaStoreClientConfig } from "./MediaStoreClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaStoreClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediastore/runtimeConfig.native.ts b/clients/client-mediastore/runtimeConfig.native.ts index d258ec44449f5..625cca134c51c 100644 --- a/clients/client-mediastore/runtimeConfig.native.ts +++ b/clients/client-mediastore/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaStoreClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaStoreClientConfig } from "./MediaStoreClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaStoreClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediastore/runtimeConfig.shared.ts b/clients/client-mediastore/runtimeConfig.shared.ts index 0e5e9666075ee..e7fb05c9eaf77 100644 --- a/clients/client-mediastore/runtimeConfig.shared.ts +++ b/clients/client-mediastore/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaStoreClientConfig } from "./MediaStoreClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaStoreClientConfig) => ({ apiVersion: "2017-09-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaStore", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaStore", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediastore/runtimeConfig.ts b/clients/client-mediastore/runtimeConfig.ts index e14c737d66588..4456eb58d9323 100644 --- a/clients/client-mediastore/runtimeConfig.ts +++ b/clients/client-mediastore/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaStoreClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaStoreClientConfig } from "./MediaStoreClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaStoreClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediatailor/MediaTailorClient.ts b/clients/client-mediatailor/MediaTailorClient.ts index 7a0239b5ad871..4eff3a9091b34 100644 --- a/clients/client-mediatailor/MediaTailorClient.ts +++ b/clients/client-mediatailor/MediaTailorClient.ts @@ -63,7 +63,7 @@ import { UpdateSourceLocationCommandOutput, } from "./commands/UpdateSourceLocationCommand"; import { UpdateVodSourceCommandInput, UpdateVodSourceCommandOutput } from "./commands/UpdateVodSourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -337,10 +337,7 @@ export class MediaTailorClient extends __Client< readonly config: MediaTailorClientResolvedConfig; constructor(configuration: MediaTailorClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mediatailor/runtimeConfig.browser.ts b/clients/client-mediatailor/runtimeConfig.browser.ts index 9bb19ece46700..61a02ef6e9bdf 100644 --- a/clients/client-mediatailor/runtimeConfig.browser.ts +++ b/clients/client-mediatailor/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MediaTailorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaTailorClientConfig } from "./MediaTailorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaTailorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mediatailor/runtimeConfig.native.ts b/clients/client-mediatailor/runtimeConfig.native.ts index aec936c16cf99..e905f01da136a 100644 --- a/clients/client-mediatailor/runtimeConfig.native.ts +++ b/clients/client-mediatailor/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MediaTailorClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MediaTailorClientConfig } from "./MediaTailorClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MediaTailorClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mediatailor/runtimeConfig.shared.ts b/clients/client-mediatailor/runtimeConfig.shared.ts index 4f9e972d8aab2..29adcafc4a746 100644 --- a/clients/client-mediatailor/runtimeConfig.shared.ts +++ b/clients/client-mediatailor/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MediaTailorClientConfig } from "./MediaTailorClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MediaTailorClientConfig) => ({ apiVersion: "2018-04-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MediaTailor", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MediaTailor", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mediatailor/runtimeConfig.ts b/clients/client-mediatailor/runtimeConfig.ts index 5db8cc3487463..32c22c1102d44 100644 --- a/clients/client-mediatailor/runtimeConfig.ts +++ b/clients/client-mediatailor/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MediaTailorClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MediaTailorClientConfig } from "./MediaTailorClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MediaTailorClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mgn/MgnClient.ts b/clients/client-mgn/MgnClient.ts index 43e7fead248e9..eee146c12b99d 100644 --- a/clients/client-mgn/MgnClient.ts +++ b/clients/client-mgn/MgnClient.ts @@ -68,7 +68,7 @@ import { UpdateReplicationConfigurationTemplateCommandInput, UpdateReplicationConfigurationTemplateCommandOutput, } from "./commands/UpdateReplicationConfigurationTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -328,10 +328,7 @@ export class MgnClient extends __Client< readonly config: MgnClientResolvedConfig; constructor(configuration: MgnClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mgn/runtimeConfig.browser.ts b/clients/client-mgn/runtimeConfig.browser.ts index 579724e6345c7..1921effa74ad2 100644 --- a/clients/client-mgn/runtimeConfig.browser.ts +++ b/clients/client-mgn/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MgnClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MgnClientConfig } from "./MgnClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MgnClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mgn/runtimeConfig.native.ts b/clients/client-mgn/runtimeConfig.native.ts index 87f02494cb715..d9a33dfdd418b 100644 --- a/clients/client-mgn/runtimeConfig.native.ts +++ b/clients/client-mgn/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MgnClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MgnClientConfig } from "./MgnClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MgnClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mgn/runtimeConfig.shared.ts b/clients/client-mgn/runtimeConfig.shared.ts index 967fac80c107b..adcec5ac4db04 100644 --- a/clients/client-mgn/runtimeConfig.shared.ts +++ b/clients/client-mgn/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MgnClientConfig } from "./MgnClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MgnClientConfig) => ({ apiVersion: "2020-02-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "mgn", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "mgn", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mgn/runtimeConfig.ts b/clients/client-mgn/runtimeConfig.ts index d7e351bf3d1f0..040761f9e4bdc 100644 --- a/clients/client-mgn/runtimeConfig.ts +++ b/clients/client-mgn/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MgnClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MgnClientConfig } from "./MgnClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MgnClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-migration-hub/MigrationHubClient.ts b/clients/client-migration-hub/MigrationHubClient.ts index 24d449e2c60ae..e2a60eb78d28d 100644 --- a/clients/client-migration-hub/MigrationHubClient.ts +++ b/clients/client-migration-hub/MigrationHubClient.ts @@ -63,7 +63,7 @@ import { PutResourceAttributesCommandInput, PutResourceAttributesCommandOutput, } from "./commands/PutResourceAttributesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -312,10 +312,7 @@ export class MigrationHubClient extends __Client< readonly config: MigrationHubClientResolvedConfig; constructor(configuration: MigrationHubClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-migration-hub/runtimeConfig.browser.ts b/clients/client-migration-hub/runtimeConfig.browser.ts index 1644fd664be4b..835fbcbd717ef 100644 --- a/clients/client-migration-hub/runtimeConfig.browser.ts +++ b/clients/client-migration-hub/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MigrationHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MigrationHubClientConfig } from "./MigrationHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MigrationHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-migration-hub/runtimeConfig.native.ts b/clients/client-migration-hub/runtimeConfig.native.ts index a2caaaebdc706..534225442de19 100644 --- a/clients/client-migration-hub/runtimeConfig.native.ts +++ b/clients/client-migration-hub/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MigrationHubClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MigrationHubClientConfig } from "./MigrationHubClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MigrationHubClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-migration-hub/runtimeConfig.shared.ts b/clients/client-migration-hub/runtimeConfig.shared.ts index 7d2900672fb26..33d7600f6eaf7 100644 --- a/clients/client-migration-hub/runtimeConfig.shared.ts +++ b/clients/client-migration-hub/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MigrationHubClientConfig } from "./MigrationHubClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MigrationHubClientConfig) => ({ apiVersion: "2017-05-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Migration Hub", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Migration Hub", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-migration-hub/runtimeConfig.ts b/clients/client-migration-hub/runtimeConfig.ts index 8ec58eab81dc8..082480789a992 100644 --- a/clients/client-migration-hub/runtimeConfig.ts +++ b/clients/client-migration-hub/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MigrationHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MigrationHubClientConfig } from "./MigrationHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MigrationHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-migrationhub-config/MigrationHubConfigClient.ts b/clients/client-migrationhub-config/MigrationHubConfigClient.ts index c143d0d40e553..ea7351ae702c4 100644 --- a/clients/client-migrationhub-config/MigrationHubConfigClient.ts +++ b/clients/client-migrationhub-config/MigrationHubConfigClient.ts @@ -7,7 +7,7 @@ import { DescribeHomeRegionControlsCommandOutput, } from "./commands/DescribeHomeRegionControlsCommand"; import { GetHomeRegionCommandInput, GetHomeRegionCommandOutput } from "./commands/GetHomeRegionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -248,10 +248,7 @@ export class MigrationHubConfigClient extends __Client< readonly config: MigrationHubConfigClientResolvedConfig; constructor(configuration: MigrationHubConfigClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-migrationhub-config/runtimeConfig.browser.ts b/clients/client-migrationhub-config/runtimeConfig.browser.ts index 3aa18aedd3894..e8c24b1b5d890 100644 --- a/clients/client-migrationhub-config/runtimeConfig.browser.ts +++ b/clients/client-migrationhub-config/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MigrationHubConfigClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MigrationHubConfigClientConfig } from "./MigrationHubConfigClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MigrationHubConfigClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-migrationhub-config/runtimeConfig.native.ts b/clients/client-migrationhub-config/runtimeConfig.native.ts index b8d98cf11befb..0e0edc48a431c 100644 --- a/clients/client-migrationhub-config/runtimeConfig.native.ts +++ b/clients/client-migrationhub-config/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MigrationHubConfigClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MigrationHubConfigClientConfig } from "./MigrationHubConfigClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MigrationHubConfigClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-migrationhub-config/runtimeConfig.shared.ts b/clients/client-migrationhub-config/runtimeConfig.shared.ts index ac0403d961f59..99e7cc3ed331d 100644 --- a/clients/client-migrationhub-config/runtimeConfig.shared.ts +++ b/clients/client-migrationhub-config/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MigrationHubConfigClientConfig } from "./MigrationHubConfigClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MigrationHubConfigClientConfig) => ({ apiVersion: "2019-06-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MigrationHub Config", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MigrationHub Config", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-migrationhub-config/runtimeConfig.ts b/clients/client-migrationhub-config/runtimeConfig.ts index 93f0c76c43bdf..2285946facc0e 100644 --- a/clients/client-migrationhub-config/runtimeConfig.ts +++ b/clients/client-migrationhub-config/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MigrationHubConfigClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MigrationHubConfigClientConfig } from "./MigrationHubConfigClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MigrationHubConfigClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mobile/MobileClient.ts b/clients/client-mobile/MobileClient.ts index 079b7679c1043..29b29ad356f46 100644 --- a/clients/client-mobile/MobileClient.ts +++ b/clients/client-mobile/MobileClient.ts @@ -7,7 +7,7 @@ import { ExportProjectCommandInput, ExportProjectCommandOutput } from "./command import { ListBundlesCommandInput, ListBundlesCommandOutput } from "./commands/ListBundlesCommand"; import { ListProjectsCommandInput, ListProjectsCommandOutput } from "./commands/ListProjectsCommand"; import { UpdateProjectCommandInput, UpdateProjectCommandOutput } from "./commands/UpdateProjectCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -239,10 +239,7 @@ export class MobileClient extends __Client< readonly config: MobileClientResolvedConfig; constructor(configuration: MobileClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mobile/runtimeConfig.browser.ts b/clients/client-mobile/runtimeConfig.browser.ts index 6c1f412223c8b..281b5d2c10c4c 100644 --- a/clients/client-mobile/runtimeConfig.browser.ts +++ b/clients/client-mobile/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MobileClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MobileClientConfig } from "./MobileClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MobileClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mobile/runtimeConfig.native.ts b/clients/client-mobile/runtimeConfig.native.ts index 814ee58b700f8..7b8cbccb335cb 100644 --- a/clients/client-mobile/runtimeConfig.native.ts +++ b/clients/client-mobile/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MobileClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MobileClientConfig } from "./MobileClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MobileClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mobile/runtimeConfig.shared.ts b/clients/client-mobile/runtimeConfig.shared.ts index 5cb5a4b86f6b9..c2fa7896ea0bb 100644 --- a/clients/client-mobile/runtimeConfig.shared.ts +++ b/clients/client-mobile/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MobileClientConfig } from "./MobileClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MobileClientConfig) => ({ apiVersion: "2017-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Mobile", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Mobile", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mobile/runtimeConfig.ts b/clients/client-mobile/runtimeConfig.ts index fcac107d11d32..c7ccd8a84f438 100644 --- a/clients/client-mobile/runtimeConfig.ts +++ b/clients/client-mobile/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MobileClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MobileClientConfig } from "./MobileClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MobileClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mq/MqClient.ts b/clients/client-mq/MqClient.ts index 8b5b30021975f..59ce81ce1d8ec 100644 --- a/clients/client-mq/MqClient.ts +++ b/clients/client-mq/MqClient.ts @@ -41,7 +41,7 @@ import { UpdateConfigurationCommandOutput, } from "./commands/UpdateConfigurationCommand"; import { UpdateUserCommandInput, UpdateUserCommandOutput } from "./commands/UpdateUserCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -295,10 +295,7 @@ export class MqClient extends __Client< readonly config: MqClientResolvedConfig; constructor(configuration: MqClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mq/runtimeConfig.browser.ts b/clients/client-mq/runtimeConfig.browser.ts index e3402a9df3f14..640f704970940 100644 --- a/clients/client-mq/runtimeConfig.browser.ts +++ b/clients/client-mq/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MqClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MqClientConfig } from "./MqClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MqClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mq/runtimeConfig.native.ts b/clients/client-mq/runtimeConfig.native.ts index 24060311f20e3..c073bd049201d 100644 --- a/clients/client-mq/runtimeConfig.native.ts +++ b/clients/client-mq/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MqClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MqClientConfig } from "./MqClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MqClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mq/runtimeConfig.shared.ts b/clients/client-mq/runtimeConfig.shared.ts index de251006887e3..b6b3d86ac06a7 100644 --- a/clients/client-mq/runtimeConfig.shared.ts +++ b/clients/client-mq/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MqClientConfig } from "./MqClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MqClientConfig) => ({ apiVersion: "2017-11-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "mq", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "mq", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mq/runtimeConfig.ts b/clients/client-mq/runtimeConfig.ts index 446803e65cfe5..07c8df455819c 100644 --- a/clients/client-mq/runtimeConfig.ts +++ b/clients/client-mq/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MqClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MqClientConfig } from "./MqClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MqClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mturk/MTurkClient.ts b/clients/client-mturk/MTurkClient.ts index 3904476572f23..99f273fc13880 100644 --- a/clients/client-mturk/MTurkClient.ts +++ b/clients/client-mturk/MTurkClient.ts @@ -100,7 +100,7 @@ import { UpdateQualificationTypeCommandInput, UpdateQualificationTypeCommandOutput, } from "./commands/UpdateQualificationTypeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -388,10 +388,7 @@ export class MTurkClient extends __Client< readonly config: MTurkClientResolvedConfig; constructor(configuration: MTurkClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mturk/runtimeConfig.browser.ts b/clients/client-mturk/runtimeConfig.browser.ts index 3b5f4660c9ac3..02327dfb9ac3b 100644 --- a/clients/client-mturk/runtimeConfig.browser.ts +++ b/clients/client-mturk/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MTurkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MTurkClientConfig } from "./MTurkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MTurkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mturk/runtimeConfig.native.ts b/clients/client-mturk/runtimeConfig.native.ts index 12f1741f865e1..c2bf64607e5a2 100644 --- a/clients/client-mturk/runtimeConfig.native.ts +++ b/clients/client-mturk/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MTurkClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MTurkClientConfig } from "./MTurkClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MTurkClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mturk/runtimeConfig.shared.ts b/clients/client-mturk/runtimeConfig.shared.ts index c59369fe59cc3..354d5b5996b53 100644 --- a/clients/client-mturk/runtimeConfig.shared.ts +++ b/clients/client-mturk/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MTurkClientConfig } from "./MTurkClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MTurkClientConfig) => ({ apiVersion: "2017-01-17", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MTurk", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MTurk", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mturk/runtimeConfig.ts b/clients/client-mturk/runtimeConfig.ts index fcfda41912ba5..c6e6c34b1f9f4 100644 --- a/clients/client-mturk/runtimeConfig.ts +++ b/clients/client-mturk/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MTurkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MTurkClientConfig } from "./MTurkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MTurkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mwaa/MWAAClient.ts b/clients/client-mwaa/MWAAClient.ts index 00a091ee1d52a..e28ed7b20827d 100644 --- a/clients/client-mwaa/MWAAClient.ts +++ b/clients/client-mwaa/MWAAClient.ts @@ -15,7 +15,7 @@ import { PublishMetricsCommandInput, PublishMetricsCommandOutput } from "./comma import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateEnvironmentCommandInput, UpdateEnvironmentCommandOutput } from "./commands/UpdateEnvironmentCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -248,10 +248,7 @@ export class MWAAClient extends __Client< readonly config: MWAAClientResolvedConfig; constructor(configuration: MWAAClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-mwaa/runtimeConfig.browser.ts b/clients/client-mwaa/runtimeConfig.browser.ts index ce651903197bf..b4b4a813be58b 100644 --- a/clients/client-mwaa/runtimeConfig.browser.ts +++ b/clients/client-mwaa/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./MWAAClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MWAAClientConfig } from "./MWAAClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MWAAClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-mwaa/runtimeConfig.native.ts b/clients/client-mwaa/runtimeConfig.native.ts index 8e8245d25f0e1..f41c59335acf1 100644 --- a/clients/client-mwaa/runtimeConfig.native.ts +++ b/clients/client-mwaa/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./MWAAClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { MWAAClientConfig } from "./MWAAClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: MWAAClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-mwaa/runtimeConfig.shared.ts b/clients/client-mwaa/runtimeConfig.shared.ts index 70dbf0048121b..ae4802e378d46 100644 --- a/clients/client-mwaa/runtimeConfig.shared.ts +++ b/clients/client-mwaa/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { MWAAClientConfig } from "./MWAAClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: MWAAClientConfig) => ({ apiVersion: "2020-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "MWAA", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "MWAA", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-mwaa/runtimeConfig.ts b/clients/client-mwaa/runtimeConfig.ts index 675f840d5e613..0f275cd30db4b 100644 --- a/clients/client-mwaa/runtimeConfig.ts +++ b/clients/client-mwaa/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./MWAAClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { MWAAClientConfig } from "./MWAAClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: MWAAClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-neptune/NeptuneClient.ts b/clients/client-neptune/NeptuneClient.ts index d4950fd034a39..5a55e6cb915cd 100644 --- a/clients/client-neptune/NeptuneClient.ts +++ b/clients/client-neptune/NeptuneClient.ts @@ -208,7 +208,7 @@ import { } from "./commands/RestoreDBClusterToPointInTimeCommand"; import { StartDBClusterCommandInput, StartDBClusterCommandOutput } from "./commands/StartDBClusterCommand"; import { StopDBClusterCommandInput, StopDBClusterCommandOutput } from "./commands/StopDBClusterCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -561,10 +561,7 @@ export class NeptuneClient extends __Client< readonly config: NeptuneClientResolvedConfig; constructor(configuration: NeptuneClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-neptune/runtimeConfig.browser.ts b/clients/client-neptune/runtimeConfig.browser.ts index fc757f66e1bc7..3b4611c71b7bd 100644 --- a/clients/client-neptune/runtimeConfig.browser.ts +++ b/clients/client-neptune/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./NeptuneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NeptuneClientConfig } from "./NeptuneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NeptuneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-neptune/runtimeConfig.native.ts b/clients/client-neptune/runtimeConfig.native.ts index de7a28b868546..ffaa9958be086 100644 --- a/clients/client-neptune/runtimeConfig.native.ts +++ b/clients/client-neptune/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./NeptuneClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { NeptuneClientConfig } from "./NeptuneClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: NeptuneClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-neptune/runtimeConfig.shared.ts b/clients/client-neptune/runtimeConfig.shared.ts index f637fe5cfd84d..2089db65bf851 100644 --- a/clients/client-neptune/runtimeConfig.shared.ts +++ b/clients/client-neptune/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { NeptuneClientConfig } from "./NeptuneClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: NeptuneClientConfig) => ({ apiVersion: "2014-10-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Neptune", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Neptune", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-neptune/runtimeConfig.ts b/clients/client-neptune/runtimeConfig.ts index 77c76f9d3bc8c..73a3380685006 100644 --- a/clients/client-neptune/runtimeConfig.ts +++ b/clients/client-neptune/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./NeptuneClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NeptuneClientConfig } from "./NeptuneClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NeptuneClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-network-firewall/NetworkFirewallClient.ts b/clients/client-network-firewall/NetworkFirewallClient.ts index 53c74d9958543..5af469cd7481c 100644 --- a/clients/client-network-firewall/NetworkFirewallClient.ts +++ b/clients/client-network-firewall/NetworkFirewallClient.ts @@ -75,7 +75,7 @@ import { UpdateSubnetChangeProtectionCommandInput, UpdateSubnetChangeProtectionCommandOutput, } from "./commands/UpdateSubnetChangeProtectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -419,10 +419,7 @@ export class NetworkFirewallClient extends __Client< readonly config: NetworkFirewallClientResolvedConfig; constructor(configuration: NetworkFirewallClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-network-firewall/runtimeConfig.browser.ts b/clients/client-network-firewall/runtimeConfig.browser.ts index c40da967c0a1b..731fe5ea01d29 100644 --- a/clients/client-network-firewall/runtimeConfig.browser.ts +++ b/clients/client-network-firewall/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./NetworkFirewallClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NetworkFirewallClientConfig } from "./NetworkFirewallClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NetworkFirewallClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-network-firewall/runtimeConfig.native.ts b/clients/client-network-firewall/runtimeConfig.native.ts index 2b25d97867905..5eb62f50bade8 100644 --- a/clients/client-network-firewall/runtimeConfig.native.ts +++ b/clients/client-network-firewall/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./NetworkFirewallClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { NetworkFirewallClientConfig } from "./NetworkFirewallClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: NetworkFirewallClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-network-firewall/runtimeConfig.shared.ts b/clients/client-network-firewall/runtimeConfig.shared.ts index 192535a96cf30..0872b41a15435 100644 --- a/clients/client-network-firewall/runtimeConfig.shared.ts +++ b/clients/client-network-firewall/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { NetworkFirewallClientConfig } from "./NetworkFirewallClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: NetworkFirewallClientConfig) => ({ apiVersion: "2020-11-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Network Firewall", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Network Firewall", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-network-firewall/runtimeConfig.ts b/clients/client-network-firewall/runtimeConfig.ts index 9e3661547cb9d..97c73bca9368b 100644 --- a/clients/client-network-firewall/runtimeConfig.ts +++ b/clients/client-network-firewall/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./NetworkFirewallClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NetworkFirewallClientConfig } from "./NetworkFirewallClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NetworkFirewallClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-networkmanager/NetworkManagerClient.ts b/clients/client-networkmanager/NetworkManagerClient.ts index 5e1473be7ef8d..e70a513af8b73 100644 --- a/clients/client-networkmanager/NetworkManagerClient.ts +++ b/clients/client-networkmanager/NetworkManagerClient.ts @@ -78,7 +78,7 @@ import { } from "./commands/UpdateGlobalNetworkCommand"; import { UpdateLinkCommandInput, UpdateLinkCommandOutput } from "./commands/UpdateLinkCommand"; import { UpdateSiteCommandInput, UpdateSiteCommandOutput } from "./commands/UpdateSiteCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -360,10 +360,7 @@ export class NetworkManagerClient extends __Client< readonly config: NetworkManagerClientResolvedConfig; constructor(configuration: NetworkManagerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-networkmanager/runtimeConfig.browser.ts b/clients/client-networkmanager/runtimeConfig.browser.ts index f4f9a937e6096..6220eb0e58f42 100644 --- a/clients/client-networkmanager/runtimeConfig.browser.ts +++ b/clients/client-networkmanager/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./NetworkManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NetworkManagerClientConfig } from "./NetworkManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NetworkManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-networkmanager/runtimeConfig.native.ts b/clients/client-networkmanager/runtimeConfig.native.ts index 42a28676f93ff..d3d5afd733acb 100644 --- a/clients/client-networkmanager/runtimeConfig.native.ts +++ b/clients/client-networkmanager/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./NetworkManagerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { NetworkManagerClientConfig } from "./NetworkManagerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: NetworkManagerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-networkmanager/runtimeConfig.shared.ts b/clients/client-networkmanager/runtimeConfig.shared.ts index 448df95ccc0b7..dfeec1ecb7896 100644 --- a/clients/client-networkmanager/runtimeConfig.shared.ts +++ b/clients/client-networkmanager/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { NetworkManagerClientConfig } from "./NetworkManagerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: NetworkManagerClientConfig) => ({ apiVersion: "2019-07-05", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "NetworkManager", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "NetworkManager", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-networkmanager/runtimeConfig.ts b/clients/client-networkmanager/runtimeConfig.ts index 2f9bbe8aa8a9b..2f9de3c713389 100644 --- a/clients/client-networkmanager/runtimeConfig.ts +++ b/clients/client-networkmanager/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./NetworkManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NetworkManagerClientConfig } from "./NetworkManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NetworkManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-nimble/NimbleClient.ts b/clients/client-nimble/NimbleClient.ts index 51c979dd9a73d..6f6ac818f0036 100644 --- a/clients/client-nimble/NimbleClient.ts +++ b/clients/client-nimble/NimbleClient.ts @@ -124,7 +124,7 @@ import { UpdateStudioComponentCommandInput, UpdateStudioComponentCommandOutput, } from "./commands/UpdateStudioComponentCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -421,10 +421,7 @@ export class NimbleClient extends __Client< readonly config: NimbleClientResolvedConfig; constructor(configuration: NimbleClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-nimble/runtimeConfig.browser.ts b/clients/client-nimble/runtimeConfig.browser.ts index 09ea095150b2f..20d31010fea9a 100644 --- a/clients/client-nimble/runtimeConfig.browser.ts +++ b/clients/client-nimble/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./NimbleClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NimbleClientConfig } from "./NimbleClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NimbleClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-nimble/runtimeConfig.native.ts b/clients/client-nimble/runtimeConfig.native.ts index 2118ea8fca5d7..46f0102fb9d34 100644 --- a/clients/client-nimble/runtimeConfig.native.ts +++ b/clients/client-nimble/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./NimbleClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { NimbleClientConfig } from "./NimbleClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: NimbleClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-nimble/runtimeConfig.shared.ts b/clients/client-nimble/runtimeConfig.shared.ts index c518be876228a..014bc7e31a80e 100644 --- a/clients/client-nimble/runtimeConfig.shared.ts +++ b/clients/client-nimble/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { NimbleClientConfig } from "./NimbleClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: NimbleClientConfig) => ({ apiVersion: "2020-08-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "nimble", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "nimble", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-nimble/runtimeConfig.ts b/clients/client-nimble/runtimeConfig.ts index e41a880565f34..d24fde95d29f7 100644 --- a/clients/client-nimble/runtimeConfig.ts +++ b/clients/client-nimble/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./NimbleClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { NimbleClientConfig } from "./NimbleClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: NimbleClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-opsworks/OpsWorksClient.ts b/clients/client-opsworks/OpsWorksClient.ts index 33e1903133de1..65af1fd492445 100644 --- a/clients/client-opsworks/OpsWorksClient.ts +++ b/clients/client-opsworks/OpsWorksClient.ts @@ -150,7 +150,7 @@ import { import { UpdateStackCommandInput, UpdateStackCommandOutput } from "./commands/UpdateStackCommand"; import { UpdateUserProfileCommandInput, UpdateUserProfileCommandOutput } from "./commands/UpdateUserProfileCommand"; import { UpdateVolumeCommandInput, UpdateVolumeCommandOutput } from "./commands/UpdateVolumeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -622,10 +622,7 @@ export class OpsWorksClient extends __Client< readonly config: OpsWorksClientResolvedConfig; constructor(configuration: OpsWorksClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-opsworks/runtimeConfig.browser.ts b/clients/client-opsworks/runtimeConfig.browser.ts index 7b6df1d23b1b4..d7c4314b39d41 100644 --- a/clients/client-opsworks/runtimeConfig.browser.ts +++ b/clients/client-opsworks/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./OpsWorksClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OpsWorksClientConfig } from "./OpsWorksClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OpsWorksClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-opsworks/runtimeConfig.native.ts b/clients/client-opsworks/runtimeConfig.native.ts index 9c5531232e99a..b84b319fa24c5 100644 --- a/clients/client-opsworks/runtimeConfig.native.ts +++ b/clients/client-opsworks/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./OpsWorksClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { OpsWorksClientConfig } from "./OpsWorksClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: OpsWorksClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-opsworks/runtimeConfig.shared.ts b/clients/client-opsworks/runtimeConfig.shared.ts index c740e4848da20..4fabc99fb3d99 100644 --- a/clients/client-opsworks/runtimeConfig.shared.ts +++ b/clients/client-opsworks/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { OpsWorksClientConfig } from "./OpsWorksClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: OpsWorksClientConfig) => ({ apiVersion: "2013-02-18", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "OpsWorks", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "OpsWorks", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-opsworks/runtimeConfig.ts b/clients/client-opsworks/runtimeConfig.ts index 12c00b5dc1e6d..836460b070dc1 100644 --- a/clients/client-opsworks/runtimeConfig.ts +++ b/clients/client-opsworks/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./OpsWorksClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OpsWorksClientConfig } from "./OpsWorksClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OpsWorksClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-opsworkscm/OpsWorksCMClient.ts b/clients/client-opsworkscm/OpsWorksCMClient.ts index 486c5df6b80f2..14588f783ccd6 100644 --- a/clients/client-opsworkscm/OpsWorksCMClient.ts +++ b/clients/client-opsworkscm/OpsWorksCMClient.ts @@ -32,7 +32,7 @@ import { UpdateServerEngineAttributesCommandInput, UpdateServerEngineAttributesCommandOutput, } from "./commands/UpdateServerEngineAttributesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -367,10 +367,7 @@ export class OpsWorksCMClient extends __Client< readonly config: OpsWorksCMClientResolvedConfig; constructor(configuration: OpsWorksCMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-opsworkscm/runtimeConfig.browser.ts b/clients/client-opsworkscm/runtimeConfig.browser.ts index 9bc8635caec94..e595c5e481e9d 100644 --- a/clients/client-opsworkscm/runtimeConfig.browser.ts +++ b/clients/client-opsworkscm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./OpsWorksCMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OpsWorksCMClientConfig } from "./OpsWorksCMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OpsWorksCMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-opsworkscm/runtimeConfig.native.ts b/clients/client-opsworkscm/runtimeConfig.native.ts index 7db72777f1985..ac409b3308ad3 100644 --- a/clients/client-opsworkscm/runtimeConfig.native.ts +++ b/clients/client-opsworkscm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./OpsWorksCMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { OpsWorksCMClientConfig } from "./OpsWorksCMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: OpsWorksCMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-opsworkscm/runtimeConfig.shared.ts b/clients/client-opsworkscm/runtimeConfig.shared.ts index 2c3cee5f6b148..767b9edaba2b6 100644 --- a/clients/client-opsworkscm/runtimeConfig.shared.ts +++ b/clients/client-opsworkscm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { OpsWorksCMClientConfig } from "./OpsWorksCMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: OpsWorksCMClientConfig) => ({ apiVersion: "2016-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "OpsWorksCM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "OpsWorksCM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-opsworkscm/runtimeConfig.ts b/clients/client-opsworkscm/runtimeConfig.ts index cc3e32f748f63..6322764bddfc4 100644 --- a/clients/client-opsworkscm/runtimeConfig.ts +++ b/clients/client-opsworkscm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./OpsWorksCMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OpsWorksCMClientConfig } from "./OpsWorksCMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OpsWorksCMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-organizations/OrganizationsClient.ts b/clients/client-organizations/OrganizationsClient.ts index a87d87bdcce8b..642dc6a83fb9d 100644 --- a/clients/client-organizations/OrganizationsClient.ts +++ b/clients/client-organizations/OrganizationsClient.ts @@ -124,7 +124,7 @@ import { UpdateOrganizationalUnitCommandOutput, } from "./commands/UpdateOrganizationalUnitCommand"; import { UpdatePolicyCommandInput, UpdatePolicyCommandOutput } from "./commands/UpdatePolicyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -506,10 +506,7 @@ export class OrganizationsClient extends __Client< readonly config: OrganizationsClientResolvedConfig; constructor(configuration: OrganizationsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-organizations/runtimeConfig.browser.ts b/clients/client-organizations/runtimeConfig.browser.ts index 20ff2b746bc4b..218f2233d5f3f 100644 --- a/clients/client-organizations/runtimeConfig.browser.ts +++ b/clients/client-organizations/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./OrganizationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OrganizationsClientConfig } from "./OrganizationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OrganizationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-organizations/runtimeConfig.native.ts b/clients/client-organizations/runtimeConfig.native.ts index 109af58a10333..01164331286a3 100644 --- a/clients/client-organizations/runtimeConfig.native.ts +++ b/clients/client-organizations/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./OrganizationsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { OrganizationsClientConfig } from "./OrganizationsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: OrganizationsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-organizations/runtimeConfig.shared.ts b/clients/client-organizations/runtimeConfig.shared.ts index f725decd1dcec..11da91c92f16a 100644 --- a/clients/client-organizations/runtimeConfig.shared.ts +++ b/clients/client-organizations/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { OrganizationsClientConfig } from "./OrganizationsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: OrganizationsClientConfig) => ({ apiVersion: "2016-11-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Organizations", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Organizations", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-organizations/runtimeConfig.ts b/clients/client-organizations/runtimeConfig.ts index fcba437dc0c7b..c886d004212b3 100644 --- a/clients/client-organizations/runtimeConfig.ts +++ b/clients/client-organizations/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./OrganizationsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OrganizationsClientConfig } from "./OrganizationsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OrganizationsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-outposts/OutpostsClient.ts b/clients/client-outposts/OutpostsClient.ts index c2aeb27f1b5e9..02427b4f0eb21 100644 --- a/clients/client-outposts/OutpostsClient.ts +++ b/clients/client-outposts/OutpostsClient.ts @@ -14,7 +14,7 @@ import { } from "./commands/ListTagsForResourceCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -248,10 +248,7 @@ export class OutpostsClient extends __Client< readonly config: OutpostsClientResolvedConfig; constructor(configuration: OutpostsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-outposts/runtimeConfig.browser.ts b/clients/client-outposts/runtimeConfig.browser.ts index e86adaf45ed5d..0ee3943f45d12 100644 --- a/clients/client-outposts/runtimeConfig.browser.ts +++ b/clients/client-outposts/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./OutpostsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OutpostsClientConfig } from "./OutpostsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OutpostsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-outposts/runtimeConfig.native.ts b/clients/client-outposts/runtimeConfig.native.ts index be932d8ecbdd4..189f77bfff414 100644 --- a/clients/client-outposts/runtimeConfig.native.ts +++ b/clients/client-outposts/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./OutpostsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { OutpostsClientConfig } from "./OutpostsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: OutpostsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-outposts/runtimeConfig.shared.ts b/clients/client-outposts/runtimeConfig.shared.ts index 3ed0690de81e9..1e7a9fcb75b61 100644 --- a/clients/client-outposts/runtimeConfig.shared.ts +++ b/clients/client-outposts/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { OutpostsClientConfig } from "./OutpostsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: OutpostsClientConfig) => ({ apiVersion: "2019-12-03", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Outposts", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Outposts", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-outposts/runtimeConfig.ts b/clients/client-outposts/runtimeConfig.ts index bb1770ea10f87..f3876a186ce60 100644 --- a/clients/client-outposts/runtimeConfig.ts +++ b/clients/client-outposts/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./OutpostsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { OutpostsClientConfig } from "./OutpostsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: OutpostsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize-events/PersonalizeEventsClient.ts b/clients/client-personalize-events/PersonalizeEventsClient.ts index 7b3bf3de1cfe0..af3a51ac739ab 100644 --- a/clients/client-personalize-events/PersonalizeEventsClient.ts +++ b/clients/client-personalize-events/PersonalizeEventsClient.ts @@ -1,7 +1,7 @@ import { PutEventsCommandInput, PutEventsCommandOutput } from "./commands/PutEventsCommand"; import { PutItemsCommandInput, PutItemsCommandOutput } from "./commands/PutItemsCommand"; import { PutUsersCommandInput, PutUsersCommandOutput } from "./commands/PutUsersCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -213,10 +213,7 @@ export class PersonalizeEventsClient extends __Client< readonly config: PersonalizeEventsClientResolvedConfig; constructor(configuration: PersonalizeEventsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-personalize-events/runtimeConfig.browser.ts b/clients/client-personalize-events/runtimeConfig.browser.ts index 0e57410eb6cdf..2c00c395711da 100644 --- a/clients/client-personalize-events/runtimeConfig.browser.ts +++ b/clients/client-personalize-events/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PersonalizeEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeEventsClientConfig } from "./PersonalizeEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize-events/runtimeConfig.native.ts b/clients/client-personalize-events/runtimeConfig.native.ts index aa68a8e1ff133..47f42cf255b0a 100644 --- a/clients/client-personalize-events/runtimeConfig.native.ts +++ b/clients/client-personalize-events/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PersonalizeEventsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PersonalizeEventsClientConfig } from "./PersonalizeEventsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PersonalizeEventsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-personalize-events/runtimeConfig.shared.ts b/clients/client-personalize-events/runtimeConfig.shared.ts index 6a5ee1d5e1b01..3c77f09768ffe 100644 --- a/clients/client-personalize-events/runtimeConfig.shared.ts +++ b/clients/client-personalize-events/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PersonalizeEventsClientConfig } from "./PersonalizeEventsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PersonalizeEventsClientConfig) => ({ apiVersion: "2018-03-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Personalize Events", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Personalize Events", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-personalize-events/runtimeConfig.ts b/clients/client-personalize-events/runtimeConfig.ts index 76946d80fd8f8..d456e8689dc86 100644 --- a/clients/client-personalize-events/runtimeConfig.ts +++ b/clients/client-personalize-events/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PersonalizeEventsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeEventsClientConfig } from "./PersonalizeEventsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeEventsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize-runtime/PersonalizeRuntimeClient.ts b/clients/client-personalize-runtime/PersonalizeRuntimeClient.ts index 77e9bd40dc225..9e1f64a425f18 100644 --- a/clients/client-personalize-runtime/PersonalizeRuntimeClient.ts +++ b/clients/client-personalize-runtime/PersonalizeRuntimeClient.ts @@ -3,7 +3,7 @@ import { GetPersonalizedRankingCommandOutput, } from "./commands/GetPersonalizedRankingCommand"; import { GetRecommendationsCommandInput, GetRecommendationsCommandOutput } from "./commands/GetRecommendationsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -213,10 +213,7 @@ export class PersonalizeRuntimeClient extends __Client< readonly config: PersonalizeRuntimeClientResolvedConfig; constructor(configuration: PersonalizeRuntimeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-personalize-runtime/runtimeConfig.browser.ts b/clients/client-personalize-runtime/runtimeConfig.browser.ts index 8141d9cd60441..167bf2b8893db 100644 --- a/clients/client-personalize-runtime/runtimeConfig.browser.ts +++ b/clients/client-personalize-runtime/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PersonalizeRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeRuntimeClientConfig } from "./PersonalizeRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize-runtime/runtimeConfig.native.ts b/clients/client-personalize-runtime/runtimeConfig.native.ts index 7f5c672641e2b..1f4b4c4bbfc5a 100644 --- a/clients/client-personalize-runtime/runtimeConfig.native.ts +++ b/clients/client-personalize-runtime/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PersonalizeRuntimeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PersonalizeRuntimeClientConfig } from "./PersonalizeRuntimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PersonalizeRuntimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-personalize-runtime/runtimeConfig.shared.ts b/clients/client-personalize-runtime/runtimeConfig.shared.ts index 63abb2f86f7c0..17879be9c2fa2 100644 --- a/clients/client-personalize-runtime/runtimeConfig.shared.ts +++ b/clients/client-personalize-runtime/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PersonalizeRuntimeClientConfig } from "./PersonalizeRuntimeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PersonalizeRuntimeClientConfig) => ({ apiVersion: "2018-05-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Personalize Runtime", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Personalize Runtime", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-personalize-runtime/runtimeConfig.ts b/clients/client-personalize-runtime/runtimeConfig.ts index 04860342fbf2d..7718eef303d6d 100644 --- a/clients/client-personalize-runtime/runtimeConfig.ts +++ b/clients/client-personalize-runtime/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PersonalizeRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeRuntimeClientConfig } from "./PersonalizeRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize/PersonalizeClient.ts b/clients/client-personalize/PersonalizeClient.ts index 45565651ce9d9..d975211b69dfc 100644 --- a/clients/client-personalize/PersonalizeClient.ts +++ b/clients/client-personalize/PersonalizeClient.ts @@ -93,7 +93,7 @@ import { StopSolutionVersionCreationCommandOutput, } from "./commands/StopSolutionVersionCreationCommand"; import { UpdateCampaignCommandInput, UpdateCampaignCommandOutput } from "./commands/UpdateCampaignCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -398,10 +398,7 @@ export class PersonalizeClient extends __Client< readonly config: PersonalizeClientResolvedConfig; constructor(configuration: PersonalizeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-personalize/runtimeConfig.browser.ts b/clients/client-personalize/runtimeConfig.browser.ts index 47320ea082097..fc31eb0d8fade 100644 --- a/clients/client-personalize/runtimeConfig.browser.ts +++ b/clients/client-personalize/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PersonalizeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeClientConfig } from "./PersonalizeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-personalize/runtimeConfig.native.ts b/clients/client-personalize/runtimeConfig.native.ts index 5bc03d0998b5b..06612f2451a21 100644 --- a/clients/client-personalize/runtimeConfig.native.ts +++ b/clients/client-personalize/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PersonalizeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PersonalizeClientConfig } from "./PersonalizeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PersonalizeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-personalize/runtimeConfig.shared.ts b/clients/client-personalize/runtimeConfig.shared.ts index 32ffd761726cf..9fa72c876aa81 100644 --- a/clients/client-personalize/runtimeConfig.shared.ts +++ b/clients/client-personalize/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PersonalizeClientConfig } from "./PersonalizeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PersonalizeClientConfig) => ({ apiVersion: "2018-05-22", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Personalize", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Personalize", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-personalize/runtimeConfig.ts b/clients/client-personalize/runtimeConfig.ts index bb828983114e4..d604bc4bf0933 100644 --- a/clients/client-personalize/runtimeConfig.ts +++ b/clients/client-personalize/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PersonalizeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PersonalizeClientConfig } from "./PersonalizeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PersonalizeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pi/PIClient.ts b/clients/client-pi/PIClient.ts index 6520a88952c2e..ac2e49a561f8c 100644 --- a/clients/client-pi/PIClient.ts +++ b/clients/client-pi/PIClient.ts @@ -7,7 +7,7 @@ import { GetDimensionKeyDetailsCommandOutput, } from "./commands/GetDimensionKeyDetailsCommand"; import { GetResourceMetricsCommandInput, GetResourceMetricsCommandOutput } from "./commands/GetResourceMetricsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -244,10 +244,7 @@ export class PIClient extends __Client< readonly config: PIClientResolvedConfig; constructor(configuration: PIClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-pi/runtimeConfig.browser.ts b/clients/client-pi/runtimeConfig.browser.ts index 90bd4d7b1b3b5..351296bae3c37 100644 --- a/clients/client-pi/runtimeConfig.browser.ts +++ b/clients/client-pi/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PIClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PIClientConfig } from "./PIClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PIClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pi/runtimeConfig.native.ts b/clients/client-pi/runtimeConfig.native.ts index 11a8066cef75e..67d833bbce287 100644 --- a/clients/client-pi/runtimeConfig.native.ts +++ b/clients/client-pi/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PIClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PIClientConfig } from "./PIClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PIClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-pi/runtimeConfig.shared.ts b/clients/client-pi/runtimeConfig.shared.ts index 9fb214f4a7575..5ce6edc9bc937 100644 --- a/clients/client-pi/runtimeConfig.shared.ts +++ b/clients/client-pi/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PIClientConfig } from "./PIClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PIClientConfig) => ({ apiVersion: "2018-02-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "PI", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "PI", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-pi/runtimeConfig.ts b/clients/client-pi/runtimeConfig.ts index e0169f2944a0b..ac2c888420adf 100644 --- a/clients/client-pi/runtimeConfig.ts +++ b/clients/client-pi/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PIClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PIClientConfig } from "./PIClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PIClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint-email/PinpointEmailClient.ts b/clients/client-pinpoint-email/PinpointEmailClient.ts index f4a000e625981..3ceb999ec50b5 100644 --- a/clients/client-pinpoint-email/PinpointEmailClient.ts +++ b/clients/client-pinpoint-email/PinpointEmailClient.ts @@ -145,7 +145,7 @@ import { UpdateConfigurationSetEventDestinationCommandInput, UpdateConfigurationSetEventDestinationCommandOutput, } from "./commands/UpdateConfigurationSetEventDestinationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -467,10 +467,7 @@ export class PinpointEmailClient extends __Client< readonly config: PinpointEmailClientResolvedConfig; constructor(configuration: PinpointEmailClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-pinpoint-email/runtimeConfig.browser.ts b/clients/client-pinpoint-email/runtimeConfig.browser.ts index 647563ad07219..9684a001f3d48 100644 --- a/clients/client-pinpoint-email/runtimeConfig.browser.ts +++ b/clients/client-pinpoint-email/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PinpointEmailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointEmailClientConfig } from "./PinpointEmailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointEmailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint-email/runtimeConfig.native.ts b/clients/client-pinpoint-email/runtimeConfig.native.ts index cdb13c1bcf668..50979281f95f0 100644 --- a/clients/client-pinpoint-email/runtimeConfig.native.ts +++ b/clients/client-pinpoint-email/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PinpointEmailClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PinpointEmailClientConfig } from "./PinpointEmailClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PinpointEmailClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-pinpoint-email/runtimeConfig.shared.ts b/clients/client-pinpoint-email/runtimeConfig.shared.ts index de8852d9f20c4..6770b3806a1d2 100644 --- a/clients/client-pinpoint-email/runtimeConfig.shared.ts +++ b/clients/client-pinpoint-email/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PinpointEmailClientConfig } from "./PinpointEmailClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PinpointEmailClientConfig) => ({ apiVersion: "2018-07-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Pinpoint Email", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Pinpoint Email", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-pinpoint-email/runtimeConfig.ts b/clients/client-pinpoint-email/runtimeConfig.ts index 2b72c5069f0a2..112d602414897 100644 --- a/clients/client-pinpoint-email/runtimeConfig.ts +++ b/clients/client-pinpoint-email/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PinpointEmailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointEmailClientConfig } from "./PinpointEmailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointEmailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint-sms-voice/PinpointSMSVoiceClient.ts b/clients/client-pinpoint-sms-voice/PinpointSMSVoiceClient.ts index 90bab6cad9dac..e5c6ab1965711 100644 --- a/clients/client-pinpoint-sms-voice/PinpointSMSVoiceClient.ts +++ b/clients/client-pinpoint-sms-voice/PinpointSMSVoiceClient.ts @@ -27,7 +27,7 @@ import { UpdateConfigurationSetEventDestinationCommandInput, UpdateConfigurationSetEventDestinationCommandOutput, } from "./commands/UpdateConfigurationSetEventDestinationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -253,10 +253,7 @@ export class PinpointSMSVoiceClient extends __Client< readonly config: PinpointSMSVoiceClientResolvedConfig; constructor(configuration: PinpointSMSVoiceClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-pinpoint-sms-voice/runtimeConfig.browser.ts b/clients/client-pinpoint-sms-voice/runtimeConfig.browser.ts index 2476f7fe91002..a1bf560e646a6 100644 --- a/clients/client-pinpoint-sms-voice/runtimeConfig.browser.ts +++ b/clients/client-pinpoint-sms-voice/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PinpointSMSVoiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointSMSVoiceClientConfig } from "./PinpointSMSVoiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointSMSVoiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint-sms-voice/runtimeConfig.native.ts b/clients/client-pinpoint-sms-voice/runtimeConfig.native.ts index 3d56c1332de21..9e470ca4d3c84 100644 --- a/clients/client-pinpoint-sms-voice/runtimeConfig.native.ts +++ b/clients/client-pinpoint-sms-voice/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PinpointSMSVoiceClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PinpointSMSVoiceClientConfig } from "./PinpointSMSVoiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PinpointSMSVoiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-pinpoint-sms-voice/runtimeConfig.shared.ts b/clients/client-pinpoint-sms-voice/runtimeConfig.shared.ts index 63c7ba5d404fd..5a26506585a2d 100644 --- a/clients/client-pinpoint-sms-voice/runtimeConfig.shared.ts +++ b/clients/client-pinpoint-sms-voice/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PinpointSMSVoiceClientConfig } from "./PinpointSMSVoiceClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PinpointSMSVoiceClientConfig) => ({ apiVersion: "2018-09-05", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Pinpoint SMS Voice", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Pinpoint SMS Voice", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-pinpoint-sms-voice/runtimeConfig.ts b/clients/client-pinpoint-sms-voice/runtimeConfig.ts index 3bc739fcaeab8..32c18fd5e2a4f 100644 --- a/clients/client-pinpoint-sms-voice/runtimeConfig.ts +++ b/clients/client-pinpoint-sms-voice/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PinpointSMSVoiceClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointSMSVoiceClientConfig } from "./PinpointSMSVoiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointSMSVoiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint/PinpointClient.ts b/clients/client-pinpoint/PinpointClient.ts index 4e2727f77af7f..2fc8727af8fa0 100644 --- a/clients/client-pinpoint/PinpointClient.ts +++ b/clients/client-pinpoint/PinpointClient.ts @@ -218,7 +218,7 @@ import { UpdateVoiceTemplateCommandInput, UpdateVoiceTemplateCommandOutput, } from "./commands/UpdateVoiceTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -652,10 +652,7 @@ export class PinpointClient extends __Client< readonly config: PinpointClientResolvedConfig; constructor(configuration: PinpointClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-pinpoint/runtimeConfig.browser.ts b/clients/client-pinpoint/runtimeConfig.browser.ts index bf1457ca08830..d2be1d445d599 100644 --- a/clients/client-pinpoint/runtimeConfig.browser.ts +++ b/clients/client-pinpoint/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PinpointClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointClientConfig } from "./PinpointClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pinpoint/runtimeConfig.native.ts b/clients/client-pinpoint/runtimeConfig.native.ts index d6d6b4d04d130..eda3832734d6c 100644 --- a/clients/client-pinpoint/runtimeConfig.native.ts +++ b/clients/client-pinpoint/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PinpointClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PinpointClientConfig } from "./PinpointClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PinpointClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-pinpoint/runtimeConfig.shared.ts b/clients/client-pinpoint/runtimeConfig.shared.ts index 37fa0bdfa6880..a4c2c867f307a 100644 --- a/clients/client-pinpoint/runtimeConfig.shared.ts +++ b/clients/client-pinpoint/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PinpointClientConfig } from "./PinpointClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PinpointClientConfig) => ({ apiVersion: "2016-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Pinpoint", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Pinpoint", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-pinpoint/runtimeConfig.ts b/clients/client-pinpoint/runtimeConfig.ts index d41d9c046509a..f1bcc4b5bfdb4 100644 --- a/clients/client-pinpoint/runtimeConfig.ts +++ b/clients/client-pinpoint/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PinpointClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PinpointClientConfig } from "./PinpointClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PinpointClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-polly/PollyClient.ts b/clients/client-polly/PollyClient.ts index bf1021020b9c2..de1ffca496851 100644 --- a/clients/client-polly/PollyClient.ts +++ b/clients/client-polly/PollyClient.ts @@ -16,7 +16,7 @@ import { StartSpeechSynthesisTaskCommandOutput, } from "./commands/StartSpeechSynthesisTaskCommand"; import { SynthesizeSpeechCommandInput, SynthesizeSpeechCommandOutput } from "./commands/SynthesizeSpeechCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -249,10 +249,7 @@ export class PollyClient extends __Client< readonly config: PollyClientResolvedConfig; constructor(configuration: PollyClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-polly/runtimeConfig.browser.ts b/clients/client-polly/runtimeConfig.browser.ts index f87d3d85da8f7..19f7ac9fdd02d 100644 --- a/clients/client-polly/runtimeConfig.browser.ts +++ b/clients/client-polly/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PollyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PollyClientConfig } from "./PollyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PollyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-polly/runtimeConfig.native.ts b/clients/client-polly/runtimeConfig.native.ts index e52b214696d9b..395e99222592e 100644 --- a/clients/client-polly/runtimeConfig.native.ts +++ b/clients/client-polly/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PollyClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PollyClientConfig } from "./PollyClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PollyClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-polly/runtimeConfig.shared.ts b/clients/client-polly/runtimeConfig.shared.ts index e0d76344686db..ecf27e50dc571 100644 --- a/clients/client-polly/runtimeConfig.shared.ts +++ b/clients/client-polly/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PollyClientConfig } from "./PollyClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PollyClientConfig) => ({ apiVersion: "2016-06-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Polly", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Polly", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-polly/runtimeConfig.ts b/clients/client-polly/runtimeConfig.ts index a8ce17ee39f83..cd32462fffe68 100644 --- a/clients/client-polly/runtimeConfig.ts +++ b/clients/client-polly/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PollyClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PollyClientConfig } from "./PollyClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PollyClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pricing/PricingClient.ts b/clients/client-pricing/PricingClient.ts index 42c44ba6e54ee..874df9c705654 100644 --- a/clients/client-pricing/PricingClient.ts +++ b/clients/client-pricing/PricingClient.ts @@ -1,7 +1,7 @@ import { DescribeServicesCommandInput, DescribeServicesCommandOutput } from "./commands/DescribeServicesCommand"; import { GetAttributeValuesCommandInput, GetAttributeValuesCommandOutput } from "./commands/GetAttributeValuesCommand"; import { GetProductsCommandInput, GetProductsCommandOutput } from "./commands/GetProductsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -237,10 +237,7 @@ export class PricingClient extends __Client< readonly config: PricingClientResolvedConfig; constructor(configuration: PricingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-pricing/runtimeConfig.browser.ts b/clients/client-pricing/runtimeConfig.browser.ts index c776ea1529961..18fd15dfc0c88 100644 --- a/clients/client-pricing/runtimeConfig.browser.ts +++ b/clients/client-pricing/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./PricingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PricingClientConfig } from "./PricingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PricingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-pricing/runtimeConfig.native.ts b/clients/client-pricing/runtimeConfig.native.ts index 6c701816537d2..05f7637bebeea 100644 --- a/clients/client-pricing/runtimeConfig.native.ts +++ b/clients/client-pricing/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./PricingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { PricingClientConfig } from "./PricingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: PricingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-pricing/runtimeConfig.shared.ts b/clients/client-pricing/runtimeConfig.shared.ts index df10135129021..dbb218d0b2a8f 100644 --- a/clients/client-pricing/runtimeConfig.shared.ts +++ b/clients/client-pricing/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { PricingClientConfig } from "./PricingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: PricingClientConfig) => ({ apiVersion: "2017-10-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Pricing", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Pricing", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-pricing/runtimeConfig.ts b/clients/client-pricing/runtimeConfig.ts index f4a10469fca3c..e7743a2121c37 100644 --- a/clients/client-pricing/runtimeConfig.ts +++ b/clients/client-pricing/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./PricingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { PricingClientConfig } from "./PricingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: PricingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-proton/ProtonClient.ts b/clients/client-proton/ProtonClient.ts index 2dece96513564..6002619005c28 100644 --- a/clients/client-proton/ProtonClient.ts +++ b/clients/client-proton/ProtonClient.ts @@ -149,7 +149,7 @@ import { UpdateServiceTemplateVersionCommandInput, UpdateServiceTemplateVersionCommandOutput, } from "./commands/UpdateServiceTemplateVersionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -554,10 +554,7 @@ export class ProtonClient extends __Client< readonly config: ProtonClientResolvedConfig; constructor(configuration: ProtonClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-proton/runtimeConfig.browser.ts b/clients/client-proton/runtimeConfig.browser.ts index b486e90696b95..ba0589bfb3f93 100644 --- a/clients/client-proton/runtimeConfig.browser.ts +++ b/clients/client-proton/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ProtonClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ProtonClientConfig } from "./ProtonClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ProtonClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-proton/runtimeConfig.native.ts b/clients/client-proton/runtimeConfig.native.ts index 3389a1caaa41f..03c2a0d10e093 100644 --- a/clients/client-proton/runtimeConfig.native.ts +++ b/clients/client-proton/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ProtonClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ProtonClientConfig } from "./ProtonClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ProtonClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-proton/runtimeConfig.shared.ts b/clients/client-proton/runtimeConfig.shared.ts index e84e76f16160a..0926c4fac30aa 100644 --- a/clients/client-proton/runtimeConfig.shared.ts +++ b/clients/client-proton/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ProtonClientConfig } from "./ProtonClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ProtonClientConfig) => ({ apiVersion: "2020-07-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Proton", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Proton", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-proton/runtimeConfig.ts b/clients/client-proton/runtimeConfig.ts index 0f6582398340a..b8c0f5fb0878c 100644 --- a/clients/client-proton/runtimeConfig.ts +++ b/clients/client-proton/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ProtonClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ProtonClientConfig } from "./ProtonClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ProtonClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-qldb-session/QLDBSessionClient.ts b/clients/client-qldb-session/QLDBSessionClient.ts index 8e118fd86d6d7..fbd6134f0edce 100644 --- a/clients/client-qldb-session/QLDBSessionClient.ts +++ b/clients/client-qldb-session/QLDBSessionClient.ts @@ -1,5 +1,5 @@ import { SendCommandCommandInput, SendCommandCommandOutput } from "./commands/SendCommandCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -229,10 +229,7 @@ export class QLDBSessionClient extends __Client< readonly config: QLDBSessionClientResolvedConfig; constructor(configuration: QLDBSessionClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-qldb-session/runtimeConfig.browser.ts b/clients/client-qldb-session/runtimeConfig.browser.ts index 841fb43bf55c6..e82588999a3d6 100644 --- a/clients/client-qldb-session/runtimeConfig.browser.ts +++ b/clients/client-qldb-session/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./QLDBSessionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QLDBSessionClientConfig } from "./QLDBSessionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QLDBSessionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-qldb-session/runtimeConfig.native.ts b/clients/client-qldb-session/runtimeConfig.native.ts index f9ad547e35866..9350e29fa5b8a 100644 --- a/clients/client-qldb-session/runtimeConfig.native.ts +++ b/clients/client-qldb-session/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./QLDBSessionClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { QLDBSessionClientConfig } from "./QLDBSessionClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: QLDBSessionClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-qldb-session/runtimeConfig.shared.ts b/clients/client-qldb-session/runtimeConfig.shared.ts index 6bc14536a485a..56b95c40ee52a 100644 --- a/clients/client-qldb-session/runtimeConfig.shared.ts +++ b/clients/client-qldb-session/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { QLDBSessionClientConfig } from "./QLDBSessionClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: QLDBSessionClientConfig) => ({ apiVersion: "2019-07-11", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "QLDB Session", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "QLDB Session", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-qldb-session/runtimeConfig.ts b/clients/client-qldb-session/runtimeConfig.ts index 0ecab1b7ec223..86aa73861a518 100644 --- a/clients/client-qldb-session/runtimeConfig.ts +++ b/clients/client-qldb-session/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./QLDBSessionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QLDBSessionClientConfig } from "./QLDBSessionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QLDBSessionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-qldb/QLDBClient.ts b/clients/client-qldb/QLDBClient.ts index 7d3e15fe36b0b..933c9ca582fe6 100644 --- a/clients/client-qldb/QLDBClient.ts +++ b/clients/client-qldb/QLDBClient.ts @@ -45,7 +45,7 @@ import { UpdateLedgerPermissionsModeCommandInput, UpdateLedgerPermissionsModeCommandOutput, } from "./commands/UpdateLedgerPermissionsModeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -295,10 +295,7 @@ export class QLDBClient extends __Client< readonly config: QLDBClientResolvedConfig; constructor(configuration: QLDBClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-qldb/runtimeConfig.browser.ts b/clients/client-qldb/runtimeConfig.browser.ts index 497024b3b96cc..5a49dff4f3ea2 100644 --- a/clients/client-qldb/runtimeConfig.browser.ts +++ b/clients/client-qldb/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./QLDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QLDBClientConfig } from "./QLDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QLDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-qldb/runtimeConfig.native.ts b/clients/client-qldb/runtimeConfig.native.ts index 6f2635ab1903f..e209ac561cef4 100644 --- a/clients/client-qldb/runtimeConfig.native.ts +++ b/clients/client-qldb/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./QLDBClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { QLDBClientConfig } from "./QLDBClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: QLDBClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-qldb/runtimeConfig.shared.ts b/clients/client-qldb/runtimeConfig.shared.ts index 2ff37bf3087aa..41a3fda07474e 100644 --- a/clients/client-qldb/runtimeConfig.shared.ts +++ b/clients/client-qldb/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { QLDBClientConfig } from "./QLDBClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: QLDBClientConfig) => ({ apiVersion: "2019-01-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "QLDB", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "QLDB", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-qldb/runtimeConfig.ts b/clients/client-qldb/runtimeConfig.ts index 01e70fae51427..b4cc80ff4ba74 100644 --- a/clients/client-qldb/runtimeConfig.ts +++ b/clients/client-qldb/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./QLDBClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QLDBClientConfig } from "./QLDBClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QLDBClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-quicksight/QuickSightClient.ts b/clients/client-quicksight/QuickSightClient.ts index 5734aa26b86fa..ed9bba70dbe36 100644 --- a/clients/client-quicksight/QuickSightClient.ts +++ b/clients/client-quicksight/QuickSightClient.ts @@ -238,7 +238,7 @@ import { UpdateThemePermissionsCommandOutput, } from "./commands/UpdateThemePermissionsCommand"; import { UpdateUserCommandInput, UpdateUserCommandOutput } from "./commands/UpdateUserCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -674,10 +674,7 @@ export class QuickSightClient extends __Client< readonly config: QuickSightClientResolvedConfig; constructor(configuration: QuickSightClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-quicksight/runtimeConfig.browser.ts b/clients/client-quicksight/runtimeConfig.browser.ts index 3a34d337e1433..f4434420efe69 100644 --- a/clients/client-quicksight/runtimeConfig.browser.ts +++ b/clients/client-quicksight/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./QuickSightClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QuickSightClientConfig } from "./QuickSightClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QuickSightClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-quicksight/runtimeConfig.native.ts b/clients/client-quicksight/runtimeConfig.native.ts index fbbae6cb3eee0..263cc4b0a7657 100644 --- a/clients/client-quicksight/runtimeConfig.native.ts +++ b/clients/client-quicksight/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./QuickSightClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { QuickSightClientConfig } from "./QuickSightClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: QuickSightClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-quicksight/runtimeConfig.shared.ts b/clients/client-quicksight/runtimeConfig.shared.ts index ddcb54d0b7738..9f2d3198267ae 100644 --- a/clients/client-quicksight/runtimeConfig.shared.ts +++ b/clients/client-quicksight/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { QuickSightClientConfig } from "./QuickSightClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: QuickSightClientConfig) => ({ apiVersion: "2018-04-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "QuickSight", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "QuickSight", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-quicksight/runtimeConfig.ts b/clients/client-quicksight/runtimeConfig.ts index 6631fc718a86d..3f72f66b4f0a2 100644 --- a/clients/client-quicksight/runtimeConfig.ts +++ b/clients/client-quicksight/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./QuickSightClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QuickSightClientConfig } from "./QuickSightClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QuickSightClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ram/RAMClient.ts b/clients/client-ram/RAMClient.ts index 04506ecd4bf47..19d45972744fa 100644 --- a/clients/client-ram/RAMClient.ts +++ b/clients/client-ram/RAMClient.ts @@ -70,7 +70,7 @@ import { UpdateResourceShareCommandInput, UpdateResourceShareCommandOutput, } from "./commands/UpdateResourceShareCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -333,10 +333,7 @@ export class RAMClient extends __Client< readonly config: RAMClientResolvedConfig; constructor(configuration: RAMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ram/runtimeConfig.browser.ts b/clients/client-ram/runtimeConfig.browser.ts index af3b44ff6adff..d5aaad456d739 100644 --- a/clients/client-ram/runtimeConfig.browser.ts +++ b/clients/client-ram/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RAMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RAMClientConfig } from "./RAMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RAMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ram/runtimeConfig.native.ts b/clients/client-ram/runtimeConfig.native.ts index eecfd6582e807..6d7410c768ffe 100644 --- a/clients/client-ram/runtimeConfig.native.ts +++ b/clients/client-ram/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RAMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RAMClientConfig } from "./RAMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RAMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ram/runtimeConfig.shared.ts b/clients/client-ram/runtimeConfig.shared.ts index fa901e5e4091d..cd94f0fba434a 100644 --- a/clients/client-ram/runtimeConfig.shared.ts +++ b/clients/client-ram/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RAMClientConfig } from "./RAMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RAMClientConfig) => ({ apiVersion: "2018-01-04", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "RAM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "RAM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ram/runtimeConfig.ts b/clients/client-ram/runtimeConfig.ts index a62a03f6c5b9c..0c78f43168531 100644 --- a/clients/client-ram/runtimeConfig.ts +++ b/clients/client-ram/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RAMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RAMClientConfig } from "./RAMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RAMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rds-data/RDSDataClient.ts b/clients/client-rds-data/RDSDataClient.ts index a4cf53fb26cf1..1debec72c71c0 100644 --- a/clients/client-rds-data/RDSDataClient.ts +++ b/clients/client-rds-data/RDSDataClient.ts @@ -10,7 +10,7 @@ import { RollbackTransactionCommandInput, RollbackTransactionCommandOutput, } from "./commands/RollbackTransactionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -237,10 +237,7 @@ export class RDSDataClient extends __Client< readonly config: RDSDataClientResolvedConfig; constructor(configuration: RDSDataClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-rds-data/runtimeConfig.browser.ts b/clients/client-rds-data/runtimeConfig.browser.ts index 9d2326f8289f9..c9bd710c7c615 100644 --- a/clients/client-rds-data/runtimeConfig.browser.ts +++ b/clients/client-rds-data/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RDSDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RDSDataClientConfig } from "./RDSDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RDSDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rds-data/runtimeConfig.native.ts b/clients/client-rds-data/runtimeConfig.native.ts index fb2b95786424c..0593e91f5f9df 100644 --- a/clients/client-rds-data/runtimeConfig.native.ts +++ b/clients/client-rds-data/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RDSDataClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RDSDataClientConfig } from "./RDSDataClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RDSDataClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-rds-data/runtimeConfig.shared.ts b/clients/client-rds-data/runtimeConfig.shared.ts index 3ff2a8d7f4231..9b3ed733470a9 100644 --- a/clients/client-rds-data/runtimeConfig.shared.ts +++ b/clients/client-rds-data/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RDSDataClientConfig } from "./RDSDataClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RDSDataClientConfig) => ({ apiVersion: "2018-08-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "RDS Data", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "RDS Data", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-rds-data/runtimeConfig.ts b/clients/client-rds-data/runtimeConfig.ts index 51de16f2962d5..d97464df5cc47 100644 --- a/clients/client-rds-data/runtimeConfig.ts +++ b/clients/client-rds-data/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RDSDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RDSDataClientConfig } from "./RDSDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RDSDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rds/RDSClient.ts b/clients/client-rds/RDSClient.ts index fc403c032375e..16f316f388a8b 100644 --- a/clients/client-rds/RDSClient.ts +++ b/clients/client-rds/RDSClient.ts @@ -441,7 +441,7 @@ import { StopDBInstanceAutomatedBackupsReplicationCommandOutput, } from "./commands/StopDBInstanceAutomatedBackupsReplicationCommand"; import { StopDBInstanceCommandInput, StopDBInstanceCommandOutput } from "./commands/StopDBInstanceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -981,10 +981,7 @@ export class RDSClient extends __Client< readonly config: RDSClientResolvedConfig; constructor(configuration: RDSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-rds/runtimeConfig.browser.ts b/clients/client-rds/runtimeConfig.browser.ts index fc1c6f15f3bce..5794fb811b9fa 100644 --- a/clients/client-rds/runtimeConfig.browser.ts +++ b/clients/client-rds/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RDSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RDSClientConfig } from "./RDSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RDSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rds/runtimeConfig.native.ts b/clients/client-rds/runtimeConfig.native.ts index 67e0658db5538..8e3bad2acf808 100644 --- a/clients/client-rds/runtimeConfig.native.ts +++ b/clients/client-rds/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RDSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RDSClientConfig } from "./RDSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RDSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-rds/runtimeConfig.shared.ts b/clients/client-rds/runtimeConfig.shared.ts index ebe09a0fbab32..b3f26db10e55a 100644 --- a/clients/client-rds/runtimeConfig.shared.ts +++ b/clients/client-rds/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RDSClientConfig } from "./RDSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RDSClientConfig) => ({ apiVersion: "2014-10-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "RDS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "RDS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-rds/runtimeConfig.ts b/clients/client-rds/runtimeConfig.ts index 93043fa94afa0..845e8a9725ec3 100644 --- a/clients/client-rds/runtimeConfig.ts +++ b/clients/client-rds/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RDSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RDSClientConfig } from "./RDSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RDSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-redshift-data/RedshiftDataClient.ts b/clients/client-redshift-data/RedshiftDataClient.ts index f0de825a253cf..3605714112f63 100644 --- a/clients/client-redshift-data/RedshiftDataClient.ts +++ b/clients/client-redshift-data/RedshiftDataClient.ts @@ -7,7 +7,7 @@ import { ListDatabasesCommandInput, ListDatabasesCommandOutput } from "./command import { ListSchemasCommandInput, ListSchemasCommandOutput } from "./commands/ListSchemasCommand"; import { ListStatementsCommandInput, ListStatementsCommandOutput } from "./commands/ListStatementsCommand"; import { ListTablesCommandInput, ListTablesCommandOutput } from "./commands/ListTablesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -239,10 +239,7 @@ export class RedshiftDataClient extends __Client< readonly config: RedshiftDataClientResolvedConfig; constructor(configuration: RedshiftDataClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-redshift-data/runtimeConfig.browser.ts b/clients/client-redshift-data/runtimeConfig.browser.ts index 91dcbb9f72cce..aad32b59e6917 100644 --- a/clients/client-redshift-data/runtimeConfig.browser.ts +++ b/clients/client-redshift-data/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RedshiftDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RedshiftDataClientConfig } from "./RedshiftDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RedshiftDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-redshift-data/runtimeConfig.native.ts b/clients/client-redshift-data/runtimeConfig.native.ts index 2c9262c2d6f7f..0e9e3e1171753 100644 --- a/clients/client-redshift-data/runtimeConfig.native.ts +++ b/clients/client-redshift-data/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RedshiftDataClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RedshiftDataClientConfig } from "./RedshiftDataClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RedshiftDataClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-redshift-data/runtimeConfig.shared.ts b/clients/client-redshift-data/runtimeConfig.shared.ts index 98335d33cf7b4..4bfb1f7a10e13 100644 --- a/clients/client-redshift-data/runtimeConfig.shared.ts +++ b/clients/client-redshift-data/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RedshiftDataClientConfig } from "./RedshiftDataClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RedshiftDataClientConfig) => ({ apiVersion: "2019-12-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Redshift Data", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Redshift Data", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-redshift-data/runtimeConfig.ts b/clients/client-redshift-data/runtimeConfig.ts index 7bcd91f909a52..ea4573050a6b6 100644 --- a/clients/client-redshift-data/runtimeConfig.ts +++ b/clients/client-redshift-data/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RedshiftDataClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RedshiftDataClientConfig } from "./RedshiftDataClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RedshiftDataClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-redshift/RedshiftClient.ts b/clients/client-redshift/RedshiftClient.ts index 324718833a4bf..0e28d51c96fc4 100644 --- a/clients/client-redshift/RedshiftClient.ts +++ b/clients/client-redshift/RedshiftClient.ts @@ -358,7 +358,7 @@ import { UpdatePartnerStatusCommandInput, UpdatePartnerStatusCommandOutput, } from "./commands/UpdatePartnerStatusCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -805,10 +805,7 @@ export class RedshiftClient extends __Client< readonly config: RedshiftClientResolvedConfig; constructor(configuration: RedshiftClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-redshift/runtimeConfig.browser.ts b/clients/client-redshift/runtimeConfig.browser.ts index e9ff0952a94e4..f3c52c63b0722 100644 --- a/clients/client-redshift/runtimeConfig.browser.ts +++ b/clients/client-redshift/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RedshiftClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RedshiftClientConfig } from "./RedshiftClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RedshiftClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-redshift/runtimeConfig.native.ts b/clients/client-redshift/runtimeConfig.native.ts index 1cc8faa14b02b..29360a336d15e 100644 --- a/clients/client-redshift/runtimeConfig.native.ts +++ b/clients/client-redshift/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RedshiftClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RedshiftClientConfig } from "./RedshiftClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RedshiftClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-redshift/runtimeConfig.shared.ts b/clients/client-redshift/runtimeConfig.shared.ts index a6684b2310046..9e9d6d2c42936 100644 --- a/clients/client-redshift/runtimeConfig.shared.ts +++ b/clients/client-redshift/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RedshiftClientConfig } from "./RedshiftClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RedshiftClientConfig) => ({ apiVersion: "2012-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Redshift", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Redshift", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-redshift/runtimeConfig.ts b/clients/client-redshift/runtimeConfig.ts index 4c9e8ee38f128..6ce05fae7658b 100644 --- a/clients/client-redshift/runtimeConfig.ts +++ b/clients/client-redshift/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RedshiftClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RedshiftClientConfig } from "./RedshiftClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RedshiftClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rekognition/RekognitionClient.ts b/clients/client-rekognition/RekognitionClient.ts index ac5b9ba4250a6..ac97222bfe19b 100644 --- a/clients/client-rekognition/RekognitionClient.ts +++ b/clients/client-rekognition/RekognitionClient.ts @@ -115,7 +115,7 @@ import { } from "./commands/StopStreamProcessorCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -427,10 +427,7 @@ export class RekognitionClient extends __Client< readonly config: RekognitionClientResolvedConfig; constructor(configuration: RekognitionClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-rekognition/runtimeConfig.browser.ts b/clients/client-rekognition/runtimeConfig.browser.ts index 5051a092c127f..cf2cef7850d5b 100644 --- a/clients/client-rekognition/runtimeConfig.browser.ts +++ b/clients/client-rekognition/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RekognitionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RekognitionClientConfig } from "./RekognitionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RekognitionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-rekognition/runtimeConfig.native.ts b/clients/client-rekognition/runtimeConfig.native.ts index a3a1bc7ce534a..090454466fddd 100644 --- a/clients/client-rekognition/runtimeConfig.native.ts +++ b/clients/client-rekognition/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RekognitionClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RekognitionClientConfig } from "./RekognitionClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RekognitionClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-rekognition/runtimeConfig.shared.ts b/clients/client-rekognition/runtimeConfig.shared.ts index 900a789ddb7fa..87c181841e9e5 100644 --- a/clients/client-rekognition/runtimeConfig.shared.ts +++ b/clients/client-rekognition/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RekognitionClientConfig } from "./RekognitionClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RekognitionClientConfig) => ({ apiVersion: "2016-06-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Rekognition", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Rekognition", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-rekognition/runtimeConfig.ts b/clients/client-rekognition/runtimeConfig.ts index a563446da9a8e..e8ff60537d6c1 100644 --- a/clients/client-rekognition/runtimeConfig.ts +++ b/clients/client-rekognition/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RekognitionClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RekognitionClientConfig } from "./RekognitionClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RekognitionClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-resource-groups-tagging-api/ResourceGroupsTaggingAPIClient.ts b/clients/client-resource-groups-tagging-api/ResourceGroupsTaggingAPIClient.ts index 439e63f5b9ba6..75af45d674684 100644 --- a/clients/client-resource-groups-tagging-api/ResourceGroupsTaggingAPIClient.ts +++ b/clients/client-resource-groups-tagging-api/ResourceGroupsTaggingAPIClient.ts @@ -15,7 +15,7 @@ import { } from "./commands/StartReportCreationCommand"; import { TagResourcesCommandInput, TagResourcesCommandOutput } from "./commands/TagResourcesCommand"; import { UntagResourcesCommandInput, UntagResourcesCommandOutput } from "./commands/UntagResourcesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -242,10 +242,7 @@ export class ResourceGroupsTaggingAPIClient extends __Client< readonly config: ResourceGroupsTaggingAPIClientResolvedConfig; constructor(configuration: ResourceGroupsTaggingAPIClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-resource-groups-tagging-api/runtimeConfig.browser.ts b/clients/client-resource-groups-tagging-api/runtimeConfig.browser.ts index c5e343e7c5fe6..ef408a052008f 100644 --- a/clients/client-resource-groups-tagging-api/runtimeConfig.browser.ts +++ b/clients/client-resource-groups-tagging-api/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ResourceGroupsTaggingAPIClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ResourceGroupsTaggingAPIClientConfig } from "./ResourceGroupsTaggingAPIClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ResourceGroupsTaggingAPIClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-resource-groups-tagging-api/runtimeConfig.native.ts b/clients/client-resource-groups-tagging-api/runtimeConfig.native.ts index d6a4b51afc0f2..efc10fd638942 100644 --- a/clients/client-resource-groups-tagging-api/runtimeConfig.native.ts +++ b/clients/client-resource-groups-tagging-api/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ResourceGroupsTaggingAPIClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ResourceGroupsTaggingAPIClientConfig } from "./ResourceGroupsTaggingAPIClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ResourceGroupsTaggingAPIClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-resource-groups-tagging-api/runtimeConfig.shared.ts b/clients/client-resource-groups-tagging-api/runtimeConfig.shared.ts index c6e15322eae76..c6e0e5157049d 100644 --- a/clients/client-resource-groups-tagging-api/runtimeConfig.shared.ts +++ b/clients/client-resource-groups-tagging-api/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ResourceGroupsTaggingAPIClientConfig } from "./ResourceGroupsTaggingAPIClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ResourceGroupsTaggingAPIClientConfig) => ({ apiVersion: "2017-01-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Resource Groups Tagging API", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Resource Groups Tagging API", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-resource-groups-tagging-api/runtimeConfig.ts b/clients/client-resource-groups-tagging-api/runtimeConfig.ts index c7ea236d95168..661f203d54bba 100644 --- a/clients/client-resource-groups-tagging-api/runtimeConfig.ts +++ b/clients/client-resource-groups-tagging-api/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ResourceGroupsTaggingAPIClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ResourceGroupsTaggingAPIClientConfig } from "./ResourceGroupsTaggingAPIClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ResourceGroupsTaggingAPIClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-resource-groups/ResourceGroupsClient.ts b/clients/client-resource-groups/ResourceGroupsClient.ts index da1866107549e..b38f97c6475ee 100644 --- a/clients/client-resource-groups/ResourceGroupsClient.ts +++ b/clients/client-resource-groups/ResourceGroupsClient.ts @@ -20,7 +20,7 @@ import { UngroupResourcesCommandInput, UngroupResourcesCommandOutput } from "./c import { UntagCommandInput, UntagCommandOutput } from "./commands/UntagCommand"; import { UpdateGroupCommandInput, UpdateGroupCommandOutput } from "./commands/UpdateGroupCommand"; import { UpdateGroupQueryCommandInput, UpdateGroupQueryCommandOutput } from "./commands/UpdateGroupQueryCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -297,10 +297,7 @@ export class ResourceGroupsClient extends __Client< readonly config: ResourceGroupsClientResolvedConfig; constructor(configuration: ResourceGroupsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-resource-groups/runtimeConfig.browser.ts b/clients/client-resource-groups/runtimeConfig.browser.ts index fc44b1f6df837..49050b01b2ff1 100644 --- a/clients/client-resource-groups/runtimeConfig.browser.ts +++ b/clients/client-resource-groups/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ResourceGroupsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ResourceGroupsClientConfig } from "./ResourceGroupsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ResourceGroupsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-resource-groups/runtimeConfig.native.ts b/clients/client-resource-groups/runtimeConfig.native.ts index f1bedafb052c2..95a2df4f6dd0a 100644 --- a/clients/client-resource-groups/runtimeConfig.native.ts +++ b/clients/client-resource-groups/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ResourceGroupsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ResourceGroupsClientConfig } from "./ResourceGroupsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ResourceGroupsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-resource-groups/runtimeConfig.shared.ts b/clients/client-resource-groups/runtimeConfig.shared.ts index 065e0dd5ddc9d..b147faad5ce7d 100644 --- a/clients/client-resource-groups/runtimeConfig.shared.ts +++ b/clients/client-resource-groups/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ResourceGroupsClientConfig } from "./ResourceGroupsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ResourceGroupsClientConfig) => ({ apiVersion: "2017-11-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Resource Groups", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Resource Groups", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-resource-groups/runtimeConfig.ts b/clients/client-resource-groups/runtimeConfig.ts index ea1fe72722dcb..cd1df6cef423d 100644 --- a/clients/client-resource-groups/runtimeConfig.ts +++ b/clients/client-resource-groups/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ResourceGroupsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ResourceGroupsClientConfig } from "./ResourceGroupsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ResourceGroupsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-robomaker/RoboMakerClient.ts b/clients/client-robomaker/RoboMakerClient.ts index 8d58b59280430..21df61f8cfe8a 100644 --- a/clients/client-robomaker/RoboMakerClient.ts +++ b/clients/client-robomaker/RoboMakerClient.ts @@ -169,7 +169,7 @@ import { UpdateWorldTemplateCommandInput, UpdateWorldTemplateCommandOutput, } from "./commands/UpdateWorldTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -493,10 +493,7 @@ export class RoboMakerClient extends __Client< readonly config: RoboMakerClientResolvedConfig; constructor(configuration: RoboMakerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-robomaker/runtimeConfig.browser.ts b/clients/client-robomaker/runtimeConfig.browser.ts index 0a13cebc10dbb..8d4fa5411e750 100644 --- a/clients/client-robomaker/runtimeConfig.browser.ts +++ b/clients/client-robomaker/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RoboMakerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RoboMakerClientConfig } from "./RoboMakerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RoboMakerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-robomaker/runtimeConfig.native.ts b/clients/client-robomaker/runtimeConfig.native.ts index 4336ee14c639f..b2922309b48fd 100644 --- a/clients/client-robomaker/runtimeConfig.native.ts +++ b/clients/client-robomaker/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RoboMakerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RoboMakerClientConfig } from "./RoboMakerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RoboMakerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-robomaker/runtimeConfig.shared.ts b/clients/client-robomaker/runtimeConfig.shared.ts index d1feef1c5614f..2169217105383 100644 --- a/clients/client-robomaker/runtimeConfig.shared.ts +++ b/clients/client-robomaker/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RoboMakerClientConfig } from "./RoboMakerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RoboMakerClientConfig) => ({ apiVersion: "2018-06-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "RoboMaker", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "RoboMaker", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-robomaker/runtimeConfig.ts b/clients/client-robomaker/runtimeConfig.ts index 19393f440b637..5b7a0824ccf69 100644 --- a/clients/client-robomaker/runtimeConfig.ts +++ b/clients/client-robomaker/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RoboMakerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RoboMakerClientConfig } from "./RoboMakerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RoboMakerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route-53-domains/Route53DomainsClient.ts b/clients/client-route-53-domains/Route53DomainsClient.ts index cd9dfabc06a06..e355b7544f1da 100644 --- a/clients/client-route-53-domains/Route53DomainsClient.ts +++ b/clients/client-route-53-domains/Route53DomainsClient.ts @@ -83,7 +83,7 @@ import { UpdateTagsForDomainCommandOutput, } from "./commands/UpdateTagsForDomainCommand"; import { ViewBillingCommandInput, ViewBillingCommandOutput } from "./commands/ViewBillingCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -349,10 +349,7 @@ export class Route53DomainsClient extends __Client< readonly config: Route53DomainsClientResolvedConfig; constructor(configuration: Route53DomainsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-route-53-domains/runtimeConfig.browser.ts b/clients/client-route-53-domains/runtimeConfig.browser.ts index 9c0d12e3b6ca6..00d1003aa27ec 100644 --- a/clients/client-route-53-domains/runtimeConfig.browser.ts +++ b/clients/client-route-53-domains/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./Route53DomainsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53DomainsClientConfig } from "./Route53DomainsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53DomainsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route-53-domains/runtimeConfig.native.ts b/clients/client-route-53-domains/runtimeConfig.native.ts index 904907076e037..cc2c631e6cabf 100644 --- a/clients/client-route-53-domains/runtimeConfig.native.ts +++ b/clients/client-route-53-domains/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./Route53DomainsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { Route53DomainsClientConfig } from "./Route53DomainsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: Route53DomainsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-route-53-domains/runtimeConfig.shared.ts b/clients/client-route-53-domains/runtimeConfig.shared.ts index 820f242fb8ba2..c891f5d588925 100644 --- a/clients/client-route-53-domains/runtimeConfig.shared.ts +++ b/clients/client-route-53-domains/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { Route53DomainsClientConfig } from "./Route53DomainsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: Route53DomainsClientConfig) => ({ apiVersion: "2014-05-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Route 53 Domains", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Route 53 Domains", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-route-53-domains/runtimeConfig.ts b/clients/client-route-53-domains/runtimeConfig.ts index 0878faf85dab4..12173951ff870 100644 --- a/clients/client-route-53-domains/runtimeConfig.ts +++ b/clients/client-route-53-domains/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./Route53DomainsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53DomainsClientConfig } from "./Route53DomainsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53DomainsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route-53/Route53Client.ts b/clients/client-route-53/Route53Client.ts index bfde974b58716..cf3f3be040ac8 100644 --- a/clients/client-route-53/Route53Client.ts +++ b/clients/client-route-53/Route53Client.ts @@ -197,7 +197,7 @@ import { UpdateTrafficPolicyInstanceCommandInput, UpdateTrafficPolicyInstanceCommandOutput, } from "./commands/UpdateTrafficPolicyInstanceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -535,10 +535,7 @@ export class Route53Client extends __Client< readonly config: Route53ClientResolvedConfig; constructor(configuration: Route53ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-route-53/runtimeConfig.browser.ts b/clients/client-route-53/runtimeConfig.browser.ts index b7a3b0bfa98ee..4e673774835e7 100644 --- a/clients/client-route-53/runtimeConfig.browser.ts +++ b/clients/client-route-53/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./Route53Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53ClientConfig } from "./Route53Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route-53/runtimeConfig.native.ts b/clients/client-route-53/runtimeConfig.native.ts index 29fe37020adfe..2f411d9bdca31 100644 --- a/clients/client-route-53/runtimeConfig.native.ts +++ b/clients/client-route-53/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./Route53Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { Route53ClientConfig } from "./Route53Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: Route53ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-route-53/runtimeConfig.shared.ts b/clients/client-route-53/runtimeConfig.shared.ts index 87be3e97e7611..c8a06cb888fb7 100644 --- a/clients/client-route-53/runtimeConfig.shared.ts +++ b/clients/client-route-53/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { Route53ClientConfig } from "./Route53Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: Route53ClientConfig) => ({ apiVersion: "2013-04-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Route 53", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Route 53", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-route-53/runtimeConfig.ts b/clients/client-route-53/runtimeConfig.ts index 34e209394ecb3..09ff09787221e 100644 --- a/clients/client-route-53/runtimeConfig.ts +++ b/clients/client-route-53/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./Route53Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53ClientConfig } from "./Route53Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route53resolver/Route53ResolverClient.ts b/clients/client-route53resolver/Route53ResolverClient.ts index 179bc547f38a2..01ba00a16eebb 100644 --- a/clients/client-route53resolver/Route53ResolverClient.ts +++ b/clients/client-route53resolver/Route53ResolverClient.ts @@ -202,7 +202,7 @@ import { UpdateResolverEndpointCommandOutput, } from "./commands/UpdateResolverEndpointCommand"; import { UpdateResolverRuleCommandInput, UpdateResolverRuleCommandOutput } from "./commands/UpdateResolverRuleCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -564,10 +564,7 @@ export class Route53ResolverClient extends __Client< readonly config: Route53ResolverClientResolvedConfig; constructor(configuration: Route53ResolverClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-route53resolver/runtimeConfig.browser.ts b/clients/client-route53resolver/runtimeConfig.browser.ts index 2f5e12e09910e..932d043f932c2 100644 --- a/clients/client-route53resolver/runtimeConfig.browser.ts +++ b/clients/client-route53resolver/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./Route53ResolverClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53ResolverClientConfig } from "./Route53ResolverClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53ResolverClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-route53resolver/runtimeConfig.native.ts b/clients/client-route53resolver/runtimeConfig.native.ts index bfcb4a831fac3..76c79bb74043e 100644 --- a/clients/client-route53resolver/runtimeConfig.native.ts +++ b/clients/client-route53resolver/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./Route53ResolverClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { Route53ResolverClientConfig } from "./Route53ResolverClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: Route53ResolverClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-route53resolver/runtimeConfig.shared.ts b/clients/client-route53resolver/runtimeConfig.shared.ts index 2a1f9b2fc3335..4492b5845167a 100644 --- a/clients/client-route53resolver/runtimeConfig.shared.ts +++ b/clients/client-route53resolver/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { Route53ResolverClientConfig } from "./Route53ResolverClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: Route53ResolverClientConfig) => ({ apiVersion: "2018-04-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Route53Resolver", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Route53Resolver", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-route53resolver/runtimeConfig.ts b/clients/client-route53resolver/runtimeConfig.ts index 89e7097715057..1629690442e0c 100644 --- a/clients/client-route53resolver/runtimeConfig.ts +++ b/clients/client-route53resolver/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./Route53ResolverClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { Route53ResolverClientConfig } from "./Route53ResolverClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: Route53ResolverClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3-control/S3ControlClient.ts b/clients/client-s3-control/S3ControlClient.ts index 3e1beffac42b7..a632ba7103053 100644 --- a/clients/client-s3-control/S3ControlClient.ts +++ b/clients/client-s3-control/S3ControlClient.ts @@ -134,7 +134,7 @@ import { } from "./commands/PutStorageLensConfigurationTaggingCommand"; import { UpdateJobPriorityCommandInput, UpdateJobPriorityCommandOutput } from "./commands/UpdateJobPriorityCommand"; import { UpdateJobStatusCommandInput, UpdateJobStatusCommandOutput } from "./commands/UpdateJobStatusCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -468,10 +468,7 @@ export class S3ControlClient extends __Client< readonly config: S3ControlClientResolvedConfig; constructor(configuration: S3ControlClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-s3-control/runtimeConfig.browser.ts b/clients/client-s3-control/runtimeConfig.browser.ts index e087b34e1f700..0b53a9558a0da 100644 --- a/clients/client-s3-control/runtimeConfig.browser.ts +++ b/clients/client-s3-control/runtimeConfig.browser.ts @@ -10,31 +10,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./S3ControlClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3ControlClientConfig } from "./S3ControlClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - md5: Md5, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - streamHasher, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3ControlClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + md5: config.md5 ?? Md5, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + streamHasher: config.streamHasher ?? streamHasher, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3-control/runtimeConfig.native.ts b/clients/client-s3-control/runtimeConfig.native.ts index 7d827c755a497..973ea862230b9 100644 --- a/clients/client-s3-control/runtimeConfig.native.ts +++ b/clients/client-s3-control/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./S3ControlClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { S3ControlClientConfig } from "./S3ControlClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: S3ControlClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-s3-control/runtimeConfig.shared.ts b/clients/client-s3-control/runtimeConfig.shared.ts index 8c5a64d60848e..7ec8a6d6b1234 100644 --- a/clients/client-s3-control/runtimeConfig.shared.ts +++ b/clients/client-s3-control/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { S3ControlClientConfig } from "./S3ControlClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: S3ControlClientConfig) => ({ apiVersion: "2018-08-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "S3 Control", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "S3 Control", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-s3-control/runtimeConfig.ts b/clients/client-s3-control/runtimeConfig.ts index d98b9a100a479..7d7a8260e28e8 100644 --- a/clients/client-s3-control/runtimeConfig.ts +++ b/clients/client-s3-control/runtimeConfig.ts @@ -13,31 +13,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./S3ControlClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3ControlClientConfig } from "./S3ControlClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - md5: Hash.bind(null, "md5"), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - streamHasher, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3ControlClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + md5: config.md5 ?? Hash.bind(null, "md5"), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + streamHasher: config.streamHasher ?? streamHasher, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3/S3Client.ts b/clients/client-s3/S3Client.ts index e9ffc5d86e23d..c3951dee2752e 100644 --- a/clients/client-s3/S3Client.ts +++ b/clients/client-s3/S3Client.ts @@ -243,7 +243,7 @@ import { WriteGetObjectResponseCommandInput, WriteGetObjectResponseCommandOutput, } from "./commands/WriteGetObjectResponseCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -684,10 +684,7 @@ export class S3Client extends __Client< readonly config: S3ClientResolvedConfig; constructor(configuration: S3ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-s3/runtimeConfig.browser.ts b/clients/client-s3/runtimeConfig.browser.ts index 11456b9b8f937..57ec0e655ffdd 100644 --- a/clients/client-s3/runtimeConfig.browser.ts +++ b/clients/client-s3/runtimeConfig.browser.ts @@ -11,32 +11,36 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./S3Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3ClientConfig } from "./S3Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamSerdeProvider, - maxAttempts: DEFAULT_MAX_ATTEMPTS, - md5: Md5, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - streamHasher, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + md5: config.md5 ?? Md5, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + streamHasher: config.streamHasher ?? streamHasher, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3/runtimeConfig.native.ts b/clients/client-s3/runtimeConfig.native.ts index ebb0239b47e57..26979d09e8096 100644 --- a/clients/client-s3/runtimeConfig.native.ts +++ b/clients/client-s3/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./S3Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { S3ClientConfig } from "./S3Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: S3ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-s3/runtimeConfig.shared.ts b/clients/client-s3/runtimeConfig.shared.ts index 7e2a09ffe840c..9d5ae1dc693de 100644 --- a/clients/client-s3/runtimeConfig.shared.ts +++ b/clients/client-s3/runtimeConfig.shared.ts @@ -1,17 +1,18 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { S3ClientConfig } from "./S3Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: S3ClientConfig) => ({ apiVersion: "2006-03-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "S3", - signingEscapePath: false, - urlParser: parseUrl, - useArnRegion: false, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "S3", + signingEscapePath: config.signingEscapePath ?? false, + urlParser: config.urlParser ?? parseUrl, + useArnRegion: config.useArnRegion ?? false, +}); diff --git a/clients/client-s3/runtimeConfig.ts b/clients/client-s3/runtimeConfig.ts index 9af9826f6a497..3b9f085311291 100644 --- a/clients/client-s3/runtimeConfig.ts +++ b/clients/client-s3/runtimeConfig.ts @@ -15,33 +15,37 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./S3Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3ClientConfig } from "./S3Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamSerdeProvider, - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - md5: Hash.bind(null, "md5"), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - streamHasher, - useArnRegion: loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS), - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + md5: config.md5 ?? Hash.bind(null, "md5"), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + streamHasher: config.streamHasher ?? streamHasher, + useArnRegion: config.useArnRegion ?? loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS), + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3outposts/S3OutpostsClient.ts b/clients/client-s3outposts/S3OutpostsClient.ts index e732af59542b9..216f3b797d0fd 100644 --- a/clients/client-s3outposts/S3OutpostsClient.ts +++ b/clients/client-s3outposts/S3OutpostsClient.ts @@ -1,7 +1,7 @@ import { CreateEndpointCommandInput, CreateEndpointCommandOutput } from "./commands/CreateEndpointCommand"; import { DeleteEndpointCommandInput, DeleteEndpointCommandOutput } from "./commands/DeleteEndpointCommand"; import { ListEndpointsCommandInput, ListEndpointsCommandOutput } from "./commands/ListEndpointsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -211,10 +211,7 @@ export class S3OutpostsClient extends __Client< readonly config: S3OutpostsClientResolvedConfig; constructor(configuration: S3OutpostsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-s3outposts/runtimeConfig.browser.ts b/clients/client-s3outposts/runtimeConfig.browser.ts index afab6fb00e759..c47019c8f644d 100644 --- a/clients/client-s3outposts/runtimeConfig.browser.ts +++ b/clients/client-s3outposts/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./S3OutpostsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3OutpostsClientConfig } from "./S3OutpostsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3OutpostsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-s3outposts/runtimeConfig.native.ts b/clients/client-s3outposts/runtimeConfig.native.ts index 90497e24b1f1a..acc637dc62730 100644 --- a/clients/client-s3outposts/runtimeConfig.native.ts +++ b/clients/client-s3outposts/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./S3OutpostsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { S3OutpostsClientConfig } from "./S3OutpostsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: S3OutpostsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-s3outposts/runtimeConfig.shared.ts b/clients/client-s3outposts/runtimeConfig.shared.ts index d9c7952917218..7e2056de6197d 100644 --- a/clients/client-s3outposts/runtimeConfig.shared.ts +++ b/clients/client-s3outposts/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { S3OutpostsClientConfig } from "./S3OutpostsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: S3OutpostsClientConfig) => ({ apiVersion: "2017-07-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "S3Outposts", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "S3Outposts", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-s3outposts/runtimeConfig.ts b/clients/client-s3outposts/runtimeConfig.ts index 56149283bd7b5..c4c56945be66b 100644 --- a/clients/client-s3outposts/runtimeConfig.ts +++ b/clients/client-s3outposts/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./S3OutpostsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { S3OutpostsClientConfig } from "./S3OutpostsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: S3OutpostsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-a2i-runtime/SageMakerA2IRuntimeClient.ts b/clients/client-sagemaker-a2i-runtime/SageMakerA2IRuntimeClient.ts index e135fac780544..9106f8a64fd19 100644 --- a/clients/client-sagemaker-a2i-runtime/SageMakerA2IRuntimeClient.ts +++ b/clients/client-sagemaker-a2i-runtime/SageMakerA2IRuntimeClient.ts @@ -3,7 +3,7 @@ import { DescribeHumanLoopCommandInput, DescribeHumanLoopCommandOutput } from ". import { ListHumanLoopsCommandInput, ListHumanLoopsCommandOutput } from "./commands/ListHumanLoopsCommand"; import { StartHumanLoopCommandInput, StartHumanLoopCommandOutput } from "./commands/StartHumanLoopCommand"; import { StopHumanLoopCommandInput, StopHumanLoopCommandOutput } from "./commands/StopHumanLoopCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -248,10 +248,7 @@ export class SageMakerA2IRuntimeClient extends __Client< readonly config: SageMakerA2IRuntimeClientResolvedConfig; constructor(configuration: SageMakerA2IRuntimeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sagemaker-a2i-runtime/runtimeConfig.browser.ts b/clients/client-sagemaker-a2i-runtime/runtimeConfig.browser.ts index da940f30a05b9..03580f17e177d 100644 --- a/clients/client-sagemaker-a2i-runtime/runtimeConfig.browser.ts +++ b/clients/client-sagemaker-a2i-runtime/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SageMakerA2IRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerA2IRuntimeClientConfig } from "./SageMakerA2IRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerA2IRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-a2i-runtime/runtimeConfig.native.ts b/clients/client-sagemaker-a2i-runtime/runtimeConfig.native.ts index 5e177fd876b90..094ea469e3284 100644 --- a/clients/client-sagemaker-a2i-runtime/runtimeConfig.native.ts +++ b/clients/client-sagemaker-a2i-runtime/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SageMakerA2IRuntimeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SageMakerA2IRuntimeClientConfig } from "./SageMakerA2IRuntimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SageMakerA2IRuntimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sagemaker-a2i-runtime/runtimeConfig.shared.ts b/clients/client-sagemaker-a2i-runtime/runtimeConfig.shared.ts index e40c60915db1e..97fa844e91c99 100644 --- a/clients/client-sagemaker-a2i-runtime/runtimeConfig.shared.ts +++ b/clients/client-sagemaker-a2i-runtime/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SageMakerA2IRuntimeClientConfig } from "./SageMakerA2IRuntimeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SageMakerA2IRuntimeClientConfig) => ({ apiVersion: "2019-11-07", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SageMaker A2I Runtime", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SageMaker A2I Runtime", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sagemaker-a2i-runtime/runtimeConfig.ts b/clients/client-sagemaker-a2i-runtime/runtimeConfig.ts index ad1e99f8e9fa9..89867ca646c3c 100644 --- a/clients/client-sagemaker-a2i-runtime/runtimeConfig.ts +++ b/clients/client-sagemaker-a2i-runtime/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SageMakerA2IRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerA2IRuntimeClientConfig } from "./SageMakerA2IRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerA2IRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-edge/SagemakerEdgeClient.ts b/clients/client-sagemaker-edge/SagemakerEdgeClient.ts index 7fac7ee449b91..684750aaa836b 100644 --- a/clients/client-sagemaker-edge/SagemakerEdgeClient.ts +++ b/clients/client-sagemaker-edge/SagemakerEdgeClient.ts @@ -3,7 +3,7 @@ import { GetDeviceRegistrationCommandOutput, } from "./commands/GetDeviceRegistrationCommand"; import { SendHeartbeatCommandInput, SendHeartbeatCommandOutput } from "./commands/SendHeartbeatCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -213,10 +213,7 @@ export class SagemakerEdgeClient extends __Client< readonly config: SagemakerEdgeClientResolvedConfig; constructor(configuration: SagemakerEdgeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sagemaker-edge/runtimeConfig.browser.ts b/clients/client-sagemaker-edge/runtimeConfig.browser.ts index 6a18d25ed633a..2f561d611d110 100644 --- a/clients/client-sagemaker-edge/runtimeConfig.browser.ts +++ b/clients/client-sagemaker-edge/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SagemakerEdgeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SagemakerEdgeClientConfig } from "./SagemakerEdgeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SagemakerEdgeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-edge/runtimeConfig.native.ts b/clients/client-sagemaker-edge/runtimeConfig.native.ts index a073acc215757..fd6b7cd128234 100644 --- a/clients/client-sagemaker-edge/runtimeConfig.native.ts +++ b/clients/client-sagemaker-edge/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SagemakerEdgeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SagemakerEdgeClientConfig } from "./SagemakerEdgeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SagemakerEdgeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sagemaker-edge/runtimeConfig.shared.ts b/clients/client-sagemaker-edge/runtimeConfig.shared.ts index 3e1755c52b827..92ed0520ec6c0 100644 --- a/clients/client-sagemaker-edge/runtimeConfig.shared.ts +++ b/clients/client-sagemaker-edge/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SagemakerEdgeClientConfig } from "./SagemakerEdgeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SagemakerEdgeClientConfig) => ({ apiVersion: "2020-09-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Sagemaker Edge", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Sagemaker Edge", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sagemaker-edge/runtimeConfig.ts b/clients/client-sagemaker-edge/runtimeConfig.ts index 6c0d45c72e133..133bab8978c1c 100644 --- a/clients/client-sagemaker-edge/runtimeConfig.ts +++ b/clients/client-sagemaker-edge/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SagemakerEdgeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SagemakerEdgeClientConfig } from "./SagemakerEdgeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SagemakerEdgeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-featurestore-runtime/SageMakerFeatureStoreRuntimeClient.ts b/clients/client-sagemaker-featurestore-runtime/SageMakerFeatureStoreRuntimeClient.ts index 12090237c2f38..72f7b360d9507 100644 --- a/clients/client-sagemaker-featurestore-runtime/SageMakerFeatureStoreRuntimeClient.ts +++ b/clients/client-sagemaker-featurestore-runtime/SageMakerFeatureStoreRuntimeClient.ts @@ -2,7 +2,7 @@ import { BatchGetRecordCommandInput, BatchGetRecordCommandOutput } from "./comma import { DeleteRecordCommandInput, DeleteRecordCommandOutput } from "./commands/DeleteRecordCommand"; import { GetRecordCommandInput, GetRecordCommandOutput } from "./commands/GetRecordCommand"; import { PutRecordCommandInput, PutRecordCommandOutput } from "./commands/PutRecordCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -247,10 +247,7 @@ export class SageMakerFeatureStoreRuntimeClient extends __Client< readonly config: SageMakerFeatureStoreRuntimeClientResolvedConfig; constructor(configuration: SageMakerFeatureStoreRuntimeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.browser.ts b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.browser.ts index befe1304e5afa..f40d20513cb87 100644 --- a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.browser.ts +++ b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SageMakerFeatureStoreRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerFeatureStoreRuntimeClientConfig } from "./SageMakerFeatureStoreRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerFeatureStoreRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.native.ts b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.native.ts index 40526c262fb02..e4f4ad59212e0 100644 --- a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.native.ts +++ b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SageMakerFeatureStoreRuntimeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SageMakerFeatureStoreRuntimeClientConfig } from "./SageMakerFeatureStoreRuntimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SageMakerFeatureStoreRuntimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.shared.ts b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.shared.ts index c0eb819f6060d..34be1771f9ede 100644 --- a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.shared.ts +++ b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SageMakerFeatureStoreRuntimeClientConfig } from "./SageMakerFeatureStoreRuntimeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SageMakerFeatureStoreRuntimeClientConfig) => ({ apiVersion: "2020-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SageMaker FeatureStore Runtime", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SageMaker FeatureStore Runtime", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.ts b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.ts index 3a7d298e20997..f5b10a4ccfc26 100644 --- a/clients/client-sagemaker-featurestore-runtime/runtimeConfig.ts +++ b/clients/client-sagemaker-featurestore-runtime/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SageMakerFeatureStoreRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerFeatureStoreRuntimeClientConfig } from "./SageMakerFeatureStoreRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerFeatureStoreRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-runtime/SageMakerRuntimeClient.ts b/clients/client-sagemaker-runtime/SageMakerRuntimeClient.ts index e2c29d451c84c..b1b6dcd207f87 100644 --- a/clients/client-sagemaker-runtime/SageMakerRuntimeClient.ts +++ b/clients/client-sagemaker-runtime/SageMakerRuntimeClient.ts @@ -1,5 +1,5 @@ import { InvokeEndpointCommandInput, InvokeEndpointCommandOutput } from "./commands/InvokeEndpointCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -209,10 +209,7 @@ export class SageMakerRuntimeClient extends __Client< readonly config: SageMakerRuntimeClientResolvedConfig; constructor(configuration: SageMakerRuntimeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sagemaker-runtime/runtimeConfig.browser.ts b/clients/client-sagemaker-runtime/runtimeConfig.browser.ts index 9e4d94da098c9..7a8cc9e62e3e2 100644 --- a/clients/client-sagemaker-runtime/runtimeConfig.browser.ts +++ b/clients/client-sagemaker-runtime/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SageMakerRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker-runtime/runtimeConfig.native.ts b/clients/client-sagemaker-runtime/runtimeConfig.native.ts index 51a4f4f9c2b49..51063ff4b631e 100644 --- a/clients/client-sagemaker-runtime/runtimeConfig.native.ts +++ b/clients/client-sagemaker-runtime/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SageMakerRuntimeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SageMakerRuntimeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sagemaker-runtime/runtimeConfig.shared.ts b/clients/client-sagemaker-runtime/runtimeConfig.shared.ts index 997ccd3d0cdc8..69521077eed49 100644 --- a/clients/client-sagemaker-runtime/runtimeConfig.shared.ts +++ b/clients/client-sagemaker-runtime/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SageMakerRuntimeClientConfig) => ({ apiVersion: "2017-05-13", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SageMaker Runtime", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SageMaker Runtime", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sagemaker-runtime/runtimeConfig.ts b/clients/client-sagemaker-runtime/runtimeConfig.ts index d262cc7b06422..d04bd1b730f56 100644 --- a/clients/client-sagemaker-runtime/runtimeConfig.ts +++ b/clients/client-sagemaker-runtime/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SageMakerRuntimeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerRuntimeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker/SageMakerClient.ts b/clients/client-sagemaker/SageMakerClient.ts index 7e59731923b9d..f858c3e97947a 100644 --- a/clients/client-sagemaker/SageMakerClient.ts +++ b/clients/client-sagemaker/SageMakerClient.ts @@ -572,7 +572,7 @@ import { import { UpdateUserProfileCommandInput, UpdateUserProfileCommandOutput } from "./commands/UpdateUserProfileCommand"; import { UpdateWorkforceCommandInput, UpdateWorkforceCommandOutput } from "./commands/UpdateWorkforceCommand"; import { UpdateWorkteamCommandInput, UpdateWorkteamCommandOutput } from "./commands/UpdateWorkteamCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -1267,10 +1267,7 @@ export class SageMakerClient extends __Client< readonly config: SageMakerClientResolvedConfig; constructor(configuration: SageMakerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sagemaker/runtimeConfig.browser.ts b/clients/client-sagemaker/runtimeConfig.browser.ts index 97543318eeb21..825521a312219 100644 --- a/clients/client-sagemaker/runtimeConfig.browser.ts +++ b/clients/client-sagemaker/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SageMakerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerClientConfig } from "./SageMakerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sagemaker/runtimeConfig.native.ts b/clients/client-sagemaker/runtimeConfig.native.ts index b9f956a952f5a..7c01d313a0108 100644 --- a/clients/client-sagemaker/runtimeConfig.native.ts +++ b/clients/client-sagemaker/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SageMakerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SageMakerClientConfig } from "./SageMakerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SageMakerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sagemaker/runtimeConfig.shared.ts b/clients/client-sagemaker/runtimeConfig.shared.ts index 155d6a2849e8a..15f6a80c9dada 100644 --- a/clients/client-sagemaker/runtimeConfig.shared.ts +++ b/clients/client-sagemaker/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SageMakerClientConfig } from "./SageMakerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SageMakerClientConfig) => ({ apiVersion: "2017-07-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SageMaker", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SageMaker", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sagemaker/runtimeConfig.ts b/clients/client-sagemaker/runtimeConfig.ts index 79addccb4529d..2989f4601777e 100644 --- a/clients/client-sagemaker/runtimeConfig.ts +++ b/clients/client-sagemaker/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SageMakerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SageMakerClientConfig } from "./SageMakerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SageMakerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-savingsplans/SavingsplansClient.ts b/clients/client-savingsplans/SavingsplansClient.ts index 1027eb616a92a..0077ddafe6193 100644 --- a/clients/client-savingsplans/SavingsplansClient.ts +++ b/clients/client-savingsplans/SavingsplansClient.ts @@ -25,7 +25,7 @@ import { } from "./commands/ListTagsForResourceCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -256,10 +256,7 @@ export class SavingsplansClient extends __Client< readonly config: SavingsplansClientResolvedConfig; constructor(configuration: SavingsplansClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-savingsplans/runtimeConfig.browser.ts b/clients/client-savingsplans/runtimeConfig.browser.ts index 454c97c060965..4cc6b1d2eed2d 100644 --- a/clients/client-savingsplans/runtimeConfig.browser.ts +++ b/clients/client-savingsplans/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SavingsplansClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SavingsplansClientConfig } from "./SavingsplansClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SavingsplansClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-savingsplans/runtimeConfig.native.ts b/clients/client-savingsplans/runtimeConfig.native.ts index 7f59691656621..48a0b7d11ba59 100644 --- a/clients/client-savingsplans/runtimeConfig.native.ts +++ b/clients/client-savingsplans/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SavingsplansClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SavingsplansClientConfig } from "./SavingsplansClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SavingsplansClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-savingsplans/runtimeConfig.shared.ts b/clients/client-savingsplans/runtimeConfig.shared.ts index d1267e3c9b70b..a02d35d1680e5 100644 --- a/clients/client-savingsplans/runtimeConfig.shared.ts +++ b/clients/client-savingsplans/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SavingsplansClientConfig } from "./SavingsplansClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SavingsplansClientConfig) => ({ apiVersion: "2019-06-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "savingsplans", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "savingsplans", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-savingsplans/runtimeConfig.ts b/clients/client-savingsplans/runtimeConfig.ts index 57ffd6ebed5e4..af5e973d0f8e3 100644 --- a/clients/client-savingsplans/runtimeConfig.ts +++ b/clients/client-savingsplans/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SavingsplansClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SavingsplansClientConfig } from "./SavingsplansClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SavingsplansClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-schemas/SchemasClient.ts b/clients/client-schemas/SchemasClient.ts index 54c607155929c..defb9aa2df72e 100644 --- a/clients/client-schemas/SchemasClient.ts +++ b/clients/client-schemas/SchemasClient.ts @@ -47,7 +47,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateDiscovererCommandInput, UpdateDiscovererCommandOutput } from "./commands/UpdateDiscovererCommand"; import { UpdateRegistryCommandInput, UpdateRegistryCommandOutput } from "./commands/UpdateRegistryCommand"; import { UpdateSchemaCommandInput, UpdateSchemaCommandOutput } from "./commands/UpdateSchemaCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -319,10 +319,7 @@ export class SchemasClient extends __Client< readonly config: SchemasClientResolvedConfig; constructor(configuration: SchemasClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-schemas/runtimeConfig.browser.ts b/clients/client-schemas/runtimeConfig.browser.ts index a574f433d2f71..12cb4aa42289c 100644 --- a/clients/client-schemas/runtimeConfig.browser.ts +++ b/clients/client-schemas/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SchemasClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SchemasClientConfig } from "./SchemasClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SchemasClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-schemas/runtimeConfig.native.ts b/clients/client-schemas/runtimeConfig.native.ts index 7412626d064e6..0898502c4bdff 100644 --- a/clients/client-schemas/runtimeConfig.native.ts +++ b/clients/client-schemas/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SchemasClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SchemasClientConfig } from "./SchemasClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SchemasClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-schemas/runtimeConfig.shared.ts b/clients/client-schemas/runtimeConfig.shared.ts index f0ce6be7b3565..3623abe9e6657 100644 --- a/clients/client-schemas/runtimeConfig.shared.ts +++ b/clients/client-schemas/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SchemasClientConfig } from "./SchemasClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SchemasClientConfig) => ({ apiVersion: "2019-12-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "schemas", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "schemas", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-schemas/runtimeConfig.ts b/clients/client-schemas/runtimeConfig.ts index 775ba42c17ee9..21388a6850590 100644 --- a/clients/client-schemas/runtimeConfig.ts +++ b/clients/client-schemas/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SchemasClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SchemasClientConfig } from "./SchemasClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SchemasClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-secrets-manager/SecretsManagerClient.ts b/clients/client-secrets-manager/SecretsManagerClient.ts index 039935d938aa1..721f45bdd3dda 100644 --- a/clients/client-secrets-manager/SecretsManagerClient.ts +++ b/clients/client-secrets-manager/SecretsManagerClient.ts @@ -41,7 +41,7 @@ import { ValidateResourcePolicyCommandInput, ValidateResourcePolicyCommandOutput, } from "./commands/ValidateResourcePolicyCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -357,10 +357,7 @@ export class SecretsManagerClient extends __Client< readonly config: SecretsManagerClientResolvedConfig; constructor(configuration: SecretsManagerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-secrets-manager/runtimeConfig.browser.ts b/clients/client-secrets-manager/runtimeConfig.browser.ts index 0d613882d93c8..32cc1889c963b 100644 --- a/clients/client-secrets-manager/runtimeConfig.browser.ts +++ b/clients/client-secrets-manager/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SecretsManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SecretsManagerClientConfig } from "./SecretsManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SecretsManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-secrets-manager/runtimeConfig.native.ts b/clients/client-secrets-manager/runtimeConfig.native.ts index 21eb6fa13d363..1ce38b48fccf7 100644 --- a/clients/client-secrets-manager/runtimeConfig.native.ts +++ b/clients/client-secrets-manager/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SecretsManagerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SecretsManagerClientConfig } from "./SecretsManagerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SecretsManagerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-secrets-manager/runtimeConfig.shared.ts b/clients/client-secrets-manager/runtimeConfig.shared.ts index 1b9a2be6bb44e..a39e27bbf482b 100644 --- a/clients/client-secrets-manager/runtimeConfig.shared.ts +++ b/clients/client-secrets-manager/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SecretsManagerClientConfig } from "./SecretsManagerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SecretsManagerClientConfig) => ({ apiVersion: "2017-10-17", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Secrets Manager", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Secrets Manager", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-secrets-manager/runtimeConfig.ts b/clients/client-secrets-manager/runtimeConfig.ts index 942635d9ab7a4..243aeb3bf30f8 100644 --- a/clients/client-secrets-manager/runtimeConfig.ts +++ b/clients/client-secrets-manager/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SecretsManagerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SecretsManagerClientConfig } from "./SecretsManagerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SecretsManagerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-securityhub/SecurityHubClient.ts b/clients/client-securityhub/SecurityHubClient.ts index 412e2eb83fb29..fad4f77e628f2 100644 --- a/clients/client-securityhub/SecurityHubClient.ts +++ b/clients/client-securityhub/SecurityHubClient.ts @@ -121,7 +121,7 @@ import { UpdateStandardsControlCommandInput, UpdateStandardsControlCommandOutput, } from "./commands/UpdateStandardsControlCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -487,10 +487,7 @@ export class SecurityHubClient extends __Client< readonly config: SecurityHubClientResolvedConfig; constructor(configuration: SecurityHubClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-securityhub/runtimeConfig.browser.ts b/clients/client-securityhub/runtimeConfig.browser.ts index 1f2cbe9cc493a..e962f7439f6b1 100644 --- a/clients/client-securityhub/runtimeConfig.browser.ts +++ b/clients/client-securityhub/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SecurityHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SecurityHubClientConfig } from "./SecurityHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SecurityHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-securityhub/runtimeConfig.native.ts b/clients/client-securityhub/runtimeConfig.native.ts index bcfb4c4062c2a..f838f18dd2071 100644 --- a/clients/client-securityhub/runtimeConfig.native.ts +++ b/clients/client-securityhub/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SecurityHubClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SecurityHubClientConfig } from "./SecurityHubClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SecurityHubClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-securityhub/runtimeConfig.shared.ts b/clients/client-securityhub/runtimeConfig.shared.ts index fdbffa7c17d21..f46bb72d44105 100644 --- a/clients/client-securityhub/runtimeConfig.shared.ts +++ b/clients/client-securityhub/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SecurityHubClientConfig } from "./SecurityHubClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SecurityHubClientConfig) => ({ apiVersion: "2018-10-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SecurityHub", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SecurityHub", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-securityhub/runtimeConfig.ts b/clients/client-securityhub/runtimeConfig.ts index 2f7ed6da5e676..3dddb6159305c 100644 --- a/clients/client-securityhub/runtimeConfig.ts +++ b/clients/client-securityhub/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SecurityHubClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SecurityHubClientConfig } from "./SecurityHubClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SecurityHubClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-serverlessapplicationrepository/ServerlessApplicationRepositoryClient.ts b/clients/client-serverlessapplicationrepository/ServerlessApplicationRepositoryClient.ts index c139fc77b370f..1b806c73642fe 100644 --- a/clients/client-serverlessapplicationrepository/ServerlessApplicationRepositoryClient.ts +++ b/clients/client-serverlessapplicationrepository/ServerlessApplicationRepositoryClient.ts @@ -36,7 +36,7 @@ import { } from "./commands/PutApplicationPolicyCommand"; import { UnshareApplicationCommandInput, UnshareApplicationCommandOutput } from "./commands/UnshareApplicationCommand"; import { UpdateApplicationCommandInput, UpdateApplicationCommandOutput } from "./commands/UpdateApplicationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -294,10 +294,7 @@ export class ServerlessApplicationRepositoryClient extends __Client< readonly config: ServerlessApplicationRepositoryClientResolvedConfig; constructor(configuration: ServerlessApplicationRepositoryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-serverlessapplicationrepository/runtimeConfig.browser.ts b/clients/client-serverlessapplicationrepository/runtimeConfig.browser.ts index 916755f2b4d7b..82bc48b0a9f3c 100644 --- a/clients/client-serverlessapplicationrepository/runtimeConfig.browser.ts +++ b/clients/client-serverlessapplicationrepository/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ServerlessApplicationRepositoryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServerlessApplicationRepositoryClientConfig } from "./ServerlessApplicationRepositoryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServerlessApplicationRepositoryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-serverlessapplicationrepository/runtimeConfig.native.ts b/clients/client-serverlessapplicationrepository/runtimeConfig.native.ts index 072c7ca09544d..34e427da43b64 100644 --- a/clients/client-serverlessapplicationrepository/runtimeConfig.native.ts +++ b/clients/client-serverlessapplicationrepository/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ServerlessApplicationRepositoryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ServerlessApplicationRepositoryClientConfig } from "./ServerlessApplicationRepositoryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ServerlessApplicationRepositoryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-serverlessapplicationrepository/runtimeConfig.shared.ts b/clients/client-serverlessapplicationrepository/runtimeConfig.shared.ts index da6791b1fb104..21466de3636b2 100644 --- a/clients/client-serverlessapplicationrepository/runtimeConfig.shared.ts +++ b/clients/client-serverlessapplicationrepository/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ServerlessApplicationRepositoryClientConfig } from "./ServerlessApplicationRepositoryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ServerlessApplicationRepositoryClientConfig) => ({ apiVersion: "2017-09-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ServerlessApplicationRepository", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ServerlessApplicationRepository", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-serverlessapplicationrepository/runtimeConfig.ts b/clients/client-serverlessapplicationrepository/runtimeConfig.ts index b192fea610529..48131d80c2ac5 100644 --- a/clients/client-serverlessapplicationrepository/runtimeConfig.ts +++ b/clients/client-serverlessapplicationrepository/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ServerlessApplicationRepositoryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServerlessApplicationRepositoryClientConfig } from "./ServerlessApplicationRepositoryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServerlessApplicationRepositoryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-catalog-appregistry/ServiceCatalogAppRegistryClient.ts b/clients/client-service-catalog-appregistry/ServiceCatalogAppRegistryClient.ts index 3543136b8078d..12067d5377147 100644 --- a/clients/client-service-catalog-appregistry/ServiceCatalogAppRegistryClient.ts +++ b/clients/client-service-catalog-appregistry/ServiceCatalogAppRegistryClient.ts @@ -48,7 +48,7 @@ import { UpdateAttributeGroupCommandInput, UpdateAttributeGroupCommandOutput, } from "./commands/UpdateAttributeGroupCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -305,10 +305,7 @@ export class ServiceCatalogAppRegistryClient extends __Client< readonly config: ServiceCatalogAppRegistryClientResolvedConfig; constructor(configuration: ServiceCatalogAppRegistryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-service-catalog-appregistry/runtimeConfig.browser.ts b/clients/client-service-catalog-appregistry/runtimeConfig.browser.ts index 38b60048db536..1b5632b05971e 100644 --- a/clients/client-service-catalog-appregistry/runtimeConfig.browser.ts +++ b/clients/client-service-catalog-appregistry/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ServiceCatalogAppRegistryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceCatalogAppRegistryClientConfig } from "./ServiceCatalogAppRegistryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceCatalogAppRegistryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-catalog-appregistry/runtimeConfig.native.ts b/clients/client-service-catalog-appregistry/runtimeConfig.native.ts index f844117ad17fe..0c90d94b5fcf3 100644 --- a/clients/client-service-catalog-appregistry/runtimeConfig.native.ts +++ b/clients/client-service-catalog-appregistry/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ServiceCatalogAppRegistryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ServiceCatalogAppRegistryClientConfig } from "./ServiceCatalogAppRegistryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ServiceCatalogAppRegistryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-service-catalog-appregistry/runtimeConfig.shared.ts b/clients/client-service-catalog-appregistry/runtimeConfig.shared.ts index 0d37aa8a2d6d5..ea2d942814c23 100644 --- a/clients/client-service-catalog-appregistry/runtimeConfig.shared.ts +++ b/clients/client-service-catalog-appregistry/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ServiceCatalogAppRegistryClientConfig } from "./ServiceCatalogAppRegistryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ServiceCatalogAppRegistryClientConfig) => ({ apiVersion: "2020-06-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Service Catalog AppRegistry", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Service Catalog AppRegistry", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-service-catalog-appregistry/runtimeConfig.ts b/clients/client-service-catalog-appregistry/runtimeConfig.ts index 3c42584910361..6830204f9eed6 100644 --- a/clients/client-service-catalog-appregistry/runtimeConfig.ts +++ b/clients/client-service-catalog-appregistry/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ServiceCatalogAppRegistryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceCatalogAppRegistryClientConfig } from "./ServiceCatalogAppRegistryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceCatalogAppRegistryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-catalog/ServiceCatalogClient.ts b/clients/client-service-catalog/ServiceCatalogClient.ts index 668502a30e0df..e1a746cf3bf89 100644 --- a/clients/client-service-catalog/ServiceCatalogClient.ts +++ b/clients/client-service-catalog/ServiceCatalogClient.ts @@ -271,7 +271,7 @@ import { UpdateServiceActionCommandOutput, } from "./commands/UpdateServiceActionCommand"; import { UpdateTagOptionCommandInput, UpdateTagOptionCommandOutput } from "./commands/UpdateTagOptionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -661,10 +661,7 @@ export class ServiceCatalogClient extends __Client< readonly config: ServiceCatalogClientResolvedConfig; constructor(configuration: ServiceCatalogClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-service-catalog/runtimeConfig.browser.ts b/clients/client-service-catalog/runtimeConfig.browser.ts index 4269f5b02a665..dbdab34f1eb7c 100644 --- a/clients/client-service-catalog/runtimeConfig.browser.ts +++ b/clients/client-service-catalog/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ServiceCatalogClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceCatalogClientConfig } from "./ServiceCatalogClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceCatalogClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-catalog/runtimeConfig.native.ts b/clients/client-service-catalog/runtimeConfig.native.ts index 657e3b597c11a..85fabe8cfd8e7 100644 --- a/clients/client-service-catalog/runtimeConfig.native.ts +++ b/clients/client-service-catalog/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ServiceCatalogClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ServiceCatalogClientConfig } from "./ServiceCatalogClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ServiceCatalogClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-service-catalog/runtimeConfig.shared.ts b/clients/client-service-catalog/runtimeConfig.shared.ts index 9be408d6c0600..97cb2331e4781 100644 --- a/clients/client-service-catalog/runtimeConfig.shared.ts +++ b/clients/client-service-catalog/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ServiceCatalogClientConfig } from "./ServiceCatalogClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ServiceCatalogClientConfig) => ({ apiVersion: "2015-12-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Service Catalog", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Service Catalog", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-service-catalog/runtimeConfig.ts b/clients/client-service-catalog/runtimeConfig.ts index b4a870cbc79fc..410a13671db2f 100644 --- a/clients/client-service-catalog/runtimeConfig.ts +++ b/clients/client-service-catalog/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ServiceCatalogClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceCatalogClientConfig } from "./ServiceCatalogClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceCatalogClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-quotas/ServiceQuotasClient.ts b/clients/client-service-quotas/ServiceQuotasClient.ts index ec2d8b01664f8..cabe768d80b4e 100644 --- a/clients/client-service-quotas/ServiceQuotasClient.ts +++ b/clients/client-service-quotas/ServiceQuotasClient.ts @@ -59,7 +59,7 @@ import { } from "./commands/RequestServiceQuotaIncreaseCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -309,10 +309,7 @@ export class ServiceQuotasClient extends __Client< readonly config: ServiceQuotasClientResolvedConfig; constructor(configuration: ServiceQuotasClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-service-quotas/runtimeConfig.browser.ts b/clients/client-service-quotas/runtimeConfig.browser.ts index 6c5161791f362..5719907f105b3 100644 --- a/clients/client-service-quotas/runtimeConfig.browser.ts +++ b/clients/client-service-quotas/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ServiceQuotasClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceQuotasClientConfig } from "./ServiceQuotasClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceQuotasClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-service-quotas/runtimeConfig.native.ts b/clients/client-service-quotas/runtimeConfig.native.ts index 5df0b7866f081..027a231228323 100644 --- a/clients/client-service-quotas/runtimeConfig.native.ts +++ b/clients/client-service-quotas/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ServiceQuotasClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ServiceQuotasClientConfig } from "./ServiceQuotasClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ServiceQuotasClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-service-quotas/runtimeConfig.shared.ts b/clients/client-service-quotas/runtimeConfig.shared.ts index 61479b937ae80..298cdea303d66 100644 --- a/clients/client-service-quotas/runtimeConfig.shared.ts +++ b/clients/client-service-quotas/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ServiceQuotasClientConfig } from "./ServiceQuotasClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ServiceQuotasClientConfig) => ({ apiVersion: "2019-06-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Service Quotas", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Service Quotas", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-service-quotas/runtimeConfig.ts b/clients/client-service-quotas/runtimeConfig.ts index 9efce42716eec..19f13ccbd6b46 100644 --- a/clients/client-service-quotas/runtimeConfig.ts +++ b/clients/client-service-quotas/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ServiceQuotasClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceQuotasClientConfig } from "./ServiceQuotasClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceQuotasClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-servicediscovery/ServiceDiscoveryClient.ts b/clients/client-servicediscovery/ServiceDiscoveryClient.ts index e56c0a7efc0fc..1f160782936a9 100644 --- a/clients/client-servicediscovery/ServiceDiscoveryClient.ts +++ b/clients/client-servicediscovery/ServiceDiscoveryClient.ts @@ -51,7 +51,7 @@ import { UpdatePublicDnsNamespaceCommandOutput, } from "./commands/UpdatePublicDnsNamespaceCommand"; import { UpdateServiceCommandInput, UpdateServiceCommandOutput } from "./commands/UpdateServiceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -318,10 +318,7 @@ export class ServiceDiscoveryClient extends __Client< readonly config: ServiceDiscoveryClientResolvedConfig; constructor(configuration: ServiceDiscoveryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-servicediscovery/runtimeConfig.browser.ts b/clients/client-servicediscovery/runtimeConfig.browser.ts index 5d943730e6300..572e617e1baa8 100644 --- a/clients/client-servicediscovery/runtimeConfig.browser.ts +++ b/clients/client-servicediscovery/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ServiceDiscoveryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceDiscoveryClientConfig } from "./ServiceDiscoveryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceDiscoveryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-servicediscovery/runtimeConfig.native.ts b/clients/client-servicediscovery/runtimeConfig.native.ts index 4567b2f65fe8a..ca61275a1075b 100644 --- a/clients/client-servicediscovery/runtimeConfig.native.ts +++ b/clients/client-servicediscovery/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ServiceDiscoveryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ServiceDiscoveryClientConfig } from "./ServiceDiscoveryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ServiceDiscoveryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-servicediscovery/runtimeConfig.shared.ts b/clients/client-servicediscovery/runtimeConfig.shared.ts index 022e47be96792..5a6736b460aa8 100644 --- a/clients/client-servicediscovery/runtimeConfig.shared.ts +++ b/clients/client-servicediscovery/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ServiceDiscoveryClientConfig } from "./ServiceDiscoveryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ServiceDiscoveryClientConfig) => ({ apiVersion: "2017-03-14", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "ServiceDiscovery", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "ServiceDiscovery", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-servicediscovery/runtimeConfig.ts b/clients/client-servicediscovery/runtimeConfig.ts index b50dc5923a77e..0382691f03adb 100644 --- a/clients/client-servicediscovery/runtimeConfig.ts +++ b/clients/client-servicediscovery/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ServiceDiscoveryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ServiceDiscoveryClientConfig } from "./ServiceDiscoveryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ServiceDiscoveryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ses/SESClient.ts b/clients/client-ses/SESClient.ts index 661a6d23e5c5e..a4abde5c13f17 100644 --- a/clients/client-ses/SESClient.ts +++ b/clients/client-ses/SESClient.ts @@ -219,7 +219,7 @@ import { VerifyEmailIdentityCommandInput, VerifyEmailIdentityCommandOutput, } from "./commands/VerifyEmailIdentityCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -579,10 +579,7 @@ export class SESClient extends __Client< readonly config: SESClientResolvedConfig; constructor(configuration: SESClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ses/runtimeConfig.browser.ts b/clients/client-ses/runtimeConfig.browser.ts index 2ee1430ca9e14..e94546f157bc6 100644 --- a/clients/client-ses/runtimeConfig.browser.ts +++ b/clients/client-ses/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SESClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SESClientConfig } from "./SESClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SESClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ses/runtimeConfig.native.ts b/clients/client-ses/runtimeConfig.native.ts index c5255bbc70c25..0d784cebbd61c 100644 --- a/clients/client-ses/runtimeConfig.native.ts +++ b/clients/client-ses/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SESClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SESClientConfig } from "./SESClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SESClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ses/runtimeConfig.shared.ts b/clients/client-ses/runtimeConfig.shared.ts index 442c6b43a06a5..edb372f6e8b7b 100644 --- a/clients/client-ses/runtimeConfig.shared.ts +++ b/clients/client-ses/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SESClientConfig } from "./SESClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SESClientConfig) => ({ apiVersion: "2010-12-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SES", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SES", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ses/runtimeConfig.ts b/clients/client-ses/runtimeConfig.ts index 4c531c4ea6601..e6d1cc41fd0c0 100644 --- a/clients/client-ses/runtimeConfig.ts +++ b/clients/client-ses/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SESClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SESClientConfig } from "./SESClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SESClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sesv2/SESv2Client.ts b/clients/client-sesv2/SESv2Client.ts index 49edfeb23bd6a..54975c46f8d59 100644 --- a/clients/client-sesv2/SESv2Client.ts +++ b/clients/client-sesv2/SESv2Client.ts @@ -250,7 +250,7 @@ import { UpdateEmailTemplateCommandInput, UpdateEmailTemplateCommandOutput, } from "./commands/UpdateEmailTemplateCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -641,10 +641,7 @@ export class SESv2Client extends __Client< readonly config: SESv2ClientResolvedConfig; constructor(configuration: SESv2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sesv2/runtimeConfig.browser.ts b/clients/client-sesv2/runtimeConfig.browser.ts index cf7e122e26a32..0c120e3f29482 100644 --- a/clients/client-sesv2/runtimeConfig.browser.ts +++ b/clients/client-sesv2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SESv2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SESv2ClientConfig } from "./SESv2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SESv2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sesv2/runtimeConfig.native.ts b/clients/client-sesv2/runtimeConfig.native.ts index 904b0fc2ce60e..4192f5782da19 100644 --- a/clients/client-sesv2/runtimeConfig.native.ts +++ b/clients/client-sesv2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SESv2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SESv2ClientConfig } from "./SESv2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SESv2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sesv2/runtimeConfig.shared.ts b/clients/client-sesv2/runtimeConfig.shared.ts index 2c62b8fbd2ea3..9f59f23ccdc85 100644 --- a/clients/client-sesv2/runtimeConfig.shared.ts +++ b/clients/client-sesv2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SESv2ClientConfig } from "./SESv2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SESv2ClientConfig) => ({ apiVersion: "2019-09-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SESv2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SESv2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sesv2/runtimeConfig.ts b/clients/client-sesv2/runtimeConfig.ts index 1ea3a71f157f5..2b44791951993 100644 --- a/clients/client-sesv2/runtimeConfig.ts +++ b/clients/client-sesv2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SESv2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SESv2ClientConfig } from "./SESv2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SESv2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sfn/SFNClient.ts b/clients/client-sfn/SFNClient.ts index 2c7e6e881bf6b..6ca049e9cac1b 100644 --- a/clients/client-sfn/SFNClient.ts +++ b/clients/client-sfn/SFNClient.ts @@ -33,7 +33,7 @@ import { StopExecutionCommandInput, StopExecutionCommandOutput } from "./command import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateStateMachineCommandInput, UpdateStateMachineCommandOutput } from "./commands/UpdateStateMachineCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -304,10 +304,7 @@ export class SFNClient extends __Client< readonly config: SFNClientResolvedConfig; constructor(configuration: SFNClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sfn/runtimeConfig.browser.ts b/clients/client-sfn/runtimeConfig.browser.ts index b254aa8ef2d0c..0c59b3950c2ce 100644 --- a/clients/client-sfn/runtimeConfig.browser.ts +++ b/clients/client-sfn/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SFNClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SFNClientConfig } from "./SFNClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SFNClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sfn/runtimeConfig.native.ts b/clients/client-sfn/runtimeConfig.native.ts index 5795204b51cab..b52aeabdec13a 100644 --- a/clients/client-sfn/runtimeConfig.native.ts +++ b/clients/client-sfn/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SFNClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SFNClientConfig } from "./SFNClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SFNClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sfn/runtimeConfig.shared.ts b/clients/client-sfn/runtimeConfig.shared.ts index 86e6407f13d80..869ac6e9a1850 100644 --- a/clients/client-sfn/runtimeConfig.shared.ts +++ b/clients/client-sfn/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SFNClientConfig } from "./SFNClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SFNClientConfig) => ({ apiVersion: "2016-11-23", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SFN", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SFN", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sfn/runtimeConfig.ts b/clients/client-sfn/runtimeConfig.ts index 17fff14cc10a3..f92fbf0b63db0 100644 --- a/clients/client-sfn/runtimeConfig.ts +++ b/clients/client-sfn/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SFNClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SFNClientConfig } from "./SFNClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SFNClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-shield/ShieldClient.ts b/clients/client-shield/ShieldClient.ts index 3e36f1feafade..22b4f54eb2bb3 100644 --- a/clients/client-shield/ShieldClient.ts +++ b/clients/client-shield/ShieldClient.ts @@ -91,7 +91,7 @@ import { UpdateProtectionGroupCommandOutput, } from "./commands/UpdateProtectionGroupCommand"; import { UpdateSubscriptionCommandInput, UpdateSubscriptionCommandOutput } from "./commands/UpdateSubscriptionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -370,10 +370,7 @@ export class ShieldClient extends __Client< readonly config: ShieldClientResolvedConfig; constructor(configuration: ShieldClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-shield/runtimeConfig.browser.ts b/clients/client-shield/runtimeConfig.browser.ts index 25c3dc3b2e3c6..b6b34c7e83953 100644 --- a/clients/client-shield/runtimeConfig.browser.ts +++ b/clients/client-shield/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./ShieldClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ShieldClientConfig } from "./ShieldClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ShieldClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-shield/runtimeConfig.native.ts b/clients/client-shield/runtimeConfig.native.ts index d88dde8410f79..d5aca17e53464 100644 --- a/clients/client-shield/runtimeConfig.native.ts +++ b/clients/client-shield/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./ShieldClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { ShieldClientConfig } from "./ShieldClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: ShieldClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-shield/runtimeConfig.shared.ts b/clients/client-shield/runtimeConfig.shared.ts index 1feca7d0e269a..e80e574fe9920 100644 --- a/clients/client-shield/runtimeConfig.shared.ts +++ b/clients/client-shield/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { ShieldClientConfig } from "./ShieldClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: ShieldClientConfig) => ({ apiVersion: "2016-06-02", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Shield", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Shield", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-shield/runtimeConfig.ts b/clients/client-shield/runtimeConfig.ts index f3fde84f55bc9..d44f9813b0b99 100644 --- a/clients/client-shield/runtimeConfig.ts +++ b/clients/client-shield/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./ShieldClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { ShieldClientConfig } from "./ShieldClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: ShieldClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-signer/SignerClient.ts b/clients/client-signer/SignerClient.ts index 5f5465989ccdf..fbdb745113c65 100644 --- a/clients/client-signer/SignerClient.ts +++ b/clients/client-signer/SignerClient.ts @@ -39,7 +39,7 @@ import { import { StartSigningJobCommandInput, StartSigningJobCommandOutput } from "./commands/StartSigningJobCommand"; import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -299,10 +299,7 @@ export class SignerClient extends __Client< readonly config: SignerClientResolvedConfig; constructor(configuration: SignerClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-signer/runtimeConfig.browser.ts b/clients/client-signer/runtimeConfig.browser.ts index b02f0d92afb06..c2e8465bed36a 100644 --- a/clients/client-signer/runtimeConfig.browser.ts +++ b/clients/client-signer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SignerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SignerClientConfig } from "./SignerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SignerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-signer/runtimeConfig.native.ts b/clients/client-signer/runtimeConfig.native.ts index 603a4cda364b5..8ebf00324e413 100644 --- a/clients/client-signer/runtimeConfig.native.ts +++ b/clients/client-signer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SignerClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SignerClientConfig } from "./SignerClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SignerClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-signer/runtimeConfig.shared.ts b/clients/client-signer/runtimeConfig.shared.ts index 678ffa649151e..e607e33048dc9 100644 --- a/clients/client-signer/runtimeConfig.shared.ts +++ b/clients/client-signer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SignerClientConfig } from "./SignerClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SignerClientConfig) => ({ apiVersion: "2017-08-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "signer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "signer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-signer/runtimeConfig.ts b/clients/client-signer/runtimeConfig.ts index ffdea8438b8d3..15afc47c26c29 100644 --- a/clients/client-signer/runtimeConfig.ts +++ b/clients/client-signer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SignerClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SignerClientConfig } from "./SignerClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SignerClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sms/SMSClient.ts b/clients/client-sms/SMSClient.ts index 65276a7fe02da..c3bec7a63aee2 100644 --- a/clients/client-sms/SMSClient.ts +++ b/clients/client-sms/SMSClient.ts @@ -93,7 +93,7 @@ import { UpdateReplicationJobCommandInput, UpdateReplicationJobCommandOutput, } from "./commands/UpdateReplicationJobCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -389,10 +389,7 @@ export class SMSClient extends __Client< readonly config: SMSClientResolvedConfig; constructor(configuration: SMSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sms/runtimeConfig.browser.ts b/clients/client-sms/runtimeConfig.browser.ts index a10df8831f0ac..08e1d6a68b2fb 100644 --- a/clients/client-sms/runtimeConfig.browser.ts +++ b/clients/client-sms/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SMSClientConfig } from "./SMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sms/runtimeConfig.native.ts b/clients/client-sms/runtimeConfig.native.ts index 969f55fe29402..06a638d1f449d 100644 --- a/clients/client-sms/runtimeConfig.native.ts +++ b/clients/client-sms/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SMSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SMSClientConfig } from "./SMSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SMSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sms/runtimeConfig.shared.ts b/clients/client-sms/runtimeConfig.shared.ts index caea43a95dacf..8eed773e9eea9 100644 --- a/clients/client-sms/runtimeConfig.shared.ts +++ b/clients/client-sms/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SMSClientConfig } from "./SMSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SMSClientConfig) => ({ apiVersion: "2016-10-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SMS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SMS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sms/runtimeConfig.ts b/clients/client-sms/runtimeConfig.ts index e6875ceb09aee..d6cc5768b246e 100644 --- a/clients/client-sms/runtimeConfig.ts +++ b/clients/client-sms/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SMSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SMSClientConfig } from "./SMSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SMSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-snowball/SnowballClient.ts b/clients/client-snowball/SnowballClient.ts index 1a9ea8690a049..2b70617bc0885 100644 --- a/clients/client-snowball/SnowballClient.ts +++ b/clients/client-snowball/SnowballClient.ts @@ -44,7 +44,7 @@ import { UpdateLongTermPricingCommandInput, UpdateLongTermPricingCommandOutput, } from "./commands/UpdateLongTermPricingCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -310,10 +310,7 @@ export class SnowballClient extends __Client< readonly config: SnowballClientResolvedConfig; constructor(configuration: SnowballClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-snowball/runtimeConfig.browser.ts b/clients/client-snowball/runtimeConfig.browser.ts index 7cbb08598c7b0..72a0017a4b15b 100644 --- a/clients/client-snowball/runtimeConfig.browser.ts +++ b/clients/client-snowball/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SnowballClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SnowballClientConfig } from "./SnowballClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SnowballClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-snowball/runtimeConfig.native.ts b/clients/client-snowball/runtimeConfig.native.ts index 4a5fd4a24f9c4..a4e443880ff81 100644 --- a/clients/client-snowball/runtimeConfig.native.ts +++ b/clients/client-snowball/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SnowballClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SnowballClientConfig } from "./SnowballClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SnowballClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-snowball/runtimeConfig.shared.ts b/clients/client-snowball/runtimeConfig.shared.ts index 2b9cc5106185d..5bbb4b923b958 100644 --- a/clients/client-snowball/runtimeConfig.shared.ts +++ b/clients/client-snowball/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SnowballClientConfig } from "./SnowballClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SnowballClientConfig) => ({ apiVersion: "2016-06-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Snowball", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Snowball", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-snowball/runtimeConfig.ts b/clients/client-snowball/runtimeConfig.ts index 1aea2129aa9b5..86725821f8300 100644 --- a/clients/client-snowball/runtimeConfig.ts +++ b/clients/client-snowball/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SnowballClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SnowballClientConfig } from "./SnowballClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SnowballClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sns/SNSClient.ts b/clients/client-sns/SNSClient.ts index 3f179c6eaa240..d62cefb87cacf 100644 --- a/clients/client-sns/SNSClient.ts +++ b/clients/client-sns/SNSClient.ts @@ -103,7 +103,7 @@ import { VerifySMSSandboxPhoneNumberCommandInput, VerifySMSSandboxPhoneNumberCommandOutput, } from "./commands/VerifySMSSandboxPhoneNumberCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -403,10 +403,7 @@ export class SNSClient extends __Client< readonly config: SNSClientResolvedConfig; constructor(configuration: SNSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sns/runtimeConfig.browser.ts b/clients/client-sns/runtimeConfig.browser.ts index ab75cad75c4c3..aa4532c24cedf 100644 --- a/clients/client-sns/runtimeConfig.browser.ts +++ b/clients/client-sns/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SNSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SNSClientConfig } from "./SNSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SNSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sns/runtimeConfig.native.ts b/clients/client-sns/runtimeConfig.native.ts index c2e1fe86d7a3f..8c44aa86d2cfb 100644 --- a/clients/client-sns/runtimeConfig.native.ts +++ b/clients/client-sns/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SNSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SNSClientConfig } from "./SNSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SNSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sns/runtimeConfig.shared.ts b/clients/client-sns/runtimeConfig.shared.ts index 218eaa024923c..b5dad9ecbca34 100644 --- a/clients/client-sns/runtimeConfig.shared.ts +++ b/clients/client-sns/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SNSClientConfig } from "./SNSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SNSClientConfig) => ({ apiVersion: "2010-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SNS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SNS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sns/runtimeConfig.ts b/clients/client-sns/runtimeConfig.ts index 5d8d94cce5526..dde2b51d791f4 100644 --- a/clients/client-sns/runtimeConfig.ts +++ b/clients/client-sns/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SNSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SNSClientConfig } from "./SNSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SNSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sqs/SQSClient.ts b/clients/client-sqs/SQSClient.ts index 6a6c05f65d6dd..46addcc57bc51 100644 --- a/clients/client-sqs/SQSClient.ts +++ b/clients/client-sqs/SQSClient.ts @@ -27,7 +27,7 @@ import { SendMessageCommandInput, SendMessageCommandOutput } from "./commands/Se import { SetQueueAttributesCommandInput, SetQueueAttributesCommandOutput } from "./commands/SetQueueAttributesCommand"; import { TagQueueCommandInput, TagQueueCommandOutput } from "./commands/TagQueueCommand"; import { UntagQueueCommandInput, UntagQueueCommandOutput } from "./commands/UntagQueueCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -352,10 +352,7 @@ export class SQSClient extends __Client< readonly config: SQSClientResolvedConfig; constructor(configuration: SQSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sqs/runtimeConfig.browser.ts b/clients/client-sqs/runtimeConfig.browser.ts index d6a4aa3ac794b..67915dafa3604 100644 --- a/clients/client-sqs/runtimeConfig.browser.ts +++ b/clients/client-sqs/runtimeConfig.browser.ts @@ -9,30 +9,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SQSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SQSClientConfig } from "./SQSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - md5: Md5, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SQSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + md5: config.md5 ?? Md5, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sqs/runtimeConfig.native.ts b/clients/client-sqs/runtimeConfig.native.ts index 9aba4a4cb12ec..ae80b26a042d8 100644 --- a/clients/client-sqs/runtimeConfig.native.ts +++ b/clients/client-sqs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SQSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SQSClientConfig } from "./SQSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SQSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sqs/runtimeConfig.shared.ts b/clients/client-sqs/runtimeConfig.shared.ts index 6358558e47f32..1331b6fa83d76 100644 --- a/clients/client-sqs/runtimeConfig.shared.ts +++ b/clients/client-sqs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SQSClientConfig } from "./SQSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SQSClientConfig) => ({ apiVersion: "2012-11-05", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SQS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SQS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sqs/runtimeConfig.ts b/clients/client-sqs/runtimeConfig.ts index 70b4322179409..0fcbb6ba5e093 100644 --- a/clients/client-sqs/runtimeConfig.ts +++ b/clients/client-sqs/runtimeConfig.ts @@ -12,30 +12,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SQSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SQSClientConfig } from "./SQSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - md5: Hash.bind(null, "md5"), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SQSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + md5: config.md5 ?? Hash.bind(null, "md5"), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm-contacts/SSMContactsClient.ts b/clients/client-ssm-contacts/SSMContactsClient.ts index e66bafe48eb95..af42f6ef6911d 100644 --- a/clients/client-ssm-contacts/SSMContactsClient.ts +++ b/clients/client-ssm-contacts/SSMContactsClient.ts @@ -49,7 +49,7 @@ import { UpdateContactChannelCommandOutput, } from "./commands/UpdateContactChannelCommand"; import { UpdateContactCommandInput, UpdateContactCommandOutput } from "./commands/UpdateContactCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -313,10 +313,7 @@ export class SSMContactsClient extends __Client< readonly config: SSMContactsClientResolvedConfig; constructor(configuration: SSMContactsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ssm-contacts/runtimeConfig.browser.ts b/clients/client-ssm-contacts/runtimeConfig.browser.ts index 8d8d5f57b1177..1b6e86a05a230 100644 --- a/clients/client-ssm-contacts/runtimeConfig.browser.ts +++ b/clients/client-ssm-contacts/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSMContactsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMContactsClientConfig } from "./SSMContactsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMContactsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm-contacts/runtimeConfig.native.ts b/clients/client-ssm-contacts/runtimeConfig.native.ts index bde7ce498e270..7280824773cb2 100644 --- a/clients/client-ssm-contacts/runtimeConfig.native.ts +++ b/clients/client-ssm-contacts/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSMContactsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSMContactsClientConfig } from "./SSMContactsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSMContactsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ssm-contacts/runtimeConfig.shared.ts b/clients/client-ssm-contacts/runtimeConfig.shared.ts index 5b0803c02ed92..660a260e8e1c5 100644 --- a/clients/client-ssm-contacts/runtimeConfig.shared.ts +++ b/clients/client-ssm-contacts/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSMContactsClientConfig } from "./SSMContactsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSMContactsClientConfig) => ({ apiVersion: "2021-05-03", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSM Contacts", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSM Contacts", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ssm-contacts/runtimeConfig.ts b/clients/client-ssm-contacts/runtimeConfig.ts index 50c7794ddf7e3..0c7f349743785 100644 --- a/clients/client-ssm-contacts/runtimeConfig.ts +++ b/clients/client-ssm-contacts/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSMContactsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMContactsClientConfig } from "./SSMContactsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMContactsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm-incidents/SSMIncidentsClient.ts b/clients/client-ssm-incidents/SSMIncidentsClient.ts index 49fa5e7ee93cc..3cd28e3dc528a 100644 --- a/clients/client-ssm-incidents/SSMIncidentsClient.ts +++ b/clients/client-ssm-incidents/SSMIncidentsClient.ts @@ -69,7 +69,7 @@ import { UpdateTimelineEventCommandInput, UpdateTimelineEventCommandOutput, } from "./commands/UpdateTimelineEventCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -344,10 +344,7 @@ export class SSMIncidentsClient extends __Client< readonly config: SSMIncidentsClientResolvedConfig; constructor(configuration: SSMIncidentsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ssm-incidents/runtimeConfig.browser.ts b/clients/client-ssm-incidents/runtimeConfig.browser.ts index a5f4662268903..9a4ec3b4209c9 100644 --- a/clients/client-ssm-incidents/runtimeConfig.browser.ts +++ b/clients/client-ssm-incidents/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSMIncidentsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMIncidentsClientConfig } from "./SSMIncidentsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMIncidentsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm-incidents/runtimeConfig.native.ts b/clients/client-ssm-incidents/runtimeConfig.native.ts index ef10f499e4d6b..7072b47f9468e 100644 --- a/clients/client-ssm-incidents/runtimeConfig.native.ts +++ b/clients/client-ssm-incidents/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSMIncidentsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSMIncidentsClientConfig } from "./SSMIncidentsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSMIncidentsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ssm-incidents/runtimeConfig.shared.ts b/clients/client-ssm-incidents/runtimeConfig.shared.ts index d12cdaf7a7827..2d52470917277 100644 --- a/clients/client-ssm-incidents/runtimeConfig.shared.ts +++ b/clients/client-ssm-incidents/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSMIncidentsClientConfig } from "./SSMIncidentsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSMIncidentsClientConfig) => ({ apiVersion: "2018-05-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSM Incidents", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSM Incidents", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ssm-incidents/runtimeConfig.ts b/clients/client-ssm-incidents/runtimeConfig.ts index 2a8f641f8ce83..b73ec370a90ef 100644 --- a/clients/client-ssm-incidents/runtimeConfig.ts +++ b/clients/client-ssm-incidents/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSMIncidentsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMIncidentsClientConfig } from "./SSMIncidentsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMIncidentsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm/SSMClient.ts b/clients/client-ssm/SSMClient.ts index 2d2cc168b49a6..d2baa52ca228c 100644 --- a/clients/client-ssm/SSMClient.ts +++ b/clients/client-ssm/SSMClient.ts @@ -403,7 +403,7 @@ import { UpdateServiceSettingCommandInput, UpdateServiceSettingCommandOutput, } from "./commands/UpdateServiceSettingCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -914,10 +914,7 @@ export class SSMClient extends __Client< readonly config: SSMClientResolvedConfig; constructor(configuration: SSMClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-ssm/runtimeConfig.browser.ts b/clients/client-ssm/runtimeConfig.browser.ts index d2d355ee1f52c..221b75b7001b9 100644 --- a/clients/client-ssm/runtimeConfig.browser.ts +++ b/clients/client-ssm/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMClientConfig } from "./SSMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-ssm/runtimeConfig.native.ts b/clients/client-ssm/runtimeConfig.native.ts index 8e8669fecf833..0340061eb5e08 100644 --- a/clients/client-ssm/runtimeConfig.native.ts +++ b/clients/client-ssm/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSMClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSMClientConfig } from "./SSMClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSMClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-ssm/runtimeConfig.shared.ts b/clients/client-ssm/runtimeConfig.shared.ts index e68ef2d4588d6..65558141959b4 100644 --- a/clients/client-ssm/runtimeConfig.shared.ts +++ b/clients/client-ssm/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSMClientConfig } from "./SSMClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSMClientConfig) => ({ apiVersion: "2014-11-06", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSM", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSM", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-ssm/runtimeConfig.ts b/clients/client-ssm/runtimeConfig.ts index 3c9cc80a707d6..388f8276744cd 100644 --- a/clients/client-ssm/runtimeConfig.ts +++ b/clients/client-ssm/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSMClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSMClientConfig } from "./SSMClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSMClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso-admin/SSOAdminClient.ts b/clients/client-sso-admin/SSOAdminClient.ts index bfc06c769b78f..3217c48027cea 100644 --- a/clients/client-sso-admin/SSOAdminClient.ts +++ b/clients/client-sso-admin/SSOAdminClient.ts @@ -110,7 +110,7 @@ import { UpdatePermissionSetCommandInput, UpdatePermissionSetCommandOutput, } from "./commands/UpdatePermissionSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -379,10 +379,7 @@ export class SSOAdminClient extends __Client< readonly config: SSOAdminClientResolvedConfig; constructor(configuration: SSOAdminClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sso-admin/runtimeConfig.browser.ts b/clients/client-sso-admin/runtimeConfig.browser.ts index 15595e8b22263..bb52d83c1910e 100644 --- a/clients/client-sso-admin/runtimeConfig.browser.ts +++ b/clients/client-sso-admin/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSOAdminClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOAdminClientConfig } from "./SSOAdminClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOAdminClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso-admin/runtimeConfig.native.ts b/clients/client-sso-admin/runtimeConfig.native.ts index 33053a6436141..b4c213747458a 100644 --- a/clients/client-sso-admin/runtimeConfig.native.ts +++ b/clients/client-sso-admin/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSOAdminClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSOAdminClientConfig } from "./SSOAdminClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSOAdminClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sso-admin/runtimeConfig.shared.ts b/clients/client-sso-admin/runtimeConfig.shared.ts index d98ef24df79a2..5e9686124986e 100644 --- a/clients/client-sso-admin/runtimeConfig.shared.ts +++ b/clients/client-sso-admin/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSOAdminClientConfig } from "./SSOAdminClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSOAdminClientConfig) => ({ apiVersion: "2020-07-20", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSO Admin", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSO Admin", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sso-admin/runtimeConfig.ts b/clients/client-sso-admin/runtimeConfig.ts index 4a9a957ee3e21..1f7c734f1674f 100644 --- a/clients/client-sso-admin/runtimeConfig.ts +++ b/clients/client-sso-admin/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSOAdminClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOAdminClientConfig } from "./SSOAdminClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOAdminClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso-oidc/SSOOIDCClient.ts b/clients/client-sso-oidc/SSOOIDCClient.ts index ece40e44d6be6..cbc2582c5b2be 100644 --- a/clients/client-sso-oidc/SSOOIDCClient.ts +++ b/clients/client-sso-oidc/SSOOIDCClient.ts @@ -4,7 +4,7 @@ import { StartDeviceAuthorizationCommandInput, StartDeviceAuthorizationCommandOutput, } from "./commands/StartDeviceAuthorizationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -222,10 +222,7 @@ export class SSOOIDCClient extends __Client< readonly config: SSOOIDCClientResolvedConfig; constructor(configuration: SSOOIDCClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sso-oidc/runtimeConfig.browser.ts b/clients/client-sso-oidc/runtimeConfig.browser.ts index 50d1401b597ec..7be6353d8f604 100644 --- a/clients/client-sso-oidc/runtimeConfig.browser.ts +++ b/clients/client-sso-oidc/runtimeConfig.browser.ts @@ -8,28 +8,31 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSOOIDCClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOOIDCClientConfig } from "./SSOOIDCClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOOIDCClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso-oidc/runtimeConfig.native.ts b/clients/client-sso-oidc/runtimeConfig.native.ts index ec7313ebd8148..7a5350f947a0d 100644 --- a/clients/client-sso-oidc/runtimeConfig.native.ts +++ b/clients/client-sso-oidc/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSOOIDCClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSOOIDCClientConfig } from "./SSOOIDCClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSOOIDCClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sso-oidc/runtimeConfig.shared.ts b/clients/client-sso-oidc/runtimeConfig.shared.ts index 53c7e6d9ec44d..b3829f8c8a5b2 100644 --- a/clients/client-sso-oidc/runtimeConfig.shared.ts +++ b/clients/client-sso-oidc/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSOOIDCClientConfig } from "./SSOOIDCClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSOOIDCClientConfig) => ({ apiVersion: "2019-06-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSO OIDC", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSO OIDC", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sso-oidc/runtimeConfig.ts b/clients/client-sso-oidc/runtimeConfig.ts index 71a0ddca23c9e..49ae653c9b532 100644 --- a/clients/client-sso-oidc/runtimeConfig.ts +++ b/clients/client-sso-oidc/runtimeConfig.ts @@ -9,28 +9,31 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSOOIDCClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOOIDCClientConfig } from "./SSOOIDCClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOOIDCClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso/SSOClient.ts b/clients/client-sso/SSOClient.ts index 80ea8fa913f47..b12a34dd4d7ab 100644 --- a/clients/client-sso/SSOClient.ts +++ b/clients/client-sso/SSOClient.ts @@ -2,7 +2,7 @@ import { GetRoleCredentialsCommandInput, GetRoleCredentialsCommandOutput } from import { ListAccountRolesCommandInput, ListAccountRolesCommandOutput } from "./commands/ListAccountRolesCommand"; import { ListAccountsCommandInput, ListAccountsCommandOutput } from "./commands/ListAccountsCommand"; import { LogoutCommandInput, LogoutCommandOutput } from "./commands/LogoutCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -220,10 +220,7 @@ export class SSOClient extends __Client< readonly config: SSOClientResolvedConfig; constructor(configuration: SSOClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sso/runtimeConfig.browser.ts b/clients/client-sso/runtimeConfig.browser.ts index f31da568d485b..e8612cdea7f44 100644 --- a/clients/client-sso/runtimeConfig.browser.ts +++ b/clients/client-sso/runtimeConfig.browser.ts @@ -8,28 +8,31 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SSOClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOClientConfig } from "./SSOClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sso/runtimeConfig.native.ts b/clients/client-sso/runtimeConfig.native.ts index ac771c3735462..856d06c34ed1a 100644 --- a/clients/client-sso/runtimeConfig.native.ts +++ b/clients/client-sso/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SSOClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SSOClientConfig } from "./SSOClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SSOClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sso/runtimeConfig.shared.ts b/clients/client-sso/runtimeConfig.shared.ts index c24c6080fa134..b4d8b853c2feb 100644 --- a/clients/client-sso/runtimeConfig.shared.ts +++ b/clients/client-sso/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SSOClientConfig } from "./SSOClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SSOClientConfig) => ({ apiVersion: "2019-06-10", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SSO", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SSO", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sso/runtimeConfig.ts b/clients/client-sso/runtimeConfig.ts index 341d5f745bd36..de0259d129a55 100644 --- a/clients/client-sso/runtimeConfig.ts +++ b/clients/client-sso/runtimeConfig.ts @@ -9,28 +9,31 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SSOClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SSOClientConfig } from "./SSOClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SSOClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-storage-gateway/StorageGatewayClient.ts b/clients/client-storage-gateway/StorageGatewayClient.ts index 2e9adcc0d993f..17f94f23a37c2 100644 --- a/clients/client-storage-gateway/StorageGatewayClient.ts +++ b/clients/client-storage-gateway/StorageGatewayClient.ts @@ -237,7 +237,7 @@ import { UpdateVTLDeviceTypeCommandInput, UpdateVTLDeviceTypeCommandOutput, } from "./commands/UpdateVTLDeviceTypeCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -696,10 +696,7 @@ export class StorageGatewayClient extends __Client< readonly config: StorageGatewayClientResolvedConfig; constructor(configuration: StorageGatewayClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-storage-gateway/runtimeConfig.browser.ts b/clients/client-storage-gateway/runtimeConfig.browser.ts index 0ebcf8380e13a..532f24e01383b 100644 --- a/clients/client-storage-gateway/runtimeConfig.browser.ts +++ b/clients/client-storage-gateway/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./StorageGatewayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { StorageGatewayClientConfig } from "./StorageGatewayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: StorageGatewayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-storage-gateway/runtimeConfig.native.ts b/clients/client-storage-gateway/runtimeConfig.native.ts index 333849f8b99ea..fff0573e27adb 100644 --- a/clients/client-storage-gateway/runtimeConfig.native.ts +++ b/clients/client-storage-gateway/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./StorageGatewayClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { StorageGatewayClientConfig } from "./StorageGatewayClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: StorageGatewayClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-storage-gateway/runtimeConfig.shared.ts b/clients/client-storage-gateway/runtimeConfig.shared.ts index f4ff108703998..6b6f838e8970a 100644 --- a/clients/client-storage-gateway/runtimeConfig.shared.ts +++ b/clients/client-storage-gateway/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { StorageGatewayClientConfig } from "./StorageGatewayClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: StorageGatewayClientConfig) => ({ apiVersion: "2013-06-30", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Storage Gateway", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Storage Gateway", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-storage-gateway/runtimeConfig.ts b/clients/client-storage-gateway/runtimeConfig.ts index d9bc9522d4a5b..196084b2e3840 100644 --- a/clients/client-storage-gateway/runtimeConfig.ts +++ b/clients/client-storage-gateway/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./StorageGatewayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { StorageGatewayClientConfig } from "./StorageGatewayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: StorageGatewayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sts/STSClient.ts b/clients/client-sts/STSClient.ts index 55a3bf372a553..6fa2e8d63ec08 100644 --- a/clients/client-sts/STSClient.ts +++ b/clients/client-sts/STSClient.ts @@ -12,7 +12,7 @@ import { GetAccessKeyInfoCommandInput, GetAccessKeyInfoCommandOutput } from "./c import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "./commands/GetCallerIdentityCommand"; import { GetFederationTokenCommandInput, GetFederationTokenCommandOutput } from "./commands/GetFederationTokenCommand"; import { GetSessionTokenCommandInput, GetSessionTokenCommandOutput } from "./commands/GetSessionTokenCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -237,10 +237,7 @@ export class STSClient extends __Client< readonly config: STSClientResolvedConfig; constructor(configuration: STSClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-sts/runtimeConfig.browser.ts b/clients/client-sts/runtimeConfig.browser.ts index addf7343a1946..40404e0e3c6d4 100644 --- a/clients/client-sts/runtimeConfig.browser.ts +++ b/clients/client-sts/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./STSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { STSClientConfig } from "./STSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: STSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-sts/runtimeConfig.native.ts b/clients/client-sts/runtimeConfig.native.ts index c6ea55a45da5a..7bc8be08f35cb 100644 --- a/clients/client-sts/runtimeConfig.native.ts +++ b/clients/client-sts/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./STSClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { STSClientConfig } from "./STSClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: STSClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-sts/runtimeConfig.shared.ts b/clients/client-sts/runtimeConfig.shared.ts index cb7e89e11f3e5..14c6ba0e6bf49 100644 --- a/clients/client-sts/runtimeConfig.shared.ts +++ b/clients/client-sts/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { STSClientConfig } from "./STSClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: STSClientConfig) => ({ apiVersion: "2011-06-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "STS", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "STS", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-sts/runtimeConfig.ts b/clients/client-sts/runtimeConfig.ts index 1ac3ec5363d66..65a5b71e5a109 100644 --- a/clients/client-sts/runtimeConfig.ts +++ b/clients/client-sts/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./STSClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { STSClientConfig } from "./STSClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: STSClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-support/SupportClient.ts b/clients/client-support/SupportClient.ts index 45ea6e0051129..6c710be5df11e 100644 --- a/clients/client-support/SupportClient.ts +++ b/clients/client-support/SupportClient.ts @@ -39,7 +39,7 @@ import { RefreshTrustedAdvisorCheckCommandOutput, } from "./commands/RefreshTrustedAdvisorCheckCommand"; import { ResolveCaseCommandInput, ResolveCaseCommandOutput } from "./commands/ResolveCaseCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -350,10 +350,7 @@ export class SupportClient extends __Client< readonly config: SupportClientResolvedConfig; constructor(configuration: SupportClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-support/runtimeConfig.browser.ts b/clients/client-support/runtimeConfig.browser.ts index 5d1dc0f0aae55..61c69502c46fc 100644 --- a/clients/client-support/runtimeConfig.browser.ts +++ b/clients/client-support/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SupportClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SupportClientConfig } from "./SupportClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SupportClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-support/runtimeConfig.native.ts b/clients/client-support/runtimeConfig.native.ts index a24f3d917b665..a36ac5bb1368b 100644 --- a/clients/client-support/runtimeConfig.native.ts +++ b/clients/client-support/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SupportClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SupportClientConfig } from "./SupportClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SupportClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-support/runtimeConfig.shared.ts b/clients/client-support/runtimeConfig.shared.ts index 2a7996708ec7d..faf5a2f3ec8f9 100644 --- a/clients/client-support/runtimeConfig.shared.ts +++ b/clients/client-support/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SupportClientConfig } from "./SupportClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SupportClientConfig) => ({ apiVersion: "2013-04-15", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Support", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Support", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-support/runtimeConfig.ts b/clients/client-support/runtimeConfig.ts index f210aeb92c8f8..d0202fc742b25 100644 --- a/clients/client-support/runtimeConfig.ts +++ b/clients/client-support/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SupportClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SupportClientConfig } from "./SupportClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SupportClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-swf/SWFClient.ts b/clients/client-swf/SWFClient.ts index 80ec2ea8bd804..c9f5c22446e70 100644 --- a/clients/client-swf/SWFClient.ts +++ b/clients/client-swf/SWFClient.ts @@ -119,7 +119,7 @@ import { UndeprecateWorkflowTypeCommandOutput, } from "./commands/UndeprecateWorkflowTypeCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -418,10 +418,7 @@ export class SWFClient extends __Client< readonly config: SWFClientResolvedConfig; constructor(configuration: SWFClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-swf/runtimeConfig.browser.ts b/clients/client-swf/runtimeConfig.browser.ts index 2d574b765c198..46b9d079d6b5b 100644 --- a/clients/client-swf/runtimeConfig.browser.ts +++ b/clients/client-swf/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SWFClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SWFClientConfig } from "./SWFClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SWFClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-swf/runtimeConfig.native.ts b/clients/client-swf/runtimeConfig.native.ts index 4a33eb8279bc6..84b9fe66a7187 100644 --- a/clients/client-swf/runtimeConfig.native.ts +++ b/clients/client-swf/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SWFClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SWFClientConfig } from "./SWFClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SWFClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-swf/runtimeConfig.shared.ts b/clients/client-swf/runtimeConfig.shared.ts index 5c4ec0776c764..77dcf6b234d2c 100644 --- a/clients/client-swf/runtimeConfig.shared.ts +++ b/clients/client-swf/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SWFClientConfig } from "./SWFClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SWFClientConfig) => ({ apiVersion: "2012-01-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "SWF", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "SWF", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-swf/runtimeConfig.ts b/clients/client-swf/runtimeConfig.ts index 93b3b6e190ae2..5e5ade5afecf9 100644 --- a/clients/client-swf/runtimeConfig.ts +++ b/clients/client-swf/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SWFClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SWFClientConfig } from "./SWFClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SWFClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-synthetics/SyntheticsClient.ts b/clients/client-synthetics/SyntheticsClient.ts index fb58d8378d20c..b72150fd8a2c1 100644 --- a/clients/client-synthetics/SyntheticsClient.ts +++ b/clients/client-synthetics/SyntheticsClient.ts @@ -20,7 +20,7 @@ import { StopCanaryCommandInput, StopCanaryCommandOutput } from "./commands/Stop import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand"; import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateCanaryCommandInput, UpdateCanaryCommandOutput } from "./commands/UpdateCanaryCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -271,10 +271,7 @@ export class SyntheticsClient extends __Client< readonly config: SyntheticsClientResolvedConfig; constructor(configuration: SyntheticsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-synthetics/runtimeConfig.browser.ts b/clients/client-synthetics/runtimeConfig.browser.ts index 52811232665ab..5698baff4ace7 100644 --- a/clients/client-synthetics/runtimeConfig.browser.ts +++ b/clients/client-synthetics/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./SyntheticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SyntheticsClientConfig } from "./SyntheticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SyntheticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-synthetics/runtimeConfig.native.ts b/clients/client-synthetics/runtimeConfig.native.ts index 71e888ac557e0..0e673e4578548 100644 --- a/clients/client-synthetics/runtimeConfig.native.ts +++ b/clients/client-synthetics/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./SyntheticsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { SyntheticsClientConfig } from "./SyntheticsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: SyntheticsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-synthetics/runtimeConfig.shared.ts b/clients/client-synthetics/runtimeConfig.shared.ts index 487e1b5b2c313..785a0b1571f0b 100644 --- a/clients/client-synthetics/runtimeConfig.shared.ts +++ b/clients/client-synthetics/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { SyntheticsClientConfig } from "./SyntheticsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: SyntheticsClientConfig) => ({ apiVersion: "2017-10-11", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "synthetics", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "synthetics", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-synthetics/runtimeConfig.ts b/clients/client-synthetics/runtimeConfig.ts index a933b04e41094..877932fb5593e 100644 --- a/clients/client-synthetics/runtimeConfig.ts +++ b/clients/client-synthetics/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./SyntheticsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { SyntheticsClientConfig } from "./SyntheticsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: SyntheticsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-textract/TextractClient.ts b/clients/client-textract/TextractClient.ts index dab1fae9590ff..e614fb7b95d02 100644 --- a/clients/client-textract/TextractClient.ts +++ b/clients/client-textract/TextractClient.ts @@ -16,7 +16,7 @@ import { StartDocumentTextDetectionCommandInput, StartDocumentTextDetectionCommandOutput, } from "./commands/StartDocumentTextDetectionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -240,10 +240,7 @@ export class TextractClient extends __Client< readonly config: TextractClientResolvedConfig; constructor(configuration: TextractClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-textract/runtimeConfig.browser.ts b/clients/client-textract/runtimeConfig.browser.ts index 9a1faa97b4157..3435ef50150ce 100644 --- a/clients/client-textract/runtimeConfig.browser.ts +++ b/clients/client-textract/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TextractClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TextractClientConfig } from "./TextractClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TextractClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-textract/runtimeConfig.native.ts b/clients/client-textract/runtimeConfig.native.ts index 3f598bafcb17d..4426daf1e7d00 100644 --- a/clients/client-textract/runtimeConfig.native.ts +++ b/clients/client-textract/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TextractClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TextractClientConfig } from "./TextractClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TextractClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-textract/runtimeConfig.shared.ts b/clients/client-textract/runtimeConfig.shared.ts index f49487ba7baf3..4e61159d2c0e1 100644 --- a/clients/client-textract/runtimeConfig.shared.ts +++ b/clients/client-textract/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TextractClientConfig } from "./TextractClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TextractClientConfig) => ({ apiVersion: "2018-06-27", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Textract", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Textract", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-textract/runtimeConfig.ts b/clients/client-textract/runtimeConfig.ts index 0a14a46c98499..a5a3fb162e4fa 100644 --- a/clients/client-textract/runtimeConfig.ts +++ b/clients/client-textract/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TextractClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TextractClientConfig } from "./TextractClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TextractClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-timestream-query/TimestreamQueryClient.ts b/clients/client-timestream-query/TimestreamQueryClient.ts index 899924fe89254..a0b3e865b311d 100644 --- a/clients/client-timestream-query/TimestreamQueryClient.ts +++ b/clients/client-timestream-query/TimestreamQueryClient.ts @@ -5,7 +5,7 @@ import { DescribeEndpointsCommandOutput, } from "./commands/DescribeEndpointsCommand"; import { QueryCommandInput, QueryCommandOutput } from "./commands/QueryCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -231,10 +231,7 @@ export class TimestreamQueryClient extends __Client< readonly config: TimestreamQueryClientResolvedConfig; constructor(configuration: TimestreamQueryClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-timestream-query/runtimeConfig.browser.ts b/clients/client-timestream-query/runtimeConfig.browser.ts index a9a4eb9b363c0..8f96f81b3c33a 100644 --- a/clients/client-timestream-query/runtimeConfig.browser.ts +++ b/clients/client-timestream-query/runtimeConfig.browser.ts @@ -8,30 +8,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TimestreamQueryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TimestreamQueryClientConfig } from "./TimestreamQueryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: () => Promise.resolve(undefined), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TimestreamQueryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: config.endpointDiscoveryEnabledProvider ?? (() => Promise.resolve(undefined)), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-timestream-query/runtimeConfig.native.ts b/clients/client-timestream-query/runtimeConfig.native.ts index 7a220f362e23c..e1c1d8a02fab0 100644 --- a/clients/client-timestream-query/runtimeConfig.native.ts +++ b/clients/client-timestream-query/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TimestreamQueryClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TimestreamQueryClientConfig } from "./TimestreamQueryClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TimestreamQueryClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-timestream-query/runtimeConfig.shared.ts b/clients/client-timestream-query/runtimeConfig.shared.ts index 60b5c56ddff7a..e798be9fccdbf 100644 --- a/clients/client-timestream-query/runtimeConfig.shared.ts +++ b/clients/client-timestream-query/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TimestreamQueryClientConfig } from "./TimestreamQueryClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TimestreamQueryClientConfig) => ({ apiVersion: "2018-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Timestream Query", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Timestream Query", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-timestream-query/runtimeConfig.ts b/clients/client-timestream-query/runtimeConfig.ts index 0533c592ff515..3da5c5d99498d 100644 --- a/clients/client-timestream-query/runtimeConfig.ts +++ b/clients/client-timestream-query/runtimeConfig.ts @@ -12,30 +12,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TimestreamQueryClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TimestreamQueryClientConfig } from "./TimestreamQueryClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TimestreamQueryClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: + config.endpointDiscoveryEnabledProvider ?? loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-timestream-write/TimestreamWriteClient.ts b/clients/client-timestream-write/TimestreamWriteClient.ts index cdcf4fe5546cb..2214c4c97b1f8 100644 --- a/clients/client-timestream-write/TimestreamWriteClient.ts +++ b/clients/client-timestream-write/TimestreamWriteClient.ts @@ -20,7 +20,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateDatabaseCommandInput, UpdateDatabaseCommandOutput } from "./commands/UpdateDatabaseCommand"; import { UpdateTableCommandInput, UpdateTableCommandOutput } from "./commands/UpdateTableCommand"; import { WriteRecordsCommandInput, WriteRecordsCommandOutput } from "./commands/WriteRecordsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -274,10 +274,7 @@ export class TimestreamWriteClient extends __Client< readonly config: TimestreamWriteClientResolvedConfig; constructor(configuration: TimestreamWriteClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-timestream-write/runtimeConfig.browser.ts b/clients/client-timestream-write/runtimeConfig.browser.ts index cf0eba687ca20..04010b3aedfbc 100644 --- a/clients/client-timestream-write/runtimeConfig.browser.ts +++ b/clients/client-timestream-write/runtimeConfig.browser.ts @@ -8,30 +8,34 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TimestreamWriteClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TimestreamWriteClientConfig } from "./TimestreamWriteClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: () => Promise.resolve(undefined), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TimestreamWriteClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: config.endpointDiscoveryEnabledProvider ?? (() => Promise.resolve(undefined)), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-timestream-write/runtimeConfig.native.ts b/clients/client-timestream-write/runtimeConfig.native.ts index f192d83dcf87d..74b3aad59f84a 100644 --- a/clients/client-timestream-write/runtimeConfig.native.ts +++ b/clients/client-timestream-write/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TimestreamWriteClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TimestreamWriteClientConfig } from "./TimestreamWriteClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TimestreamWriteClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-timestream-write/runtimeConfig.shared.ts b/clients/client-timestream-write/runtimeConfig.shared.ts index b6246f8087fc6..5fc1f5a6964ab 100644 --- a/clients/client-timestream-write/runtimeConfig.shared.ts +++ b/clients/client-timestream-write/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TimestreamWriteClientConfig } from "./TimestreamWriteClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TimestreamWriteClientConfig) => ({ apiVersion: "2018-11-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Timestream Write", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Timestream Write", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-timestream-write/runtimeConfig.ts b/clients/client-timestream-write/runtimeConfig.ts index ca380c8e9b6ad..79b333bb3f9a8 100644 --- a/clients/client-timestream-write/runtimeConfig.ts +++ b/clients/client-timestream-write/runtimeConfig.ts @@ -12,30 +12,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TimestreamWriteClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TimestreamWriteClientConfig } from "./TimestreamWriteClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - endpointDiscoveryEnabledProvider: loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TimestreamWriteClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + endpointDiscoveryEnabledProvider: + config.endpointDiscoveryEnabledProvider ?? loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transcribe-streaming/TranscribeStreamingClient.ts b/clients/client-transcribe-streaming/TranscribeStreamingClient.ts index da8212907cafa..c0cd6fafec641 100644 --- a/clients/client-transcribe-streaming/TranscribeStreamingClient.ts +++ b/clients/client-transcribe-streaming/TranscribeStreamingClient.ts @@ -6,7 +6,7 @@ import { StartStreamTranscriptionCommandInput, StartStreamTranscriptionCommandOutput, } from "./commands/StartStreamTranscriptionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -251,10 +251,7 @@ export class TranscribeStreamingClient extends __Client< readonly config: TranscribeStreamingClientResolvedConfig; constructor(configuration: TranscribeStreamingClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-transcribe-streaming/runtimeConfig.browser.ts b/clients/client-transcribe-streaming/runtimeConfig.browser.ts index 52936dc43c2e3..eba17d97bb2cb 100644 --- a/clients/client-transcribe-streaming/runtimeConfig.browser.ts +++ b/clients/client-transcribe-streaming/runtimeConfig.browser.ts @@ -10,31 +10,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TranscribeStreamingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranscribeStreamingClientConfig } from "./TranscribeStreamingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamPayloadHandlerProvider: () => eventStreamPayloadHandler, - eventStreamSerdeProvider, - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new WebSocketHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranscribeStreamingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamPayloadHandlerProvider: config.eventStreamPayloadHandlerProvider ?? (() => eventStreamPayloadHandler), + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new WebSocketHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transcribe-streaming/runtimeConfig.native.ts b/clients/client-transcribe-streaming/runtimeConfig.native.ts index c8d372a7f5604..e736bbfbd1268 100644 --- a/clients/client-transcribe-streaming/runtimeConfig.native.ts +++ b/clients/client-transcribe-streaming/runtimeConfig.native.ts @@ -1,15 +1,19 @@ import { Sha256 } from "@aws-crypto/sha256-js"; import { WebSocketHandler, eventStreamPayloadHandler } from "@aws-sdk/middleware-sdk-transcribe-streaming"; -import { ClientDefaults } from "./TranscribeStreamingClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TranscribeStreamingClientConfig } from "./TranscribeStreamingClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - eventStreamPayloadHandlerProvider: () => eventStreamPayloadHandler, - requestHandler: new WebSocketHandler(), - sha256: Sha256, +export const getRuntimeConfig = (config: TranscribeStreamingClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + eventStreamPayloadHandlerProvider: config.eventStreamPayloadHandlerProvider ?? (() => eventStreamPayloadHandler), + requestHandler: config.requestHandler ?? new WebSocketHandler(), + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-transcribe-streaming/runtimeConfig.shared.ts b/clients/client-transcribe-streaming/runtimeConfig.shared.ts index cbbfedfca61ba..7f210dd95861a 100644 --- a/clients/client-transcribe-streaming/runtimeConfig.shared.ts +++ b/clients/client-transcribe-streaming/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TranscribeStreamingClientConfig } from "./TranscribeStreamingClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TranscribeStreamingClientConfig) => ({ apiVersion: "2017-10-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Transcribe Streaming", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Transcribe Streaming", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-transcribe-streaming/runtimeConfig.ts b/clients/client-transcribe-streaming/runtimeConfig.ts index 2d121f816a69c..58279df7806ec 100644 --- a/clients/client-transcribe-streaming/runtimeConfig.ts +++ b/clients/client-transcribe-streaming/runtimeConfig.ts @@ -13,31 +13,35 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TranscribeStreamingClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranscribeStreamingClientConfig } from "./TranscribeStreamingClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - eventStreamPayloadHandlerProvider, - eventStreamSerdeProvider, - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttp2Handler({ disableConcurrentStreams: true }), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranscribeStreamingClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + eventStreamPayloadHandlerProvider: config.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider, + eventStreamSerdeProvider: config.eventStreamSerdeProvider ?? eventStreamSerdeProvider, + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttp2Handler({ disableConcurrentStreams: true }), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transcribe/TranscribeClient.ts b/clients/client-transcribe/TranscribeClient.ts index ddd7f2b84de68..ee49b1e6459f9 100644 --- a/clients/client-transcribe/TranscribeClient.ts +++ b/clients/client-transcribe/TranscribeClient.ts @@ -88,7 +88,7 @@ import { UpdateVocabularyFilterCommandInput, UpdateVocabularyFilterCommandOutput, } from "./commands/UpdateVocabularyFilterCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -352,10 +352,7 @@ export class TranscribeClient extends __Client< readonly config: TranscribeClientResolvedConfig; constructor(configuration: TranscribeClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-transcribe/runtimeConfig.browser.ts b/clients/client-transcribe/runtimeConfig.browser.ts index 5e884ec1a6826..285c18f0f7793 100644 --- a/clients/client-transcribe/runtimeConfig.browser.ts +++ b/clients/client-transcribe/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TranscribeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranscribeClientConfig } from "./TranscribeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranscribeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transcribe/runtimeConfig.native.ts b/clients/client-transcribe/runtimeConfig.native.ts index 3a5cce4938080..db617994c3053 100644 --- a/clients/client-transcribe/runtimeConfig.native.ts +++ b/clients/client-transcribe/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TranscribeClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TranscribeClientConfig } from "./TranscribeClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TranscribeClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-transcribe/runtimeConfig.shared.ts b/clients/client-transcribe/runtimeConfig.shared.ts index 1b6d28ac07528..14f75f01a029d 100644 --- a/clients/client-transcribe/runtimeConfig.shared.ts +++ b/clients/client-transcribe/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TranscribeClientConfig } from "./TranscribeClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TranscribeClientConfig) => ({ apiVersion: "2017-10-26", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Transcribe", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Transcribe", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-transcribe/runtimeConfig.ts b/clients/client-transcribe/runtimeConfig.ts index 353c18632d8ed..6d00cf21f47f7 100644 --- a/clients/client-transcribe/runtimeConfig.ts +++ b/clients/client-transcribe/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TranscribeClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranscribeClientConfig } from "./TranscribeClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranscribeClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transfer/TransferClient.ts b/clients/client-transfer/TransferClient.ts index f18c6a1853ef4..c5df92865550b 100644 --- a/clients/client-transfer/TransferClient.ts +++ b/clients/client-transfer/TransferClient.ts @@ -35,7 +35,7 @@ import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./command import { UpdateAccessCommandInput, UpdateAccessCommandOutput } from "./commands/UpdateAccessCommand"; import { UpdateServerCommandInput, UpdateServerCommandOutput } from "./commands/UpdateServerCommand"; import { UpdateUserCommandInput, UpdateUserCommandOutput } from "./commands/UpdateUserCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -303,10 +303,7 @@ export class TransferClient extends __Client< readonly config: TransferClientResolvedConfig; constructor(configuration: TransferClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-transfer/runtimeConfig.browser.ts b/clients/client-transfer/runtimeConfig.browser.ts index 2530781f4bd3d..9aab0dd1646a5 100644 --- a/clients/client-transfer/runtimeConfig.browser.ts +++ b/clients/client-transfer/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TransferClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TransferClientConfig } from "./TransferClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TransferClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-transfer/runtimeConfig.native.ts b/clients/client-transfer/runtimeConfig.native.ts index cedd63512069d..febeac64d9268 100644 --- a/clients/client-transfer/runtimeConfig.native.ts +++ b/clients/client-transfer/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TransferClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TransferClientConfig } from "./TransferClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TransferClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-transfer/runtimeConfig.shared.ts b/clients/client-transfer/runtimeConfig.shared.ts index aed65606afbaa..81f21593a83ba 100644 --- a/clients/client-transfer/runtimeConfig.shared.ts +++ b/clients/client-transfer/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TransferClientConfig } from "./TransferClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TransferClientConfig) => ({ apiVersion: "2018-11-05", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Transfer", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Transfer", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-transfer/runtimeConfig.ts b/clients/client-transfer/runtimeConfig.ts index b2497a687d631..97ad03ff5b8bd 100644 --- a/clients/client-transfer/runtimeConfig.ts +++ b/clients/client-transfer/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TransferClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TransferClientConfig } from "./TransferClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TransferClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-translate/TranslateClient.ts b/clients/client-translate/TranslateClient.ts index 49fe15a2083aa..1336f6e814e37 100644 --- a/clients/client-translate/TranslateClient.ts +++ b/clients/client-translate/TranslateClient.ts @@ -24,7 +24,7 @@ import { } from "./commands/StopTextTranslationJobCommand"; import { TranslateTextCommandInput, TranslateTextCommandOutput } from "./commands/TranslateTextCommand"; import { UpdateParallelDataCommandInput, UpdateParallelDataCommandOutput } from "./commands/UpdateParallelDataCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -263,10 +263,7 @@ export class TranslateClient extends __Client< readonly config: TranslateClientResolvedConfig; constructor(configuration: TranslateClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-translate/runtimeConfig.browser.ts b/clients/client-translate/runtimeConfig.browser.ts index 611cdeb388abc..9a19b9291645a 100644 --- a/clients/client-translate/runtimeConfig.browser.ts +++ b/clients/client-translate/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./TranslateClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranslateClientConfig } from "./TranslateClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranslateClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-translate/runtimeConfig.native.ts b/clients/client-translate/runtimeConfig.native.ts index 811be083a10d6..ed240daba5e10 100644 --- a/clients/client-translate/runtimeConfig.native.ts +++ b/clients/client-translate/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./TranslateClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { TranslateClientConfig } from "./TranslateClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: TranslateClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-translate/runtimeConfig.shared.ts b/clients/client-translate/runtimeConfig.shared.ts index f0456b167716a..84193d8988d5d 100644 --- a/clients/client-translate/runtimeConfig.shared.ts +++ b/clients/client-translate/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { TranslateClientConfig } from "./TranslateClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: TranslateClientConfig) => ({ apiVersion: "2017-07-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Translate", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Translate", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-translate/runtimeConfig.ts b/clients/client-translate/runtimeConfig.ts index 625db47cf9606..3c12140346403 100644 --- a/clients/client-translate/runtimeConfig.ts +++ b/clients/client-translate/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./TranslateClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { TranslateClientConfig } from "./TranslateClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: TranslateClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-waf-regional/WAFRegionalClient.ts b/clients/client-waf-regional/WAFRegionalClient.ts index 9f8a429957883..a95eda9d19781 100644 --- a/clients/client-waf-regional/WAFRegionalClient.ts +++ b/clients/client-waf-regional/WAFRegionalClient.ts @@ -184,7 +184,7 @@ import { } from "./commands/UpdateSqlInjectionMatchSetCommand"; import { UpdateWebACLCommandInput, UpdateWebACLCommandOutput } from "./commands/UpdateWebACLCommand"; import { UpdateXssMatchSetCommandInput, UpdateXssMatchSetCommandOutput } from "./commands/UpdateXssMatchSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -566,10 +566,7 @@ export class WAFRegionalClient extends __Client< readonly config: WAFRegionalClientResolvedConfig; constructor(configuration: WAFRegionalClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-waf-regional/runtimeConfig.browser.ts b/clients/client-waf-regional/runtimeConfig.browser.ts index 4619a15762e14..9450c037fa6a6 100644 --- a/clients/client-waf-regional/runtimeConfig.browser.ts +++ b/clients/client-waf-regional/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WAFRegionalClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFRegionalClientConfig } from "./WAFRegionalClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFRegionalClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-waf-regional/runtimeConfig.native.ts b/clients/client-waf-regional/runtimeConfig.native.ts index 6adaa5d1f8eed..ba2d3dd880cd0 100644 --- a/clients/client-waf-regional/runtimeConfig.native.ts +++ b/clients/client-waf-regional/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WAFRegionalClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WAFRegionalClientConfig } from "./WAFRegionalClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WAFRegionalClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-waf-regional/runtimeConfig.shared.ts b/clients/client-waf-regional/runtimeConfig.shared.ts index ff1647e0167c9..73afd7903ca34 100644 --- a/clients/client-waf-regional/runtimeConfig.shared.ts +++ b/clients/client-waf-regional/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WAFRegionalClientConfig } from "./WAFRegionalClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WAFRegionalClientConfig) => ({ apiVersion: "2016-11-28", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WAF Regional", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WAF Regional", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-waf-regional/runtimeConfig.ts b/clients/client-waf-regional/runtimeConfig.ts index 83985c8d12c6c..1c97080734990 100644 --- a/clients/client-waf-regional/runtimeConfig.ts +++ b/clients/client-waf-regional/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WAFRegionalClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFRegionalClientConfig } from "./WAFRegionalClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFRegionalClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-waf/WAFClient.ts b/clients/client-waf/WAFClient.ts index b7e0b1af69a41..ff300d1b017ac 100644 --- a/clients/client-waf/WAFClient.ts +++ b/clients/client-waf/WAFClient.ts @@ -174,7 +174,7 @@ import { } from "./commands/UpdateSqlInjectionMatchSetCommand"; import { UpdateWebACLCommandInput, UpdateWebACLCommandOutput } from "./commands/UpdateWebACLCommand"; import { UpdateXssMatchSetCommandInput, UpdateXssMatchSetCommandOutput } from "./commands/UpdateXssMatchSetCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -548,10 +548,7 @@ export class WAFClient extends __Client< readonly config: WAFClientResolvedConfig; constructor(configuration: WAFClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-waf/runtimeConfig.browser.ts b/clients/client-waf/runtimeConfig.browser.ts index 29417fd604ae0..e35b95a345261 100644 --- a/clients/client-waf/runtimeConfig.browser.ts +++ b/clients/client-waf/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WAFClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFClientConfig } from "./WAFClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-waf/runtimeConfig.native.ts b/clients/client-waf/runtimeConfig.native.ts index b0ffc8b5f4db8..28bc340fc9f72 100644 --- a/clients/client-waf/runtimeConfig.native.ts +++ b/clients/client-waf/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WAFClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WAFClientConfig } from "./WAFClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WAFClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-waf/runtimeConfig.shared.ts b/clients/client-waf/runtimeConfig.shared.ts index 1e4920f7b72cd..4b68edfd526cb 100644 --- a/clients/client-waf/runtimeConfig.shared.ts +++ b/clients/client-waf/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WAFClientConfig } from "./WAFClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WAFClientConfig) => ({ apiVersion: "2015-08-24", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WAF", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WAF", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-waf/runtimeConfig.ts b/clients/client-waf/runtimeConfig.ts index 47ca0587542b3..de6225fe82028 100644 --- a/clients/client-waf/runtimeConfig.ts +++ b/clients/client-waf/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WAFClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFClientConfig } from "./WAFClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-wafv2/WAFV2Client.ts b/clients/client-wafv2/WAFV2Client.ts index 7617b416e50ce..fc169c1f1594d 100644 --- a/clients/client-wafv2/WAFV2Client.ts +++ b/clients/client-wafv2/WAFV2Client.ts @@ -92,7 +92,7 @@ import { } from "./commands/UpdateRegexPatternSetCommand"; import { UpdateRuleGroupCommandInput, UpdateRuleGroupCommandOutput } from "./commands/UpdateRuleGroupCommand"; import { UpdateWebACLCommandInput, UpdateWebACLCommandOutput } from "./commands/UpdateWebACLCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -438,10 +438,7 @@ export class WAFV2Client extends __Client< readonly config: WAFV2ClientResolvedConfig; constructor(configuration: WAFV2ClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-wafv2/runtimeConfig.browser.ts b/clients/client-wafv2/runtimeConfig.browser.ts index 1453fb9cb61ca..2783915f551f8 100644 --- a/clients/client-wafv2/runtimeConfig.browser.ts +++ b/clients/client-wafv2/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WAFV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFV2ClientConfig } from "./WAFV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-wafv2/runtimeConfig.native.ts b/clients/client-wafv2/runtimeConfig.native.ts index 31797ed4b06fe..8a353e24fa5e1 100644 --- a/clients/client-wafv2/runtimeConfig.native.ts +++ b/clients/client-wafv2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WAFV2Client"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WAFV2ClientConfig } from "./WAFV2Client"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WAFV2ClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-wafv2/runtimeConfig.shared.ts b/clients/client-wafv2/runtimeConfig.shared.ts index f96f861d5c3eb..bf895f24b3879 100644 --- a/clients/client-wafv2/runtimeConfig.shared.ts +++ b/clients/client-wafv2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WAFV2ClientConfig } from "./WAFV2Client"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WAFV2ClientConfig) => ({ apiVersion: "2019-07-29", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WAFV2", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WAFV2", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-wafv2/runtimeConfig.ts b/clients/client-wafv2/runtimeConfig.ts index a05305c7f1707..6cf9ce9ba8680 100644 --- a/clients/client-wafv2/runtimeConfig.ts +++ b/clients/client-wafv2/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WAFV2Client"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WAFV2ClientConfig } from "./WAFV2Client"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WAFV2ClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-wellarchitected/WellArchitectedClient.ts b/clients/client-wellarchitected/WellArchitectedClient.ts index ab0f35c6f4585..5a09471b3b8f9 100644 --- a/clients/client-wellarchitected/WellArchitectedClient.ts +++ b/clients/client-wellarchitected/WellArchitectedClient.ts @@ -56,7 +56,7 @@ import { UpdateWorkloadShareCommandOutput, } from "./commands/UpdateWorkloadShareCommand"; import { UpgradeLensReviewCommandInput, UpgradeLensReviewCommandOutput } from "./commands/UpgradeLensReviewCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -334,10 +334,7 @@ export class WellArchitectedClient extends __Client< readonly config: WellArchitectedClientResolvedConfig; constructor(configuration: WellArchitectedClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-wellarchitected/runtimeConfig.browser.ts b/clients/client-wellarchitected/runtimeConfig.browser.ts index a1975c17a186b..3f530a2dfda60 100644 --- a/clients/client-wellarchitected/runtimeConfig.browser.ts +++ b/clients/client-wellarchitected/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WellArchitectedClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WellArchitectedClientConfig } from "./WellArchitectedClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WellArchitectedClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-wellarchitected/runtimeConfig.native.ts b/clients/client-wellarchitected/runtimeConfig.native.ts index d32398df27750..98f5444be9012 100644 --- a/clients/client-wellarchitected/runtimeConfig.native.ts +++ b/clients/client-wellarchitected/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WellArchitectedClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WellArchitectedClientConfig } from "./WellArchitectedClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WellArchitectedClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-wellarchitected/runtimeConfig.shared.ts b/clients/client-wellarchitected/runtimeConfig.shared.ts index 4a86aa5f6d15b..e76acfdeeb886 100644 --- a/clients/client-wellarchitected/runtimeConfig.shared.ts +++ b/clients/client-wellarchitected/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WellArchitectedClientConfig } from "./WellArchitectedClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WellArchitectedClientConfig) => ({ apiVersion: "2020-03-31", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WellArchitected", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WellArchitected", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-wellarchitected/runtimeConfig.ts b/clients/client-wellarchitected/runtimeConfig.ts index d70a99b5073ae..ed72722951f6b 100644 --- a/clients/client-wellarchitected/runtimeConfig.ts +++ b/clients/client-wellarchitected/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WellArchitectedClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WellArchitectedClientConfig } from "./WellArchitectedClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WellArchitectedClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workdocs/WorkDocsClient.ts b/clients/client-workdocs/WorkDocsClient.ts index dc7976d86726b..21ac9ba3c874f 100644 --- a/clients/client-workdocs/WorkDocsClient.ts +++ b/clients/client-workdocs/WorkDocsClient.ts @@ -87,7 +87,7 @@ import { } from "./commands/UpdateDocumentVersionCommand"; import { UpdateFolderCommandInput, UpdateFolderCommandOutput } from "./commands/UpdateFolderCommand"; import { UpdateUserCommandInput, UpdateUserCommandOutput } from "./commands/UpdateUserCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -411,10 +411,7 @@ export class WorkDocsClient extends __Client< readonly config: WorkDocsClientResolvedConfig; constructor(configuration: WorkDocsClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-workdocs/runtimeConfig.browser.ts b/clients/client-workdocs/runtimeConfig.browser.ts index 24f6066740819..bdadfda0a0829 100644 --- a/clients/client-workdocs/runtimeConfig.browser.ts +++ b/clients/client-workdocs/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WorkDocsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkDocsClientConfig } from "./WorkDocsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkDocsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workdocs/runtimeConfig.native.ts b/clients/client-workdocs/runtimeConfig.native.ts index cb1c286cbcd44..165de5494341f 100644 --- a/clients/client-workdocs/runtimeConfig.native.ts +++ b/clients/client-workdocs/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WorkDocsClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WorkDocsClientConfig } from "./WorkDocsClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WorkDocsClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-workdocs/runtimeConfig.shared.ts b/clients/client-workdocs/runtimeConfig.shared.ts index 1c9be0d0d5d23..0e5273436ed91 100644 --- a/clients/client-workdocs/runtimeConfig.shared.ts +++ b/clients/client-workdocs/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WorkDocsClientConfig } from "./WorkDocsClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WorkDocsClientConfig) => ({ apiVersion: "2016-05-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WorkDocs", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WorkDocs", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-workdocs/runtimeConfig.ts b/clients/client-workdocs/runtimeConfig.ts index c5b0b587dc612..926fe1f3a45f0 100644 --- a/clients/client-workdocs/runtimeConfig.ts +++ b/clients/client-workdocs/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WorkDocsClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkDocsClientConfig } from "./WorkDocsClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkDocsClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-worklink/WorkLinkClient.ts b/clients/client-worklink/WorkLinkClient.ts index f06d70bb837d4..481039a54d3fe 100644 --- a/clients/client-worklink/WorkLinkClient.ts +++ b/clients/client-worklink/WorkLinkClient.ts @@ -91,7 +91,7 @@ import { UpdateIdentityProviderConfigurationCommandInput, UpdateIdentityProviderConfigurationCommandOutput, } from "./commands/UpdateIdentityProviderConfigurationCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -373,10 +373,7 @@ export class WorkLinkClient extends __Client< readonly config: WorkLinkClientResolvedConfig; constructor(configuration: WorkLinkClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-worklink/runtimeConfig.browser.ts b/clients/client-worklink/runtimeConfig.browser.ts index e2710867c0167..b48b68d83b939 100644 --- a/clients/client-worklink/runtimeConfig.browser.ts +++ b/clients/client-worklink/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WorkLinkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkLinkClientConfig } from "./WorkLinkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkLinkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-worklink/runtimeConfig.native.ts b/clients/client-worklink/runtimeConfig.native.ts index d0c16bd31f35a..d0494982981e4 100644 --- a/clients/client-worklink/runtimeConfig.native.ts +++ b/clients/client-worklink/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WorkLinkClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WorkLinkClientConfig } from "./WorkLinkClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WorkLinkClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-worklink/runtimeConfig.shared.ts b/clients/client-worklink/runtimeConfig.shared.ts index c54853fcbc5e0..ef47be7e3d065 100644 --- a/clients/client-worklink/runtimeConfig.shared.ts +++ b/clients/client-worklink/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WorkLinkClientConfig } from "./WorkLinkClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WorkLinkClientConfig) => ({ apiVersion: "2018-09-25", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WorkLink", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WorkLink", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-worklink/runtimeConfig.ts b/clients/client-worklink/runtimeConfig.ts index 28e5b568778e3..3542ed9d4c04e 100644 --- a/clients/client-worklink/runtimeConfig.ts +++ b/clients/client-worklink/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WorkLinkClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkLinkClientConfig } from "./WorkLinkClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkLinkClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workmail/WorkMailClient.ts b/clients/client-workmail/WorkMailClient.ts index 0174b60a6086d..11566d0daa23c 100644 --- a/clients/client-workmail/WorkMailClient.ts +++ b/clients/client-workmail/WorkMailClient.ts @@ -133,7 +133,7 @@ import { UpdatePrimaryEmailAddressCommandOutput, } from "./commands/UpdatePrimaryEmailAddressCommand"; import { UpdateResourceCommandInput, UpdateResourceCommandOutput } from "./commands/UpdateResourceCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -486,10 +486,7 @@ export class WorkMailClient extends __Client< readonly config: WorkMailClientResolvedConfig; constructor(configuration: WorkMailClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-workmail/runtimeConfig.browser.ts b/clients/client-workmail/runtimeConfig.browser.ts index a9fab859256e9..58d72407a58b2 100644 --- a/clients/client-workmail/runtimeConfig.browser.ts +++ b/clients/client-workmail/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WorkMailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkMailClientConfig } from "./WorkMailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkMailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workmail/runtimeConfig.native.ts b/clients/client-workmail/runtimeConfig.native.ts index 568be7b3ea408..de230e2a57937 100644 --- a/clients/client-workmail/runtimeConfig.native.ts +++ b/clients/client-workmail/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WorkMailClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WorkMailClientConfig } from "./WorkMailClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WorkMailClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-workmail/runtimeConfig.shared.ts b/clients/client-workmail/runtimeConfig.shared.ts index 92fae30e87a7d..6225607d715fc 100644 --- a/clients/client-workmail/runtimeConfig.shared.ts +++ b/clients/client-workmail/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WorkMailClientConfig } from "./WorkMailClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WorkMailClientConfig) => ({ apiVersion: "2017-10-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WorkMail", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WorkMail", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-workmail/runtimeConfig.ts b/clients/client-workmail/runtimeConfig.ts index 673abe1c39e0f..4e15648aaabc5 100644 --- a/clients/client-workmail/runtimeConfig.ts +++ b/clients/client-workmail/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WorkMailClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkMailClientConfig } from "./WorkMailClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkMailClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workmailmessageflow/WorkMailMessageFlowClient.ts b/clients/client-workmailmessageflow/WorkMailMessageFlowClient.ts index 41f38ae16ee7c..f0a2db60689ec 100644 --- a/clients/client-workmailmessageflow/WorkMailMessageFlowClient.ts +++ b/clients/client-workmailmessageflow/WorkMailMessageFlowClient.ts @@ -6,7 +6,7 @@ import { PutRawMessageContentCommandInput, PutRawMessageContentCommandOutput, } from "./commands/PutRawMessageContentCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -220,10 +220,7 @@ export class WorkMailMessageFlowClient extends __Client< readonly config: WorkMailMessageFlowClientResolvedConfig; constructor(configuration: WorkMailMessageFlowClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-workmailmessageflow/runtimeConfig.browser.ts b/clients/client-workmailmessageflow/runtimeConfig.browser.ts index 4972832f01058..41ef2f768fe53 100644 --- a/clients/client-workmailmessageflow/runtimeConfig.browser.ts +++ b/clients/client-workmailmessageflow/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WorkMailMessageFlowClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workmailmessageflow/runtimeConfig.native.ts b/clients/client-workmailmessageflow/runtimeConfig.native.ts index 73ad10fb6f6fc..05d248127b451 100644 --- a/clients/client-workmailmessageflow/runtimeConfig.native.ts +++ b/clients/client-workmailmessageflow/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WorkMailMessageFlowClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-workmailmessageflow/runtimeConfig.shared.ts b/clients/client-workmailmessageflow/runtimeConfig.shared.ts index 99b9acd30daba..afd6df75ff590 100644 --- a/clients/client-workmailmessageflow/runtimeConfig.shared.ts +++ b/clients/client-workmailmessageflow/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => ({ apiVersion: "2019-05-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WorkMailMessageFlow", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WorkMailMessageFlow", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-workmailmessageflow/runtimeConfig.ts b/clients/client-workmailmessageflow/runtimeConfig.ts index 975cd4d0d8538..d179e02288878 100644 --- a/clients/client-workmailmessageflow/runtimeConfig.ts +++ b/clients/client-workmailmessageflow/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WorkMailMessageFlowClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkMailMessageFlowClientConfig } from "./WorkMailMessageFlowClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkMailMessageFlowClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workspaces/WorkSpacesClient.ts b/clients/client-workspaces/WorkSpacesClient.ts index 47caca73bca5d..aecb464038dbe 100644 --- a/clients/client-workspaces/WorkSpacesClient.ts +++ b/clients/client-workspaces/WorkSpacesClient.ts @@ -150,7 +150,7 @@ import { UpdateWorkspaceImagePermissionCommandInput, UpdateWorkspaceImagePermissionCommandOutput, } from "./commands/UpdateWorkspaceImagePermissionCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -468,10 +468,7 @@ export class WorkSpacesClient extends __Client< readonly config: WorkSpacesClientResolvedConfig; constructor(configuration: WorkSpacesClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-workspaces/runtimeConfig.browser.ts b/clients/client-workspaces/runtimeConfig.browser.ts index 15dac90d2632a..a65667d31a542 100644 --- a/clients/client-workspaces/runtimeConfig.browser.ts +++ b/clients/client-workspaces/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./WorkSpacesClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkSpacesClientConfig } from "./WorkSpacesClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkSpacesClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-workspaces/runtimeConfig.native.ts b/clients/client-workspaces/runtimeConfig.native.ts index 396313f75e503..c67830ae4a2f1 100644 --- a/clients/client-workspaces/runtimeConfig.native.ts +++ b/clients/client-workspaces/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./WorkSpacesClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { WorkSpacesClientConfig } from "./WorkSpacesClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: WorkSpacesClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-workspaces/runtimeConfig.shared.ts b/clients/client-workspaces/runtimeConfig.shared.ts index f8b5cca5b27e7..920fabf5eaeab 100644 --- a/clients/client-workspaces/runtimeConfig.shared.ts +++ b/clients/client-workspaces/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { WorkSpacesClientConfig } from "./WorkSpacesClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: WorkSpacesClientConfig) => ({ apiVersion: "2015-04-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "WorkSpaces", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "WorkSpaces", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-workspaces/runtimeConfig.ts b/clients/client-workspaces/runtimeConfig.ts index 4b02b097bfd6d..b6f966238321c 100644 --- a/clients/client-workspaces/runtimeConfig.ts +++ b/clients/client-workspaces/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./WorkSpacesClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { WorkSpacesClientConfig } from "./WorkSpacesClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: WorkSpacesClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-xray/XRayClient.ts b/clients/client-xray/XRayClient.ts index 22812cd4956d9..397f0be626f8f 100644 --- a/clients/client-xray/XRayClient.ts +++ b/clients/client-xray/XRayClient.ts @@ -49,7 +49,7 @@ import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/Ta import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand"; import { UpdateGroupCommandInput, UpdateGroupCommandOutput } from "./commands/UpdateGroupCommand"; import { UpdateSamplingRuleCommandInput, UpdateSamplingRuleCommandOutput } from "./commands/UpdateSamplingRuleCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -314,10 +314,7 @@ export class XRayClient extends __Client< readonly config: XRayClientResolvedConfig; constructor(configuration: XRayClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/clients/client-xray/runtimeConfig.browser.ts b/clients/client-xray/runtimeConfig.browser.ts index ab62cf726b2cb..bd583e7b6c647 100644 --- a/clients/client-xray/runtimeConfig.browser.ts +++ b/clients/client-xray/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./XRayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { XRayClientConfig } from "./XRayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: XRayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/clients/client-xray/runtimeConfig.native.ts b/clients/client-xray/runtimeConfig.native.ts index b0c08cafda9a9..495c4b18b04f7 100644 --- a/clients/client-xray/runtimeConfig.native.ts +++ b/clients/client-xray/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./XRayClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { XRayClientConfig } from "./XRayClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: XRayClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/clients/client-xray/runtimeConfig.shared.ts b/clients/client-xray/runtimeConfig.shared.ts index b4652b2f84e44..4bba2bbb89525 100644 --- a/clients/client-xray/runtimeConfig.shared.ts +++ b/clients/client-xray/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { XRayClientConfig } from "./XRayClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: XRayClientConfig) => ({ apiVersion: "2016-04-12", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "XRay", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "XRay", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/clients/client-xray/runtimeConfig.ts b/clients/client-xray/runtimeConfig.ts index a770281c7413d..57a098be94967 100644 --- a/clients/client-xray/runtimeConfig.ts +++ b/clients/client-xray/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./XRayClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { XRayClientConfig } from "./XRayClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: XRayClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java index 59171c15217fe..69f22c4e0af3a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPlugin.java @@ -161,15 +161,13 @@ public Map> getRuntimeConfigWriters( String signingService = service.getTrait(SigV4Trait.class).get().getName(); return MapUtils.of( "signingName", writer -> { - writer.write("signingName: $S,", signingService); + writer.write("$S", signingService); } ); case BROWSER: return MapUtils.of( "credentialDefaultProvider", writer -> { - writer.write( - "credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error(" - + "\"Credential is missing\")),"); + writer.write("((_: unknown) => () => Promise.reject(new Error(\"Credential is missing\")))"); } ); case NODE: @@ -186,8 +184,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE); writer.addImport("defaultProvider", "credentialDefaultProvider", AwsDependency.CREDENTIAL_PROVIDER_NODE.packageName); - writer.write("credentialDefaultProvider: decorateDefaultCredentialProvider(" - + "credentialDefaultProvider),"); + writer.write("decorateDefaultCredentialProvider(credentialDefaultProvider)"); } ); default: 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 7cb7a0d0273de..02a87f5645ff6 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 @@ -103,7 +103,7 @@ public Map> getRuntimeConfigWriters( .orElse(null); if (serviceId != null) { runtimeConfigs.put("serviceId", writer -> { - writer.write("serviceId: $S,", serviceId); + writer.write("$S", serviceId); }); } else { LOGGER.info("Cannot generate a serivce ID for the client because no aws.api#Service " @@ -128,7 +128,7 @@ private Map> getDefaultConfig( writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); writer.addImport("invalidProvider", "invalidProvider", TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.write("region: invalidProvider(\"Region is missing\"),"); + writer.write("invalidProvider(\"Region is missing\")"); }); case NODE: return MapUtils.of("region", writer -> { @@ -141,7 +141,7 @@ private Map> getDefaultConfig( writer.addImport("NODE_REGION_CONFIG_FILE_OPTIONS", "NODE_REGION_CONFIG_FILE_OPTIONS", TypeScriptDependency.CONFIG_RESOLVER.packageName); writer.write( - "region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),"); + "loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS)"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBodyChecksumGeneratorDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBodyChecksumGeneratorDependency.java index 7a15762a52986..4fa386c2ab9a3 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBodyChecksumGeneratorDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBodyChecksumGeneratorDependency.java @@ -72,14 +72,14 @@ public Map> getRuntimeConfigWriters( writer.addDependency(AwsDependency.BODY_CHECKSUM_GENERATOR_NODE); writer.addImport("bodyChecksumGenerator", "bodyChecksumGenerator", AwsDependency.BODY_CHECKSUM_GENERATOR_NODE.packageName); - writer.write("bodyChecksumGenerator,"); + writer.write("bodyChecksumGenerator"); }); case BROWSER: return MapUtils.of("bodyChecksumGenerator", writer -> { writer.addDependency(AwsDependency.BODY_CHECKSUM_GENERATOR_BROWSER); writer.addImport("bodyChecksumGenerator", "bodyChecksumGenerator", AwsDependency.BODY_CHECKSUM_GENERATOR_BROWSER.packageName); - writer.write("bodyChecksumGenerator,"); + writer.write("bodyChecksumGenerator"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddClientRuntimeConfig.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddClientRuntimeConfig.java index 4b7c648dd5407..b0254f0ab363a 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddClientRuntimeConfig.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddClientRuntimeConfig.java @@ -91,7 +91,7 @@ public Map> getRuntimeConfigWriters( return MapUtils.of( "logger", writer -> { writer.addImport("Logger", "__Logger", TypeScriptDependency.AWS_SDK_TYPES.packageName); - writer.write("logger: {} as __Logger,"); + writer.write("{} as __Logger"); } ); case BROWSER: @@ -100,13 +100,13 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY); writer.addImport("DEFAULT_MAX_ATTEMPTS", "DEFAULT_MAX_ATTEMPTS", TypeScriptDependency.MIDDLEWARE_RETRY.packageName); - writer.write("maxAttempts: DEFAULT_MAX_ATTEMPTS,"); + writer.write("DEFAULT_MAX_ATTEMPTS"); }, "retryModeProvider", writer -> { writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY); writer.addImport("DEFAULT_RETRY_MODE", "DEFAULT_RETRY_MODE", TypeScriptDependency.MIDDLEWARE_RETRY.packageName); - writer.write("retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE),"); + writer.write("(() => Promise.resolve(DEFAULT_RETRY_MODE))"); } ); case NODE: @@ -117,7 +117,7 @@ public Map> getRuntimeConfigWriters( AwsDependency.NODE_CONFIG_PROVIDER.packageName); writer.addImport("NODE_MAX_ATTEMPT_CONFIG_OPTIONS", "NODE_MAX_ATTEMPT_CONFIG_OPTIONS", TypeScriptDependency.MIDDLEWARE_RETRY.packageName); - writer.write("maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),"); + writer.write("loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS)"); }, "retryModeProvider", writer -> { writer.addDependency(AwsDependency.NODE_CONFIG_PROVIDER); @@ -126,7 +126,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY); writer.addImport("NODE_RETRY_MODE_CONFIG_OPTIONS", "NODE_RETRY_MODE_CONFIG_OPTIONS", TypeScriptDependency.MIDDLEWARE_RETRY.packageName); - writer.write("retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),"); + writer.write("loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS)"); } ); default: diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java index 3533b67ab3ea0..960cae5c68e52 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEndpointDiscoveryPlugin.java @@ -108,7 +108,7 @@ public Map> getRuntimeConfigWriters( case BROWSER: return MapUtils.of( "endpointDiscoveryEnabledProvider", writer -> { - writer.write("endpointDiscoveryEnabledProvider: () => Promise.resolve(undefined),"); + writer.write("(() => Promise.resolve(undefined))"); } ); case NODE: @@ -118,8 +118,7 @@ public Map> getRuntimeConfigWriters( writer.addImport("NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS", "NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS", AwsDependency.MIDDLEWARE_ENDPOINT_DISCOVERY.packageName); - writer.write("endpointDiscoveryEnabledProvider: loadNodeConfig(" - + "NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS),"); + writer.write("loadNodeConfig(NODE_ENDPOINT_DISCOVERY_CONFIG_OPTIONS)"); } ); default: diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java index d4e53bdc0012b..d776f3ed05cc3 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddEventStreamHandlingDependency.java @@ -95,7 +95,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(AwsDependency.AWS_SDK_EVENTSTREAM_HANDLER_NODE); writer.addImport("eventStreamPayloadHandlerProvider", "eventStreamPayloadHandlerProvider", AwsDependency.AWS_SDK_EVENTSTREAM_HANDLER_NODE.packageName); - writer.write("eventStreamPayloadHandlerProvider,"); + writer.write("eventStreamPayloadHandlerProvider"); }); case BROWSER: /** @@ -107,7 +107,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); writer.addImport("invalidFunction", "invalidFunction", TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.openBlock("eventStreamPayloadHandlerProvider: () => ({", "}),", () -> { + writer.openBlock("(() => ({", "}))", () -> { writer.write("handle: invalidFunction(\"event stream request is not supported in browser.\"),"); }); }); @@ -121,7 +121,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY); writer.addImport("invalidFunction", "invalidFunction", TypeScriptDependency.INVALID_DEPENDENCY.packageName); - writer.openBlock("eventStreamPayloadHandlerProvider: () => ({", "}),", () -> { + writer.openBlock("(() => ({", "}))", () -> { writer.write("handle: invalidFunction(\"event stream request " + "is not supported in ReactNative.\"),"); }); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttp2Dependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttp2Dependency.java index 93b00c534b3cd..926f1726ef0a1 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttp2Dependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddHttp2Dependency.java @@ -49,7 +49,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER); writer.addImport("NodeHttp2Handler", "NodeHttp2Handler", TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER.packageName); - writer.write("requestHandler: new NodeHttp2Handler(),"); + writer.write("new NodeHttp2Handler()"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java index dd06e1901ca4f..78901ba5f5a7c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddS3Config.java @@ -84,9 +84,9 @@ public Map> getRuntimeConfigWriters(TypeScrip switch (target) { case SHARED: return MapUtils.of("signingEscapePath", writer -> { - writer.write("signingEscapePath: false,"); + writer.write("false"); }, "useArnRegion", writer -> { - writer.write("useArnRegion: false"); + writer.write("false"); }); case NODE: return MapUtils.of("useArnRegion", writer -> { @@ -95,7 +95,7 @@ public Map> getRuntimeConfigWriters(TypeScrip .addDependency(AwsDependency.BUCKET_ENDPOINT_MIDDLEWARE) .addImport("NODE_USE_ARN_REGION_CONFIG_OPTIONS", "NODE_USE_ARN_REGION_CONFIG_OPTIONS", AwsDependency.BUCKET_ENDPOINT_MIDDLEWARE.packageName) - .write("useArnRegion: loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS),"); + .write("loadNodeConfig(NODE_USE_ARN_REGION_CONFIG_OPTIONS)"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddSqsDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddSqsDependency.java index 3eccae37277a1..1869ef8817338 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddSqsDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddSqsDependency.java @@ -97,13 +97,13 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.AWS_SDK_TYPES); writer.addImport("HashConstructor", "__HashConstructor", TypeScriptDependency.AWS_SDK_TYPES.packageName); - writer.write("md5: Hash.bind(null, \"md5\"),"); + writer.write("Hash.bind(null, \"md5\")"); }); case BROWSER: return MapUtils.of("md5", writer -> { writer.addDependency(TypeScriptDependency.MD5_BROWSER); writer.addImport("Md5", "Md5", TypeScriptDependency.MD5_BROWSER.packageName); - writer.write("md5: Md5,"); + writer.write("Md5"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java index 67d99f870d1d1..9a1527f5cca1c 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddTranscribeStreamingDependency.java @@ -67,13 +67,13 @@ public Map> getRuntimeConfigWriters( writer.addDependency(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE); writer.addImport("eventStreamPayloadHandler", "eventStreamPayloadHandler", AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.packageName); - writer.write("eventStreamPayloadHandlerProvider: () => eventStreamPayloadHandler,"); + writer.write("(() => eventStreamPayloadHandler)"); }, "requestHandler", writer -> { writer.addDependency(AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE); writer.addImport("WebSocketHandler", "WebSocketHandler", AwsDependency.TRANSCRIBE_STREAMING_MIDDLEWARE.packageName); - writer.write("requestHandler: new WebSocketHandler(),"); + writer.write("new WebSocketHandler()"); }); switch (target) { @@ -83,7 +83,7 @@ public Map> getRuntimeConfigWriters( writer.addDependency(TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER); writer.addImport("NodeHttp2Handler", "NodeHttp2Handler", TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER.packageName); - writer.write("requestHandler: new NodeHttp2Handler({ disableConcurrentStreams: true }),"); + writer.write("new NodeHttp2Handler({ disableConcurrentStreams: true })"); }); case REACT_NATIVE: case BROWSER: diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependency.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependency.java index 8bf68ba0e2d92..999d0a1d35fff 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependency.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependency.java @@ -93,9 +93,9 @@ public Map> getRuntimeConfigWriters( } private void writeDefaultUserAgentProvider(TypeScriptWriter writer, TypeScriptSettings settings, Model model) { - writer.write("defaultUserAgentProvider: defaultUserAgent({" + writer.write("defaultUserAgent({" // serviceId is optional in defaultUserAgent. serviceId exists only for AWS services - + (isAwsService(settings, model) ? "serviceId: ClientSharedValues.serviceId, " : "") - + "clientVersion: packageInfo.version}),"); + + (isAwsService(settings, model) ? "serviceId: clientSharedValues.serviceId, " : "") + + "clientVersion: packageInfo.version})"); } } diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEndpointGeneratorIntegration.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEndpointGeneratorIntegration.java index 5cd58c8685483..30ea604ea4ccc 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEndpointGeneratorIntegration.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEndpointGeneratorIntegration.java @@ -84,7 +84,7 @@ public Map> getRuntimeConfigWriters( case SHARED: return MapUtils.of("regionInfoProvider", writer -> { writer.addImport("defaultRegionInfoProvider", "defaultRegionInfoProvider", "./endpoints"); - writer.write("regionInfoProvider: defaultRegionInfoProvider,"); + writer.write("defaultRegionInfoProvider"); }); default: return Collections.emptyMap(); diff --git a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPluginTest.java b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPluginTest.java index 201f22d6b4452..5eef6af88762f 100644 --- a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPluginTest.java +++ b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsAuthPluginTest.java @@ -42,7 +42,7 @@ public void awsClient() { // Check config files assertThat(manifest.getFileString("runtimeConfig.ts").get(), - containsString("credentialDefaultProvider: decorateDefaultCredentialProvider")); + containsString("decorateDefaultCredentialProvider")); assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("Credential is missing")); assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), not(containsString("signingName:"))); @@ -81,7 +81,7 @@ public void sigV4GenericClient() { // Check config files assertThat(manifest.getFileString("runtimeConfig.ts").get(), - containsString("credentialDefaultProvider: decorateDefaultCredentialProvider")); + containsString("decorateDefaultCredentialProvider")); assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("Credential is missing")); assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), containsString("signingName:")); @@ -120,7 +120,7 @@ public void notSigV4GenericClient() { // Check config files assertThat(manifest.getFileString("runtimeConfig.ts").get(), - not(containsString("credentialDefaultProvider: decorateDefaultCredentialProvider"))); + not(containsString("decorateDefaultCredentialProvider"))); assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), not(containsString("Credential is missing"))); assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), not(containsString("signingName:"))); diff --git a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfigTest.java b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfigTest.java index 4fd4bcfac6b8a..f2f60a437f2a3 100644 --- a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfigTest.java +++ b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddAwsRuntimeConfigTest.java @@ -44,9 +44,9 @@ public void awsClient() { assertThat(manifest.getFileString("NotSameClient.ts").get(), containsString("region?:")); // Check config files - assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), containsString("serviceId: \"Not Same\"")); - assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("region: invalidProvider")); - assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("region: loadNodeConfig")); + assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), containsString("serviceId: config.serviceId ?? \"Not Same\"")); + assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("region: config.region ?? invalidProvider")); + assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("region: config.region ?? loadNodeConfig")); } @Test @@ -81,8 +81,8 @@ public void sigV4GenericClient() { // Check config files assertThat(manifest.getFileString("runtimeConfig.shared.ts").get(), not(containsString("serviceId:"))); - assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("region: invalidProvider")); - assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("region: loadNodeConfig")); + assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("region: config.region ?? invalidProvider")); + assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("region: config.region ?? loadNodeConfig")); } @Test diff --git a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependencyTest.java b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependencyTest.java index f655e7b1f3391..9a8513d23e0d9 100644 --- a/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependencyTest.java +++ b/codegen/smithy-aws-typescript-codegen/src/test/java/software/amazon/smithy/aws/typescript/codegen/AddUserAgentDependencyTest.java @@ -42,11 +42,11 @@ public void awsClient() { // Check config files assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("defaultUserAgent")); assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("packageInfo.version")); - assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("ClientSharedValues.serviceId")); + assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("clientSharedValues.serviceId")); assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("defaultUserAgent")); assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("packageInfo.version")); - assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("ClientSharedValues.serviceId")); + assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("clientSharedValues.serviceId")); // Check the config resolution and middleware plugin assertThat(manifest.getFileString("NotSameClient.ts").get(), containsString("resolveUserAgentConfig")); diff --git a/protocol_tests/aws-ec2/EC2ProtocolClient.ts b/protocol_tests/aws-ec2/EC2ProtocolClient.ts index 104e5e34dc595..2afa2beafaab6 100644 --- a/protocol_tests/aws-ec2/EC2ProtocolClient.ts +++ b/protocol_tests/aws-ec2/EC2ProtocolClient.ts @@ -33,7 +33,7 @@ import { XmlEnumsCommandInput, XmlEnumsCommandOutput } from "./commands/XmlEnums import { XmlListsCommandInput, XmlListsCommandOutput } from "./commands/XmlListsCommand"; import { XmlNamespacesCommandInput, XmlNamespacesCommandOutput } from "./commands/XmlNamespacesCommand"; import { XmlTimestampsCommandInput, XmlTimestampsCommandOutput } from "./commands/XmlTimestampsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -263,10 +263,7 @@ export class EC2ProtocolClient extends __Client< readonly config: EC2ProtocolClientResolvedConfig; constructor(configuration: EC2ProtocolClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/protocol_tests/aws-ec2/runtimeConfig.browser.ts b/protocol_tests/aws-ec2/runtimeConfig.browser.ts index affd3bccf52c3..bf9d886b56ef9 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.browser.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.browser.ts @@ -7,27 +7,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./EC2ProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2ProtocolClientConfig } from "./EC2ProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-ec2/runtimeConfig.native.ts b/protocol_tests/aws-ec2/runtimeConfig.native.ts index 34df16be30da0..59fabb634ffca 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.native.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./EC2ProtocolClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { EC2ProtocolClientConfig } from "./EC2ProtocolClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/protocol_tests/aws-ec2/runtimeConfig.shared.ts b/protocol_tests/aws-ec2/runtimeConfig.shared.ts index 08b60e712bbc6..e6edff2e1ed32 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.shared.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { EC2ProtocolClientConfig } from "./EC2ProtocolClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => ({ apiVersion: "2020-01-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "EC2 Protocol", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "EC2 Protocol", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/protocol_tests/aws-ec2/runtimeConfig.ts b/protocol_tests/aws-ec2/runtimeConfig.ts index 08d9087c6bf17..8c8b1087c1f27 100644 --- a/protocol_tests/aws-ec2/runtimeConfig.ts +++ b/protocol_tests/aws-ec2/runtimeConfig.ts @@ -8,27 +8,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./EC2ProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { EC2ProtocolClientConfig } from "./EC2ProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-json/JsonProtocolClient.ts b/protocol_tests/aws-json/JsonProtocolClient.ts index 7832b368b118b..a579bcc72088a 100644 --- a/protocol_tests/aws-json/JsonProtocolClient.ts +++ b/protocol_tests/aws-json/JsonProtocolClient.ts @@ -24,7 +24,7 @@ import { SimpleScalarPropertiesCommandInput, SimpleScalarPropertiesCommandOutput, } from "./commands/SimpleScalarPropertiesCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -253,10 +253,7 @@ export class JsonProtocolClient extends __Client< readonly config: JsonProtocolClientResolvedConfig; constructor(configuration: JsonProtocolClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/protocol_tests/aws-json/runtimeConfig.browser.ts b/protocol_tests/aws-json/runtimeConfig.browser.ts index 5e1930bf11898..e3596882e9b8c 100644 --- a/protocol_tests/aws-json/runtimeConfig.browser.ts +++ b/protocol_tests/aws-json/runtimeConfig.browser.ts @@ -8,29 +8,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./JsonProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { JsonProtocolClientConfig } from "./JsonProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("Credential is missing")), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - region: invalidProvider("Region is missing"), - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: JsonProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + region: config.region ?? invalidProvider("Region is missing"), + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-json/runtimeConfig.native.ts b/protocol_tests/aws-json/runtimeConfig.native.ts index b677bfe9f69b8..29b0dfc4d6558 100644 --- a/protocol_tests/aws-json/runtimeConfig.native.ts +++ b/protocol_tests/aws-json/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./JsonProtocolClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { JsonProtocolClientConfig } from "./JsonProtocolClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: JsonProtocolClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/protocol_tests/aws-json/runtimeConfig.shared.ts b/protocol_tests/aws-json/runtimeConfig.shared.ts index 1ae33ef57c26c..273795b696f9b 100644 --- a/protocol_tests/aws-json/runtimeConfig.shared.ts +++ b/protocol_tests/aws-json/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { JsonProtocolClientConfig } from "./JsonProtocolClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: JsonProtocolClientConfig) => ({ apiVersion: "2018-01-01", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Json Protocol", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Json Protocol", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/protocol_tests/aws-json/runtimeConfig.ts b/protocol_tests/aws-json/runtimeConfig.ts index 092961ef8e308..1c18134c4c471 100644 --- a/protocol_tests/aws-json/runtimeConfig.ts +++ b/protocol_tests/aws-json/runtimeConfig.ts @@ -11,29 +11,33 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./JsonProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { JsonProtocolClientConfig } from "./JsonProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - credentialDefaultProvider: decorateDefaultCredentialProvider(credentialDefaultProvider), - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: JsonProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + credentialDefaultProvider: + config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider), + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-query/QueryProtocolClient.ts b/protocol_tests/aws-query/QueryProtocolClient.ts index 7c5315fa574ca..e0b687a32b6fe 100644 --- a/protocol_tests/aws-query/QueryProtocolClient.ts +++ b/protocol_tests/aws-query/QueryProtocolClient.ts @@ -47,7 +47,7 @@ import { XmlMapsCommandInput, XmlMapsCommandOutput } from "./commands/XmlMapsCom import { XmlMapsXmlNameCommandInput, XmlMapsXmlNameCommandOutput } from "./commands/XmlMapsXmlNameCommand"; import { XmlNamespacesCommandInput, XmlNamespacesCommandOutput } from "./commands/XmlNamespacesCommand"; import { XmlTimestampsCommandInput, XmlTimestampsCommandOutput } from "./commands/XmlTimestampsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -293,10 +293,7 @@ export class QueryProtocolClient extends __Client< readonly config: QueryProtocolClientResolvedConfig; constructor(configuration: QueryProtocolClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/protocol_tests/aws-query/runtimeConfig.browser.ts b/protocol_tests/aws-query/runtimeConfig.browser.ts index 1e9a8ca0c5331..bf2e9caa761bc 100644 --- a/protocol_tests/aws-query/runtimeConfig.browser.ts +++ b/protocol_tests/aws-query/runtimeConfig.browser.ts @@ -7,27 +7,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./QueryProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QueryProtocolClientConfig } from "./QueryProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QueryProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-query/runtimeConfig.native.ts b/protocol_tests/aws-query/runtimeConfig.native.ts index 293d8ed99c309..f2ad16dca4565 100644 --- a/protocol_tests/aws-query/runtimeConfig.native.ts +++ b/protocol_tests/aws-query/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./QueryProtocolClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { QueryProtocolClientConfig } from "./QueryProtocolClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: QueryProtocolClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/protocol_tests/aws-query/runtimeConfig.shared.ts b/protocol_tests/aws-query/runtimeConfig.shared.ts index ee35519aea3f3..86ac2fe07c66c 100644 --- a/protocol_tests/aws-query/runtimeConfig.shared.ts +++ b/protocol_tests/aws-query/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { QueryProtocolClientConfig } from "./QueryProtocolClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: QueryProtocolClientConfig) => ({ apiVersion: "2020-01-08", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Query Protocol", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Query Protocol", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/protocol_tests/aws-query/runtimeConfig.ts b/protocol_tests/aws-query/runtimeConfig.ts index 48f47d1693c78..afda48d9f09ce 100644 --- a/protocol_tests/aws-query/runtimeConfig.ts +++ b/protocol_tests/aws-query/runtimeConfig.ts @@ -8,27 +8,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./QueryProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { QueryProtocolClientConfig } from "./QueryProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: QueryProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-restjson/RestJsonProtocolClient.ts b/protocol_tests/aws-restjson/RestJsonProtocolClient.ts index ccf4f584993e4..87748ea9089f3 100644 --- a/protocol_tests/aws-restjson/RestJsonProtocolClient.ts +++ b/protocol_tests/aws-restjson/RestJsonProtocolClient.ts @@ -118,7 +118,7 @@ import { TimestampFormatHeadersCommandInput, TimestampFormatHeadersCommandOutput, } from "./commands/TimestampFormatHeadersCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -398,10 +398,7 @@ export class RestJsonProtocolClient extends __Client< readonly config: RestJsonProtocolClientResolvedConfig; constructor(configuration: RestJsonProtocolClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/protocol_tests/aws-restjson/runtimeConfig.browser.ts b/protocol_tests/aws-restjson/runtimeConfig.browser.ts index a82733c44fbd7..7b8325c072a41 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.browser.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.browser.ts @@ -7,27 +7,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RestJsonProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-restjson/runtimeConfig.native.ts b/protocol_tests/aws-restjson/runtimeConfig.native.ts index 592bb8c091add..d1e3ffd93f4a3 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.native.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RestJsonProtocolClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/protocol_tests/aws-restjson/runtimeConfig.shared.ts b/protocol_tests/aws-restjson/runtimeConfig.shared.ts index 59da86dcb59b4..98d03051adb9e 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.shared.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => ({ apiVersion: "2019-12-16", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Rest Json Protocol", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Rest Json Protocol", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/protocol_tests/aws-restjson/runtimeConfig.ts b/protocol_tests/aws-restjson/runtimeConfig.ts index 102c4eb1fdcdf..b7c082d17f318 100644 --- a/protocol_tests/aws-restjson/runtimeConfig.ts +++ b/protocol_tests/aws-restjson/runtimeConfig.ts @@ -8,27 +8,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RestJsonProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RestJsonProtocolClientConfig } from "./RestJsonProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RestJsonProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-restxml/RestXmlProtocolClient.ts b/protocol_tests/aws-restxml/RestXmlProtocolClient.ts index 61fc864cd1d11..5d508afb4200c 100644 --- a/protocol_tests/aws-restxml/RestXmlProtocolClient.ts +++ b/protocol_tests/aws-restxml/RestXmlProtocolClient.ts @@ -135,7 +135,7 @@ import { XmlMapsXmlNameCommandInput, XmlMapsXmlNameCommandOutput } from "./comma import { XmlNamespacesCommandInput, XmlNamespacesCommandOutput } from "./commands/XmlNamespacesCommand"; import { XmlTimestampsCommandInput, XmlTimestampsCommandOutput } from "./commands/XmlTimestampsCommand"; import { XmlUnionsCommandInput, XmlUnionsCommandOutput } from "./commands/XmlUnionsCommand"; -import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; import { EndpointsInputConfig, EndpointsResolvedConfig, @@ -431,10 +431,7 @@ export class RestXmlProtocolClient extends __Client< readonly config: RestXmlProtocolClientResolvedConfig; constructor(configuration: RestXmlProtocolClientConfig) { - let _config_0 = { - ...__ClientDefaultValues, - ...configuration, - }; + let _config_0 = __getRuntimeConfig(configuration); let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveEndpointsConfig(_config_1); let _config_3 = resolveRetryConfig(_config_2); diff --git a/protocol_tests/aws-restxml/runtimeConfig.browser.ts b/protocol_tests/aws-restxml/runtimeConfig.browser.ts index 2f7de1ac26ad3..ba8197bcb5816 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.browser.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.browser.ts @@ -7,27 +7,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; -import { ClientDefaults } from "./RestXmlProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RestXmlProtocolClientConfig } from "./RestXmlProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "browser", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: DEFAULT_MAX_ATTEMPTS, - requestHandler: new FetchHttpHandler(), - retryModeProvider: () => Promise.resolve(DEFAULT_RETRY_MODE), - sha256: Sha256, - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RestXmlProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + requestHandler: config.requestHandler ?? new FetchHttpHandler(), + retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config.sha256 ?? Sha256, + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/protocol_tests/aws-restxml/runtimeConfig.native.ts b/protocol_tests/aws-restxml/runtimeConfig.native.ts index 331db5fe38a37..16990ad4fe8d1 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.native.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.native.ts @@ -1,12 +1,16 @@ import { Sha256 } from "@aws-crypto/sha256-js"; -import { ClientDefaults } from "./RestXmlProtocolClient"; -import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"; +import { RestXmlProtocolClientConfig } from "./RestXmlProtocolClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...BrowserDefaults, - runtime: "react-native", - sha256: Sha256, +export const getRuntimeConfig = (config: RestXmlProtocolClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config.sha256 ?? Sha256, + }; }; diff --git a/protocol_tests/aws-restxml/runtimeConfig.shared.ts b/protocol_tests/aws-restxml/runtimeConfig.shared.ts index 918b732586d8c..d3d1efaee5ac8 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.shared.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.shared.ts @@ -1,15 +1,16 @@ import { defaultRegionInfoProvider } from "./endpoints"; import { Logger as __Logger } from "@aws-sdk/types"; import { parseUrl } from "@aws-sdk/url-parser"; +import { RestXmlProtocolClientConfig } from "./RestXmlProtocolClient"; /** * @internal */ -export const ClientSharedValues = { +export const getRuntimeConfig = (config: RestXmlProtocolClientConfig) => ({ apiVersion: "2019-12-16", - disableHostPrefix: false, - logger: {} as __Logger, - regionInfoProvider: defaultRegionInfoProvider, - serviceId: "Rest Xml Protocol", - urlParser: parseUrl, -}; + disableHostPrefix: config.disableHostPrefix ?? false, + logger: config.logger ?? ({} as __Logger), + regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider, + serviceId: config.serviceId ?? "Rest Xml Protocol", + urlParser: config.urlParser ?? parseUrl, +}); diff --git a/protocol_tests/aws-restxml/runtimeConfig.ts b/protocol_tests/aws-restxml/runtimeConfig.ts index 01cef72f70c7a..38c5968134d1f 100644 --- a/protocol_tests/aws-restxml/runtimeConfig.ts +++ b/protocol_tests/aws-restxml/runtimeConfig.ts @@ -8,27 +8,30 @@ import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; -import { ClientDefaults } from "./RestXmlProtocolClient"; -import { ClientSharedValues } from "./runtimeConfig.shared"; +import { RestXmlProtocolClientConfig } from "./RestXmlProtocolClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; /** * @internal */ -export const ClientDefaultValues: Required = { - ...ClientSharedValues, - runtime: "node", - base64Decoder: fromBase64, - base64Encoder: toBase64, - bodyLengthChecker: calculateBodyLength, - defaultUserAgentProvider: defaultUserAgent({ - serviceId: ClientSharedValues.serviceId, - clientVersion: packageInfo.version, - }), - maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), - requestHandler: new NodeHttpHandler(), - retryModeProvider: loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), - sha256: Hash.bind(null, "sha256"), - streamCollector, - utf8Decoder: fromUtf8, - utf8Encoder: toUtf8, +export const getRuntimeConfig = (config: RestXmlProtocolClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config.base64Decoder ?? fromBase64, + base64Encoder: config.base64Encoder ?? toBase64, + bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config.defaultUserAgentProvider ?? + defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }), + maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + requestHandler: config.requestHandler ?? new NodeHttpHandler(), + retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config.streamCollector ?? streamCollector, + utf8Decoder: config.utf8Decoder ?? fromUtf8, + utf8Encoder: config.utf8Encoder ?? toUtf8, + }; }; diff --git a/scripts/generate-clients/copy-to-clients.js b/scripts/generate-clients/copy-to-clients.js index c47cafbfb4bd7..a2395af8e878f 100644 --- a/scripts/generate-clients/copy-to-clients.js +++ b/scripts/generate-clients/copy-to-clients.js @@ -3,8 +3,39 @@ const { normalize, join } = require("path"); const { copySync, removeSync } = require("fs-extra"); const { readdirSync, lstatSync, readFileSync, existsSync, writeFileSync } = require("fs"); -const getOverwritablePredicate = (packageName) => (pathName) => { - const overwritablePathnames = [ +// const getOverwritablePredicate = (packageName) => (pathName) => { +// const overwritablePathnames = [ +// "commands", +// "models", +// "protocols", +// "pagination", +// "tests", +// "waiters", +// "LICENCE", +// "runtimeConfig.ts", +// "runtimeConfig.browser.ts", +// "runtimeConfig.shared.ts", +// "runtimeConfig.native.ts", +// "index.ts", +// "endpoints.ts", +// "README.md", +// ]; +// const additionalGeneratedFiles = { +// "@aws-sdk/client-sts": ["defaultRoleAssumers.ts", "defaultStsRoleAssumers.ts", "defaultRoleAssumers.spec.ts"], +// }; +// return ( +// // pathName +// // .toLowerCase() +// // .startsWith( +// // packageName.toLowerCase().replace("@aws-sdk/client-", "").replace("@aws-sdk/aws-", "").replace(/-/g, "") +// // ) || +// pathName.endsWith("Client.ts") && +// overwritablePathnames.indexOf(pathName) >= 0 || +// additionalGeneratedFiles[packageName.toLowerCase()]?.indexOf(pathName) >= 0 +// ); +// }; +const getOverwritableDirectories = (subDirectories) => { + const overwritableDirectories = [ "commands", "models", "protocols", @@ -19,19 +50,17 @@ const getOverwritablePredicate = (packageName) => (pathName) => { "index.ts", "endpoints.ts", "README.md", + // @aws-sdk/client-sts special files + "defaultRoleAssumers.ts", + "defaultStsRoleAssumers.ts", + "defaultRoleAssumers.spec.ts", ]; - const additionalGeneratedFiles = { - "@aws-sdk/client-sts": ["defaultRoleAssumers.ts", "defaultStsRoleAssumers.ts", "defaultRoleAssumers.spec.ts"], - }; - return ( - pathName - .toLowerCase() - .startsWith( - packageName.toLowerCase().replace("@aws-sdk/client-", "").replace("@aws-sdk/aws-", "").replace(/-/g, "") - ) || - overwritablePathnames.indexOf(pathName) >= 0 || - additionalGeneratedFiles[packageName.toLowerCase()]?.indexOf(pathName) >= 0 - ); + return subDirectories.filter((subDirectory) => { + const isBareBoneClient = + subDirectory.endsWith("Client.ts") && subDirectories.includes(subDirectory.replace("Client.ts", ".ts")); + const isAggregateClient = subDirectories.includes(subDirectory.replace(".ts", "Client.ts")); + return isBareBoneClient || isAggregateClient || overwritableDirectories.indexOf(subDirectory) >= 0; + }); }; /** @@ -109,7 +138,6 @@ const copyToClients = async (sourceDir, destinationDir) => { console.log(`copying ${packageName} from ${artifactPath} to ${destinationDir}`); const destPath = join(destinationDir, clientName); - const overwritablePredicate = getOverwritablePredicate(packageName); // Code to move files/folders prefixed with `doc-client-` to `lib/lib-dynamodb` if (clientName === "client-dynamodb") { @@ -124,7 +152,9 @@ const copyToClients = async (sourceDir, destinationDir) => { } } - for (const packageSub of readdirSync(artifactPath)) { + const packageSubs = readdirSync(artifactPath); + const overWritableSubs = getOverwritableDirectories(packageSubs); + for (const packageSub of packageSubs) { const packageSubPath = join(artifactPath, packageSub); const destSubPath = join(destPath, packageSub); @@ -141,7 +171,7 @@ const copyToClients = async (sourceDir, destinationDir) => { }, }; writeFileSync(destSubPath, JSON.stringify(mergedManifest, null, 2).concat(`\n`)); - } else if (overwritablePredicate(packageSub) || !existsSync(destSubPath)) { + } else if (overWritableSubs.includes(packageSub) || !existsSync(destSubPath)) { if (lstatSync(packageSubPath).isDirectory()) removeSync(destSubPath); copySync(packageSubPath, destSubPath, { overwrite: true, @@ -168,9 +198,10 @@ const copyServerTests = async (sourceDir, destinationDir) => { console.log(`copying ${packageName} from ${artifactPath} to ${destinationDir}`); const destPath = join(destinationDir, testName); - const overwritablePredicate = getOverwritablePredicate(packageName); - for (const packageSub of readdirSync(artifactPath)) { + const packageSubs = readdirSync(artifactPath); + const overWritableSubs = getOverwritableDirectories(packageSubs); + for (const packageSub of packageSubs) { const packageSubPath = join(artifactPath, packageSub); const destSubPath = join(destPath, packageSub); @@ -187,7 +218,7 @@ const copyServerTests = async (sourceDir, destinationDir) => { }, }; writeFileSync(destSubPath, JSON.stringify(mergedManifest, null, 2).concat(`\n`)); - } else if (overwritablePredicate(packageSub) || !existsSync(destSubPath)) { + } else if (overWritableSubs.includes(packageSub) || !existsSync(destSubPath)) { if (lstatSync(packageSubPath).isDirectory()) removeSync(destSubPath); copySync(packageSubPath, destSubPath, { overwrite: true, diff --git a/scripts/generate-clients/index.js b/scripts/generate-clients/index.js index ef3fb695a166b..128df68ddaf9b 100644 --- a/scripts/generate-clients/index.js +++ b/scripts/generate-clients/index.js @@ -48,7 +48,7 @@ const { await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); await copyServerTests(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PROTOCOL_TESTS_CLIENTS_DIR); - emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); + // emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); emptyDirSync(TEMP_CODE_GEN_INPUT_DIR); rmdirSync(TEMP_CODE_GEN_INPUT_DIR);