/** * camelCase-aware read/write helpers for an Entity.data blob. The tenant API * client camelCases response keys (incl. the data blob), so a snake_case attr * `team_verdict` lands as `teamVerdict`; try the camel form first, then the raw * key. Pure + framework-free. */ import type { EntityRecord } from './types'; export function toCamelKey(name: string): string { return name.replace(/_+([a-z0-9])/g, (_m, c: string) => c.toUpperCase()); } export function readData(data: EntityRecord['data'] | undefined, name: string): unknown { if (!data) return undefined; const bag = data as Record; return bag[toCamelKey(name)] ?? bag[name]; }