Appearance
Feature flags builder
@investec/plugins-feature-flags-builder is a legacy compatibility layer that aggregates feature availability from gateway endpoints into a flat object of truthy feature codes.
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-feature-flags-builderThe platform owns installation of released plugin versions. A consuming team normally contributes shared logic in this repository and then asks the platform team to adopt the published version.
Public contract
The main package-root exports include:
getUserFeaturesWeb(authRes)getUserFeatures(authRes)- feature-related auth and response types
Integration pattern
ts
import { getUserFeaturesWeb } from '@investec/plugins-feature-flags-builder';
const featureFlags = await getUserFeaturesWeb(authResponse);The resolved object uses feature codes as keys:
ts
{
alwaysTrue: true,
SomeFeatureCode: true,
AnotherFeatureCode: true
}Runtime behaviour
getUserFeatures(...) always calls:
/edge/base/feature
and conditionally calls additional endpoints based on auth flags:
- ZA private-bank and wealth endpoints when
authRes.PrivateBankZAis true - UK private-bank endpoints when
authRes.PrivateBankUKis true
It combines the responses, ignores ExclusiveHide entries, and returns a flat feature object.
How consumers extend it
Consumers usually treat the returned flag map as one input into a broader application decision.
Use consumer code to:
- gate local UI with the returned feature map;
- combine legacy flags with feature-registry eligibility;
- decide how strictly a feature should be hidden in one application.
Change the package when a new upstream feature endpoint, merge rule, or shared normalisation step is needed.
Extension example: compose legacy flags with app-owned gating
ts
import { getUserFeaturesWeb } from '@investec/plugins-feature-flags-builder';
type LocalFeature = {
key: string;
requiredLegacyFlag?: string;
enabledByProduct: boolean;
};
export async function filterFeaturesForSurface(authResponse: any, features: LocalFeature[]): Promise<LocalFeature[]> {
const legacyFlags = await getUserFeaturesWeb(authResponse);
return features.filter((feature) => {
if (!feature.enabledByProduct) {
return false;
}
if (!feature.requiredLegacyFlag) {
return true;
}
return Boolean(legacyFlags[feature.requiredLegacyFlag]);
});
}Extend the shared plugin
Add an approved feature endpoint in feature-flags-builder/src/lib/user-features/user-features.ts, beside the existing auth-conditional calls. Update the auth and response types when the new endpoint introduces typed fields, and add tests for:
- the auth condition that includes the endpoint;
- successful feature-code merging;
ExclusiveHidebehaviour;- endpoint failure and fallback behaviour;
- consumers that do not meet the new condition.
This is a legacy compatibility package. Contact the Web Platform team before adding a new feature-governance model, changing the { alwaysTrue: true } fallback, or using this package instead of the feature registry for a new capability.
Consumer notes
getUserFeaturesWeb(...)wrapsgetUserFeatures(...)and returns a fallback{ alwaysTrue: true }if the underlying call chain rejects.- The returned flat shape is a legacy capability map, not a full feature-registry record.
- For new discoverability and entitlement work, prefer the Feature library package.