@backstage/config
Advanced tools
Comparing version 0.1.11 to 0.1.12
# @backstage/config | ||
## 0.1.12 | ||
### Patch Changes | ||
- f5343e7c1a: The `ConfigReader#get` method now always returns a deep clone of the configuration data. | ||
## 0.1.11 | ||
@@ -4,0 +10,0 @@ |
@@ -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.1.11", | ||
"version": "0.1.12", | ||
"private": false, | ||
@@ -37,3 +37,3 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@backstage/test-utils": "^0.1.20", | ||
"@backstage/test-utils": "^0.2.2", | ||
"@types/jest": "^26.0.7", | ||
@@ -45,4 +45,4 @@ "@types/node": "^14.14.32" | ||
], | ||
"gitHead": "3db0cb3683d3000666802af90a465ba4fb0d1e8d", | ||
"gitHead": "da66c61bdd63cdb3f0f0cd2e26dc9e6454d93c7b", | ||
"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
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
76850