/** @file Vertical extraction types. */ import type { ExtractorCapability, SourceReference } from "../../types.ts"; export interface VerticalExtractorPage { text: string; finalUrl: string; status: number; contentType?: string; html?: string; requestedUrl?: string; } export interface VerticalExtractorProgress { state: string; message?: string; url?: string; } export interface VerticalExtractorContext { /** Manifest-level options passed into primitive extractors (e.g. code-extract). */ manifest?: Record; /** @deprecated Use manifest */ recipe?: Record; fetchJson(url: string, signal?: AbortSignal): Promise; fetchJsonPost?(url: string, body: unknown, signal?: AbortSignal): Promise; /** * Generic fetch with method, headers, and body support. Used by declarative manifests with custom * HTTP method/headers/body templates. */ fetch?( url: string, opts?: { method?: "GET" | "POST" | "PUT" | "DELETE"; headers?: Record; body?: string; }, signal?: AbortSignal, ): Promise<{ data: unknown; status: number }>; fetchText?(url: string, signal?: AbortSignal): Promise; fetchPage?(url: string, signal?: AbortSignal): Promise; emitProgress?(options: VerticalExtractorProgress): void | Promise; } export interface VerticalExtractionResult { extractor: string; url: string; data?: T; sources?: SourceReference[]; error?: { code: string; message: string; retryable: boolean }; } export interface VerticalExtractor { capability: ExtractorCapability; match(url: URL): Record | undefined; extract( url: URL, match: Record, context: VerticalExtractorContext, signal?: AbortSignal, ): Promise; }