(text: string)
| 83 | * PURE. |
| 84 | */ |
| 85 | export function deserializeMaintainHistory(text: string): { runs: MaintainRun[]; exportedAt?: string; version?: number; audit?: HistoryAudit } { |
| 86 | let obj: any; |
| 87 | try { obj = JSON.parse(text); } catch { throw new Error('not valid JSON'); } |
| 88 | const rawRuns = Array.isArray(obj) ? obj : obj?.runs; |
| 89 | if (!Array.isArray(rawRuns)) throw new Error('no maintain runs found in the file'); |
| 90 | const runs = rawRuns.filter(isRunLike).map(normalizeRun); |
| 91 | const audit = obj?.audit && typeof obj.audit === 'object' && typeof obj.audit.head === 'string' ? obj.audit as HistoryAudit : undefined; |
| 92 | return { runs, exportedAt: typeof obj?.exportedAt === 'string' ? obj.exportedAt : undefined, version: typeof obj?.version === 'number' ? obj.version : undefined, audit }; |
| 93 | } |
| 94 | |
| 95 | /** A stable identity for a run, so re-importing the same snapshot doesn't double-count. */ |
| 96 | function runKey(r: MaintainRun): string { |
no outgoing calls
no test coverage detected