Skip to content

refactor: merge Prismic clients into one file - #445

Open
angeloashmore wants to merge 8 commits into
mainfrom
claude/single-prismic-client
Open

angeloashmore wants to merge 8 commits into
mainfrom
claude/single-prismic-client

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Resolves:

Description

Before this PR, each Prismic service had its own client file. The files hid parts of each request in shared helpers. For example, to know which token, headers, and error messages a request used, a reader had to follow two or three helpers.

After this PR, all requests to Prismic are in one client file, grouped by service. Each client function shows its full request and returns the API response as it is. A new endpoint starts from a copy of a similar function. The next PR adds a login retry to each of these functions (#443).

The behavior of the CLI does not change.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA 1

Run the commands that use the Prismic API, for example prismic repo view, prismic pull, and prismic webhook list. They work as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du


Note

Medium Risk
Wide mechanical refactor across all Prismic API usage; regressions would affect auth, repo settings, push/pull, and dev sync if any response handling was missed.

Overview
Consolidates every Prismic HTTP client that lived under src/lib/prismic/clients/ into a single src/lib/prismic/client.ts, grouped by backend service. Shared request wrappers are removed so each export builds its own URL, headers/credentials, and Zod schema inline. AGENTS.md now points at client.ts instead of a clients/ folder.

Call sites across commands, adapters, auth, models, and tracking import from the new module. Several exports are renamed for clarity (getProfile → getUserProfile, getRepositories → getUserRepositories, removePreview/removeLocale → deletePreview/deleteLocale, screenshot and API-access helpers similarly). List and metadata helpers now return parsed API envelopes (e.g. { results } for previews/locales, { simulator_url }, { id } from createRelease, { total } for document counts) instead of unwrapping inside the client—commands destructure those fields locally. Model sync uses bulkUpdateModels / BulkModelChange instead of the old custom-types names.

Intended CLI behavior is unchanged; the shape change sets up a follow-up to add login retry per request.

Reviewed by Cursor Bugbot for commit 09efad4. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment. ↩

Move all Prismic service requests from src/lib/prismic/clients/ into
src/lib/prismic/client.ts, grouped by service. The services now share
one config type and two auth helpers: one sends the token as a Bearer
header and one sends it as the prismic-auth cookie. Core and Wroom use
the same repository domain, so they now share one request helper.

The behavior does not change. AGENTS.md now describes the new file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Each service request helper now takes a path. The helper builds the URL
from the service base, so the separate base URL helpers are not needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Each client function now builds its own request: the URL, the token,
and the error messages. A reader can see the full request in one
function, and a new endpoint starts from a copy of a similar one.

Small helpers still give the base URL of each service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Client functions now return the response that the API sends. The
callers take the values that they need from the response. A client
function then only describes one request.

The screenshot upload gets its upload form from its own client
function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
In one client file, a name like bulkUpdate or removeLocale does not say
what it acts on. The names now include the object and stay close to the
API endpoint, for example bulkUpdateModels and getUserProfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
@angeloashmore
angeloashmore marked this pull request as ready for review October 29, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants