Restructure compute core by extracting job contracts and runtime logic into separate modules (`contracts.ts`, `local-runtime.ts`) for improved modularity and clearer API boundaries. Update exports and imports across worker, server, and local compute backends to use the new modules. Enhance Next.js config to support dynamic backend selection via build-time constants and aliasing, enabling seamless switching between local and worker compute modes. Adjust TypeScript paths and Dockerfile entrypoint to align with the new structure.
62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import type { TTSSentenceAlignment } from './types/tts';
|
|
import type { ParsedPdfDocument } from './types/parsed-pdf';
|
|
|
|
export type {
|
|
TTSAudioBuffer,
|
|
TTSAudioBytes,
|
|
TTSSentenceAlignment,
|
|
TTSSentenceWord,
|
|
} from './types/tts';
|
|
export type {
|
|
ParsedPdfBlockKind,
|
|
ParsedPdfBlockFragment,
|
|
ParsedPdfBlock,
|
|
ParsedPdfPage,
|
|
ParsedPdfDocument,
|
|
} from './types/parsed-pdf';
|
|
|
|
export const ALIGN_QUEUE_NAME = 'whisper-align';
|
|
export const PDF_LAYOUT_QUEUE_NAME = 'pdf-layout';
|
|
|
|
export interface WhisperAlignJobRequest {
|
|
text: string;
|
|
lang?: string;
|
|
cacheKey?: string;
|
|
audioObjectKey: string;
|
|
}
|
|
|
|
export interface WhisperAlignJobResult {
|
|
alignments: TTSSentenceAlignment[];
|
|
timing?: WorkerJobTiming;
|
|
}
|
|
|
|
export interface PdfLayoutJobRequest {
|
|
documentId: string;
|
|
namespace: string | null;
|
|
documentObjectKey: string;
|
|
}
|
|
|
|
export interface PdfLayoutJobResult {
|
|
parsed: ParsedPdfDocument;
|
|
timing?: WorkerJobTiming;
|
|
}
|
|
|
|
export type WorkerJobState = 'queued' | 'running' | 'succeeded' | 'failed';
|
|
|
|
export interface WorkerJobErrorShape {
|
|
message: string;
|
|
code?: string;
|
|
}
|
|
|
|
export interface WorkerJobTiming {
|
|
queueWaitMs?: number;
|
|
s3FetchMs?: number;
|
|
computeMs?: number;
|
|
}
|
|
|
|
export interface WorkerJobStatusResponse<Result> {
|
|
status: WorkerJobState;
|
|
result?: Result;
|
|
error?: WorkerJobErrorShape;
|
|
timing?: WorkerJobTiming;
|
|
}
|