Repository navigation
Add optional cacheControl to put and bump to 0.2.0 - #11
Conversation
Consumers migrating hosts that serve stored images publicly need to keep a Cache-Control header with the object (first recorded need: Exsimplify product image uploads storing "public, max-age=31536000, immutable"). Every first-class backend keeps Cache-Control as native object state served with the bytes — Azure blobHTTPHeaders.blobCacheControl, S3 and R2 CacheControl — so it is an honest intersection, unlike signed URLs or lifecycle rules, which stay out of the port. PutOptions gains an optional cacheControl validated like content-type (printable ASCII, no surrounding whitespace, 256-byte cap, no default); BlobObjectInfo returns it from head/get, undefined when a put omitted it, and a replacing put without one clears it. Conformance covers round-trip, absent-by-default, replace-clears, and rejection across the memory store and all three adapters. Minor bump to 0.2.0 since the port surface grew. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f82ec0d7e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🟢 Ready to approve
The port extension is consistently implemented across the port, conformance suite, and all first-class adapters with clear validation and documented semantics.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Extends the @pegma/storage-blobs port to allow storing an object-level Cache-Control value at write time (and returning it from head/get), with matching conformance coverage and adapter support across Azure Blob, S3, and R2; also bumps the published package versions to 0.2.0.
Changes:
- Add
PutOptions.cacheControl?: string,BlobObjectInfo.cacheControl: string | undefined,MAX_CACHE_CONTROL_BYTES, andassertValidCacheControlto the port (including memory-store round-trip). - Add conformance cases for cache-control round-trip, omission semantics, replace-clears semantics, and validation rejection.
- Wire cache-control through Azure/S3/R2 adapters and bump all package versions/dependencies to
0.2.0(plus doc/version reference updates).
File summaries
| File | Description |
|---|---|
| README.md | Update published version references to 0.2.0. |
| packages/storage-s3/src/index.ts | Pass cacheControl through put/head/get and normalize empty-string responses to undefined. |
| packages/storage-s3/README.md | Update version reference to 0.2.0. |
| packages/storage-s3/package.json | Bump package and port dependency to 0.2.0. |
| packages/storage-cloudflare-r2/src/index.ts | Pass cacheControl through put/head/get and normalize empty-string responses to undefined. |
| packages/storage-cloudflare-r2/README.md | Update version reference to 0.2.0. |
| packages/storage-cloudflare-r2/package.json | Bump package and port dependency to 0.2.0. |
| packages/storage-blobs/src/index.ts | Add cache-control to the port types, validation, and memory store persistence. |
| packages/storage-blobs/src/conformance.ts | Add conformance coverage for cache-control behavior and validation. |
| packages/storage-blobs/README.md | Document cacheControl usage and bump install/version references to 0.2.0. |
| packages/storage-blobs/package.json | Bump package version to 0.2.0. |
| packages/storage-azure-blob/src/index.ts | Pass cacheControl via Azure blob HTTP headers and return it from head/get; normalize empty-string to undefined. |
| packages/storage-azure-blob/README.md | Update version reference to 0.2.0. |
| packages/storage-azure-blob/package.json | Bump package and port dependency to 0.2.0. |
| package-lock.json | Align lockfile package versions and internal dependency pins to 0.2.0. |
| docs/PROJECT_PLAN.md | Update status/version references and note the new cache-control capability. |
Review details
- Files reviewed: 15/16 changed files
- Comments generated: 0
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Adapters read head and get through different provider calls, so the replace-clears case must pin both consumer-visible paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Why
The Exsimplify migration surfaced a real consumer need the port could not express: the .NET host stored product images with
Cache-Control: public, max-age=31536000, immutablefor public CDN-ish serving, and the Pegma port had to drop the header (recorded as a feedback candidate in Exsimplify'sdocs/Pegma-Migration-Plan.md, Phase 5).Scope decision
Weighed against the package's refusals: Cache-Control at write time is native object state on every first-class backend — Azure
blobHTTPHeaders.blobCacheControl, S3CacheControl, R2CacheControlvia the S3-compatible API — served with the bytes on read. That makes it an honest intersection, in the same family ascontentType, unlike signed URLs and lifecycle rules, which remain out of the port. A broader allowlisted response-headers object was considered and rejected:Content-Dispositionand friends are host response policy at serve time, and only cacheControl has a demonstrated consumer need. The decision is documented in the package README ("Cache-control" section).What changed
@pegma/storage-blobs):PutOptions.cacheControl?: string, validated like content-type (printable ASCII, no surrounding whitespace,MAX_CACHE_CONTROL_BYTES= 256, no default).BlobObjectInfo.cacheControl: string | undefinedreturned byhead/get; a replacing put without one clears it. ExportedassertValidCacheControl. Memory store round-trips it.undefinedwhen omitted, replace-clears, and rejection of illegal values.blobCacheControlon upload, read from properties/download), s3 and r2 (CacheControlonPutObjectCommand, read from Head/Get). Empty-string responses normalize toundefined(Azurite reports cleared cache-control as"").0.2.0(port surface grew → minor per repo convention), adapter deps exact-pinned to0.2.0, lockfile refreshed, README/plan version references updated.Verification
npm run format:check,npm run check, andnpm testall green — 240 tests including the new cases against Azurite (Azure) and LocalStack (S3, R2), 16 new case runs total.🤖 Generated with Claude Code