Skip to content

Commit

Permalink
fix(clients): use optional chaining while processing runtime config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gosar authored Aug 23, 2021
1 parent c7350f8 commit 18469ce
Show file tree
Hide file tree
Showing 1,129 changed files with 10,173 additions and 10,173 deletions.
28 changes: 14 additions & 14 deletions clients/client-accessanalyzer/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shar
/**
* @internal
*/
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig = {}) => {
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,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config.region ?? invalidProvider("Region is missing"),
requestHandler: config.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config.sha256 ?? Sha256,
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: config?.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
4 changes: 2 additions & 2 deletions clients/client-accessanalyzer/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.bro
/**
* @internal
*/
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig = {}) => {
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => {
const browserDefaults = getBrowserRuntimeConfig(config);
return {
...browserDefaults,
...config,
runtime: "react-native",
sha256: config.sha256 ?? Sha256,
sha256: config?.sha256 ?? Sha256,
};
};
12 changes: 6 additions & 6 deletions clients/client-accessanalyzer/runtimeConfig.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { AccessAnalyzerClientConfig } from "./AccessAnalyzerClient";
/**
* @internal
*/
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig = {}) => ({
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => ({
apiVersion: "2019-11-01",
disableHostPrefix: config.disableHostPrefix ?? false,
logger: config.logger ?? ({} as __Logger),
regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config.serviceId ?? "AccessAnalyzer",
urlParser: config.urlParser ?? parseUrl,
disableHostPrefix: config?.disableHostPrefix ?? false,
logger: config?.logger ?? ({} as __Logger),
regionInfoProvider: config?.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config?.serviceId ?? "AccessAnalyzer",
urlParser: config?.urlParser ?? parseUrl,
});
28 changes: 14 additions & 14 deletions clients/client-accessanalyzer/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ import { emitWarningIfUnsupportedVersion } from "@aws-sdk/smithy-client";
/**
* @internal
*/
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig = {}) => {
export const getRuntimeConfig = (config: AccessAnalyzerClientConfig) => {
emitWarningIfUnsupportedVersion(process.version);
const clientSharedValues = getSharedRuntimeConfig(config);
return {
...clientSharedValues,
...config,
runtime: "node",
base64Decoder: config.base64Decoder ?? fromBase64,
base64Encoder: config.base64Encoder ?? toBase64,
bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
config?.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config?.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
28 changes: 14 additions & 14 deletions clients/client-acm-pca/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shar
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMPCAClientConfig = {}) => {
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,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config.region ?? invalidProvider("Region is missing"),
requestHandler: config.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config.sha256 ?? Sha256,
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: config?.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
4 changes: 2 additions & 2 deletions clients/client-acm-pca/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.bro
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMPCAClientConfig = {}) => {
export const getRuntimeConfig = (config: ACMPCAClientConfig) => {
const browserDefaults = getBrowserRuntimeConfig(config);
return {
...browserDefaults,
...config,
runtime: "react-native",
sha256: config.sha256 ?? Sha256,
sha256: config?.sha256 ?? Sha256,
};
};
12 changes: 6 additions & 6 deletions clients/client-acm-pca/runtimeConfig.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { ACMPCAClientConfig } from "./ACMPCAClient";
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMPCAClientConfig = {}) => ({
export const getRuntimeConfig = (config: ACMPCAClientConfig) => ({
apiVersion: "2017-08-22",
disableHostPrefix: config.disableHostPrefix ?? false,
logger: config.logger ?? ({} as __Logger),
regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config.serviceId ?? "ACM PCA",
urlParser: config.urlParser ?? parseUrl,
disableHostPrefix: config?.disableHostPrefix ?? false,
logger: config?.logger ?? ({} as __Logger),
regionInfoProvider: config?.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config?.serviceId ?? "ACM PCA",
urlParser: config?.urlParser ?? parseUrl,
});
28 changes: 14 additions & 14 deletions clients/client-acm-pca/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ import { emitWarningIfUnsupportedVersion } from "@aws-sdk/smithy-client";
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMPCAClientConfig = {}) => {
export const getRuntimeConfig = (config: ACMPCAClientConfig) => {
emitWarningIfUnsupportedVersion(process.version);
const clientSharedValues = getSharedRuntimeConfig(config);
return {
...clientSharedValues,
...config,
runtime: "node",
base64Decoder: config.base64Decoder ?? fromBase64,
base64Encoder: config.base64Encoder ?? toBase64,
bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
config?.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config?.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
28 changes: 14 additions & 14 deletions clients/client-acm/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shar
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMClientConfig = {}) => {
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,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
config?.credentialDefaultProvider ?? ((_: unknown) => () => Promise.reject(new Error("Credential is missing"))),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config.region ?? invalidProvider("Region is missing"),
requestHandler: config.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config.sha256 ?? Sha256,
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: config?.requestHandler ?? new FetchHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
4 changes: 2 additions & 2 deletions clients/client-acm/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.bro
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMClientConfig = {}) => {
export const getRuntimeConfig = (config: ACMClientConfig) => {
const browserDefaults = getBrowserRuntimeConfig(config);
return {
...browserDefaults,
...config,
runtime: "react-native",
sha256: config.sha256 ?? Sha256,
sha256: config?.sha256 ?? Sha256,
};
};
12 changes: 6 additions & 6 deletions clients/client-acm/runtimeConfig.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { ACMClientConfig } from "./ACMClient";
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMClientConfig = {}) => ({
export const getRuntimeConfig = (config: ACMClientConfig) => ({
apiVersion: "2015-12-08",
disableHostPrefix: config.disableHostPrefix ?? false,
logger: config.logger ?? ({} as __Logger),
regionInfoProvider: config.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config.serviceId ?? "ACM",
urlParser: config.urlParser ?? parseUrl,
disableHostPrefix: config?.disableHostPrefix ?? false,
logger: config?.logger ?? ({} as __Logger),
regionInfoProvider: config?.regionInfoProvider ?? defaultRegionInfoProvider,
serviceId: config?.serviceId ?? "ACM",
urlParser: config?.urlParser ?? parseUrl,
});
28 changes: 14 additions & 14 deletions clients/client-acm/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ import { emitWarningIfUnsupportedVersion } from "@aws-sdk/smithy-client";
/**
* @internal
*/
export const getRuntimeConfig = (config: ACMClientConfig = {}) => {
export const getRuntimeConfig = (config: ACMClientConfig) => {
emitWarningIfUnsupportedVersion(process.version);
const clientSharedValues = getSharedRuntimeConfig(config);
return {
...clientSharedValues,
...config,
runtime: "node",
base64Decoder: config.base64Decoder ?? fromBase64,
base64Encoder: config.base64Encoder ?? toBase64,
bodyLengthChecker: config.bodyLengthChecker ?? calculateBodyLength,
base64Decoder: config?.base64Decoder ?? fromBase64,
base64Encoder: config?.base64Encoder ?? toBase64,
bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
credentialDefaultProvider:
config.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
config?.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
defaultUserAgentProvider:
config.defaultUserAgentProvider ??
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
maxAttempts: config.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config.streamCollector ?? streamCollector,
utf8Decoder: config.utf8Decoder ?? fromUtf8,
utf8Encoder: config.utf8Encoder ?? toUtf8,
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config?.requestHandler ?? new NodeHttpHandler(),
retryModeProvider: config?.retryModeProvider ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS),
sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
streamCollector: config?.streamCollector ?? streamCollector,
utf8Decoder: config?.utf8Decoder ?? fromUtf8,
utf8Encoder: config?.utf8Encoder ?? toUtf8,
};
};
Loading

0 comments on commit 18469ce

Please sign in to comment.