初始化环境文件
This commit is contained in:
50
node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js
generated
vendored
Normal file
50
node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
export const createConfigValueProvider = (configKey, canonicalEndpointParamKey, config, isClientContextParam = false) => {
|
||||
const configProvider = async () => {
|
||||
let configValue;
|
||||
if (isClientContextParam) {
|
||||
const clientContextParams = config.clientContextParams;
|
||||
const nestedValue = clientContextParams?.[configKey];
|
||||
configValue = nestedValue ?? config[configKey] ?? config[canonicalEndpointParamKey];
|
||||
}
|
||||
else {
|
||||
configValue = config[configKey] ?? config[canonicalEndpointParamKey];
|
||||
}
|
||||
if (typeof configValue === "function") {
|
||||
return configValue();
|
||||
}
|
||||
return configValue;
|
||||
};
|
||||
if (configKey === "credentialScope" || canonicalEndpointParamKey === "CredentialScope") {
|
||||
return async () => {
|
||||
const credentials = typeof config.credentials === "function" ? await config.credentials() : config.credentials;
|
||||
const configValue = credentials?.credentialScope ?? credentials?.CredentialScope;
|
||||
return configValue;
|
||||
};
|
||||
}
|
||||
if (configKey === "accountId" || canonicalEndpointParamKey === "AccountId") {
|
||||
return async () => {
|
||||
const credentials = typeof config.credentials === "function" ? await config.credentials() : config.credentials;
|
||||
const configValue = credentials?.accountId ?? credentials?.AccountId;
|
||||
return configValue;
|
||||
};
|
||||
}
|
||||
if (configKey === "endpoint" || canonicalEndpointParamKey === "endpoint") {
|
||||
return async () => {
|
||||
if (config.isCustomEndpoint === false) {
|
||||
return undefined;
|
||||
}
|
||||
const endpoint = await configProvider();
|
||||
if (endpoint && typeof endpoint === "object") {
|
||||
if ("url" in endpoint) {
|
||||
return endpoint.url.href;
|
||||
}
|
||||
if ("hostname" in endpoint) {
|
||||
const { protocol, hostname, port, path } = endpoint;
|
||||
return `${protocol}//${hostname}${port ? ":" + port : ""}${path}`;
|
||||
}
|
||||
}
|
||||
return endpoint;
|
||||
};
|
||||
}
|
||||
return configProvider;
|
||||
};
|
||||
Reference in New Issue
Block a user