@audialize/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -0
- package/dist/index.cjs +648 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +278 -0
- package/dist/index.d.ts +278 -0
- package/dist/index.js +626 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/http/errors.ts","../src/http/HttpClient.ts","../src/workflows/JobPoller.ts","../src/resources/jobs.ts","../src/resources/languages.ts","../src/resources/subtitles.ts","../src/utils/retry.ts","../src/utils/multipart.ts","../src/resources/files.ts","../src/workflows/localize.ts","../src/client.ts"],"names":["delay","eventListeners"],"mappings":";;;AAAO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EACxB,IAAA;AAAA,EAEhB,WAAA,CAAY,SAAiB,IAAA,EAAc;AACzC,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAEO,IAAM,iBAAA,GAAN,cAAgC,cAAA,CAAe;AAAA,EACpC,UAAA;AAAA,EACA,SAAA;AAAA,EAEhB,WAAA,CAAY,OAAA,EAAiB,IAAA,EAAc,UAAA,EAAoB,SAAA,EAAoB;AACjF,IAAA,KAAA,CAAM,SAAS,IAAI,CAAA;AACnB,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AACF;AAEO,IAAM,mBAAA,GAAN,cAAkC,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,SAAiB,SAAA,EAAoB;A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AAA,GAAO,IAAI,UAAA,CAAW,WAAW,CAAA;AAEtC,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,YAAA,CAAa,IAAA,CAAK,IAAI,CAAA;AACtC,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AAChD,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AAChD,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,SAAS,OAAA,EAAwC;AAC5D,IAAA,OAAO,QAAA,CAAS,MAAM,OAAO,CAAA;AAAA,EAC/B;AACF","file":"index.cjs","sourcesContent":["export class AudiolizeError extends Error {\n public readonly code: string;\n\n constructor(message: string, code: string) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class AudiolizeApiError extends AudiolizeError {\n public readonly statusCode: number;\n public readonly requestId?: string | undefined;\n\n constructor(message: string, code: string, statusCode: number, requestId?: string) {\n super(message, code);\n this.statusCode = statusCode;\n this.requestId = requestId;\n }\n}\n\nexport class AuthenticationError extends AudiolizeApiError {\n constructor(message: string, requestId?: string) {\n super(message, 'AUTHENTICATION_ERROR', 401, requestId);\n }\n}\n\nexport class AuthorizationError extends AudiolizeApiError {\n constructor(message: string, requestId?: string) {\n super(message, 'AUTHORIZATION_ERROR', 403, requestId);\n }\n}\n\nexport class NotFoundError extends AudiolizeApiError {\n constructor(message: string, requestId?: string) {\n super(message, 'NOT_FOUND_ERROR', 404, requestId);\n }\n}\n\nexport class RateLimitError extends AudiolizeApiError {\n public readonly retryAfter?: number | undefined;\n\n constructor(message: string, retryAfter?: number, requestId?: string) {\n super(message, 'RATE_LIMIT_ERROR', 429, requestId);\n this.retryAfter = retryAfter;\n }\n}\n\nexport class PaywallError extends AudiolizeApiError {\n constructor(message: string, requestId?: string) {\n super(message, 'PAYWALL_ERROR', 402, requestId);\n }\n}\n\nexport class ServerError extends AudiolizeApiError {\n constructor(message: string, statusCode: number, requestId?: string) {\n super(message, 'SERVER_ERROR', statusCode, requestId);\n }\n}\n\nexport class AudiolizeUploadError extends AudiolizeError {\n constructor(message: string) {\n super(message, 'UPLOAD_ERROR');\n }\n}\n\nexport class AudiolizeTimeoutError extends AudiolizeError {\n constructor(message: string) {\n super(message, 'TIMEOUT_ERROR');\n }\n}\n\nexport class AudiolizeValidationError extends AudiolizeError {\n constructor(message: string) {\n super(message, 'VALIDATION_ERROR');\n }\n}\n","import {\n AudiolizeApiError,\n AudiolizeTimeoutError,\n AuthenticationError,\n AuthorizationError,\n NotFoundError,\n PaywallError,\n RateLimitError,\n ServerError,\n} from './errors';\n\nexport interface HttpClientOptions {\n apiKey: string;\n baseUrl?: string;\n timeout?: number;\n maxRetries?: number;\n fetch?: typeof fetch;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly fetchImpl: typeof fetch;\n\n constructor(options: HttpClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || 'https://api.audialize.com';\n this.timeout = options.timeout || 30000;\n this.maxRetries = options.maxRetries ?? 3;\n this.fetchImpl = options.fetch || globalThis.fetch.bind(globalThis);\n }\n\n public async request<T>(path: string, options: RequestInit = {}): Promise<T> {\n const url = new URL(path, this.baseUrl).toString();\n const headers = new Headers(options.headers);\n \n headers.set('Authorization', `Bearer ${this.apiKey}`);\n if (!headers.has('Content-Type') && options.body && typeof options.body === 'string') {\n headers.set('Content-Type', 'application/json');\n }\n\n let attempt = 0;\n while (attempt <= this.maxRetries) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n const response = await this.fetchImpl(url, {\n ...options,\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (response.ok) {\n if (response.status === 204) {\n return {} as T;\n }\n return (await response.json()) as T;\n }\n\n await this.handleErrorResponse(response);\n } catch (error: unknown) {\n if (error instanceof AudiolizeApiError) {\n if (error instanceof RateLimitError && attempt < this.maxRetries) {\n const delayMs = error.retryAfter ? error.retryAfter * 1000 : this.getBackoffDelay(attempt);\n await this.delay(delayMs);\n attempt++;\n continue;\n }\n if (error.statusCode >= 500 && attempt < this.maxRetries) {\n await this.delay(this.getBackoffDelay(attempt));\n attempt++;\n continue;\n }\n throw error;\n }\n\n if (error instanceof Error && error.name === 'AbortError') {\n if (attempt < this.maxRetries) {\n await this.delay(this.getBackoffDelay(attempt));\n attempt++;\n continue;\n }\n\n throw new AudiolizeTimeoutError(`Request timeout after ${this.timeout}ms`);\n }\n\n if (attempt < this.maxRetries) {\n await this.delay(this.getBackoffDelay(attempt));\n attempt++;\n continue;\n }\n\n throw error;\n }\n }\n\n throw new Error('Max retries exceeded');\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n let errorData: Record<string, unknown> = {};\n try {\n const parsed: unknown = await response.json();\n if (isRecord(parsed)) {\n errorData = parsed;\n }\n } catch {\n // Ignore JSON parse errors for error responses\n }\n\n const errorMessage = typeof errorData.error === 'string' ? errorData.error : undefined;\n const fallbackMessage = typeof errorData.message === 'string' ? errorData.message : undefined;\n const message = errorMessage || fallbackMessage || response.statusText;\n const requestId = response.headers.get('x-request-id') || undefined;\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message, requestId);\n case 402:\n throw new PaywallError(message, requestId);\n case 403:\n throw new AuthorizationError(message, requestId);\n case 404:\n throw new NotFoundError(message, requestId);\n case 429: {\n const retryAfterHeader = response.headers.get('retry-after');\n const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : undefined;\n throw new RateLimitError(message, retryAfter, requestId);\n }\n default:\n if (response.status >= 500) {\n throw new ServerError(message, response.status, requestId);\n }\n throw new AudiolizeApiError(message, 'API_ERROR', response.status, requestId);\n }\n }\n\n private delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private getBackoffDelay(attempt: number): number {\n const baseDelay = 1000;\n const maxDelay = 60000;\n const delay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);\n // Add jitter\n return delay * (0.5 + Math.random() * 0.5);\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import type { JobsResource } from '../resources/jobs';\nimport type { Job, JobStep } from '../types/job';\nimport { AudiolizeTimeoutError } from '../http/errors';\n\nexport interface PollOptions {\n interval?: number; // ms between polls, default 3000\n maxInterval?: number; // max ms after backoff, default 15000\n timeout?: number; // total ms before AudiolizeTimeoutError, default 600000 (10 min)\n backoff?: boolean; // increase interval when step hasn't changed, default true\n}\n\ntype EventMap = {\n progress: (data: { step: JobStep | null; progress: number }) => void;\n completed: (job: Job) => void;\n failed: (error: Error) => void;\n};\n\ntype EventPayloadMap = {\n progress: { step: JobStep | null; progress: number };\n completed: Job;\n failed: Error;\n};\n\nexport class JobPoller {\n private readonly jobId: string;\n private readonly jobsResource: JobsResource;\n private readonly options: Required<PollOptions>;\n private currentInterval: number;\n private unchangedStepCount: number = 0;\n private lastStep: JobStep | null = null;\n private isPolling: boolean = false;\n private listeners: { [K in keyof EventMap]?: EventMap[K][] } = {};\n\n constructor(jobId: string, jobsResource: JobsResource, options?: PollOptions) {\n this.jobId = jobId;\n this.jobsResource = jobsResource;\n this.options = {\n interval: options?.interval ?? 3000,\n maxInterval: options?.maxInterval ?? 15000,\n timeout: options?.timeout ?? 600000,\n backoff: options?.backoff ?? true,\n };\n this.currentInterval = this.options.interval;\n }\n\n public on<K extends keyof EventMap>(event: K, listener: EventMap[K]): this {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event]!.push(listener);\n return this;\n }\n\n private emit(event: 'progress', payload: EventPayloadMap['progress']): void;\n private emit(event: 'completed', payload: EventPayloadMap['completed']): void;\n private emit(event: 'failed', payload: EventPayloadMap['failed']): void;\n private emit(event: keyof EventPayloadMap, payload: EventPayloadMap[keyof EventPayloadMap]): void {\n if (event === 'progress') {\n const eventListeners = this.listeners.progress ?? [];\n for (const listener of eventListeners) {\n listener(payload as EventPayloadMap['progress']);\n }\n return;\n }\n\n if (event === 'completed') {\n const eventListeners = this.listeners.completed ?? [];\n for (const listener of eventListeners) {\n listener(payload as EventPayloadMap['completed']);\n }\n return;\n }\n\n const eventListeners = this.listeners.failed ?? [];\n for (const listener of eventListeners) {\n listener(payload as EventPayloadMap['failed']);\n }\n }\n\n public async start(): Promise<Job> {\n if (this.isPolling) {\n throw new Error('Polling is already in progress');\n }\n this.isPolling = true;\n\n const startTime = Date.now();\n\n while (this.isPolling) {\n if (Date.now() - startTime > this.options.timeout) {\n this.isPolling = false;\n const error = new AudiolizeTimeoutError(`Job ${this.jobId} timed out after ${this.options.timeout}ms`);\n this.emit('failed', error);\n throw error;\n }\n\n try {\n const job = await this.jobsResource.get(this.jobId);\n\n if (job.status === 'completed') {\n this.isPolling = false;\n this.emit('completed', job);\n return job;\n }\n\n if (job.status === 'failed') {\n this.isPolling = false;\n const error = new Error(job.error || 'Job failed');\n this.emit('failed', error);\n throw error;\n }\n\n this.emit('progress', { step: job.currentStep, progress: job.progress });\n\n if (this.options.backoff) {\n if (job.currentStep === this.lastStep) {\n this.unchangedStepCount++;\n if (this.unchangedStepCount >= 3) {\n this.currentInterval = Math.min(this.currentInterval * 2, this.options.maxInterval);\n }\n } else {\n this.unchangedStepCount = 0;\n this.currentInterval = this.options.interval;\n this.lastStep = job.currentStep;\n }\n }\n\n await new Promise((resolve) => setTimeout(resolve, this.currentInterval));\n } catch (error) {\n this.isPolling = false;\n const err = error instanceof Error ? error : new Error(String(error));\n this.emit('failed', err);\n throw err;\n }\n }\n\n throw new Error('Polling stopped unexpectedly');\n }\n\n public stop(): void {\n this.isPolling = false;\n }\n}\n","import type { HttpClient } from '../http/HttpClient';\nimport type { Job } from '../types/job';\nimport type { ListOptions, PagedResponse } from '../types/common';\nimport { JobPoller, type PollOptions } from '../workflows/JobPoller';\n\nexport interface WaitForCompletionOptions extends PollOptions {\n onProgress?: (step: string | null, progress: number) => void;\n}\n\nexport class JobsResource {\n constructor(private readonly client: HttpClient) {}\n\n public async get(jobId: string): Promise<Job> {\n return this.client.request<Job>(`/jobs/${jobId}/status`);\n }\n\n public async list(options?: ListOptions): Promise<PagedResponse<Job>> {\n const query = new URLSearchParams();\n if (options?.limit) query.set('limit', options.limit.toString());\n if (options?.pageToken) query.set('pageToken', options.pageToken);\n\n const path = `/jobs${query.toString() ? `?${query.toString()}` : ''}`;\n return this.client.request<PagedResponse<Job>>(path);\n }\n\n /**\n * Polls until the job reaches `completed` or `failed`, then returns the final job.\n * Throws `AudiolizeTimeoutError` if the job does not complete within `options.timeout`.\n */\n public waitForCompletion(jobId: string, options?: WaitForCompletionOptions): Promise<Job> {\n const pollConfig: PollOptions = {};\n if (options?.interval !== undefined) pollConfig.interval = options.interval;\n if (options?.maxInterval !== undefined) pollConfig.maxInterval = options.maxInterval;\n if (options?.timeout !== undefined) pollConfig.timeout = options.timeout;\n if (options?.backoff !== undefined) pollConfig.backoff = options.backoff;\n\n const poller = new JobPoller(jobId, this, pollConfig);\n\n if (options?.onProgress) {\n poller.on('progress', ({ step, progress }) => {\n options.onProgress!(step, progress);\n });\n }\n\n return poller.start();\n }\n\n /**\n * Returns a `JobPoller` instance for event-driven polling.\n * Call `.start()` to begin, or listen to `progress`, `completed`, `failed` events.\n */\n public poll(jobId: string, options?: PollOptions): JobPoller {\n return new JobPoller(jobId, this, options);\n }\n}\n","import type { HttpClient } from '../http/HttpClient';\n\nexport interface Language {\n code: string;\n name: string;\n}\n\nexport class LanguagesResource {\n constructor(private readonly client: HttpClient) {}\n\n public async list(): Promise<Language[]> {\n return this.client.request<Language[]>('/supported-languages');\n }\n}\n","import type { HttpClient } from '../http/HttpClient';\nimport type { SubtitleFormat, SubtitleResult } from '../types/subtitle';\n\nexport class SubtitlesResource {\n constructor(private readonly client: HttpClient) {}\n\n public async download(jobId: string, language: string, format: SubtitleFormat): Promise<string | SubtitleResult> {\n const response = await this.client.request<{ url: string }>('/presigned-url', {\n method: 'POST',\n body: JSON.stringify({\n type: 'download',\n jobId,\n language,\n format,\n }),\n });\n\n const downloadResponse = await fetch(response.url);\n if (!downloadResponse.ok) {\n throw new Error(`Failed to download subtitles: ${downloadResponse.statusText}`);\n }\n\n if (format === 'json') {\n return downloadResponse.json() as Promise<SubtitleResult>;\n }\n\n return downloadResponse.text();\n }\n}\n","/**\n * Calculates exponential backoff with jitter.\n * formula: min(baseDelay * 2^attempt, maxDelay) * (0.5 + random * 0.5)\n */\nexport function getBackoffDelay(attempt: number, baseDelay = 1000, maxDelay = 60000): number {\n const exponential = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);\n const jitter = 0.5 + Math.random() * 0.5;\n return Math.floor(exponential * jitter);\n}\n\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport interface RetryOptions {\n maxRetries?: number;\n baseDelay?: number;\n maxDelay?: number;\n shouldRetry?: (error: unknown, attempt: number) => boolean;\n}\n\n/**\n * Runs `fn` with retry logic. Retries on transient errors up to `maxRetries` times.\n */\nexport async function withRetry<T>(fn: () => Promise<T>, options: RetryOptions = {}): Promise<T> {\n const { maxRetries = 3, baseDelay = 1000, maxDelay = 60000, shouldRetry } = options;\n\n let attempt = 0;\n while (true) {\n try {\n return await fn();\n } catch (error) {\n const isRetryable = shouldRetry ? shouldRetry(error, attempt) : true;\n if (!isRetryable || attempt >= maxRetries) {\n throw error;\n }\n await delay(getBackoffDelay(attempt, baseDelay, maxDelay));\n attempt++;\n }\n }\n}\n","import { AudiolizeUploadError } from '../http/errors';\nimport { withRetry } from './retry';\n\nexport interface UploadPart {\n partNumber: number;\n etag: string;\n}\n\nexport interface MultipartChunk {\n partNumber: number;\n url: string;\n data: Blob | Buffer;\n size: number;\n}\n\n/**\n * Splits a file-like input into chunks for multipart upload.\n * Returns an array of blobs (browser) or buffers (Node.js).\n */\nexport function splitIntoChunks(\n file: Blob | Buffer | File,\n partUrls: string[],\n): Promise<MultipartChunk[]> {\n const totalSize = file instanceof Blob ? file.size : file.length;\n const partCount = partUrls.length;\n const chunkSize = Math.ceil(totalSize / partCount);\n\n const chunks: MultipartChunk[] = [];\n for (let i = 0; i < partCount; i++) {\n const start = i * chunkSize;\n const end = Math.min(start + chunkSize, totalSize);\n\n let data: Blob | Buffer;\n if (file instanceof Blob) {\n data = file.slice(start, end);\n } else {\n // Node.js Buffer\n data = file.subarray(start, end);\n }\n\n chunks.push({\n partNumber: i + 1,\n url: partUrls[i]!,\n data,\n size: end - start,\n });\n }\n\n return Promise.resolve(chunks);\n}\n\n/**\n * Uploads a single part via PUT to its presigned GCS URL.\n * Returns the ETag from the response headers.\n */\nexport async function uploadPart(chunk: MultipartChunk): Promise<UploadPart> {\n const response = await withRetry(\n () =>\n fetch(chunk.url, {\n method: 'PUT',\n body: chunk.data as BodyInit,\n headers: {\n 'Content-Length': chunk.size.toString(),\n },\n }),\n { maxRetries: 3 },\n );\n\n if (!response.ok) {\n throw new AudiolizeUploadError(\n `Failed to upload part ${chunk.partNumber}: ${response.statusText}`,\n );\n }\n\n const etag = response.headers.get('etag');\n if (!etag) {\n throw new AudiolizeUploadError(`No ETag returned for part ${chunk.partNumber}`);\n }\n\n return { partNumber: chunk.partNumber, etag };\n}\n\n/**\n * Uploads all parts with bounded concurrency.\n * Emits progress via the `onProgress` callback: called with uploaded byte count and total bytes.\n */\nexport async function uploadAllParts(\n chunks: MultipartChunk[],\n concurrency = 4,\n onProgress?: (uploadedBytes: number, totalBytes: number) => void,\n): Promise<UploadPart[]> {\n const totalBytes = chunks.reduce((sum, c) => sum + c.size, 0);\n let uploadedBytes = 0;\n const results: UploadPart[] = [];\n\n // Process in batches of `concurrency`\n for (let i = 0; i < chunks.length; i += concurrency) {\n const batch = chunks.slice(i, i + concurrency);\n const batchResults = await Promise.all(\n batch.map(async (chunk) => {\n const part = await uploadPart(chunk);\n uploadedBytes += chunk.size;\n onProgress?.(uploadedBytes, totalBytes);\n return { part, index: chunk.partNumber - 1 };\n }),\n );\n for (const { part, index } of batchResults) {\n results[index] = part;\n }\n }\n\n return results;\n}\n","import type { HttpClient } from '../http/HttpClient';\nimport type {\n UploadOptions,\n PresignedUploadResponse,\n PresignedMultipartUploadResponse,\n CompleteMultipartUploadResponse,\n} from '../types/upload';\nimport { AudiolizeUploadError, AudiolizeValidationError } from '../http/errors';\nimport { splitIntoChunks, uploadAllParts } from '../utils/multipart';\nimport { withRetry } from '../utils/retry';\n\nexport type FileInput = string | Buffer | Blob | File | ReadableStream;\n\n/** Default file size above which multipart upload is used (100 MB). */\nexport const DEFAULT_MULTIPART_THRESHOLD = 100 * 1024 * 1024;\n\nexport interface SingleUploadOptions extends UploadOptions {\n onUploadProgress?: (percent: number) => void;\n}\n\nexport interface MultipartUploadOptions extends UploadOptions {\n /** Number of concurrent part uploads. Default: 4. */\n concurrency?: number;\n onUploadProgress?: (percent: number) => void;\n}\n\nexport class FilesResource {\n constructor(private readonly client: HttpClient) {}\n\n public async upload(file: FileInput, options: SingleUploadOptions): Promise<{ jobId: string }> {\n const response = await this.client.request<PresignedUploadResponse>('/presigned-url', {\n method: 'POST',\n body: JSON.stringify({\n type: 'upload',\n fileName: options.fileName,\n languages: options.languages,\n sourceLanguage: options.sourceLanguage,\n transcriptionOptions: options.transcriptionOptions,\n context: options.context,\n estimatedMinutes: options.estimatedMinutes,\n enableDubbing: options.enableDubbing,\n enableSdh: options.enableSdh,\n }),\n });\n\n const body = await resolveBody(file);\n\n const uploadResponse = await withRetry(\n () =>\n fetch(response.uploadUrl, {\n method: 'PUT',\n body: body as BodyInit,\n headers: {\n 'Content-Type': options.contentType || 'application/octet-stream',\n },\n }),\n { maxRetries: 3 },\n );\n\n if (!uploadResponse.ok) {\n throw new AudiolizeUploadError(`Failed to upload file: ${uploadResponse.statusText}`);\n }\n\n options.onUploadProgress?.(100);\n return { jobId: response.jobId };\n }\n\n public async uploadMultipart(\n file: Buffer | Blob | File,\n options: MultipartUploadOptions,\n ): Promise<{ jobId: string }> {\n const fileSize = file instanceof Blob ? file.size : file.length;\n if (fileSize === 0) {\n throw new AudiolizeValidationError('Cannot multipart-upload an empty file.');\n }\n\n const presigned = await this.client.request<PresignedMultipartUploadResponse>('/presigned-url', {\n method: 'POST',\n body: JSON.stringify({\n type: 'upload',\n multipart: true,\n fileSize,\n fileName: options.fileName,\n languages: options.languages,\n sourceLanguage: options.sourceLanguage,\n transcriptionOptions: options.transcriptionOptions,\n context: options.context,\n estimatedMinutes: options.estimatedMinutes,\n enableDubbing: options.enableDubbing,\n enableSdh: options.enableSdh,\n }),\n });\n\n const chunks = await splitIntoChunks(file, presigned.partUrls);\n\n const progressCallback = options.onUploadProgress;\n const onProgress = progressCallback\n ? (uploaded: number, total: number) =>\n progressCallback(Math.round((uploaded / total) * 100))\n : undefined;\n\n const parts = await uploadAllParts(chunks, options.concurrency ?? 4, onProgress);\n\n const completion = await this.client.request<CompleteMultipartUploadResponse>('/presigned-url', {\n method: 'POST',\n body: JSON.stringify({\n type: 'complete-multipart',\n uploadId: presigned.uploadId,\n uploadKey: presigned.uploadKey,\n parts,\n }),\n });\n\n if (!completion.success) {\n throw new AudiolizeUploadError('Multipart upload completion reported failure.');\n }\n\n return { jobId: presigned.jobId };\n }\n}\n\n/**\n * Resolves a FileInput to a body value suitable for `fetch` PUT requests.\n * Lazily imports Node.js `fs` so the browser bundle is not affected.\n */\nasync function resolveBody(\n file: FileInput,\n): Promise<Blob | Buffer | ArrayBufferView | ReadableStream> {\n if (typeof file === 'string') {\n // Treated as a file path in Node.js\n const { readFile } = await import('node:fs/promises');\n return readFile(file);\n }\n return file;\n}\n","import type { AudiolizeClient } from '../client';\nimport type { Job } from '../types/job';\nimport type { UploadOptions } from '../types/upload';\nimport { JobPoller, type PollOptions } from './JobPoller';\nimport { DEFAULT_MULTIPART_THRESHOLD, type SingleUploadOptions } from '../resources/files';\n\nexport interface LocalizeOptions extends Omit<UploadOptions, 'fileName'> {\n file: File | Blob | Buffer | string;\n fileName?: string;\n /**\n * File size threshold (bytes) above which multipart upload is used.\n * Defaults to 100 MB.\n */\n multipartThreshold?: number;\n pollOptions?: PollOptions;\n onUploadProgress?: (percent: number) => void;\n onProgress?: (step: string | null, progress: number) => void;\n}\n\nexport async function localize(client: AudiolizeClient, options: LocalizeOptions): Promise<Job> {\n const multipartThreshold = options.multipartThreshold ?? DEFAULT_MULTIPART_THRESHOLD;\n\n const uploadOptions: SingleUploadOptions = {\n fileName: options.fileName ?? (typeof options.file === 'string' ? options.file.split('/').pop() ?? 'upload' : 'upload'),\n languages: options.languages,\n ...(options.sourceLanguage !== undefined && { sourceLanguage: options.sourceLanguage }),\n ...(options.transcriptionOptions !== undefined && { transcriptionOptions: options.transcriptionOptions }),\n ...(options.context !== undefined && { context: options.context }),\n ...(options.estimatedMinutes !== undefined && { estimatedMinutes: options.estimatedMinutes }),\n ...(options.enableDubbing !== undefined && { enableDubbing: options.enableDubbing }),\n ...(options.enableSdh !== undefined && { enableSdh: options.enableSdh }),\n ...(options.onUploadProgress !== undefined && { onUploadProgress: options.onUploadProgress }),\n };\n\n const fileSize = getFileSize(options.file);\n let jobId: string;\n\n if (fileSize !== null && fileSize >= multipartThreshold && typeof options.file !== 'string') {\n const result = await client.files.uploadMultipart(options.file, {\n ...uploadOptions,\n concurrency: 4,\n });\n jobId = result.jobId;\n } else {\n const result = await client.files.upload(options.file, uploadOptions);\n jobId = result.jobId;\n }\n\n // Poll for completion\n const poller = new JobPoller(jobId, client.jobs, options.pollOptions);\n\n const progressCallback = options.onProgress;\n if (progressCallback) {\n poller.on('progress', ({ step, progress }) => {\n progressCallback(step, progress);\n });\n }\n\n return poller.start();\n}\n\nfunction getFileSize(file: File | Blob | Buffer | string): number | null {\n if (file instanceof Blob) return file.size;\n if (Buffer.isBuffer(file)) return file.length;\n return null;\n}\n","import { HttpClient, type HttpClientOptions } from './http/HttpClient';\nimport { JobsResource } from './resources/jobs';\nimport { LanguagesResource } from './resources/languages';\nimport { SubtitlesResource } from './resources/subtitles';\nimport { FilesResource } from './resources/files';\nimport { localize, type LocalizeOptions } from './workflows/localize';\nimport type { Job } from './types/job';\n\nexport interface AudiolizeClientOptions {\n apiKey: string;\n baseUrl?: string;\n timeout?: number;\n maxRetries?: number;\n}\n\nexport class AudiolizeClient {\n private readonly http: HttpClient;\n\n public readonly jobs: JobsResource;\n public readonly languages: LanguagesResource;\n public readonly subtitles: SubtitlesResource;\n public readonly files: FilesResource;\n\n constructor(options: AudiolizeClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n\n const httpOptions: HttpClientOptions = {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl || 'https://api.audialize.com/v1',\n };\n if (options.timeout !== undefined) httpOptions.timeout = options.timeout;\n if (options.maxRetries !== undefined) httpOptions.maxRetries = options.maxRetries;\n\n this.http = new HttpClient(httpOptions);\n\n this.jobs = new JobsResource(this.http);\n this.languages = new LanguagesResource(this.http);\n this.subtitles = new SubtitlesResource(this.http);\n this.files = new FilesResource(this.http);\n }\n\n /**\n * High-level workflow to upload a file, create a job, and poll until completion.\n * @param options LocalizeOptions\n * @returns Promise<Job>\n */\n public async localize(options: LocalizeOptions): Promise<Job> {\n return localize(this, options);\n }\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
interface HttpClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
declare class HttpClient {
|
|
9
|
+
private readonly apiKey;
|
|
10
|
+
private readonly baseUrl;
|
|
11
|
+
private readonly timeout;
|
|
12
|
+
private readonly maxRetries;
|
|
13
|
+
private readonly fetchImpl;
|
|
14
|
+
constructor(options: HttpClientOptions);
|
|
15
|
+
request<T>(path: string, options?: RequestInit): Promise<T>;
|
|
16
|
+
private handleErrorResponse;
|
|
17
|
+
private delay;
|
|
18
|
+
private getBackoffDelay;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
22
|
+
type JobStep = 'initializing' | 'extracting_audio' | 'transcribing' | 'translating' | 'generating_subtitles' | 'finalizing';
|
|
23
|
+
interface Job {
|
|
24
|
+
jobId: string;
|
|
25
|
+
fileName: string;
|
|
26
|
+
status: JobStatus;
|
|
27
|
+
progress: number;
|
|
28
|
+
currentStep: JobStep | null;
|
|
29
|
+
languages: string[];
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ListOptions {
|
|
36
|
+
limit?: number;
|
|
37
|
+
pageToken?: string;
|
|
38
|
+
}
|
|
39
|
+
interface PagedResponse<T> {
|
|
40
|
+
items: T[];
|
|
41
|
+
nextPageToken?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface PollOptions {
|
|
45
|
+
interval?: number;
|
|
46
|
+
maxInterval?: number;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
backoff?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type EventMap = {
|
|
51
|
+
progress: (data: {
|
|
52
|
+
step: JobStep | null;
|
|
53
|
+
progress: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
completed: (job: Job) => void;
|
|
56
|
+
failed: (error: Error) => void;
|
|
57
|
+
};
|
|
58
|
+
declare class JobPoller {
|
|
59
|
+
private readonly jobId;
|
|
60
|
+
private readonly jobsResource;
|
|
61
|
+
private readonly options;
|
|
62
|
+
private currentInterval;
|
|
63
|
+
private unchangedStepCount;
|
|
64
|
+
private lastStep;
|
|
65
|
+
private isPolling;
|
|
66
|
+
private listeners;
|
|
67
|
+
constructor(jobId: string, jobsResource: JobsResource, options?: PollOptions);
|
|
68
|
+
on<K extends keyof EventMap>(event: K, listener: EventMap[K]): this;
|
|
69
|
+
private emit;
|
|
70
|
+
start(): Promise<Job>;
|
|
71
|
+
stop(): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface WaitForCompletionOptions extends PollOptions {
|
|
75
|
+
onProgress?: (step: string | null, progress: number) => void;
|
|
76
|
+
}
|
|
77
|
+
declare class JobsResource {
|
|
78
|
+
private readonly client;
|
|
79
|
+
constructor(client: HttpClient);
|
|
80
|
+
get(jobId: string): Promise<Job>;
|
|
81
|
+
list(options?: ListOptions): Promise<PagedResponse<Job>>;
|
|
82
|
+
/**
|
|
83
|
+
* Polls until the job reaches `completed` or `failed`, then returns the final job.
|
|
84
|
+
* Throws `AudiolizeTimeoutError` if the job does not complete within `options.timeout`.
|
|
85
|
+
*/
|
|
86
|
+
waitForCompletion(jobId: string, options?: WaitForCompletionOptions): Promise<Job>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns a `JobPoller` instance for event-driven polling.
|
|
89
|
+
* Call `.start()` to begin, or listen to `progress`, `completed`, `failed` events.
|
|
90
|
+
*/
|
|
91
|
+
poll(jobId: string, options?: PollOptions): JobPoller;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Language {
|
|
95
|
+
code: string;
|
|
96
|
+
name: string;
|
|
97
|
+
}
|
|
98
|
+
declare class LanguagesResource {
|
|
99
|
+
private readonly client;
|
|
100
|
+
constructor(client: HttpClient);
|
|
101
|
+
list(): Promise<Language[]>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type SubtitleFormat = 'srt' | 'vtt' | 'json';
|
|
105
|
+
interface SubtitleCue {
|
|
106
|
+
id: string;
|
|
107
|
+
startTime: number;
|
|
108
|
+
endTime: number;
|
|
109
|
+
text: string;
|
|
110
|
+
confidence?: number;
|
|
111
|
+
}
|
|
112
|
+
interface SubtitleResult {
|
|
113
|
+
language: string;
|
|
114
|
+
cues: SubtitleCue[];
|
|
115
|
+
srt: string;
|
|
116
|
+
vtt: string;
|
|
117
|
+
raw: SubtitleCue[];
|
|
118
|
+
}
|
|
119
|
+
interface LocalizeResult {
|
|
120
|
+
jobId: string;
|
|
121
|
+
subtitles: Record<string, SubtitleResult>;
|
|
122
|
+
job: Job;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class SubtitlesResource {
|
|
126
|
+
private readonly client;
|
|
127
|
+
constructor(client: HttpClient);
|
|
128
|
+
download(jobId: string, language: string, format: SubtitleFormat): Promise<string | SubtitleResult>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface JobContext {
|
|
132
|
+
domain?: string;
|
|
133
|
+
translationNotes?: string;
|
|
134
|
+
targetAudience?: string;
|
|
135
|
+
}
|
|
136
|
+
interface TranscriptionOptions {
|
|
137
|
+
speakerDiarization?: boolean;
|
|
138
|
+
languageHints?: string[];
|
|
139
|
+
}
|
|
140
|
+
interface UploadOptions {
|
|
141
|
+
fileName?: string;
|
|
142
|
+
contentType?: string;
|
|
143
|
+
languages: string[];
|
|
144
|
+
sourceLanguage?: string;
|
|
145
|
+
transcriptionOptions?: TranscriptionOptions;
|
|
146
|
+
context?: JobContext;
|
|
147
|
+
estimatedMinutes?: number;
|
|
148
|
+
enableDubbing?: boolean;
|
|
149
|
+
enableSdh?: boolean;
|
|
150
|
+
}
|
|
151
|
+
interface PresignedUploadResponse {
|
|
152
|
+
uploadUrl: string;
|
|
153
|
+
jobId: string;
|
|
154
|
+
key: string;
|
|
155
|
+
}
|
|
156
|
+
interface PresignedMultipartUploadResponse {
|
|
157
|
+
uploadId: string;
|
|
158
|
+
uploadKey: string;
|
|
159
|
+
jobId: string;
|
|
160
|
+
partUrls: string[];
|
|
161
|
+
}
|
|
162
|
+
interface CompleteMultipartUploadResponse {
|
|
163
|
+
success: boolean;
|
|
164
|
+
jobId: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type FileInput = string | Buffer | Blob | File | ReadableStream;
|
|
168
|
+
/** Default file size above which multipart upload is used (100 MB). */
|
|
169
|
+
declare const DEFAULT_MULTIPART_THRESHOLD: number;
|
|
170
|
+
interface SingleUploadOptions extends UploadOptions {
|
|
171
|
+
onUploadProgress?: (percent: number) => void;
|
|
172
|
+
}
|
|
173
|
+
interface MultipartUploadOptions extends UploadOptions {
|
|
174
|
+
/** Number of concurrent part uploads. Default: 4. */
|
|
175
|
+
concurrency?: number;
|
|
176
|
+
onUploadProgress?: (percent: number) => void;
|
|
177
|
+
}
|
|
178
|
+
declare class FilesResource {
|
|
179
|
+
private readonly client;
|
|
180
|
+
constructor(client: HttpClient);
|
|
181
|
+
upload(file: FileInput, options: SingleUploadOptions): Promise<{
|
|
182
|
+
jobId: string;
|
|
183
|
+
}>;
|
|
184
|
+
uploadMultipart(file: Buffer | Blob | File, options: MultipartUploadOptions): Promise<{
|
|
185
|
+
jobId: string;
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface LocalizeOptions extends Omit<UploadOptions, 'fileName'> {
|
|
190
|
+
file: File | Blob | Buffer | string;
|
|
191
|
+
fileName?: string;
|
|
192
|
+
/**
|
|
193
|
+
* File size threshold (bytes) above which multipart upload is used.
|
|
194
|
+
* Defaults to 100 MB.
|
|
195
|
+
*/
|
|
196
|
+
multipartThreshold?: number;
|
|
197
|
+
pollOptions?: PollOptions;
|
|
198
|
+
onUploadProgress?: (percent: number) => void;
|
|
199
|
+
onProgress?: (step: string | null, progress: number) => void;
|
|
200
|
+
}
|
|
201
|
+
declare function localize(client: AudiolizeClient, options: LocalizeOptions): Promise<Job>;
|
|
202
|
+
|
|
203
|
+
interface AudiolizeClientOptions {
|
|
204
|
+
apiKey: string;
|
|
205
|
+
baseUrl?: string;
|
|
206
|
+
timeout?: number;
|
|
207
|
+
maxRetries?: number;
|
|
208
|
+
}
|
|
209
|
+
declare class AudiolizeClient {
|
|
210
|
+
private readonly http;
|
|
211
|
+
readonly jobs: JobsResource;
|
|
212
|
+
readonly languages: LanguagesResource;
|
|
213
|
+
readonly subtitles: SubtitlesResource;
|
|
214
|
+
readonly files: FilesResource;
|
|
215
|
+
constructor(options: AudiolizeClientOptions);
|
|
216
|
+
/**
|
|
217
|
+
* High-level workflow to upload a file, create a job, and poll until completion.
|
|
218
|
+
* @param options LocalizeOptions
|
|
219
|
+
* @returns Promise<Job>
|
|
220
|
+
*/
|
|
221
|
+
localize(options: LocalizeOptions): Promise<Job>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare class AudiolizeError extends Error {
|
|
225
|
+
readonly code: string;
|
|
226
|
+
constructor(message: string, code: string);
|
|
227
|
+
}
|
|
228
|
+
declare class AudiolizeApiError extends AudiolizeError {
|
|
229
|
+
readonly statusCode: number;
|
|
230
|
+
readonly requestId?: string | undefined;
|
|
231
|
+
constructor(message: string, code: string, statusCode: number, requestId?: string);
|
|
232
|
+
}
|
|
233
|
+
declare class AuthenticationError extends AudiolizeApiError {
|
|
234
|
+
constructor(message: string, requestId?: string);
|
|
235
|
+
}
|
|
236
|
+
declare class AuthorizationError extends AudiolizeApiError {
|
|
237
|
+
constructor(message: string, requestId?: string);
|
|
238
|
+
}
|
|
239
|
+
declare class NotFoundError extends AudiolizeApiError {
|
|
240
|
+
constructor(message: string, requestId?: string);
|
|
241
|
+
}
|
|
242
|
+
declare class RateLimitError extends AudiolizeApiError {
|
|
243
|
+
readonly retryAfter?: number | undefined;
|
|
244
|
+
constructor(message: string, retryAfter?: number, requestId?: string);
|
|
245
|
+
}
|
|
246
|
+
declare class PaywallError extends AudiolizeApiError {
|
|
247
|
+
constructor(message: string, requestId?: string);
|
|
248
|
+
}
|
|
249
|
+
declare class ServerError extends AudiolizeApiError {
|
|
250
|
+
constructor(message: string, statusCode: number, requestId?: string);
|
|
251
|
+
}
|
|
252
|
+
declare class AudiolizeUploadError extends AudiolizeError {
|
|
253
|
+
constructor(message: string);
|
|
254
|
+
}
|
|
255
|
+
declare class AudiolizeTimeoutError extends AudiolizeError {
|
|
256
|
+
constructor(message: string);
|
|
257
|
+
}
|
|
258
|
+
declare class AudiolizeValidationError extends AudiolizeError {
|
|
259
|
+
constructor(message: string);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Calculates exponential backoff with jitter.
|
|
264
|
+
* formula: min(baseDelay * 2^attempt, maxDelay) * (0.5 + random * 0.5)
|
|
265
|
+
*/
|
|
266
|
+
declare function getBackoffDelay(attempt: number, baseDelay?: number, maxDelay?: number): number;
|
|
267
|
+
interface RetryOptions {
|
|
268
|
+
maxRetries?: number;
|
|
269
|
+
baseDelay?: number;
|
|
270
|
+
maxDelay?: number;
|
|
271
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Runs `fn` with retry logic. Retries on transient errors up to `maxRetries` times.
|
|
275
|
+
*/
|
|
276
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
277
|
+
|
|
278
|
+
export { AudiolizeApiError, AudiolizeClient, type AudiolizeClientOptions, AudiolizeError, AudiolizeTimeoutError, AudiolizeUploadError, AudiolizeValidationError, AuthenticationError, AuthorizationError, type CompleteMultipartUploadResponse, DEFAULT_MULTIPART_THRESHOLD, type FileInput, FilesResource, type Job, type JobContext, JobPoller, type JobStatus, type JobStep, JobsResource, type Language, LanguagesResource, type ListOptions, type LocalizeOptions, type LocalizeResult, type MultipartUploadOptions, NotFoundError, type PagedResponse, PaywallError, type PollOptions, type PresignedMultipartUploadResponse, type PresignedUploadResponse, RateLimitError, type RetryOptions, ServerError, type SingleUploadOptions, type SubtitleCue, type SubtitleFormat, type SubtitleResult, SubtitlesResource, type TranscriptionOptions, type UploadOptions, type WaitForCompletionOptions, getBackoffDelay, localize, withRetry };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
interface HttpClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
declare class HttpClient {
|
|
9
|
+
private readonly apiKey;
|
|
10
|
+
private readonly baseUrl;
|
|
11
|
+
private readonly timeout;
|
|
12
|
+
private readonly maxRetries;
|
|
13
|
+
private readonly fetchImpl;
|
|
14
|
+
constructor(options: HttpClientOptions);
|
|
15
|
+
request<T>(path: string, options?: RequestInit): Promise<T>;
|
|
16
|
+
private handleErrorResponse;
|
|
17
|
+
private delay;
|
|
18
|
+
private getBackoffDelay;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
22
|
+
type JobStep = 'initializing' | 'extracting_audio' | 'transcribing' | 'translating' | 'generating_subtitles' | 'finalizing';
|
|
23
|
+
interface Job {
|
|
24
|
+
jobId: string;
|
|
25
|
+
fileName: string;
|
|
26
|
+
status: JobStatus;
|
|
27
|
+
progress: number;
|
|
28
|
+
currentStep: JobStep | null;
|
|
29
|
+
languages: string[];
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ListOptions {
|
|
36
|
+
limit?: number;
|
|
37
|
+
pageToken?: string;
|
|
38
|
+
}
|
|
39
|
+
interface PagedResponse<T> {
|
|
40
|
+
items: T[];
|
|
41
|
+
nextPageToken?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface PollOptions {
|
|
45
|
+
interval?: number;
|
|
46
|
+
maxInterval?: number;
|
|
47
|
+
timeout?: number;
|
|
48
|
+
backoff?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type EventMap = {
|
|
51
|
+
progress: (data: {
|
|
52
|
+
step: JobStep | null;
|
|
53
|
+
progress: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
completed: (job: Job) => void;
|
|
56
|
+
failed: (error: Error) => void;
|
|
57
|
+
};
|
|
58
|
+
declare class JobPoller {
|
|
59
|
+
private readonly jobId;
|
|
60
|
+
private readonly jobsResource;
|
|
61
|
+
private readonly options;
|
|
62
|
+
private currentInterval;
|
|
63
|
+
private unchangedStepCount;
|
|
64
|
+
private lastStep;
|
|
65
|
+
private isPolling;
|
|
66
|
+
private listeners;
|
|
67
|
+
constructor(jobId: string, jobsResource: JobsResource, options?: PollOptions);
|
|
68
|
+
on<K extends keyof EventMap>(event: K, listener: EventMap[K]): this;
|
|
69
|
+
private emit;
|
|
70
|
+
start(): Promise<Job>;
|
|
71
|
+
stop(): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface WaitForCompletionOptions extends PollOptions {
|
|
75
|
+
onProgress?: (step: string | null, progress: number) => void;
|
|
76
|
+
}
|
|
77
|
+
declare class JobsResource {
|
|
78
|
+
private readonly client;
|
|
79
|
+
constructor(client: HttpClient);
|
|
80
|
+
get(jobId: string): Promise<Job>;
|
|
81
|
+
list(options?: ListOptions): Promise<PagedResponse<Job>>;
|
|
82
|
+
/**
|
|
83
|
+
* Polls until the job reaches `completed` or `failed`, then returns the final job.
|
|
84
|
+
* Throws `AudiolizeTimeoutError` if the job does not complete within `options.timeout`.
|
|
85
|
+
*/
|
|
86
|
+
waitForCompletion(jobId: string, options?: WaitForCompletionOptions): Promise<Job>;
|
|
87
|
+
/**
|
|
88
|
+
* Returns a `JobPoller` instance for event-driven polling.
|
|
89
|
+
* Call `.start()` to begin, or listen to `progress`, `completed`, `failed` events.
|
|
90
|
+
*/
|
|
91
|
+
poll(jobId: string, options?: PollOptions): JobPoller;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface Language {
|
|
95
|
+
code: string;
|
|
96
|
+
name: string;
|
|
97
|
+
}
|
|
98
|
+
declare class LanguagesResource {
|
|
99
|
+
private readonly client;
|
|
100
|
+
constructor(client: HttpClient);
|
|
101
|
+
list(): Promise<Language[]>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type SubtitleFormat = 'srt' | 'vtt' | 'json';
|
|
105
|
+
interface SubtitleCue {
|
|
106
|
+
id: string;
|
|
107
|
+
startTime: number;
|
|
108
|
+
endTime: number;
|
|
109
|
+
text: string;
|
|
110
|
+
confidence?: number;
|
|
111
|
+
}
|
|
112
|
+
interface SubtitleResult {
|
|
113
|
+
language: string;
|
|
114
|
+
cues: SubtitleCue[];
|
|
115
|
+
srt: string;
|
|
116
|
+
vtt: string;
|
|
117
|
+
raw: SubtitleCue[];
|
|
118
|
+
}
|
|
119
|
+
interface LocalizeResult {
|
|
120
|
+
jobId: string;
|
|
121
|
+
subtitles: Record<string, SubtitleResult>;
|
|
122
|
+
job: Job;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class SubtitlesResource {
|
|
126
|
+
private readonly client;
|
|
127
|
+
constructor(client: HttpClient);
|
|
128
|
+
download(jobId: string, language: string, format: SubtitleFormat): Promise<string | SubtitleResult>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface JobContext {
|
|
132
|
+
domain?: string;
|
|
133
|
+
translationNotes?: string;
|
|
134
|
+
targetAudience?: string;
|
|
135
|
+
}
|
|
136
|
+
interface TranscriptionOptions {
|
|
137
|
+
speakerDiarization?: boolean;
|
|
138
|
+
languageHints?: string[];
|
|
139
|
+
}
|
|
140
|
+
interface UploadOptions {
|
|
141
|
+
fileName?: string;
|
|
142
|
+
contentType?: string;
|
|
143
|
+
languages: string[];
|
|
144
|
+
sourceLanguage?: string;
|
|
145
|
+
transcriptionOptions?: TranscriptionOptions;
|
|
146
|
+
context?: JobContext;
|
|
147
|
+
estimatedMinutes?: number;
|
|
148
|
+
enableDubbing?: boolean;
|
|
149
|
+
enableSdh?: boolean;
|
|
150
|
+
}
|
|
151
|
+
interface PresignedUploadResponse {
|
|
152
|
+
uploadUrl: string;
|
|
153
|
+
jobId: string;
|
|
154
|
+
key: string;
|
|
155
|
+
}
|
|
156
|
+
interface PresignedMultipartUploadResponse {
|
|
157
|
+
uploadId: string;
|
|
158
|
+
uploadKey: string;
|
|
159
|
+
jobId: string;
|
|
160
|
+
partUrls: string[];
|
|
161
|
+
}
|
|
162
|
+
interface CompleteMultipartUploadResponse {
|
|
163
|
+
success: boolean;
|
|
164
|
+
jobId: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type FileInput = string | Buffer | Blob | File | ReadableStream;
|
|
168
|
+
/** Default file size above which multipart upload is used (100 MB). */
|
|
169
|
+
declare const DEFAULT_MULTIPART_THRESHOLD: number;
|
|
170
|
+
interface SingleUploadOptions extends UploadOptions {
|
|
171
|
+
onUploadProgress?: (percent: number) => void;
|
|
172
|
+
}
|
|
173
|
+
interface MultipartUploadOptions extends UploadOptions {
|
|
174
|
+
/** Number of concurrent part uploads. Default: 4. */
|
|
175
|
+
concurrency?: number;
|
|
176
|
+
onUploadProgress?: (percent: number) => void;
|
|
177
|
+
}
|
|
178
|
+
declare class FilesResource {
|
|
179
|
+
private readonly client;
|
|
180
|
+
constructor(client: HttpClient);
|
|
181
|
+
upload(file: FileInput, options: SingleUploadOptions): Promise<{
|
|
182
|
+
jobId: string;
|
|
183
|
+
}>;
|
|
184
|
+
uploadMultipart(file: Buffer | Blob | File, options: MultipartUploadOptions): Promise<{
|
|
185
|
+
jobId: string;
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface LocalizeOptions extends Omit<UploadOptions, 'fileName'> {
|
|
190
|
+
file: File | Blob | Buffer | string;
|
|
191
|
+
fileName?: string;
|
|
192
|
+
/**
|
|
193
|
+
* File size threshold (bytes) above which multipart upload is used.
|
|
194
|
+
* Defaults to 100 MB.
|
|
195
|
+
*/
|
|
196
|
+
multipartThreshold?: number;
|
|
197
|
+
pollOptions?: PollOptions;
|
|
198
|
+
onUploadProgress?: (percent: number) => void;
|
|
199
|
+
onProgress?: (step: string | null, progress: number) => void;
|
|
200
|
+
}
|
|
201
|
+
declare function localize(client: AudiolizeClient, options: LocalizeOptions): Promise<Job>;
|
|
202
|
+
|
|
203
|
+
interface AudiolizeClientOptions {
|
|
204
|
+
apiKey: string;
|
|
205
|
+
baseUrl?: string;
|
|
206
|
+
timeout?: number;
|
|
207
|
+
maxRetries?: number;
|
|
208
|
+
}
|
|
209
|
+
declare class AudiolizeClient {
|
|
210
|
+
private readonly http;
|
|
211
|
+
readonly jobs: JobsResource;
|
|
212
|
+
readonly languages: LanguagesResource;
|
|
213
|
+
readonly subtitles: SubtitlesResource;
|
|
214
|
+
readonly files: FilesResource;
|
|
215
|
+
constructor(options: AudiolizeClientOptions);
|
|
216
|
+
/**
|
|
217
|
+
* High-level workflow to upload a file, create a job, and poll until completion.
|
|
218
|
+
* @param options LocalizeOptions
|
|
219
|
+
* @returns Promise<Job>
|
|
220
|
+
*/
|
|
221
|
+
localize(options: LocalizeOptions): Promise<Job>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare class AudiolizeError extends Error {
|
|
225
|
+
readonly code: string;
|
|
226
|
+
constructor(message: string, code: string);
|
|
227
|
+
}
|
|
228
|
+
declare class AudiolizeApiError extends AudiolizeError {
|
|
229
|
+
readonly statusCode: number;
|
|
230
|
+
readonly requestId?: string | undefined;
|
|
231
|
+
constructor(message: string, code: string, statusCode: number, requestId?: string);
|
|
232
|
+
}
|
|
233
|
+
declare class AuthenticationError extends AudiolizeApiError {
|
|
234
|
+
constructor(message: string, requestId?: string);
|
|
235
|
+
}
|
|
236
|
+
declare class AuthorizationError extends AudiolizeApiError {
|
|
237
|
+
constructor(message: string, requestId?: string);
|
|
238
|
+
}
|
|
239
|
+
declare class NotFoundError extends AudiolizeApiError {
|
|
240
|
+
constructor(message: string, requestId?: string);
|
|
241
|
+
}
|
|
242
|
+
declare class RateLimitError extends AudiolizeApiError {
|
|
243
|
+
readonly retryAfter?: number | undefined;
|
|
244
|
+
constructor(message: string, retryAfter?: number, requestId?: string);
|
|
245
|
+
}
|
|
246
|
+
declare class PaywallError extends AudiolizeApiError {
|
|
247
|
+
constructor(message: string, requestId?: string);
|
|
248
|
+
}
|
|
249
|
+
declare class ServerError extends AudiolizeApiError {
|
|
250
|
+
constructor(message: string, statusCode: number, requestId?: string);
|
|
251
|
+
}
|
|
252
|
+
declare class AudiolizeUploadError extends AudiolizeError {
|
|
253
|
+
constructor(message: string);
|
|
254
|
+
}
|
|
255
|
+
declare class AudiolizeTimeoutError extends AudiolizeError {
|
|
256
|
+
constructor(message: string);
|
|
257
|
+
}
|
|
258
|
+
declare class AudiolizeValidationError extends AudiolizeError {
|
|
259
|
+
constructor(message: string);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Calculates exponential backoff with jitter.
|
|
264
|
+
* formula: min(baseDelay * 2^attempt, maxDelay) * (0.5 + random * 0.5)
|
|
265
|
+
*/
|
|
266
|
+
declare function getBackoffDelay(attempt: number, baseDelay?: number, maxDelay?: number): number;
|
|
267
|
+
interface RetryOptions {
|
|
268
|
+
maxRetries?: number;
|
|
269
|
+
baseDelay?: number;
|
|
270
|
+
maxDelay?: number;
|
|
271
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Runs `fn` with retry logic. Retries on transient errors up to `maxRetries` times.
|
|
275
|
+
*/
|
|
276
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
277
|
+
|
|
278
|
+
export { AudiolizeApiError, AudiolizeClient, type AudiolizeClientOptions, AudiolizeError, AudiolizeTimeoutError, AudiolizeUploadError, AudiolizeValidationError, AuthenticationError, AuthorizationError, type CompleteMultipartUploadResponse, DEFAULT_MULTIPART_THRESHOLD, type FileInput, FilesResource, type Job, type JobContext, JobPoller, type JobStatus, type JobStep, JobsResource, type Language, LanguagesResource, type ListOptions, type LocalizeOptions, type LocalizeResult, type MultipartUploadOptions, NotFoundError, type PagedResponse, PaywallError, type PollOptions, type PresignedMultipartUploadResponse, type PresignedUploadResponse, RateLimitError, type RetryOptions, ServerError, type SingleUploadOptions, type SubtitleCue, type SubtitleFormat, type SubtitleResult, SubtitlesResource, type TranscriptionOptions, type UploadOptions, type WaitForCompletionOptions, getBackoffDelay, localize, withRetry };
|