Repository navigation
feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed - #537
Merged
Merged
Conversation
Expose virtual `webPath` (the ordered ancestor slug chain incl. self, e.g.
`/belgium/flanders/antwerp`) and `webUrl` (that path joined to SAHAJATLAS_URL)
on Regions, and on Events as the region path + `/<id>`. Both are computed on
read from a per-request region path map (`getRegionWebPaths`) built in a single
`regions` query from each region's nested-docs breadcrumb chain + current slugs
— no hierarchy re-derivation, no stored path, so a slug/ancestry change is
reflected on the next read with no backfill.
The event `webUrl` (previously the interim `${WEMEDITATE_WEB_URL}/map#/!/events/
<id>` map link from #395) is repointed to the canonical Atlas URL; its
published gate is preserved, so verify/reminder links stay null on unpublish.
The geojson feed injects `region` (and `_status` for `webUrl`) into a client's
`select` when a path field is requested, so per-point navigation targets resolve
without the caller having to select the fields those computed values derive from.
Closes #530
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- regions: full ancestor slug chain, region-optional (country→city) shape, webUrl = webPath joined to the Atlas host, and read-time recompute after an ancestor slug rename. - events: canonical webPath/webUrl for a published event; webPath kept but webUrl nulled while unpublished (replaces the old map-link assertion). - geojson: webPath/webUrl exposed in feature properties even when the caller selects only the path field (region/_status injected). Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per the /simplify pass: - Move the `region`/`_status` select-injection out of the geojson endpoint into an `ensureWebPathDeps` beforeOperation hook on Events, so `webPath`/`webUrl` stay selectable on their own across every read path (list, findByID, geojson), not just the feed — the endpoint-only version was a bandaid. - regionWebPaths: drop an unreachable `[id]` fallback in `breadcrumbChainIds` and document why the slug/path build needs two passes. - atlasWebFields: resolve the trailing-slash-trimmed Atlas host once at config build instead of per read. Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Restore the `[id]` collapse in breadcrumbChainIds for the case the /simplify pass wrongly called unreachable: a non-empty breadcrumb trail whose docs all resolve to null (corrupt/transient data) now falls back to the region's own globally-unique slug instead of dropping it from the path map (silent null webPath/webUrl). Per /code-review. Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-537 environment in sahajcloud
|
`webPath` and `webUrl` are the same computation — one path, with the URL just prefixing a base — so drive both from publicUrlFields' existing `buildPath` instead of a parallel factory. Two additive options make it reusable for the Atlas case: - `pathName` — also emit the raw `buildPath` result as a path-only field (`webPath`), no base. - `requirePublished` (default true) — opt out of the publish gate for collections with no `_status` (Regions), which would otherwise read as "not published" and null every field. Regions/Events now call `publicUrlFields` directly (buildPath calls the kept `getRegionWebPaths` resolver); `atlasWebFields.ts` is deleted. Event `webPath` is now published-gated alongside `webUrl` (a draft exposes neither) — its test is updated. Pages' `webUrl`/`appUrl` are unchanged (gate defaults on). Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Every collection now exposes the same three published-gated link fields from one buildPath — no per-call field-name or output config. Drops webName / appName / pathName; keeps only requirePublished (the one flag a field hook can't infer, since it can't tell "no _status column" from "_status deselected"). - webPath — the raw buildPath result (no base). - webUrl — web base + path (null when no web base). - appUrl — app base + path (null when no app base). Pages gains webPath; Events/Regions gain a (null) appUrl — no Atlas app deep-link. Regions stay ungated via requirePublished: false. Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The exported const bought little: it's used by two collections that can read the validated env directly, and it put a base-URL concern in a path-resolution module. Its trailing-slash trim guarded a case nothing else in the codebase guards (AtlasMapView, the verify page, and the old event webUrl all assume these URL env vars have no trailing slash), so drop it too. Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Replace `data?.id as number` casts in the Regions/Events buildPath closures with proper type narrowing. - Note the RESOLVING_FLAG ↔ eventDefaultsFallback context-spread coupling at its load-bearing site so a future edit doesn't silently reintroduce the per-ancestor re-scan. Refs #530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Jul 5, 2026
…olver The `RESOLVING_FLAG` re-entrancy guard existed solely to stop the removed `eventDefaultsFallback` afterRead hook — whose selectless nested `regions` read returned full docs and re-triggered the webPath field hooks — from making the resolver re-scan the tree per ancestor. With that hook gone, the resolver is protected by its own narrow `select` (slug + breadcrumbs only, so webPath/webUrl field hooks never run on its results) plus the identity-keyed per-request memo. Remove the flag, the context clone, and the short-circuit; #537's webPath integration tests still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Jul 5, 2026
* chore(regions): remove region-level event defaults feature The `eventDefaults` group (language + timeZone) on Regions and its `eventDefaultsFallback` afterRead inheritance hook were unconsumed — nothing in this app or the Atlas client read the inherited values, yet the per-read ancestor query fired on every region read (and, on the feat/regions-events-webpath branch, forwarded the client `req` without a `select`, 400-ing client reads that populated a region). Remove the field group + admin UI, the afterRead hook, the seed importer's `buildEventDefaults` wiring (+ orphaned legacy `defaultLanguageCode`), the now-unused `getTimezoneOptions` helper, and the associated tests. `SUPPORTED_TIMEZONES` stays (the schedule field's `timezone: true` companions use it); its unit test is repointed there. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * chore(migrations): drop region eventDefaults columns/table/enums Drops the schema objects the removed Regions `eventDefaults` group created: the `regions.event_defaults_language` column + its enum, and the `regions_event_defaults_time_zone` table (+ FK/indexes) + its enum. Reversible `down()` recreates them. Pairs with the field/hook removal in the preceding commit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * refactor(atlas): drop now-dead RESOLVING_FLAG from region webpath resolver The `RESOLVING_FLAG` re-entrancy guard existed solely to stop the removed `eventDefaultsFallback` afterRead hook — whose selectless nested `regions` read returned full docs and re-triggered the webPath field hooks — from making the resolver re-scan the tree per ancestor. With that hook gone, the resolver is protected by its own narrow `select` (slug + breadcrumbs only, so webPath/webUrl field hooks never run on its results) plus the identity-keyed per-request memo. Remove the flag, the context clone, and the short-circuit; #537's webPath integration tests still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Jul 5, 2026
This branch was successfully deployed
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.
Summary
webPath(canonical path),webUrl(path + web host),appUrl(path + app scheme) — all computed on read and published-gated. For the Atlas,webPathis the region's ancestor slug chain (e.g./belgium/flanders/antwerp/downtown-hall/12345), so the widget navigates to final URLs directly — no client-side breadcrumb walking, nodepth:2reads, no redirect flash.webUrlis repointed from the interim${WEMEDITATE_WEB_URL}/map#/!/events/<id>map link to the canonical Atlas URL; the published gate is preserved, so verify/reminder links stay null on unpublish.GET /api/events/geojsonexposeswebPath/webUrlper feature, selectable on their own.Changes
src/fields/publicUrlFields.ts— one factory now emits the fixedwebPath/webUrl/appUrltrio from a singlebuildPath, published-gated (requirePublished, defaulttrue; Regions passfalse— they have no_status).webPath= raw path;webUrl/appUrl= path prefixed with the web/app base (null when that base isn't configured).src/lib/atlas/regionWebPaths.ts—getRegionWebPaths(req): one boundedregionsquery builds anid → pathmap from each region's nested-docs breadcrumb chain + current slugs, memoized per request (the whole geojson feed pays for one query), with a re-entrancy guard against the RegionseventDefaultsFallbackafterRead. Read-time, so a slug/ancestry change is reflected on the next read — no stored path, no backfill.src/collections/Regions/Regions.ts,src/collections/Events/Events.ts— callpublicUrlFieldswith theirbuildPath(Region = its own path; Event = region path +/<id>).src/collections/Events/hooks/ensureWebPathDeps.ts— beforeOperation hook that re-addsregion/_statusto an include-modeselectwhen a path field is requested, sowebPath/webUrlresolve on any event read (list, findByID, geojson), not just the feed.Test Results
regions+events-geojson+event-verification+pages— all passvirtual: true— no DB columns)Notes for reviewer
appUrlis always emitted but null for Events/Regions (there's no Atlas app deep-link base) — a deliberate "same three fields everywhere" shape.overrideAccess: true(region slugs are globally-unique public routing keys) and a re-entrancy guard soeventDefaultsFallbackcan't trigger a per-ancestor re-scan.webUrlsemantics changed (WeMeditate map → Atlas host + hierarchical path); the verify "View event" button and ExpireEvents reminder emails now link to the canonical Atlas URL. Confirm the productionSAHAJATLAS_URLis the intended target.Closes #530
🤖 Generated with Claude Code