()
| 77 | |
| 78 | /** The product list backing the `search` tool description. Empty if unseeded. */ |
| 79 | export async function getProducts(): Promise<string[]> { |
| 80 | const now = Date.now() |
| 81 | if (fresh(productsEntry, now)) return productsEntry.value |
| 82 | |
| 83 | const obj = await env.SPEC_BUCKET.get('products.json') |
| 84 | const value: string[] = obj ? await obj.json() : [] |
| 85 | productsEntry = { value, expiresAt: now + TTL_MS } |
| 86 | return value |
| 87 | } |
| 88 | |
| 89 | /** Drop cached artifacts. For tests that re-seed R2 between cases. */ |
| 90 | export function resetIsolateCache(): void { |
no test coverage detected