openreader/compute-worker/tests/compute/algorithms/support/document-fixtures.ts
Richard R 3d5dfd2a88 refactor(compute-worker): migrate compute logic to modular architecture
- Remove legacy compute-worker monolith under `src/compute/`, including PDF and Whisper inference, control-plane, and runtime orchestration
- Move PDF and Whisper inference logic to new `src/inference/` module
- Move control-plane, orchestrator, and state machine logic to `src/operations/`
- Move NATS/JetStream adapters to `src/infrastructure/`
- Move job orchestration, progress, and artifact persistence to `src/jobs/`
- Update imports throughout tests and main app to reference new module structure
- Update Dockerfile and scripts to use new asset paths
- Add new entrypoints: `src/api/app.ts` and `src/api/contracts.ts`
- Remove obsolete files and update `.gitignore` for new dev artifacts

This refactor modularizes the compute-worker, improving maintainability and separation of concerns. No functional changes to inference or orchestration logic.

BREAKING CHANGE: compute-worker internal APIs, directory structure, and imports have changed; downstream code must update imports and integration points.
2026-06-12 14:07:15 -06:00

54 lines
1.2 KiB
TypeScript

import type { BaseDocument } from '../../../../../src/types/documents';
import type { ParsedPdfBlock, ParsedPdfBlockKind, ParsedPdfDocument, ParsedPdfPage } from '../../../../src/inference/types';
export function makeBaseDocument(overrides: Partial<BaseDocument> = {}): BaseDocument {
return {
id: 'doc-1',
name: 'document.pdf',
size: 1_024,
lastModified: 1_700_000_000_000,
type: 'pdf',
...overrides,
};
}
export function makeParsedPdfBlock(input: {
id: string;
kind: ParsedPdfBlockKind;
text: string;
page: number;
readingOrder: number;
}): ParsedPdfBlock {
return {
id: input.id,
kind: input.kind,
text: input.text,
fragments: [
{
page: input.page,
bbox: [0, 0, 100, 10],
text: input.text,
readingOrder: input.readingOrder,
},
],
};
}
export function makeParsedPdfPage(pageNumber: number, blocks: ParsedPdfBlock[]): ParsedPdfPage {
return {
pageNumber,
width: 800,
height: 1_200,
blocks,
};
}
export function makeParsedPdfDocument(pages: ParsedPdfPage[]): ParsedPdfDocument {
return {
schemaVersion: 1,
documentId: 'doc-fixture',
parserVersion: 'test',
parsedAt: 1_700_000_000_000,
pages,
};
}