Appearance
Client type router
@investec/plugins-client-type-router is a configuration-driven router for shell state. It accepts a URL, the current platform interaction state, and the current client type, then returns the client type and chrome settings that should apply to that route.
Package
sh
npm install --save @investec/plugins-client-type-routerWhat it owns
- URL-to-client-type routing rules;
- shell-chrome updates for
header,leftNav,rightNav,rightNavApp,featureLibrary,megaMenu, andserviceNotification; - a default rule set through
DEFAULT_ROUTE_RULES; - an escape hatch for consumer-supplied custom rules.
Public contract
The package exports:
clientTypeRouter.activeEnvironmentrouteClientTypeBasedOnUrl(...)DEFAULT_ROUTE_RULESIPlatformInteractionsInterfaceIRouteRule
Integration pattern
Set the environment before routing:
ts
import {
clientTypeRouter,
routeClientTypeBasedOnUrl,
type IPlatformInteractionsInterface,
} from '@investec/plugins-client-type-router';
clientTypeRouter.activeEnvironment = 'staging';
const currentInteractions: IPlatformInteractionsInterface = {
header: { showHeader: true },
leftNav: { showLeftNav: true, isOpen: true },
featureLibrary: { showFeatureLibrary: true, isOpen: false },
};
const result = routeClientTypeBasedOnUrl(
'/usrroot-wpaas/types',
currentInteractions,
'private-client'
);The result shape is:
ts
{
clientType: string;
platformInteractions: IPlatformInteractionsInterface;
}Default routing behaviour
The built-in rules cover platform paths such as:
/usrroot-wpaas/types/prog-banking-wpaas/- intermediary paths like
/ifa-uk,/ifaroot,/ifb-sa - business-banking paths like
/bb - IX paths like
/ixand/vdr-wpaas/ix - pre-login paths such as
/setupand/login-wpaas/form /open-api/
The router always falls back to private-client if no earlier rule matches.
Custom rules
Pass a custom rules array when the default rules are not sufficient:
ts
import {
DEFAULT_ROUTE_RULES,
routeClientTypeBasedOnUrl,
type IRouteRule,
} from '@investec/plugins-client-type-router';
const customRules: IRouteRule[] = [
...DEFAULT_ROUTE_RULES,
{
name: 'custom-labs-area',
urlMatcher: '/labs/',
clientType: 'private-client',
updateInteractions: {
featureLibrary: { showFeatureLibrary: false },
},
},
];
const result = routeClientTypeBasedOnUrl(
'/labs/preview',
currentInteractions,
'private-client',
customRules
);Rules are checked by ascending priority. Exclusions and optional condition callbacks are applied before a rule matches.
How consumers extend it
This plugin already exposes its main extension point: pass customRules to routeClientTypeBasedOnUrl(...).
Use consumer code when you need:
- an app-specific route that should not become platform-wide;
- extra post-processing on the returned interaction state;
- an experiment or temporary policy in one shell only.
Change the plugin package when the new rule is a shared default that other consumers should inherit from DEFAULT_ROUTE_RULES.
Extension example: add a consumer-only route rule
ts
import {
DEFAULT_ROUTE_RULES,
routeClientTypeBasedOnUrl,
type IPlatformInteractionsInterface,
type IRouteRule,
} from '@investec/plugins-client-type-router';
const baseInteractions: IPlatformInteractionsInterface = {
header: { showHeader: true, showProfileSelector: true },
leftNav: { showLeftNav: true, isOpen: true },
featureLibrary: { showFeatureLibrary: true, isOpen: false },
};
const appRules: IRouteRule[] = [
{
name: 'labs-preview',
urlMatcher: '/my-feature/labs',
clientType: 'private-client',
priority: -10,
updateInteractions: {
featureLibrary: { showFeatureLibrary: false },
rightNav: { showRightNav: false },
},
},
...DEFAULT_ROUTE_RULES,
];
const result = routeClientTypeBasedOnUrl(
'/my-feature/labs',
baseInteractions,
'private-client',
appRules
);
// Persist the plugin result in application state.
const nextClientType = result.clientType;
const nextPlatformInteractions = result.platformInteractions;Consumer notes
- The IX rule is environment-sensitive: it hides the left nav in production and shows it in non-production.
- String matchers use
url.includes(...); they are not anchored path matches. - Interaction updates are deep-merged into the supplied state, not replaced wholesale.