- Removed deprecated functions related to document parsing and blob storage in blobstore.ts. - Introduced new PDF rendering logic in pdf-preview-renderer.ts and pdf-preview-pdfjs-runtime.ts. - Updated previews-render.ts to utilize the new PDF rendering functions. - Refactored user-whisper-align-job.ts to use the compute-worker client for alignment requests. - Enhanced artifact.ts and operation.ts to validate parsed PDF artifacts and resolve current PDF parses. - Updated snapshot.ts to align with new worker operation types. - Adjusted runtime-config.ts to check for compute-worker availability. - Modified types in parsed-pdf.ts and tts.ts to reflect changes in the compute-worker protocol. - Added unit tests for PDF artifact validation and compute-worker client contract. - Removed obsolete pdf-op-key.vitest.spec.ts test file.
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import type { BaseDocument } from '../../../src/types/documents';
|
|
import type { ParsedPdfBlock, ParsedPdfBlockKind, ParsedPdfDocument, ParsedPdfPage } from '../../../../src/compute/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,
|
|
};
|
|
}
|