Repository navigation
refactor: starters, examples and docs read with get/list; read-verbs codemod (3d) - #39
Merged
Merged
Conversation
|
Caution Review failedThe pull request is closed. TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
🦋 Changeset detectedLatest commit: 79e3126 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 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 |
cursor Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
…tion rehearsal Co-authored-by: jherr <jherr@pobox.com>
cursor
Bot
force-pushed
the
cursor/read-verbs-migration-d21e
branch
from
November 6, 2026 14:50
b4e4171 to
62d6dfe
Compare
cursor
Bot
force-pushed
the
cursor/populate-sidecar-a931
branch
from
November 6, 2026 14:50
3aecfb8 to
35ed2e9
Compare
jherr
force-pushed
the
cursor/read-verbs-migration-d21e
branch
from
November 6, 2026 15:09
62d6dfe to
79e3126
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements cms-refactor-plan.md § Phase 3 (3d), the "Wrap, migrate, then remove in phase 6" step of item 5. The older verbs stay as wrappers that keep their old defaults.
Merge chain: step 19 of 24. Base:
main. Merge it right after #35. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit62d6dfe(treebb98cb3).What
The codemod
pnpm codemod read-verbs(scripts/codemods/read-verbs.ts, ts-morph) rewrites:queryDocumentsAstolistAs. It addspopulate: false, and turns a one-namecollections: [x]intocollection: x.readDocumentAsto(await getAs(ctx, { collection, id, populate: false }))?.doc ?? null.readDocumentBySlugAsto an id-first lookup,(await getAs(…, { id: key })) ?? (await getAs(…, { locator: key })), which matches the old behaviour. If the key or context can't safely be written twice, or the read isn't awaited, it falls back to a singlelocatorread with alocatorTODO.publicContext();cmsAs(cms, ctx)handle methods;await import()and code fences in Markdown.It adds a
// TODO(read-verbs): …and a warning in four cases:live.list's maximum of 500.titleorpublished.It leaves the call alone, with a warning, for:
findDocumentBySlug(As);query;collections;The fixtures cover each case, including the
locatorfallback.Hand migration, limited to read call sites:
CMS-INTEGRATION.mdfiles.*-afterparity tests. The parity tests went through the codemod and were then tidied.app/base: the dashboard reports and report rows. Unit and E2E tests check that a scoped session can't callget/list, and that an anonymousGET /api/cms/v1/ops/listgets 401.atproto publishreads withgetAs(publicContext())(patch changeset).Docs:
building-pages.md(with new type-checked snippets),cms-core-server.md,cms-api.md,routes-and-endpoints.md,operations-registry.md,cli.md,data-layer.md,terminology.md, the migration pages, and two upgrading steps (5, and this PR's get/list step).The dialect baseline drops from 221 to 171 non-test matches (table below). No marker retires.
Breaking changes
None in published packages. Two changes affect starter code that apps copy:
multi-tenant-fleet:listTenantPages/listTenantAssetsitems are{ id, collection, doc }, with notitleorpublished. The starter's tests and UI only useidanddoc.blog-voting:getTopPostsderivestitlefromdoc.title, falling back to the id, as before.Sites left on the older verbs, and why
Reads that feed a write in an edit or system context.
getwould overlay staged changes, but the write has to see the stored row. These are:sendNewsletterIssue;claimListing;app/baseread-modify-writes;app/prmimport and scripts.5a (feat(core,api,client): writes as document state strategy actions — save and act, rooted in the operations registry (5a) #40) adds
get({ staged: false })for Phase 6 to move these to.multi-tenant-fleetreadTenantPage: an edit-mode read whose result the overlay would change.getPublicDocument/findDocumentBySlugAswithpreferred: a cross-collection lookup, whichgetcan't express.Admin editor reads, package internals and package tests. Phase 6 handles these.
Storage-adapter calls and
ScopedCmsClientmethods.app/base/scripts/smoke-docker.mjs: it needs Docker.Dialect inventory (non-test matches; test counts in brackets)
queryDocumentsreadDocumentreadDocumentBySlugfindDocumentBySluggetPublicDocumentlistPublishedDocumentsqueryDocumentsandreadDocumentno longer appear in starters, examples or.claude/skills.How verified
GitHub Actions is out of billing, so everything ran locally. On a scratch branch, I merged
77e80a9intoorigin/mainat3b4a112. The only conflict wasscripts/codemods/index.ts, where I kept all four codemods. I then added the docs-onlyd951055and reran kiira and both E2E suites.pnpm install --frozen-lockfilepnpm test:ci(174 tasks)@tanstack/cms-api:test:oxlintfails. Core 595 (30 skipped), api 207, client 35, CLI 25, base 42, prm 9, blog-voting 8,*-after5 each, all 13 starters, kiira 127/127.pnpm test:dtspnpm test:dialectspnpm test:scriptspnpm test:definitionsAssumptions (conservative defaults where the plan gives none)
populate: false, so migrated results keep relation ids.readDocumentAsin edit and system contexts. List reads migrate in any mode, becauselistAsreads whatqueryDocumentsAsread.limit.idfirst, then bylocator. That applies to blog-votingresolvePost, the voting skill and the codemod's output. Under 3c(i) (feat(core)!: locators — locatorStrategy, nested slugs, a unique per-locale locator index, and get({ locator }) through it (3c(i)) #38), a locator is the slug, or the id only when there's no slug, so these lookups keep working. Sites whose key is always a URL slug uselocatoralone: the emdash parity test and thebuilding-pages.mdexamples.scripts/isn't published.Divergence from plan
get. The sites listed above keep their old verbs, becausegetwould change the result or has no equivalent.listreturns committed documents and doesn't overlay staged changes.*-aftertests drop the codemod'spopulate: falsewhere they only read counts or fields.Follow-up (
b4e4171, a fast-forward fromd951055)The cross-stack integration rehearsal found that, combined with #38, blog-voting's
get({ locator: postId })fails all 8 of its tests.2be56ab: blog-votingresolvePostand the voting skill look up byid, then bylocator.197be9c: the codemod'sreadDocumentBySlug(As)rewrite emits the same two-step lookup. The fixtures are updated, and there's a new fallback case.b4e4171: three doc sentences no longer describe alocatorread as slug-or-id (cms-core-server.md,building-pages.md, and the get/list upgrading step).Verification on
b4e4171:test:libpasses 8,test:typespasses, and the 8 also pass on a local merge with feat(core)!: locators — locatorStrategy, nested slugs, a unique per-locale locator index, and get({ locator }) through it (3c(i)) #38.*-afterparity tests: 5 each.test:scripts: 43 pass.test:docs: no broken links.Merge chain (local verification, CI down)
This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied. Five conflicts: the emdash and payload skills,
cms-core-server.md,from-sanity.mdandscripts/codemods/index.ts. The dialect baseline is refreshed.The chain tip's tree is exactly the integration rehearsal plus #46 (
c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the newmain; that rebase is always clean.