Skip to content

feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed - #537

Merged
Ardnived merged 8 commits into
mainfrom
feat/regions-events-webpath
Jul 5, 2026
Merged

Ardnived merged 8 commits into
mainfrom
feat/regions-events-webpath

Conversation

@Ardnived

@Ardnived Ardnived commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Regions, Events, and Pages now expose a consistent trio of server-computed public link fields — webPath (canonical path), webUrl (path + web host), appUrl (path + app scheme) — all computed on read and published-gated. For the Atlas, webPath is 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, no depth:2 reads, no redirect flash.
  • Event webUrl is 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/geojson exposes webPath/webUrl per feature, selectable on their own.

Changes

  • src/fields/publicUrlFields.ts — one factory now emits the fixed webPath/webUrl/appUrl trio from a single buildPath, published-gated (requirePublished, default true; Regions pass false — 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 bounded regions query builds an id → path map 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 Regions eventDefaultsFallback afterRead. 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 — call publicUrlFields with their buildPath (Region = its own path; Event = region path + /<id>).
  • src/collections/Events/hooks/ensureWebPathDeps.ts — beforeOperation hook that re-adds region / _status to an include-mode select when a path field is requested, so webPath/webUrl resolve on any event read (list, findByID, geojson), not just the feed.

Test Results

  • Integration (targeted): regions + events-geojson + event-verification + pages — all pass
  • Unit: 643 passed · Lint ✓ · Typecheck ✓
  • No migration (fields are virtual: true — no DB columns)

Notes for reviewer

  • No migration / backfill: the link fields are virtual, computed at read time from the breadcrumbs the nested-docs plugin already maintains — not a re-implemented region hierarchy.
  • appUrl is always emitted but null for Events/Regions (there's no Atlas app deep-link base) — a deliberate "same three fields everywhere" shape.
  • The resolver reads all regions once per request with overrideAccess: true (region slugs are globally-unique public routing keys) and a re-entrancy guard so eventDefaultsFallback can't trigger a per-ancestor re-scan.
  • Event webUrl semantics 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 production SAHAJATLAS_URL is the intended target.

Closes #530

🤖 Generated with Claude Code

Ardnived and others added 4 commits July 5, 2026 11:13
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]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-537 July 5, 2026 10:36 Destroyed
@railway-app

railway-app Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-537 environment in sahajcloud

Service Status Web Updated (UTC)
SahajCloud ✅ Success (View Logs) Web Jul 5, 2026 at 1:31 pm

Ardnived and others added 4 commits July 5, 2026 13:09
`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]>
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-537 July 5, 2026 13:29 Destroyed
@Ardnived
Ardnived merged commit 00f994a into main Jul 5, 2026
2 checks passed
@Ardnived
Ardnived deleted the feat/regions-events-webpath branch July 5, 2026 13:45
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 branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-537 — 1fbc8435 Deployed Jul 5, 2026 by railway-app[bot]
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.

feat(regions,events): server-computed webPath/webUrl + webPath in geojson feed

1 participant