SPB Git

Repository Public

types.ts 7.1 KB 234 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : UQO Éval — Le Grand Défi Immobilier8 * File             : packages/engine/src/types.ts9 * Module           : engine10 * Repository       : https://git.spboucher.ai/uqo-eval-jeux11 * Project Website  : https://jeux.uqo-eval.app12 * Created          : 2026-11-2513 * Last Modified    : 2026-11-2514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243/** Types partagés par les moteurs, l'API et l'interface. */4445/** Ligne brute de la base d'inscriptions (lecture seule, jamais modifiée). */46export interface RawListing {47  uid: string;48  source: string;49  title: string | null;50  address: string | null;51  sector: string | null;52  city: string | null;53  region: string | null;54  property_type: string | null;55  price: number | null;56  bedrooms: number | null;57  bathrooms: number | null;58  powder_rooms: number | null;59  area_sqft: number | null;60  lot_sqft: number | null;61  year_built: number | null;62  mls: string | null;63  description: string | null;64  details: string | null;65  images: string | null;66  lat: number | null;67  lng: number | null;68  first_seen: number | null;69  last_seen: number | null;70  updated_at: number | null;71  /** Données du rôle d'évaluation foncière jointes à l'inscription (JSON). */72  assessment_json: string | null;73  quality_score: number | null;74  dup_hidden: number | null;75  dup_of: string | null;76  active: number | null;77  published: number | null;78}7980export interface RawPricePoint {81  ts: number;82  price: number;83}8485export const CATEGORIES = [86  "unifamiliale",87  "jumele",88  "rangee",89  "condo",90  "plex",91  "chalet",92  "mobile",93  "fermette",94] as const;95export type Category = (typeof CATEGORIES)[number];9697export const CATEGORY_LABELS: Record<Category, string> = {98  unifamiliale: "Maison unifamiliale",99  jumele: "Maison jumelée",100  rangee: "Maison en rangée",101  condo: "Copropriété",102  plex: "Plex",103  chalet: "Chalet",104  mobile: "Maison mobile",105  fermette: "Fermette",106};107108export const CATEGORY_PLURALS: Record<Category, string> = {109  unifamiliale: "maisons unifamiliales",110  jumele: "maisons jumelées",111  rangee: "maisons en rangée",112  condo: "copropriétés",113  plex: "plex",114  chalet: "chalets",115  mobile: "maisons mobiles",116  fermette: "fermettes",117};118119export interface Assessment {120  total: number;121  land: number | null;122  building: number | null;123  year: number | null;124}125126export interface PricePoint {127  /** Date ISO (jour) de l'observation. */128  date: string;129  price: number;130}131132/** Propriété normalisée : uniquement des renseignements réellement présents à la source. */133export interface NormalizedProperty {134  sourceUid: string;135  source: string;136  category: Category;137  /** Précision du type lorsque la source la fournit (ex. « Plain-pied (bungalow) », « Triplex »). */138  subtype: string | null;139  municipality: string;140  municipalityCode: string | null;141  sector: string | null;142  regionCode: string | null;143  regionName: string | null;144  mrc: string | null;145  price: number;146  /** Date ISO de la dernière observation du prix affiché. */147  priceObservedAt: string;148  firstSeenAt: string | null;149  priceHistory: PricePoint[];150  bedrooms: number | null;151  bathrooms: number | null;152  powderRooms: number | null;153  livingAreaSqft: number | null;154  lotAreaSqft: number | null;155  yearBuilt: number | null;156  rooms: number | null;157  floors: number | null;158  unitFloor: string | null;159  garage: string | null;160  pool: string | null;161  basement: string | null;162  heating: string | null;163  heatingEnergy: string | null;164  siding: string | null;165  roofing: string | null;166  foundation: string | null;167  windows: string | null;168  parking: string | null;169  view: string | null;170  waterfront: string | null;171  siteFeatures: string | null;172  fireplace: string | null;173  condoFeesYearly: number | null;174  annualRevenue: number | null;175  municipalTaxes: number | null;176  assessment: Assessment | null;177  description: string | null;178  imageUrls: string[];179  lat: number | null;180  lng: number | null;181  qualityScore: number;182  dedupeKeys: string[];183}184185export type RejectionReason =186  | "inactive"187  | "duplicate_flag"188  | "excluded_source"189  | "unknown_type"190  | "not_for_sale"191  | "price_missing"192  | "price_out_of_range"193  | "price_incoherent"194  | "no_municipality"195  | "low_quality"196  | "implausible_data";197198export type NormalizeResult =199  | { ok: true; property: NormalizedProperty }200  | { ok: false; reason: RejectionReason; detail?: string };201202export const DIFFICULTIES = ["initiation", "intermediaire", "avance", "expert"] as const;203export type Difficulty = (typeof DIFFICULTIES)[number];204205export const DIFFICULTY_LABELS: Record<Difficulty, string> = {206  initiation: "Initiation",207  intermediaire: "Intermédiaire",208  avance: "Avancé",209  expert: "Expert",210};211212export const PHASES = [213  { phase: 1, name: "Découverte", difficulty: "initiation" },214  { phase: 2, name: "Analyse", difficulty: "intermediaire" },215  { phase: 3, name: "Expertise", difficulty: "avance" },216  { phase: 4, name: "Maîtrise", difficulty: "expert" },217] as const satisfies readonly { phase: number; name: string; difficulty: Difficulty }[];218219export const PRICE_BANDS = [220  { key: "moins-300", label: "Moins de 300 000 $", min: 0, max: 300_000 },221  { key: "300-450", label: "300 000 $ à 450 000 $", min: 300_000, max: 450_000 },222  { key: "450-650", label: "450 000 $ à 650 000 $", min: 450_000, max: 650_000 },223  { key: "650-1000", label: "650 000 $ à 1 000 000 $", min: 650_000, max: 1_000_000 },224  { key: "plus-1000", label: "Plus de 1 000 000 $", min: 1_000_000, max: Number.POSITIVE_INFINITY },225] as const;226export type PriceBandKey = (typeof PRICE_BANDS)[number]["key"];227228export function priceBandOf(price: number): (typeof PRICE_BANDS)[number] {229  return PRICE_BANDS.find((b) => price >= b.min && price < b.max) ?? PRICE_BANDS[PRICE_BANDS.length - 1]!;230}231232export const COURSES = ["IMM1003", "IMM1033"] as const;233export type Course = (typeof COURSES)[number];234
Files main
Menu

Theme