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
sh
npm install --save @investec/plugins-feature-flags-builderPublic contract
The package exports:
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]);
});
}Consumer notes
getUserFeaturesWeb(...)wrapsgetUserFeatures(...)and returns a fallback{ alwaysTrue: true }if the underlying call chain rejects.- The returned shape is intentionally simple and is best treated as a legacy capability map, not a full feature-registry record.
- For new discoverability and entitlement work, prefer the Feature library package.