import { z } from 'zod'; import { ManifestSchema } from './schemas/manifest.schema.js'; import { EvidenceError } from '../../lib/EvidenceError.js'; type FileContent = () => Promise; type QueryResultMeta = { columnTypes: { name: string; evidenceType: 'string' | 'number' | 'boolean' | 'date'; typeFidelity: 'precise' | 'inferred'; }[]; expectedRowCount?: number | undefined; }; type QueryResultData[] = Record[]> = { rows?: T; } & QueryResultMeta; type QueryResultUrl = { url: string; } & QueryResultMeta; export type QueryResult> = QueryResultData | QueryResultUrl; export type QueryResultTable[] = Record[]> = QueryResult & { name: string; content: string }; export interface SourceDirectory { [filename: string]: SourceDirectory | FileContent; } export type SourceUtils = { isCached: (name: string, content: string) => boolean; isFiltered: (name: string) => boolean; shouldRun: (name: string, content: string) => boolean; addToCache: (name: string, content: string) => void; subSourceVariables: (query: string) => string; escape: (tableName: string, tableContent: string) => QueryResultTable; }; export type ProcessSourceFn = Record> = ( opts: T, files: SourceDirectory, utils: SourceUtils ) => AsyncIterable; export type Manifest = z.infer; export type SourceFilters = { sources: Set | null; queries: Set | null; only_changed: boolean; };