@backstage/config-loader
Advanced tools
Comparing version 0.6.5 to 0.6.6
# @backstage/config-loader | ||
## 0.6.6 | ||
### Patch Changes | ||
- e9d3983ee: Add option to populate the `filteredKeys` property when processing configuration with a schema. | ||
- Updated dependencies | ||
- @backstage/config@0.1.6 | ||
## 0.6.5 | ||
@@ -4,0 +12,0 @@ |
@@ -405,7 +405,8 @@ 'use strict'; | ||
function filterByVisibility(data, includeVisibilities, visibilityByPath, transformFunc) { | ||
function filterByVisibility(data, includeVisibilities, visibilityByPath, transformFunc, withFilteredKeys) { | ||
var _a; | ||
function transform(jsonVal, path) { | ||
const filteredKeys = new Array(); | ||
function transform(jsonVal, visibilityPath, filterPath) { | ||
var _a2; | ||
const visibility = (_a2 = visibilityByPath.get(path)) != null ? _a2 : DEFAULT_CONFIG_VISIBILITY; | ||
const visibility = (_a2 = visibilityByPath.get(visibilityPath)) != null ? _a2 : DEFAULT_CONFIG_VISIBILITY; | ||
const isVisible = includeVisibilities.includes(visibility); | ||
@@ -419,2 +420,5 @@ if (typeof jsonVal !== "object") { | ||
} | ||
if (withFilteredKeys) { | ||
filteredKeys.push(filterPath); | ||
} | ||
return void 0; | ||
@@ -426,3 +430,3 @@ } else if (jsonVal === null) { | ||
for (const [index, value] of jsonVal.entries()) { | ||
const out = transform(value, `${path}/${index}`); | ||
const out = transform(value, `${visibilityPath}/${index}`, `${filterPath}[${index}]`); | ||
if (out !== void 0) { | ||
@@ -443,3 +447,3 @@ arr.push(out); | ||
} | ||
const out = transform(value, `${path}/${key}`); | ||
const out = transform(value, `${visibilityPath}/${key}`, filterPath ? `${filterPath}.${key}` : key); | ||
if (out !== void 0) { | ||
@@ -455,3 +459,6 @@ outObj[key] = out; | ||
} | ||
return (_a = transform(data, "")) != null ? _a : {}; | ||
return { | ||
filteredKeys: withFilteredKeys ? filteredKeys : void 0, | ||
data: (_a = transform(data, "", "")) != null ? _a : {} | ||
}; | ||
} | ||
@@ -472,3 +479,3 @@ | ||
return { | ||
process(configs, {visibility, valueTransform} = {}) { | ||
process(configs, {visibility, valueTransform, withFilteredKeys} = {}) { | ||
const result = validate(configs); | ||
@@ -484,3 +491,3 @@ if (result.errors) { | ||
context, | ||
data: filterByVisibility(data, visibility, result.visibilityByPath, valueTransform) | ||
...filterByVisibility(data, visibility, result.visibilityByPath, valueTransform, withFilteredKeys) | ||
})); | ||
@@ -490,3 +497,3 @@ } else if (valueTransform) { | ||
context, | ||
data: filterByVisibility(data, Array.from(CONFIG_VISIBILITIES), result.visibilityByPath, valueTransform) | ||
...filterByVisibility(data, Array.from(CONFIG_VISIBILITIES), result.visibilityByPath, valueTransform, withFilteredKeys) | ||
})); | ||
@@ -493,0 +500,0 @@ } |
@@ -58,2 +58,8 @@ import { AppConfig, JsonObject } from '@backstage/config'; | ||
valueTransform?: TransformFunc<any>; | ||
/** | ||
* Whether or not to include the `filteredKeys` property in the output `AppConfig`s. | ||
* | ||
* Default: `false`. | ||
*/ | ||
withFilteredKeys?: boolean; | ||
}; | ||
@@ -60,0 +66,0 @@ /** |
@@ -394,7 +394,8 @@ import yaml from 'yaml'; | ||
function filterByVisibility(data, includeVisibilities, visibilityByPath, transformFunc) { | ||
function filterByVisibility(data, includeVisibilities, visibilityByPath, transformFunc, withFilteredKeys) { | ||
var _a; | ||
function transform(jsonVal, path) { | ||
const filteredKeys = new Array(); | ||
function transform(jsonVal, visibilityPath, filterPath) { | ||
var _a2; | ||
const visibility = (_a2 = visibilityByPath.get(path)) != null ? _a2 : DEFAULT_CONFIG_VISIBILITY; | ||
const visibility = (_a2 = visibilityByPath.get(visibilityPath)) != null ? _a2 : DEFAULT_CONFIG_VISIBILITY; | ||
const isVisible = includeVisibilities.includes(visibility); | ||
@@ -408,2 +409,5 @@ if (typeof jsonVal !== "object") { | ||
} | ||
if (withFilteredKeys) { | ||
filteredKeys.push(filterPath); | ||
} | ||
return void 0; | ||
@@ -415,3 +419,3 @@ } else if (jsonVal === null) { | ||
for (const [index, value] of jsonVal.entries()) { | ||
const out = transform(value, `${path}/${index}`); | ||
const out = transform(value, `${visibilityPath}/${index}`, `${filterPath}[${index}]`); | ||
if (out !== void 0) { | ||
@@ -432,3 +436,3 @@ arr.push(out); | ||
} | ||
const out = transform(value, `${path}/${key}`); | ||
const out = transform(value, `${visibilityPath}/${key}`, filterPath ? `${filterPath}.${key}` : key); | ||
if (out !== void 0) { | ||
@@ -444,3 +448,6 @@ outObj[key] = out; | ||
} | ||
return (_a = transform(data, "")) != null ? _a : {}; | ||
return { | ||
filteredKeys: withFilteredKeys ? filteredKeys : void 0, | ||
data: (_a = transform(data, "", "")) != null ? _a : {} | ||
}; | ||
} | ||
@@ -461,3 +468,3 @@ | ||
return { | ||
process(configs, {visibility, valueTransform} = {}) { | ||
process(configs, {visibility, valueTransform, withFilteredKeys} = {}) { | ||
const result = validate(configs); | ||
@@ -473,3 +480,3 @@ if (result.errors) { | ||
context, | ||
data: filterByVisibility(data, visibility, result.visibilityByPath, valueTransform) | ||
...filterByVisibility(data, visibility, result.visibilityByPath, valueTransform, withFilteredKeys) | ||
})); | ||
@@ -479,3 +486,3 @@ } else if (valueTransform) { | ||
context, | ||
data: filterByVisibility(data, Array.from(CONFIG_VISIBILITIES), result.visibilityByPath, valueTransform) | ||
...filterByVisibility(data, Array.from(CONFIG_VISIBILITIES), result.visibilityByPath, valueTransform, withFilteredKeys) | ||
})); | ||
@@ -482,0 +489,0 @@ } |
{ | ||
"name": "@backstage/config-loader", | ||
"description": "Config loading functionality used by Backstage backend, and CLI", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"private": false, | ||
@@ -34,3 +34,3 @@ "publishConfig": { | ||
"@backstage/cli-common": "^0.1.1", | ||
"@backstage/config": "^0.1.5", | ||
"@backstage/config": "^0.1.6", | ||
"@types/json-schema": "^7.0.6", | ||
@@ -56,4 +56,4 @@ "ajv": "^7.0.3", | ||
], | ||
"gitHead": "ffae1bb6e47ca75858b142ec2721ecc61fe8e083", | ||
"gitHead": "0cbbc971f3894862bf5a248603b5b997f8052da1", | ||
"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
151201
1138
+ Addedmath-intrinsics@1.1.0(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
Updated@backstage/config@^0.1.6