@backstage/config
Advanced tools
Comparing version 1.0.1 to 1.0.2-next.0
# @backstage/config | ||
## 1.0.2-next.0 | ||
### Patch Changes | ||
- 7d47def9c4: Removed dependency on `@types/jest`. | ||
## 1.0.1 | ||
@@ -4,0 +10,0 @@ |
@@ -55,12 +55,17 @@ 'use strict'; | ||
} | ||
return configs.reduce((previousReader, { data, context, filteredKeys, deprecatedKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
reader.filteredKeys = filteredKeys; | ||
if (deprecatedKeys) { | ||
for (const { key, description } of deprecatedKeys) { | ||
console.warn(`The configuration key '${key}' of ${context} is deprecated and may be removed soon. ${description || ""}`); | ||
return configs.reduce( | ||
(previousReader, { data, context, filteredKeys, deprecatedKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
reader.filteredKeys = filteredKeys; | ||
if (deprecatedKeys) { | ||
for (const { key, description } of deprecatedKeys) { | ||
console.warn( | ||
`The configuration key '${key}' of ${context} is deprecated and may be removed soon. ${description || ""}` | ||
); | ||
} | ||
} | ||
} | ||
return reader; | ||
}, void 0); | ||
return reader; | ||
}, | ||
void 0 | ||
); | ||
} | ||
@@ -98,3 +103,5 @@ has(key) { | ||
this.notifiedFilteredKeys.add(fullKey); | ||
console.warn(`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -107,3 +114,8 @@ } | ||
} | ||
return mergeWith__default["default"]({}, { value: fallbackValue }, { value }, (into, from) => !isObject(from) || !isObject(into) ? from : void 0).value; | ||
return mergeWith__default["default"]( | ||
{}, | ||
{ value: fallbackValue }, | ||
{ value }, | ||
(into, from) => !isObject(from) || !isObject(into) ? from : void 0 | ||
).value; | ||
} | ||
@@ -125,3 +137,5 @@ getConfig(key) { | ||
if (value !== void 0) { | ||
throw new TypeError(errors.type(this.fullKey(key), this.context, typeOf(value), "object")); | ||
throw new TypeError( | ||
errors.type(this.fullKey(key), this.context, typeOf(value), "object") | ||
); | ||
} | ||
@@ -155,3 +169,5 @@ return fallbackConfig; | ||
this.notifiedFilteredKeys.add(key); | ||
console.warn(`Failed to read configuration array at '${key}' as it does not have any visible elements. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration array at '${key}' as it does not have any visible elements. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -171,3 +187,6 @@ } | ||
getOptionalNumber(key) { | ||
const value = this.readConfigValue(key, (val) => typeof val === "number" || typeof val === "string" || { expected: "number" }); | ||
const value = this.readConfigValue( | ||
key, | ||
(val) => typeof val === "number" || typeof val === "string" || { expected: "number" } | ||
); | ||
if (typeof value === "number" || value === void 0) { | ||
@@ -178,3 +197,5 @@ return value; | ||
if (!Number.isFinite(number)) { | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "number")); | ||
throw new Error( | ||
errors.convert(this.fullKey(key), this.context, "number") | ||
); | ||
} | ||
@@ -191,3 +212,6 @@ return number; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || { expected: "boolean" }); | ||
return this.readConfigValue( | ||
key, | ||
(value) => typeof value === "boolean" || { expected: "boolean" } | ||
); | ||
} | ||
@@ -202,3 +226,6 @@ getString(key) { | ||
getOptionalString(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "string" && value !== "" || { expected: "string" }); | ||
return this.readConfigValue( | ||
key, | ||
(value) => typeof value === "string" && value !== "" || { expected: "string" } | ||
); | ||
} | ||
@@ -229,3 +256,8 @@ getStringArray(key) { | ||
copy(data, key, fallback) { | ||
const reader = new ConfigReader(data, this.context, fallback, this.fullKey(key)); | ||
const reader = new ConfigReader( | ||
data, | ||
this.context, | ||
fallback, | ||
this.fullKey(key) | ||
); | ||
reader.filteredKeys = this.filteredKeys; | ||
@@ -242,3 +274,5 @@ return reader; | ||
this.notifiedFilteredKeys.add(fullKey); | ||
console.warn(`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -251,3 +285,10 @@ } | ||
const { key: keyName = key, value: theValue = value, expected } = result; | ||
throw new TypeError(errors.type(this.fullKey(keyName), this.context, typeOf(theValue), expected)); | ||
throw new TypeError( | ||
errors.type( | ||
this.fullKey(keyName), | ||
this.context, | ||
typeOf(theValue), | ||
expected | ||
) | ||
); | ||
} | ||
@@ -272,3 +313,5 @@ return value; | ||
const badKey = this.fullKey(parts.slice(0, index).join(".")); | ||
throw new TypeError(errors.type(badKey, this.context, typeOf(value), "object")); | ||
throw new TypeError( | ||
errors.type(badKey, this.context, typeOf(value), "object") | ||
); | ||
} | ||
@@ -275,0 +318,0 @@ } |
@@ -46,12 +46,17 @@ import cloneDeep from 'lodash/cloneDeep'; | ||
} | ||
return configs.reduce((previousReader, { data, context, filteredKeys, deprecatedKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
reader.filteredKeys = filteredKeys; | ||
if (deprecatedKeys) { | ||
for (const { key, description } of deprecatedKeys) { | ||
console.warn(`The configuration key '${key}' of ${context} is deprecated and may be removed soon. ${description || ""}`); | ||
return configs.reduce( | ||
(previousReader, { data, context, filteredKeys, deprecatedKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
reader.filteredKeys = filteredKeys; | ||
if (deprecatedKeys) { | ||
for (const { key, description } of deprecatedKeys) { | ||
console.warn( | ||
`The configuration key '${key}' of ${context} is deprecated and may be removed soon. ${description || ""}` | ||
); | ||
} | ||
} | ||
} | ||
return reader; | ||
}, void 0); | ||
return reader; | ||
}, | ||
void 0 | ||
); | ||
} | ||
@@ -89,3 +94,5 @@ has(key) { | ||
this.notifiedFilteredKeys.add(fullKey); | ||
console.warn(`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -98,3 +105,8 @@ } | ||
} | ||
return mergeWith({}, { value: fallbackValue }, { value }, (into, from) => !isObject(from) || !isObject(into) ? from : void 0).value; | ||
return mergeWith( | ||
{}, | ||
{ value: fallbackValue }, | ||
{ value }, | ||
(into, from) => !isObject(from) || !isObject(into) ? from : void 0 | ||
).value; | ||
} | ||
@@ -116,3 +128,5 @@ getConfig(key) { | ||
if (value !== void 0) { | ||
throw new TypeError(errors.type(this.fullKey(key), this.context, typeOf(value), "object")); | ||
throw new TypeError( | ||
errors.type(this.fullKey(key), this.context, typeOf(value), "object") | ||
); | ||
} | ||
@@ -146,3 +160,5 @@ return fallbackConfig; | ||
this.notifiedFilteredKeys.add(key); | ||
console.warn(`Failed to read configuration array at '${key}' as it does not have any visible elements. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration array at '${key}' as it does not have any visible elements. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -162,3 +178,6 @@ } | ||
getOptionalNumber(key) { | ||
const value = this.readConfigValue(key, (val) => typeof val === "number" || typeof val === "string" || { expected: "number" }); | ||
const value = this.readConfigValue( | ||
key, | ||
(val) => typeof val === "number" || typeof val === "string" || { expected: "number" } | ||
); | ||
if (typeof value === "number" || value === void 0) { | ||
@@ -169,3 +188,5 @@ return value; | ||
if (!Number.isFinite(number)) { | ||
throw new Error(errors.convert(this.fullKey(key), this.context, "number")); | ||
throw new Error( | ||
errors.convert(this.fullKey(key), this.context, "number") | ||
); | ||
} | ||
@@ -182,3 +203,6 @@ return number; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || { expected: "boolean" }); | ||
return this.readConfigValue( | ||
key, | ||
(value) => typeof value === "boolean" || { expected: "boolean" } | ||
); | ||
} | ||
@@ -193,3 +217,6 @@ getString(key) { | ||
getOptionalString(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "string" && value !== "" || { expected: "string" }); | ||
return this.readConfigValue( | ||
key, | ||
(value) => typeof value === "string" && value !== "" || { expected: "string" } | ||
); | ||
} | ||
@@ -220,3 +247,8 @@ getStringArray(key) { | ||
copy(data, key, fallback) { | ||
const reader = new ConfigReader(data, this.context, fallback, this.fullKey(key)); | ||
const reader = new ConfigReader( | ||
data, | ||
this.context, | ||
fallback, | ||
this.fullKey(key) | ||
); | ||
reader.filteredKeys = this.filteredKeys; | ||
@@ -233,3 +265,5 @@ return reader; | ||
this.notifiedFilteredKeys.add(fullKey); | ||
console.warn(`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.`); | ||
console.warn( | ||
`Failed to read configuration value at '${fullKey}' as it is not visible. See https://backstage.io/docs/conf/defining#visibility for instructions on how to make it visible.` | ||
); | ||
} | ||
@@ -242,3 +276,10 @@ } | ||
const { key: keyName = key, value: theValue = value, expected } = result; | ||
throw new TypeError(errors.type(this.fullKey(keyName), this.context, typeOf(theValue), expected)); | ||
throw new TypeError( | ||
errors.type( | ||
this.fullKey(keyName), | ||
this.context, | ||
typeOf(theValue), | ||
expected | ||
) | ||
); | ||
} | ||
@@ -263,3 +304,5 @@ return value; | ||
const badKey = this.fullKey(parts.slice(0, index).join(".")); | ||
throw new TypeError(errors.type(badKey, this.context, typeOf(value), "object")); | ||
throw new TypeError( | ||
errors.type(badKey, this.context, typeOf(value), "object") | ||
); | ||
} | ||
@@ -266,0 +309,0 @@ } |
{ | ||
"name": "@backstage/config", | ||
"description": "Config API used by Backstage core, backend, and CLI", | ||
"version": "1.0.1", | ||
"private": false, | ||
"version": "1.0.2-next.0", | ||
"publishConfig": { | ||
@@ -40,4 +39,4 @@ "access": "public", | ||
"devDependencies": { | ||
"@backstage/test-utils": "^1.1.0", | ||
"@types/jest": "^26.0.7", | ||
"@backstage/cli": "^0.19.0-next.3", | ||
"@backstage/test-utils": "^1.2.0-next.3", | ||
"@types/node": "^16.0.0" | ||
@@ -48,4 +47,4 @@ }, | ||
], | ||
"gitHead": "96323f280ba32ee526c5b151cda42260aee927c9", | ||
"gitHead": "2f458448f850dc68a711e2f31d14a91f96cf175d", | ||
"module": "dist/index.esm.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
94177
815
1