@aws-sdk/node-config-provider
Advanced tools
Comparing version 3.178.0 to 3.183.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03) | ||
**Note:** Version bump only for package @aws-sdk/node-config-provider | ||
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23) | ||
@@ -8,0 +16,0 @@ |
@@ -5,6 +5,2 @@ import { chain, memoize } from "@aws-sdk/property-provider"; | ||
import { fromStatic } from "./fromStatic"; | ||
export var loadConfig = function (_a, configuration) { | ||
var environmentVariableSelector = _a.environmentVariableSelector, configFileSelector = _a.configFileSelector, defaultValue = _a.default; | ||
if (configuration === void 0) { configuration = {}; } | ||
return memoize(chain(fromEnv(environmentVariableSelector), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue))); | ||
}; | ||
export const loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => memoize(chain(fromEnv(environmentVariableSelector), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue))); |
@@ -1,20 +0,13 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { CredentialsProviderError } from "@aws-sdk/property-provider"; | ||
export var fromEnv = function (envVarSelector) { | ||
return function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var config; | ||
return __generator(this, function (_a) { | ||
try { | ||
config = envVarSelector(process.env); | ||
if (config === undefined) { | ||
throw new Error(); | ||
} | ||
return [2, config]; | ||
} | ||
catch (e) { | ||
throw new CredentialsProviderError(e.message || "Cannot load config from environment variables with getter: ".concat(envVarSelector)); | ||
} | ||
return [2]; | ||
}); | ||
}); }; | ||
export const fromEnv = (envVarSelector) => async () => { | ||
try { | ||
const config = envVarSelector(process.env); | ||
if (config === undefined) { | ||
throw new Error(); | ||
} | ||
return config; | ||
} | ||
catch (e) { | ||
throw new CredentialsProviderError(e.message || `Cannot load config from environment variables with getter: ${envVarSelector}`); | ||
} | ||
}; |
@@ -1,35 +0,22 @@ | ||
import { __assign, __awaiter, __generator, __rest } from "tslib"; | ||
import { CredentialsProviderError } from "@aws-sdk/property-provider"; | ||
import { getProfileName, loadSharedConfigFiles } from "@aws-sdk/shared-ini-file-loader"; | ||
export var fromSharedConfigFiles = function (configSelector, _a) { | ||
if (_a === void 0) { _a = {}; } | ||
var _b = _a.preferredFile, preferredFile = _b === void 0 ? "config" : _b, init = __rest(_a, ["preferredFile"]); | ||
return function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var profile, _a, configFile, credentialsFile, profileFromCredentials, profileFromConfig, mergedProfile, configValue; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
profile = getProfileName(init); | ||
return [4, loadSharedConfigFiles(init)]; | ||
case 1: | ||
_a = _b.sent(), configFile = _a.configFile, credentialsFile = _a.credentialsFile; | ||
profileFromCredentials = credentialsFile[profile] || {}; | ||
profileFromConfig = configFile[profile] || {}; | ||
mergedProfile = preferredFile === "config" | ||
? __assign(__assign({}, profileFromCredentials), profileFromConfig) : __assign(__assign({}, profileFromConfig), profileFromCredentials); | ||
try { | ||
configValue = configSelector(mergedProfile); | ||
if (configValue === undefined) { | ||
throw new Error(); | ||
} | ||
return [2, configValue]; | ||
} | ||
catch (e) { | ||
throw new CredentialsProviderError(e.message || | ||
"Cannot load config for profile ".concat(profile, " in SDK configuration files with getter: ").concat(configSelector)); | ||
} | ||
return [2]; | ||
} | ||
}); | ||
}); }; | ||
export const fromSharedConfigFiles = (configSelector, { preferredFile = "config", ...init } = {}) => async () => { | ||
const profile = getProfileName(init); | ||
const { configFile, credentialsFile } = await loadSharedConfigFiles(init); | ||
const profileFromCredentials = credentialsFile[profile] || {}; | ||
const profileFromConfig = configFile[profile] || {}; | ||
const mergedProfile = preferredFile === "config" | ||
? { ...profileFromCredentials, ...profileFromConfig } | ||
: { ...profileFromConfig, ...profileFromCredentials }; | ||
try { | ||
const configValue = configSelector(mergedProfile); | ||
if (configValue === undefined) { | ||
throw new Error(); | ||
} | ||
return configValue; | ||
} | ||
catch (e) { | ||
throw new CredentialsProviderError(e.message || | ||
`Cannot load config for profile ${profile} in SDK configuration files with getter: ${configSelector}`); | ||
} | ||
}; |
@@ -1,11 +0,3 @@ | ||
import { __awaiter, __generator } from "tslib"; | ||
import { fromStatic as convertToProvider } from "@aws-sdk/property-provider"; | ||
var isFunction = function (func) { return typeof func === "function"; }; | ||
export var fromStatic = function (defaultValue) { | ||
return isFunction(defaultValue) ? function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, defaultValue()]; | ||
case 1: return [2, _a.sent()]; | ||
} | ||
}); }); } : convertToProvider(defaultValue); | ||
}; | ||
const isFunction = (func) => typeof func === "function"; | ||
export const fromStatic = (defaultValue) => isFunction(defaultValue) ? async () => await defaultValue() : convertToProvider(defaultValue); |
{ | ||
"name": "@aws-sdk/node-config-provider", | ||
"version": "3.178.0", | ||
"version": "3.183.0", | ||
"description": "Load config default values from ini config files and environmental variable", | ||
@@ -25,5 +25,5 @@ "scripts": { | ||
"dependencies": { | ||
"@aws-sdk/property-provider": "3.178.0", | ||
"@aws-sdk/shared-ini-file-loader": "3.178.0", | ||
"@aws-sdk/types": "3.178.0", | ||
"@aws-sdk/property-provider": "3.183.0", | ||
"@aws-sdk/shared-ini-file-loader": "3.183.0", | ||
"@aws-sdk/types": "3.183.0", | ||
"tslib": "^2.3.1" | ||
@@ -30,0 +30,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38731
198
+ Added@aws-sdk/property-provider@3.183.0(transitive)
+ Added@aws-sdk/shared-ini-file-loader@3.183.0(transitive)
+ Added@aws-sdk/types@3.183.0(transitive)
- Removed@aws-sdk/property-provider@3.178.0(transitive)
- Removed@aws-sdk/shared-ini-file-loader@3.178.0(transitive)
- Removed@aws-sdk/types@3.178.0(transitive)
Updated@aws-sdk/types@3.183.0