Add media usage read APIs#2092
Conversation
🦋 Changeset detectedLatest commit: 976ed70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
Scope checkThis PR changes 2,213 lines across 22 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 976ed70 | Jul 17 2026, 01:14 PM |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 976ed70 | Jul 17 2026, 01:15 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | 976ed70 | Jul 17 2026, 01:15 PM |
There was a problem hiding this comment.
This is the right change for the approved Discussion: additive, read-only media usage APIs with the advertised scope/permission gating. The implementation keeps default query cost intact (usage is opt-in via includeUsage=1), groups details by content entry, and reuses the existing projection tables and repair pipeline. It also wires up routes, OpenAPI, client methods, docs, and regression tests.
I reviewed the diff and related source statically and found no blocking correctness, security, authorization, or AGENTS.md violations. The repository-level pagination SQL is parameterized, draft/trash metadata is guarded by content:read_drafts plus an admin token scope, the response envelope stays consistent, and the changeset is user-facing.
Only two small client-type completeness gaps are worth noting so the TypeScript contract matches what the server now returns.
There was a problem hiding this comment.
This is the right change for the approved Discussion: it adds read-only, coverage-aware media usage APIs without changing default query cost. The implementation reuses the existing media-usage projection tables and repair pipeline, and the authorization/scope gating matches the PR description.
I re-checked the diff statically after the previous review. The two client-type completeness gaps from the prior pass are resolved: EmDashClient now accepts includeUsage on mediaList / mediaGet and exposes mediaGetUsage with matching MediaUsageDetailsResponse / MediaUsageSummary types.
No blocking issues remain. The repository SQL is parameterized Kysely (no interpolation), draft/trash metadata is guarded by content:read_drafts plus admin token scope, the response envelope shape stays consistent, the changeset is user-facing, and the new tests cover schema validation, route auth/success/error paths, query-count budgets, and client serialization. Locale filtering does not come into play here because usage details are read from the projection tables and grouped by content row ID, which is already per-locale.
Approved.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
What does this PR do?
Adds coverage-aware media usage reads so authorized clients can show where local assets are referenced.
Discussion: #1503
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
No visual changes.
pnpm formatpnpm lintpnpm typecheck