Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backstage/config

Package Overview
Dependencies
Maintainers
4
Versions
327
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/config - npm Package Compare versions

Comparing version 0.0.0-nightly-20214622436 to 0.0.0-nightly-20217421937

8

CHANGELOG.md
# @backstage/config
## 0.0.0-nightly-20214622436
## 0.0.0-nightly-20217421937
### Patch Changes
- e9d3983ee: Add warning when trying to access configuration values that have been filtered out by visibility.
## 0.1.5
### Patch Changes
- d8b81fd28: Bump `json-schema` dependency from `0.2.5` to `0.3.0`.

@@ -8,0 +14,0 @@

@@ -54,4 +54,6 @@ 'use strict';

}
return configs.reduce((previousReader, {data, context}) => {
return new ConfigReader(data, context, previousReader);
return configs.reduce((previousReader, {data, context, filteredKeys}) => {
const reader = new ConfigReader(data, context, previousReader);
reader.filteredKeys = filteredKeys;
return reader;
}, void 0);

@@ -81,6 +83,14 @@ }

getOptional(key) {
var _a;
var _a, _b;
const value = this.readValue(key);
const fallbackValue = (_a = this.fallback) == null ? void 0 : _a.getOptional(key);
if (value === void 0) {
if (process.env.NODE_ENV === "development") {
if (fallbackValue === void 0 && key) {
const fullKey = this.fullKey(key);
if ((_b = this.filteredKeys) == null ? void 0 : _b.includes(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.`);
}
}
}
return fallbackValue;

@@ -103,5 +113,4 @@ } else if (fallbackValue === void 0) {

const fallbackConfig = (_a = this.fallback) == null ? void 0 : _a.getOptionalConfig(key);
const prefix = this.fullKey(key);
if (isObject(value)) {
return new ConfigReader(value, this.context, fallbackConfig, prefix);
return this.copy(value, key, fallbackConfig);
}

@@ -121,2 +130,3 @@ if (value !== void 0) {

getOptionalConfigArray(key) {
var _a;
const configs = this.readConfigValue(key, (values) => {

@@ -134,5 +144,11 @@ if (!Array.isArray(values)) {

if (!configs) {
if (process.env.NODE_ENV === "development") {
const fullKey = this.fullKey(key);
if ((_a = this.filteredKeys) == null ? void 0 : _a.some((k) => k.startsWith(fullKey))) {
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.`);
}
}
return void 0;
}
return configs.map((obj, index) => new ConfigReader(obj, this.context, void 0, this.fullKey(`${key}[${index}]`)));
return configs.map((obj, index) => this.copy(obj, `${key}[${index}]`));
}

@@ -200,7 +216,18 @@ getNumber(key) {

}
copy(data, key, fallback) {
const reader = new ConfigReader(data, this.context, fallback, this.fullKey(key));
reader.filteredKeys = this.filteredKeys;
return reader;
}
readConfigValue(key, validate) {
var _a;
var _a, _b;
const value = this.readValue(key);
if (value === void 0) {
return (_a = this.fallback) == null ? void 0 : _a.readConfigValue(key, validate);
if (process.env.NODE_ENV === "development") {
const fullKey = this.fullKey(key);
if ((_a = this.filteredKeys) == null ? void 0 : _a.includes(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.`);
}
}
return (_b = this.fallback) == null ? void 0 : _b.readConfigValue(key, validate);
}

@@ -207,0 +234,0 @@ const result = validate(value);

@@ -11,2 +11,3 @@ declare type JsonPrimitive = number | string | boolean | null;

data: JsonObject;
filteredKeys?: string[];
};

@@ -37,2 +38,10 @@ declare type Config = {

private readonly prefix;
/**
* A set of key paths that where removed from the config due to not being visible.
*
* This was added as a mutable private member to avoid changes to the public API.
* Its only purpose of this is to warn users of missing visibility when running
* the frontend in development mode.
*/
private filteredKeys?;
static fromConfigs(configs: AppConfig[]): ConfigReader;

@@ -57,2 +66,3 @@ constructor(data: JsonObject | undefined, context?: string, fallback?: ConfigReader | undefined, prefix?: string);

private fullKey;
private copy;
private readConfigValue;

@@ -59,0 +69,0 @@ private readValue;

@@ -45,4 +45,6 @@ import cloneDeep from 'lodash/cloneDeep';

}
return configs.reduce((previousReader, {data, context}) => {
return new ConfigReader(data, context, previousReader);
return configs.reduce((previousReader, {data, context, filteredKeys}) => {
const reader = new ConfigReader(data, context, previousReader);
reader.filteredKeys = filteredKeys;
return reader;
}, void 0);

@@ -72,6 +74,14 @@ }

getOptional(key) {
var _a;
var _a, _b;
const value = this.readValue(key);
const fallbackValue = (_a = this.fallback) == null ? void 0 : _a.getOptional(key);
if (value === void 0) {
if (process.env.NODE_ENV === "development") {
if (fallbackValue === void 0 && key) {
const fullKey = this.fullKey(key);
if ((_b = this.filteredKeys) == null ? void 0 : _b.includes(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.`);
}
}
}
return fallbackValue;

@@ -94,5 +104,4 @@ } else if (fallbackValue === void 0) {

const fallbackConfig = (_a = this.fallback) == null ? void 0 : _a.getOptionalConfig(key);
const prefix = this.fullKey(key);
if (isObject(value)) {
return new ConfigReader(value, this.context, fallbackConfig, prefix);
return this.copy(value, key, fallbackConfig);
}

@@ -112,2 +121,3 @@ if (value !== void 0) {

getOptionalConfigArray(key) {
var _a;
const configs = this.readConfigValue(key, (values) => {

@@ -125,5 +135,11 @@ if (!Array.isArray(values)) {

if (!configs) {
if (process.env.NODE_ENV === "development") {
const fullKey = this.fullKey(key);
if ((_a = this.filteredKeys) == null ? void 0 : _a.some((k) => k.startsWith(fullKey))) {
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.`);
}
}
return void 0;
}
return configs.map((obj, index) => new ConfigReader(obj, this.context, void 0, this.fullKey(`${key}[${index}]`)));
return configs.map((obj, index) => this.copy(obj, `${key}[${index}]`));
}

@@ -191,7 +207,18 @@ getNumber(key) {

}
copy(data, key, fallback) {
const reader = new ConfigReader(data, this.context, fallback, this.fullKey(key));
reader.filteredKeys = this.filteredKeys;
return reader;
}
readConfigValue(key, validate) {
var _a;
var _a, _b;
const value = this.readValue(key);
if (value === void 0) {
return (_a = this.fallback) == null ? void 0 : _a.readConfigValue(key, validate);
if (process.env.NODE_ENV === "development") {
const fullKey = this.fullKey(key);
if ((_a = this.filteredKeys) == null ? void 0 : _a.includes(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.`);
}
}
return (_b = this.fallback) == null ? void 0 : _b.readConfigValue(key, validate);
}

@@ -198,0 +225,0 @@ const result = validate(value);

2

package.json
{
"name": "@backstage/config",
"description": "Config API used by Backstage core, backend, and CLI",
"version": "0.0.0-nightly-20214622436",
"version": "0.0.0-nightly-20217421937",
"private": false,

@@ -6,0 +6,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc