Appearance
Toggles builder
@investec/plugins-toggles-builder is the legacy kill-switch package for mapping returned toggle hashes to feature names and removing disabled features from a feature list.
Package
sh
npm install --save @investec/plugins-toggles-builderPublic contract
The package exports:
togglesMappergetToggles()mapToggles(toggleList)removeToggledFeatures(featureList)
Integration pattern
ts
import {
getToggles,
mapToggles,
removeToggledFeatures,
} from '@investec/plugins-toggles-builder';
const rawToggles = await getToggles();
const mappedToggles = mapToggles(rawToggles);
const visibleFeatures = removeToggledFeatures(featureList);Runtime behaviour
getToggles() posts to:
text
/edge/base/toggleswith:
json
{ "CategoryName": "IO.Core" }mapToggles(...) mutates the module-level togglesMapper array by setting matching entries to active: false.
removeToggledFeatures(...) then mutates the supplied feature list by removing feature entries whose feature.value.name matches a disabled toggle name.
How consumers extend it
Consumers generally extend this package by deciding where the mapped toggles should be applied:
- hide or disable UI locally from the returned toggle state;
- remove disabled features from one app-specific feature list;
- combine toggle results with feature-registry and flag-based gating.
Change the package when the shared toggle-to-feature mapping or fetch behaviour itself needs to change.
Extension example: remove disabled items from a page-specific feature list
ts
import {
getToggles,
mapToggles,
removeToggledFeatures,
type IFeatureApps,
} from '@investec/plugins-toggles-builder';
export async function filterVisibleFeatures(
featureList: IFeatureApps[]
): Promise<IFeatureApps[]> {
const rawToggleHashes = await getToggles();
mapToggles(rawToggleHashes);
const workingCopy = [...featureList];
return removeToggledFeatures(workingCopy);
}Consumer notes
- This is a legacy compatibility layer and should not be the first place to add new feature-governance logic.
- Both
mapToggles(...)andremoveToggledFeatures(...)mutate existing arrays. - The feature-name comparison uses
feature.value.name, not the feature key.