export type PythonApiDisposition = "exposed" | "restricted" | "nonportable" | "not_implemented" | "planned"; export interface PythonApiRuntimeIndex { schema: "freecad-web-python-api-runtime-index/v1"; source: { manifest: string; manifestSha256: string }; fields: { modules: string[]; kinds: string[]; families: string[]; tiers: string[]; dispositions: PythonApiDisposition[] }; records: [string, number, number, string, number, number, number, string?, number?][]; } export interface PythonApiRecord { id: string; module: string; kind: string; name: string; family: string; tier: string; disposition: PythonApiDisposition; sourcePath?: string; sourceLine?: number; } export function decodePythonApiRecord(index: PythonApiRuntimeIndex, row: PythonApiRuntimeIndex["records"][number]): PythonApiRecord { return { id: row[0], module: index.fields.modules[row[1]], kind: index.fields.kinds[row[2]], name: row[3], family: index.fields.families[row[4]], tier: index.fields.tiers[row[5]], disposition: index.fields.dispositions[row[6]], ...(row[7] ? { sourcePath: row[7] } : {}), ...(typeof row[8] === "number" ? { sourceLine: row[8] } : {}) }; } export function createPythonApiLookup(index: PythonApiRuntimeIndex): Map { return new Map(index.records.map((row) => { const record = decodePythonApiRecord(index, row); return [record.id, record] as const; })); }