Add ingestHtml and ingestMarkdown with ADR-0003 pageless offset semantics, PDF intrinsic metadata extraction with caller-wins merge (WP-0003), and citation recovery primitives including re-ingest reconcile, local quote search, and pluggable discovery hooks (ADR-0004). Mark all three workplans finished with contract tests (80 passing).
33 lines
No EOL
970 B
TypeScript
33 lines
No EOL
970 B
TypeScript
import type { Document, DocumentRepresentation } from "@citation-evidence/engine/shared";
|
|
|
|
import { reconcileFingerprint, type ReconcileResult } from "./reconcile";
|
|
|
|
export interface IngestOutcome {
|
|
readonly document: Document;
|
|
readonly representation: DocumentRepresentation;
|
|
}
|
|
|
|
export type IngestFn<TOptions = void> = (
|
|
bytes: Uint8Array,
|
|
options?: TOptions,
|
|
) => Promise<IngestOutcome>;
|
|
|
|
export interface ReIngestInput<TOptions = void> {
|
|
readonly previous: Document;
|
|
readonly bytes: Uint8Array;
|
|
readonly options?: TOptions;
|
|
}
|
|
|
|
export interface ReIngestResult {
|
|
readonly outcome: IngestOutcome;
|
|
readonly reconcile: ReconcileResult;
|
|
}
|
|
|
|
export async function reIngestAndCompare<TOptions>(
|
|
input: ReIngestInput<TOptions>,
|
|
ingest: IngestFn<TOptions>,
|
|
): Promise<ReIngestResult> {
|
|
const outcome = await ingest(input.bytes, input.options);
|
|
const reconcile = reconcileFingerprint(input.previous, outcome.document);
|
|
return { outcome, reconcile };
|
|
} |