Skip to content

Update provisioning to auto-detect forecast zones from AFP#1011

Open
rchlfryn wants to merge 8 commits intonav-updatesfrom
provisioning-updates
Open

Update provisioning to auto-detect forecast zones from AFP#1011
rchlfryn wants to merge 8 commits intonav-updatesfrom
provisioning-updates

Conversation

@rchlfryn
Copy link
Copy Markdown
Collaborator

@rchlfryn rchlfryn commented Mar 26, 2026

Description

Auto-detect single vs multi-zone avalanche centers from AFP data during provisioning, and create the appropriate zone-specific built-in pages. Non-forecast built-in pages are now sourced from DVAC's navigation rather than a hardcoded list, so changes to the template automatically propagate to new tenants. Mountain Weather is conditionally provisioned based on whether the center has weather forecasts configured in NAC.

Related Issues

Fixes #999

Key Changes

  • Zone-aware provisioningprovisionTenant.ts calls getActiveForecastZones() during provisioning. Single-zone centers get one "Avalanche Forecast" page; multi-zone centers get "All Forecasts" + per-zone pages sorted by rank. Falls back to a default "All Forecasts" page if AFP is unavailable.
  • DVAC as source of truth for non-forecast built-in pages — Instead of a hardcoded BUILT_IN_PAGES list, non-forecast pages (weather stations, observations, blog, events, etc.) are extracted directly from DVAC's resolved navigation (depth: 1). extractNavReferences now returns { title, url } pairs so no separate DB query is needed.
  • Mountain Weather from NAC — Mountain Weather (/weather/forecast) is no longer sourced from DVAC's nav. It's conditionally included based on whether the center has platforms.weather enabled in NAC.
  • Zone-aware navigation — Provisioning now populates the forecasts tab (single zone: direct link; multi-zone: "All Forecasts" + per-zone items) and the observations tab with built-in page links. Also adds missing blog and events tab data that was causing nav creation to silently fail.
  • Split checklist items — "Built-in pages" in the onboarding checklist is now two items: "Forecast Built-In pages" and "Default Built-In pages", each with their own count.
  • Shared resolveBuiltInPages function — Deduplicates the AFP query + page resolution logic between provisionTenant.ts and onboardingActions.ts.

How to test

  1. Run pnpm seed to seed the database
  2. Go to /admin/collections/tenants and create a new tenant (e.g. name: "Test Center", slug: "btac")
  3. Verify the onboarding checklist shows separate "Forecast Built-In pages" and "Default Built-In pages" counts
    • For a multi-zone center like btac (4 zones), verify "All Forecasts" + 4 zone pages are created as built-in pages
    • For a single-zone center like msac), verify a single "Avalanche Forecast" built-in page is created
  4. Verify Mountain Weather is only created for centers with weather forecasts in NAC
  5. Verify navigation is created with forecast zone links populated
  6. Run pnpm test — all 289 tests pass

Screenshots / Demo video

https://www.loom.com/share/0563513b68564b3d8265cdba9ec9519b

Migration Explanation

No new migrations in this PR's scope (provisioning changes only).

Future enhancements / Questions

  • The onboarding status check calls AFP on every checklist load — could cache the zone count if this becomes a performance concern (likely not)

@rchlfryn rchlfryn self-assigned this Mar 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Preview deployment: https://provisioning-updates.preview.avy-fx.org

@rchlfryn rchlfryn marked this pull request as ready for review March 26, 2026 18:50
@rchlfryn rchlfryn requested a review from busbyk March 26, 2026 18:50
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.

1 participant