feat(api): make canonical list metadata hydration optional (#829) - #837
Conversation
🦋 Changeset detectedLatest commit: 67c1226 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (2)
🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Implements issue #829 §5 ("Make expensive enrichment optional") for the canonical file listing.
What changed
GET /v1/workspaces/:workspace/files(and its legacy/me/workspaces/:name/filesalias, which forwards the query string unchanged) now accepts?metadata=0/?metadata=falseto skip the D1 metadata hydration pass. Default behavior is unchanged — no param, or any other value, still hydrates and returnsmetadataper row exactly as before. No response fields were removed or renamed.packages/uploads's client (list/listAll) now sendsmetadata=0whenever the caller didn't passmetadata: true. Previously the client always paid for the server's hydration pass and then discarded themetadatamap client-side when the caller hadn't asked for it — this closes that gap. Callers that do passmetadata: trueare unaffected (client still sendsmetadata=1and surfaces the map).Param naming
files.ts's legacy bearer listing route already uses?metadata=1/trueas an opt-in (that route doesn't hydrate by default). The canonical route hydrates by default, so this reuses the samemetadataparam name with inverted polarity (0/falseopts out) rather than introducing a second param — same spelling callers already know, consistent with how each route's default behaves.Left out of scope
Evaluated gallery preview enrichment (
workspace-galleries.ts'sitemCount/references/previewUrlhydration onGET /:workspace/galleries) for the same opt-out pattern. That enrichment is structurally different — it isn't a single D1 read but a per-row storage resolve for the cover thumbnail — so making it optional is a larger change than this PR's scope. Noting it here rather than doing it as part of §5.Tests
apps/api/test/routes-workspace-files.test.ts: default hydration is unchanged;?metadata=0and?metadata=falseboth skip hydration (nometadatakey on returned rows).packages/uploads/test/client-metadata.test.ts: client still requestsmetadata=1whenmetadata: trueis passed; now asserts it sendsmetadata=0when it isn't.pnpm test(root, full suite): all passing.apps/api(pnpm --filter @uploads/api run typecheck) andpackages/uploads(pnpm run typecheckin that package) both clean.Changeset
Added a
minorchangeset for@buildinternet/uploads— additive client behavior change (fewer bytes/less server work onlist/listAllcalls that don't request metadata).Refs #829 §5.