92 lines
2.1 KiB
TypeScript
92 lines
2.1 KiB
TypeScript
export type DoResumableDownloadParams = {
|
|
url: string
|
|
filepath: string
|
|
timeout: number
|
|
allowedMimeTypes: string[]
|
|
signal?: AbortSignal
|
|
onProgress?: (progress: DoResumableDownloadProgress) => void
|
|
onComplete?: (url: string, path: string) => void | Promise<void>
|
|
forceNew?: boolean
|
|
}
|
|
|
|
export type DoResumableDownloadWithRetryParams = DoResumableDownloadParams & {
|
|
max_retries?: number
|
|
retry_delay?: number
|
|
onAttemptError?: (error: Error, attempt: number) => void
|
|
}
|
|
|
|
export type DoResumableDownloadProgress = {
|
|
downloadedBytes: number
|
|
totalBytes: number
|
|
lastProgressTime: number
|
|
lastDownloadedBytes: number
|
|
url: string
|
|
}
|
|
|
|
export type DownloadProgressData = {
|
|
percent: number
|
|
downloadedBytes: number
|
|
totalBytes: number
|
|
lastProgressTime: number
|
|
}
|
|
|
|
export type RunDownloadJobParams = Omit<
|
|
DoResumableDownloadParams,
|
|
'onProgress' | 'onComplete' | 'signal'
|
|
> & {
|
|
filetype: string
|
|
title?: string
|
|
totalBytes?: number
|
|
resourceMetadata?: {
|
|
resource_id: string
|
|
version: string
|
|
collection_ref: string | null
|
|
/**
|
|
* True only when this download was initiated by the content auto-updater.
|
|
* Gates the per-resource auto-update backoff (success reset in
|
|
* RunDownloadJob.onComplete, terminal-failure increment in the worker
|
|
* `failed` handler) so manual downloads never touch the counter.
|
|
*/
|
|
auto?: boolean
|
|
}
|
|
}
|
|
|
|
export type DownloadJobWithProgress = {
|
|
jobId: string
|
|
url: string
|
|
progress: number
|
|
filepath: string
|
|
filetype: string
|
|
title?: string
|
|
downloadedBytes?: number
|
|
totalBytes?: number
|
|
lastProgressTime?: number
|
|
status?: 'active' | 'waiting' | 'delayed' | 'failed'
|
|
failedReason?: string
|
|
}
|
|
|
|
// Wikipedia selector types
|
|
export type WikipediaOption = {
|
|
id: string
|
|
name: string
|
|
description: string
|
|
size_mb: number
|
|
url: string | null
|
|
}
|
|
|
|
export type WikipediaOptionsFile = {
|
|
options: WikipediaOption[]
|
|
}
|
|
|
|
export type WikipediaCurrentSelection = {
|
|
optionId: string
|
|
status: 'none' | 'downloading' | 'installed' | 'failed'
|
|
filename: string | null
|
|
url: string | null
|
|
}
|
|
|
|
export type WikipediaState = {
|
|
options: WikipediaOption[]
|
|
currentSelection: WikipediaCurrentSelection | null
|
|
}
|