/** CDNs Eponyme can purge on its own. `custom` hands every purge to the `eponyme:cdn:purge` hook. */ export type EponymeCdnProvider = 'vercel' | 'cloudflare' | 'custom'; /** * Something cached that does not carry an entry's own tags but still shows it: a layout reading a * singleton, a page listing a collection, a sitemap. * * @example * ```ts * // The layout reads the `club` singleton, so every page shows it. * { on: ['club'], routes: ['/**'] } * // Aggregates: purged whatever changed. * { on: '*', routes: ['/sitemap.xml', '/llms.txt'], tags: ['eponyme:plan-du-site'] } * ``` */ export interface EponymeCdnDependency { /** * What the cached responses depend on: singleton names (`club`, `pages/homepage`), collection names * (`articles`, which covers every entry of it) or exact entry names (`articles/my-article`). `'*'` * means any change at all. */ on: string[] | '*'; /** * Route patterns tagged at request time so a change of `on` purges them. Globs (`/club/**`, `/*`) * and named segments (`/:slug`) are understood. Unlike a route rule, several patterns may match the * same request: their tags add up instead of overriding each other. */ routes?: string[]; /** Tags purged as well, typically ones a route of yours sets by hand. */ tags?: string[]; /** * URL prefixes purged as well, without a scheme: `example.com/blog/`. Only Cloudflare purges by * prefix; the other providers ignore them and say so at startup. */ prefixes?: string[]; } /** What one purge asks of the CDN, every change of a batch merged. */ export interface EponymeCdnPurgeRequest { tags: string[]; prefixes: string[]; /** The entries whose change caused it, for logging. */ entries: string[]; } /** Context of the `eponyme:cdn:purge` hook, the custom adapter. */ export interface EponymeCdnPurgeContext extends EponymeCdnPurgeRequest { provider: EponymeCdnProvider; } export interface EponymeCdnPurgeFailedContext extends EponymeCdnPurgeContext { /** Attempts made, retries included. */ attempts: number; error: unknown; }