← back to Nationalrealestate

src/ingest/brokers/types.ts

37 lines

/**
 * State licensing-roster adapter contract (M-B1). Each adapter wraps ONE state's
 * genuinely-open bulk download (no portals, no sessions) and yields normalized rows.
 * `kind:'firm'` rows are brokerage entities (companies/partnerships); `kind:'broker'`
 * rows are individual licensees (brokers AND salespersons — license_type records which).
 */
export interface BrokerRow {
  kind: 'firm' | 'broker';
  name: string;
  license_no: string | null;
  license_type: string | null;
  license_status: string | null;
  /** broker rows only: sponsoring/employing firm as printed in the roster */
  firm_name?: string | null;
  firm_license_no?: string | null;
  email?: string | null;
  phone?: string | null;
  city?: string | null;
  state_code?: string | null;
}

export interface FetchedFile {
  path: string;
  sha256: string;
}

export interface StateAdapter {
  /** 2-letter licensing state, e.g. 'TX' — becomes license_state + region 'state:XX' */
  state: string;
  /** provenance source key, e.g. 'tx_trec' — becomes broker.source / firm.source */
  source: string;
  /** primary URL recorded on the ingest_runs row */
  url: string;
  fetch(): Promise<FetchedFile[]>;
  parse(files: FetchedFile[]): Generator<BrokerRow>;
}