(url)
| 68 | } |
| 69 | |
| 70 | async function fetchCatalog(url) { |
| 71 | const res = await fetch(url, { headers: { Accept: "application/json" } }); |
| 72 | if (!res.ok) throw new Error(`HTTP ${res.status}`); |
| 73 | const raw = await res.json(); |
| 74 | if (typeof raw !== "object" || raw === null || Array.isArray(raw)) { |
| 75 | throw new Error("invalid payload shape"); |
| 76 | } |
| 77 | const stripped = {}; |
| 78 | for (const [k, v] of Object.entries(raw)) { |
| 79 | const p = stripProvider(v); |
| 80 | if (p !== undefined && Object.keys(p).length > 0) stripped[k] = p; |
| 81 | } |
| 82 | return JSON.stringify(stripped); |
| 83 | } |
| 84 | |
| 85 | async function main() { |
| 86 | console.log(`Fetching ${modelsUrl} ...`); |
no test coverage detected