@backstage/config
Advanced tools
Comparing version 0.0.0-nightly-202192822050 to 0.0.0-nightly-20220923026
# @backstage/config | ||
## 0.0.0-nightly-202192822050 | ||
## 0.0.0-nightly-20220923026 | ||
### Patch Changes | ||
- f5343e7c1a: The `ConfigReader#get` method now always returns a deep clone of the configuration data. | ||
- Updated dependencies | ||
- @backstage/types@0.0.0-nightly-20220923026 | ||
## 0.1.11 | ||
### Patch Changes | ||
- 10d267a1b7: Minor exports cleanup | ||
@@ -8,0 +16,0 @@ - 41c49884d2: Start using the new `@backstage/types` package. Initially, this means using the `Observable` and `Json*` types from there. The types also remain in their old places but deprecated, and will be removed in a future release. |
@@ -49,3 +49,3 @@ 'use strict'; | ||
this.prefix = prefix; | ||
this.notifiedFilteredKeys = new Set(); | ||
this.notifiedFilteredKeys = /* @__PURE__ */ new Set(); | ||
} | ||
@@ -56,3 +56,3 @@ static fromConfigs(configs) { | ||
} | ||
return configs.reduce((previousReader, {data, context, filteredKeys}) => { | ||
return configs.reduce((previousReader, { data, context, filteredKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
@@ -75,3 +75,3 @@ reader.filteredKeys = filteredKeys; | ||
const fallbackKeys = (_b = (_a = this.fallback) == null ? void 0 : _a.keys()) != null ? _b : []; | ||
return [...new Set([...localKeys, ...fallbackKeys])]; | ||
return [.../* @__PURE__ */ new Set([...localKeys, ...fallbackKeys])]; | ||
} | ||
@@ -87,3 +87,3 @@ get(key) { | ||
var _a, _b; | ||
const value = this.readValue(key); | ||
const value = cloneDeep__default["default"](this.readValue(key)); | ||
const fallbackValue = (_a = this.fallback) == null ? void 0 : _a.getOptional(key); | ||
@@ -104,3 +104,3 @@ if (value === void 0) { | ||
} | ||
return mergeWith__default['default']({}, {value: cloneDeep__default['default'](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; | ||
} | ||
@@ -137,7 +137,7 @@ getConfig(key) { | ||
if (!Array.isArray(values)) { | ||
return {expected: "object-array"}; | ||
return { expected: "object-array" }; | ||
} | ||
for (const [index, value] of values.entries()) { | ||
if (!isObject(value)) { | ||
return {expected: "object-array", value, key: `${key}[${index}]`}; | ||
return { expected: "object-array", value, key: `${key}[${index}]` }; | ||
} | ||
@@ -167,3 +167,3 @@ } | ||
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) { | ||
@@ -186,3 +186,3 @@ return value; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || {expected: "boolean"}); | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || { expected: "boolean" }); | ||
} | ||
@@ -197,3 +197,3 @@ 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" }); | ||
} | ||
@@ -210,7 +210,7 @@ getStringArray(key) { | ||
if (!Array.isArray(values)) { | ||
return {expected: "string-array"}; | ||
return { expected: "string-array" }; | ||
} | ||
for (const [index, value] of values.entries()) { | ||
if (typeof value !== "string" || value === "") { | ||
return {expected: "string-array", value, key: `${key}[${index}]`}; | ||
return { expected: "string-array", value, key: `${key}[${index}]` }; | ||
} | ||
@@ -244,3 +244,3 @@ } | ||
if (result !== true) { | ||
const {key: keyName = key, value: theValue = value, expected} = result; | ||
const { key: keyName = key, value: theValue = value, expected } = result; | ||
throw new TypeError(errors.type(this.fullKey(keyName), this.context, typeOf(theValue), expected)); | ||
@@ -247,0 +247,0 @@ } |
@@ -40,3 +40,3 @@ import cloneDeep from 'lodash/cloneDeep'; | ||
this.prefix = prefix; | ||
this.notifiedFilteredKeys = new Set(); | ||
this.notifiedFilteredKeys = /* @__PURE__ */ new Set(); | ||
} | ||
@@ -47,3 +47,3 @@ static fromConfigs(configs) { | ||
} | ||
return configs.reduce((previousReader, {data, context, filteredKeys}) => { | ||
return configs.reduce((previousReader, { data, context, filteredKeys }) => { | ||
const reader = new ConfigReader(data, context, previousReader); | ||
@@ -66,3 +66,3 @@ reader.filteredKeys = filteredKeys; | ||
const fallbackKeys = (_b = (_a = this.fallback) == null ? void 0 : _a.keys()) != null ? _b : []; | ||
return [...new Set([...localKeys, ...fallbackKeys])]; | ||
return [.../* @__PURE__ */ new Set([...localKeys, ...fallbackKeys])]; | ||
} | ||
@@ -78,3 +78,3 @@ get(key) { | ||
var _a, _b; | ||
const value = this.readValue(key); | ||
const value = cloneDeep(this.readValue(key)); | ||
const fallbackValue = (_a = this.fallback) == null ? void 0 : _a.getOptional(key); | ||
@@ -95,3 +95,3 @@ if (value === void 0) { | ||
} | ||
return mergeWith({}, {value: cloneDeep(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; | ||
} | ||
@@ -128,7 +128,7 @@ getConfig(key) { | ||
if (!Array.isArray(values)) { | ||
return {expected: "object-array"}; | ||
return { expected: "object-array" }; | ||
} | ||
for (const [index, value] of values.entries()) { | ||
if (!isObject(value)) { | ||
return {expected: "object-array", value, key: `${key}[${index}]`}; | ||
return { expected: "object-array", value, key: `${key}[${index}]` }; | ||
} | ||
@@ -158,3 +158,3 @@ } | ||
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) { | ||
@@ -177,3 +177,3 @@ return value; | ||
getOptionalBoolean(key) { | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || {expected: "boolean"}); | ||
return this.readConfigValue(key, (value) => typeof value === "boolean" || { expected: "boolean" }); | ||
} | ||
@@ -188,3 +188,3 @@ 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" }); | ||
} | ||
@@ -201,7 +201,7 @@ getStringArray(key) { | ||
if (!Array.isArray(values)) { | ||
return {expected: "string-array"}; | ||
return { expected: "string-array" }; | ||
} | ||
for (const [index, value] of values.entries()) { | ||
if (typeof value !== "string" || value === "") { | ||
return {expected: "string-array", value, key: `${key}[${index}]`}; | ||
return { expected: "string-array", value, key: `${key}[${index}]` }; | ||
} | ||
@@ -235,3 +235,3 @@ } | ||
if (result !== true) { | ||
const {key: keyName = key, value: theValue = value, expected} = result; | ||
const { key: keyName = key, value: theValue = value, expected } = result; | ||
throw new TypeError(errors.type(this.fullKey(keyName), this.context, typeOf(theValue), expected)); | ||
@@ -238,0 +238,0 @@ } |
{ | ||
"name": "@backstage/config", | ||
"description": "Config API used by Backstage core, backend, and CLI", | ||
"version": "0.0.0-nightly-202192822050", | ||
"version": "0.0.0-nightly-20220923026", | ||
"private": false, | ||
@@ -33,7 +33,7 @@ "publishConfig": { | ||
"dependencies": { | ||
"@backstage/types": "^0.1.1", | ||
"@backstage/types": "^0.0.0-nightly-20220923026", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@backstage/test-utils": "^0.0.0-nightly-202192822050", | ||
"@backstage/test-utils": "^0.0.0-nightly-20220923026", | ||
"@types/jest": "^26.0.7", | ||
@@ -40,0 +40,0 @@ "@types/node": "^14.14.32" |
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
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
66097
+ Added@backstage/types@0.0.0-nightly-20241119023621(transitive)
- Removed@backstage/types@0.1.3(transitive)