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
Warning: By default, this package must be installed only by the platform team into the Investec Online shell application. Do not add it as a direct dependency of a consumer/feature application unless the Web Platform team has explicitly approved that specific use as a rare exception. 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-client-type-routerThe 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.
What 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 main package-root exports include:
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 /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.
Hide Contact us for a route
To hide Contact us for every URL that contains /ifi-wpaas, add an approved shared rule:
ts
const ifiRules: IRouteRule[] = [
{
name: 'ifi-wpaas-contact-us',
urlMatcher: '/ifi-wpaas',
clientType: 'intermediaries',
updateInteractions: {
leftNav: {
showContactUs: false,
},
},
},
...DEFAULT_ROUTE_RULES,
];String matchers use url.includes(...), so this rule matches the base path and nested routes. Confirm the route ownership and client type with the Web Platform team before adding the rule to DEFAULT_ROUTE_RULES.
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,
showConcierge: true,
showProfileSettings: true,
showRightNavToggle: 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;Extend the shared plugin
Use:
DEFAULT_ROUTE_RULESfor a route that must become a platform-wide default;environment.tsfor an approved environment-dependent routing value;IRouteRuleonly when the current matcher, condition, and interaction-update model cannot represent an approved shared rule;client-type-router.spec.tsfor match, exclusion, priority, merge, and fallback coverage.
A bounded route-rule or configuration addition can be implemented directly when the route ownership and client type are approved. Contact the Web Platform team before adding a client-type model, changing the default fallback, removing legacy routes, or changing shell-interaction semantics.
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.