Repository navigation
feat(core)!: locators — locatorStrategy, nested slugs, a unique per-locale locator index, and get({ locator }) through it (3c(i)) - #38
Merged
Conversation
🦋 Changeset detectedLatest commit: bf7f6e7 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 |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 59 minutes. View limit details
TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
cursor
Bot
force-pushed
the
cursor/populate-sidecar-a931
branch
from
November 6, 2026 14:50
3aecfb8 to
35ed2e9
Compare
cursor
Bot
force-pushed
the
cursor/locators-a931
branch
from
November 6, 2026 14:50
29df10d to
31e8607
Compare
jherr
force-pushed
the
cursor/locators-a931
branch
from
November 6, 2026 15:09
31e8607 to
bf7f6e7
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 part (i) of cms-refactor-plan.md § Phase 3 (3c): item 2's locator work, and collision rules 1–5 and 8 from § "Decided: nested slugs". Part (ii) does the rest: rules 6 and 7 (shadowing and redirects), the default
path(), the catch-all routes and the Starlight example.Merge chain: step 20 of 24. Base:
main. Merge it right after #39. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit31e8607(tree06dc155).Merge order: 4b (#29) must merge before this PR, because of migration numbering (see below). On the merge chain it does: #29 is step 12.
What
locatorStrategy.slugOrId, is the normalized slug, or the id when the document has no slug. Normalizing drops leading, trailing and doubled/.localizedslug gives one locator per locale.get/listresults carry it aslocatornext toid.slugOrId,locatorStrategyOf,normalizeLocator,LocatorStrategy,LocatorInput.nested: trueonslugfields.slugifyhandles one segment at a time./alone is the collection root (locator''), accepted on nested slug fields only.VALIDATION_FAILEDon the slug field.guidesnext toguides/intro).DocumentIndex.locators?is new.StorageOps.findDocumentsByLocator(collection, locator, locale?). The SQL adapters (SQLite, libSQL, D1) and Postgres implement it, and the composite router forwards it.locatorstable, keyed(collection, locale, locator). Postgres adds an FK cascade and adownmigration.metarebuilds the index when locator derivation changes.get({ locator })resolves through the index, replacing 3a's slug-or-id stopgap./or''returns the root.locale, the lookup stays in that locale. Without it, the default locale is tried first, then the others.localizedslug with a per-locale value was regenerated from the title on save. It's now kept.documentation-kbgets aversionedSlugstrategy (v1/install), matching itspath().multi-tenant-fleetgets atenantSlugstrategy (tenant-a/home).headless-api's contract test gives its two staged items different titles.collections-and-fields.md(with a new "Locators" section),cms-core-server.md,cms-core.md,routes-and-endpoints.md,operations-registry.md,terminology.md, and a new upgrading step (step 29 on the merge chain)..changeset/locators.md(core, api, client and store-postgres minor).Migration numbering
This PR uses SQLite v17 / Postgres v9, leaving v16 / v8 to 4b (#29). Both runners only apply migrations above the current version.
Both PRs also append to
SQL_MIGRATIONSandPOSTGRES_MIGRATIONS, and both entries must stay in version order.transfer.test.tscompares the applied migrations against the migration list, so a gap in the numbering doesn't break it.Breaking changes
get({ locator })no longer finds a slugged document by its id. Useget({ id }). The older slug-or-id verbs are unchanged.get/listresults gainlocator.locatorStrategythat includes the scope.How verified
tests/locators.test.ts(21 tests) covers:downruns.540af28intoorigin/mainat3b4a112. Two conflicts, both resolved by keeping both sides:scripts/codemods/index.ts;starters/multi-tenant-fleet/src/cms.config.ts, where main'sbodyFieldsits next tolocatorStrategy.pnpm install --frozen-lockfilepnpm test:ci(174 tasks)@tanstack/cms-api:test:oxlintfails. core 619, api 207, client 35, store-postgres 102, store-libsql 64; every starter passes.pnpm test:dtspnpm test:dialectspnpm test:scriptsAssumptions (conservative defaults where the plan gives none)
uniquefield indexes. Writes stay strict./is accepted only on nested slug fields.reindexDocuments().ReadResult.locatoris computed from the redacted document, so a hidden slug isn't leaked.findDocumentsByLocatoris optional, and the storage contract stays atversion: 1.Divergence from plan
locatorStrategyor a localized slug's other locales. A SQL version of the check broke the scoped-slug starters.documentation-kbneeded alocatorStrategy, because its slugs repeat across versions.Seams for 3c(ii)
path():/{publicPrefix}/{locator}. The catch-all route callsget({ locator: params._splat }).createRouteschecks reserved route keys againstfindDocumentsByLocatorat boot and on write.documentLocatorson the stored row, and the new ones fromdenormalize(...).locators. A difference between the two is where a redirect gets written.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.
Ten files conflicted, resolved as in the rehearsal: the docs,
ops.ts,internal.ts,review.ts,verbs.ts, the starters' runtime configs, and the migrations. The migrations go in the order SQLite v16 then v17, and Postgres v8 then v9.These changes had no textual conflict but were still needed:
suffixGeneratedSlugin 4b's staging prep indocument-state.ts;locatorStrategyin the two starters'cms.definition.ts;/definitionexport ofLocatorInputandLocatorStrategy;Its upgrading section is step 29.
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.