@uploadcare/upload-client 6.4.1 → 6.5.0-alpha.2
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/dist/cjs/index.browser.cjs +1679 -0
- package/dist/cjs/index.browser.d.cts +501 -0
- package/dist/cjs/index.node.cjs +1708 -0
- package/dist/cjs/index.node.d.cts +501 -0
- package/dist/cjs/index.react-native.cjs +1707 -0
- package/dist/cjs/index.react-native.d.cts +501 -0
- package/dist/esm/index.browser.d.mts +501 -0
- package/dist/{index.browser.js → esm/index.browser.mjs} +42 -26
- package/dist/esm/index.node.d.mts +501 -0
- package/dist/{index.node.js → esm/index.node.mjs} +49 -30
- package/dist/esm/index.react-native.d.mts +501 -0
- package/dist/{index.react-native.js → esm/index.react-native.mjs} +42 -26
- package/dist/index.d.ts +58 -58
- package/package.json +26 -14
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v6.12.0
|
|
2
|
+
|
|
3
|
+
import NodeFormData from 'form-data';
|
|
4
|
+
|
|
5
|
+
export type CustomUserAgentOptions = {
|
|
6
|
+
publicKey: string;
|
|
7
|
+
libraryName: string;
|
|
8
|
+
libraryVersion: string;
|
|
9
|
+
languageName: string;
|
|
10
|
+
integration?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CustomUserAgentFn = (options: CustomUserAgentOptions) => string;
|
|
13
|
+
export type CustomUserAgent = string | CustomUserAgentFn;
|
|
14
|
+
export type GetUserAgentOptions = {
|
|
15
|
+
libraryName: string;
|
|
16
|
+
libraryVersion: string;
|
|
17
|
+
publicKey?: string;
|
|
18
|
+
integration?: string;
|
|
19
|
+
userAgent?: CustomUserAgent | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function getUserAgent({ libraryName, libraryVersion, userAgent, publicKey, integration }: GetUserAgentOptions): string;
|
|
22
|
+
export declare class UploadcareNetworkError extends Error {
|
|
23
|
+
originalProgressEvent: ProgressEvent;
|
|
24
|
+
constructor(progressEvent: ProgressEvent);
|
|
25
|
+
}
|
|
26
|
+
export type GeoLocation = {
|
|
27
|
+
latitude: number;
|
|
28
|
+
longitude: number;
|
|
29
|
+
};
|
|
30
|
+
export type ImageInfo = {
|
|
31
|
+
height: number;
|
|
32
|
+
width: number;
|
|
33
|
+
geoLocation: GeoLocation | null;
|
|
34
|
+
datetimeOriginal: string;
|
|
35
|
+
format: string;
|
|
36
|
+
colorMode: string;
|
|
37
|
+
dpi: {
|
|
38
|
+
"0": number;
|
|
39
|
+
"1": number;
|
|
40
|
+
} | null;
|
|
41
|
+
orientation: number | null;
|
|
42
|
+
sequence: boolean | null;
|
|
43
|
+
};
|
|
44
|
+
export type AudioInfo = {
|
|
45
|
+
bitrate: number | null;
|
|
46
|
+
codec: string | null;
|
|
47
|
+
sampleRate: number | null;
|
|
48
|
+
channels: string | null;
|
|
49
|
+
};
|
|
50
|
+
export type VideoInfo = {
|
|
51
|
+
duration: number;
|
|
52
|
+
format: string;
|
|
53
|
+
bitrate: number;
|
|
54
|
+
audio: AudioInfo | null;
|
|
55
|
+
video: {
|
|
56
|
+
height: number;
|
|
57
|
+
width: number;
|
|
58
|
+
frameRate: number;
|
|
59
|
+
bitrate: number;
|
|
60
|
+
codec: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type MimeInfo = {
|
|
64
|
+
mime: string;
|
|
65
|
+
type: string;
|
|
66
|
+
subtype: string;
|
|
67
|
+
};
|
|
68
|
+
export type ContentInfo = {
|
|
69
|
+
mime?: MimeInfo;
|
|
70
|
+
image?: ImageInfo;
|
|
71
|
+
video?: VideoInfo;
|
|
72
|
+
};
|
|
73
|
+
export type Metadata = Record<string, string>;
|
|
74
|
+
export type StoreValue = "auto" | boolean;
|
|
75
|
+
export interface DefaultSettings {
|
|
76
|
+
baseCDN: string;
|
|
77
|
+
baseURL: string;
|
|
78
|
+
maxContentLength: number;
|
|
79
|
+
retryThrottledRequestMaxTimes: number;
|
|
80
|
+
retryNetworkErrorMaxTimes: number;
|
|
81
|
+
multipartMinFileSize: number;
|
|
82
|
+
multipartChunkSize: number;
|
|
83
|
+
multipartMinLastPartSize: number;
|
|
84
|
+
maxConcurrentRequests: number;
|
|
85
|
+
pollingTimeoutMilliseconds: number;
|
|
86
|
+
pusherKey: string;
|
|
87
|
+
}
|
|
88
|
+
export interface Settings extends Partial<DefaultSettings> {
|
|
89
|
+
publicKey: string;
|
|
90
|
+
fileName?: string;
|
|
91
|
+
contentType?: string;
|
|
92
|
+
store?: StoreValue;
|
|
93
|
+
secureSignature?: string;
|
|
94
|
+
secureExpire?: string;
|
|
95
|
+
integration?: string;
|
|
96
|
+
userAgent?: CustomUserAgent;
|
|
97
|
+
checkForUrlDuplicates?: boolean;
|
|
98
|
+
saveUrlForRecurrentUploads?: boolean;
|
|
99
|
+
source?: string;
|
|
100
|
+
jsonpCallback?: string;
|
|
101
|
+
}
|
|
102
|
+
export type BrowserFile = Blob | File;
|
|
103
|
+
export type NodeFile = Buffer;
|
|
104
|
+
export type ReactNativeAsset = {
|
|
105
|
+
type: string;
|
|
106
|
+
uri: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
};
|
|
109
|
+
export type SupportedFileInput = BrowserFile | NodeFile | ReactNativeAsset;
|
|
110
|
+
export type Sliceable = BrowserFile | NodeFile;
|
|
111
|
+
export type FileInfo = {
|
|
112
|
+
size: number;
|
|
113
|
+
done: number;
|
|
114
|
+
total: number;
|
|
115
|
+
uuid: Uuid;
|
|
116
|
+
fileId: Uuid;
|
|
117
|
+
originalFilename: string;
|
|
118
|
+
filename: string;
|
|
119
|
+
mimeType: string;
|
|
120
|
+
isImage: boolean;
|
|
121
|
+
isStored: boolean;
|
|
122
|
+
isReady: string;
|
|
123
|
+
imageInfo: ImageInfo | null;
|
|
124
|
+
videoInfo: VideoInfo | null;
|
|
125
|
+
contentInfo: ContentInfo | null;
|
|
126
|
+
s3Bucket?: string;
|
|
127
|
+
metadata?: Metadata;
|
|
128
|
+
};
|
|
129
|
+
export type GroupInfo = {
|
|
130
|
+
datetimeCreated: string;
|
|
131
|
+
datetimeStored: string | null;
|
|
132
|
+
filesCount: string;
|
|
133
|
+
cdnUrl: string;
|
|
134
|
+
files: FileInfo[];
|
|
135
|
+
url: string;
|
|
136
|
+
id: GroupId;
|
|
137
|
+
};
|
|
138
|
+
export type Token = string;
|
|
139
|
+
export type Uuid = string;
|
|
140
|
+
export type GroupId = string;
|
|
141
|
+
export type Url = string;
|
|
142
|
+
export type ComputableProgressInfo = {
|
|
143
|
+
isComputable: true;
|
|
144
|
+
value: number;
|
|
145
|
+
};
|
|
146
|
+
export type UnknownProgressInfo = {
|
|
147
|
+
isComputable: false;
|
|
148
|
+
};
|
|
149
|
+
export type ProgressCallback<T = ComputableProgressInfo | UnknownProgressInfo> = (arg: T) => void;
|
|
150
|
+
export type BaseResponse = {
|
|
151
|
+
file: Uuid;
|
|
152
|
+
};
|
|
153
|
+
export type BaseOptions = {
|
|
154
|
+
publicKey: string;
|
|
155
|
+
fileName?: string;
|
|
156
|
+
baseURL?: string;
|
|
157
|
+
secureSignature?: string;
|
|
158
|
+
secureExpire?: string;
|
|
159
|
+
store?: StoreValue;
|
|
160
|
+
contentType?: string;
|
|
161
|
+
signal?: AbortSignal;
|
|
162
|
+
onProgress?: ProgressCallback;
|
|
163
|
+
source?: string;
|
|
164
|
+
integration?: string;
|
|
165
|
+
userAgent?: CustomUserAgent;
|
|
166
|
+
retryThrottledRequestMaxTimes?: number;
|
|
167
|
+
retryNetworkErrorMaxTimes?: number;
|
|
168
|
+
metadata?: Metadata;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Performs file uploading request to Uploadcare Upload API. Can be canceled and
|
|
172
|
+
* has progress.
|
|
173
|
+
*/
|
|
174
|
+
export function base(file: SupportedFileInput, { publicKey, fileName, contentType, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, metadata }: BaseOptions): Promise<BaseResponse>;
|
|
175
|
+
export declare enum TypeEnum {
|
|
176
|
+
Token = "token",
|
|
177
|
+
FileInfo = "file_info"
|
|
178
|
+
}
|
|
179
|
+
export type TokenResponse = {
|
|
180
|
+
type: TypeEnum.Token;
|
|
181
|
+
token: string;
|
|
182
|
+
};
|
|
183
|
+
export type FileInfoResponse = {
|
|
184
|
+
type: TypeEnum.FileInfo;
|
|
185
|
+
} & FileInfo;
|
|
186
|
+
export type FromUrlSuccessResponse = FileInfoResponse | TokenResponse;
|
|
187
|
+
export type FromUrlResponse = FromUrlSuccessResponse;
|
|
188
|
+
export type FromUrlOptions = {
|
|
189
|
+
publicKey: string;
|
|
190
|
+
baseURL?: string;
|
|
191
|
+
store?: StoreValue;
|
|
192
|
+
fileName?: string;
|
|
193
|
+
checkForUrlDuplicates?: boolean;
|
|
194
|
+
saveUrlForRecurrentUploads?: boolean;
|
|
195
|
+
secureSignature?: string;
|
|
196
|
+
secureExpire?: string;
|
|
197
|
+
signal?: AbortSignal;
|
|
198
|
+
source?: string;
|
|
199
|
+
integration?: string;
|
|
200
|
+
userAgent?: CustomUserAgent;
|
|
201
|
+
retryThrottledRequestMaxTimes?: number;
|
|
202
|
+
retryNetworkErrorMaxTimes?: number;
|
|
203
|
+
metadata?: Metadata;
|
|
204
|
+
};
|
|
205
|
+
/** Uploading files from URL. */
|
|
206
|
+
export function fromUrl(sourceUrl: Url, { publicKey, baseURL, store, fileName, checkForUrlDuplicates, saveUrlForRecurrentUploads, secureSignature, secureExpire, source, signal, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, metadata }: FromUrlOptions): Promise<FromUrlSuccessResponse>;
|
|
207
|
+
export declare enum Status {
|
|
208
|
+
Unknown = "unknown",
|
|
209
|
+
Waiting = "waiting",
|
|
210
|
+
Progress = "progress",
|
|
211
|
+
Error = "error",
|
|
212
|
+
Success = "success"
|
|
213
|
+
}
|
|
214
|
+
export type StatusUnknownResponse = {
|
|
215
|
+
status: Status.Unknown;
|
|
216
|
+
};
|
|
217
|
+
export type StatusWaitingResponse = {
|
|
218
|
+
status: Status.Waiting;
|
|
219
|
+
};
|
|
220
|
+
export type StatusProgressResponse = {
|
|
221
|
+
status: Status.Progress;
|
|
222
|
+
size: number;
|
|
223
|
+
done: number;
|
|
224
|
+
total: number | "unknown";
|
|
225
|
+
};
|
|
226
|
+
export type StatusErrorResponse = {
|
|
227
|
+
status: Status.Error;
|
|
228
|
+
error: string;
|
|
229
|
+
errorCode: string;
|
|
230
|
+
};
|
|
231
|
+
export type StatusSuccessResponse = {
|
|
232
|
+
status: Status.Success;
|
|
233
|
+
} & FileInfo;
|
|
234
|
+
export type FromUrlStatusResponse = StatusUnknownResponse | StatusWaitingResponse | StatusProgressResponse | StatusErrorResponse | StatusSuccessResponse;
|
|
235
|
+
export type FromUrlStatusOptions = {
|
|
236
|
+
publicKey?: string;
|
|
237
|
+
baseURL?: string;
|
|
238
|
+
signal?: AbortSignal;
|
|
239
|
+
integration?: string;
|
|
240
|
+
userAgent?: CustomUserAgent;
|
|
241
|
+
retryThrottledRequestMaxTimes?: number;
|
|
242
|
+
retryNetworkErrorMaxTimes?: number;
|
|
243
|
+
};
|
|
244
|
+
/** Checking upload status and working with file tokens. */
|
|
245
|
+
export function fromUrlStatus(token: Token, { publicKey, baseURL, signal, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }?: FromUrlStatusOptions): Promise<FromUrlStatusResponse>;
|
|
246
|
+
export type GroupOptions = {
|
|
247
|
+
publicKey: string;
|
|
248
|
+
baseURL?: string;
|
|
249
|
+
jsonpCallback?: string;
|
|
250
|
+
secureSignature?: string;
|
|
251
|
+
secureExpire?: string;
|
|
252
|
+
signal?: AbortSignal;
|
|
253
|
+
source?: string;
|
|
254
|
+
integration?: string;
|
|
255
|
+
userAgent?: CustomUserAgent;
|
|
256
|
+
retryThrottledRequestMaxTimes?: number;
|
|
257
|
+
retryNetworkErrorMaxTimes?: number;
|
|
258
|
+
};
|
|
259
|
+
/** Create files group. */
|
|
260
|
+
export function group(uuids: Uuid[], { publicKey, baseURL, jsonpCallback, secureSignature, secureExpire, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: GroupOptions): Promise<GroupInfo>;
|
|
261
|
+
export type GroupInfoOptions = {
|
|
262
|
+
publicKey: string;
|
|
263
|
+
baseURL?: string;
|
|
264
|
+
signal?: AbortSignal;
|
|
265
|
+
source?: string;
|
|
266
|
+
integration?: string;
|
|
267
|
+
userAgent?: CustomUserAgent;
|
|
268
|
+
retryThrottledRequestMaxTimes?: number;
|
|
269
|
+
retryNetworkErrorMaxTimes?: number;
|
|
270
|
+
};
|
|
271
|
+
/** Get info about group. */
|
|
272
|
+
export function groupInfo(id: GroupId, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: GroupInfoOptions): Promise<GroupInfo>;
|
|
273
|
+
export type InfoOptions = {
|
|
274
|
+
publicKey: string;
|
|
275
|
+
baseURL?: string;
|
|
276
|
+
signal?: AbortSignal;
|
|
277
|
+
source?: string;
|
|
278
|
+
integration?: string;
|
|
279
|
+
userAgent?: CustomUserAgent;
|
|
280
|
+
retryThrottledRequestMaxTimes?: number;
|
|
281
|
+
retryNetworkErrorMaxTimes?: number;
|
|
282
|
+
};
|
|
283
|
+
/** Returns a JSON dictionary holding file info. */
|
|
284
|
+
export function info(uuid: Uuid, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: InfoOptions): Promise<FileInfo>;
|
|
285
|
+
export type MultipartStartOptions = {
|
|
286
|
+
publicKey: string;
|
|
287
|
+
contentType?: string;
|
|
288
|
+
fileName?: string;
|
|
289
|
+
baseURL?: string;
|
|
290
|
+
secureSignature?: string;
|
|
291
|
+
secureExpire?: string;
|
|
292
|
+
store?: StoreValue;
|
|
293
|
+
multipartChunkSize?: number;
|
|
294
|
+
signal?: AbortSignal;
|
|
295
|
+
source?: string;
|
|
296
|
+
integration?: string;
|
|
297
|
+
userAgent?: CustomUserAgent;
|
|
298
|
+
retryThrottledRequestMaxTimes?: number;
|
|
299
|
+
retryNetworkErrorMaxTimes?: number;
|
|
300
|
+
metadata?: Metadata;
|
|
301
|
+
};
|
|
302
|
+
export type MultipartPart = string;
|
|
303
|
+
export type MultipartStartResponse = {
|
|
304
|
+
parts: MultipartPart[];
|
|
305
|
+
uuid: Uuid;
|
|
306
|
+
};
|
|
307
|
+
/** Start multipart uploading. */
|
|
308
|
+
export function multipartStart(size: number, { publicKey, contentType, fileName, multipartChunkSize, baseURL, secureSignature, secureExpire, store, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, metadata }: MultipartStartOptions): Promise<MultipartStartResponse>;
|
|
309
|
+
export type MultipartUploadOptions = {
|
|
310
|
+
publicKey?: string;
|
|
311
|
+
contentType?: string;
|
|
312
|
+
signal?: AbortSignal;
|
|
313
|
+
onProgress?: ProgressCallback<ComputableProgressInfo>;
|
|
314
|
+
integration?: string;
|
|
315
|
+
retryThrottledRequestMaxTimes?: number;
|
|
316
|
+
retryNetworkErrorMaxTimes?: number;
|
|
317
|
+
};
|
|
318
|
+
export type MultipartUploadResponse = {
|
|
319
|
+
code?: number;
|
|
320
|
+
};
|
|
321
|
+
/** Complete multipart uploading. */
|
|
322
|
+
export function multipartUpload(part: SupportedFileInput, url: MultipartPart, { contentType, signal, onProgress, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
323
|
+
export type MultipartCompleteOptions = {
|
|
324
|
+
publicKey: string;
|
|
325
|
+
baseURL?: string;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
source?: string;
|
|
328
|
+
integration?: string;
|
|
329
|
+
userAgent?: CustomUserAgent;
|
|
330
|
+
retryThrottledRequestMaxTimes?: number;
|
|
331
|
+
retryNetworkErrorMaxTimes?: number;
|
|
332
|
+
};
|
|
333
|
+
/** Complete multipart uploading. */
|
|
334
|
+
export function multipartComplete(uuid: Uuid, { publicKey, baseURL, source, signal, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: MultipartCompleteOptions): Promise<FileInfo>;
|
|
335
|
+
export declare class UploadcareFile {
|
|
336
|
+
readonly uuid: Uuid;
|
|
337
|
+
readonly name: null | string;
|
|
338
|
+
readonly size: null | number;
|
|
339
|
+
readonly isStored: null | boolean;
|
|
340
|
+
readonly isImage: null | boolean;
|
|
341
|
+
readonly mimeType: null | string;
|
|
342
|
+
readonly cdnUrl: null | string;
|
|
343
|
+
readonly s3Url: null | string;
|
|
344
|
+
readonly originalFilename: null | string;
|
|
345
|
+
readonly imageInfo: null | ImageInfo;
|
|
346
|
+
readonly videoInfo: null | VideoInfo;
|
|
347
|
+
readonly contentInfo: null | ContentInfo;
|
|
348
|
+
readonly metadata: null | Metadata;
|
|
349
|
+
readonly s3Bucket: null | string;
|
|
350
|
+
constructor(fileInfo: FileInfo, { baseCDN, fileName }?: {
|
|
351
|
+
baseCDN?: string;
|
|
352
|
+
fileName?: string;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
export type FileFromOptions = {
|
|
356
|
+
publicKey: string;
|
|
357
|
+
fileName?: string;
|
|
358
|
+
baseURL?: string;
|
|
359
|
+
secureSignature?: string;
|
|
360
|
+
secureExpire?: string;
|
|
361
|
+
store?: StoreValue;
|
|
362
|
+
signal?: AbortSignal;
|
|
363
|
+
onProgress?: ProgressCallback;
|
|
364
|
+
source?: string;
|
|
365
|
+
integration?: string;
|
|
366
|
+
userAgent?: CustomUserAgent;
|
|
367
|
+
retryThrottledRequestMaxTimes?: number;
|
|
368
|
+
retryNetworkErrorMaxTimes?: number;
|
|
369
|
+
contentType?: string;
|
|
370
|
+
multipartMinFileSize?: number;
|
|
371
|
+
multipartChunkSize?: number;
|
|
372
|
+
maxConcurrentRequests?: number;
|
|
373
|
+
baseCDN?: string;
|
|
374
|
+
checkForUrlDuplicates?: boolean;
|
|
375
|
+
saveUrlForRecurrentUploads?: boolean;
|
|
376
|
+
pusherKey?: string;
|
|
377
|
+
metadata?: Metadata;
|
|
378
|
+
};
|
|
379
|
+
/** Uploads file from provided data. */
|
|
380
|
+
export declare function uploadFile(data: SupportedFileInput | Url | Uuid, { publicKey, fileName, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, contentType, multipartMinFileSize, multipartChunkSize, maxConcurrentRequests, baseCDN, checkForUrlDuplicates, saveUrlForRecurrentUploads, pusherKey, metadata }: FileFromOptions): Promise<UploadcareFile>;
|
|
381
|
+
export type DirectOptions = {
|
|
382
|
+
publicKey: string;
|
|
383
|
+
fileName?: string;
|
|
384
|
+
baseURL?: string;
|
|
385
|
+
secureSignature?: string;
|
|
386
|
+
secureExpire?: string;
|
|
387
|
+
store?: StoreValue;
|
|
388
|
+
contentType?: string;
|
|
389
|
+
signal?: AbortSignal;
|
|
390
|
+
onProgress?: ProgressCallback;
|
|
391
|
+
source?: string;
|
|
392
|
+
integration?: string;
|
|
393
|
+
userAgent?: CustomUserAgent;
|
|
394
|
+
retryThrottledRequestMaxTimes?: number;
|
|
395
|
+
retryNetworkErrorMaxTimes?: number;
|
|
396
|
+
baseCDN?: string;
|
|
397
|
+
metadata?: Metadata;
|
|
398
|
+
};
|
|
399
|
+
export declare const uploadDirect: (file: SupportedFileInput, { publicKey, fileName, baseURL, secureSignature, secureExpire, store, contentType, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, baseCDN, metadata }: DirectOptions) => Promise<UploadcareFile>;
|
|
400
|
+
export type FromUploadedOptions = {
|
|
401
|
+
publicKey: string;
|
|
402
|
+
fileName?: string;
|
|
403
|
+
baseURL?: string;
|
|
404
|
+
signal?: AbortSignal;
|
|
405
|
+
onProgress?: ProgressCallback;
|
|
406
|
+
source?: string;
|
|
407
|
+
integration?: string;
|
|
408
|
+
userAgent?: CustomUserAgent;
|
|
409
|
+
retryThrottledRequestMaxTimes?: number;
|
|
410
|
+
retryNetworkErrorMaxTimes?: number;
|
|
411
|
+
baseCDN?: string;
|
|
412
|
+
};
|
|
413
|
+
export declare const uploadFromUploaded: (uuid: Uuid, { publicKey, fileName, baseURL, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, baseCDN }: FromUploadedOptions) => Promise<UploadcareFile>;
|
|
414
|
+
export type UploadFromUrlOptions = {
|
|
415
|
+
baseCDN?: string;
|
|
416
|
+
onProgress?: ProgressCallback;
|
|
417
|
+
pusherKey?: string;
|
|
418
|
+
} & FromUrlOptions;
|
|
419
|
+
export declare const uploadFromUrl: (sourceUrl: string, { publicKey, fileName, baseURL, baseCDN, checkForUrlDuplicates, saveUrlForRecurrentUploads, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, pusherKey, metadata }: UploadFromUrlOptions) => Promise<UploadcareFile>;
|
|
420
|
+
export type MultipartOptions = {
|
|
421
|
+
publicKey: string;
|
|
422
|
+
contentType?: string;
|
|
423
|
+
multipartChunkSize?: number;
|
|
424
|
+
fileName?: string;
|
|
425
|
+
fileSize?: number;
|
|
426
|
+
baseURL?: string;
|
|
427
|
+
secureSignature?: string;
|
|
428
|
+
secureExpire?: string;
|
|
429
|
+
store?: StoreValue;
|
|
430
|
+
signal?: AbortSignal;
|
|
431
|
+
onProgress?: ProgressCallback<ComputableProgressInfo>;
|
|
432
|
+
source?: string;
|
|
433
|
+
integration?: string;
|
|
434
|
+
userAgent?: CustomUserAgent;
|
|
435
|
+
retryThrottledRequestMaxTimes?: number;
|
|
436
|
+
retryNetworkErrorMaxTimes?: number;
|
|
437
|
+
maxConcurrentRequests?: number;
|
|
438
|
+
baseCDN?: string;
|
|
439
|
+
metadata?: Metadata;
|
|
440
|
+
};
|
|
441
|
+
export declare const uploadMultipart: (file: SupportedFileInput, { publicKey, fileName, fileSize, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, contentType, multipartChunkSize, maxConcurrentRequests, baseCDN, metadata }: MultipartOptions) => Promise<UploadcareFile>;
|
|
442
|
+
export declare class UploadcareGroup {
|
|
443
|
+
readonly uuid: GroupId;
|
|
444
|
+
readonly filesCount: string;
|
|
445
|
+
readonly totalSize: number;
|
|
446
|
+
readonly isStored: boolean;
|
|
447
|
+
readonly isImage: boolean;
|
|
448
|
+
readonly cdnUrl: string;
|
|
449
|
+
readonly files: UploadcareFile[];
|
|
450
|
+
readonly createdAt: string;
|
|
451
|
+
readonly storedAt: string | null;
|
|
452
|
+
constructor(groupInfo: GroupInfo, files: UploadcareFile[]);
|
|
453
|
+
}
|
|
454
|
+
export type GroupFromOptions = {
|
|
455
|
+
jsonpCallback?: string;
|
|
456
|
+
};
|
|
457
|
+
export declare function uploadFileGroup(data: SupportedFileInput[] | Url[] | Uuid[], { publicKey, fileName, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, contentType, multipartChunkSize, baseCDN, checkForUrlDuplicates, saveUrlForRecurrentUploads, jsonpCallback }: FileFromOptions & GroupFromOptions): Promise<UploadcareGroup>;
|
|
458
|
+
export declare class UploadClient {
|
|
459
|
+
private settings;
|
|
460
|
+
constructor(settings: Settings);
|
|
461
|
+
updateSettings(newSettings: Settings): void;
|
|
462
|
+
getSettings(): Settings;
|
|
463
|
+
base(file: SupportedFileInput, options?: Partial<BaseOptions>): Promise<BaseResponse>;
|
|
464
|
+
info(uuid: Uuid, options?: Partial<InfoOptions>): Promise<FileInfo>;
|
|
465
|
+
fromUrl(sourceUrl: Url, options?: Partial<FromUrlOptions>): Promise<FromUrlResponse>;
|
|
466
|
+
fromUrlStatus(token: Token, options?: Partial<FromUrlStatusOptions>): Promise<FromUrlStatusResponse>;
|
|
467
|
+
group(uuids: Uuid[], options?: Partial<GroupOptions>): Promise<GroupInfo>;
|
|
468
|
+
groupInfo(id: GroupId, options?: Partial<GroupInfoOptions>): Promise<GroupInfo>;
|
|
469
|
+
multipartStart(size: number, options?: Partial<MultipartStartOptions>): Promise<MultipartStartResponse>;
|
|
470
|
+
multipartUpload(part: Sliceable, url: MultipartPart, options?: Partial<MultipartUploadOptions>): Promise<MultipartUploadResponse>;
|
|
471
|
+
multipartComplete(uuid: Uuid, options?: Partial<MultipartCompleteOptions>): Promise<FileInfo>;
|
|
472
|
+
uploadFile(data: SupportedFileInput | Url | Uuid, options?: Partial<FileFromOptions>): Promise<UploadcareFile>;
|
|
473
|
+
uploadFileGroup(data: SupportedFileInput[] | Url[] | Uuid[], options?: Partial<FileFromOptions & GroupFromOptions>): Promise<UploadcareGroup>;
|
|
474
|
+
}
|
|
475
|
+
export type Headers = {
|
|
476
|
+
[key: string]: string | string[] | undefined;
|
|
477
|
+
};
|
|
478
|
+
export type ErrorRequestInfo = {
|
|
479
|
+
method?: string;
|
|
480
|
+
url: string;
|
|
481
|
+
query?: string;
|
|
482
|
+
data?: NodeFormData | FormData | SupportedFileInput;
|
|
483
|
+
headers?: Headers;
|
|
484
|
+
};
|
|
485
|
+
export type ErrorResponseInfo = {
|
|
486
|
+
error?: {
|
|
487
|
+
statusCode: number;
|
|
488
|
+
content: string;
|
|
489
|
+
errorCode: string;
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
export declare class UploadClientError extends Error {
|
|
493
|
+
isCancel?: boolean;
|
|
494
|
+
readonly code?: string;
|
|
495
|
+
readonly request?: ErrorRequestInfo;
|
|
496
|
+
readonly response?: ErrorResponseInfo;
|
|
497
|
+
readonly headers?: Headers;
|
|
498
|
+
constructor(message: string, code?: string, request?: ErrorRequestInfo, response?: ErrorResponseInfo, headers?: Headers);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export {};
|
|
@@ -90,6 +90,7 @@ function retrier(fn, options = defaultOptions) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
class UploadcareNetworkError extends Error {
|
|
93
|
+
originalProgressEvent;
|
|
93
94
|
constructor(progressEvent) {
|
|
94
95
|
super();
|
|
95
96
|
this.name = 'UploadcareNetworkError';
|
|
@@ -111,9 +112,9 @@ const onCancel = (signal, callback) => {
|
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
class CancelError extends Error {
|
|
115
|
+
isCancel = true;
|
|
114
116
|
constructor(message = 'Request canceled') {
|
|
115
117
|
super(message);
|
|
116
|
-
this.isCancel = true;
|
|
117
118
|
Object.setPrototypeOf(this, CancelError.prototype);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
@@ -313,7 +314,7 @@ const isFileValue = (value) => !!value &&
|
|
|
313
314
|
function collectParams(params, inputKey, inputValue) {
|
|
314
315
|
if (isFileValue(inputValue)) {
|
|
315
316
|
const { name, contentType } = inputValue;
|
|
316
|
-
const file = transformFile(inputValue.data, name, contentType);
|
|
317
|
+
const file = transformFile(inputValue.data, name, contentType ?? defaultContentType);
|
|
317
318
|
const options = getFileOptions({ name, contentType });
|
|
318
319
|
params.push([inputKey, file, ...options]);
|
|
319
320
|
}
|
|
@@ -347,6 +348,11 @@ function buildFormData(options) {
|
|
|
347
348
|
}
|
|
348
349
|
|
|
349
350
|
class UploadClientError extends Error {
|
|
351
|
+
isCancel;
|
|
352
|
+
code;
|
|
353
|
+
request;
|
|
354
|
+
response;
|
|
355
|
+
headers;
|
|
350
356
|
constructor(message, code, request, response, headers) {
|
|
351
357
|
super();
|
|
352
358
|
this.name = 'UploadClientError';
|
|
@@ -765,20 +771,21 @@ function isReadyPoll({ file, publicKey, baseURL, source, integration, userAgent,
|
|
|
765
771
|
}
|
|
766
772
|
|
|
767
773
|
class UploadcareFile {
|
|
774
|
+
uuid;
|
|
775
|
+
name = null;
|
|
776
|
+
size = null;
|
|
777
|
+
isStored = null;
|
|
778
|
+
isImage = null;
|
|
779
|
+
mimeType = null;
|
|
780
|
+
cdnUrl = null;
|
|
781
|
+
s3Url = null;
|
|
782
|
+
originalFilename = null;
|
|
783
|
+
imageInfo = null;
|
|
784
|
+
videoInfo = null;
|
|
785
|
+
contentInfo = null;
|
|
786
|
+
metadata = null;
|
|
787
|
+
s3Bucket = null;
|
|
768
788
|
constructor(fileInfo, { baseCDN = defaultSettings.baseCDN, fileName } = {}) {
|
|
769
|
-
this.name = null;
|
|
770
|
-
this.size = null;
|
|
771
|
-
this.isStored = null;
|
|
772
|
-
this.isImage = null;
|
|
773
|
-
this.mimeType = null;
|
|
774
|
-
this.cdnUrl = null;
|
|
775
|
-
this.s3Url = null;
|
|
776
|
-
this.originalFilename = null;
|
|
777
|
-
this.imageInfo = null;
|
|
778
|
-
this.videoInfo = null;
|
|
779
|
-
this.contentInfo = null;
|
|
780
|
-
this.metadata = null;
|
|
781
|
-
this.s3Bucket = null;
|
|
782
789
|
const { uuid, s3Bucket } = fileInfo;
|
|
783
790
|
const cdnUrl = getUrl(baseCDN, `${uuid}/`);
|
|
784
791
|
const s3Url = s3Bucket
|
|
@@ -895,9 +902,7 @@ const race = (fns, { signal } = {}) => {
|
|
|
895
902
|
var WebSocket = window.WebSocket;
|
|
896
903
|
|
|
897
904
|
class Events {
|
|
898
|
-
|
|
899
|
-
this.events = Object.create({});
|
|
900
|
-
}
|
|
905
|
+
events = Object.create({});
|
|
901
906
|
emit(event, data) {
|
|
902
907
|
this.events[event]?.forEach((fn) => fn(data));
|
|
903
908
|
}
|
|
@@ -925,13 +930,15 @@ const response = (type, data) => {
|
|
|
925
930
|
return { status: Status.Error, ...data };
|
|
926
931
|
};
|
|
927
932
|
class Pusher {
|
|
933
|
+
key;
|
|
934
|
+
disconnectTime;
|
|
935
|
+
ws = undefined;
|
|
936
|
+
queue = [];
|
|
937
|
+
isConnected = false;
|
|
938
|
+
subscribers = 0;
|
|
939
|
+
emmitter = new Events();
|
|
940
|
+
disconnectTimeoutId = null;
|
|
928
941
|
constructor(pusherKey, disconnectTime = 30000) {
|
|
929
|
-
this.ws = undefined;
|
|
930
|
-
this.queue = [];
|
|
931
|
-
this.isConnected = false;
|
|
932
|
-
this.subscribers = 0;
|
|
933
|
-
this.emmitter = new Events();
|
|
934
|
-
this.disconnectTimeoutId = null;
|
|
935
942
|
this.key = pusherKey;
|
|
936
943
|
this.disconnectTime = disconnectTime;
|
|
937
944
|
}
|
|
@@ -1319,7 +1326,7 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1319
1326
|
});
|
|
1320
1327
|
};
|
|
1321
1328
|
};
|
|
1322
|
-
contentType
|
|
1329
|
+
contentType ||= getContentType(file);
|
|
1323
1330
|
return multipartStart(size, {
|
|
1324
1331
|
publicKey,
|
|
1325
1332
|
contentType,
|
|
@@ -1469,8 +1476,16 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
|
|
|
1469
1476
|
}
|
|
1470
1477
|
|
|
1471
1478
|
class UploadcareGroup {
|
|
1479
|
+
uuid;
|
|
1480
|
+
filesCount;
|
|
1481
|
+
totalSize;
|
|
1482
|
+
isStored;
|
|
1483
|
+
isImage;
|
|
1484
|
+
cdnUrl;
|
|
1485
|
+
files;
|
|
1486
|
+
createdAt;
|
|
1487
|
+
storedAt = null;
|
|
1472
1488
|
constructor(groupInfo, files) {
|
|
1473
|
-
this.storedAt = null;
|
|
1474
1489
|
this.uuid = groupInfo.id;
|
|
1475
1490
|
this.filesCount = groupInfo.filesCount;
|
|
1476
1491
|
this.totalSize = Object.values(groupInfo.files).reduce((acc, file) => acc + file.size, 0);
|
|
@@ -1583,6 +1598,7 @@ const populateOptionsWithSettings = (options, settings) => ({
|
|
|
1583
1598
|
...options
|
|
1584
1599
|
});
|
|
1585
1600
|
class UploadClient {
|
|
1601
|
+
settings;
|
|
1586
1602
|
constructor(settings) {
|
|
1587
1603
|
this.settings = Object.assign({}, defaultSettings, settings);
|
|
1588
1604
|
}
|