Caracterizacion del matching viejo de node-red en docs/legacy-matching.md (reglas: candidatas geo $near 1000km, filtro fino geolib dist/1000<=sub.distance, dedupe 500m, content i18n kmnasa/kmvecinal con 'км' cirilico verbatim, sealed via Iron). Modulos: - matcher/content.ts: i18n kmnasa/kmvecinal + km redondeado (Math.round dist/1000*10/10) - matcher/geo.ts: geolib.getDistance (identico al viejo) + isHit - matcher/seal.ts: @hapi/iron (Fe26.2) — COMPATIBLE con el iron@5 de la web (verificado: sello en servicio -> unseal en web round-trip OK) - matcher/matcher.ts: matchFire(fire, ctx) -> docs notifications identicos a node-red; dedupe 500m + 1 notif/usuario/fuego; solo audiencia web/mobile - deps: @hapi/iron, geolib 63 tests en verde (incluye interop CJS/ESM en dist). MongoDB 3.2 -> ingesta por polling (sin change streams), pendiente de cablear.
27 lines
826 B
TypeScript
27 lines
826 B
TypeScript
import type { ObjectId } from 'mongodb';
|
|
|
|
/** A document in `activefires` (see docs/legacy-matching.md §1). */
|
|
export interface FireDoc {
|
|
_id: ObjectId;
|
|
ourid?: { type: 'Point'; coordinates: [number, number] }; // [lon, lat]
|
|
lat: number;
|
|
lon: number;
|
|
when: Date;
|
|
type: 'modis' | 'viirs' | 'vecinal' | string;
|
|
createdAt?: Date;
|
|
updatedAt?: Date;
|
|
fireUnion?: ObjectId;
|
|
[k: string]: unknown; // other NASA fields (acq_date, frp, confidence, ...)
|
|
}
|
|
|
|
/** A document in `subscriptions`. */
|
|
export interface SubscriptionDoc {
|
|
_id: ObjectId;
|
|
location: { lat: number; lon: number };
|
|
geo: { type: 'Point'; coordinates: [number, number] }; // [lon, lat]
|
|
distance: number; // radius in km
|
|
owner: string; // userId
|
|
type: 'web' | 'mobile' | 'telegram' | string;
|
|
chatId?: number;
|
|
telegramBot?: string;
|
|
}
|