( name: string, type: ItemType, baseUrl: string = DEFAULT_REGISTRY_URL, )
| 106 | * Throws on network failure (callers decide whether to degrade gracefully). |
| 107 | */ |
| 108 | export async function fetchItemManifest( |
| 109 | name: string, |
| 110 | type: ItemType, |
| 111 | baseUrl: string = DEFAULT_REGISTRY_URL, |
| 112 | ): Promise<RegistryItem> { |
| 113 | const dir = ITEM_TYPE_DIRS[type]; |
| 114 | const cacheFile = cachePath(baseUrl, `${dir}__${name}`); |
| 115 | const cached = readCache<RegistryItem>(cacheFile); |
| 116 | if (cached) return cached; |
| 117 | |
| 118 | const url = `${baseUrl}/${dir}/${name}/registry-item.json`; |
| 119 | const item = await fetchJson<RegistryItem>(url); |
| 120 | writeCache(cacheFile, item); |
| 121 | return item; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Download a single file referenced by an item to a local destination. |
no test coverage detected