/** * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * Project: Groupe Ka / Ka Maps * * Per-app layer registry. The framework defines the vocabulary of layers * (groups + ids); each app registers only what its data actually supports. * Unsupported layers stay declared-but-hidden so future datasets plug in * without touching the framework. */ import type { KaLayerDefinition } from "../types/index.js"; export const LAYER_GROUPS = { property: "Propriétés", market: "Marché", land: "Territoire", lifestyle: "Milieu de vie", investment: "Investissement", } as const; /** The full Ka Maps layer vocabulary. Apps pick from (or extend) this. */ export const KNOWN_LAYERS: KaLayerDefinition[] = [ { id: "for-sale", group: "property", label: "À vendre", supported: false }, { id: "for-rent", group: "property", label: "À louer", supported: false }, { id: "recently-sold", group: "property", label: "Vendues récemment", supported: false }, { id: "estimated-values", group: "property", label: "Valeurs estimées", supported: false }, { id: "median-price", group: "market", label: "Prix médian", supported: false }, { id: "price-per-sqft", group: "market", label: "Prix / pi²", supported: false }, { id: "yoy-change", group: "market", label: "Variation annuelle", supported: false }, { id: "inventory", group: "market", label: "Inventaire", supported: false }, { id: "days-on-market", group: "market", label: "Jours sur le marché", supported: false }, { id: "price-cuts", group: "market", label: "Baisses de prix", supported: false }, { id: "buildings", group: "land", label: "Bâtiments", supported: false }, { id: "lots", group: "land", label: "Lots", supported: false }, { id: "zoning", group: "land", label: "Zonage", supported: false }, { id: "admin-boundaries", group: "land", label: "Limites administratives", supported: false }, { id: "schools", group: "lifestyle", label: "Écoles", supported: false }, { id: "transit", group: "lifestyle", label: "Transport en commun", supported: false }, { id: "grocery", group: "lifestyle", label: "Épiceries", supported: false }, { id: "parks", group: "lifestyle", label: "Parcs", supported: false }, { id: "est-yield", group: "investment", label: "Rendement estimé", supported: false }, { id: "est-rent", group: "investment", label: "Loyer estimé", supported: false }, { id: "est-cashflow", group: "investment", label: "Flux de trésorerie estimé", supported: false }, ]; /** * Build an app's registry: mark the layers it supports (and optionally * activates by default); everything else stays declared but unsupported. */ export function buildLayerRegistry( supported: { id: string; defaultActive?: boolean }[], ): KaLayerDefinition[] { const byId = new Map(supported.map((s) => [s.id, s])); return KNOWN_LAYERS.map((layer) => { const s = byId.get(layer.id); return s ? { ...layer, supported: true, defaultActive: s.defaultActive ?? false } : { ...layer }; }); }