Appearance
Toggles builder
@investec/plugins-toggles-builder is the legacy feature-disable package for mapping returned toggle hashes to feature names and removing disabled features from a feature list.
Package
Warning: This is a legacy package, but the same platform-only default applies as for every other plugin: it must be installed only by the platform team into the Investec Online shell application. Do not add it as a direct dependency of a new feature application. Consumers should use this plugin's behaviour through the Invsy SDK, or contribute a bounded, governed change to this plugin's own source (see Plugin change governance).
sh
npm install --save @investec/plugins-toggles-builderThe platform owns installation of released plugin versions. A consuming team normally contributes shared legacy-toggle mappings in this repository and then asks the platform team to adopt the published version.
Public contract
The main package-root exports include:
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);
}Extend the shared plugin
Add an approved legacy mapping to togglesMapper with the feature name and toggle hash supplied by the toggle owner. Add tests that prove:
- the returned hash disables the intended mapping;
- unrelated mappings remain active;
- the expected feature name is removed;
- the input mutation is understood by the caller.
Change getToggles() only when the approved category, endpoint, request, or response contract changes. Contact the Web Platform team before adding new feature-governance behaviour, changing the global category, or replacing this legacy package with a new toggle model.
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.