@uploadcare/upload-client 6.4.0 → 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} +47 -29
- package/dist/esm/index.node.d.mts +501 -0
- package/dist/{index.node.js → esm/index.node.mjs} +54 -33
- package/dist/esm/index.react-native.d.mts +501 -0
- package/dist/{index.react-native.js → esm/index.react-native.mjs} +47 -29
- package/dist/index.d.ts +59 -59
- package/package.json +27 -15
|
@@ -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
|
}
|
|
@@ -321,7 +322,7 @@ const isFileValue = (value) => !!value &&
|
|
|
321
322
|
function collectParams(params, inputKey, inputValue) {
|
|
322
323
|
if (isFileValue(inputValue)) {
|
|
323
324
|
const { name, contentType } = inputValue;
|
|
324
|
-
const file = transformFile(inputValue.data, name, contentType);
|
|
325
|
+
const file = transformFile(inputValue.data, name, contentType ?? defaultContentType);
|
|
325
326
|
const options = getFileOptions();
|
|
326
327
|
params.push([inputKey, file, ...options]);
|
|
327
328
|
}
|
|
@@ -355,6 +356,11 @@ function buildFormData(options) {
|
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
class UploadClientError extends Error {
|
|
359
|
+
isCancel;
|
|
360
|
+
code;
|
|
361
|
+
request;
|
|
362
|
+
response;
|
|
363
|
+
headers;
|
|
358
364
|
constructor(message, code, request, response, headers) {
|
|
359
365
|
super();
|
|
360
366
|
this.name = 'UploadClientError';
|
|
@@ -398,7 +404,7 @@ const getUrl = (base, path, query) => {
|
|
|
398
404
|
return url.toString();
|
|
399
405
|
};
|
|
400
406
|
|
|
401
|
-
var version = '6.4.
|
|
407
|
+
var version = '6.4.1';
|
|
402
408
|
|
|
403
409
|
const LIBRARY_NAME = 'UploadcareUploadClient';
|
|
404
410
|
const LIBRARY_VERSION = version;
|
|
@@ -773,20 +779,21 @@ function isReadyPoll({ file, publicKey, baseURL, source, integration, userAgent,
|
|
|
773
779
|
}
|
|
774
780
|
|
|
775
781
|
class UploadcareFile {
|
|
782
|
+
uuid;
|
|
783
|
+
name = null;
|
|
784
|
+
size = null;
|
|
785
|
+
isStored = null;
|
|
786
|
+
isImage = null;
|
|
787
|
+
mimeType = null;
|
|
788
|
+
cdnUrl = null;
|
|
789
|
+
s3Url = null;
|
|
790
|
+
originalFilename = null;
|
|
791
|
+
imageInfo = null;
|
|
792
|
+
videoInfo = null;
|
|
793
|
+
contentInfo = null;
|
|
794
|
+
metadata = null;
|
|
795
|
+
s3Bucket = null;
|
|
776
796
|
constructor(fileInfo, { baseCDN = defaultSettings.baseCDN, fileName } = {}) {
|
|
777
|
-
this.name = null;
|
|
778
|
-
this.size = null;
|
|
779
|
-
this.isStored = null;
|
|
780
|
-
this.isImage = null;
|
|
781
|
-
this.mimeType = null;
|
|
782
|
-
this.cdnUrl = null;
|
|
783
|
-
this.s3Url = null;
|
|
784
|
-
this.originalFilename = null;
|
|
785
|
-
this.imageInfo = null;
|
|
786
|
-
this.videoInfo = null;
|
|
787
|
-
this.contentInfo = null;
|
|
788
|
-
this.metadata = null;
|
|
789
|
-
this.s3Bucket = null;
|
|
790
797
|
const { uuid, s3Bucket } = fileInfo;
|
|
791
798
|
const cdnUrl = getUrl(baseCDN, `${uuid}/`);
|
|
792
799
|
const s3Url = s3Bucket
|
|
@@ -903,9 +910,7 @@ const race = (fns, { signal } = {}) => {
|
|
|
903
910
|
var WebSocket = window.WebSocket;
|
|
904
911
|
|
|
905
912
|
class Events {
|
|
906
|
-
|
|
907
|
-
this.events = Object.create({});
|
|
908
|
-
}
|
|
913
|
+
events = Object.create({});
|
|
909
914
|
emit(event, data) {
|
|
910
915
|
this.events[event]?.forEach((fn) => fn(data));
|
|
911
916
|
}
|
|
@@ -933,13 +938,15 @@ const response = (type, data) => {
|
|
|
933
938
|
return { status: Status.Error, ...data };
|
|
934
939
|
};
|
|
935
940
|
class Pusher {
|
|
941
|
+
key;
|
|
942
|
+
disconnectTime;
|
|
943
|
+
ws = undefined;
|
|
944
|
+
queue = [];
|
|
945
|
+
isConnected = false;
|
|
946
|
+
subscribers = 0;
|
|
947
|
+
emmitter = new Events();
|
|
948
|
+
disconnectTimeoutId = null;
|
|
936
949
|
constructor(pusherKey, disconnectTime = 30000) {
|
|
937
|
-
this.ws = undefined;
|
|
938
|
-
this.queue = [];
|
|
939
|
-
this.isConnected = false;
|
|
940
|
-
this.subscribers = 0;
|
|
941
|
-
this.emmitter = new Events();
|
|
942
|
-
this.disconnectTimeoutId = null;
|
|
943
950
|
this.key = pusherKey;
|
|
944
951
|
this.disconnectTime = disconnectTime;
|
|
945
952
|
}
|
|
@@ -1347,7 +1354,7 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
|
|
|
1347
1354
|
});
|
|
1348
1355
|
};
|
|
1349
1356
|
};
|
|
1350
|
-
contentType
|
|
1357
|
+
contentType ||= getContentType(file);
|
|
1351
1358
|
return multipartStart(size, {
|
|
1352
1359
|
publicKey,
|
|
1353
1360
|
contentType,
|
|
@@ -1497,8 +1504,16 @@ async function uploadFile(data, { publicKey, fileName, baseURL = defaultSettings
|
|
|
1497
1504
|
}
|
|
1498
1505
|
|
|
1499
1506
|
class UploadcareGroup {
|
|
1507
|
+
uuid;
|
|
1508
|
+
filesCount;
|
|
1509
|
+
totalSize;
|
|
1510
|
+
isStored;
|
|
1511
|
+
isImage;
|
|
1512
|
+
cdnUrl;
|
|
1513
|
+
files;
|
|
1514
|
+
createdAt;
|
|
1515
|
+
storedAt = null;
|
|
1500
1516
|
constructor(groupInfo, files) {
|
|
1501
|
-
this.storedAt = null;
|
|
1502
1517
|
this.uuid = groupInfo.id;
|
|
1503
1518
|
this.filesCount = groupInfo.filesCount;
|
|
1504
1519
|
this.totalSize = Object.values(groupInfo.files).reduce((acc, file) => acc + file.size, 0);
|
|
@@ -1539,7 +1554,7 @@ const isUrlArray = (data) => {
|
|
|
1539
1554
|
return true;
|
|
1540
1555
|
};
|
|
1541
1556
|
|
|
1542
|
-
function uploadFileGroup(data, { publicKey, fileName, baseURL = defaultSettings.baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, contentType, multipartChunkSize = defaultSettings.multipartChunkSize, baseCDN = defaultSettings.baseCDN, jsonpCallback }) {
|
|
1557
|
+
function uploadFileGroup(data, { publicKey, fileName, baseURL = defaultSettings.baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, contentType, multipartChunkSize = defaultSettings.multipartChunkSize, baseCDN = defaultSettings.baseCDN, checkForUrlDuplicates, saveUrlForRecurrentUploads, jsonpCallback }) {
|
|
1543
1558
|
if (!isFileDataArray(data) && !isUrlArray(data) && !isUuidArray(data)) {
|
|
1544
1559
|
throw new TypeError(`Group uploading from "${data}" is not supported`);
|
|
1545
1560
|
}
|
|
@@ -1579,7 +1594,9 @@ function uploadFileGroup(data, { publicKey, fileName, baseURL = defaultSettings.
|
|
|
1579
1594
|
retryNetworkErrorMaxTimes,
|
|
1580
1595
|
contentType,
|
|
1581
1596
|
multipartChunkSize,
|
|
1582
|
-
baseCDN
|
|
1597
|
+
baseCDN,
|
|
1598
|
+
checkForUrlDuplicates,
|
|
1599
|
+
saveUrlForRecurrentUploads
|
|
1583
1600
|
}))).then((files) => {
|
|
1584
1601
|
const uuids = files.map((file) => file.uuid);
|
|
1585
1602
|
return group(uuids, {
|
|
@@ -1609,6 +1626,7 @@ const populateOptionsWithSettings = (options, settings) => ({
|
|
|
1609
1626
|
...options
|
|
1610
1627
|
});
|
|
1611
1628
|
class UploadClient {
|
|
1629
|
+
settings;
|
|
1612
1630
|
constructor(settings) {
|
|
1613
1631
|
this.settings = Object.assign({}, defaultSettings, settings);
|
|
1614
1632
|
}
|