import type { BatchReprocessStatus, BatchTranscriber, CommonTranscriber, WhisperCapableTranscriber, } from "../src/SofyaTranscriber"; type CreateTranscriber = typeof import("../src/SofyaTranscriber").createTranscriber; const createTranscriber = null as unknown as CreateTranscriber; describe("createTranscriber typings", () => { it("narrows batch reprocess capability to whisper providers", () => { if (false) { const whisper = createTranscriber({ provider: "sofya_as_service", endpoint: "wss://scribe.sofya.health/api/realtime", config: { language: "en-US", batchReprocess: { parseResponse: async () => ({ transcript: "ok" }), }, }, }); const whisperTyped: WhisperCapableTranscriber<{ transcript: string }> = whisper; const batchStatus: BatchReprocessStatus = whisper.getBatchReprocessStatus(); void whisperTyped; void batchStatus; void whisper.reprocessAudio(); void whisper.getBatchReprocessRemainingTime(); const apiKey = createTranscriber({ apiKey: "demo-key", config: { language: "en-US", batchReprocess: { endpoint: "https://scribe.sofya.health/api/transcriber", }, }, }); const apiKeyCommon: CommonTranscriber = apiKey; void apiKeyCommon; // @ts-expect-error apiKey connections do not promise batch reprocess capability apiKey.reprocessAudio(); // @ts-expect-error apiKey connections do not promise batch TTL access apiKey.getBatchReprocessRemainingTime(); const oracle = createTranscriber({ provider: "oracle", endpoint: "https://oracle.example.com", config: { language: "en-US", token: "token", compartmentId: "compartment", region: "us-ashburn-1", }, }); const oracleCommon: CommonTranscriber = oracle; void oracleCommon; // @ts-expect-error non-whisper providers do not expose batch status in the typed factory result oracle.getBatchReprocessStatus(); // @ts-expect-error non-whisper providers do not expose batch TTL access in the typed factory result oracle.getBatchReprocessRemainingTime(); createTranscriber({ provider: "sofya_compliance", endpoint: "https://oracle.example.com", config: { language: "en-US", token: "token", compartmentId: "compartment", region: "us-ashburn-1", // @ts-expect-error non-whisper configs do not expose batch reprocess overrides batchReprocess: { endpoint: "https://scribe.sofya.health/api/transcriber", }, }, }); } expect(true).toBe(true); }); it("narrows primary batch mode to a stop-returning batch transcriber", () => { if (false) { const batch = createTranscriber({ provider: "sofya_as_service", mode: "batch", endpoint: "https://scribe.sofya.health/api/transcriber", config: { language: "en-US", token: "token", batch: { parseResponse: async () => ({ transcript: "ok" }), }, }, }); const batchTyped: BatchTranscriber<{ transcript: string }> = batch; void batchTyped; void batch.stopTranscription().then((payload) => payload.transcript); batch.pauseTranscription(); batch.resumeTranscription(); // @ts-expect-error batch mode does not expose realtime batch reprocess batch.reprocessAudio(); // @ts-expect-error batch mode does not expose realtime batch TTL access batch.getBatchReprocessRemainingTime(); const realtime = createTranscriber({ provider: "sofya_as_service", endpoint: "wss://scribe.sofya.health/api/realtime", config: { language: "en-US", }, }); const realtimeTyped: WhisperCapableTranscriber = realtime; void realtimeTyped; void realtime.stopTranscription().then((payload) => payload); createTranscriber({ provider: "oracle", // @ts-expect-error non-whisper providers do not support batch mode mode: "batch", endpoint: "https://oracle.example.com/api/transcriber", config: { language: "en-US", token: "token", compartmentId: "compartment", region: "us-ashburn-1", }, }); createTranscriber({ apiKey: "demo-key", // @ts-expect-error apiKey discovery does not support batch mode yet mode: "batch", // @ts-expect-error apiKey discovery does not support batch mode yet config: { language: "en-US", }, }); } expect(true).toBe(true); }); });