// Copyright: © 2026 TWWIM UG. All rights reserved. (www.twwim.com) /** * Centralised typed accessors for enum-bearing fields on the authenticated * user. Stores receive raw `string | undefined` from JWT/localStorage; these * helpers validate against the enum's known values and narrow once so call * sites avoid sprinkling `as Enum | undefined` casts. */ import { AuthOrigin, EmployeeRole } from '@archer/domain'; export function toAuthOrigin(raw: string | undefined | null): AuthOrigin | undefined { if (!raw) return undefined; return (Object.values(AuthOrigin) as string[]).includes(raw) ? (raw as AuthOrigin) : undefined; } export function toEmployeeRole(raw: string | undefined | null): EmployeeRole | undefined { if (!raw) return undefined; return (Object.values(EmployeeRole) as string[]).includes(raw) ? (raw as EmployeeRole) : undefined; }