/
index.d.ts
151 lines (138 loc) · 4.11 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import type { PluginOptions, UppyFile, BasePlugin } from '@uppy/core'
import TransloaditLocale from './generatedLocale'
export interface FileInfo {
id: string,
name: string,
basename: string,
ext: string,
size: number,
mime: string,
type: string,
field: string,
md5hash: string,
is_tus_file: boolean,
original_md5hash: string,
original_id: string,
original_name: string
original_basename: string,
original_path: string,
url: string,
ssl_url: string,
tus_upload_url: string,
meta: Record<string, any>
}
export interface Result extends FileInfo {
cost: number,
execTime: number,
queue: string,
queueTime: number,
localId: string | null
}
export interface Assembly {
ok?: string,
message?: string,
assembly_id: string,
parent_id?: string,
account_id: string,
template_id?: string,
instance: string,
assembly_url: string,
assembly_ssl_url: string,
uppyserver_url: string,
companion_url: string,
websocket_url: string,
tus_url: string,
bytes_received: number,
bytes_expected: number,
upload_duration: number,
client_agent?: string,
client_ip?: string,
client_referer?: string,
transloadit_client: string,
start_date: string,
upload_meta_data_extracted: boolean,
warnings: any[],
is_infinite: boolean,
has_dupe_jobs: boolean,
execution_start: string,
execution_duration: number,
queue_duration: number,
jobs_queue_duration: number,
notify_start?: any,
notify_url?: string,
notify_status?: any,
notify_response_code?: any,
notify_duration?: any,
last_job_completed?: string,
fields: Record<string, any>,
running_jobs: any[],
bytes_usage: number,
executing_jobs: any[],
started_jobs: string[],
parent_assembly_status: any,
params: string,
template?: any,
merged_params: string,
uploads: FileInfo[],
results: Record<string, Result[]>,
build_id: string,
error?: string,
stderr?: string,
stdout?: string,
reason?: string,
}
interface AssemblyParameters {
auth: {
key: string,
expires?: string
}
template_id?: string
steps?: { [step: string]: Record<string, unknown> }
notify_url?: string
fields?: { [name: string]: number | string }
}
interface AssemblyOptions {
params: AssemblyParameters
fields?: { [name: string]: number | string }
signature?: string
}
interface TransloaditOptionsBase extends PluginOptions {
service?: string
errorReporting?: boolean
waitForEncoding?: boolean
waitForMetadata?: boolean
importFromUploadURLs?: boolean
alwaysRunAssembly?: boolean
locale?: TransloaditLocale
limit?: number
}
// Either have a getAssemblyOptions() that returns an AssemblyOptions, *or* have them embedded in the options
export type TransloaditOptions = TransloaditOptionsBase &
(
| {
getAssemblyOptions?: (file: UppyFile) => AssemblyOptions | Promise<AssemblyOptions>
}
| AssemblyOptions)
export default class Transloadit extends BasePlugin<TransloaditOptions> {
/** @deprecated */
static COMPANION: string
/** @deprecated */
static COMPANION_PATTERN: RegExp
}
export const COMPANION_URL: string
export const COMPANION_ALLOWED_HOSTS: RegExp
// Events
export type TransloaditAssemblyCreatedCallback = (assembly: Assembly, fileIDs: string[]) => void;
export type TransloaditUploadedCallback = (file: FileInfo, assembly: Assembly) => void;
export type TransloaditAssemblyExecutingCallback = (assembly: Assembly) => void;
export type TransloaditResultCallback = (stepName: string, result: Result, assembly: Assembly) => void;
export type TransloaditCompleteCallback = (assembly: Assembly) => void;
declare module '@uppy/core' {
export interface UppyEventMap {
'transloadit:assembly-created': TransloaditAssemblyCreatedCallback
'transloadit:upload': TransloaditUploadedCallback
'transloadit:assembly-executing': TransloaditAssemblyExecutingCallback
'transloadit:result': TransloaditResultCallback
'transloadit:complete': TransloaditCompleteCallback
}
}