import { PAYLOAD_CONTENT_KEY, PAYLOAD_TABS_KEY } from "#configuration/constants/leak.constants"; export const isRecord = function isRecord(value: unknown): value is Record { return typeof value === "object" && value !== null; }; export const textAt = function textAt(record: Record, key: string): string | null { const value = record[key]; return typeof value === "string" ? value : null; }; export const listAt = function listAt(value: unknown, key: string): Record[] { const held = isRecord(value) ? value[key] : undefined; return Array.isArray(held) ? held.filter(isRecord) : []; }; export const contentOf = function contentOf(payload: unknown): Record | null { const content = isRecord(payload) ? payload[PAYLOAD_CONTENT_KEY] : undefined; return isRecord(content) ? content : null; }; export const tabsIn = function tabsIn(content: unknown): Record[] { return listAt(content, PAYLOAD_TABS_KEY); };