Repository navigation
feat(storage): add purgeProjectCache to purge the CDN cache of every bucket - #2860
officialasishkumar wants to merge 1 commit into
Conversation
…bucket
Storage already exposes `purgeBucketCache(bucket)` and
`from(bucket).purgeCache(path)`, but not the project-wide
`DELETE /cdn/` endpoint, so invalidating the CDN cache of the whole
project meant purging bucket by bucket.
Add `purgeProjectCache(options?, parameters?)` on the bucket API
(`supabase.storage.purgeProjectCache()`). Like the other purge methods
it accepts `{ transformations: true }` to purge only resized/formatted
variants, forwards an `AbortSignal`, and returns `{ data: { message } }`
or a `StorageError`.
Register `storage.file_buckets.purge_project_cache` in
sdk-compliance.yaml and cover the request URL, query string, signal
forwarding and error mapping with unit tests.
|
No actionable comments were generated in the recent review. Summary
Change: Feature Merge Risk:
|
🔍 Description
What changed?
Adds
purgeProjectCache(options?, parameters?)to the Storage bucket API, sosupabase.storage.purgeProjectCache()invalidates the CDN cache for every bucket in the project. It maps to the Storage API'sDELETE /cdn/endpoint.It works the same way as the existing
purgeBucketCacheandfrom(bucket).purgeCache:{ transformations: true }purges only resized/formatted variants and keeps the cached originals (?transformations=true)AbortSignalcan be passed throughparameters{ data: { message }, error: null }, or{ data: null, error: StorageError }It also registers
storage.file_buckets.purge_project_cacheinsdk-compliance.yaml(the capability already exists in the pinned capability matrix) and widens thePurgeCacheOptions.transformationsdoc to cover project-wide purges.Why was this change needed?
The Storage API exposes three purge scopes: project, bucket and object. supabase-js covers only bucket and object (#2429). Purging the whole project, for example after changing image transformation settings, meant listing every bucket and calling
purgeBucketCacheon each one. The capability matrix tracks the project scope asstorage.file_buckets.purge_project_cache, which supabase-js has not implemented yet.📸 Screenshots/Examples
🔄 Breaking changes
📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
/cdn/with a trailing slash. That's the exact path the Storage server registers and tests for the tenant purge route (src/http/routes/cdn/purgeCache.ts,src/test/cdn.test.tsin supabase/storage).storageBucketApi.test.tsmirror thepurgeBucketCacheones: URL, transformations query, signal forwarding, and error mapping.validate-complianceandcheck-api-symbolsboth pass. The additions check also needs the inheritedStorageClient.purgeProjectCacheregistered, so it is listed next todefault.purgeProjectCache.