(o: any)
| 52 | } |
| 53 | |
| 54 | function coerce(o: any): RunReceipt | null { |
| 55 | if (!o || typeof o !== 'object') return null; |
| 56 | const status = STATUSES.has(o.status) ? o.status : (o.prUrl || o.pr_url ? 'opened' : undefined); |
| 57 | if (!status) return null; |
| 58 | const checks = Array.isArray(o.verification) |
| 59 | ? o.verification.map((c: any) => ({ command: String(c?.command ?? ''), passed: !!c?.passed })).filter((c: ReceiptCheck) => c.command) |
| 60 | : undefined; |
| 61 | const files = Array.isArray(o.filesChanged ?? o.files) |
| 62 | ? (o.filesChanged ?? o.files).map((f: any) => String(f)).filter(Boolean) |
| 63 | : undefined; |
| 64 | return { |
| 65 | status, |
| 66 | goal: str(o.goal), |
| 67 | branch: str(o.branch), |
| 68 | prUrl: str(o.prUrl ?? o.pr_url), |
| 69 | reason: str(o.reason), |
| 70 | summary: str(o.summary), |
| 71 | filesChanged: files, |
| 72 | verification: checks, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | const str = (x: any): string | undefined => (typeof x === 'string' && x.trim() ? x.trim() : undefined); |
| 77 |
no test coverage detected