/** * Derive a stable table-preferences id from the current route. * * Table caching (`useTablePreferences`) is gated on a `tableId`. Historically * every consuming MFE had to pass one explicitly, so any grid/filter/toolbar * that forgot the prop silently cached nothing. This helper lets the shared * components fall back to a route-derived id so caching works out of the box. * * Why the pathname, and nothing else: * A grid, its `GenericFilter` and its `CustomGridToolbar` all read and write * the *same* `tpref_` bucket (the grid stores page size / sort / column * layout, the filter stores `filters` — different keys, one object). For that * to work the three components must independently derive the *identical* id. * The only signal all three share without a wrapper is the route pathname, so * the derivation is a pure function of it — no component type, no `uniqueId` * (the filter never sees the grid's `uniqueId`). * * Known limitations (both resolved by passing an explicit `tableId`): * - Two independent grids on one route would derive the same id and share a * cache. No real page does this today; such pages must pass explicit ids. * - A route with path params (e.g. `/course/123/students`) yields a separate * bucket per id. Sometimes desirable, sometimes not — override when not. * * @param {object} [opts] * @param {string} [opts.prefix="route"] namespacing prefix for the derived id * @returns {string|null} a stable id, or null when it cannot be derived * (non-browser env) — null keeps caching a no-op. */ export function deriveTableId({ prefix }?: { prefix?: string; }): string | null; /** * Resolve the effective table id for a shared component. * * Keeps `tableId`'s existing semantics intact and only adds the fallback: * - an explicit string -> used as-is (the 7 MFEs already on caching are * unaffected; explicit always wins) * - `false` / `null` / `""` -> caching stays OFF (explicit opt-out) * - `undefined` (not passed) -> derive from the route (the new default-on) * * @param {string|false|null|undefined} tableId the component's `tableId` prop * @param {object} [opts] forwarded to `deriveTableId` * @returns {string|null|false} value to hand to `useTablePreferences` */ export function resolveTableId(tableId: string | false | null | undefined, opts?: object): string | null | false;